From f2e83987148ae62400dd060f741b740f3d19ede8 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Thu, 21 Mar 2019 13:13:01 +0100 Subject: [PATCH] fix angbotsposten --- entity/Offeritem_entity/Offeritem_entity.aod | 4 +++- .../entityfields/assignedto/valueProcess.js | 6 ++++++ .../entityfields/itemposition/valueProcess.js | 0 .../entityfields/product_id/onValueChange.js | 9 ++++++--- .../recordcontainers/db/conditionProcess.js | 2 +- .../recordcontainers/db/onDBInsert.js | 3 +-- entity/Orderitem_entity/Orderitem_entity.aod | 3 +-- .../entityfields/itemposition/valueProcess.js | 2 ++ .../data/example_product/PRODUCT_42154311.xml | 13 +++++++++++++ process/OfferOrder_lib/process.js | 17 +++++++++-------- 10 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 entity/Offeritem_entity/entityfields/assignedto/valueProcess.js create mode 100644 entity/Offeritem_entity/entityfields/itemposition/valueProcess.js create mode 100644 entity/Orderitem_entity/entityfields/itemposition/valueProcess.js diff --git a/entity/Offeritem_entity/Offeritem_entity.aod b/entity/Offeritem_entity/Offeritem_entity.aod index c32766528f..bc5dc6575a 100644 --- a/entity/Offeritem_entity/Offeritem_entity.aod +++ b/entity/Offeritem_entity/Offeritem_entity.aod @@ -12,6 +12,7 @@ </entityProvider> <entityField> <name>ASSIGNEDTO</name> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/assignedto/valueProcess.js</valueProcess> </entityField> <entityField> <name>DISCOUNT</name> @@ -33,6 +34,7 @@ <name>ITEMPOSITION</name> <title>Position</title> <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/itemposition/valueProcess.js</valueProcess> </entityField> <entityField> <name>ITEMSORT</name> @@ -80,7 +82,7 @@ <documentation>%aditoprj%/entity/Offeritem_entity/entityfields/quantity/documentation.adoc</documentation> <title>Quantity</title> <contentType>NUMBER</contentType> - <outputFormat>#,##0</outputFormat> + <outputFormat>#</outputFormat> <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/quantity/valueProcess.js</valueProcess> <onValueChange>%aditoprj%/entity/Offeritem_entity/entityfields/quantity/onValueChange.js</onValueChange> <onValueChangeTypes> diff --git a/entity/Offeritem_entity/entityfields/assignedto/valueProcess.js b/entity/Offeritem_entity/entityfields/assignedto/valueProcess.js new file mode 100644 index 0000000000..8f2c38c402 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/assignedto/valueProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("system.result"); +import("system.neon"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) + result.string("") \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/itemposition/valueProcess.js b/entity/Offeritem_entity/entityfields/itemposition/valueProcess.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/entity/Offeritem_entity/entityfields/product_id/onValueChange.js b/entity/Offeritem_entity/entityfields/product_id/onValueChange.js index da456d1c46..65c4f6f6bc 100644 --- a/entity/Offeritem_entity/entityfields/product_id/onValueChange.js +++ b/entity/Offeritem_entity/entityfields/product_id/onValueChange.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.vars"); import("system.neon"); import("Product_lib"); @@ -7,10 +8,11 @@ import("Entity_lib"); var pid = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.PRODUCT_ID")); if(pid != "") { - var curr = vars.exists("$param.Currency_param") ? vars.get("$param.Currency_param") : ""; + var currency = vars.exists("$param.Currency_param") ? vars.get("$param.Currency_param") : ""; var contactid = vars.exists("$param.ContactId_param") ? vars.get("$param.ContactId_param") : ""; - var PriceListFilter = { currency: curr, quantity: vars.get("$field.QUANTITY"), relationId: contactid }; + logging.log(currency) + var PriceListFilter = { currency: currency, quantity: vars.get("$field.QUANTITY"), relationId: contactid }; //TODO: loading from db until loading from Consumer is possible. var ProductDetails = ProductUtils.getProductDetails(pid, PriceListFilter, ["INFO"]); @@ -21,9 +23,10 @@ if(pid != "") neon.setFieldValue("$field.UNIT", ProductDetails.unit); neon.setFieldValue("$field.ITEMNAME", ProductDetails.productName); neon.setFieldValue("$field.INFO", ProductDetails.INFO); - + if(ProductDetails.PriceListToUse != null) { + logging.log(ProductDetails.PriceListToUse.price) neon.setFieldValue("$field.PRICE", ProductDetails.PriceListToUse.price); neon.setFieldValue("$field.VAT", ProductDetails.PriceListToUse.vat); } diff --git a/entity/Offeritem_entity/recordcontainers/db/conditionProcess.js b/entity/Offeritem_entity/recordcontainers/db/conditionProcess.js index 810d73b911..989688f833 100644 --- a/entity/Offeritem_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Offeritem_entity/recordcontainers/db/conditionProcess.js @@ -2,6 +2,6 @@ import("system.result"); import("system.vars"); if(vars.exists("$param.OfferId_param") && vars.get("$param.OfferId_param") != "") - result.string("OFFERITEM.OFFER_ID = ('" + vars.get("$param.OfferId_param") + "')"); + result.string("OFFERITEM.OFFER_ID = ('" + vars.get("$param.OfferId_param") + "')dd"); else result.string(""); \ No newline at end of file diff --git a/entity/Offeritem_entity/recordcontainers/db/onDBInsert.js b/entity/Offeritem_entity/recordcontainers/db/onDBInsert.js index ebfbe9a644..71fca5641e 100644 --- a/entity/Offeritem_entity/recordcontainers/db/onDBInsert.js +++ b/entity/Offeritem_entity/recordcontainers/db/onDBInsert.js @@ -12,8 +12,7 @@ if(oid != "") { var curr = vars.exists("$param.Currency_param") ? vars.get("$param.Currency_param") : ""; var contactid = vars.exists("$param.ContactId_param") ? vars.get("$param.ContactId_param") : ""; - - var oiUtils = new OfferItemUtils(vars.get("$field.OFFER_ID")); + var oiUtils = new OfferItemUtils(vars.get("$field.OFFER_ID")); oiUtils.insertPartsList(vars.get("$field.PRODUCT_ID"), vars.get("$field.OFFERITEMID"), curr, contactid); oiUtils.reOrgItems(); diff --git a/entity/Orderitem_entity/Orderitem_entity.aod b/entity/Orderitem_entity/Orderitem_entity.aod index 689247f0ed..21b47054a4 100644 --- a/entity/Orderitem_entity/Orderitem_entity.aod +++ b/entity/Orderitem_entity/Orderitem_entity.aod @@ -32,8 +32,7 @@ <name>ITEMPOSITION</name> <title>Position</title> <state>READONLY</state> - <valueProcess></valueProcess> - <onValidation></onValidation> + <valueProcess>%aditoprj%/entity/Orderitem_entity/entityfields/itemposition/valueProcess.js</valueProcess> </entityField> <entityField> <name>ITEMSORT</name> diff --git a/entity/Orderitem_entity/entityfields/itemposition/valueProcess.js b/entity/Orderitem_entity/entityfields/itemposition/valueProcess.js new file mode 100644 index 0000000000..92951e02d3 --- /dev/null +++ b/entity/Orderitem_entity/entityfields/itemposition/valueProcess.js @@ -0,0 +1,2 @@ +import("system.result"); +result.string("") \ No newline at end of file diff --git a/others/db_changes/data_alias/basic/2019.2/data/example_product/PRODUCT_42154311.xml b/others/db_changes/data_alias/basic/2019.2/data/example_product/PRODUCT_42154311.xml index ca0d647143..b4ed1504d2 100644 --- a/others/db_changes/data_alias/basic/2019.2/data/example_product/PRODUCT_42154311.xml +++ b/others/db_changes/data_alias/basic/2019.2/data/example_product/PRODUCT_42154311.xml @@ -41,6 +41,19 @@ <column name="STATUS" valueNumeric="1"/> <column name="UNIT" value="548ffe3b-466b-4c8f-97d6-e3ad23e33344"/> </insert> + <insert tableName="PRODUCTPRICE"> + <column name="PRODUCTPRICEID" value="c5b5bfce-2bec-4601-ba43-2567209bea04"/> + <column name="VALID_TO" valueDate="2058-10-31T00:00:00"/> + <column name="VALID_FROM" valueDate="2018-11-01T00:00:00"/> + <column name="PRICE" valueNumeric="106.00"/> + <column name="VAT" valueNumeric="19.00"/> + <column name="PRODUCT_ID" value="6e52e636-284d-454b-978c-8f58844c5c5b"/> + <column name="FROMQUANTITY" valueNumeric="1.00"/> + <column name="CURRENCY" value="EUR"/> + <column name="PRICELIST" value="02553fc7-4611-4914-8ff5-0b7c4e7531c9"/> + <column name="BUYSELL" value="SP"/> + </insert> + <insert tableName="PRODUCT"> <column name="PRODUCTID" value="072680e3-9e5d-4228-b5a8-f4acef8f2452"/> <column name="ADVERTISING" value="N"/> diff --git a/process/OfferOrder_lib/process.js b/process/OfferOrder_lib/process.js index 2473019db2..f1c7180310 100644 --- a/process/OfferOrder_lib/process.js +++ b/process/OfferOrder_lib/process.js @@ -7,6 +7,7 @@ import("system.eMath"); import("system.db"); import("Product_lib"); import("Money_lib"); +import("Sql_lib"); /** * Abstract class that provides methods for dealing with offer / order items. @@ -181,9 +182,11 @@ ItemUtils.prototype.initItemTree = function() { if (this.ItemTree == undefined) { this.ItemTree = {}; this.ItemIds = []; - var data = db.table("select " + this.tableName + "ITEMID, ASSIGNEDTO, ITEMPOSITION, ITEMSORT from " + this.tableName - + "ITEM where " + this.tableName + "_ID" + " = '" + this.offerOrderId + "' order by ITEMSORT"); - + var data = db.table(SqlCondition.begin() + .andPrepare(this.tableName + "ITEM." + this.tableName + "_ID", this.offerOrderId) + .buildSql("select " + this.tableName + "ITEMID, ASSIGNEDTO, ITEMPOSITION, ITEMSORT from " + this.tableName + "ITEM", + "1=2", "order by ITEMSORT")) + for (var i = 0; i < data.length; i++) { this.ItemTree[data[i][0]] = this._getItemTreeNodeObject(data[i][1], data[i][2], data[i][3]); @@ -414,8 +417,7 @@ ItemUtils.prototype.getNextItemPosition = function(assignedTo, tree, ids) { ids = this.ItemIds; var maxPos = ["0"]; - - if (assignedTo != "") { + if (assignedTo) { if (tree[assignedTo].ids.length < 1) { //first item in this level maxPos = tree[assignedTo].pos.split("."); maxPos = maxPos.concat(["0"]); //next level pos @@ -425,12 +427,11 @@ ItemUtils.prototype.getNextItemPosition = function(assignedTo, tree, ids) { } } else { if (ids.length > 0) { - maxPos[0] = this.ItemTree[ids[ids.length-1]].pos; + maxPos[0] = this.ItemTree[ids[ids.length-1]].pos.split(".")[0]; } } - maxPos[maxPos.length-1] = (Number(maxPos[maxPos.length-1]) + 1).toString(); - + return maxPos.join("."); } -- GitLab