int chargeID) throws Exception
{
MPPProductBOMLine[] bomLines = bom.getLines();
MInventoryLine invLine;
MProduct lineProduct;
MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(),
pack.getM_AttributeSetInstance_ID(),
get_TrxName());
BigDecimal sg = (BigDecimal)asi.get_Value("SG");
BigDecimal vol;
int asiID;
// Make sure SG in the Attribute Set Instance has a value. Abort if not.
if (sg == null || sg.equals(BigDecimal.valueOf(0)))
throw new AdempiereUserError("@Error@ SG value not set for Attribute Set Instance "+
asi.getDescription());
// Generate inventory lines from the BOM lines
for (MPPProductBOMLine bomLine : bomLines)
{
lineProduct = new MProduct(getCtx(), bomLine.getM_Product_ID(), get_TrxName());
// Only assign the Attribute Set Instance to lines where the product on
// that line has a Finished Product Batch Number
if (lineProduct.getAttributeSet() != null &&
lineProduct.getAttributeSet().getName().equals("Finished Product Batch Number"))
asiID = asi.getM_AttributeSetInstance_ID();
else
asiID = 0;
invLine = new MInventoryLine(inv,
p_M_Locator_ID,