diff --git a/entity/Offeritem_entity/Offeritem_entity.aod b/entity/Offeritem_entity/Offeritem_entity.aod index 6b565529443f73da3bcaf29879476f274b13e90d..d8cfad37c1414399ff010ec3dd1724b82b24c47c 100644 --- a/entity/Offeritem_entity/Offeritem_entity.aod +++ b/entity/Offeritem_entity/Offeritem_entity.aod @@ -296,6 +296,12 @@ <name>itemInsertStatements</name> <documentation>%aditoprj%/entity/Offeritem_entity/entityfields/iteminsertstatements/documentation.adoc</documentation> </entityField> + <entityField> + <name>currency</name> + <title>Currency</title> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/currency/valueProcess.js</valueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Offeritem_entity/entityfields/currency/valueProcess.js b/entity/Offeritem_entity/entityfields/currency/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..f125324e596f8c1180a1fbb47601c2a8f0ad95c0 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/currency/valueProcess.js @@ -0,0 +1,13 @@ +import("KeywordRegistry_basic"); +import("Keyword_lib"); +import("system.result"); +import("system.neon"); +import("system.vars"); + +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) +{ + if(vars.get("$param.Currency_param") && vars.get("$param.Currency_param") != "") + { + result.string(KeywordUtils.getViewValue($KeywordRegistry.currency(), vars.getString("$param.Currency_param"))); + } +} \ No newline at end of file diff --git a/entity/Orderitem_entity/Orderitem_entity.aod b/entity/Orderitem_entity/Orderitem_entity.aod index 68999920abfefb7875463dc38a5b1bca18e994dd..054bfac329c06b0fd0e546eb3176521adecb0b49 100644 --- a/entity/Orderitem_entity/Orderitem_entity.aod +++ b/entity/Orderitem_entity/Orderitem_entity.aod @@ -282,6 +282,12 @@ <name>itemInsertStatements</name> <documentation>%aditoprj%/entity/Orderitem_entity/entityfields/iteminsertstatements/documentation.adoc</documentation> </entityField> + <entityField> + <name>currency</name> + <title>Currency</title> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Orderitem_entity/entityfields/currency/valueProcess.js</valueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Orderitem_entity/entityfields/currency/valueProcess.js b/entity/Orderitem_entity/entityfields/currency/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..f125324e596f8c1180a1fbb47601c2a8f0ad95c0 --- /dev/null +++ b/entity/Orderitem_entity/entityfields/currency/valueProcess.js @@ -0,0 +1,13 @@ +import("KeywordRegistry_basic"); +import("Keyword_lib"); +import("system.result"); +import("system.neon"); +import("system.vars"); + +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) +{ + if(vars.get("$param.Currency_param") && vars.get("$param.Currency_param") != "") + { + result.string(KeywordUtils.getViewValue($KeywordRegistry.currency(), vars.getString("$param.Currency_param"))); + } +} \ No newline at end of file diff --git a/entity/Orderitem_entity/entityfields/product_id/onValueChange.js b/entity/Orderitem_entity/entityfields/product_id/onValueChange.js index 07ed27e6e201cab5dee47355979c9e9f9037c9ac..83f60fa1a8d9b90b49baed0d01c96d4a97e32fa1 100644 --- a/entity/Orderitem_entity/entityfields/product_id/onValueChange.js +++ b/entity/Orderitem_entity/entityfields/product_id/onValueChange.js @@ -25,10 +25,10 @@ if(pId != "" && vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) var partsListObject = oiUtils.insertPartsList(pId, vars.get("$field.SALESORDERITEMID"), curr, contactid, quantity, true, vars.get("$field.SALESORDER_ID"), sumUpTop); neon.setFieldValue("$field.itemInsertStatements", JSON.stringify(partsListObject["partsList"])); - if(sumUpTop)//only sum-up this price if there is no valid Price + if(sumUpTop && partsListObject["topProductInfo"])//only sum-up this price if there is no valid Price { - neon.setFieldValue("$field.PRICE", partsListObject["topProductInfo"]["price"]*quantity); - neon.setFieldValue("$field.VAT", partsListObject["topProductInfo"]["vat"]); + neon.setFieldValue("$field.PRICE", partsListObject["topProductInfo"]["price"]*quantity); + neon.setFieldValue("$field.VAT", partsListObject["topProductInfo"]["vat"]); } } diff --git a/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js b/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js index 48d5a48dba985e36efff385275848c0daf4cd188..de7096303d2fcaf0a4b3c31b8ea352577816af70 100644 --- a/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js +++ b/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js @@ -4,6 +4,14 @@ import("system.result"); import("system.vars"); import("Product_lib"); -var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP", true); +var currency; +if(vars.get("$param.OrderOfferInformations_param")) +{ + currency = JSON.parse(vars.get("$param.OrderOfferInformations_param")).Currency_param; +} + +var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP", true, currency); if (price.length > 0) - result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]); \ No newline at end of file +{ + result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]); +} \ No newline at end of file diff --git a/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js b/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js index 6981610dc3c3738e745b030d2c37468a7e48d186..b7abab4378b2ecedf8698130a15889ebc5e02ac5 100644 --- a/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js +++ b/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js @@ -4,6 +4,14 @@ import("system.result"); import("system.vars"); import("Product_lib"); -var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "SP", true); +var currency; +if(vars.get("$param.OrderOfferInformations_param")) +{ + currency = JSON.parse(vars.get("$param.OrderOfferInformations_param")).Currency_param; +} + +var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "SP", true, currency); if (price.length > 0) - result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]); \ No newline at end of file +{ + result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]); +} \ No newline at end of file diff --git a/neonView/OfferitemEdit_view/OfferitemEdit_view.aod b/neonView/OfferitemEdit_view/OfferitemEdit_view.aod index 0c19ce2dd173c2aeb2d075a287a54929bbc00f36..401e099fe0312e7b34c72860317857920b544d57 100644 --- a/neonView/OfferitemEdit_view/OfferitemEdit_view.aod +++ b/neonView/OfferitemEdit_view/OfferitemEdit_view.aod @@ -40,6 +40,10 @@ <name>2b635ddb-d52c-4063-af11-aea8eeee151b</name> <entityField>PRICE</entityField> </entityFieldLink> + <entityFieldLink> + <name>fa6d99df-4f30-4737-8064-28eb5c88f17f</name> + <entityField>currency</entityField> + </entityFieldLink> <entityFieldLink> <name>4f339738-6358-463e-b941-3b2693ab115a</name> <entityField>DISCOUNT</entityField> diff --git a/neonView/OrderitemEdit_view/OrderitemEdit_view.aod b/neonView/OrderitemEdit_view/OrderitemEdit_view.aod index 8149fa636066fe7f47e27e290d848834dcc53e1c..bc85773ca902dda4352de7775535c2477f566e8a 100644 --- a/neonView/OrderitemEdit_view/OrderitemEdit_view.aod +++ b/neonView/OrderitemEdit_view/OrderitemEdit_view.aod @@ -39,6 +39,10 @@ <name>f7bd09a0-ed27-4989-940e-e3baac4c3c80</name> <entityField>PRICE</entityField> </entityFieldLink> + <entityFieldLink> + <name>f4e3ecc2-6303-493b-aa5a-5d6b974ae9da</name> + <entityField>currency</entityField> + </entityFieldLink> <entityFieldLink> <name>2b38de6e-85de-479c-99fd-27ff0d2e1c33</name> <entityField>DISCOUNT</entityField> diff --git a/process/OfferOrder_lib/process.js b/process/OfferOrder_lib/process.js index 70aee7aa9870bd982648daabff7fc23a95400894..0d59b0439da82a04fa09d6806c28433205338e65 100644 --- a/process/OfferOrder_lib/process.js +++ b/process/OfferOrder_lib/process.js @@ -628,6 +628,11 @@ ItemUtils.product_IdOnValueChange = function (pProductId, pUid, pEntity) neon.setFieldValue("$field.PRICE", ProductDetails.PriceListToUse.price); neon.setFieldValue("$field.VAT", ProductDetails.PriceListToUse.vat); } + else + { + neon.setFieldValue("$field.PRICE", ""); + neon.setFieldValue("$field.VAT", 0); + } } }; @@ -669,7 +674,7 @@ ItemUtils.sumUpPricesWhenInserting = function (pStatements, pCorrectOrder, pTree let price = 0; if(pPriceObj[id]) { - price = pPriceObj[id]["price"]*pPriceObj[id]["quantity"]; + price = pPriceObj[id]["price"]*(pPriceObj[id]["quantity"] == undefined ? 1 : pPriceObj[id]["quantity"]); } calcPrice = eMath.addDec(price, calcPrice); if(pPriceObj[id] && pPriceObj[id]["vat"] && pPriceObj[id]["vat"] > 0) diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index 92cb931a3b2ba91ace549b09c770b8eec698953f..f6b58db1ec5ec0ff20a7dd12ffdecf6bcbb62bbc 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -29,12 +29,13 @@ function ProductUtils() {} * @param {String} pid ProductID * @param {String} buySell possible values: PP, SP * @param {String} [onlyStandard=false] if true, only standard price lists are selected. + * @param {String} pCurrency * * @example productUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP") * * @return {Array[]} currently valid product price with currency: [price, "CURRENCY", "VAT"] or [] if no price found */ -ProductUtils.getCurrentProductPrice = function(pid, buySell, onlyStandard) { +ProductUtils.getCurrentProductPrice = function(pid, buySell, onlyStandard, pCurrency) { if (pid != undefined && pid != "" && buySell != undefined && buySell != "") { var today = datetime.clearTime(vars.get("sys.date"), "utc"); @@ -49,6 +50,7 @@ ProductUtils.getCurrentProductPrice = function(pid, buySell, onlyStandard) { actualPriceSelect.and("PRODUCTPRICE.BUYSELL", buySell) .and("PRODUCTPRICE.PRODUCT_ID", pid) + .andIfSet("PRODUCTPRICE.CURRENCY", pCurrency) .and("PRODUCTPRICE.VALID_FROM", today, SqlBuilder.LESS_OR_EQUAL()) .and(newWhere("PRODUCTPRICE.VALID_TO", today, SqlBuilder.GREATER_OR_EQUAL()) .or("PRODUCTPRICE.VALID_TO is null"));