diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod index c05681af0543e0adfdf905f424a06e98b44ea7ae..ab14630e7b739493e1533938f71e551befd0b599 100644 --- a/entity/Product_entity/Product_entity.aod +++ b/entity/Product_entity/Product_entity.aod @@ -62,20 +62,18 @@ <mandatory v="true" /> </entityField> <entityField> - <name>currentPurchasePriceId</name> + <name>currentPurchasePrice</name> <title>Curr. purchase price</title> - <contentType>NUMBER</contentType> - <outputFormat>#,##0.00 €</outputFormat> + <contentType>TEXT</contentType> <state>READONLY</state> - <valueProcess>%aditoprj%/entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js</valueProcess> + <valueProcess>%aditoprj%/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js</valueProcess> </entityField> <entityField> - <name>currentSalesPriceId</name> + <name>currentSalesPrice</name> <title>Curr. sales price</title> - <contentType>NUMBER</contentType> - <outputFormat>#,##0.00 €</outputFormat> + <contentType>TEXT</contentType> <state>READONLY</state> - <valueProcess>%aditoprj%/entity/Product_entity/entityfields/currentsalespriceid/valueProcess.js</valueProcess> + <valueProcess>%aditoprj%/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js</valueProcess> </entityField> <entityConsumer> <name>Organisations</name> diff --git a/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js b/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e9ef972e437973279fcf9144c2504ab288b20df6 --- /dev/null +++ b/entity/Product_entity/entityfields/currentpurchaseprice/valueProcess.js @@ -0,0 +1,9 @@ +import("system.translate"); +import("system.text"); +import("system.result"); +import("system.vars"); +import("Product_lib"); + +var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP"); +if (price.length > 0) + result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]); \ No newline at end of file diff --git a/entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js b/entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js deleted file mode 100644 index 67eac3b8220e51644ee450e4d74252cb89a3c8dc..0000000000000000000000000000000000000000 --- a/entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js +++ /dev/null @@ -1,5 +0,0 @@ -import("system.result"); -import("system.vars"); -import("Product_lib"); - -result.string(ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP")); \ No newline at end of file diff --git a/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js b/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..50bd3113611e859c5288cb2fe8a4851384a3a001 --- /dev/null +++ b/entity/Product_entity/entityfields/currentsalesprice/valueProcess.js @@ -0,0 +1,9 @@ +import("system.translate"); +import("system.text"); +import("system.result"); +import("system.vars"); +import("Product_lib"); + +var price = ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "SP"); +if (price.length > 0) + result.string(text.formatDouble(price[0], "#,##0.00", true) + " " + price[1]); \ No newline at end of file diff --git a/entity/Product_entity/entityfields/currentsalespriceid/valueProcess.js b/entity/Product_entity/entityfields/currentsalespriceid/valueProcess.js deleted file mode 100644 index dfac7a4979bc666a1b65a3609bc5e19a773a2021..0000000000000000000000000000000000000000 --- a/entity/Product_entity/entityfields/currentsalespriceid/valueProcess.js +++ /dev/null @@ -1,5 +0,0 @@ -import("system.result"); -import("system.vars"); -import("Product_lib"); - -result.string(ProductUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "SP")); \ No newline at end of file diff --git a/neonView/ProductPreview_view/ProductPreview_view.aod b/neonView/ProductPreview_view/ProductPreview_view.aod index b027cff6ec46895f9a2012132616409c72fc59f3..ec357f90b38dd8275058f1310dedab536c091ed7 100644 --- a/neonView/ProductPreview_view/ProductPreview_view.aod +++ b/neonView/ProductPreview_view/ProductPreview_view.aod @@ -54,12 +54,12 @@ <entityField>#ENTITY</entityField> <fields> <entityFieldLink> - <name>b93cd0c5-7028-496b-9709-ed57ba53ab47</name> - <entityField>currentPurchasePriceId</entityField> + <name>e47628f5-dd89-4a5d-bb39-8edf8dba9e73</name> + <entityField>currentPurchasePrice</entityField> </entityFieldLink> <entityFieldLink> - <name>6e4db325-6546-47f8-8dfa-ae60e8c37a13</name> - <entityField>currentSalesPriceId</entityField> + <name>da93c159-d0b2-41d4-8ebe-7f28f623356c</name> + <entityField>currentSalesPrice</entityField> </entityFieldLink> </fields> </genericViewTemplate> diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index 1d51b694be88511c165cc9ccfd30e80e16657cdf..99a29735c11b6866fa20079f8846c6fcaeded0d3 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -27,7 +27,7 @@ function ProductUtils() {} * * @example productUtils.getCurrentProductPrice(vars.get("$field.PRODUCTID"), "PP") * - * @return {String} currently valid product price + * @return {Array[]} currently valid product price with currency: [price, "CURRENCY"] or [] if no price found */ ProductUtils.getCurrentProductPrice = function(pid, buySell) { if (pid != undefined && pid != "" && buySell != undefined && buySell != "") @@ -36,20 +36,19 @@ ProductUtils.getCurrentProductPrice = function(pid, buySell) { var actualPriceCondition = SqlCondition.begin() .andPrepare("PRODUCTPRICE.BUYSELL", buySell) .andPrepare("PRODUCTPRICE.PRODUCT_ID", pid) - .andPrepare("PRODUCTPRICE.CURRENCY", 1) // TODO: warum ist Currency hardgecoded auf 1?? --> Einheitliche Währungen einbauen (auch zeichen vor oder nach der zahel, etc.) 1034949 .andPrepare("PRODUCTPRICE.VALID_FROM", today, "# <= ?") .andSqlCondition(SqlCondition.begin() .orPrepare("PRODUCTPRICE.VALID_TO", today, "# >= ?") .or("PRODUCTPRICE.VALID_TO is null"), "1 = 2"); var productPriceData = db.array(db.ROW, actualPriceCondition.buildSql("select PRICE, CURRENCY from PRODUCTPRICE", "1 = 2", "order by VALID_FROM desc")); - + if (productPriceData[0] && productPriceData[1]) - return productPriceData[0] + " " + KeywordUtils.getViewValue($KeywordRegistry.currency(), productPriceData[1]); + return [productPriceData[0], KeywordUtils.getViewValue($KeywordRegistry.currency(), productPriceData[1])]; else - return ""; + return []; } else { - return ""; + return []; } }