From 00113367a7f108e7f0568c88930c40c0ae16a747 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maximilian=20Schr=C3=B6ger?= <m.schroeger@adito.de>
Date: Mon, 5 Nov 2018 15:53:06 +0100
Subject: [PATCH] Angebot/Angebotsposten Preislogik

---
 entity/Contract_entity/Contract_entity.aod    |   4 +-
 entity/Offer_entity/Offer_entity.aod          |  40 +++++-
 .../entityfields/header/valueProcess.js}      |   0
 .../entityfields/net/fieldIdProcess.js}       |   0
 .../entityfields/net/valueProcess.js          |   0
 .../children/currency_param/code.js           |   4 +
 .../children/relationid_param/code.js         |   4 +
 .../entityfields/previewtitle/valueProcess.js |   5 +
 .../entityfields/totalgross/valueProcess.js   |   8 ++
 entity/Offeritem_entity/Offeritem_entity.aod  |  44 +++++++
 entity/Offeritem_entity/conditionProcess.js   |   2 +-
 .../groupcodeid}/possibleItemsProcess.js      |   2 +-
 .../entityfields/image/valueProcess.js        |   2 +
 .../entityfields/offeritemid/valueProcess.js  |   7 ++
 .../optional/possibleItemsProcess.js          |   7 ++
 .../entityfields/optional/valueProcess.js     |   6 +
 .../entityfields/product_id/onValidation.js   |   2 +
 .../entityfields/product_id/onValueChange.js  |  29 +++++
 .../product_id/possibleItemsProcess.js        |  17 +++
 .../entityfields/quantity/onValidation.js     |   0
 .../entityfields/quantity/onValueChange.js    |  23 ++++
 .../entityfields/quantity/valueProcess.js     |  10 ++
 .../entityfields/totalprice/valueProcess.js   |   8 ++
 .../entityfields/unit/possibleItemsProcess.js |   8 ++
 entity/Offeritem_entity/onDBDelete.js         |  17 +++
 entity/Offeritem_entity/onDBInsert.js         |  17 +++
 entity/Offeritem_entity/onDBUpdate.js         |  18 +++
 .../Productprice_entity.aod                   |  15 +--
 .../entityfields/buysell/mandatoryProcess.js  |  12 --
 .../buysell/possibleItemsProcess.js           |   2 +-
 .../entityfields/buysell/valueProcess.js      |   6 +
 .../entityfields/pricelist/captionProcess.js  |  10 ++
 .../pricelist/possibleItemsProcess.js         |  10 ++
 .../entityfields/pricelist/stateProcess.js    |   7 ++
 .../entityfields/pricelist/valueProcess.js    |   0
 .../pricelist_relation/valueProcess.js        |  16 ---
 .../Productprice_entity/orderClauseProcess.js |   3 +
 .../_____LANGUAGE_EXTRA.aod                   |  69 +++++++++++
 .../_____LANGUAGE_de/_____LANGUAGE_de.aod     |  71 +++++++++++
 .../_____LANGUAGE_en/_____LANGUAGE_en.aod     |  69 +++++++++++
 .../Offeritem_context/Offeritem_context.aod   |   3 +
 .../OfferPreview_view/OfferPreview_view.aod   |  12 +-
 .../OfferitemFilter_view.aod                  |   3 +-
 .../OfferitemPreview_view.aod                 |  21 ++++
 .../ProductpriceFilter_view.aod               |   2 +-
 .../ProductpriceRelation_view.aod             |   8 +-
 process/Offer_lib/process.js                  |  47 +++++++
 process/Product_lib/process.js                | 116 ++++++++++++++++++
 48 files changed, 730 insertions(+), 56 deletions(-)
 rename entity/{Productprice_entity/entityfields/pricelist_relation/onValidation.js => Offer_entity/entityfields/header/valueProcess.js} (100%)
 rename entity/{Productprice_entity/entityfields/pricelist_relation/onValueChange.js => Offer_entity/entityfields/net/fieldIdProcess.js} (100%)
 create mode 100644 entity/Offer_entity/entityfields/net/valueProcess.js
 create mode 100644 entity/Offer_entity/entityfields/offerofferitem_dfo/children/currency_param/code.js
 create mode 100644 entity/Offer_entity/entityfields/offerofferitem_dfo/children/relationid_param/code.js
 create mode 100644 entity/Offer_entity/entityfields/previewtitle/valueProcess.js
 create mode 100644 entity/Offer_entity/entityfields/totalgross/valueProcess.js
 rename entity/{Productprice_entity/entityfields/pricelist_relation => Offeritem_entity/entityfields/groupcodeid}/possibleItemsProcess.js (71%)
 create mode 100644 entity/Offeritem_entity/entityfields/image/valueProcess.js
 create mode 100644 entity/Offeritem_entity/entityfields/offeritemid/valueProcess.js
 create mode 100644 entity/Offeritem_entity/entityfields/optional/possibleItemsProcess.js
 create mode 100644 entity/Offeritem_entity/entityfields/optional/valueProcess.js
 create mode 100644 entity/Offeritem_entity/entityfields/product_id/onValidation.js
 create mode 100644 entity/Offeritem_entity/entityfields/product_id/onValueChange.js
 create mode 100644 entity/Offeritem_entity/entityfields/product_id/possibleItemsProcess.js
 create mode 100644 entity/Offeritem_entity/entityfields/quantity/onValidation.js
 create mode 100644 entity/Offeritem_entity/entityfields/quantity/onValueChange.js
 create mode 100644 entity/Offeritem_entity/entityfields/quantity/valueProcess.js
 create mode 100644 entity/Offeritem_entity/entityfields/totalprice/valueProcess.js
 create mode 100644 entity/Offeritem_entity/entityfields/unit/possibleItemsProcess.js
 create mode 100644 entity/Offeritem_entity/onDBDelete.js
 create mode 100644 entity/Offeritem_entity/onDBInsert.js
 create mode 100644 entity/Offeritem_entity/onDBUpdate.js
 create mode 100644 entity/Productprice_entity/entityfields/buysell/valueProcess.js
 create mode 100644 entity/Productprice_entity/entityfields/pricelist/captionProcess.js
 create mode 100644 entity/Productprice_entity/entityfields/pricelist/stateProcess.js
 create mode 100644 entity/Productprice_entity/entityfields/pricelist/valueProcess.js
 delete mode 100644 entity/Productprice_entity/entityfields/pricelist_relation/valueProcess.js
 create mode 100644 entity/Productprice_entity/orderClauseProcess.js

diff --git a/entity/Contract_entity/Contract_entity.aod b/entity/Contract_entity/Contract_entity.aod
index 8388d1b55c..cc82300d09 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 4ab172e44a..3fcc7bafc9 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 0000000000..e69de29bb2
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 0000000000..5e55d336c5
--- /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 0000000000..a5cee65a3b
--- /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 0000000000..d8bf28486a
--- /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 0000000000..6e374c8f50
--- /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 e79df8ba11..1b5b708ced 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 904a7b5517..b39721ef89 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 6b44f39adb..ec42dede21 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 0000000000..e29d35c160
--- /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 0000000000..5be18c3983
--- /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 0000000000..1dfbf04839
--- /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 0000000000..04344c1e2c
--- /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 0000000000..139597f9cb
--- /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 0000000000..bdb931f90f
--- /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 0000000000..ece8c2eca1
--- /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 0000000000..e69de29bb2
diff --git a/entity/Offeritem_entity/entityfields/quantity/onValueChange.js b/entity/Offeritem_entity/entityfields/quantity/onValueChange.js
new file mode 100644
index 0000000000..5acf7788da
--- /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 0000000000..3aebc70e19
--- /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 0000000000..7fff82a426
--- /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 0000000000..020f0770d4
--- /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 0000000000..e7ce64e153
--- /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 0000000000..d27032ac0e
--- /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 0000000000..15e362e109
--- /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 0ab83ab71f..18c204977a 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 7808bc1144..e69de29bb2 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 5da424e274..827f2d7a13 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 0000000000..334695bcf3
--- /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 0000000000..325222cf9a
--- /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 6b44f39adb..23c85c28b9 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 0000000000..7736f0d634
--- /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 0000000000..e69de29bb2
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 3f9089e29c..0000000000
--- 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 0000000000..9fd0aad5a4
--- /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 b792b08850..a37c3f2fda 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 2befe9354a..a3683b6322 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 88547b9265..8f1c4ca492 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 bbfcab9649..d541a52c51 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 d639c0b4f7..c9b1bb9929 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 ec94cab9be..481f23266f 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 467fadca47..48c2b919c5 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 1c56c25712..96f22def03 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 3d65425be7..861b1d1178 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 d142a7bc54..b7c05285b8 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 dd841c2a86..0d4f9f1d18 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
-- 
GitLab