From 66e103369e269277a776bf7a7116399cf985715e Mon Sep 17 00:00:00 2001 From: Pascal Neub <p.neub@adito.de> Date: Tue, 7 Dec 2021 16:00:02 +0100 Subject: [PATCH] =?UTF-8?q?[Projekt:=20xRM-Sales][TicketNr.:=202002815][An?= =?UTF-8?q?gebotsposten=20k=C3=B6nnen=20nicht=20bei=20Angebot=20hinzugef?= =?UTF-8?q?=C3=BCgt=20werden]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entity/Offeritem_entity/afterSave.js | 6 +++++- process/OfferOrder_lib/process.js | 29 +++++++++++++++------------- process/Offer_lib/process.js | 29 +++++++++++++++------------- process/Order_lib/process.js | 27 ++++++++++++++------------ 4 files changed, 52 insertions(+), 39 deletions(-) diff --git a/entity/Offeritem_entity/afterSave.js b/entity/Offeritem_entity/afterSave.js index 0c2ebb01d11..0fc435de653 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 7d890d2866c..567c87350b0 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 15c7e2f1a78..4f4be22c23c 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 802648b9ffa..3cfcb2dc8c4 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]); } -- GitLab