use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class ComponentChange method actionAdd.
// doIt
protected void actionAdd(MPPProductBOMLine bomline, int line) {
MPPProductBOMLine newbomline = new MPPProductBOMLine(getCtx(), 0, get_TrxName());
MPPProductBOMLine.copyValues(bomline, newbomline);
newbomline.setIsActive(true);
newbomline.setLine(line);
newbomline.setM_ChangeNotice_ID(p_M_ChangeNotice_ID);
//
newbomline.setM_Product_ID(p_New_M_Product_ID);
if (p_Qty.signum() != 0) {
newbomline.setQtyBOM(p_Qty);
}
newbomline.setValidFrom(newbomline.getUpdated());
newbomline.saveEx();
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class ImportProductBOM method importBOMLine.
/**
* Import or update an existent BOM Line
*
* @param bom
* Product BOM
* @param importBOM
* Import Product BOM
* @return MPPProductBOMLine if is imported
*/
private MPPProductBOMLine importBOMLine(MPPProductBOM bom, X_I_Product_BOM importBOM) {
// Search a BOM Line if not exist create a new based on import record
MPPProductBOMLine bomLine = getProductBOMLine(bom, importBOM);
// Component
MProduct component = new MProduct(Env.getCtx(), importBOM.getM_BOMProduct_ID(), get_TrxName());
if (bomLine == null) {
bomLine = new MPPProductBOMLine(Env.getCtx(), 0, get_TrxName());
bomLine.setAD_Org_ID(importBOM.getAD_Org_ID());
bomLine.setPP_Product_BOM_ID(bom.get_ID());
bomLine.setM_Product_ID(importBOM.getM_BOMProduct_ID());
}
bomLine.setComponentType(importBOM.getComponentType());
bomLine.setQtyBOM(importBOM.getQtyBOM());
bomLine.setQtyBatch(importBOM.getQtyBatch());
bomLine.setIssueMethod(importBOM.getIssueMethod());
bomLine.setIsQtyPercentage(importBOM.isQtyPercentage());
bomLine.setValidFrom(importBOM.getValidFrom());
bomLine.setM_ChangeNotice_ID(importBOM.getM_ChangeNotice_ID());
bomLine.setIsCritical(importBOM.isCritical());
bomLine.setCostAllocationPerc(importBOM.getCostAllocationPerc());
bomLine.setScrap(importBOM.getScrap());
bomLine.setAssay(importBOM.getAssay());
bomLine.setBackflushGroup(importBOM.getBackflushGroup());
bomLine.setLeadTimeOffset(importBOM.getLeadTimeOffset());
if (importBOM.getC_UOM_ID() > 0)
bomLine.setC_UOM_ID(importBOM.getC_UOM_ID());
else
bomLine.setC_UOM_ID(component.getC_UOM_ID());
bomLine.saveEx();
return bomLine;
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class IndentedBOM method getBOMs.
/**
* Get BOMs for given product
* @param product
* @param isComponent
* @return list of MProductBOM
*/
private List<MPPProductBOMLine> getBOMs(MProduct product) {
log.severe(" PRODUCT NAME = " + product.getName());
StringBuffer whereClause = new StringBuffer();
whereClause.append(MPPProductBOMLine.COLUMNNAME_PP_Product_BOM_ID);
whereClause.append(" IN ( SELECT PP_Product_BOM_ID FROM PP_Product_BOM ");
whereClause.append(" WHERE M_Product_ID = " + product.get_ID() + " ) ");
List<MPPProductBOMLine> list = new Query(getCtx(), MPPProductBOMLine.Table_Name, whereClause.toString(), null).setOnlyActiveRecords(true).setOrderBy(MPPProductBOMLine.COLUMNNAME_Line).list();
return list;
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class IndentedBOM method explodeProduct.
// doIt
/**
* Generate an Explosion for this product
* @param product
* @param isComponent component / header
*/
private llCost explodeProduct(int M_Product_ID, BigDecimal qty, BigDecimal accumQty) {
MProduct product = MProduct.get(getCtx(), M_Product_ID);
X_T_BOM_Indented tboml = new X_T_BOM_Indented(getCtx(), 0, get_TrxName());
tboml.setAD_Org_ID(p_AD_Org_ID);
tboml.setC_AcctSchema_ID(p_C_AcctSchema_ID);
tboml.setAD_PInstance_ID(getAD_PInstance_ID());
tboml.setM_CostElement_ID(p_M_CostElement_ID);
tboml.setSel_Product_ID(product.get_ID());
tboml.setM_Product_ID(p_M_Product_ID);
tboml.setQtyBOM(qty);
tboml.setQty(accumQty);
//
tboml.setSeqNo(m_SeqNo);
tboml.setLevelNo(m_LevelNo);
tboml.setLevels((m_LevelNo > 0 ? ":" : "") + StringUtils.repeat(" ", m_LevelNo) + " " + product.getValue());
//
// Set Costs:
MCost cost = MCost.get(product, 0, m_as, p_AD_Org_ID, 0, p_M_CostElement_ID, get_TrxName());
tboml.setCurrentCostPrice(cost.getCurrentCostPrice());
tboml.setCost(cost.getCurrentCostPrice().multiply(accumQty));
tboml.setFutureCostPrice(cost.getFutureCostPrice());
tboml.setCostFuture(cost.getFutureCostPrice().multiply(accumQty));
m_SeqNo++;
BigDecimal llCost = Env.ZERO;
BigDecimal llFutureCost = Env.ZERO;
List<MPPProductBOMLine> list = getBOMs(product);
for (MPPProductBOMLine bom : list) {
m_LevelNo++;
llCost ll = explodeProduct(bom.getM_Product_ID(), bom.getQtyBOM(), accumQty.multiply(bom.getQtyBOM()));
llCost = llCost.add(ll.currentCost.multiply(accumQty.multiply(bom.getQtyBOM())));
llFutureCost = llFutureCost.add(ll.futureCost.multiply(accumQty.multiply(bom.getQtyBOM())));
m_LevelNo--;
}
llCost retVal = new llCost();
if (list.size() == 0) {
tboml.setCurrentCostPriceLL(cost.getCurrentCostPrice());
tboml.setFutureCostPriceLL(cost.getFutureCostPrice());
//
retVal.currentCost = cost.getCurrentCostPrice();
retVal.futureCost = cost.getFutureCostPrice();
} else {
tboml.setCurrentCostPriceLL(llCost);
tboml.setFutureCostPriceLL(llFutureCost);
//
retVal.currentCost = llCost;
retVal.futureCost = llFutureCost;
}
tboml.saveEx();
return retVal;
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class VProductConfigurationBOM method buildConfigBOMIDToBOMLevelToLinesMap.
private HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> buildConfigBOMIDToBOMLevelToLinesMap(MProduct m_product) {
log.fine("In buildConfigBOMIDToBOMLevelToLinesMap");
HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> m_ConfigBOMIDToBOMLevelToLinesMap = new HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>>();
HashMap<Integer, ArrayList<MPPProductBOMLine>> m_BOMLevelToLinesMap = new HashMap<Integer, ArrayList<MPPProductBOMLine>>();
MPPProductBOMLine[] bomLines = getBOMLines(m_product);
int bomLevel = 0;
ArrayList<MPPProductBOMLine> col = new ArrayList<MPPProductBOMLine>();
for (int i = 0; i < bomLines.length; i++) {
log.fine("bom line from product with product_id: " + getProductFromMPPProductBOMLine(bomLines[i]).get_ID());
col.add(bomLines[i]);
}
//Collection<MPPProductBOMLine> col = new ArrayList<MPPProductBOMLine>();
//Collections.addAll(col, bomLines);
m_BOMLevelToLinesMap.put(new Integer(bomLevel), (ArrayList) col);
MPPProductBOMLine m_MPPProductBOMLine = bomLines[0];
int PP_Product_BOM_ID = m_MPPProductBOMLine.getPP_Product_BOM_ID();
m_ConfigBOMIDToBOMLevelToLinesMap.put(new Integer(PP_Product_BOM_ID), m_BOMLevelToLinesMap);
return m_ConfigBOMIDToBOMLevelToLinesMap;
}
Aggregations