details:   https://code.openbravo.com/erp/devel/pi/rev/a013006eeb9b
changeset: 20461:a013006eeb9b
user:      David Miguelez <david.miguelez <at> openbravo.com>
date:      Wed May 15 12:19:51 2013 +0200
summary:   Fixes Issue 23715.

diffstat:

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

diffs (53 lines):

diff -r 291741e7259e -r a013006eeb9b 
src-db/database/model/functions/C_ORDER_POST1.xml
--- a/src-db/database/model/functions/C_ORDER_POST1.xml Wed May 22 17:22:04 
2013 +0200
+++ b/src-db/database/model/functions/C_ORDER_POST1.xml Wed May 15 12:19:51 
2013 +0200
@@ -221,6 +221,49 @@
       IF (v_reject_reason IS NULL) THEN
         RAISE_APPLICATION_ERROR(-20000, '@NoRejectReason@') ;
       END IF;
+      /*
+        * Undo inventory reservation
+        */
+        DECLARE
+          Cur_ResLine RECORD;
+          v_QtySO NUMBER; -- Reserved
+          v_QtyOrderSO NUMBER;
+          v_QtyPO NUMBER; -- Ordered
+          v_QtyOrderPO NUMBER;
+        BEGIN
+          v_ResultStr:='ReserveInventory';
+          -- For all lines needing reservation
+          FOR Cur_ResLine IN
+            (SELECT l.M_Warehouse_ID, l.M_Product_ID, 
l.M_AttributeSetInstance_ID, l.C_OrderLine_ID,
+                 l.QtyOrdered AS Qty, l.QUANTITYORDER, l.qtyreserved, 
l.qtydelivered,
+                l.C_UOM_ID, l.M_PRODUCT_UOM_ID
+             FROM C_ORDERLINE l, M_PRODUCT p
+             WHERE l.C_Order_ID=v_Record_ID  -- Reserve Products (not: 
services, null products)
+               AND l.M_Product_ID=p.M_Product_ID
+               AND p.IsStocked='Y'
+               AND p.ProductType='I'  FOR UPDATE
+             )
+            LOOP
+            -- Qty corrected for SO/PO
+              v_QtySO:=-Cur_ResLine.QtyReserved;
+              IF (Cur_ResLine.QtyReserved=Cur_ResLine.Qty) THEN
+                v_QtyOrderSO := -Cur_ResLine.QuantityOrder;
+              ELSIF Cur_ResLine.M_Product_UOM_ID IS NOT NULL THEN
+                v_QtyOrderSO := -C_Uom_Convert(v_QtySO, Cur_ResLine.C_UOM_ID, 
Cur_ResLine.M_Product_UOM_ID, 'Y');
+              END IF;
+              v_QtyPO:=0;
+              v_QtyOrderPO:=NULL;
+              M_UPDATE_STORAGE_PENDING(v_Client_ID, v_Org_ID, v_UpdatedBy, 
Cur_ResLine.M_Product_ID, Cur_ResLine.M_Warehouse_ID, 
Cur_ResLine.M_AttributeSetInstance_ID, Cur_ResLine.C_UOM_ID, 
Cur_ResLine.M_PRODUCT_UOM_ID, v_QtySO, v_QtyOrderSO, v_QtyPO, v_QtyOrderPO) ;
+          END LOOP;
+          -- Set reserved quantity to 0
+          UPDATE C_ORDERLINE
+          SET QtyReserved = 0,
+              Updated=now(),
+              UpdatedBy=v_User
+          WHERE c_orderline_id IN (select c_orderline_id
+                                   from c_orderline
+                                   where c_order_id = v_Record_id);
+        END;
       UPDATE C_ORDER
       SET DocStatus='CJ',
           DocAction='--',

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to