Bug Fix [ 1564496 ] Inventory Move should warn if insufficient stock on hand
Contributed by Armen Brought back from revision 280 and adapted to new version Completed migration script
This commit is contained in:
parent
73500538fa
commit
f0a5522d82
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
|
@ -13,9 +13,11 @@
|
|||
* For the text or an alternative of this public license, you may reach us *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
* Contributor(s): Armen Rizal (armen@goodwill.co.id) Bug Fix 1564496 *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
import org.compiere.util.*;
|
||||
|
||||
|
@ -33,8 +35,8 @@ public class CalloutMovement extends CalloutEngine
|
|||
*
|
||||
* @param ctx Context
|
||||
* @param WindowNo current Window No
|
||||
* @param mTab Model Tab
|
||||
* @param mField Model Field
|
||||
* @param GridTab Model Tab
|
||||
* @param GridField Model Field
|
||||
* @param value The new value
|
||||
* @return Error message or ""
|
||||
*/
|
||||
|
@ -49,7 +51,68 @@ public class CalloutMovement extends CalloutEngine
|
|||
mTab.setValue("M_AttributeSetInstance_ID", new Integer(Env.getContextAsInt(ctx, Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID")));
|
||||
else
|
||||
mTab.setValue("M_AttributeSetInstance_ID", null);
|
||||
|
||||
// Begin Armen 2006/10/01
|
||||
MProduct product = MProduct.get(ctx, M_Product_ID.intValue());
|
||||
if (product.isStocked()) {
|
||||
BigDecimal MovementQty = (BigDecimal) mTab.getValue("MovementQty");
|
||||
int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID");
|
||||
int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, "M_AttributeSetInstance_ID");
|
||||
BigDecimal available = MStorage.getQtyAvailable(M_Warehouse_ID,
|
||||
M_Product_ID.intValue(), M_AttributeSetInstance_ID, null);
|
||||
if (available == null)
|
||||
available = Env.ZERO;
|
||||
if (available.signum() == 0)
|
||||
mTab.fireDataStatusEEvent("NoQtyAvailable", "0", false);
|
||||
else if (available.compareTo(MovementQty) < 0)
|
||||
mTab.fireDataStatusEEvent("InsufficientQtyAvailable", available.toString(), false);
|
||||
}
|
||||
// End Armen
|
||||
|
||||
return "";
|
||||
} // product
|
||||
|
||||
// Begin Armen 2006/10/01
|
||||
/**
|
||||
* Movement Line - MovementQty modified
|
||||
* called from MovementQty
|
||||
*
|
||||
* @param ctx Context
|
||||
* @param WindowNo current Window No
|
||||
* @param GridTab Model Tab
|
||||
* @param GridField Model Field
|
||||
* @param value The new value
|
||||
* @return Error message or ""
|
||||
*/
|
||||
public String qty(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
|
||||
if (isCalloutActive() || value == null)
|
||||
return "";
|
||||
setCalloutActive(true);
|
||||
|
||||
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
|
||||
// log.log(Level.WARNING,"qty - init - M_Product_ID=" + M_Product_ID);
|
||||
|
||||
if (M_Product_ID != 0) {
|
||||
MProduct product = MProduct.get(ctx, M_Product_ID);
|
||||
if (product.isStocked()) {
|
||||
BigDecimal MovementQty = (BigDecimal) value;
|
||||
int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID");
|
||||
int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx,
|
||||
WindowNo, "M_AttributeSetInstance_ID");
|
||||
BigDecimal available = MStorage.getQtyAvailable(M_Warehouse_ID,
|
||||
M_Product_ID, M_AttributeSetInstance_ID, null);
|
||||
if (available == null)
|
||||
available = Env.ZERO;
|
||||
if (available.signum() == 0)
|
||||
mTab.fireDataStatusEEvent("NoQtyAvailable", "0", false);
|
||||
else if (available.compareTo(MovementQty) < 0)
|
||||
mTab.fireDataStatusEEvent("InsufficientQtyAvailable",
|
||||
available.toString(), false);
|
||||
}
|
||||
}
|
||||
//
|
||||
setCalloutActive(false);
|
||||
return "";
|
||||
} // qty
|
||||
|
||||
} // CalloutMove
|
|
@ -0,0 +1,5 @@
|
|||
UPDATE AD_COLUMN
|
||||
SET callout = 'org.compiere.model.CalloutMovement.qty'
|
||||
WHERE ad_column_id = 3594;
|
||||
|
||||
COMMIT;
|
|
@ -0,0 +1,5 @@
|
|||
UPDATE AD_COLUMN
|
||||
SET callout = 'org.compiere.model.CalloutMovement.qty'
|
||||
WHERE ad_column_id = 3594;
|
||||
|
||||
COMMIT;
|
Loading…
Reference in New Issue