diff --git a/entity/Offeritem_entity/Offeritem_entity.aod b/entity/Offeritem_entity/Offeritem_entity.aod index 11fa6807168d590f9d7c5db1b894b0d63e4e0860..468d323d76c33bf46f45fb7c3bea9bddab852228 100644 --- a/entity/Offeritem_entity/Offeritem_entity.aod +++ b/entity/Offeritem_entity/Offeritem_entity.aod @@ -10,6 +10,7 @@ <grantCreateProcess>%aditoprj%/entity/Offeritem_entity/grantCreateProcess.js</grantCreateProcess> <grantUpdateProcess>%aditoprj%/entity/Offeritem_entity/grantUpdateProcess.js</grantUpdateProcess> <grantDeleteProcess>%aditoprj%/entity/Offeritem_entity/grantDeleteProcess.js</grantDeleteProcess> + <afterSave>%aditoprj%/entity/Offeritem_entity/afterSave.js</afterSave> <titlePlural>Offeritems</titlePlural> <recordContainer>db</recordContainer> <entityFields> @@ -18,6 +19,7 @@ </entityProvider> <entityField> <name>ASSIGNEDTO</name> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/assignedto/valueProcess.js</valueProcess> </entityField> <entityField> <name>DISCOUNT</name> @@ -265,6 +267,12 @@ <entityActionGroup> <name>group</name> <children> + <entityActionField> + <name>insertSubnode</name> + <title>Insert subnode</title> + <onActionProcess>%aditoprj%/entity/Offeritem_entity/entityfields/group/children/insertsubnode/onActionProcess.js</onActionProcess> + <stateProcess>%aditoprj%/entity/Offeritem_entity/entityfields/group/children/insertsubnode/stateProcess.js</stateProcess> + </entityActionField> <entityActionField> <name>moveUp</name> <onActionProcess>%aditoprj%/entity/Offeritem_entity/entityfields/group/children/moveup/onActionProcess.js</onActionProcess> @@ -296,6 +304,10 @@ <state>READONLY</state> <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/currency/valueProcess.js</valueProcess> </entityField> + <entityParameter> + <name>AssignedTo_param</name> + <expose v="true" /> + </entityParameter> <entityField> <name>OFFER_CODE</name> <title>Offer number</title> diff --git a/entity/Offeritem_entity/afterSave.js b/entity/Offeritem_entity/afterSave.js new file mode 100644 index 0000000000000000000000000000000000000000..7c2d55dd966eddba21d0bbc81d5202578886f64f --- /dev/null +++ b/entity/Offeritem_entity/afterSave.js @@ -0,0 +1,10 @@ +import("system.neon"); +import("system.vars"); +import("Offer_lib"); + +if(vars.get("$local.recordstate") == neon.OPERATINGSTATE_NEW) +{ + var oiUtils = new OfferItemUtils(vars.get("$field.OFFER_ID")); + oiUtils.reOrgItems(); + neon.refreshAll(); +} diff --git a/entity/Offeritem_entity/entityfields/assignedto/valueProcess.js b/entity/Offeritem_entity/entityfields/assignedto/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..bbde8dea6b2ea6dce3e1284e78334a24623fb1ba --- /dev/null +++ b/entity/Offeritem_entity/entityfields/assignedto/valueProcess.js @@ -0,0 +1,5 @@ +import("system.result"); +import("system.vars"); + +var assignedTo = vars.get("$param.AssignedTo_param"); +assignedTo && result.string(assignedTo); diff --git a/entity/Offeritem_entity/entityfields/group/children/insertsubnode/onActionProcess.js b/entity/Offeritem_entity/entityfields/group/children/insertsubnode/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..456e0cc7070a4c5318834277cf7e21d29054d6d1 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/group/children/insertsubnode/onActionProcess.js @@ -0,0 +1,12 @@ +import("system.neonFilter"); +import("system.neon"); +import("system.vars"); + +neon.openContextWithRecipe(vars.get("$sys.currentcontextname"), null, neonFilter.createEntityRecordsRecipeBuilder().parameters({ + ContactId_param: vars.get("$param.ContactId_param"), + OfferId_param: vars.get("$param.OfferId_param"), + ProductId_param: vars.get("$param.ProductId_param"), + Currency_param: vars.get("$param.Currency_param"), + Discount_param: vars.get("$param.Discount_param"), + AssignedTo_param: vars.get("$sys.uid") +}).toString(), neon.OPERATINGSTATE_NEW); diff --git a/entity/Offeritem_entity/entityfields/group/children/insertsubnode/stateProcess.js b/entity/Offeritem_entity/entityfields/group/children/insertsubnode/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5ba1e5ac67bc1f57c8df368230755af1bd132b29 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/group/children/insertsubnode/stateProcess.js @@ -0,0 +1,11 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); +import("Offer_lib"); + +var res = neon.COMPONENTSTATE_DISABLED; +if(OfferUtils.isEditable(vars.get("$param.OfferStatus_param"))) +{ + res = neon.COMPONENTSTATE_EDITABLE; +} +result.string(res); diff --git a/entity/Offeritem_entity/grantDeleteProcess.js b/entity/Offeritem_entity/grantDeleteProcess.js index 97dc6583f5a2a29fe03fc9342fdb814093bdbc97..f23d205f0cd1ac600e41119d3532531960b0ee57 100644 --- a/entity/Offeritem_entity/grantDeleteProcess.js +++ b/entity/Offeritem_entity/grantDeleteProcess.js @@ -1,24 +1,5 @@ -import("Sql_lib"); -import("system.vars"); import("system.result"); +import("system.vars"); import("Offer_lib"); -var canDelete = false; -if(OfferUtils.isDeletable(vars.get("$param.OfferStatus_param"))) -{ - var offerItemIds = vars.get("$sys.selection"); - - if(offerItemIds.length == 1 && offerItemIds[0] != null) - { - assignedTo = newSelect("OFFERITEM.ASSIGNEDTO") - .from("OFFERITEM") - .where("OFFERITEM.OFFERITEMID", offerItemIds[0]) - .orderBy("ITEMPOSITION desc") - .cell(); - if(assignedTo == "")//topItem - { - canDelete = true; - } - } -} -result.object(canDelete); \ No newline at end of file +result.object(OfferUtils.isDeletable(vars.get("$param.OfferStatus_param"))); diff --git a/entity/Orderitem_entity/Orderitem_entity.aod b/entity/Orderitem_entity/Orderitem_entity.aod index d88495d1e76c565cfe288026f0688f41ad2c3fc6..dbdcda99143f4bb0b4db861f5cb61c3d057db778 100644 --- a/entity/Orderitem_entity/Orderitem_entity.aod +++ b/entity/Orderitem_entity/Orderitem_entity.aod @@ -10,6 +10,7 @@ <grantCreateProcess>%aditoprj%/entity/Orderitem_entity/grantCreateProcess.js</grantCreateProcess> <grantUpdateProcess>%aditoprj%/entity/Orderitem_entity/grantUpdateProcess.js</grantUpdateProcess> <grantDeleteProcess>%aditoprj%/entity/Orderitem_entity/grantDeleteProcess.js</grantDeleteProcess> + <afterSave>%aditoprj%/entity/Orderitem_entity/afterSave.js</afterSave> <titlePlural>Orderitems</titlePlural> <recordContainer>db</recordContainer> <entityFields> @@ -18,6 +19,7 @@ </entityProvider> <entityField> <name>ASSIGNEDTO</name> + <valueProcess>%aditoprj%/entity/Orderitem_entity/entityfields/assignedto/valueProcess.js</valueProcess> </entityField> <entityField> <name>DISCOUNT</name> @@ -243,6 +245,12 @@ <entityActionGroup> <name>group</name> <children> + <entityActionField> + <name>insertSubnode</name> + <title>Insert subnode</title> + <onActionProcess>%aditoprj%/entity/Orderitem_entity/entityfields/group/children/insertsubnode/onActionProcess.js</onActionProcess> + <stateProcess>%aditoprj%/entity/Orderitem_entity/entityfields/group/children/insertsubnode/stateProcess.js</stateProcess> + </entityActionField> <entityActionField> <name>moveUp</name> <onActionProcess>%aditoprj%/entity/Orderitem_entity/entityfields/group/children/moveup/onActionProcess.js</onActionProcess> @@ -279,6 +287,10 @@ <state>READONLY</state> <valueProcess>%aditoprj%/entity/Orderitem_entity/entityfields/currency/valueProcess.js</valueProcess> </entityField> + <entityParameter> + <name>AssignedTo_param</name> + <expose v="true" /> + </entityParameter> <entityField> <name>ORDER_CODE</name> <title>Receipt number</title> diff --git a/entity/Orderitem_entity/afterSave.js b/entity/Orderitem_entity/afterSave.js new file mode 100644 index 0000000000000000000000000000000000000000..7526b591eca1914fe359f020220ef00400c153af --- /dev/null +++ b/entity/Orderitem_entity/afterSave.js @@ -0,0 +1,10 @@ +import("system.neon"); +import("system.vars"); +import("Order_lib"); + +if(vars.get("$local.recordstate") == neon.OPERATINGSTATE_NEW) +{ + var oiUtils = new OrderItemUtils(vars.get("$field.SALESORDER_ID")); + oiUtils.reOrgItems(); + neon.refreshAll(); +} diff --git a/entity/Orderitem_entity/entityfields/assignedto/valueProcess.js b/entity/Orderitem_entity/entityfields/assignedto/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..bbde8dea6b2ea6dce3e1284e78334a24623fb1ba --- /dev/null +++ b/entity/Orderitem_entity/entityfields/assignedto/valueProcess.js @@ -0,0 +1,5 @@ +import("system.result"); +import("system.vars"); + +var assignedTo = vars.get("$param.AssignedTo_param"); +assignedTo && result.string(assignedTo); diff --git a/entity/Orderitem_entity/entityfields/group/children/insertsubnode/onActionProcess.js b/entity/Orderitem_entity/entityfields/group/children/insertsubnode/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..fa085e2b7cd98c641f1e5e6681ebcf7c6a57f462 --- /dev/null +++ b/entity/Orderitem_entity/entityfields/group/children/insertsubnode/onActionProcess.js @@ -0,0 +1,13 @@ +import("system.neonFilter"); +import("system.logging"); +import("system.neon"); +import("system.vars"); + +neon.openContextWithRecipe(vars.get("$sys.currentcontextname"), null, neonFilter.createEntityRecordsRecipeBuilder().parameters({ + ContactId_param: vars.get("$param.ContactId_param"), + OrderId_param: vars.get("$param.OrderId_param"), + ProductId_param: vars.get("$param.ProductId_param"), + Currency_param: vars.get("$param.Currency_param"), + Discount_param: vars.get("$param.Discount_param"), + AssignedTo_param: vars.get("$sys.uid") +}).toString(), neon.OPERATINGSTATE_NEW); diff --git a/entity/Orderitem_entity/entityfields/group/children/insertsubnode/stateProcess.js b/entity/Orderitem_entity/entityfields/group/children/insertsubnode/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..ab4319e289d632c4168cccca2761b4bf7212a8e2 --- /dev/null +++ b/entity/Orderitem_entity/entityfields/group/children/insertsubnode/stateProcess.js @@ -0,0 +1,33 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); +import("system.db"); +import("Sql_lib"); +import("Order_lib"); + +var itemcount = newSelect("count(*)") + .from("SALESORDERITEM") + .whereIfSet("SALESORDERITEM.SALESORDER_ID", "$field.SALESORDER_ID") + .cell(true, "0"); + +var res; +if (vars.get("$field.OrderStatus") == undefined) +{ + res = neon.COMPONENTSTATE_DISABLED; +} +else if (itemcount == "0" && vars.get("$field.OrderStatus") == "1" ) +{ + res = neon.COMPONENTSTATE_DISABLED; +} +else if (itemcount == "0" && vars.get("$field.OrderStatus") == "0") +{ + res = neon.COMPONENTSTATE_EDITABLE; +} +else +{ + res = OrderUtils.isEditable(vars.get("$field.OrderStatus") + ? neon.COMPONENTSTATE_EDITABLE + : neon.COMPONENTSTATE_DISABLED + ); +} +result.string(res); diff --git a/entity/Orderitem_entity/grantDeleteProcess.js b/entity/Orderitem_entity/grantDeleteProcess.js index 56d26c9ab2c9703e5c0bcd19b25c826057e72802..ec8d83f2d99ed83184ba76936bfc21468e95fbcd 100644 --- a/entity/Orderitem_entity/grantDeleteProcess.js +++ b/entity/Orderitem_entity/grantDeleteProcess.js @@ -1,24 +1,5 @@ -import("Order_lib"); -import("Sql_lib"); -import("system.vars"); import("system.result"); +import("system.vars"); +import("Order_lib"); -var canDelete = false; -if(OrderUtils.isDeletable(vars.get("$param.OrderStatus_param"))) -{ - var orderItemIds = vars.get("$sys.selection"); - - if(orderItemIds.length == 1 && orderItemIds[0] != null) - { - assignedTo = newSelect("SALESORDERITEM.ASSIGNEDTO") - .from("SALESORDERITEM") - .where("SALESORDERITEM.SALESORDERITEMID", orderItemIds[0]) - .orderBy("ITEMPOSITION desc") - .cell(); - if(assignedTo == "")//topItem - { - canDelete = true; - } - } -} -result.object(canDelete); \ No newline at end of file +result.object(OrderUtils.isDeletable(vars.get("$param.OrderStatus_param"))); diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 1efadae4992ea4d1fce88382d1cd0dd433142c88..0b73b03f7ebbd7abe80fb1d4b1bc2b5ed84064e5 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -14655,6 +14655,10 @@ Bitte Datumseingabe prüfen</value> <key>Offers / Receipts</key> <value>Angebote / Belege</value> </entry> + <entry> + <key>Insert subnode</key> + <value>Unterposten einfügen</value> + </entry> <entry> <key>Calculate sum</key> <value>Summe berechnen</value> diff --git a/process/OfferOrder_lib/process.js b/process/OfferOrder_lib/process.js index 7d890d2866c7f074a10c13b8506608fec261502d..5ef98cc5d6fb90b4d6b994d079f80f8814c0b75e 100644 --- a/process/OfferOrder_lib/process.js +++ b/process/OfferOrder_lib/process.js @@ -467,6 +467,16 @@ ItemUtils.prototype.deletePartsList = function(itemId) { function _deleteNode(pItemId) { //delete Object property delete self.ItemTree[pItemId]; + + // delete id references + for(var currItemId in self.ItemTree) + { + var idsIdx = self.ItemTree[currItemId].ids.indexOf(pItemId); + if (idsIdx >= 0) + { + self.ItemTree[currItemId].ids.splice(idsIdx, 1); + } + } //delete id in global Array "ItemIds" var idx = self.ItemIds.indexOf(pItemId);