From 31818e07d274f18669ac6aa3e315947877b369b4 Mon Sep 17 00:00:00 2001
From: "m.escher" <m.escher@adito.de>
Date: Tue, 4 Dec 2018 09:31:21 +0100
Subject: [PATCH] RecordContainer fix: Stock_entity

---
 entity/Stock_entity/Stock_entity.aod          | 81 +++++++++++++++++--
 .../recordcontainers/db/conditionProcess.js   |  7 ++
 .../recordcontainers/db/orderClauseProcess.js |  3 +
 3 files changed, 83 insertions(+), 8 deletions(-)
 create mode 100644 entity/Stock_entity/recordcontainers/db/conditionProcess.js
 create mode 100644 entity/Stock_entity/recordcontainers/db/orderClauseProcess.js

diff --git a/entity/Stock_entity/Stock_entity.aod b/entity/Stock_entity/Stock_entity.aod
index dfae4c28d4..1a5f8adf5e 100644
--- a/entity/Stock_entity/Stock_entity.aod
+++ b/entity/Stock_entity/Stock_entity.aod
@@ -8,6 +8,15 @@
   <alias>Data_alias</alias>
   <conditionProcess>%aditoprj%/entity/Stock_entity/conditionProcess.js</conditionProcess>
   <orderClauseProcess>%aditoprj%/entity/Stock_entity/orderClauseProcess.js</orderClauseProcess>
+  <recordContainer>db</recordContainer>
+  <linkInformation>
+    <linkInformation>
+      <name>f8caac29-1e0d-4cf5-9137-fedd6a765d55</name>
+      <tableName>STOCK</tableName>
+      <primaryKey>STOCKID</primaryKey>
+      <isUIDTable v="true" />
+    </linkInformation>
+  </linkInformation>
   <entityFields>
     <entityField>
       <name>DATE_EDIT</name>
@@ -131,12 +140,68 @@
       <name>#INCOMING</name>
     </entityIncomingField>
   </entityFields>
-  <linkInformation>
-    <linkInformation>
-      <name>f8caac29-1e0d-4cf5-9137-fedd6a765d55</name>
-      <tableName>STOCK</tableName>
-      <primaryKey>STOCKID</primaryKey>
-      <isUIDTable v="true" />
-    </linkInformation>
-  </linkInformation>
+  <recordContainers>
+    <dbRecordContainer>
+      <name>db</name>
+      <alias>Data_alias</alias>
+      <maximumDbRows v="0" />
+      <conditionProcess>%aditoprj%/entity/Stock_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
+      <orderClauseProcess>%aditoprj%/entity/Stock_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess>
+      <linkInformation>
+        <linkInformation>
+          <name>d291e552-0b6a-48e1-a830-1558beb5f58e</name>
+          <tableName>STOCK</tableName>
+          <primaryKey>STOCKID</primaryKey>
+          <isUIDTable v="true" />
+          <readonly v="false" />
+        </linkInformation>
+      </linkInformation>
+      <recordFieldMappings>
+        <dbRecordFieldMapping>
+          <name>DATE_EDIT.value</name>
+          <value>STOCK.DATE_EDIT</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>DATE_NEW.value</name>
+          <value>STOCK.DATE_NEW</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>ENTRYDATE.value</name>
+          <value>STOCK.ENTRYDATE</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>IN_OUT.value</name>
+          <value>STOCK.IN_OUT</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>PRODUCT_ID.value</name>
+          <value>STOCK.PRODUCT_ID</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>QUANTITY.value</name>
+          <value>STOCK.QUANTITY</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>REFNUMBER.value</name>
+          <value>STOCK.REFNUMBER</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>STOCKID.value</name>
+          <value>STOCK.STOCKID</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>USER_EDIT.value</name>
+          <value>STOCK.USER_EDIT</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>USER_NEW.value</name>
+          <value>STOCK.USER_NEW</value>
+        </dbRecordFieldMapping>
+        <dbRecordFieldMapping>
+          <name>WAREHOUSE.value</name>
+          <value>STOCK.WAREHOUSE</value>
+        </dbRecordFieldMapping>
+      </recordFieldMappings>
+    </dbRecordContainer>
+  </recordContainers>
 </entity>
diff --git a/entity/Stock_entity/recordcontainers/db/conditionProcess.js b/entity/Stock_entity/recordcontainers/db/conditionProcess.js
new file mode 100644
index 0000000000..530b6b4554
--- /dev/null
+++ b/entity/Stock_entity/recordcontainers/db/conditionProcess.js
@@ -0,0 +1,7 @@
+import("system.result");
+import("system.vars");
+
+if(vars.exists("$param.ProductId_param") && vars.get("$param.ProductId_param") != "")
+    result.string("STOCK.PRODUCT_ID = ('" + vars.get("$param.ProductId_param") + "')");  
+else
+    result.string("1 = 2");  
\ No newline at end of file
diff --git a/entity/Stock_entity/recordcontainers/db/orderClauseProcess.js b/entity/Stock_entity/recordcontainers/db/orderClauseProcess.js
new file mode 100644
index 0000000000..ec31c7395e
--- /dev/null
+++ b/entity/Stock_entity/recordcontainers/db/orderClauseProcess.js
@@ -0,0 +1,3 @@
+import("system.result");
+
+result.object( {"STOCK.ENTRYDATE": "down"} );
\ No newline at end of file
-- 
GitLab