Backout issue 24139: Available quantity
authorJavier Etxarri <javier.echarri@openbravo.com>
Mon, 30 Sep 2013 15:36:45 +0200
changeset 21219 237a498f9e4d
parent 21218 73df6c79ca82
child 21220 f01d485c6cf2
child 22193 3fba21559fed
Backout issue 24139: Available quantity
wrongly updated when voiding a goods shipment of a reactivated order
src-db/database/model/functions/M_INOUT_POST.xml
--- a/src-db/database/model/functions/M_INOUT_POST.xml	Mon Sep 30 17:25:31 2013 +0530
+++ b/src-db/database/model/functions/M_INOUT_POST.xml	Mon Sep 30 15:36:45 2013 +0200
@@ -47,7 +47,6 @@
   v_Message VARCHAR2(2000):='';
   v_Message_aux VARCHAR2(2000):='';
   v_Record_ID VARCHAR2(32);
-  v_DocStatus VARCHAR2(60);
   v_User VARCHAR2(32);
   v_PUser VARCHAR2(32);
   v_is_included NUMBER:=0;
@@ -603,25 +602,12 @@
               -- stocked product
               IF(Cur_InOutLine.M_Product_ID IS NOT NULL AND v_IsStocked=1) THEN
                 -- Update OrderLine (if C-, Qty is negative)
-                SELECT DOCSTATUS into v_DocStatus
-                FROM C_ORDER
-                WHERE C_ORDER_ID = (SELECT C_ORDER_ID
-                                    FROM C_ORDERLINE 
-                                    WHERE C_ORDERLINE_ID=Cur_InOutLine.C_OrderLine_ID);
-                IF (v_DocStatus = 'DR') THEN
-                  UPDATE C_ORDERLINE
-                    SET QtyDelivered=QtyDelivered + v_QtySO,
-                    Updated=now(),
-                    UpdatedBy=v_User
-                  WHERE C_OrderLine_ID=Cur_InOutLine.C_OrderLine_ID;
-                ELSE 
-                  UPDATE C_ORDERLINE
-                    SET QtyReserved=QtyReserved - v_QtyPO - v_QtySO,
-                    QtyDelivered=QtyDelivered + v_QtySO,
-                    Updated=now(),
-                    UpdatedBy=v_User
-                   WHERE C_OrderLine_ID=Cur_InOutLine.C_OrderLine_ID;
-                END IF;
+                UPDATE C_ORDERLINE
+                  SET QtyReserved=QtyReserved - v_QtyPO - v_QtySO,
+                  QtyDelivered=QtyDelivered + v_QtySO,
+                  Updated=now(),
+                  UpdatedBy=v_User
+                WHERE C_OrderLine_ID=Cur_InOutLine.C_OrderLine_ID;
                 -- Products not stocked
               ELSE
                 -- Update OrderLine (if C-, Qty is negative)