use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class DistributionRunOrders method groovy1.
public String groovy1(String A_TrxName, Properties A_Ctx, int P_M_Warehouse_ID, int P_M_PriceList_Version_ID, int P_M_DistributionList_ID) {
MDistributionRunLine main = new MDistributionRunLine(A_Ctx, 0, A_TrxName);
MProduct product = MProduct.get(A_Ctx, main.getM_Product_ID());
BigDecimal Qty = main.getTotalQty();
int seq = main.getLine();
int num = 1;
if (product.isBOM() && Qty.signum() > 0) {
seq += 1;
MPPProductBOM bom = MPPProductBOM.getDefault(product, A_TrxName);
//Explotando los componentes
for (MPPProductBOMLine line : bom.getLines()) {
num += 1;
int M_Product_ID = line.getM_Product_ID();
BigDecimal QtyRequired = line.getQtyBOM().multiply(Qty);
BigDecimal QtyAvailable = MStorage.getQtyAvailable(P_M_Warehouse_ID, M_Product_ID, 0, 0, A_TrxName);
BigDecimal QtyOnHand = MPPMRP.getQtyOnHand(A_Ctx, P_M_Warehouse_ID, M_Product_ID, A_TrxName);
BigDecimal QtyToDeliver = QtyRequired;
if (QtyRequired.compareTo(QtyAvailable) > 0)
QtyToDeliver = QtyAvailable;
MDistributionRunLine drl = new MDistributionRunLine(A_Ctx, 0, A_TrxName);
drl.setM_DistributionRun_ID(main.getM_DistributionRun_ID());
drl.setLine(seq);
drl.setM_Product_ID(M_Product_ID);
drl.setM_DistributionList_ID(main.getM_DistributionList_ID());
drl.setDescription(Msg.translate(A_Ctx, "QtyRequired") + " = " + QtyRequired.intValue() + " | " + Msg.translate(A_Ctx, "QtyAvailable") + " = " + QtyAvailable + " | " + Msg.translate(A_Ctx, "QtyOnHand") + " = " + QtyOnHand);
drl.setTotalQty(QtyToDeliver);
drl.saveEx();
}
}
main.setIsActive(false);
return "Componentes del Juego:" + num;
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class ImportProductBOM method importRecords.
/**
* import the I_Product_BOM records to PP_ProductBOM table
*/
private void importRecords() {
for (X_I_Product_BOM importBOM : getRecords(false, m_IsImportOnlyNoErrors)) {
isImported = false;
MPPProductBOM bom = getMPPProductBOM(importBOM);
MPPProductBOMLine bomLine = null;
if (bom != null)
bomLine = importBOMLine(bom, importBOM);
if (bomLine != null) {
importBOM.setPP_Product_BOMLine_ID(bomLine.getPP_Product_BOMLine_ID());
importBOM.setPP_Product_BOM_ID(bom.get_ID());
imported++;
isImported = true;
}
importBOM.setI_IsImported(isImported);
importBOM.setProcessed(isImported);
importBOM.saveEx();
}
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class BOMVerify method validateProduct.
/**
* Validate Product
* @param product product
* @return Info
*/
private boolean validateProduct(MProduct product) {
if (!product.isBOM())
return false;
// Check Old Product BOM Structure
log.config(product.getName());
foundproducts.add(product);
//MProductBOM[] productsBOMs = MProductBOM.getBOMLines(product);
MPPProductBOMLine[] productsBOMs = MPPProductBOMLine.getBOMLines(product);
boolean containsinvalid = false;
boolean invalid = false;
for (int i = 0; i < productsBOMs.length; i++) {
MPPProductBOMLine productsBOM = productsBOMs[i];
MProduct pp = new MProduct(getCtx(), productsBOM.getM_Product_ID(), get_TrxName());
if (!pp.isBOM())
log.finer(pp.getName());
else {
if (validproducts.contains(pp)) {
//Do nothing, no need to recheck
}
if (invalidproducts.contains(pp)) {
containsinvalid = true;
} else if (foundproducts.contains(pp)) {
invalid = true;
addLog(0, null, null, product.getValue() + " recursively contains " + pp.getValue());
} else {
if (!validateProduct(pp)) {
containsinvalid = true;
}
}
}
}
checkedproducts.add(product);
foundproducts.remove(product);
if (invalid) {
invalidproducts.add(product);
product.setIsVerified(false);
product.save();
return false;
} else if (containsinvalid) {
containinvalidproducts.add(product);
product.setIsVerified(false);
product.save();
return false;
} else {
validproducts.add(product);
product.setIsVerified(true);
product.save();
return true;
}
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class ComponentChange method doIt.
// prepare
@Override
protected String doIt() throws Exception {
if (p_Action == null) {
throw new FillMandatoryException("Action");
}
List<Object> params = new ArrayList<Object>();
StringBuffer whereClause = new StringBuffer();
whereClause.append(MPPProductBOMLine.COLUMNNAME_M_Product_ID + "=?");
params.add(p_M_Product_ID);
if (p_ValidTo != null) {
whereClause.append(" AND TRUNC(" + MPPProductBOMLine.COLUMNNAME_ValidTo + ") <= ?");
params.add(p_ValidTo);
}
if (p_ValidFrom != null) {
whereClause.append(" AND TRUNC(" + MPPProductBOMLine.COLUMNNAME_ValidFrom + ") >= ?");
params.add(p_ValidFrom);
}
List<MPPProductBOMLine> components = new Query(getCtx(), MPPProductBOMLine.Table_Name, whereClause.toString(), get_TrxName()).setParameters(params).list();
for (MPPProductBOMLine bomline : components) {
if (p_Action.equals(ACTION_Add)) {
actionAdd(bomline, 0);
} else if (p_Action.equals(ACTION_Deactivate)) {
actionDeactivate(bomline);
} else if (p_Action.equals(ACTION_Expire)) {
actionExpire(bomline);
} else if (p_Action.equals(ACTION_Replace)) {
actionAdd(bomline, bomline.getLine() + 1);
actionDeactivate(bomline);
} else if (p_Action.equals(ACTION_ReplaceAndExpire)) {
actionAdd(bomline, bomline.getLine() + 1);
actionExpire(bomline);
} else {
throw new AdempiereException("Action not supported - " + p_Action);
}
addLog(MRefList.getListName(getCtx(), ACTION_AD_Reference_ID, p_Action));
}
return "@OK@";
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class CopyFromBOM method doIt.
// prepare
protected String doIt() throws Exception {
log.info("From PP_Product_BOM_ID=" + p_PP_Product_BOM_ID + " to " + p_Record_ID);
if (p_Record_ID == 0)
throw new IllegalArgumentException("Target PP_Product_BOM_ID == 0");
if (p_PP_Product_BOM_ID == 0)
throw new IllegalArgumentException("Source PP_Product_BOM_ID == 0");
if (p_Record_ID == p_PP_Product_BOM_ID)
return "";
MPPProductBOM fromBom = new MPPProductBOM(ctx, p_PP_Product_BOM_ID, get_TrxName());
MPPProductBOM toBOM = new MPPProductBOM(ctx, p_Record_ID, get_TrxName());
if (toBOM.getLines().length > 0) {
throw new AdempiereSystemError("@Error@ Existing BOM Line(s)");
}
MPPProductBOMLine[] frombomlines = fromBom.getLines();
for (MPPProductBOMLine frombomline : frombomlines) {
MPPProductBOMLine tobomline = new MPPProductBOMLine(ctx, 0, get_TrxName());
MPPProductBOMLine.copyValues(frombomline, tobomline);
tobomline.setPP_Product_BOM_ID(toBOM.getPP_Product_BOM_ID());
tobomline.save();
++no;
}
return "OK";
}
Aggregations