BF [ 1879568 ] CalloutMouvement QtyAvailable issues
http://sourceforge.net/tracker/?func=detail&atid=879332&aid=1879568&group_id=176962 * minor refactoring
This commit is contained in:
parent
b4016c6fc0
commit
f7ebc30818
|
@ -26,6 +26,9 @@ import org.compiere.util.*;
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: CalloutMovement.java,v 1.2 2006/07/30 00:51:03 jjanke Exp $
|
* @version $Id: CalloutMovement.java,v 1.2 2006/07/30 00:51:03 jjanke Exp $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
|
* <li>BF [ 1879568 ] CalloutMouvement QtyAvailable issues
|
||||||
*/
|
*/
|
||||||
public class CalloutMovement extends CalloutEngine
|
public class CalloutMovement extends CalloutEngine
|
||||||
{
|
{
|
||||||
|
@ -52,23 +55,7 @@ public class CalloutMovement extends CalloutEngine
|
||||||
else
|
else
|
||||||
mTab.setValue("M_AttributeSetInstance_ID", null);
|
mTab.setValue("M_AttributeSetInstance_ID", null);
|
||||||
|
|
||||||
// Begin Armen 2006/10/01
|
checkQtyAvailable(ctx, mTab, WindowNo, M_Product_ID, null);
|
||||||
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 "";
|
return "";
|
||||||
} // product
|
} // product
|
||||||
|
|
||||||
|
@ -90,29 +77,61 @@ public class CalloutMovement extends CalloutEngine
|
||||||
setCalloutActive(true);
|
setCalloutActive(true);
|
||||||
|
|
||||||
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
|
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
|
||||||
// log.log(Level.WARNING,"qty - init - M_Product_ID=" + M_Product_ID);
|
checkQtyAvailable(ctx, mTab, WindowNo, M_Product_ID, (BigDecimal)value);
|
||||||
|
//
|
||||||
|
setCalloutActive(false);
|
||||||
|
return "";
|
||||||
|
} // qty
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Movement Line - Locator modified
|
||||||
|
*
|
||||||
|
* @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 locator(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
|
||||||
|
if (value == null)
|
||||||
|
return "";
|
||||||
|
int M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
|
||||||
|
checkQtyAvailable(ctx, mTab, WindowNo, M_Product_ID, null);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check available qty
|
||||||
|
*
|
||||||
|
* @param ctx context
|
||||||
|
* @param mTab Model Tab
|
||||||
|
* @param WindowNo current Window No
|
||||||
|
* @param M_Product_ID product ID
|
||||||
|
* @param MovementQty movement qty (if null will be get from context "MovementQty")
|
||||||
|
*/
|
||||||
|
private void checkQtyAvailable(Properties ctx, GridTab mTab, int WindowNo, int M_Product_ID, BigDecimal MovementQty) {
|
||||||
|
// Begin Armen 2006/10/01
|
||||||
if (M_Product_ID != 0) {
|
if (M_Product_ID != 0) {
|
||||||
MProduct product = MProduct.get(ctx, M_Product_ID);
|
MProduct product = MProduct.get(ctx, M_Product_ID);
|
||||||
if (product.isStocked()) {
|
if (product.isStocked()) {
|
||||||
BigDecimal MovementQty = (BigDecimal) value;
|
if (MovementQty == null)
|
||||||
int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID");
|
MovementQty = (BigDecimal) mTab.getValue("MovementQty");
|
||||||
int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx,
|
int M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, "M_Locator_ID");
|
||||||
WindowNo, "M_AttributeSetInstance_ID");
|
// If no locator, don't check anything and assume is ok
|
||||||
BigDecimal available = MStorage.getQtyAvailable(M_Warehouse_ID,
|
if (M_Locator_ID <= 0)
|
||||||
M_Product_ID, M_AttributeSetInstance_ID, null);
|
return;
|
||||||
|
int M_Warehouse_ID = MLocator.get(ctx, M_Locator_ID).getM_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)
|
if (available == null)
|
||||||
available = Env.ZERO;
|
available = Env.ZERO;
|
||||||
if (available.signum() == 0)
|
if (available.signum() == 0)
|
||||||
mTab.fireDataStatusEEvent("NoQtyAvailable", "0", false);
|
mTab.fireDataStatusEEvent("NoQtyAvailable", "0", false);
|
||||||
else if (available.compareTo(MovementQty) < 0)
|
else if (available.compareTo(MovementQty) < 0)
|
||||||
mTab.fireDataStatusEEvent("InsufficientQtyAvailable",
|
mTab.fireDataStatusEEvent("InsufficientQtyAvailable", available.toString(), false);
|
||||||
available.toString(), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
// End Armen
|
||||||
setCalloutActive(false);
|
}
|
||||||
return "";
|
|
||||||
} // qty
|
|
||||||
|
|
||||||
} // CalloutMove
|
} // CalloutMove
|
|
@ -0,0 +1,8 @@
|
||||||
|
-- BF [ 1879568 ] CalloutMouvement QtyAvailable issues
|
||||||
|
-- http://sourceforge.net/tracker/?func=detail&atid=879332&aid=1879568&group_id=176962
|
||||||
|
--
|
||||||
|
-- WARNING: if you already modified the Callout column, this update will do nothing, solve the issue manually
|
||||||
|
update AD_Column set Callout='org.compiere.model.CalloutMovement.locator'
|
||||||
|
where AD_Column_ID=3591 and Callout is null;
|
||||||
|
--
|
||||||
|
commit;
|
|
@ -0,0 +1,8 @@
|
||||||
|
-- BF [ 1879568 ] CalloutMouvement QtyAvailable issues
|
||||||
|
-- http://sourceforge.net/tracker/?func=detail&atid=879332&aid=1879568&group_id=176962
|
||||||
|
--
|
||||||
|
-- WARNING: if you already modified the Callout column, this update will do nothing, solve the issue manually
|
||||||
|
update AD_Column set Callout='org.compiere.model.CalloutMovement.locator'
|
||||||
|
where AD_Column_ID=3591 and Callout is null;
|
||||||
|
--
|
||||||
|
commit;
|
Loading…
Reference in New Issue