From c5ff9a90353e04fed93641b4efaef8a011694da3 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Thu, 13 Dec 2018 16:21:37 +0100 Subject: [PATCH] refactor all booleans to tinyint --- aliasDefinition/Data_alias/Data_alias.aod | 38 +++++++++---------- .../optional/possibleItemsProcess.js | 4 +- .../entityfields/optional/valueProcess.js | 2 +- entity/Prod2prod_entity/Prod2prod_entity.aod | 1 + .../optional/possibleItemsProcess.js | 4 +- .../entityfields/optional/valueProcess.js | 2 +- .../takeprice/possibleItemsProcess.js | 4 +- .../recordcontainers/jdito/contentProcess.js | 1 - .../recordcontainers/jdito/onDelete.js | 6 ++- .../recordcontainers/jdito/onInsert.js | 4 +- .../recordcontainers/jdito/onUpdate.js | 10 ++++- .../recordcontainers/jdito/rowCountProcess.js | 0 .../in_out/possibleItemsProcess.js | 2 +- .../recordcontainers/db/conditionProcess.js | 7 ++-- .../data/example_offer/OFFER_1000.xml | 16 ++++---- .../data/example_offer/OFFER_1001.xml | 2 +- .../data/example_offer/OFFER_1002.xml | 2 +- .../data/example_offer/OFFER_1003.xml | 2 +- .../data/example_offer/OFFER_1004.xml | 2 +- .../data/example_product/PRODUCT_42154311.xml | 28 +++++++------- others/db_changes/struct/create_comm.xml | 4 +- others/db_changes/struct/create_offeritem.xml | 4 +- others/db_changes/struct/create_org.xml | 2 +- others/db_changes/struct/create_prod2prod.xml | 8 +++- others/db_changes/struct/create_relation.xml | 2 +- others/db_changes/struct/create_stock.xml | 4 +- others/db_changes/whichDatatype.adoc | 14 +++++++ process/OfferOrder_lib/process.js | 36 +++++++++++------- process/Product_lib/process.js | 13 +++---- 29 files changed, 130 insertions(+), 94 deletions(-) create mode 100644 entity/Prod2prod_entity/recordcontainers/jdito/rowCountProcess.js create mode 100644 others/db_changes/whichDatatype.adoc diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod index f63c1362a95..c1dc9cf2364 100644 --- a/aliasDefinition/Data_alias/Data_alias.aod +++ b/aliasDefinition/Data_alias/Data_alias.aod @@ -140,8 +140,8 @@ <name>TYPE</name> <dbName></dbName> <primaryKey v="false" /> - <columnType v="5" /> - <size v="5" /> + <columnType v="4" /> + <size v="10" /> <scale v="0" /> <notNull v="false" /> <isUnique v="false" /> @@ -266,8 +266,8 @@ <name>STATUS</name> <dbName></dbName> <primaryKey v="false" /> - <columnType v="5" /> - <size v="5" /> + <columnType v="4" /> + <size v="10" /> <scale v="0" /> <notNull v="false" /> <isUnique v="false" /> @@ -1195,10 +1195,10 @@ <name>STANDARD</name> <dbName></dbName> <primaryKey v="false" /> - <columnType v="4" /> - <size v="10" /> + <columnType v="5" /> + <size v="5" /> <scale v="0" /> - <notNull v="false" /> + <notNull v="true" /> <isUnique v="false" /> <index v="false" /> <title></title> @@ -1656,10 +1656,10 @@ <name>OPTIONAL</name> <dbName></dbName> <primaryKey v="false" /> - <columnType v="1" /> - <size v="1" /> + <columnType v="5" /> + <size v="5" /> <scale v="0" /> - <notNull v="false" /> + <notNull v="true" /> <isUnique v="false" /> <index v="false" /> <title></title> @@ -1669,10 +1669,10 @@ <name>TAKEPRICE</name> <dbName></dbName> <primaryKey v="false" /> - <columnType v="1" /> - <size v="1" /> + <columnType v="5" /> + <size v="5" /> <scale v="0" /> - <notNull v="false" /> + <notNull v="true" /> <isUnique v="false" /> <index v="false" /> <title></title> @@ -2164,10 +2164,10 @@ <name>IN_OUT</name> <dbName></dbName> <primaryKey v="false" /> - <columnType v="4" /> - <size v="10" /> + <columnType v="5" /> + <size v="5" /> <scale v="0" /> - <notNull v="false" /> + <notNull v="true" /> <isUnique v="false" /> <index v="false" /> <title></title> @@ -2777,10 +2777,10 @@ <name>OPTIONAL</name> <dbName></dbName> <primaryKey v="false" /> - <columnType v="4" /> - <size v="10" /> + <columnType v="5" /> + <size v="5" /> <scale v="0" /> - <notNull v="false" /> + <notNull v="true" /> <isUnique v="false" /> <index v="false" /> <title></title> diff --git a/entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js b/entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js index 1dfbf04839c..8ddad3ebcc3 100644 --- a/entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js +++ b/entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js @@ -2,6 +2,6 @@ import("system.translate"); import("system.result"); result.object([ - ["0", translate.text("Yes")] - ,["1", translate.text("No")] + [1, translate.text("Yes")] + ,[0, translate.text("No")] ]); \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/optional/valueProcess.js b/entity/Offeritem_entity/entityfields/optional/valueProcess.js index 04344c1e2ca..cbdd72fde38 100644 --- a/entity/Offeritem_entity/entityfields/optional/valueProcess.js +++ b/entity/Offeritem_entity/entityfields/optional/valueProcess.js @@ -3,4 +3,4 @@ import("system.result"); import("system.neon"); if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) - result.string("1"); \ No newline at end of file + result.string("0"); \ No newline at end of file diff --git a/entity/Prod2prod_entity/Prod2prod_entity.aod b/entity/Prod2prod_entity/Prod2prod_entity.aod index 5fb7a848fff..f262f3c4370 100644 --- a/entity/Prod2prod_entity/Prod2prod_entity.aod +++ b/entity/Prod2prod_entity/Prod2prod_entity.aod @@ -101,6 +101,7 @@ <contentProcess>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js</contentProcess> <isPageable v="false" /> <isSortable v="false" /> + <rowCountProcess>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/rowCountProcess.js</rowCountProcess> <onInsert>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js</onInsert> <onUpdate>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js</onUpdate> <onDelete>%aditoprj%/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js</onDelete> diff --git a/entity/Prod2prod_entity/entityfields/optional/possibleItemsProcess.js b/entity/Prod2prod_entity/entityfields/optional/possibleItemsProcess.js index 1dfbf04839c..8ddad3ebcc3 100644 --- a/entity/Prod2prod_entity/entityfields/optional/possibleItemsProcess.js +++ b/entity/Prod2prod_entity/entityfields/optional/possibleItemsProcess.js @@ -2,6 +2,6 @@ import("system.translate"); import("system.result"); result.object([ - ["0", translate.text("Yes")] - ,["1", translate.text("No")] + [1, translate.text("Yes")] + ,[0, translate.text("No")] ]); \ No newline at end of file diff --git a/entity/Prod2prod_entity/entityfields/optional/valueProcess.js b/entity/Prod2prod_entity/entityfields/optional/valueProcess.js index 8a574b0a35d..a772de2f7d4 100644 --- a/entity/Prod2prod_entity/entityfields/optional/valueProcess.js +++ b/entity/Prod2prod_entity/entityfields/optional/valueProcess.js @@ -3,4 +3,4 @@ //import("system.neon"); // //if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) -// result.string("1"); \ No newline at end of file +// result.string("0"); \ No newline at end of file diff --git a/entity/Prod2prod_entity/entityfields/takeprice/possibleItemsProcess.js b/entity/Prod2prod_entity/entityfields/takeprice/possibleItemsProcess.js index f31ec18e895..8ddad3ebcc3 100644 --- a/entity/Prod2prod_entity/entityfields/takeprice/possibleItemsProcess.js +++ b/entity/Prod2prod_entity/entityfields/takeprice/possibleItemsProcess.js @@ -2,6 +2,6 @@ import("system.translate"); import("system.result"); result.object([ - ["Y", translate.text("Yes")] - ,["N", translate.text("No")] + [1, translate.text("Yes")] + ,[0, translate.text("No")] ]); \ No newline at end of file diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js b/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js index 63f948e2d8f..912ab1f560d 100644 --- a/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Prod2prod_entity/recordcontainers/jdito/contentProcess.js @@ -10,6 +10,5 @@ var prodid = vars.exists("$param.ProductId_param") if(prodid != "") { var p2pUtils = new Prod2ProdUtils(prodid); - logging.log(p2pUtils.getPartsListForRecordContainer().toSource()) result.object(p2pUtils.getPartsListForRecordContainer()); } \ No newline at end of file diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js b/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js index db58c1cefaa..e2c6c0ff0e6 100644 --- a/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js +++ b/entity/Prod2prod_entity/recordcontainers/jdito/onDelete.js @@ -1,4 +1,6 @@ -import("system.vars"); import("system.db"); +import("Sql_lib"); -db.deleteData("PROD2PROD", "PROD2PRODID = '" + vars.get("$field.UID") + "'"); \ No newline at end of file +db.deleteData("PROD2PROD", SqlCondition.begin() + .andPrepareVars("PROD2PROD.PROD2PRODID", "$field.UID", "# = ?") + .build("1 = 0")); \ No newline at end of file diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js b/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js index a20684ae000..cae95088615 100644 --- a/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js +++ b/entity/Prod2prod_entity/recordcontainers/jdito/onInsert.js @@ -20,6 +20,4 @@ var vals = [ vars.get("$field.UID") , vars.get("$field.DATE_NEW") , vars.get("$field.USER_NEW") ]; -var colTypes = db.getColumnTypes("PROD2PROD", cols); - -db.insertData("PROD2PROD", cols, colTypes, vals); \ No newline at end of file +db.insertData("PROD2PROD", cols, null, vals); \ No newline at end of file diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js b/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js index 93a576e2c7d..98a1e3d2dfe 100644 --- a/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/Prod2prod_entity/recordcontainers/jdito/onUpdate.js @@ -1,6 +1,7 @@ import("system.datetime"); import("system.vars"); import("system.db"); +imp var cols = [ "DEST_ID" , "SOURCE_ID" @@ -18,6 +19,11 @@ var vals = [ vars.get("$field.DEST_ID") , vars.get("$field.DATE_EDIT") , vars.get("$field.USER_EDIT") ]; -var colTypes = db.getColumnTypes("PROD2PROD", cols); -db.updateData("PROD2PROD", cols, colTypes, vals, "PROD2PRODID = '" + vars.get("$field.UID") + "'"); \ No newline at end of file +db.updateData("PROD2PROD", + cols, + null, + vals, + SqlCondition.begin() + .andPrepareVars("PROD2PROD.PROD2PRODID", "$field.UID", "# = ?") + .build("1 = 0")); \ No newline at end of file diff --git a/entity/Prod2prod_entity/recordcontainers/jdito/rowCountProcess.js b/entity/Prod2prod_entity/recordcontainers/jdito/rowCountProcess.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/entity/Stock_entity/entityfields/in_out/possibleItemsProcess.js b/entity/Stock_entity/entityfields/in_out/possibleItemsProcess.js index e87580dcd9e..b74e336ebe8 100644 --- a/entity/Stock_entity/entityfields/in_out/possibleItemsProcess.js +++ b/entity/Stock_entity/entityfields/in_out/possibleItemsProcess.js @@ -3,5 +3,5 @@ import("system.translate"); result.object([ ["1", translate.text("IN")], - ["-1", translate.text("OUT")] + ["0", translate.text("OUT")] ]); \ No newline at end of file diff --git a/entity/Stock_entity/recordcontainers/db/conditionProcess.js b/entity/Stock_entity/recordcontainers/db/conditionProcess.js index 530b6b4554e..1ff335472b3 100644 --- a/entity/Stock_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Stock_entity/recordcontainers/db/conditionProcess.js @@ -1,7 +1,6 @@ import("system.result"); import("system.vars"); -if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != "") - result.string("STOCK.PRODUCT_ID = ('" + vars.get("$param.ProductId_param") + "')"); -else - result.string("1 = 2"); \ No newline at end of file +result.string(SqlCondition.begin() + .andPrepareVars("STOCK.PRODUCT_ID", "$param.ProductId_param") + .build("1 = 0")); \ No newline at end of file diff --git a/others/db_changes/data/example_offer/OFFER_1000.xml b/others/db_changes/data/example_offer/OFFER_1000.xml index c1ae476c95c..6d228aaaf91 100644 --- a/others/db_changes/data/example_offer/OFFER_1000.xml +++ b/others/db_changes/data/example_offer/OFFER_1000.xml @@ -12,7 +12,7 @@ <column name="PROBABILITY" valueNumeric="5"/> <column name="NET" valueNumeric="210.00"/> <column name="VAT" valueNumeric="39.90"/> - <column name="CURRENCY" valueNumeric="1"/> + <column name="CURRENCY" valueNumeric="0"/> <column name="LANGUAGE" value="de-DE"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:11:19"/> @@ -29,7 +29,7 @@ <column name="PRODUCT_ID" value="P101 "/> <column name="VAT" valueNumeric="19.00"/> <column name="ITEMNAME" value="AX45"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:19"/> @@ -45,7 +45,7 @@ <column name="ITEMSORT" valueNumeric="2"/> <column name="PRODUCT_ID" value="feefb3a9-f02a-4536-9ebb-ab7070cc71ba"/> <column name="ITEMNAME" value="AX47"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1.1"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:29"/> @@ -61,7 +61,7 @@ <column name="ITEMSORT" valueNumeric="3"/> <column name="PRODUCT_ID" value="6e52e636-284d-454b-978c-8f58844c5c5b"/> <column name="ITEMNAME" value="Produktname4.1"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1.1.1"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:35"/> @@ -77,7 +77,7 @@ <column name="ITEMSORT" valueNumeric="4"/> <column name="PRODUCT_ID" value="368aa1c0-b802-4dea-844e-e61bf85a03c9"/> <column name="ITEMNAME" value="Sonderrabatt"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1.1.1.1"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:38"/> @@ -93,7 +93,7 @@ <column name="ITEMSORT" valueNumeric="5"/> <column name="PRODUCT_ID" value="072680e3-9e5d-4228-b5a8-f4acef8f2452"/> <column name="ITEMNAME" value="Produktname4.2a"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1.1.2"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:48"/> @@ -109,7 +109,7 @@ <column name="ITEMSORT" valueNumeric="6"/> <column name="PRODUCT_ID" value="f52b1d6e-bf08-4fe1-8d83-ac0728c4b1c4"/> <column name="ITEMNAME" value="Produktname1.1"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1.2"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:51"/> @@ -125,7 +125,7 @@ <column name="ITEMSORT" valueNumeric="7"/> <column name="PRODUCT_ID" value="b973e3f9-277c-4787-96a0-7cac54472420"/> <column name="ITEMNAME" value="Produktname1.2"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1.3"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:55"/> diff --git a/others/db_changes/data/example_offer/OFFER_1001.xml b/others/db_changes/data/example_offer/OFFER_1001.xml index 45a5a3a6739..af385c8fcbe 100644 --- a/others/db_changes/data/example_offer/OFFER_1001.xml +++ b/others/db_changes/data/example_offer/OFFER_1001.xml @@ -29,7 +29,7 @@ <column name="PRODUCT_ID" value="P101 "/> <column name="VAT" valueNumeric="19.00"/> <column name="ITEMNAME" value="AX45"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:19"/> diff --git a/others/db_changes/data/example_offer/OFFER_1002.xml b/others/db_changes/data/example_offer/OFFER_1002.xml index 593db0b54dc..5dc19d4ca20 100644 --- a/others/db_changes/data/example_offer/OFFER_1002.xml +++ b/others/db_changes/data/example_offer/OFFER_1002.xml @@ -29,7 +29,7 @@ <column name="PRODUCT_ID" value="P101 "/> <column name="VAT" valueNumeric="19.00"/> <column name="ITEMNAME" value="AX45"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:19"/> diff --git a/others/db_changes/data/example_offer/OFFER_1003.xml b/others/db_changes/data/example_offer/OFFER_1003.xml index 27420daf107..116bae3c00b 100644 --- a/others/db_changes/data/example_offer/OFFER_1003.xml +++ b/others/db_changes/data/example_offer/OFFER_1003.xml @@ -29,7 +29,7 @@ <column name="PRODUCT_ID" value="P101 "/> <column name="VAT" valueNumeric="19.00"/> <column name="ITEMNAME" value="AX45"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:19"/> diff --git a/others/db_changes/data/example_offer/OFFER_1004.xml b/others/db_changes/data/example_offer/OFFER_1004.xml index 7f3ed3871c0..93278cc1b6f 100644 --- a/others/db_changes/data/example_offer/OFFER_1004.xml +++ b/others/db_changes/data/example_offer/OFFER_1004.xml @@ -29,7 +29,7 @@ <column name="PRODUCT_ID" value="P101 "/> <column name="VAT" valueNumeric="19.00"/> <column name="ITEMNAME" value="AX45"/> - <column name="OPTIONAL" valueNumeric="1"/> + <column name="OPTIONAL" valueNumeric="0"/> <column name="ITEMPOSITION" value="1"/> <column name="USER_NEW" value="Admin"/> <column name="DATE_NEW" valueDate="2018-11-21T14:32:19"/> diff --git a/others/db_changes/data/example_product/PRODUCT_42154311.xml b/others/db_changes/data/example_product/PRODUCT_42154311.xml index b64161fe6a3..15f6a25763d 100644 --- a/others/db_changes/data/example_product/PRODUCT_42154311.xml +++ b/others/db_changes/data/example_product/PRODUCT_42154311.xml @@ -88,8 +88,8 @@ <insert tableName="PROD2PROD"> <column name="PROD2PRODID" value="c5288f96-41f0-4b9b-b79f-23da12ad485b"/> - <column name="OPTIONAL" value="1"/> - <column name="TAKEPRICE" value="N"/> + <column name="OPTIONAL" valueNumeric="0"/> + <column name="TAKEPRICE" valueNumeric="0"/> <column name="QUANTITY" valueNumeric="1.00"/> <column name="SOURCE_ID" value="feefb3a9-f02a-4536-9ebb-ab7070cc71ba"/> <column name="DEST_ID" value="P101 "/> @@ -98,8 +98,8 @@ </insert> <insert tableName="PROD2PROD"> <column name="PROD2PRODID" value="f78cf164-3a9d-43a6-a58c-9f462e5ed012"/> - <column name="OPTIONAL" value="1"/> - <column name="TAKEPRICE" value="Y"/> + <column name="OPTIONAL" valueNumeric="0"/> + <column name="TAKEPRICE" valueNumeric="1"/> <column name="QUANTITY" valueNumeric="2.00"/> <column name="SOURCE_ID" value="f52b1d6e-bf08-4fe1-8d83-ac0728c4b1c4"/> <column name="DEST_ID" value="P101 "/> @@ -108,8 +108,8 @@ </insert> <insert tableName="PROD2PROD"> <column name="PROD2PRODID" value="cbd0699d-947c-4f6c-8c43-e9dcea72447a"/> - <column name="OPTIONAL" value="1"/> - <column name="TAKEPRICE" value="Y"/> + <column name="OPTIONAL" valueNumeric="0"/> + <column name="TAKEPRICE" valueNumeric="1"/> <column name="QUANTITY" valueNumeric="3.00"/> <column name="SOURCE_ID" value="b973e3f9-277c-4787-96a0-7cac54472420"/> <column name="DEST_ID" value="P101 "/> @@ -118,8 +118,8 @@ </insert> <insert tableName="PROD2PROD"> <column name="PROD2PRODID" value="aefd0be1-325d-42f7-9b79-1bab24e7ae23"/> - <column name="OPTIONAL" value="1"/> - <column name="TAKEPRICE" value="Y"/> + <column name="OPTIONAL" valueNumeric="0"/> + <column name="TAKEPRICE" valueNumeric="1"/> <column name="QUANTITY" valueNumeric="3.00"/> <column name="SOURCE_ID" value="6e52e636-284d-454b-978c-8f58844c5c5b"/> <column name="DEST_ID" value="feefb3a9-f02a-4536-9ebb-ab7070cc71ba"/> @@ -128,8 +128,8 @@ </insert> <insert tableName="PROD2PROD"> <column name="PROD2PRODID" value="e413c0f8-c953-4380-ad2e-b9c04411baad"/> - <column name="OPTIONAL" value="1"/> - <column name="TAKEPRICE" value="N"/> + <column name="OPTIONAL" valueNumeric="0"/> + <column name="TAKEPRICE" valueNumeric="0"/> <column name="QUANTITY" valueNumeric="3.00"/> <column name="SOURCE_ID" value="072680e3-9e5d-4228-b5a8-f4acef8f2452"/> <column name="DEST_ID" value="feefb3a9-f02a-4536-9ebb-ab7070cc71ba"/> @@ -138,8 +138,8 @@ </insert> <insert tableName="PROD2PROD"> <column name="PROD2PRODID" value="cb43c351-38dc-4b1e-b408-2d9afcfdbb13"/> - <column name="OPTIONAL" value="1"/> - <column name="TAKEPRICE" value="N"/> + <column name="OPTIONAL" valueNumeric="0"/> + <column name="TAKEPRICE" valueNumeric="0"/> <column name="QUANTITY" valueNumeric="3.00"/> <column name="SOURCE_ID" value="368aa1c0-b802-4dea-844e-e61bf85a03c9"/> <column name="DEST_ID" value="6e52e636-284d-454b-978c-8f58844c5c5b"/> @@ -254,7 +254,7 @@ </insert> <insert tableName="STOCK"> <column name="STOCKID" value="bd4c1a16-1b80-4b3e-aa67-306f387a62df"/> - <column name="IN_OUT" valueNumeric="-1"/> + <column name="IN_OUT" valueNumeric="0"/> <column name="QUANTITY" valueNumeric="23"/> <column name="PRODUCT_ID" value="P101 "/> <column name="ENTRYDATE" valueDate="2018-11-22T00:00:00"/> @@ -264,7 +264,7 @@ </insert> <insert tableName="STOCK"> <column name="STOCKID" value="3caba278-9d38-485c-9d78-11ea969b832c"/> - <column name="IN_OUT" valueNumeric="-1"/> + <column name="IN_OUT" valueNumeric="0"/> <column name="QUANTITY" valueNumeric="17"/> <column name="PRODUCT_ID" value="P101 "/> <column name="ENTRYDATE" valueDate="2018-11-15T00:00:00"/> diff --git a/others/db_changes/struct/create_comm.xml b/others/db_changes/struct/create_comm.xml index 0fdb1ef77a5..ce1a745f3f4 100644 --- a/others/db_changes/struct/create_comm.xml +++ b/others/db_changes/struct/create_comm.xml @@ -8,7 +8,9 @@ <column name="ADDR" type="VARCHAR(255)"/> <column name="MEDIUM_ID" type="INTEGER"/> <column name="RELATION_ID" type="CHAR(36)"/> - <column name="STANDARD" type="INTEGER"/> + <column name="STANDARD" type="TINYINT"> + <constraints nullable="false"/> + </column> <column name="DATE_EDIT" type="TIMESTAMP"/> <column name="DATE_NEW" type="TIMESTAMP"> <constraints nullable="false"/> diff --git a/others/db_changes/struct/create_offeritem.xml b/others/db_changes/struct/create_offeritem.xml index d81a9e397f7..ee141f069a2 100644 --- a/others/db_changes/struct/create_offeritem.xml +++ b/others/db_changes/struct/create_offeritem.xml @@ -20,7 +20,9 @@ </column> <column name="VAT" type="NUMERIC(14,2)"/> <column name="ITEMNAME" type="VARCHAR(250)"/> - <column name="OPTIONAL" type="INTEGER"/> + <column name="OPTIONAL" type="TINYINT"> + <constraints nullable="false"/> + </column> <column name="DISCOUNT" type="NUMERIC(14,2)"/> <column name="ITEMPOSITION" type="VARCHAR(10)"/> <column name="DATE_EDIT" type="TIMESTAMP"/> diff --git a/others/db_changes/struct/create_org.xml b/others/db_changes/struct/create_org.xml index 7543f81eaab..8622d415d06 100644 --- a/others/db_changes/struct/create_org.xml +++ b/others/db_changes/struct/create_org.xml @@ -6,7 +6,7 @@ <constraints nullable="false"/> </column> <column name="INFO" type="NCLOB"/> - <column name="TYPE" type="SMALLINT"/> + <column name="TYPE" type="INTEGER"/> <column name="CUSTOMERCODE" type="NVARCHAR(30)"/> <column name="ORGID" type="CHAR(36)"> <constraints primaryKey="true" primaryKeyName="PK_ORG_ORGID"/> diff --git a/others/db_changes/struct/create_prod2prod.xml b/others/db_changes/struct/create_prod2prod.xml index d8a0f879c46..a52b1bda725 100644 --- a/others/db_changes/struct/create_prod2prod.xml +++ b/others/db_changes/struct/create_prod2prod.xml @@ -5,8 +5,12 @@ <column name="PROD2PRODID" type="CHAR(36)"> <constraints primaryKey="true" primaryKeyName="PK_PROD2PROD_PROD2PRODID"/> </column> - <column name="OPTIONAL" type="CHAR(1)"/> - <column name="TAKEPRICE" type="CHAR(1)"/> + <column name="OPTIONAL" type="TINYINT"> + <constraints nullable="false"/> + </column> + <column name="TAKEPRICE" type="TINYINT"> + <constraints nullable="false"/> + </column> <column name="QUANTITY" type="NUMERIC(14,2)"/> <column name="SOURCE_ID" type="CHAR(36)"> <constraints nullable="false" foreignKeyName="FK_PROD2PROD_SOURCE_ID" references="PRODUCT(PRODUCTID)"/> diff --git a/others/db_changes/struct/create_relation.xml b/others/db_changes/struct/create_relation.xml index 33467103609..cc007b21963 100644 --- a/others/db_changes/struct/create_relation.xml +++ b/others/db_changes/struct/create_relation.xml @@ -2,7 +2,7 @@ <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> <changeSet author="j.hoermann" id="1f8bb402-3dd8-4732-8409-0ffc784f84f4"> <createTable tableName="RELATION"> - <column name="STATUS" type="SMALLINT"/> + <column name="STATUS" type="INTEGER"/> <column name="LANGUAGE" type="CHAR(5)"/> <column name="ORG_ID" type="CHAR(36)"/> <column name="PERS_ID" type="CHAR(36)" /> diff --git a/others/db_changes/struct/create_stock.xml b/others/db_changes/struct/create_stock.xml index 5450df334f2..b5f0f600442 100644 --- a/others/db_changes/struct/create_stock.xml +++ b/others/db_changes/struct/create_stock.xml @@ -5,7 +5,9 @@ <column name="STOCKID" type="CHAR(36)"> <constraints primaryKey="true" primaryKeyName="PK_STOCK_STOCKID"/> </column> - <column name="IN_OUT" type="INTEGER"/> + <column name="IN_OUT" type="TINYINT"> + <constraints nullable="false"/> + </column> <column name="QUANTITY" type="NUMERIC(14,2)"/> <column name="REFNUMBER" type="VARCHAR(50)"/> <column name="PRODUCT_ID" type="CHAR(36)"> diff --git a/others/db_changes/whichDatatype.adoc b/others/db_changes/whichDatatype.adoc new file mode 100644 index 00000000000..7ba7cd96c36 --- /dev/null +++ b/others/db_changes/whichDatatype.adoc @@ -0,0 +1,14 @@ +Overview over datatypes +======================= + +This is a simple overview about when to to use which datatype. + +== Boolean == +Datatype: +tinyint + +Usage: +0 => false +1 => true + +Add nullable="false" constraint, because for boolean null makes no sense and complicates searches and validations. diff --git a/process/OfferOrder_lib/process.js b/process/OfferOrder_lib/process.js index ba537998bb1..ffbab0b9eaf 100644 --- a/process/OfferOrder_lib/process.js +++ b/process/OfferOrder_lib/process.js @@ -1,3 +1,6 @@ +import("system.datetime"); +import("system.text"); +import("system.logging"); import("system.neon"); import("system.translate"); import("system.db"); @@ -57,13 +60,18 @@ OfferUtils.getOfferNetAndVAT = function(offerId, offeritemIdsToDel) { var vat = 0; var oiUtils = new OfferItemUtils(offerId); - var condition = "where OFFER_ID = '" + offerId + "'"; + var condition = SqlCondition.begin().andPrepare("OFFERITEM.OFFER_ID", offerId); + if (offeritemIdsToDel != undefined) - condition += " and OFFERITEMID not in ('" + offeritemIdsToDel.join("','") + "')"; - - var offerItems = db.table("select QUANTITY, PRICE, DISCOUNT, VAT, OPTIONAL " - + "from OFFERITEM " + condition); + { + offeritemIdsToDel.forEach(function(pItem) + { + condition.andPrepare("OFFERITEM.OFFERITEMID", pItem, "# <> ?"); + }); + } + var offerItems = db.table(condition.buildSelect("select QUANTITY, PRICE, DISCOUNT, VAT, OPTIONAL from OFFERITEM", "1 = 0", afterCondition)); + for (var i = 0; i < offerItems.length; i++) { sum += oiUtils.getItemSum(offerItems[i][0], offerItems[i][1], offerItems[i][2], offerItems[i][4]); @@ -101,10 +109,6 @@ OfferUtils.createNewOffer = function(pSalesprojectId, pRelationId) * Open Offer report * * @param {String} pOfferID - * @param {Boolean} pExport - * @param {String} pUser - * @param {String} pRPT req Name des Reports - * @param {String} pLanguage opt Sprache wird nur für mobile benötigt * * @return {[]} */ @@ -160,8 +164,9 @@ OfferUtils.openOfferReport = function(pOfferID) // calculate: // "OFFERITEM_QUANTITY" * "OFFERITEM_PRICE" fullPrice = eMath.mulDec(parseFloat(rptdata[i][22]), parseFloat(rptdata[i][23]) ); + // ( fullPrice * ( 100 - "OFFERITEM_DISCOUNT" ) ) / 100 - if(optional != 1) + if(optional) { itemSum = eMath.roundDec(eMath.divDec(eMath.mulDec(fullPrice, eMath.subDec(100, rptdata[i][24]) ), 100), 2, eMath.ROUND_HALF_EVEN); //Summe je Artikel sumItemSum += itemSum; //Gesamtsumme aller Artikel @@ -178,7 +183,8 @@ OfferUtils.openOfferReport = function(pOfferID) rptdata[i][23] = text.formatDouble(rptdata[i][23], translate.text("#,##0.00"), true); rptdata[i][24] = text.formatDouble(rptdata[i][24], translate.text("0.00"), true); rptdata[i][22] = text.formatDouble(rptdata[i][22], translate.text("#,##0"), true); - rptdata[i][27] = text.formatDouble(rptdata[i][27], translate.text("#,##0.00"), true); + rptdata[i][27] = text.formatDouble(rptdata[i][27], translate.text("#,##0.00"), true); + logging.log("sum: " + itemSum) rptdata[i][28] = text.formatDouble(itemSum, translate.text("#,##0.00"), true); //Immer zwei Nachkommastellen und ',' statt '.' rptdata[i][29] = KeywordUtils.get("UNIT", rptdata[i][20])[1]; } @@ -497,7 +503,8 @@ ItemUtils.prototype.getItemSum = function(quantity, price, discount, optional) { price = price || 0; discount = discount || 0; - return Number(optional) * parseFloat(quantity) * parseFloat(price) * ((100 - parseFloat(discount)) / 100); + return optional ? (parseFloat(quantity) * parseFloat(price) * ((100 - parseFloat(discount)) / 100)) + : 0; } /** @@ -509,7 +516,8 @@ ItemUtils.prototype.getItemVAT = function(quantity, price, discount, vat, option discount = discount || 0; vat = vat || 0; - return Number(optional) * parseFloat(quantity) * parseFloat(price) * ((100 - parseFloat(discount)) / 100) * (parseFloat(vat) / 100); + return optional ? (parseFloat(quantity) * parseFloat(price) * ((100 - parseFloat(discount)) / 100) * (parseFloat(vat) / 100)) + : 0; } /** @@ -577,7 +585,7 @@ ItemUtils.prototype.insertPartsList = function(columns, table, productId, assign var price = ""; var vat = ""; - if (P2pObject.takeprice == "Y" && ProductDetails.productId && ProductDetails.PriceListToUse) { + if (P2pObject.takeprice && ProductDetails.productId && ProductDetails.PriceListToUse) { price = ProductDetails.PriceListToUse.price; vat = ProductDetails.PriceListToUse.vat; } diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index 7f2579b0699..67263627b0a 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -66,7 +66,8 @@ ProductUtils.getStockCount = function(pid) { { var sum = db.cell(SqlCondition.begin() .andPrepare("STOCK.PRODUCT_ID", pid) - .buildSelect("select sum(QUANTITY * IN_OUT) from STOCK")); + .buildSelect("select sum(QUANTITY * case IN_OUT when 0 then -1 else 1)" + + " from STOCK")); if (sum == "") sum = "0"; @@ -385,8 +386,8 @@ function Prod2ProdUtils(productId) { * , destid: "Parent ProductID" <br> * , sourceid: "Child ProductID" <br> * , quantity: "Quantity" <br> - * , optional: "1" = not optional, "0" = optional (for easier calculation) <br> - * , takeprice: "Y" = price, "N" = no price <br> + * , optional: "0" = not optional, "1" = optional <br> + * , takeprice: "0" = no price, "1" = price <br> * } } */ Prod2ProdUtils.prototype.getPartsListObject = function() { @@ -486,11 +487,9 @@ Prod2ProdUtils.prototype.getParentProdIds = function() { */ Prod2ProdUtils.prototype._initProd2ProdData = function() { if (this.data == undefined) { - var sqlStr = "select PROD2PRODID, DEST_ID, SOURCE_ID, QUANTITY, OPTIONAL, TAKEPRICE, PRODUCTCODE " + this.data = db.table("select PROD2PRODID, DEST_ID, SOURCE_ID, QUANTITY, OPTIONAL, TAKEPRICE, PRODUCTCODE " + "from PROD2PROD join PRODUCT on PROD2PROD.SOURCE_ID = PRODUCTID " - + "order by PRODUCTCODE "; - - this.data = db.table(sqlStr); + + "order by PRODUCTCODE "); } } -- GitLab