Changed onCreateDefault value for IsCompletelyInvoiced and removed logs from the process
authorAaron Calero <aaron.calero@openbravo.com>
Mon, 25 Mar 2019 14:34:01 +0100
changeset 32498 ed508cf70117
parent 32497 f328756bfc8e
child 32499 7c394b3e425a
Changed onCreateDefault value for IsCompletelyInvoiced and removed logs from the process
src-db/database/model/tables/M_INOUT.xml
src/org/openbravo/erpCommon/ad_process/UpdateIsCompletelyInvoicedQ1.java
--- a/src-db/database/model/tables/M_INOUT.xml	Fri Mar 22 09:23:17 2019 +0100
+++ b/src-db/database/model/tables/M_INOUT.xml	Mon Mar 25 14:34:01 2019 +0100
@@ -263,7 +263,7 @@
       </column>
       <column name="ISCOMPLETELYINVOICED" primaryKey="false" required="true" type="CHAR" size="1" autoIncrement="false">
         <default><![CDATA[N]]></default>
-        <onCreateDefault><![CDATA['Y']]></onCreateDefault>
+        <onCreateDefault><![CDATA['N']]></onCreateDefault>
       </column>
       <foreign-key foreignTable="M_FREIGHTCATEGORY" name="M_FREIGHTCATEGORY_M_INOUT">
         <reference local="M_FREIGHTCATEGORY_ID" foreign="M_FREIGHTCATEGORY_ID"/>
--- a/src/org/openbravo/erpCommon/ad_process/UpdateIsCompletelyInvoicedQ1.java	Fri Mar 22 09:23:17 2019 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/UpdateIsCompletelyInvoicedQ1.java	Mon Mar 25 14:34:01 2019 +0100
@@ -95,11 +95,11 @@
         .getInstance()
         .getSession()
         .createQuery( //
-            "SELECT distinct io.id" //
+            "SELECT io.id" //
                 + " FROM MaterialMgmtShipmentInOut io" //
                 + " WHERE io.salesTransaction = true" //
                 + " AND io.completelyInvoiced = true" //
-                + " AND EXISTS (SELECT 1" //
+                + " AND NOT EXISTS (SELECT 1" //
                 + "   FROM MaterialMgmtShipmentInOutLine iol" //
                 + "   LEFT JOIN iol.invoiceLineList il" //
                 + "   LEFT JOIN il.invoice i" //
@@ -108,9 +108,8 @@
                 + "   HAVING (iol.movementQuantity >= 0 AND iol.movementQuantity > SUM(COALESCE(CASE WHEN i.documentStatus = 'CO' THEN il.invoicedQuantity ELSE 0 END,0)))" //
                 + "   OR (iol.movementQuantity < 0 AND iol.movementQuantity < SUM(COALESCE(CASE WHEN i.documentStatus = 'CO' THEN il.invoicedQuantity ELSE 0 END,0))))");
     inOutIds.setMaxResults(QUERY_SIZE);
-    log4j.info("Executing query to get m_inouts to process");
+
     List<String> inOutListIds = inOutIds.list();
-    log4j.info("M_InOuts to update: " + inOutListIds.size());
     return inOutListIds;
   }
 
@@ -119,7 +118,6 @@
     int recordsToUpdate = inOutIdsToUpdate.size();
     boolean stop = false;
     try {
-      log4j.info("Starting m_inout update process...");
       TriggerHandler.getInstance().disable();
       while (!kill && !stop && totalUpdatedRecords < QUERY_SIZE) {
         int updatedRecords = 0;
@@ -136,14 +134,12 @@
               .getInstance()
               .getSession()
               .createQuery(
-                  "UPDATE MaterialMgmtShipmentInOut SET completelyInvoiced = 'N' where id in :ids");
+                  "UPDATE MaterialMgmtShipmentInOut SET completelyInvoiced = 'Y' where id in :ids");
           inOutIds.setParameterList("ids", sublist);
           updatedRecords = inOutIds.executeUpdate();
           totalUpdatedRecords = totalUpdatedRecords + updatedRecords;
           OBDal.getInstance().getConnection().commit();
           OBDal.getInstance().getSession().clear();
-          log4j.info("Updated " + updatedRecords + " m_inouts. Total updated: "
-              + totalUpdatedRecords + ". ");
         } else {
           stop = true;
         }