diff --git a/entity/Contract_entity/Contract_entity.aod b/entity/Contract_entity/Contract_entity.aod index 8388d1b55c2ea8912f9b948347290f6031bd3336..cc82300d0986c441f01a2b044ab91312c9d7193c 100644 --- a/entity/Contract_entity/Contract_entity.aod +++ b/entity/Contract_entity/Contract_entity.aod @@ -3,11 +3,11 @@ <name>Contract_entity</name> <title>Contract</title> <majorModelMode>DISTRIBUTED</majorModelMode> + <alias>Data_alias</alias> + <conditionProcess>%aditoprj%/entity/Contract_entity/conditionProcess.js</conditionProcess> <recordContainerType>DB</recordContainerType> <caption>Contract</caption> <iconId>VAADIN:FORM</iconId> - <alias>Data_alias</alias> - <conditionProcess>%aditoprj%/entity/Contract_entity/conditionProcess.js</conditionProcess> <entityFields> <entityField> <name>CONTRACTCODE</name> diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 4ab172e44a1d1f5a212b7d39a4d9693d33d5ffa5..3fcc7bafc9d8cf36c79a38e03f1de41d71b27cd3 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -41,12 +41,6 @@ <mandatory v="true" /> <possibleItemsProcess>%aditoprj%/entity/Offer_entity/entityfields/language/possibleItemsProcess.js</possibleItemsProcess> </entityField> - <entityField> - <name>NET</name> - <tableName>OFFER</tableName> - <columnName>NET</columnName> - <caption>Total net</caption> - </entityField> <entityField> <name>OFFERCODE</name> <tableName>OFFER</tableName> @@ -116,6 +110,7 @@ <tableName>OFFER</tableName> <columnName>VAT</columnName> <caption>Total VAT</caption> + <state>READONLY</state> </entityField> <entityField> <name>IMAGE</name> @@ -127,6 +122,7 @@ <tableName>OFFER</tableName> <columnName>HEADER</columnName> <caption>Header text</caption> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/header/valueProcess.js</valueProcess> </entityField> <entityField> <name>FOOTER</name> @@ -153,6 +149,19 @@ <triggerRecalculation v="true" /> <mandatory v="true" /> </entityParameter> + <entityParameter> + <name>Currency_param</name> + <code>%aditoprj%/entity/Offer_entity/entityfields/offerofferitem_dfo/children/currency_param/code.js</code> + <expose v="true" /> + <triggerRecalculation v="true" /> + </entityParameter> + <entityParameter> + <name>RelationId_param</name> + <code>%aditoprj%/entity/Offer_entity/entityfields/offerofferitem_dfo/children/relationid_param/code.js</code> + <expose v="true" /> + <triggerRecalculation v="true" /> + <mandatory v="true" /> + </entityParameter> </children> </entityOutgoingField> <entityActionField> @@ -161,6 +170,25 @@ <onActionProcess>%aditoprj%/entity/Offer_entity/entityfields/newofferversion/onActionProcess.js</onActionProcess> <caption>New offer verison</caption> </entityActionField> + <entityField> + <name>PreviewTitle</name> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/previewtitle/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>NET</name> + <tableName>OFFER</tableName> + <columnName>NET</columnName> + <caption>Total net</caption> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/net/valueProcess.js</valueProcess> + <fieldIdProcess>%aditoprj%/entity/Offer_entity/entityfields/net/fieldIdProcess.js</fieldIdProcess> + </entityField> + <entityField> + <name>TotalGross</name> + <caption>Total gross</caption> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/totalgross/valueProcess.js</valueProcess> + </entityField> </entityFields> <linkInformation> <linkInformation> diff --git a/entity/Productprice_entity/entityfields/pricelist_relation/onValidation.js b/entity/Offer_entity/entityfields/header/valueProcess.js similarity index 100% rename from entity/Productprice_entity/entityfields/pricelist_relation/onValidation.js rename to entity/Offer_entity/entityfields/header/valueProcess.js diff --git a/entity/Productprice_entity/entityfields/pricelist_relation/onValueChange.js b/entity/Offer_entity/entityfields/net/fieldIdProcess.js similarity index 100% rename from entity/Productprice_entity/entityfields/pricelist_relation/onValueChange.js rename to entity/Offer_entity/entityfields/net/fieldIdProcess.js diff --git a/entity/Offer_entity/entityfields/net/valueProcess.js b/entity/Offer_entity/entityfields/net/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/entity/Offer_entity/entityfields/offerofferitem_dfo/children/currency_param/code.js b/entity/Offer_entity/entityfields/offerofferitem_dfo/children/currency_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..5e55d336c5058653f14b546e53fcc03f9dce105c --- /dev/null +++ b/entity/Offer_entity/entityfields/offerofferitem_dfo/children/currency_param/code.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.CURRENCY")); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/offerofferitem_dfo/children/relationid_param/code.js b/entity/Offer_entity/entityfields/offerofferitem_dfo/children/relationid_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..a5cee65a3ba3e16976d5f7d3952da23c73ef54da --- /dev/null +++ b/entity/Offer_entity/entityfields/offerofferitem_dfo/children/relationid_param/code.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.RELATION_ID")); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/previewtitle/valueProcess.js b/entity/Offer_entity/entityfields/previewtitle/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..d8bf28486a9cc4b31d3042ee6df5b00dbcdf6063 --- /dev/null +++ b/entity/Offer_entity/entityfields/previewtitle/valueProcess.js @@ -0,0 +1,5 @@ +import("system.translate"); +import("system.result"); +import("system.vars"); + +result.string(translate.text("Offer") + " " + vars.get("$field.OFFERCODE")); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/totalgross/valueProcess.js b/entity/Offer_entity/entityfields/totalgross/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..6e374c8f50a610ed0f50b89319726224167631d0 --- /dev/null +++ b/entity/Offer_entity/entityfields/totalgross/valueProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("system.vars"); +import("system.eMath"); + +var netValue = vars.get("$field.NET"); +var vatValue = vars.get("$field.VAT"); + +result.string( eMath.addDec(netValue, vatValue) ); \ No newline at end of file diff --git a/entity/Offeritem_entity/Offeritem_entity.aod b/entity/Offeritem_entity/Offeritem_entity.aod index e79df8ba11966550710e4281b06a5de92d3a766c..1b5b708ced210c497497f8a9b241ce03c0be477b 100644 --- a/entity/Offeritem_entity/Offeritem_entity.aod +++ b/entity/Offeritem_entity/Offeritem_entity.aod @@ -5,6 +5,9 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <alias>Data_alias</alias> <conditionProcess>%aditoprj%/entity/Offeritem_entity/conditionProcess.js</conditionProcess> + <onDBInsert>%aditoprj%/entity/Offeritem_entity/onDBInsert.js</onDBInsert> + <onDBUpdate>%aditoprj%/entity/Offeritem_entity/onDBUpdate.js</onDBUpdate> + <onDBDelete>%aditoprj%/entity/Offeritem_entity/onDBDelete.js</onDBDelete> <recordContainerType>DB</recordContainerType> <caption>Offeritem</caption> <entityFields> @@ -44,6 +47,7 @@ <tableName>OFFERITEM</tableName> <columnName>DESCRIPTION</columnName> <caption>Description</caption> + <contentType>LONG_TEXT</contentType> </entityField> <entityField> <name>DISCOUNT</name> @@ -56,6 +60,8 @@ <tableName>OFFERITEM</tableName> <columnName>GROUPCODEID</columnName> <caption>Commodity group</caption> + <possibleItemsProcess>%aditoprj%/entity/Offeritem_entity/entityfields/groupcodeid/possibleItemsProcess.js</possibleItemsProcess> + <state>READONLY</state> </entityField> <entityField> <name>ITEMNAME</name> @@ -68,6 +74,7 @@ <tableName>OFFERITEM</tableName> <columnName>ITEMPOSITION</columnName> <caption>Position</caption> + <state>READONLY</state> </entityField> <entityField> <name>ITEMSORT</name> @@ -78,6 +85,7 @@ <name>OFFERITEMID</name> <tableName>OFFERITEM</tableName> <columnName>OFFERITEMID</columnName> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/offeritemid/valueProcess.js</valueProcess> </entityField> <entityField> <name>OFFER_ID</name> @@ -90,6 +98,9 @@ <tableName>OFFERITEM</tableName> <columnName>OPTIONAL</columnName> <caption>Optional</caption> + <contentType>BOOLEAN</contentType> + <possibleItemsProcess>%aditoprj%/entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js</possibleItemsProcess> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/optional/valueProcess.js</valueProcess> </entityField> <entityField> <name>PRICE</name> @@ -102,18 +113,25 @@ <tableName>OFFERITEM</tableName> <columnName>PRODUCT_ID</columnName> <caption>Article</caption> + <possibleItemsProcess>%aditoprj%/entity/Offeritem_entity/entityfields/product_id/possibleItemsProcess.js</possibleItemsProcess> + <onValidation>%aditoprj%/entity/Offeritem_entity/entityfields/product_id/onValidation.js</onValidation> + <onValueChange>%aditoprj%/entity/Offeritem_entity/entityfields/product_id/onValueChange.js</onValueChange> </entityField> <entityField> <name>QUANTITY</name> <tableName>OFFERITEM</tableName> <columnName>QUANTITY</columnName> <caption>Quantity</caption> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/quantity/valueProcess.js</valueProcess> + <onValidation>%aditoprj%/entity/Offeritem_entity/entityfields/quantity/onValidation.js</onValidation> + <onValueChange>%aditoprj%/entity/Offeritem_entity/entityfields/quantity/onValueChange.js</onValueChange> </entityField> <entityField> <name>UNIT</name> <tableName>OFFERITEM</tableName> <columnName>UNIT</columnName> <caption>Unit</caption> + <possibleItemsProcess>%aditoprj%/entity/Offeritem_entity/entityfields/unit/possibleItemsProcess.js</possibleItemsProcess> </entityField> <entityField> <name>USER_EDIT</name> @@ -132,6 +150,7 @@ <tableName>OFFERITEM</tableName> <columnName>VAT</columnName> <caption>VAT</caption> + <state>READONLY</state> </entityField> <entityParameter> <name>OfferId_param</name> @@ -140,6 +159,31 @@ <mandatory v="true" /> <description>PARAMETER</description> </entityParameter> + <entityParameter> + <name>RelationId_param</name> + <expose v="true" /> + <triggerRecalculation v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityParameter> + <name>Currency_param</name> + <expose v="true" /> + <triggerRecalculation v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityField> + <name>TotalPrice</name> + <caption>Sum</caption> + <contentType>NUMBER</contentType> + <outputFormat>#,##0.00</outputFormat> + <state>READONLY</state> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/totalprice/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>IMAGE</name> + <contentType>IMAGE</contentType> + <valueProcess>%aditoprj%/entity/Offeritem_entity/entityfields/image/valueProcess.js</valueProcess> + </entityField> </entityFields> <linkInformation> <linkInformation> diff --git a/entity/Offeritem_entity/conditionProcess.js b/entity/Offeritem_entity/conditionProcess.js index 904a7b5517b1c1bd7f40ae87e00d2aaf3ea91b22..b39721ef89a7459add6bade8992f1d23296a84c4 100644 --- a/entity/Offeritem_entity/conditionProcess.js +++ b/entity/Offeritem_entity/conditionProcess.js @@ -5,4 +5,4 @@ import("system.vars"); if(vars.exists("$param.OfferId_param") && vars.get("$param.OfferId_param") != "") result.string("OFFERITEM.OFFER_ID = ('" + vars.get("$param.OfferId_param") + "')"); else - result.string("1 = 2"); \ No newline at end of file + result.string(""); \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/pricelist_relation/possibleItemsProcess.js b/entity/Offeritem_entity/entityfields/groupcodeid/possibleItemsProcess.js similarity index 71% rename from entity/Productprice_entity/entityfields/pricelist_relation/possibleItemsProcess.js rename to entity/Offeritem_entity/entityfields/groupcodeid/possibleItemsProcess.js index 6b44f39adb82667f216ba46a76f1b3db73f83879..ec42dede214f092bd764b4151c5a0e93fa25de84 100644 --- a/entity/Productprice_entity/entityfields/pricelist_relation/possibleItemsProcess.js +++ b/entity/Offeritem_entity/entityfields/groupcodeid/possibleItemsProcess.js @@ -4,5 +4,5 @@ import("Keyword_lib"); var kwdUtils, items; kwdUtils = new KeywordUtils(); -items = kwdUtils.getStandardArray("PRICELIST"); +items = kwdUtils.getStandardArray("GROUPCODE"); result.object(items); \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/image/valueProcess.js b/entity/Offeritem_entity/entityfields/image/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e29d35c1604de27ca8281ae2d1848e258a943efd --- /dev/null +++ b/entity/Offeritem_entity/entityfields/image/valueProcess.js @@ -0,0 +1,2 @@ +import("system.result"); +result.string("TEXT:IM"); \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/offeritemid/valueProcess.js b/entity/Offeritem_entity/entityfields/offeritemid/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..5be18c39832eee52e38b7147961d7db4bab5a588 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/offeritemid/valueProcess.js @@ -0,0 +1,7 @@ +import("system.util"); +import("system.vars"); +import("system.result"); +import("system.neon"); + +if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) + result.string(util.getNewUUID()); \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js b/entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..1dfbf04839cfeacd9b7e3af1a453f1892cea77f1 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js @@ -0,0 +1,7 @@ +import("system.translate"); +import("system.result"); + +result.object([ + ["0", translate.text("Yes")] + ,["1", 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 new file mode 100644 index 0000000000000000000000000000000000000000..04344c1e2caaa81ee9c4e8ed7c9e10c084b49f95 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/optional/valueProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("system.result"); +import("system.neon"); + +if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) + result.string("1"); \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/product_id/onValidation.js b/entity/Offeritem_entity/entityfields/product_id/onValidation.js new file mode 100644 index 0000000000000000000000000000000000000000..139597f9cb07c5d48bed18984ec4747f4b4f3438 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/product_id/onValidation.js @@ -0,0 +1,2 @@ + + diff --git a/entity/Offeritem_entity/entityfields/product_id/onValueChange.js b/entity/Offeritem_entity/entityfields/product_id/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..bdb931f90f8d6afa263804676af9479fd4ec5aa9 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/product_id/onValueChange.js @@ -0,0 +1,29 @@ +import("system.logging"); +import("system.vars"); +import("system.neon"); +import("Product_lib"); + +var pid = vars.get("$local.value"); +if(pid != "") +{ + var curr = vars.exists("$param.Currency_param") ? vars.get("$param.Currency_param") : ""; + var relid = vars.exists("$param.RelationId_param") ? vars.get("$param.RelationId_param") : ""; + + var pUtils = new ProductUtils(); + var PriceListFilter = { currency: curr, quantity: vars.get("$field.QUANTITY"), relationId: relid }; + + var ProductDetails = pUtils.getProductDetails(pid, PriceListFilter); + + if(ProductDetails[pid] != undefined) + { + vars.set("$field.GROUPCODEID", ProductDetails[pid].groupCode); + vars.set("$field.UNIT", ProductDetails[pid].unit); + vars.set("$field.ITEMNAME", ProductDetails[pid].productName); + + if(ProductDetails[pid].PriceListToUse != null) + { + vars.set("$field.PRICE", ProductDetails[pid].PriceListToUse.price); + vars.set("$field.VAT", ProductDetails[pid].PriceListToUse.vat); + } + } +} \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/product_id/possibleItemsProcess.js b/entity/Offeritem_entity/entityfields/product_id/possibleItemsProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..ece8c2eca10356f471b5d9013c36208311b4a7b6 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/product_id/possibleItemsProcess.js @@ -0,0 +1,17 @@ +import("system.logging"); +import("system.result"); +import("system.db"); +import("Sql_lib"); + +//TODO: change field to lookup field +var sqlUtils = new LegacySqlUtils(); +var prodsSql = "select PRODUCTID, " + sqlUtils.concat(["PRODUCTCODE", "'/'", "PRODUCTNAME"]) + + " from PRODUCT"; + +var prods = db.table(prodsSql); + +var retArray = []; +for(var i = 0; i < prods.length; i++) + retArray.push(prods[i]); + +result.object(retArray); \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/quantity/onValidation.js b/entity/Offeritem_entity/entityfields/quantity/onValidation.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/entity/Offeritem_entity/entityfields/quantity/onValueChange.js b/entity/Offeritem_entity/entityfields/quantity/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..5acf7788daa3af2aeb320809b1c55acdabf05908 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/quantity/onValueChange.js @@ -0,0 +1,23 @@ +import("system.logging"); +import("system.vars"); +import("system.neon"); +import("Product_lib"); + +var pid = vars.get("$field.PRODUCT_ID"); +var newQuantity = vars.get("$local.value"); +if(pid != "" && newQuantity != "") +{ + var curr = vars.exists("$param.Currency_param") ? vars.get("$param.Currency_param") : ""; + var relid = vars.exists("$param.RelationId_param") ? vars.get("$param.RelationId_param") : ""; + + var pUtils = new ProductUtils(); + var PriceListFilter = { currency: curr, quantity: newQuantity, relationId: relid }; + + var ProductDetails = pUtils.getProductDetails(pid, PriceListFilter); + + if(ProductDetails[pid] != undefined && ProductDetails[pid].PriceListToUse != null) + { + vars.set("$field.PRICE", ProductDetails[pid].PriceListToUse.price); + vars.set("$field.VAT", ProductDetails[pid].PriceListToUse.vat); + } +} \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/quantity/valueProcess.js b/entity/Offeritem_entity/entityfields/quantity/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..3aebc70e19c7c9cb3c62338a847b4759f5af2be0 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/quantity/valueProcess.js @@ -0,0 +1,10 @@ +import("system.vars"); +import("system.result"); +import("system.neon"); + +if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == "") +{ + result.string("1"); +} +else + result.string(vars.get("$this.value")); \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/totalprice/valueProcess.js b/entity/Offeritem_entity/entityfields/totalprice/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7fff82a426deedb7c0729b258be6c55dda0b19f7 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/totalprice/valueProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("system.vars"); +import("Offer_lib"); + +var oiUtils = new OfferItemUtils(); + +result.string(oiUtils.roundPrice(oiUtils.getItemSum(vars.get("$field.QUANTITY"), vars.get("$field.PRICE") + , vars.get("$field.DISCOUNT"), vars.get("$field.OPTIONAL")))); \ No newline at end of file diff --git a/entity/Offeritem_entity/entityfields/unit/possibleItemsProcess.js b/entity/Offeritem_entity/entityfields/unit/possibleItemsProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..020f0770d41377e4f1eb2a0265e64a0055ef01f0 --- /dev/null +++ b/entity/Offeritem_entity/entityfields/unit/possibleItemsProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("Keyword_lib"); + +var kwdUtils, items; + +kwdUtils = new KeywordUtils(); +items = kwdUtils.getStandardArray("UNIT"); +result.object(items); \ No newline at end of file diff --git a/entity/Offeritem_entity/onDBDelete.js b/entity/Offeritem_entity/onDBDelete.js new file mode 100644 index 0000000000000000000000000000000000000000..e7ce64e15311337b8b619f36dc75edd10eeb3c52 --- /dev/null +++ b/entity/Offeritem_entity/onDBDelete.js @@ -0,0 +1,17 @@ +import("system.neon"); +import("system.vars"); +import("system.db"); +import("Offer_lib"); + +var oid = vars.get("$field.OFFER_ID"); +if(oid != "") +{ + var cols = ["NET", "VAT"]; + var colTypes = db.getColumnTypes("OFFER", cols); + var oUtils = new OfferUtils(); + var vals = oUtils.getOfferNetAndVAT(oid, vars.get("$field.OFFERITEMID")); + + db.updateData("OFFER", cols, colTypes, vals, "OFFERID = '" + oid + "'"); + + neon.refresh("Offer_entity"); +} \ No newline at end of file diff --git a/entity/Offeritem_entity/onDBInsert.js b/entity/Offeritem_entity/onDBInsert.js new file mode 100644 index 0000000000000000000000000000000000000000..d27032ac0e449b2de5efa128292bb59561213b6f --- /dev/null +++ b/entity/Offeritem_entity/onDBInsert.js @@ -0,0 +1,17 @@ +import("system.neon"); +import("system.vars"); +import("system.db"); +import("Offer_lib"); + +var oid = vars.get("$field.OFFER_ID"); +if(oid != "") +{ + var cols = ["NET", "VAT"]; + var colTypes = db.getColumnTypes("OFFER", cols); + var oUtils = new OfferUtils(); + var vals = oUtils.getOfferNetAndVAT(oid); + + db.updateData("OFFER", cols, colTypes, vals, "OFFERID = '" + oid + "'"); + + neon.refresh("Offer_entity"); +} \ No newline at end of file diff --git a/entity/Offeritem_entity/onDBUpdate.js b/entity/Offeritem_entity/onDBUpdate.js new file mode 100644 index 0000000000000000000000000000000000000000..15e362e109713c274f3b53bc35fe30a3a99bb3ab --- /dev/null +++ b/entity/Offeritem_entity/onDBUpdate.js @@ -0,0 +1,18 @@ +import("system.logging"); +import("system.vars"); +import("system.db"); +import("system.neon"); +import("Offer_lib"); + +var oid = vars.get("$field.OFFER_ID"); +if(oid != "") +{ + var cols = ["NET", "VAT"]; + var colTypes = db.getColumnTypes("OFFER", cols); + var oUtils = new OfferUtils(); + var vals = oUtils.getOfferNetAndVAT(oid); + + db.updateData("OFFER", cols, colTypes, vals, "OFFERID = '" + oid + "'"); + + neon.refresh("Offer_entity"); +} \ No newline at end of file diff --git a/entity/Productprice_entity/Productprice_entity.aod b/entity/Productprice_entity/Productprice_entity.aod index 0ab83ab71f67b32c62d0a0994004dc3b1f75b7cc..18c204977a78bd7d91d1261dd0a6f805b6d741c7 100644 --- a/entity/Productprice_entity/Productprice_entity.aod +++ b/entity/Productprice_entity/Productprice_entity.aod @@ -5,6 +5,7 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <alias>Data_alias</alias> <conditionProcess>%aditoprj%/entity/Productprice_entity/conditionProcess.js</conditionProcess> + <orderClauseProcess>%aditoprj%/entity/Productprice_entity/orderClauseProcess.js</orderClauseProcess> <recordContainerType>DB</recordContainerType> <caption>Price list</caption> <entityFields> @@ -16,6 +17,7 @@ <mandatory v="true" /> <mandatoryProcess>%aditoprj%/entity/Productprice_entity/entityfields/buysell/mandatoryProcess.js</mandatoryProcess> <possibleItemsProcess>%aditoprj%/entity/Productprice_entity/entityfields/buysell/possibleItemsProcess.js</possibleItemsProcess> + <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/buysell/valueProcess.js</valueProcess> </entityField> <entityField> <name>CURRENCY</name> @@ -69,7 +71,7 @@ <name>PRODUCT_ID</name> <tableName>PRODUCTPRICE</tableName> <columnName>PRODUCT_ID</columnName> - <caption>Product name</caption> + <caption>Product</caption> <linkedContext>Product_context</linkedContext> <mandatory v="false" /> <outgoingField>ProductpriceProduct_dfo</outgoingField> @@ -130,8 +132,11 @@ <tableName>PRODUCTPRICE</tableName> <columnName>PRICELIST</columnName> <caption>Price list</caption> + <captionProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/captionProcess.js</captionProcess> <possibleItemsProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/possibleItemsProcess.js</possibleItemsProcess> <state>AUTO</state> + <stateProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/stateProcess.js</stateProcess> + <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist/valueProcess.js</valueProcess> </entityField> <entityIncomingField> <name>ProductProductprice_dfi</name> @@ -158,14 +163,6 @@ <mandatory v="false" /> <description>PARAMETER</description> </entityParameter> - <entityField> - <name>Pricelist_Relation</name> - <caption>Price list / Company</caption> - <possibleItemsProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist_relation/possibleItemsProcess.js</possibleItemsProcess> - <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/pricelist_relation/valueProcess.js</valueProcess> - <onValidation>%aditoprj%/entity/Productprice_entity/entityfields/pricelist_relation/onValidation.js</onValidation> - <onValueChange>%aditoprj%/entity/Productprice_entity/entityfields/pricelist_relation/onValueChange.js</onValueChange> - </entityField> <entityField> <name>PRODUCT_GROUPCODEID</name> <caption>Product group</caption> diff --git a/entity/Productprice_entity/entityfields/buysell/mandatoryProcess.js b/entity/Productprice_entity/entityfields/buysell/mandatoryProcess.js index 7808bc1144567b08f53c71a2934533fbb28bd695..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/entity/Productprice_entity/entityfields/buysell/mandatoryProcess.js +++ b/entity/Productprice_entity/entityfields/buysell/mandatoryProcess.js @@ -1,12 +0,0 @@ -import("system.logging"); -import("system.vars"); -import("system.result"); - -if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != "") -{ - result.string("true"); -} -else -{ - result.string("false"); -} \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/buysell/possibleItemsProcess.js b/entity/Productprice_entity/entityfields/buysell/possibleItemsProcess.js index 5da424e274784b45e964216aa3a62cf03bdbacc4..827f2d7a130b4b475d4a486628908a9c5929df90 100644 --- a/entity/Productprice_entity/entityfields/buysell/possibleItemsProcess.js +++ b/entity/Productprice_entity/entityfields/buysell/possibleItemsProcess.js @@ -2,6 +2,6 @@ import("system.translate"); import("system.result"); result.object([ - ["PP", translate.text("PP")], ["SP", translate.text("SP")] + , ["PP", translate.text("PP")] ]); \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/buysell/valueProcess.js b/entity/Productprice_entity/entityfields/buysell/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..334695bcf35bf986d3158845954c58707cec9755 --- /dev/null +++ b/entity/Productprice_entity/entityfields/buysell/valueProcess.js @@ -0,0 +1,6 @@ +import("system.vars"); +import("system.result"); +import("system.neon"); + +if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW && vars.get("$this.value") == "") + result.string("SP"); \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/pricelist/captionProcess.js b/entity/Productprice_entity/entityfields/pricelist/captionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..325222cf9a75416c2e498b3493b1dc5be5c893c2 --- /dev/null +++ b/entity/Productprice_entity/entityfields/pricelist/captionProcess.js @@ -0,0 +1,10 @@ +import("system.vars"); +import("system.translate"); +import("system.neon"); +import("system.result"); + +var str = translate.text("Price list"); +if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_VIEW) + str = translate.text("Price list / Company"); + +result.string(str); \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/pricelist/possibleItemsProcess.js b/entity/Productprice_entity/entityfields/pricelist/possibleItemsProcess.js index 6b44f39adb82667f216ba46a76f1b3db73f83879..23c85c28b992637216dd30c649dd607110dd9c02 100644 --- a/entity/Productprice_entity/entityfields/pricelist/possibleItemsProcess.js +++ b/entity/Productprice_entity/entityfields/pricelist/possibleItemsProcess.js @@ -1,3 +1,6 @@ +import("system.db"); +import("system.neon"); +import("system.vars"); import("system.result"); import("Keyword_lib"); @@ -5,4 +8,11 @@ var kwdUtils, items; kwdUtils = new KeywordUtils(); items = kwdUtils.getStandardArray("PRICELIST"); + +if(vars.get("$field.RELATION_ID") != "") +{ + var orgname = db.cell("select NAME from ORG join RELATION on ORG_ID = ORGID where RELATIONID = '" + vars.get("$field.RELATION_ID") + "'"); + items.push(["", orgname]); +} + result.object(items); \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/pricelist/stateProcess.js b/entity/Productprice_entity/entityfields/pricelist/stateProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7736f0d63499e5ffdee2b861d1dffb69d961f0ec --- /dev/null +++ b/entity/Productprice_entity/entityfields/pricelist/stateProcess.js @@ -0,0 +1,7 @@ +import("system.vars"); +import("system.result"); + +if(vars.get("$field.RELATION_ID") != "") + result.string("READONLY"); +else + result.string("EDITABLE"); \ No newline at end of file diff --git a/entity/Productprice_entity/entityfields/pricelist/valueProcess.js b/entity/Productprice_entity/entityfields/pricelist/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/entity/Productprice_entity/entityfields/pricelist_relation/valueProcess.js b/entity/Productprice_entity/entityfields/pricelist_relation/valueProcess.js deleted file mode 100644 index 3f9089e29c49884f47876b8d9a789ac01df256f0..0000000000000000000000000000000000000000 --- a/entity/Productprice_entity/entityfields/pricelist_relation/valueProcess.js +++ /dev/null @@ -1,16 +0,0 @@ -import("system.result"); -import("system.vars"); -import("Keyword_lib"); - -var kewUtils = new KeywordUtils(); - -var rel = vars.get("$field.RELATION_ID"); - -if(rel != "") -{ - result.string("Firma");//TODO: Org/pers Name -} -else -{ - result.string(kewUtils.getViewValue("PRICELIST", vars.get("$field.PRICELIST"))); -} \ No newline at end of file diff --git a/entity/Productprice_entity/orderClauseProcess.js b/entity/Productprice_entity/orderClauseProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..9fd0aad5a4bce2f8f7f5ca713d35f79bc1b9a7ec --- /dev/null +++ b/entity/Productprice_entity/orderClauseProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.object({"PRODUCTPRICE.VALID_FROM": "down"}); \ No newline at end of file diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index b792b088507a336429f459b8e866edfc1764882f..a37c3f2fda4e76d43298037b7924a342cea607be 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -696,6 +696,75 @@ <entry> <key>New offer verison</key> </entry> + <entry> + <key>ISO3 Code</key> + </entry> + <entry> + <key>zusagen</key> + </entry> + <entry> + <key>EU Member</key> + </entry> + <entry> + <key>Zip exists</key> + </entry> + <entry> + <key>ISO2 Code</key> + </entry> + <entry> + <key>Sum</key> + </entry> + <entry> + <key>absagen</key> + </entry> + <entry> + <key>Option4</key> + </entry> + <entry> + <key>Option3</key> + </entry> + <entry> + <key>Option2</key> + </entry> + <entry> + <key>Option1</key> + </entry> + <entry> + <key>Countries</key> + </entry> + <entry> + <key>Euro zone</key> + </entry> + <entry> + <key>NAME</key> + </entry> + <entry> + <key>Options</key> + </entry> + <entry> + <key>Country code</key> + </entry> + <entry> + <key>Country Code</key> + </entry> + <entry> + <key>PO-box name</key> + </entry> + <entry> + <key>Adress format</key> + </entry> + <entry> + <key>vielleicht</key> + </entry> + <entry> + <key>Administration</key> + </entry> + <entry> + <key>Flag</key> + </entry> + <entry> + <key>Total gross</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 2befe9354a3f1458eefcdc771769a07ca247f5a5..a3683b6322427ec28d949b94239a810293604e2a 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -909,6 +909,77 @@ <key>New offer verison</key> <value>Neue Angebotsversion</value> </entry> + <entry> + <key>ISO3 Code</key> + </entry> + <entry> + <key>zusagen</key> + </entry> + <entry> + <key>EU Member</key> + </entry> + <entry> + <key>Zip exists</key> + </entry> + <entry> + <key>ISO2 Code</key> + </entry> + <entry> + <key>Sum</key> + <value>Summe</value> + </entry> + <entry> + <key>absagen</key> + </entry> + <entry> + <key>Option4</key> + </entry> + <entry> + <key>Option3</key> + </entry> + <entry> + <key>Option2</key> + </entry> + <entry> + <key>Option1</key> + </entry> + <entry> + <key>Countries</key> + </entry> + <entry> + <key>Euro zone</key> + </entry> + <entry> + <key>NAME</key> + </entry> + <entry> + <key>Options</key> + </entry> + <entry> + <key>Country code</key> + </entry> + <entry> + <key>Country Code</key> + </entry> + <entry> + <key>PO-box name</key> + </entry> + <entry> + <key>Adress format</key> + </entry> + <entry> + <key>vielleicht</key> + </entry> + <entry> + <key>Administration</key> + </entry> + <entry> + <key>Flag</key> + </entry> + <entry> + <key>Total gross</key> + <value>Betrag brutto</value> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index 88547b926576827437d608ede7b69fb816c67337..8f1c4ca4922e38aa5735c049a17eae478d499c16 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -704,6 +704,75 @@ <entry> <key>New offer verison</key> </entry> + <entry> + <key>ISO3 Code</key> + </entry> + <entry> + <key>zusagen</key> + </entry> + <entry> + <key>EU Member</key> + </entry> + <entry> + <key>Zip exists</key> + </entry> + <entry> + <key>ISO2 Code</key> + </entry> + <entry> + <key>Sum</key> + </entry> + <entry> + <key>absagen</key> + </entry> + <entry> + <key>Option4</key> + </entry> + <entry> + <key>Option3</key> + </entry> + <entry> + <key>Option2</key> + </entry> + <entry> + <key>Option1</key> + </entry> + <entry> + <key>Countries</key> + </entry> + <entry> + <key>Euro zone</key> + </entry> + <entry> + <key>NAME</key> + </entry> + <entry> + <key>Options</key> + </entry> + <entry> + <key>Country code</key> + </entry> + <entry> + <key>Country Code</key> + </entry> + <entry> + <key>PO-box name</key> + </entry> + <entry> + <key>Adress format</key> + </entry> + <entry> + <key>vielleicht</key> + </entry> + <entry> + <key>Administration</key> + </entry> + <entry> + <key>Flag</key> + </entry> + <entry> + <key>Total gross</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/neonContext/Offeritem_context/Offeritem_context.aod b/neonContext/Offeritem_context/Offeritem_context.aod index bbfcab9649ab51bd109a53945a6a54e42686bfbc..d541a52c517c3226f5605c3e52c7520dfa07e3ad 100644 --- a/neonContext/Offeritem_context/Offeritem_context.aod +++ b/neonContext/Offeritem_context/Offeritem_context.aod @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <neonContext 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/neonContext/1.0.0"> <name>Offeritem_context</name> + <title>Offeritem</title> <majorModelMode>DISTRIBUTED</majorModelMode> + <filterview>OfferitemFilter_view</filterview> + <preview>OfferitemPreview_view</preview> <entity>Offeritem_entity</entity> <references> <neonViewReference> diff --git a/neonView/OfferPreview_view/OfferPreview_view.aod b/neonView/OfferPreview_view/OfferPreview_view.aod index d639c0b4f7c4d5134e511749ef64ff9f3b97b0f3..c9b1bb992940cd5becb6ce76339038340b54a6b9 100644 --- a/neonView/OfferPreview_view/OfferPreview_view.aod +++ b/neonView/OfferPreview_view/OfferPreview_view.aod @@ -11,7 +11,7 @@ <cardViewTemplate> <name>OfferHeader_template</name> <iconField>IMAGE</iconField> - <titleField>OFFERCODE</titleField> + <titleField>PreviewTitle</titleField> <descriptionField>RELATION_ID</descriptionField> <entityField>#ENTITY</entityField> </cardViewTemplate> @@ -33,13 +33,17 @@ <entityField>LANGUAGE</entityField> </entityFieldLink> <entityFieldLink> - <name>9e876b07-3029-42fe-a1e7-5c19b845e50d</name> + <name>4843f0f0-4ee8-47c2-bc0f-99241bad4c51</name> <entityField>NET</entityField> </entityFieldLink> <entityFieldLink> <name>cd72899a-69b2-4fe2-bf58-4fb9f594324e</name> <entityField>VAT</entityField> </entityFieldLink> + <entityFieldLink> + <name>10d8f38b-1e01-45a1-bc57-424284bf87be</name> + <entityField>TotalGross</entityField> + </entityFieldLink> <entityFieldLink> <name>16d38881-d3d3-4c4d-9f23-39d60eadce8d</name> <entityField>CURRENCY</entityField> @@ -52,6 +56,10 @@ <name>3317b73e-68e8-41a8-a678-89c7c7c8513e</name> <entityField>SALESPROJECT_ID</entityField> </entityFieldLink> + <entityFieldLink> + <name>683e3a86-0f9f-4b40-85c0-ae102a5a4a9a</name> + <entityField>HEADER</entityField> + </entityFieldLink> </fields> </genericViewTemplate> </children> diff --git a/neonView/OfferitemFilter_view/OfferitemFilter_view.aod b/neonView/OfferitemFilter_view/OfferitemFilter_view.aod index ec94cab9bee6ab6e9b5adf44202c92331bec418b..481f23266f24a2ec1e102aec6645739475d23e7e 100644 --- a/neonView/OfferitemFilter_view/OfferitemFilter_view.aod +++ b/neonView/OfferitemFilter_view/OfferitemFilter_view.aod @@ -10,6 +10,7 @@ <children> <tableViewTemplate> <name>OfferitemFilter_table</name> + <autoNewRow v="true" /> <entityField>#ENTITY</entityField> <columns> <neonTableColumn> @@ -18,7 +19,7 @@ </neonTableColumn> <neonTableColumn> <name>545f79bf-2fee-4112-9541-0889d0e514eb</name> - <entityField>ITEMNAME</entityField> + <entityField>PRODUCT_ID</entityField> </neonTableColumn> <neonTableColumn> <name>2a907da4-b48d-4933-bc17-a40e7d4556f9</name> diff --git a/neonView/OfferitemPreview_view/OfferitemPreview_view.aod b/neonView/OfferitemPreview_view/OfferitemPreview_view.aod index 467fadca47f07681dabc81aa3f3686000323ea40..48c2b919c5c99ecc9e4ad2babe5a431fb44b2ecf 100644 --- a/neonView/OfferitemPreview_view/OfferitemPreview_view.aod +++ b/neonView/OfferitemPreview_view/OfferitemPreview_view.aod @@ -10,8 +10,29 @@ <children> <cardViewTemplate> <name>OfferitemPreview_header</name> + <iconField>IMAGE</iconField> <titleField>ITEMNAME</titleField> <descriptionField>DESCRIPTION</descriptionField> + <entityField>#ENTITY</entityField> </cardViewTemplate> + <genericViewTemplate> + <name>Offeritem_generic</name> + <showDrawer v="true" /> + <entityField>#ENTITY</entityField> + <fields> + <entityFieldLink> + <name>9868560c-41c7-4641-b0f1-627a61b796b3</name> + <entityField>TotalPrice</entityField> + </entityFieldLink> + <entityFieldLink> + <name>c0c04d1c-90a7-4c0b-9323-1f0783757987</name> + <entityField>GROUPCODEID</entityField> + </entityFieldLink> + <entityFieldLink> + <name>e25386dc-a740-4f93-a1f0-32317cf5a36a</name> + <entityField>OPTIONAL</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> </children> </neonView> diff --git a/neonView/ProductpriceFilter_view/ProductpriceFilter_view.aod b/neonView/ProductpriceFilter_view/ProductpriceFilter_view.aod index 1c56c25712bcf4b6c50bad7737801cbf34810b61..96f22def03c732f18052ddd63f262f037c0b3ded 100644 --- a/neonView/ProductpriceFilter_view/ProductpriceFilter_view.aod +++ b/neonView/ProductpriceFilter_view/ProductpriceFilter_view.aod @@ -20,7 +20,7 @@ </neonTableColumn> <neonTableColumn> <name>695ce7be-d738-48a9-833d-e8815c6eff74</name> - <entityField>Pricelist_Relation</entityField> + <entityField>PRICELIST</entityField> </neonTableColumn> <neonTableColumn> <name>472a96ca-10ff-49c7-b2ae-6550e04c4e6f</name> diff --git a/neonView/ProductpriceRelation_view/ProductpriceRelation_view.aod b/neonView/ProductpriceRelation_view/ProductpriceRelation_view.aod index 3d65425be7d9285d965e27d67589c0b096c87e43..861b1d1178595c2b98e2fbc557f4d8de0128ea3a 100644 --- a/neonView/ProductpriceRelation_view/ProductpriceRelation_view.aod +++ b/neonView/ProductpriceRelation_view/ProductpriceRelation_view.aod @@ -18,10 +18,6 @@ <name>bc7ca35e-c454-4cc0-9b2e-0656e03f1f65</name> <entityField>IMAGE</entityField> </neonTableColumn> - <neonTableColumn> - <name>0b2271ca-f55f-4339-b63f-f6f95d1d18e6</name> - <entityField>PRODUCT_GROUPCODEID</entityField> - </neonTableColumn> <neonTableColumn> <name>9b809450-cbe5-40f3-8d64-b4a5bac5eb5b</name> <entityField>PRODUCT_ID</entityField> @@ -46,6 +42,10 @@ <name>20efd64c-297d-4774-b020-437d3610e798</name> <entityField>CURRENCY</entityField> </neonTableColumn> + <neonTableColumn> + <name>787d2cce-ddb0-4d7e-8df4-5675e0d96d76</name> + <entityField>VAT</entityField> + </neonTableColumn> </columns> </tableViewTemplate> </children> diff --git a/process/Offer_lib/process.js b/process/Offer_lib/process.js index d142a7bc54e17f5950585a38c7fdd81f56c0ace9..b7c05285b8fb45833a699b54a8901fae47fab9e7 100644 --- a/process/Offer_lib/process.js +++ b/process/Offer_lib/process.js @@ -30,4 +30,51 @@ function OfferUtils(){ this.getOfferNumberValidationFailString = function(){ return translate.text("The offer number already exists!"); } + + this.getOfferNetAndVAT = function(pOfferId, pOfferitemIdToDel){ + //TODO: Bessere Möglichkeit als per SQL die zugehörigen Posten aus der DB zu holen? + var sum = 0; + var vat = 0; + var oiUtils = new OfferItemUtils(); + + var condition = "where OFFER_ID = '" + pOfferId + "'"; + if(pOfferitemIdToDel != undefined) + condition += " and OFFERITEMID <> '" + pOfferitemIdToDel + "'"; + + var offerItems = db.table("select QUANTITY, PRICE, DISCOUNT, VAT, OPTIONAL " + + "from OFFERITEM " + condition); + + for(var i = 0; i < offerItems.length; i++){ + sum += oiUtils.getItemSum(offerItems[i][0], offerItems[i][1], offerItems[i][2], offerItems[i][4]); + vat += oiUtils.getItemVAT(offerItems[i][0], offerItems[i][1], offerItems[i][2], offerItems[i][3], offerItems[i][4]); + } + + return [sum, vat]; + } +} + +function OfferItemUtils(){ + + this.getItemSum = function(pQuantity, pPrice, pDiscount, pOptional){ + + pQuantity = pQuantity || 0; + pPrice = pPrice || 0; + pDiscount = pDiscount || 0; + + return Number(pOptional) * parseFloat(pQuantity) * parseFloat(pPrice) * ((100 - parseFloat(pDiscount)) / 100); + } + + this.getItemVAT = function(pQuantity, pPrice, pDiscount, pVAT, pOptional){ + + pQuantity = pQuantity || 0; + pPrice = pPrice || 0; + pDiscount = pDiscount || 0; + pVAT = pVAT || 0; + + return Number(pOptional) * parseFloat(pQuantity) * parseFloat(pPrice) * ((100 - parseFloat(pDiscount)) / 100) * (parseFloat(pVAT) / 100); + } + + this.roundPrice = function(pPrice){ + return eMath.roundDec(pPrice, 2, eMath.ROUND_HALF_UP); + } } \ No newline at end of file diff --git a/process/Product_lib/process.js b/process/Product_lib/process.js index dd841c2a86f1b5d8c279ffebd4902d8950f292d4..0d4f9f1d184b6c6b5d8254fbe04322d3e3c0c947 100644 --- a/process/Product_lib/process.js +++ b/process/Product_lib/process.js @@ -64,4 +64,120 @@ function ProductUtils() throw new Error();//TODO: add message } } + + /** + * Delivers the stock + * + * @param pPid {String} ProductID + * + * @example productUtils.getStockCount(vars.get("$field.PRODUCTID")) + * + * @result {String} stock count + */ + this.getProductDetails = function( pPid, pPriceListFilter ) + { + var ProductDetails = {}; + + var cols = []; + var colsProduct = ["PRODUCT.PRODUCTID", "PRODUCT.PRODUCTNAME", "PRODUCT.GROUPCODEID", "PRODUCT.UNIT"]; + cols = cols.concat(colsProduct); + + var joins = []; + var conditions = ["1=1"]; + var orderby = ["PRODUCTID"]; + var sqltypes = []; + + //Prod2Prod + //TODO: get product structure + + //PriceList + if(pPriceListFilter != undefined + && pPriceListFilter.currency != undefined && pPriceListFilter.currency != "" + && pPriceListFilter.quantity != undefined && pPriceListFilter.quantity != "") + { + var colsPricelist = ["PRODUCTPRICE.PRODUCTPRICEID", "PRODUCTPRICE.RELATION_ID", "PRODUCTPRICE.PRICELIST", "PRODUCTPRICE.PRICE", "PRODUCTPRICE.VAT"]; + cols = cols.concat(colsPricelist); + joins.push(" left join PRODUCTPRICE on PRODUCTPRICE.PRODUCT_ID = PRODUCTID " + + " and PRODUCTPRICE.CURRENCY = " + pPriceListFilter.currency + + " and PRODUCTPRICE.VALID_FROM <= ? and (PRODUCTPRICE.VALID_TO > ? or PRODUCTPRICE.VALID_TO is null) " + + " and PRODUCTPRICE.FROMQUANTITY <= " + pPriceListFilter.quantity + + " and (PRODUCTPRICE.RELATION_ID = '" + pPriceListFilter.relationId + "' or (PRODUCTPRICE.RELATION_ID is null and PRODUCTPRICE.BUYSELL = 'SP')) "); + + sqltypes.push([datetime.date().toString(), SQLTYPES.TIMESTAMP]); + sqltypes.push([datetime.date().toString(), SQLTYPES.TIMESTAMP]); + orderby = orderby.concat(["PRODUCTPRICE.VALID_FROM desc, PRODUCTPRICE.FROMQUANTITY desc"]); + } + + var ProductDataSql = "select " + cols.join(", ") + + " from PRODUCT " + + joins.join(" ") + + " where PRODUCTID = '" + pPid + "' " + + " and " + conditions.join(" and ") + + " order by " + orderby.join(", "); + + + var ProductData = db.table([ProductDataSql, sqltypes]); + + for(var i = 0; i < ProductData.length; i++) + { + //Product + if(ProductDetails[ProductData[i][0]] == undefined) + { + ProductDetails[ProductData[i][0]] = { + productId: ProductData[i][0] + , productName: ProductData[i][1] + , groupCode: ProductData[i][2] + , unit: ProductData[i][3] + , Prod2Prod: {} + , CurrentValidPriceLists: {} + , PriceListToUse: null + }; + } + //Pricelist + var colIdx = colsProduct.length; + if(ProductData[i][colIdx] != "") //Pricelist found + { + ProductDetails[ProductData[i][0]].CurrentValidPriceLists[ProductData[i][colIdx]] = { + priceListId: ProductData[i][colIdx++] + , relationId: ProductData[i][colIdx++] + , priceList: ProductData[i][colIdx++] + , price: ProductData[i][colIdx++] + , vat: ProductData[i][colIdx++] + } + } + } + + ProductDetails[pPid].PriceListToUse = _getPriceListToUse(ProductDetails[pPid].CurrentValidPriceLists, pPriceListFilter); + + return ProductDetails; + + + function _getPriceListToUse(pPriceLists, pPriceListFilter) + { + for(var list in pPriceLists) + { + //customer specific price (defined in Org -> Conditions) + if(pPriceListFilter.relationId != "" && pPriceListFilter.relationId == pPriceLists[list].relationId) + { + return pPriceLists[list]; + } + //customer deposited price list (defined by Attribute) + if(pPriceListFilter.priceList != "" && pPriceListFilter.priceList == pPriceLists[list].priceList) + { + return pPriceLists[list]; + } + //default price list + if(pPriceLists[list].priceList == "1") + { + return pPriceLists[list]; + } + } + + //no valid price list found + return null; + } + } + + + } \ No newline at end of file