details:   https://code.openbravo.com/erp/devel/pi/rev/2807ccffa546
changeset: 33754:2807ccffa546
user:      Armaignac <collazoandy4 <at> gmail.com>
date:      Fri Mar 23 09:29:15 2018 -0400
summary:   Fixes issue 38102: Different behavior in automatic creation of 
negative goods
shipment if the product depending on the product having stock or not

When completing a Warehouse or POS order and at least one line have Insufficient
stock for a product the proper error message doesn't shown in the order window,
also if the product have a negative qty the process fail

Now the correct error message is shown when there is Insufficient stock for a 
product
and a negative Warehouse or Pos order can be completed as a negative shipment 
increase
the product stock

diffstat:

 src-db/database/model/functions/M_INOUT_CREATE.xml |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r ca0f109a23f9 -r 2807ccffa546 
src-db/database/model/functions/M_INOUT_CREATE.xml
--- a/src-db/database/model/functions/M_INOUT_CREATE.xml        Sun Mar 25 
18:46:54 2018 -0400
+++ b/src-db/database/model/functions/M_INOUT_CREATE.xml        Fri Mar 23 
09:29:15 2018 -0400
@@ -619,8 +619,8 @@
                 --<<NEXT_PRODUCT>>
                 NEXT_PRODUCT:=false;
                 
-                IF (v_NegStockLocator IS NULL) THEN
-                -- Get Locator with negative Stock that belongs to the same 
Warehosue      
+                IF (v_NegStockLocator IS NULL AND ((Cur_Order.IsSOTrx = 'Y' 
AND v_Qty>0) OR (Cur_Order.IsSOTrx = 'N' AND v_Qty<0))) THEN
+                -- Get Locator with negative Stock that belongs to the same 
Warehosue for Transactions that decrease the stock
                   SELECT MIN(l.m_locator_id)
                   INTO v_NegStockLocator
                   FROM m_locator l
@@ -634,9 +634,22 @@
                                     WHERE l.m_warehouse_id = ol.M_Warehouse_ID
                                     AND invs.overissue = 'Y'
                                     AND l.isactive='Y');
+                ELSIF (v_NegStockLocator IS NULL AND ((Cur_Order.IsSOTrx = 'Y' 
AND v_Qty<0) OR (Cur_Order.IsSOTrx = 'N' AND v_Qty>0))) THEN
+                -- For Transactions that increase the Stock, pick the Bin with 
the lowest priority for the Warehouse
+                     SELECT MIN(M_LOCATOR_ID)
+                     INTO v_NegStockLocator
+                     FROM M_LOCATOR
+                     WHERE M_WAREHOUSE_ID=ol.M_Warehouse_ID
+                     AND M_LOCATOR.ISACTIVE = 'Y'
+                     AND priorityno = (SELECT min(priorityno) 
+                                                                    FROM 
M_LOCATOR  
+                                                                    WHERE 
M_WAREHOUSE_ID=ol.M_Warehouse_ID
+                                                                    AND 
M_LOCATOR.ISACTIVE = 'Y');
                 END IF;
 
-                IF (v_Qty<>0 AND (v_ForceDelivery='Y' OR v_NegStockLocator IS 
NOT NULL)) THEN
+                IF (v_Qty<>0 AND v_ForceDelivery='Y' AND v_NegStockLocator IS 
NULL) THEN
+                  RAISE_APPLICATION_ERROR(-20000, ' @NotEnoughStocked@ 
@ForProduct@ ' || ol.name);
+                ELSIF (v_Qty<>0 AND (v_ForceDelivery='Y' OR v_NegStockLocator 
IS NOT NULL)) THEN
                   -- Create InOut Line
                   Ad_Sequence_Next('M_InOutLine', Cur_Order.C_Order_ID, 
v_NextNo) ;
                   IF (v_ProductUOM IS NOT NULL) THEN

------------------------------------------------------------------------------
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