protected String doIt() throws Exception
{
X_Z_Packs pack = new X_Z_Packs(getCtx(), getRecord_ID(), get_TrxName());
MProduct product = new MProduct(getCtx(), pack.getM_Product_ID(), get_TrxName());
MPPProductBOM bom = MPPProductBOM.get(product, getAD_Client_ID(), get_TrxName());
MLocator loc = new MLocator(getCtx(), p_M_Locator_ID, get_TrxName());
int chargeID = getChargeID();
// Error Checking. An error results in an exception thrown which is caught
// by SrvProcess which then rolls back any changes to the database made as
// part of the get_TrxName() transaction.
if (bom.is_new())
throw new AdempiereUserError("@Error@ Bill Of Materials does not exist for "+
product.getName());
if (product.getVolume() == null || product.getVolume().doubleValue() <= 0)
throw new AdempiereUserError("@Error@ Volume value for product "+product.getName()+
" is zero or less.");
if (!product.isVerified())
throw new AdempiereUserError("@Error@ Product "+product.getName()+" is not verified");
// Create the Inventory record
MInventory inv = new MInventory(getCtx(), 0, get_TrxName());
inv.setM_Warehouse_ID(loc.getM_Warehouse_ID());
inv.setClientOrg(getAD_Client_ID(), Env.getAD_Org_ID(getCtx()));
inv.addDescription("From BOM " + bom.getValue());
inv.setZPacksDocumentNo();
inv.save(get_TrxName());