details:   https://code.openbravo.com/erp/devel/pi/rev/4882d76b8d6a
changeset: 24157:4882d76b8d6a
user:      Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
date:      Mon Aug 04 14:47:58 2014 +0200
summary:   Fixed bug 27140: Useless usage of hex_to_int()

diffstat:

 src-db/database/model/functions/C_ORDER_POST1.xml |  32 ++++++++++------------
 1 files changed, 14 insertions(+), 18 deletions(-)

diffs (67 lines):

diff -r 4f449d9a56f7 -r 4882d76b8d6a 
src-db/database/model/functions/C_ORDER_POST1.xml
--- a/src-db/database/model/functions/C_ORDER_POST1.xml Mon Aug 04 14:10:59 
2014 +0200
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml Mon Aug 04 14:47:58 
2014 +0200
@@ -61,8 +61,9 @@
   v_IsBinding CHAR(1):='Y';
   v_istaxincluded CHAR(1);
   --
-  ToDeliver NUMBER;
-  ToInvoice NUMBER;
+  ToDeliver CHAR(1):='N';
+  ToInvoice CHAR(1):='N';
+  ToDeliverOrToInvoice CHAR(1):='N';
   --
   InOut_ID VARCHAR2(32);
   Invoice_ID VARCHAR2(32);
@@ -1358,14 +1359,11 @@
      */
       BEGIN
         v_ResultStr:='OrderCompleteCheck';
-        SELECT SUM(QtyOrdered*hex_to_int(C_OrderLine_ID)) 
-SUM(QtyDelivered*hex_to_int(C_OrderLine_ID)),
-            SUM(QtyOrdered*hex_to_int(C_OrderLine_ID)) 
-SUM(QtyInvoiced*hex_to_int(C_OrderLine_ID))
-          INTO ToDeliver,
-            ToInvoice
-        FROM C_ORDERLINE
-        WHERE C_Order_ID=v_Record_ID;
-        -- If no lines, ToDeliver is NULL
-        IF ((ToDeliver=0 AND ToInvoice=0) OR(ToDeliver IS NULL AND ToInvoice 
IS NULL)) THEN
+        SELECT 'Y' INTO ToDeliverOrToInvoice FROM DUAL
+        WHERE 0 <> ANY (select QtyOrdered - QtyDelivered from c_orderline 
where c_order_id = v_Record_ID)
+        OR    0 <> ANY (select QtyOrdered - QtyInvoiced  from c_orderline 
where c_order_id = v_Record_ID);
+        -- If something to deliver or to invoice, then ToDeliverOrToInvoice = 
'Y'
+        IF (ToDeliverOrToInvoice <> 'Y') THEN
           DBMS_OUTPUT.PUT_LINE('OrderComplete') ;
           IF (v_DocAction='CL') THEN
             END_PROCESSING:=TRUE;
@@ -1508,17 +1506,15 @@
      /**
       * Final Completeness check
       */
-      SELECT SUM(QtyOrdered*hex_to_int(C_OrderLine_ID)) 
-SUM(QtyDelivered*hex_to_int(C_OrderLine_ID)),
-          SUM(QtyOrdered*hex_to_int(C_OrderLine_ID)) 
-SUM(QtyInvoiced*hex_to_int(C_OrderLine_ID))
-        INTO ToDeliver,
-          ToInvoice
-      FROM C_ORDERLINE
-      WHERE C_Order_ID=v_Record_ID;
+      SELECT 'Y' INTO ToDeliver FROM DUAL
+      WHERE 0 <> ANY (select QtyOrdered - QtyDelivered from c_orderline where 
c_order_id = v_Record_ID);
+      SELECT 'Y' INTO ToInvoice FROM DUAL
+      WHERE 0 <> ANY (select QtyOrdered - QtyInvoiced from c_orderline where 
c_order_id = v_Record_ID);
       DBMS_OUTPUT.PUT_LINE('To deliver - ' || ToDeliver) ;
       DBMS_OUTPUT.PUT_LINE('ToInvoice - ' || ToInvoice) ;
       DBMS_OUTPUT.PUT_LINE('v_DocSubTypeSO - ' || v_DocSubTypeSO) ;
       -- Nothing to Deliver + Invoice for (W)illCall(I)nvoice and 
(W)alkIn(R)eceipt
-      IF (v_DocSubTypeSO IN ('WI', 'WR') AND ToDeliver=0 AND ToInvoice=0) THEN
+      IF (v_DocSubTypeSO IN ('WI', 'WR') AND ToDeliver <> 'Y' AND ToInvoice <> 
'Y') THEN
         UPDATE C_ORDER
         SET DocStatus='CO',
             DocAction='--',
@@ -1534,7 +1530,7 @@
         END IF;
       END IF;
       -- Nothing to Deliver for (W)illCall(P)ickup (Invoice generated 
independently)
-      IF (v_DocSubTypeSO='WP' AND ToDeliver=0) THEN
+      IF (v_DocSubTypeSO='WP' AND ToDeliver <> 'Y') THEN
         UPDATE C_ORDER
         SET DocStatus='CO',
             DocAction='--',

------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms controls. 
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to