use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class VProductConfigurationBOM method getTotalBOMLevels.
private int getTotalBOMLevels(HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> m_ConfigBOMInstIDToBOMLinesMap) {
log.fine("In getTotalBOMLevels");
int maxBOMLevel = 0;
Set set = m_ConfigBOMInstIDToBOMLinesMap.entrySet();
for (Iterator i = set.iterator(); i.hasNext(); ) {
Map.Entry me = (Map.Entry) i.next();
HashMap<Integer, ArrayList<MPPProductBOMLine>> m_BOMLevelToLinesMap = new HashMap<Integer, ArrayList<MPPProductBOMLine>>();
log.fine("PP_Product_BOM_ID: " + me.getKey().toString() + " has: ");
m_BOMLevelToLinesMap = (HashMap<Integer, ArrayList<MPPProductBOMLine>>) me.getValue();
Set setLines = m_BOMLevelToLinesMap.entrySet();
for (Iterator k = setLines.iterator(); k.hasNext(); ) {
Map.Entry me2 = (Map.Entry) k.next();
if (((Integer) me2.getKey()).intValue() > maxBOMLevel)
maxBOMLevel = ((Integer) me2.getKey()).intValue();
}
}
log.fine("maxBOMLevel found: " + maxBOMLevel);
return maxBOMLevel;
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class VProductConfigurationBOM method printConfigBOMIDToBOMLinesMapForProduct.
private void printConfigBOMIDToBOMLinesMapForProduct(MProduct m_product, HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> m_ConfigBOMInstIDToBOMLinesMap) {
log.fine("In printConfigBOMIDToBOMLinesMapForProduct");
log.fine("Analyzing product bom id's and corresponding bomlines and levels for those product bom id's for a particular product");
log.fine("Product: " + m_product.getName() + " has:");
log.fine("Total BOM's: " + m_ConfigBOMInstIDToBOMLinesMap.size());
Set set = m_ConfigBOMInstIDToBOMLinesMap.entrySet();
for (Iterator i = set.iterator(); i.hasNext(); ) {
Map.Entry me = (Map.Entry) i.next();
HashMap<Integer, ArrayList<MPPProductBOMLine>> m_BOMLevelToLinesMap = new HashMap<Integer, ArrayList<MPPProductBOMLine>>();
log.fine("PP_Product_BOM_ID: " + me.getKey().toString() + " has: ");
m_BOMLevelToLinesMap = (HashMap<Integer, ArrayList<MPPProductBOMLine>>) me.getValue();
Set setLines = m_BOMLevelToLinesMap.entrySet();
for (Iterator k = setLines.iterator(); k.hasNext(); ) {
Map.Entry me2 = (Map.Entry) k.next();
ArrayList<MPPProductBOMLine> bomLines = (ArrayList<MPPProductBOMLine>) me2.getValue();
log.fine("Total bom lines: " + bomLines.size());
for (int count = 0; count < bomLines.size(); count++) {
MPPProductBOMLine m_MPPProductBOMLine = (MPPProductBOMLine) bomLines.get(count);
log.fine("bom line #: " + count + " product: " + m_MPPProductBOMLine.getDescription());
}
}
}
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class MProduction method createBOM.
/**
* Create Lines from finished product
* @param mustBeStocked
* @param finishedProduct
* @param requiredQty
* @return
*/
private String createBOM(boolean mustBeStocked, MProduct finishedProduct, BigDecimal requiredQty) {
int defaultLocator = 0;
MPPProductBOM bom = MPPProductBOM.getDefault(finishedProduct, get_TrxName());
for (MPPProductBOMLine bLine : bom.getLines()) {
lineno = lineno + 10;
BigDecimal BOMMovementQty = getQty(bLine, true).multiply(requiredQty);
int precision = bLine.getPrecision();
if (BOMMovementQty.scale() > precision) {
BOMMovementQty = BOMMovementQty.setScale(precision, RoundingMode.HALF_UP);
}
MProduct bomproduct = bLine.getProduct();
if (bomproduct.isBOM() && bomproduct.isPhantom()) {
createBOM(mustBeStocked, bomproduct, BOMMovementQty);
} else {
defaultLocator = bomproduct.getM_Locator_ID();
if (defaultLocator == 0)
defaultLocator = getM_Locator_ID();
if (!bomproduct.isStocked()) {
MProductionLine BOMLine = null;
BOMLine = new MProductionLine(this);
BOMLine.setLine(lineno);
BOMLine.setM_Product_ID(bomproduct.getM_Product_ID());
BOMLine.setM_Locator_ID(defaultLocator);
BOMLine.setQtyUsed(BOMMovementQty);
BOMLine.setPlannedQty(BOMMovementQty);
BOMLine.setMovementQty(BOMMovementQty.negate());
BOMLine.saveEx(get_TrxName());
lineno = lineno + 10;
} else if (BOMMovementQty.signum() == 0) {
MProductionLine BOMLine = null;
BOMLine = new MProductionLine(this);
BOMLine.setLine(lineno);
BOMLine.setM_Product_ID(bomproduct.getM_Product_ID());
BOMLine.setM_Locator_ID(defaultLocator);
BOMLine.setQtyUsed(BOMMovementQty);
BOMLine.setPlannedQty(BOMMovementQty);
BOMLine.saveEx(get_TrxName());
lineno = lineno + 10;
} else {
MProductionLine BOMLine = null;
BOMLine = new MProductionLine(this);
BOMLine.setLine(lineno);
BOMLine.setM_Product_ID(bomproduct.getM_Product_ID());
BOMLine.setM_Locator_ID(defaultLocator);
BOMLine.setPlannedQty(BOMMovementQty);
BOMLine.setQtyReserved(BOMMovementQty);
BOMLine.setMovementQty(BOMMovementQty.negate());
BOMLine.saveEx(get_TrxName());
lineno = lineno + 10;
}
// for available storages
}
}
return "";
}
Aggregations