From eb79a11f4d6499397396dd390adb62c1323f68e0 Mon Sep 17 00:00:00 2001
From: Benjamin Ulrich <b.ulrich@adito.de>
Date: Wed, 10 Jun 2020 08:13:10 +0000
Subject: [PATCH] =?UTF-8?q?[Projekt:=20Entwicklung=20-=20Neon][TicketNr.:?=
 =?UTF-8?q?=201049870][Preiskonditionen=20in=20Firma=20flasche=20Darstellu?=
 =?UTF-8?q?ng=20der=20Tabellenspalte=20"ab=20St=C3=BCckzahl"]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Productprice_entity.aod                   |  8 ++++++-
 .../fromquantity/displayValueProcess.js       | 16 ++++++++++++++
 .../entityfields/fromquantity/titleProcess.js | 21 +++++++++++++++++++
 .../fromquantity.displayvalue/expression.js   | 14 +++++++++++++
 .../_____LANGUAGE_EXTRA.aod                   | 20 ++++++++++++++----
 .../_____LANGUAGE_de/_____LANGUAGE_de.aod     | 21 +++++++++++++++----
 .../_____LANGUAGE_en/_____LANGUAGE_en.aod     | 20 ++++++++++++++----
 7 files changed, 107 insertions(+), 13 deletions(-)
 create mode 100644 entity/Productprice_entity/entityfields/fromquantity/displayValueProcess.js
 create mode 100644 entity/Productprice_entity/entityfields/fromquantity/titleProcess.js
 create mode 100644 entity/Productprice_entity/recordcontainers/db/recordfieldmappings/fromquantity.displayvalue/expression.js

diff --git a/entity/Productprice_entity/Productprice_entity.aod b/entity/Productprice_entity/Productprice_entity.aod
index 6d1292a402..a6d245878b 100644
--- a/entity/Productprice_entity/Productprice_entity.aod
+++ b/entity/Productprice_entity/Productprice_entity.aod
@@ -30,13 +30,15 @@
     </entityField>
     <entityField>
       <name>FROMQUANTITY</name>
-      <title>From no. of units</title>
+      <title>Valid from</title>
       <contentType>NUMBER</contentType>
       <outputFormat>#,##0</outputFormat>
       <inputFormat>#,##0</inputFormat>
       <mandatory v="true" />
       <state>AUTO</state>
+      <titleProcess>%aditoprj%/entity/Productprice_entity/entityfields/fromquantity/titleProcess.js</titleProcess>
       <valueProcess>%aditoprj%/entity/Productprice_entity/entityfields/fromquantity/valueProcess.js</valueProcess>
+      <displayValueProcess>%aditoprj%/entity/Productprice_entity/entityfields/fromquantity/displayValueProcess.js</displayValueProcess>
     </entityField>
     <entityField>
       <name>PRICE</name>
@@ -317,6 +319,10 @@
           <name>PRODUCT_ID.displayValue</name>
           <expression>%aditoprj%/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/product_id.displayvalue/expression.js</expression>
         </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>FROMQUANTITY.displayValue</name>
+          <expression>%aditoprj%/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/fromquantity.displayvalue/expression.js</expression>
+        </dbRecordFieldMapping>
       </recordFieldMappings>
     </dbRecordContainer>
   </recordContainers>
diff --git a/entity/Productprice_entity/entityfields/fromquantity/displayValueProcess.js b/entity/Productprice_entity/entityfields/fromquantity/displayValueProcess.js
new file mode 100644
index 0000000000..7b30f11d5e
--- /dev/null
+++ b/entity/Productprice_entity/entityfields/fromquantity/displayValueProcess.js
@@ -0,0 +1,16 @@
+import("KeywordRegistry_basic");
+import("Keyword_lib");
+import("Sql_lib");
+import("system.result");
+import("system.vars");
+
+
+var value = vars.get("$field.FROMQUANTITY")
+var productid = vars.get("$field.PRODUCT_ID")
+var unit = newSelect("UNIT")
+                    .from("PRODUCT")
+                    .where("PRODUCT.PRODUCTID", productid)
+                    .cell();
+
+if(value)
+    result.string(value + " " + KeywordUtils.getViewValue($KeywordRegistry.quantityUnit(), unit));
diff --git a/entity/Productprice_entity/entityfields/fromquantity/titleProcess.js b/entity/Productprice_entity/entityfields/fromquantity/titleProcess.js
new file mode 100644
index 0000000000..c1ace705cd
--- /dev/null
+++ b/entity/Productprice_entity/entityfields/fromquantity/titleProcess.js
@@ -0,0 +1,21 @@
+import("system.translate");
+import("KeywordRegistry_basic");
+import("Keyword_lib");
+import("Sql_lib");
+import("system.result");
+import("system.vars");
+import("system.neon")
+
+if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && 
+    vars.get("$field.PRODUCT_ID") != null && vars.get("$field.PRODUCT_ID") != undefined && vars.get("$field.PRODUCT_ID") != "")
+{
+    var productid = vars.get("$field.PRODUCT_ID")
+    var unit = newSelect("UNIT")
+                    .from("PRODUCT")
+                    .where("PRODUCT.PRODUCTID", productid)
+                    .cell();
+                    
+    result.string(translate.text("Valid from (as ") + KeywordUtils.getViewValue($KeywordRegistry.quantityUnit(), unit) + ")");
+}
+else
+    result.string(translate.text("Valid from"));
\ No newline at end of file
diff --git a/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/fromquantity.displayvalue/expression.js b/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/fromquantity.displayvalue/expression.js
new file mode 100644
index 0000000000..9d2ad81500
--- /dev/null
+++ b/entity/Productprice_entity/recordcontainers/db/recordfieldmappings/fromquantity.displayvalue/expression.js
@@ -0,0 +1,14 @@
+import("system.result");
+import("KeywordRegistry_basic");
+import("Keyword_lib");
+import("system.SQLTYPES");
+import("Sql_lib");
+
+
+var helper = new SqlMaskingUtils();
+
+var res =  newSelect(helper.concat([helper.cast("PRODUCTPRICE.FROMQUANTITY", SQLTYPES.CHAR, 36), "' '", KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.quantityUnit(), "PRODUCT.UNIT")], "|"))
+                        .from("PRODUCT")
+                        .where("PRODUCT.PRODUCTID = PRODUCTPRICE.PRODUCT_ID")
+                        .toString()
+result.string(res)
\ No newline at end of file
diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
index cfa2e9c9be..089944a564 100644
--- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
+++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod
@@ -6773,9 +6773,6 @@
     <entry>
       <key>Offer No.</key>
     </entry>
-    <entry>
-      <key>Version %0</key>
-    </entry>
     <entry>
       <key>of other on this employee's calendar</key>
     </entry>
@@ -6786,7 +6783,22 @@
       <key>Offerrequest</key>
     </entry>
     <entry>
-      <key>data</key>
+      <key>Full Permissions</key>
+    </entry>
+    <entry>
+      <key>Full permissions already assigned</key>
+    </entry>
+    <entry>
+      <key>Import Daten</key>
+    </entry>
+    <entry>
+      <key>Import Logs</key>
+    </entry>
+    <entry>
+      <key>Transferdaten</key>
+    </entry>
+    <entry>
+      <key>Valid from (as </key>
     </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
index 297c496a68..2200e100f0 100644
--- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
+++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod
@@ -8681,9 +8681,6 @@ Bitte Datumseingabe prüfen</value>
       <key>Offer No.</key>
       <value>Angebots Nr.</value>
     </entry>
-    <entry>
-      <key>Version %0</key>
-    </entry>
     <entry>
       <key>of other on this employee's calendar</key>
       <value>von den Anderen auf den Kalender dieses Mitarbeiters</value>
@@ -8697,7 +8694,23 @@ Bitte Datumseingabe prüfen</value>
       <value>Angebotsanfrage</value>
     </entry>
     <entry>
-      <key>data</key>
+      <key>Full Permissions</key>
+    </entry>
+    <entry>
+      <key>Full permissions already assigned</key>
+    </entry>
+    <entry>
+      <key>Import Daten</key>
+    </entry>
+    <entry>
+      <key>Import Logs</key>
+    </entry>
+    <entry>
+      <key>Transferdaten</key>
+    </entry>
+    <entry>
+      <key>Valid from (as </key>
+      <value>gültig ab (in </value>
     </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
index 6b3c84ea62..d59ca73aff 100644
--- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
+++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod
@@ -6838,9 +6838,6 @@
     <entry>
       <key>Offer No.</key>
     </entry>
-    <entry>
-      <key>Version %0</key>
-    </entry>
     <entry>
       <key>of other on this employee's calendar</key>
     </entry>
@@ -6851,7 +6848,22 @@
       <key>Offerrequest</key>
     </entry>
     <entry>
-      <key>data</key>
+      <key>Full Permissions</key>
+    </entry>
+    <entry>
+      <key>Full permissions already assigned</key>
+    </entry>
+    <entry>
+      <key>Import Daten</key>
+    </entry>
+    <entry>
+      <key>Import Logs</key>
+    </entry>
+    <entry>
+      <key>Transferdaten</key>
+    </entry>
+    <entry>
+      <key>Valid from (as </key>
     </entry>
   </keyValueMap>
   <font name="Dialog" style="0" size="11" />
-- 
GitLab