From 46442d12454a986bb00c63c5d86b82c534d10153 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maximilian=20Schr=C3=B6ger?= <m.schroeger@adito.de>
Date: Tue, 9 Oct 2018 10:00:22 +0200
Subject: [PATCH] Fertigstellung Standard Produkt Maske

---
 entity/Org_entity/Org_entity.aod              |  6 ++
 .../children/orgid_param/code.js              |  4 ++
 entity/Product_entity/Product_entity.aod      | 41 ++++++++++++++
 .../advertising/possibleItemsProcess.js       |  7 +++
 .../entityfields/advertising/valueProcess.js  |  6 ++
 .../entityfields/date_edit/valueProcess.js    |  6 ++
 .../entityfields/date_new/valueProcess.js     |  8 +++
 .../entityfields/org_id/valueProcess.js       | 12 ++++
 .../entityfields/productcode/onValidation.js  | 12 ++++
 .../status/possibleItemsProcess.js            |  7 +++
 .../entityfields/status/valueProcess.js       |  6 ++
 .../entityfields/unit/possibleItemsProcess.js |  8 +++
 .../entityfields/user_edit/valueProcess.js    |  6 ++
 .../entityfields/user_new/valueProcess.js     |  6 ++
 .../ProductFilter_view/ProductFilter_view.aod | 12 ++++
 .../ProductPreview_view.aod                   | 56 +++++++++++++++++++
 .../_____PREFERENCES_PROJECT.aod              |  2 +-
 process/Keyword_lib/process.js                |  8 +++
 18 files changed, 212 insertions(+), 1 deletion(-)
 create mode 100644 entity/Org_entity/entityfields/orgproduct_dfo/children/orgid_param/code.js
 create mode 100644 entity/Product_entity/entityfields/advertising/possibleItemsProcess.js
 create mode 100644 entity/Product_entity/entityfields/advertising/valueProcess.js
 create mode 100644 entity/Product_entity/entityfields/date_edit/valueProcess.js
 create mode 100644 entity/Product_entity/entityfields/date_new/valueProcess.js
 create mode 100644 entity/Product_entity/entityfields/org_id/valueProcess.js
 create mode 100644 entity/Product_entity/entityfields/productcode/onValidation.js
 create mode 100644 entity/Product_entity/entityfields/status/possibleItemsProcess.js
 create mode 100644 entity/Product_entity/entityfields/status/valueProcess.js
 create mode 100644 entity/Product_entity/entityfields/unit/possibleItemsProcess.js
 create mode 100644 entity/Product_entity/entityfields/user_edit/valueProcess.js
 create mode 100644 entity/Product_entity/entityfields/user_new/valueProcess.js

diff --git a/entity/Org_entity/Org_entity.aod b/entity/Org_entity/Org_entity.aod
index 402f4cfa4db..e91d10816b3 100644
--- a/entity/Org_entity/Org_entity.aod
+++ b/entity/Org_entity/Org_entity.aod
@@ -252,6 +252,12 @@
         <entityName>Product_entity</entityName>
         <fieldName>OrgProduct_dfi</fieldName>
       </dependency>
+      <children>
+        <entityParameter>
+          <name>OrgId_param</name>
+          <code>%aditoprj%/entity/Org_entity/entityfields/orgproduct_dfo/children/orgid_param/code.js</code>
+        </entityParameter>
+      </children>
     </entityOutgoingField>
   </entityFields>
   <linkInformation>
diff --git a/entity/Org_entity/entityfields/orgproduct_dfo/children/orgid_param/code.js b/entity/Org_entity/entityfields/orgproduct_dfo/children/orgid_param/code.js
new file mode 100644
index 00000000000..43a0099996b
--- /dev/null
+++ b/entity/Org_entity/entityfields/orgproduct_dfo/children/orgid_param/code.js
@@ -0,0 +1,4 @@
+import("system.result");
+import("system.vars");
+
+result.string(vars.get("$field.ORGID"));
\ No newline at end of file
diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod
index c2b1b3226e0..455699b59aa 100644
--- a/entity/Product_entity/Product_entity.aod
+++ b/entity/Product_entity/Product_entity.aod
@@ -13,16 +13,24 @@
       <columnName>ADVERTISING</columnName>
       <caption>Werbemittel</caption>
       <contentType>BOOLEAN</contentType>
+      <possibleItemsProcess>%aditoprj%/entity/Product_entity/entityfields/advertising/possibleItemsProcess.js</possibleItemsProcess>
+      <valueProcess>%aditoprj%/entity/Product_entity/entityfields/advertising/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>DATE_EDIT</name>
       <tableName>PRODUCT</tableName>
       <columnName>DATE_EDIT</columnName>
+      <contentType>DATE</contentType>
+      <outputFormat>yyyy-MM-dd&amp;apos;T&amp;apos;HH:mm:ssZ</outputFormat>
+      <valueProcess>%aditoprj%/entity/Product_entity/entityfields/date_edit/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>DATE_NEW</name>
       <tableName>PRODUCT</tableName>
       <columnName>DATE_NEW</columnName>
+      <contentType>DATE</contentType>
+      <outputFormat>yyyy-MM-dd&amp;apos;T&amp;apos;HH:mm:ssZ</outputFormat>
+      <valueProcess>%aditoprj%/entity/Product_entity/entityfields/date_new/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>GROUPCODEID</name>
@@ -44,11 +52,16 @@
       <name>ORG_ID</name>
       <tableName>PRODUCT</tableName>
       <columnName>ORG_ID</columnName>
+      <caption>Hersteller</caption>
+      <valueProcess>%aditoprj%/entity/Product_entity/entityfields/org_id/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>PRODUCTCODE</name>
       <tableName>PRODUCT</tableName>
       <columnName>PRODUCTCODE</columnName>
+      <caption>Produkt-Nr.</caption>
+      <mandatory v="true" />
+      <onValidation>%aditoprj%/entity/Product_entity/entityfields/productcode/onValidation.js</onValidation>
     </entityField>
     <entityField>
       <name>PRODUCTID</name>
@@ -59,6 +72,8 @@
       <name>PRODUCTNAME</name>
       <tableName>PRODUCT</tableName>
       <columnName>PRODUCTNAME</columnName>
+      <caption>Produktname</caption>
+      <mandatory v="true" />
     </entityField>
     <entityField>
       <name>STANDARD</name>
@@ -71,21 +86,28 @@
       <columnName>STATUS</columnName>
       <caption>Aktiv</caption>
       <contentType>BOOLEAN</contentType>
+      <possibleItemsProcess>%aditoprj%/entity/Product_entity/entityfields/status/possibleItemsProcess.js</possibleItemsProcess>
+      <valueProcess>%aditoprj%/entity/Product_entity/entityfields/status/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>UNIT</name>
       <tableName>PRODUCT</tableName>
       <columnName>UNIT</columnName>
+      <caption>Einheit</caption>
+      <mandatory v="true" />
+      <possibleItemsProcess>%aditoprj%/entity/Product_entity/entityfields/unit/possibleItemsProcess.js</possibleItemsProcess>
     </entityField>
     <entityField>
       <name>USER_EDIT</name>
       <tableName>PRODUCT</tableName>
       <columnName>USER_EDIT</columnName>
+      <valueProcess>%aditoprj%/entity/Product_entity/entityfields/user_edit/valueProcess.js</valueProcess>
     </entityField>
     <entityField>
       <name>USER_NEW</name>
       <tableName>PRODUCT</tableName>
       <columnName>USER_NEW</columnName>
+      <valueProcess>%aditoprj%/entity/Product_entity/entityfields/user_new/valueProcess.js</valueProcess>
     </entityField>
     <entityOutgoingField>
       <name>ProductOrg_dfo</name>
@@ -108,6 +130,25 @@
         </entityDependency>
       </dependencies>
     </entityIncomingField>
+    <entityField>
+      <name>STOCKCOUNT</name>
+      <caption>Lagerbestand</caption>
+    </entityField>
+    <entityParameter>
+      <name>OrgId_param</name>
+      <expose v="true" />
+      <triggerRecalculation v="true" />
+      <mandatory v="false" />
+      <description>PARAMETER</description>
+    </entityParameter>
+    <entityField>
+      <name>currentPurchasePrice</name>
+      <caption>akt. EK-Preis</caption>
+    </entityField>
+    <entityField>
+      <name>currentSalesPrice</name>
+      <caption>akt. VK-Preis</caption>
+    </entityField>
   </entityFields>
   <linkInformation>
     <linkInformation>
diff --git a/entity/Product_entity/entityfields/advertising/possibleItemsProcess.js b/entity/Product_entity/entityfields/advertising/possibleItemsProcess.js
new file mode 100644
index 00000000000..88409cc9683
--- /dev/null
+++ b/entity/Product_entity/entityfields/advertising/possibleItemsProcess.js
@@ -0,0 +1,7 @@
+import("system.translate");
+import("system.result");
+
+result.object([
+     ["Y", translate.text("Ja")]
+    ,["N", translate.text("Nein")]
+]);
\ No newline at end of file
diff --git a/entity/Product_entity/entityfields/advertising/valueProcess.js b/entity/Product_entity/entityfields/advertising/valueProcess.js
new file mode 100644
index 00000000000..0a98fa35746
--- /dev/null
+++ b/entity/Product_entity/entityfields/advertising/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("N");
\ No newline at end of file
diff --git a/entity/Product_entity/entityfields/date_edit/valueProcess.js b/entity/Product_entity/entityfields/date_edit/valueProcess.js
new file mode 100644
index 00000000000..00e95d744ea
--- /dev/null
+++ b/entity/Product_entity/entityfields/date_edit/valueProcess.js
@@ -0,0 +1,6 @@
+import("system.vars");
+import("system.result");
+import("system.neon");
+
+if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT)
+    result.string(vars.getString("$sys.date"));
\ No newline at end of file
diff --git a/entity/Product_entity/entityfields/date_new/valueProcess.js b/entity/Product_entity/entityfields/date_new/valueProcess.js
new file mode 100644
index 00000000000..eedddb3cf02
--- /dev/null
+++ b/entity/Product_entity/entityfields/date_new/valueProcess.js
@@ -0,0 +1,8 @@
+import("system.logging");
+import("system.vars");
+import("system.result");
+import("system.neon");
+
+if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW)
+    result.string(vars.getString("$sys.date"));
+
diff --git a/entity/Product_entity/entityfields/org_id/valueProcess.js b/entity/Product_entity/entityfields/org_id/valueProcess.js
new file mode 100644
index 00000000000..d1edd60f9f8
--- /dev/null
+++ b/entity/Product_entity/entityfields/org_id/valueProcess.js
@@ -0,0 +1,12 @@
+import("system.logging");
+import("system.vars");
+import("system.result");
+import("system.neon");
+
+if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW)
+{
+    if(vars.exists("$param.OrgId_param") && vars.get("$param.OrgId_param") != null)
+        result.string(vars.getString("$param.OrgId_param"));    
+}
+else
+    result.string(vars.get("$this.value"));    
diff --git a/entity/Product_entity/entityfields/productcode/onValidation.js b/entity/Product_entity/entityfields/productcode/onValidation.js
new file mode 100644
index 00000000000..9c3a82d0063
--- /dev/null
+++ b/entity/Product_entity/entityfields/productcode/onValidation.js
@@ -0,0 +1,12 @@
+import("system.db");
+import("system.vars");
+import("system.swing");
+import("system.result");
+import("system.translate");
+
+//Productcode has to be unique
+if(db.cell("select count(PRODUCTID) from PRODUCT where PRODUCTCODE = '" + vars.get("$local.value")
+    + "' and PRODUCTID != '" + vars.get("$field.PRODUCTID") + "'") != 0)
+{
+    result.string( translate.text("Die Produktnummer exisitiert bereits!") );
+}
\ No newline at end of file
diff --git a/entity/Product_entity/entityfields/status/possibleItemsProcess.js b/entity/Product_entity/entityfields/status/possibleItemsProcess.js
new file mode 100644
index 00000000000..dd8baa43d33
--- /dev/null
+++ b/entity/Product_entity/entityfields/status/possibleItemsProcess.js
@@ -0,0 +1,7 @@
+import("system.translate");
+import("system.result");
+
+result.object([
+     ["1", translate.text("Ja")]
+    ,["2", translate.text("Nein")]
+]);
\ No newline at end of file
diff --git a/entity/Product_entity/entityfields/status/valueProcess.js b/entity/Product_entity/entityfields/status/valueProcess.js
new file mode 100644
index 00000000000..04344c1e2ca
--- /dev/null
+++ b/entity/Product_entity/entityfields/status/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/Product_entity/entityfields/unit/possibleItemsProcess.js b/entity/Product_entity/entityfields/unit/possibleItemsProcess.js
new file mode 100644
index 00000000000..020f0770d41
--- /dev/null
+++ b/entity/Product_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/Product_entity/entityfields/user_edit/valueProcess.js b/entity/Product_entity/entityfields/user_edit/valueProcess.js
new file mode 100644
index 00000000000..67c86b14ca9
--- /dev/null
+++ b/entity/Product_entity/entityfields/user_edit/valueProcess.js
@@ -0,0 +1,6 @@
+import("system.vars");
+import("system.result");
+import("system.neon");
+
+if(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT)
+    result.string(vars.getString("$sys.user"));
\ No newline at end of file
diff --git a/entity/Product_entity/entityfields/user_new/valueProcess.js b/entity/Product_entity/entityfields/user_new/valueProcess.js
new file mode 100644
index 00000000000..81966a3fbcd
--- /dev/null
+++ b/entity/Product_entity/entityfields/user_new/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(vars.getString("$sys.user"));
\ No newline at end of file
diff --git a/neonView/ProductFilter_view/ProductFilter_view.aod b/neonView/ProductFilter_view/ProductFilter_view.aod
index f1ae438afed..946718cd876 100644
--- a/neonView/ProductFilter_view/ProductFilter_view.aod
+++ b/neonView/ProductFilter_view/ProductFilter_view.aod
@@ -20,6 +20,18 @@
           <name>ee627d12-c60c-48c2-a86e-2a144f5853e6</name>
           <entityField>PRODUCTCODE</entityField>
         </neonTableColumn>
+        <neonTableColumn>
+          <name>cd013f0c-b9b0-4c5a-866b-53a9f69ad75e</name>
+          <entityField>PRODUCTNAME</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>4d23de03-5729-4568-a65d-3f0bdb67f66e</name>
+          <entityField>UNIT</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>3e774e1c-0998-4b2c-b876-22e99a79cb55</name>
+          <entityField>ORG_ID</entityField>
+        </neonTableColumn>
       </columns>
     </tableViewTemplate>
   </children>
diff --git a/neonView/ProductPreview_view/ProductPreview_view.aod b/neonView/ProductPreview_view/ProductPreview_view.aod
index 31106c2cfe6..612ead7d150 100644
--- a/neonView/ProductPreview_view/ProductPreview_view.aod
+++ b/neonView/ProductPreview_view/ProductPreview_view.aod
@@ -2,4 +2,60 @@
 <neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.0.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.0.0">
   <name>ProductPreview_view</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+    </boxLayout>
+  </layout>
+  <children>
+    <cardViewTemplate>
+      <name>ProductHeader_template</name>
+      <titleField>PRODUCTCODE</titleField>
+      <descriptionField>GROUPCODEID</descriptionField>
+      <entityField>#ENTITY</entityField>
+    </cardViewTemplate>
+    <genericViewTemplate>
+      <name>ProductInfo_template</name>
+      <showDrawer v="true" />
+      <entityField>#ENTITY</entityField>
+      <fields>
+        <entityFieldLink>
+          <name>00594c0e-6641-4f6d-9717-1eee2678ad5d</name>
+          <entityField>PRODUCTNAME</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>7074979a-a2fc-4a57-98ad-3d8e98fde37a</name>
+          <entityField>ORG_ID</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>a5a3ecee-059d-4bf2-9654-abe3efd58510</name>
+          <entityField>UNIT</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>abef7fe5-88f6-44fe-af91-38487eb9b750</name>
+          <entityField>ADVERTISING</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>505cc05b-0497-4baa-81cb-294ec6e1a133</name>
+          <entityField>STATUS</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>ba604dc5-06b2-44f2-a9b3-c4c3adb9f8f8</name>
+          <entityField>MINSTOCK</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>3802b031-10fc-4694-8e06-71d0033ae351</name>
+          <entityField>STOCKCOUNT</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>bcf1cada-cb5b-4012-85d1-544eabc5b86d</name>
+          <entityField>currentPurchasePrice</entityField>
+        </entityFieldLink>
+        <entityFieldLink>
+          <name>4ef15389-761a-40e6-8774-f7145ace5c12</name>
+          <entityField>currentSalesPrice</entityField>
+        </entityFieldLink>
+      </fields>
+    </genericViewTemplate>
+  </children>
 </neonView>
diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
index b0f2142f631..6342decac50 100644
--- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
+++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod
@@ -2,7 +2,7 @@
 <preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.0.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.0.1">
   <name>_____PREFERENCES_PROJECT</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
-  <projectName>xRM-Basic-5</projectName>
+  <projectName>xRM-Basic</projectName>
   <jditoMaxContentSize v="57671680" />
   <calendarCategoriesEvent>
     <entry>
diff --git a/process/Keyword_lib/process.js b/process/Keyword_lib/process.js
index 14306721400..0b808dc164a 100644
--- a/process/Keyword_lib/process.js
+++ b/process/Keyword_lib/process.js
@@ -131,6 +131,14 @@ function KeywordUtils(){
                     ,createKeywordEntry("6", translate.text("Dienstleistung"))
                 ]);
                 break;
+            case "UNIT":
+                valueContainer = createKeywordEntriesContainer([
+                     createKeywordEntry("1", translate.text("Stück"))
+                    ,createKeywordEntry("2", translate.text("Kg"))
+                    ,createKeywordEntry("3", translate.text("Liter"))
+                    ,createKeywordEntry("4", translate.text("Stunden"))
+                ]);
+                break;
             default: 
                 throw new Error(translate.withArguments("[%0]the given keyword \"%1\" has no match with the possible keywordlist", [
                     arguments.callee.name, keywordType
-- 
GitLab