diff --git a/entity/Offeritem_entity/afterSave.js b/entity/Offeritem_entity/afterSave.js index 0c2ebb01d11cf89a3f7f335596306896ba0ef16d..0fc435de6530b8e80d7e205b331ace1191a336ac 100644 --- a/entity/Offeritem_entity/afterSave.js +++ b/entity/Offeritem_entity/afterSave.js @@ -14,7 +14,11 @@ if(vars.get("$local.recordstate") == neon.OPERATINGSTATE_EDIT) if(!childIds.has(pId)) { childIds.add(pId); - offerItemUtils.ItemTree[pId].ids.forEach(_traverseChilds); + if(pId in offerItemUtils.ItemTree) + { + // catch errors if the item tree got calculated while inserting / deleting items + offerItemUtils.ItemTree[pId].ids.forEach(_traverseChilds); + } } } _traverseChilds(vars.get("$sys.uid")); diff --git a/process/OfferOrder_lib/process.js b/process/OfferOrder_lib/process.js index 7d890d2866c7f074a10c13b8506608fec261502d..567c87350b049c3f212d5782cdb6aeb3bbe77f68 100644 --- a/process/OfferOrder_lib/process.js +++ b/process/OfferOrder_lib/process.js @@ -354,7 +354,8 @@ ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, c //recursive function for building item insert statements function __itemInsertStatement(partsListObj, assignedTo, currency, contactId) { - for (var i = 0; i < partsListObj.ids.length; i++) { + for (var i = 0; i < partsListObj.ids.length; i++) + { var newid = util.getNewUUID(); self._appendNode(newid, assignedTo); var pos = self.ItemTree[newid].pos; @@ -383,7 +384,6 @@ ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, c priceObject[newid]["vat"] = vat; priceObject[newid]["quantity"] = P2pObject["quantity"]; } - } else if(pSumUpPrices)//also build priceObject if pSumUpPrices is set to true { @@ -396,16 +396,19 @@ ItemUtils.prototype.insertPartsList = function(columns, productId, assignedTo, c treeStructure = ItemUtils.buildTreeStructure(treeStructure, assignedTo, newid); } - var vals = [newid - , self.offerOrderId - , prodid - , ProductDetails.groupCode - , assignedTo - , ProductDetails.productName - , ProductDetails.unit - , price - , vat == null || vat == undefined || vat == "" ? 0 : vat - , P2pObject.quantity]; + var vals = [ + newid, + self.offerOrderId, + prodid, + ProductDetails.groupCode, + assignedTo, + ProductDetails.productName, + ProductDetails.unit, + price, + vat == null || vat == undefined || vat == "" ? 0 : vat, + P2pObject.quantity, + "0" + ]; if(_optionalIsIncluded(columns) == true)//add optional if needed @@ -913,4 +916,4 @@ ItemUtils.getNode = function (pObject, pName, pCurrName){ return res; } return null; - } \ No newline at end of file + } diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index 15c7e2f1a7843a5e40784d64a04249acff3a2cd8..4f4be22c23c572b7d6cdf2ef79027dab7cfa60a0 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -592,19 +592,22 @@ OfferItemUtils.prototype.roundPrice = function(pPrice) { OfferItemUtils.prototype.insertPartsList = function(pProductId, pAssignedTo, pCurrency, pContactId, pLanguage, pQuantity, pSumUpPrices, pOfferId, pSumUpTopPrice) { this.initItemTree(); - var cols = ["OFFERITEMID" - , "OFFER_ID" - , "PRODUCT_ID" - , "GROUPCODEID" - , "ASSIGNEDTO" - , "ITEMNAME" - , "UNIT" - , "PRICE" - , "VAT" - , "QUANTITY" - , "OPTIONAL" - , "ITEMPOSITION" - , "ITEMSORT"]; + var cols = [ + "OFFERITEMID", + "OFFER_ID", + "PRODUCT_ID", + "GROUPCODEID", + "ASSIGNEDTO", + "ITEMNAME", + "UNIT", + "PRICE", + "VAT", + "QUANTITY", + "DISCOUNT", + "OPTIONAL", + "ITEMPOSITION", + "ITEMSORT" + ]; return ItemUtils.prototype.insertPartsList.apply(this, [cols, pProductId, pAssignedTo, pCurrency, pContactId, [[["info", "INFO"], ["info", "( " + newSelect("DESCRIPTION") diff --git a/process/Order_lib/process.js b/process/Order_lib/process.js index 802648b9ffade4f8e137f796eb5722f5b11e4381..3cfcb2dc8c4f8cc328d1897faad8ef8173eaa509 100644 --- a/process/Order_lib/process.js +++ b/process/Order_lib/process.js @@ -704,18 +704,21 @@ OrderItemUtils.prototype.roundPrice = function(pPrice) { OrderItemUtils.prototype.insertPartsList = function(pProductId, pAssignedTo, pCurrency, pContactId, pQuantity, pSumUpPrices, pOrderId, pSumUpTopPrice) { this.initItemTree(); - var cols = ["SALESORDERITEMID" - , "SALESORDER_ID" - , "PRODUCT_ID" - , "GROUPCODEID" - , "ASSIGNEDTO" - , "ITEMNAME" - , "UNIT" - , "PRICE" - , "VAT" - , "QUANTITY" - , "ITEMPOSITION" - , "ITEMSORT"]; + var cols = [ + "SALESORDERITEMID", + "SALESORDER_ID", + "PRODUCT_ID", + "GROUPCODEID", + "ASSIGNEDTO", + "ITEMNAME", + "UNIT", + "PRICE", + "VAT", + "QUANTITY", + "DISCOUNT", + "ITEMPOSITION", + "ITEMSORT" + ]; return ItemUtils.prototype.insertPartsList.apply(this, [cols, pProductId, pAssignedTo, pCurrency, pContactId, undefined, pQuantity, pSumUpPrices, "Order", pOrderId, pAssignedTo, pSumUpTopPrice, true]); }