details:   https://code.openbravo.com/erp/devel/pi/rev/570ce3b92b69
changeset: 32505:570ce3b92b69
user:      Armaignac <collazoandy4 <at> gmail.com>
date:      Tue Jul 18 11:06:02 2017 -0400
summary:   Fixes issue 36476: Cannot add some sales order lines to goods 
shipments after
upgrading to 3.0PR17Q1 as a modulescript set the order as isdelivered

Cannot add some sales order lines to goods shipments because the modulescript
set the order as isdelivered when the order contains lines with negative 
qtyordered
and the sum(qtyordered) = sum(qtydelivered)

Now the update only happend when the order don't have a line where
QTYORDERED <> QTYDELIVERED.

Because the NOT EXISTS change the check to issotrx field now is made in the main
query because a wrong evaluation in the subquery happends when issotrx = 'N' and
NOT EXISTS

diffstat:

 src-db/database/model/functions/M_INOUT_POST.xml                               
             |   15 ++++---
 
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateQtyDeliveredData.class
 |    0 
 
src-util/modulescript/src/org/openbravo/modulescript/UpdateQtyDelivered_data.xsql
           |   18 ++++-----
 3 files changed, 16 insertions(+), 17 deletions(-)

diffs (63 lines):

diff -r b69110075180 -r 570ce3b92b69 
src-db/database/model/functions/M_INOUT_POST.xml
--- a/src-db/database/model/functions/M_INOUT_POST.xml  Thu Jul 20 11:28:33 
2017 +0200
+++ b/src-db/database/model/functions/M_INOUT_POST.xml  Tue Jul 18 11:06:02 
2017 -0400
@@ -852,14 +852,15 @@
                -- Normal Scenario
                UPDATE C_Order o
                SET IsDelivered = 'Y'
-               WHERE o.c_order_id = Cur_Order.c_order_id
+               WHERE o.c_order_id = Cur_Order.c_order_id 
                AND o.IsDelivered = 'N'
-               AND EXISTS (SELECT 1
-                           FROM C_ORDERLINE ol
-                           WHERE ol.C_Order_ID = o.C_Order_ID
-                           AND ol.c_order_discount_id IS NULL
-                           GROUP BY ol.C_Order_ID
-                           HAVING SUM(ol.QTYORDERED) = SUM(ol.QTYDELIVERED));
+               AND o.processed = 'Y'                
+               AND NOT EXISTS (SELECT 1
+                               FROM c_orderline ol
+                               WHERE ol.C_Order_ID = o.C_Order_ID
+                               AND ol.c_order_discount_id IS NULL
+                               AND ol.QTYORDERED <> ol.QTYDELIVERED
+                              );
              ELSIF (v_IsReversedDoc = 'Y') THEN
                -- Void Scenario
                UPDATE C_Order o
diff -r b69110075180 -r 570ce3b92b69 
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateQtyDeliveredData.class
Binary file 
src-util/modulescript/build/classes/org/openbravo/modulescript/UpdateQtyDeliveredData.class
 has changed
diff -r b69110075180 -r 570ce3b92b69 
src-util/modulescript/src/org/openbravo/modulescript/UpdateQtyDelivered_data.xsql
--- 
a/src-util/modulescript/src/org/openbravo/modulescript/UpdateQtyDelivered_data.xsql
 Thu Jul 20 11:28:33 2017 +0200
+++ 
b/src-util/modulescript/src/org/openbravo/modulescript/UpdateQtyDelivered_data.xsql
 Tue Jul 18 11:06:02 2017 -0400
@@ -12,7 +12,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2016 Openbravo SLU
+ * All portions are Copyright (C) 2016-2017 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -56,15 +56,13 @@
         SET IsDelivered = 'Y'
         WHERE o.IsDelivered = 'N'
         AND o.processed = 'Y'
-        AND EXISTS (SELECT 1
-                    FROM c_doctype dt, c_orderline ol
-                    WHERE o.c_doctypetarget_id = dt.c_doctype_id
-                    AND o.c_order_id = ol.c_order_id
-                    AND (o.issotrx = 'Y' OR (o.issotrx = 'N' AND dt.isreturn = 
'Y'))
-                    AND ol.c_order_discount_id IS NULL
-                    GROUP BY ol.C_Order_ID
-                    HAVING SUM(ol.QTYORDERED) = SUM(ol.QTYDELIVERED)
-                   )
+        AND (o.issotrx = 'Y' OR (o.issotrx = 'N' AND (SELECT dt.isreturn FROM 
c_doctype dt WHERE o.c_doctypetarget_id = dt.c_doctype_id) = 'Y'))
+        AND NOT EXISTS (SELECT 1
+                        FROM c_orderline ol
+                        WHERE o.c_order_id = ol.c_order_id
+                        AND ol.c_order_discount_id IS NULL
+                        AND ol.QTYORDERED <> ol.QTYDELIVERED
+                       )
       ]]>
     </Sql>
   </SqlMethod>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to