IDEMPIERE-2629 M_StorageOnHand Qty and Total M_Transaction Qty did not match / integrate peer review from hengsin

This commit is contained in:
Carlos Ruiz 2015-07-23 09:24:58 -05:00
parent 1fbe0d67d9
commit 74e3447857
3 changed files with 2 additions and 5 deletions

View File

@ -121,7 +121,6 @@ public class MProductionLine extends X_M_ProductionLine {
MStorageOnHand storage = MStorageOnHand.getCreate(getCtx(), getM_Locator_ID(), MStorageOnHand storage = MStorageOnHand.getCreate(getCtx(), getM_Locator_ID(),
getM_Product_ID(), asi.get_ID(),dateMPolicy, get_TrxName()); getM_Product_ID(), asi.get_ID(),dateMPolicy, get_TrxName());
storage.addQtyOnHand(getMovementQty()); storage.addQtyOnHand(getMovementQty());
storage.load(storage.get_TrxName());
if (log.isLoggable(Level.FINE))log.log(Level.FINE, "Created finished goods line " + getLine()); if (log.isLoggable(Level.FINE))log.log(Level.FINE, "Created finished goods line " + getLine());
return errorString.toString(); return errorString.toString();
@ -180,7 +179,6 @@ public class MProductionLine extends X_M_ProductionLine {
} }
DB.getDatabase().forUpdate(storages[sl], 120); DB.getDatabase().forUpdate(storages[sl], 120);
storages[sl].addQtyOnHand(lineQty.negate()); storages[sl].addQtyOnHand(lineQty.negate());
storages[sl].load(storages[sl].get_TrxName());
qtyToMove = qtyToMove.subtract(lineQty); qtyToMove = qtyToMove.subtract(lineQty);
if (log.isLoggable(Level.FINE))log.log(Level.FINE, getLine() + " Qty moved = " + lineQty + ", Remaining = " + qtyToMove ); if (log.isLoggable(Level.FINE))log.log(Level.FINE, getLine() + " Qty moved = " + lineQty + ", Remaining = " + qtyToMove );
} }
@ -239,7 +237,6 @@ public class MProductionLine extends X_M_ProductionLine {
if (log.isLoggable(Level.FINE))log.log(Level.FINE, "Saved transaction for " + toString()); if (log.isLoggable(Level.FINE))log.log(Level.FINE, "Saved transaction for " + toString());
} }
storage.addQtyOnHand(lineQty.negate()); storage.addQtyOnHand(lineQty.negate());
storage.load(storage.get_TrxName());
qtyToMove = qtyToMove.subtract(lineQty); qtyToMove = qtyToMove.subtract(lineQty);
if (log.isLoggable(Level.FINE))log.log(Level.FINE, getLine() + " Qty moved = " + lineQty + ", Remaining = " + qtyToMove ); if (log.isLoggable(Level.FINE))log.log(Level.FINE, getLine() + " Qty moved = " + lineQty + ", Remaining = " + qtyToMove );
} }

View File

@ -737,7 +737,6 @@ public class MStorageOnHand extends X_M_StorageOnHand
} }
storage.addQtyOnHand(diffQtyOnHand); storage.addQtyOnHand(diffQtyOnHand);
storage.load(storage.get_TrxName());
if (storage.getQtyOnHand().signum() == -1) { if (storage.getQtyOnHand().signum() == -1) {
if (MWarehouse.get(Env.getCtx(), M_Warehouse_ID).isDisallowNegativeInv()) { if (MWarehouse.get(Env.getCtx(), M_Warehouse_ID).isDisallowNegativeInv()) {
throw new AdempiereException(Msg.getMsg(ctx, "NegativeInventoryDisallowed")); throw new AdempiereException(Msg.getMsg(ctx, "NegativeInventoryDisallowed"));
@ -760,6 +759,7 @@ public class MStorageOnHand extends X_M_StorageOnHand
DB.executeUpdateEx(sql, DB.executeUpdateEx(sql,
new Object[] {addition, Env.getAD_User_ID(Env.getCtx()), getM_Product_ID(), getM_Locator_ID(), getM_AttributeSetInstance_ID(), getDateMaterialPolicy()}, new Object[] {addition, Env.getAD_User_ID(Env.getCtx()), getM_Product_ID(), getM_Locator_ID(), getM_AttributeSetInstance_ID(), getDateMaterialPolicy()},
get_TrxName()); get_TrxName());
load(get_TrxName());
} }
/************************************************************************** /**************************************************************************

View File

@ -249,7 +249,6 @@ public class MStorageReservation extends X_M_StorageReservation {
} }
storage.addQty(diffQty); storage.addQty(diffQty);
storage.load(storage.get_TrxName());
if (s_log.isLoggable(Level.FINE)) { if (s_log.isLoggable(Level.FINE)) {
StringBuilder diffText = new StringBuilder("(Qty=").append(diffQty).append(") -> ").append(storage.toString()); StringBuilder diffText = new StringBuilder("(Qty=").append(diffQty).append(") -> ").append(storage.toString());
s_log.fine(diffText.toString()); s_log.fine(diffText.toString());
@ -267,6 +266,7 @@ public class MStorageReservation extends X_M_StorageReservation {
DB.executeUpdateEx(sql, DB.executeUpdateEx(sql,
new Object[] {addition, Env.getAD_User_ID(Env.getCtx()), getM_Product_ID(), getM_Warehouse_ID(), getM_AttributeSetInstance_ID(), isSOTrx()}, new Object[] {addition, Env.getAD_User_ID(Env.getCtx()), getM_Product_ID(), getM_Warehouse_ID(), getM_AttributeSetInstance_ID(), isSOTrx()},
get_TrxName()); get_TrxName());
load(get_TrxName());
} }
/** /**