logic to check negative on-hand for warehouse don't work 100% if IsDisallowNegativeInv change sometime

Description

1. when we change "Disallow Negative Inventory" of warehouse from false to true idempiere check quality per warehouse
logic at MWarehouse.beforeSave

SELECT M_Product_ID FROM M_StorageOnHand s WHERE s.M_Locator_ID IN (SELECT M_Locator_ID FROM M_Locator l WHERE M_Warehouse_ID=? ) GROUP BY M_Product_ID, M_Locator_ID, M_AttributeSetInstance_ID, C_OrderLine_ID HAVING SUM(s.QtyOnHand) < 0

2. when do a movement, idempiere check "Disallow Negative Inventory" per locator
logic at MStorageOnHand.addQtyOnHand

if (getQtyOnHand().signum() == -1) {

=======

suppose we have two StorageOnHand record and warehouse is allow negative
onhand_1 record quality = -100
onhand_2 record quality = 200
now we change warehouse to disallow negative. it's ok because total on warehouse > 0

:yellow_star: issue 1:
do a warehouse movement in quality = 50, by logic it choose record onhand_1 to auto balancing
logic on MStorageOnHand.addQtyOnHand will raise NegativeInventoryDisallowed exception

:yellow_star: issue 2:
do a warehouse movement out quality = 150, by logic it choose record onhand_2 to process, so after that we have
onhand_1 record quality = -100
onhand_2 record quality = 50
so now total quality on warehouse is negative, conflict with properties "Disallow Negative Inventory"

, , wdyt?

i description it base on status of my data. but it can be get test case to redo. i will provide test case late.

Environment

None

Attachments

1
  • 30 Jun 2017, 01:04 PM

Activity

Show:

Hiep Lq January 19, 2018 at 5:28 PM

Carlos Ruiz July 4, 2017 at 11:40 AM

, I think your test case is not reproducible - if there is a reproducible test case where disallow negative inventory is set and a storage is saved negative then is a bug (we recently fixed one in production doc).

About the sync between the logic in validation and the logic in storage - if the data can be fixed after set (maybe with a Storage Cleanup, or a movement, or a physical inventory) that would be OK, if the data cannot be fixed then we have a problem.

Hiep Lq June 30, 2017 at 1:05 PM

issue 1: for me it's ok to by pass check Negative Inventory in case move on warehouse

Norbert Bede June 28, 2017 at 1:29 PM

can be related https://idempiere.atlassian.net/browse/IDEMPIERE-3412#icft=IDEMPIERE-3412 - DisallowNegativeQty checks also Locator To

Norbert Bede June 28, 2017 at 1:21 PM

i can confirm time-to-time system hit negative levels when disallow quantity is 0.
Mainly when inventory moves created on warehouse locators across organisations.

Won't Fix

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created June 28, 2017 at 11:06 AM
Updated January 19, 2018 at 5:28 PM
Resolved January 19, 2018 at 5:28 PM