From 48b6d51eab827f91cc88711fa73f6b24c2b9b902 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Wed, 5 Dec 2018 15:47:08 +0100 Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?= =?UTF-8?q?=201029579][Preise=20=C3=BCberarbeiten]=20fix=20current=20EK,?= =?UTF-8?q?=20VK.=20Moved=20to=20other=20context?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entity/Pers_entity/Pers_entity.aod | 20 +++++++--- .../entityfields/previewtitle/valueProcess.js | 15 ------- entity/Pers_entity/titleProcess.js | 2 +- entity/Product_entity/Product_entity.aod | 14 +++++++ .../currentpurchasepriceid/valueProcess.js | 5 +++ .../currentsalespriceid/valueProcess.js | 5 +++ .../Productprice_entity.aod | 14 ------- .../currency/possibleItemsProcess.js | 4 +- .../currentpurchaseprice/valueProcess.js | 8 ---- .../currentsalesprice/valueProcess.js | 8 ---- .../_____LANGUAGE_de/_____LANGUAGE_de.aod | 4 ++ .../_____LANGUAGE_en/_____LANGUAGE_en.aod | 3 ++ .../Productprice_context.aod | 4 -- neonView/PersDetail_view/PersDetail_view.aod | 16 +------- .../ProductPreview_view.aod | 21 +++++++--- .../ProductpriceCurrent_view.aod | 28 ------------- .../ProductpriceFilter_view.aod | 8 ++-- .../db_changes/struct/create_productprice.xml | 4 +- process/Product_lib/process.js | 39 ++++++++++++------- 19 files changed, 96 insertions(+), 126 deletions(-) delete mode 100644 entity/Pers_entity/entityfields/previewtitle/valueProcess.js create mode 100644 entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js create mode 100644 entity/Product_entity/entityfields/currentsalespriceid/valueProcess.js delete mode 100644 entity/Productprice_entity/entityfields/currentpurchaseprice/valueProcess.js delete mode 100644 entity/Productprice_entity/entityfields/currentsalesprice/valueProcess.js delete mode 100644 neonView/ProductpriceCurrent_view/ProductpriceCurrent_view.aod diff --git a/entity/Pers_entity/Pers_entity.aod b/entity/Pers_entity/Pers_entity.aod index cd1ba6cd61a..56e6046d325 100644 --- a/entity/Pers_entity/Pers_entity.aod +++ b/entity/Pers_entity/Pers_entity.aod @@ -118,11 +118,6 @@ <state>READONLY</state> <valueProcess>%aditoprj%/entity/Pers_entity/entityfields/pers_user_new/valueProcess.js</valueProcess> </entityField> - <entityField> - <name>PREVIEWTITLE</name> - <title></title> - <valueProcess>%aditoprj%/entity/Pers_entity/entityfields/previewtitle/valueProcess.js</valueProcess> - </entityField> <entityParameter> <name>OrgId_param</name> <expose v="true" /> @@ -186,7 +181,6 @@ </entityField> <entityField> <name>ORG_ID</name> - <title></title> <tableName>RELATION</tableName> <columnName>ORG_ID</columnName> <valueProcess>%aditoprj%/entity/Pers_entity/entityfields/org_id/valueProcess.js</valueProcess> @@ -469,6 +463,20 @@ <mandatory v="false" /> <description>PARAMETER</description> </entityParameter> + <entityFieldGroup> + <name>FULL_NAME_fieldGroup</name> + <valueProcess>%aditoprj%/entity/Pers_entity/entityfields/full_name_fieldgroup/valueProcess.js</valueProcess> + <title>Name</title> + <description>FIELDGROUP</description> + <fields> + <element>SALUTATION</element> + <element>TITLE</element> + <element>FIRSTNAME</element> + <element>MIDDLENAME</element> + <element>LASTNAME</element> + <element>TITLESUFFIX</element> + </fields> + </entityFieldGroup> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Pers_entity/entityfields/previewtitle/valueProcess.js b/entity/Pers_entity/entityfields/previewtitle/valueProcess.js deleted file mode 100644 index 25b8c0094c4..00000000000 --- a/entity/Pers_entity/entityfields/previewtitle/valueProcess.js +++ /dev/null @@ -1,15 +0,0 @@ -import("system.vars"); -import("system.result"); - -var salutation = vars.get("$field.SALUTATION"); -var title = vars.get("$field.TITLE"); -var firstname = vars.get("$field.FIRSTNAME"); -var middlename = vars.get("$field.MIDDLENAME"); -var lastname = vars.get("$field.LASTNAME"); -var titlesuffix = vars.get("$field.TITLESUFFIX"); -var resultString = [salutation, title, firstname, middlename, lastname, titlesuffix].filter(Boolean).join(" "); - -if(resultString) - result.string(resultString); -else - result.string("Neuer Kontakt"); diff --git a/entity/Pers_entity/titleProcess.js b/entity/Pers_entity/titleProcess.js index 372d4df696f..f939acba4fe 100644 --- a/entity/Pers_entity/titleProcess.js +++ b/entity/Pers_entity/titleProcess.js @@ -1,4 +1,4 @@ import("system.vars"); import("system.result"); -result.string(vars.get("$field.PREVIEWTITLE")); \ No newline at end of file +result.string(vars.get("$field.FULL_NAME_fieldGroup")); \ No newline at end of file diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod index d0e760c9d4b..0605fa87d79 100644 --- a/entity/Product_entity/Product_entity.aod +++ b/entity/Product_entity/Product_entity.aod @@ -124,6 +124,20 @@ <columnName>USER_NEW</columnName> <valueProcess>%aditoprj%/entity/Product_entity/entityfields/user_new/valueProcess.js</valueProcess> </entityField> + <entityField> + <name>currentPurchasePriceId</name> + <title>Curr. purchase price</title> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>currentSalesPriceId</name> + <title>Curr. sales price</title> + <contentType>NUMBER</contentType> + <outputFormat>#,##0.00 €</outputFormat> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Product_entity/entityfields/currentsalespriceid/valueProcess.js</valueProcess> + </entityField> <entityOutgoingField> <name>ProductOrg_dfo</name> <fieldType>DEPENDENCY_OUT</fieldType> diff --git a/entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js b/entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js new file mode 100644 index 00000000000..67eac3b8220 --- /dev/null +++ b/entity/Product_entity/entityfields/currentpurchasepriceid/valueProcess.js @@ -0,0 +1,5 @@ +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/currentsalespriceid/valueProcess.js b/entity/Product_entity/entityfields/currentsalespriceid/valueProcess.js new file mode 100644 index 00000000000..dfac7a4979b --- /dev/null +++ b/entity/Product_entity/entityfields/currentsalespriceid/valueProcess.js @@ -0,0 +1,5 @@ +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/entity/Productprice_entity/Productprice_entity.aod b/entity/Productprice_entity/Productprice_entity.aod index a4b52d7466d..dc8c8f09128 100644 --- a/entity/Productprice_entity/Productprice_entity.aod +++ b/entity/Productprice_entity/Productprice_entity.aod @@ -240,20 +240,6 @@ <contentType>IMAGE</contentType> <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/image/valueProcess.js</valueProcess> </entityField> - <entityField> - <name>currentPurchasePrice</name> - <title>Curr. purchase price</title> - <contentType>NUMBER</contentType> - <outputFormat>#,##0.00 €</outputFormat> - <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/currentpurchaseprice/valueProcess.js</valueProcess> - </entityField> - <entityField> - <name>currentSalesPrice</name> - <title>Curr. sales price</title> - <contentType>NUMBER</contentType> - <outputFormat>#,##0.00 €</outputFormat> - <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/currentsalesprice/valueProcess.js</valueProcess> - </entityField> <entityIncomingField> <name>#INCOMING</name> </entityIncomingField> diff --git a/entity/Productprice_entity/entityfields/currency/possibleItemsProcess.js b/entity/Productprice_entity/entityfields/currency/possibleItemsProcess.js index 82e43a3d1a5..bf738952489 100644 --- a/entity/Productprice_entity/entityfields/currency/possibleItemsProcess.js +++ b/entity/Productprice_entity/entityfields/currency/possibleItemsProcess.js @@ -1,7 +1,5 @@ import("system.result"); import("Keyword_lib"); -var KeywordUtils, items; - -items = KeywordUtils.getStandardArray("CURRENCY"); +var items = KeywordUtils.getStandardArray("CURRENCY"); result.object(items); \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/currentpurchaseprice/valueProcess.js b/entity/Productprice_entity/entityfields/currentpurchaseprice/valueProcess.js deleted file mode 100644 index 13cf295450b..00000000000 --- a/entity/Productprice_entity/entityfields/currentpurchaseprice/valueProcess.js +++ /dev/null @@ -1,8 +0,0 @@ -import("system.result"); -import("system.vars"); -import("Product_lib"); - -if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != "") -{ - result.string( ProductUtils.getCurrentProductPrice(vars.get("$param.ProductId_param"), "PP") ); -} \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/currentsalesprice/valueProcess.js b/entity/Productprice_entity/entityfields/currentsalesprice/valueProcess.js deleted file mode 100644 index 3ba7d9974be..00000000000 --- a/entity/Productprice_entity/entityfields/currentsalesprice/valueProcess.js +++ /dev/null @@ -1,8 +0,0 @@ -import("system.result"); -import("system.vars"); -import("Product_lib"); - -if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != "") -{ - result.string( ProductUtils.getCurrentProductPrice(vars.get("$param.ProductId_param"), "SP") ); -} \ No newline at end of file diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 44a211a3e23..f417acbd882 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -926,6 +926,10 @@ <entry> <key>Euro zone</key> </entry> + <entry> + <key>Prices</key> + <value>Preise</value> + </entry> <entry> <key>NAME</key> </entry> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index dda68531ba2..b46ca9a33a4 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -287,6 +287,9 @@ <entry> <key>Ein Gruppentermin kann nur durch den Organisator bearbeitet werden.</key> </entry> + <entry> + <key>Prices</key> + </entry> <entry> <key>Communication Other</key> </entry> diff --git a/neonContext/Productprice_context/Productprice_context.aod b/neonContext/Productprice_context/Productprice_context.aod index 14c5eb885dd..9b7a23a4498 100644 --- a/neonContext/Productprice_context/Productprice_context.aod +++ b/neonContext/Productprice_context/Productprice_context.aod @@ -18,9 +18,5 @@ <name>d1c8b084-a20b-49ae-88fe-7a578396d4a5</name> <view>ProductpriceRelation_view</view> </neonViewReference> - <neonViewReference> - <name>d6d23301-5660-4938-b6a3-683dc096baac</name> - <view>ProductpriceCurrent_view</view> - </neonViewReference> </references> </neonContext> diff --git a/neonView/PersDetail_view/PersDetail_view.aod b/neonView/PersDetail_view/PersDetail_view.aod index 37e24b85971..1e547fec939 100644 --- a/neonView/PersDetail_view/PersDetail_view.aod +++ b/neonView/PersDetail_view/PersDetail_view.aod @@ -14,20 +14,8 @@ <entityField>#ENTITY</entityField> <fields> <entityFieldLink> - <name>cb520389-fbb4-4ae3-a172-c3dc428de20c</name> - <entityField>TITLE</entityField> - </entityFieldLink> - <entityFieldLink> - <name>b2557e5d-729e-4aab-a695-8952d4427d88</name> - <entityField>FIRSTNAME</entityField> - </entityFieldLink> - <entityFieldLink> - <name>1ea425a7-8203-4592-996f-e3dcd5c880b6</name> - <entityField>MIDDLENAME</entityField> - </entityFieldLink> - <entityFieldLink> - <name>c0e18d4a-04e3-4c81-83da-39b1870cc540</name> - <entityField>LASTNAME</entityField> + <name>c08b6952-9825-42fa-9b42-7a20a376fec7</name> + <entityField>FULL_NAME_fieldGroup</entityField> </entityFieldLink> <entityFieldLink> <name>bfd5e2d2-d89d-4c90-a8e2-f85fb2cc48f3</name> diff --git a/neonView/ProductPreview_view/ProductPreview_view.aod b/neonView/ProductPreview_view/ProductPreview_view.aod index 77430189389..c1f1fa217d9 100644 --- a/neonView/ProductPreview_view/ProductPreview_view.aod +++ b/neonView/ProductPreview_view/ProductPreview_view.aod @@ -51,10 +51,21 @@ <entityField>ProductStockCount_dfo</entityField> <view>StockCount_view</view> </neonViewReference> - <neonViewReference> - <name>297942d3-d87d-4813-96b0-7fa1bb58a9cf</name> - <entityField>ProductProductpriceCurr_dfo</entityField> - <view>ProductpriceCurrent_view</view> - </neonViewReference> + <genericViewTemplate> + <name>ProductPriceCurrent_template</name> + <showDrawer v="true" /> + <drawerCaption>Prices</drawerCaption> + <entityField>#ENTITY</entityField> + <fields> + <entityFieldLink> + <name>b93cd0c5-7028-496b-9709-ed57ba53ab47</name> + <entityField>currentPurchasePriceId</entityField> + </entityFieldLink> + <entityFieldLink> + <name>6e4db325-6546-47f8-8dfa-ae60e8c37a13</name> + <entityField>currentSalesPriceId</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> </children> </neonView> diff --git a/neonView/ProductpriceCurrent_view/ProductpriceCurrent_view.aod b/neonView/ProductpriceCurrent_view/ProductpriceCurrent_view.aod deleted file mode 100644 index fcd91b34fcd..00000000000 --- a/neonView/ProductpriceCurrent_view/ProductpriceCurrent_view.aod +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.0"> - <name>ProductpriceCurrent_view</name> - <majorModelMode>DISTRIBUTED</majorModelMode> - <layout> - <noneLayout> - <name>layout</name> - </noneLayout> - </layout> - <children> - <genericViewTemplate> - <name>Generic</name> - <showDrawer v="true" /> - <drawerCaption>Current purchase/sales price</drawerCaption> - <entityField>#ENTITY</entityField> - <fields> - <entityFieldLink> - <name>8775da33-ac67-474f-b3cc-43f848d805aa</name> - <entityField>currentPurchasePrice</entityField> - </entityFieldLink> - <entityFieldLink> - <name>7ea07988-e3f6-4540-bdb2-4e34cf3211be</name> - <entityField>currentSalesPrice</entityField> - </entityFieldLink> - </fields> - </genericViewTemplate> - </children> -</neonView> diff --git a/neonView/ProductpriceFilter_view/ProductpriceFilter_view.aod b/neonView/ProductpriceFilter_view/ProductpriceFilter_view.aod index 872fcf91be1..0bbe2d61232 100644 --- a/neonView/ProductpriceFilter_view/ProductpriceFilter_view.aod +++ b/neonView/ProductpriceFilter_view/ProductpriceFilter_view.aod @@ -35,6 +35,10 @@ <name>56902ebb-b48b-42f9-b867-fb2b07527461</name> <entityField>PRICE</entityField> </neonTableColumn> + <neonTableColumn> + <name>8879e46d-fa53-4769-8bcf-15b65fdf9967</name> + <entityField>CURRENCY</entityField> + </neonTableColumn> <neonTableColumn> <name>15a669d9-b089-4134-89a0-129de6e1e68c</name> <entityField>BUYSELL</entityField> @@ -47,10 +51,6 @@ <name>981f29b1-b4c5-4591-8064-21a72f339179</name> <entityField>VAT</entityField> </neonTableColumn> - <neonTableColumn> - <name>8879e46d-fa53-4769-8bcf-15b65fdf9967</name> - <entityField>CURRENCY</entityField> - </neonTableColumn> </columns> </tableViewTemplate> </children> diff --git a/others/db_changes/struct/create_productprice.xml b/others/db_changes/struct/create_productprice.xml index 8e6ea5446de..662969bf891 100644 --- a/others/db_changes/struct/create_productprice.xml +++ b/others/db_changes/struct/create_productprice.xml @@ -15,7 +15,9 @@ <constraints nullable="false" foreignKeyName="FK_PRODUCTPRICE_PRODUCT_ID" references="PRODUCT(PRODUCTID)"/> </column> <column name="FROMQUANTITY" type="NUMERIC(14,2)"/> - <column name="CURRENCY" type="INTEGER"/> + <column name="CURRENCY" type="INTEGER"> + <constraints nullable="false"/> + </column> <column name="PRICELIST" type="INTEGER"/> <column name="BUYSELL" type="VARCHAR(5)"/> <column name="DATE_EDIT" type="TIMESTAMP"/> diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index de0967210ea..a85854cd062 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -2,7 +2,10 @@ import("system.SQLTYPES"); import("system.datetime"); import("system.db"); import("system.vars"); +import("system.translate"); import("Util_lib"); +import("Sql_lib"); +import("Keyword_lib"); /** @@ -26,19 +29,22 @@ function ProductUtils() {} ProductUtils.getCurrentProductPrice = function(pid, buySell) { if (pid != undefined && pid != "" && buySell != undefined && buySell != "") { - var actualpriceSelect = "select PRICE from PRODUCTPRICE \n\ - where BUYSELL = '" + buySell + "' and PRODUCT_ID = '" + pid + "' and CURRENCY = 1 \n\ - and VALID_FROM <= ? and (VALID_TO >= ? or VALID_TO is null) \n\ - order by VALID_FROM desc"; - - var today = datetime.today(); - var sqltypes = [ [today.toString(), SQLTYPES.TIMESTAMP], [today.toString(), SQLTYPES.TIMESTAMP] ]; - var actualprice = db.cell([actualpriceSelect, sqltypes]); - - if (actualprice != "") - return actualprice; + var today = datetime.clearTime(vars.get("sys.date"), "utc"); + var actualPriceCondition = SqlCondition.begin() + .andPrepare("PRODUCTPRICE.BUYSELL", buySell) + .andPrepare("PRODUCTPRICE.PRODUCT_ID", pid) + .andPrepare("PRODUCTPRICE.CURRENCY", 1) // TODO: warum ist Currency hardgecoded auf 1?? + .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.buildSelect("select PRICE, CURRENCY from PRODUCTPRICE", "1 = 2", "order by VALID_FROM desc")); + + if (productPriceData[0] != "") + return productPriceData[0] + " " + KeywordUtils.get("CURRENCY", productPriceData[1])[1]; else - return "0.00"; + return ""; } else { throw new Error(); // TODO: add message } @@ -56,7 +62,10 @@ ProductUtils.getCurrentProductPrice = function(pid, buySell) { ProductUtils.getStockCount = function(pid) { if (pid != undefined && pid != "") { - var sum = db.cell("select sum(QUANTITY * IN_OUT) from STOCK where PRODUCT_ID = '" + pid + "'"); + var sum = db.cell(SqlCondition.begin() + .andPrepare("STOCK.PRODUCT_ID", pid) + .buildSelect("select sum(QUANTITY * IN_OUT) from STOCK")); + if (sum == "") sum = "0"; @@ -74,7 +83,7 @@ ProductUtils.getStockCount = function(pid) { * current price list to use for offer/order are delivered. * * @param {String} pid req ProductID - * @param {Object} pPriceListFilter opt { currency: "currencyValue", quantity: "quantityValue", relationId: "relationIdValue (for custom price lists)" } + * @param {Object} priceListFilter opt { currency: "currencyValue", quantity: "quantityValue", relationId: "relationIdValue (for custom price lists)" } * * @example //Product_entity, Field: PRODUCT_ID, Process: onValueChange * var pid = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.PRODUCT_ID")); @@ -286,7 +295,7 @@ ProductUtils.getProductDetails = function(pid, priceListFilter) * @return {Object | null} null if no identical price list was found, otherwise the found price list */ ProductUtils.checkForIndenticalPriceLists = function(pid, priceList) { - var PriceLists = that.getProductDetails(pid).PriceLists; + var PriceLists = this.getProductDetails(pid).PriceLists; for (var pricelist in PriceLists) { //equal price list -- GitLab