[costAdjs]improve the performance in module script InitializeMTransCostDateacct
authorMiguel A. Alsasua <miguel.alsasua@openbravo.com>
Fri, 19 Sep 2014 09:21:59 +0200
changeset 24912 fa7c2a34e0fc
parent 24911 5f231c95b68d
child 24913 e10ca5e6571f
[costAdjs]improve the performance in module script InitializeMTransCostDateacct
src-util/modulescript/build/classes/org/openbravo/modulescript/InitializeMTransCostDateacct.class
src-util/modulescript/build/classes/org/openbravo/modulescript/InitializeMTransCostDateacctData.class
src-util/modulescript/src/org/openbravo/modulescript/InitializeMTransCostDateacct.java
src-util/modulescript/src/org/openbravo/modulescript/InitializeMTransCostDateacct_data.xsql
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/InitializeMTransCostDateacct.class has changed
Binary file src-util/modulescript/build/classes/org/openbravo/modulescript/InitializeMTransCostDateacctData.class has changed
--- a/src-util/modulescript/src/org/openbravo/modulescript/InitializeMTransCostDateacct.java	Thu Sep 18 19:04:13 2014 +0200
+++ b/src-util/modulescript/src/org/openbravo/modulescript/InitializeMTransCostDateacct.java	Fri Sep 19 09:21:59 2014 +0200
@@ -32,6 +32,7 @@
       ConnectionProvider cp = getConnectionProvider();
       if (InitializeMTransCostDateacctData.hasMTransCostDateacct(cp.getConnection(), cp)) {
         InitializeMTransCostDateacctData.initializeMTransCostDateacct(cp.getConnection(), cp);
+        InitializeMTransCostDateacctData.initializeMTransCostDateacct2(cp.getConnection(), cp);
       }
     } catch (Exception e) {
       handleError(e);
--- a/src-util/modulescript/src/org/openbravo/modulescript/InitializeMTransCostDateacct_data.xsql	Thu Sep 18 19:04:13 2014 +0200
+++ b/src-util/modulescript/src/org/openbravo/modulescript/InitializeMTransCostDateacct_data.xsql	Fri Sep 19 09:21:59 2014 +0200
@@ -43,14 +43,32 @@
       <![CDATA[
         UPDATE m_transaction_cost mc 
             SET dateacct = (
-                SELECT COALESCE (inot.dateacct,m.movementdate) 
+                SELECT m.movementdate 
+                FROM m_transaction m 
+                WHERE  m.m_transaction_id = mc.m_transaction_id 
+                )
+            WHERE dateacct IS NULL
+      ]]>
+    </Sql>
+  </SqlMethod>
+  <SqlMethod name="initializeMTransCostDateacct2" type="preparedStatement" connection="true" return="rowcount">
+    <SqlMethodComment></SqlMethodComment>
+    <Sql>
+      <![CDATA[
+        UPDATE m_transaction_cost mc 
+            SET dateacct = (
+            SELECT COALESCE (inot.dateacct,m.movementdate) 
                 FROM m_transaction_cost mc1 
                 LEFT JOIN m_transaction m ON m.m_transaction_id = mc.m_transaction_id 
                 LEFT JOIN m_inoutline inoutl ON inoutl.m_inoutline_id = m.m_inoutline_id 
                 LEFT JOIN m_inout inot ON inoutl.m_inout_id = inot.m_inout_id 
                 WHERE mc.m_transaction_cost_id = mc1.m_transaction_cost_id
                 )
-            WHERE dateacct IS NULL
+            WHERE m_transaction_id in (SELECT m.m_transaction_id
+                                       FROM m_transaction m 
+                                       LEFT JOIN m_inoutline inoutl ON inoutl.m_inoutline_id = m.m_inoutline_id 
+                                       LEFT JOIN m_inout inot ON inoutl.m_inout_id = inot.m_inout_id 
+                                       where  inot.dateacct <> inot.movementdate)
       ]]>
     </Sql>
   </SqlMethod>