Skip to content
Snippets Groups Projects
Verified Commit 9bc0a3ff authored by Pascal Neub's avatar Pascal Neub
Browse files

[Projekt: xRM-Sales][TicketNr.: 2002123][Fehler beim Hinzufügen eines Produktes im Angebot]

parent 7669c23b
No related branches found
No related tags found
No related merge requests found
......@@ -764,15 +764,14 @@ ItemUtils.sumUpPricesWhenInserting = function (pStatements, pCorrectOrder, pTree
//We want to sum up the prices directly under the current item to calculate the price if we don't have an valid price for them
function _handleSumUpPricesOfItems(pOrder, pTreestruct, pSumUpPrices, pPriceObj, pQuantity, pStatements)
{
var currentStruc = pTreestruct;
var sumUpPrices = pSumUpPrices;
var quantity = pQuantity;
var order = pOrder;
var summandObject = {};
var calculatedPrices = {};
var priceObj = pPriceObj;
for (var i = order.length; i > -1; i--)//we do this backwards because otherwiese we would run into problems when trying to build the sum (we could have items without an price yet)
var priceObj = Object.assign({}, pPriceObj); // shallow copy object
for (var i = order.length; i > -1; i--) // we do this backwards because otherwiese we would run into problems when trying to build the sum (we could have items without an price yet)
{
if(sumUpPrices.hasOwnProperty(order[i]))
{
......@@ -784,12 +783,12 @@ ItemUtils.sumUpPricesWhenInserting = function (pStatements, pCorrectOrder, pTree
var childPrice;
if(pPriceObj[child] != undefined)
{
childPrice = priceObj[child]["price"]*priceObj[child]["quantity"]
childPrice = priceObj[child]["price"]*priceObj[child]["quantity"];
}
else if(summandObject[child] != undefined && summandObject[child][child] != undefined)
{
childPrice = priceObj[Object.keys(summandObject[child][child])[0]]["price"]*priceObj[child]["quantity"]
vat = pPriceObj[Object.keys(summandObject[child][child])[0]]["vat"]
childPrice = priceObj[Object.keys(summandObject[child][child])[0]]["price"]*priceObj[child]["quantity"];
vat = pPriceObj[Object.keys(summandObject[child][child])[0]]["vat"];
}
else
{
......@@ -809,8 +808,6 @@ ItemUtils.sumUpPricesWhenInserting = function (pStatements, pCorrectOrder, pTree
priceObj[order[i]] = {};
priceObj[order[i]]["price"] = calcPrice*sumUpPrices[order[i]];
priceObj[order[i]]["vat"] = vat;
}
}
......@@ -838,7 +835,7 @@ ItemUtils.sumUpPricesWhenInserting = function (pStatements, pCorrectOrder, pTree
}
}
}
};
}
/**
* Recursive function to build the tree structure so we can later sum up the prices accordingly (call for every item (top-down))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment