use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class RadioButtonTreeCellRenderer method parent.
public DefaultMutableTreeNode parent(MPPProductBOM bom) {
log.fine("Parent:" + bom.getName());
MProduct product = MProduct.get(Env.getCtx(), bom.getM_Product_ID());
//vparent.setValue(m_product_id);
String data = Msg.translate(Env.getCtx(), "PP_Product_BOM_ID") + " " + Msg.translate(Env.getCtx(), "Value") + ":" + bom.getValue() + " " + Msg.translate(Env.getCtx(), "Name") + ": " + bom.getName();
DefaultMutableTreeNode parent = new DefaultMutableTreeNode(new nodeUserObject(data, product, bom, null));
String whereClause = "PP_Product_BOM_ID=?";
List<MPPProductBOMLine> bomlines = new Query(Env.getCtx(), MPPProductBOMLine.Table_Name, whereClause, null).setParameters(new Object[] { bom.getPP_Product_BOM_ID() }).list();
for (MPPProductBOMLine bomline : bomlines) {
MProduct component = MProduct.get(Env.getCtx(), bomline.getM_Product_ID());
//System.out.println("Componente :" + component.getValue() + "[" + component.getName() + "]");
//component(component);
Vector<Comparable<?>> line = new Vector<Comparable<?>>(17);
// 0 Select
line.add(new Boolean(false));
// 1 IsActive
line.add(new Boolean(true));
// 2 Line
line.add(new Integer(bomline.getLine()));
// 3 ValidDrom
line.add((Timestamp) bomline.getValidFrom());
// 4 ValidTo
line.add((Timestamp) bomline.getValidTo());
KeyNamePair pp = new KeyNamePair(component.getM_Product_ID(), component.getName());
// 5 M_Product_ID
line.add(pp);
KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(), "");
// 6 C_UOM_ID
line.add(uom);
// 7 IsQtyPercentage
line.add(new Boolean(bomline.isQtyPercentage()));
// 8 BatchPercent
line.add((BigDecimal) bomline.getQtyBatch());
// 9 QtyBom
line.add((BigDecimal) bomline.getQtyBOM());
// 10 IsCritical
line.add(new Boolean(bomline.isCritical()));
// 11 LTOffSet
line.add((Integer) bomline.getLeadTimeOffset());
// 12 Assay
line.add((BigDecimal) bomline.getAssay());
// 13 Scrap
line.add((BigDecimal) (bomline.getScrap()));
// 14 IssueMethod
line.add((String) bomline.getIssueMethod());
// 15 BackflushGroup
line.add((String) bomline.getBackflushGroup());
// 16 Forecast
line.add((BigDecimal) bomline.getForecast());
//line.add(this.);
dataBOM.add(line);
parent.add(component(component, bom, bomline));
}
return parent;
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class RadioButtonTreeCellRenderer method action_loadBOM.
/**
* Action: Fill Tree with all nodes
*/
public DefaultMutableTreeNode action_loadBOM(MProduct Product, boolean setRoot) {
int M_Product_ID = Product.get_ID();
MProduct M_Product = MProduct.get(Env.getCtx(), M_Product_ID);
MUOM UOM = new MUOM(Env.getCtx(), M_Product.getC_UOM_ID(), null);
DefaultMutableTreeNode root = new DefaultMutableTreeNode(new nodeUserObject(Msg.translate(Env.getCtx(), "M_Product_ID") + Msg.translate(Env.getCtx(), "Value") + ": " + M_Product.getValue() + " " + Msg.translate(Env.getCtx(), "Name") + ": " + M_Product.getName() + " " + Msg.translate(Env.getCtx(), "C_UOM_ID") + ": " + UOM.getName(), M_Product, null, null));
if (setRoot) {
this.root = root;
}
dataBOM.clear();
if (false) {
String whereClause = "M_Product_ID=?";
List<MPPProductBOMLine> bomlines = new Query(Env.getCtx(), MPPProductBOMLine.Table_Name, whereClause, null).setParameters(new Object[] { M_Product_ID }).list();
for (MPPProductBOMLine bomline : bomlines) {
root.add(parent(bomline));
}
} else {
String whereClause = "M_Product_ID=?";
List<MPPProductBOM> boms = new Query(Env.getCtx(), MPPProductBOM.Table_Name, whereClause, null).setParameters(new Object[] { M_Product_ID }).setOnlyActiveRecords(true).list();
for (MPPProductBOM bom : boms) {
DefaultMutableTreeNode child = parent(bom);
root.add(child);
}
}
log.fine("root.getChildCount: " + root.getChildCount());
if (root.getChildCount() > 0) {
root = (DefaultMutableTreeNode) root.getFirstChild();
}
if (setRoot)
this.root = root;
return root;
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class PP_Product_BOM_Check method doIt.
// prepare
/**
* Process
*
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("Check BOM Structure");
// Record ID is M_Product_ID of product to be tested
MProduct xp = new MProduct(Env.getCtx(), p_Record_ID, get_TrxName());
if (!xp.isBOM()) {
log.info("Product is not a BOM");
// No BOM - should not happen, but no problem
return "OK";
}
// Check Parent Level
int lowlevel = MPPProductBOMLine.getLowLevel(getCtx(), p_Record_ID, get_TrxName());
xp.setLowLevel(lowlevel);
xp.setIsVerified(true);
xp.saveEx();
// Get Default BOM from this product
MPPProductBOM tbom = MPPProductBOM.getDefault(xp, get_TrxName());
if (tbom == null) {
raiseError("No Default BOM found: ", "Check BOM Parent search key");
}
// Check All BOM Lines
if (tbom.getM_Product_ID() != 0) {
MPPProductBOMLine[] tbomlines = tbom.getLines();
for (MPPProductBOMLine tbomline : tbomlines) {
lowlevel = tbomline.getLowLevel();
MProduct p = new MProduct(getCtx(), tbomline.getM_Product_ID(), get_TrxName());
p.setLowLevel(lowlevel);
p.setIsVerified(true);
p.saveEx();
}
}
return "OK";
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class MOrder method explodeBOM.
// prepareIt
/**
* Explode non stocked BOM.
* @return true if bom exploded
*/
private boolean explodeBOM() {
boolean retValue = false;
String where = "AND IsActive='Y' AND EXISTS " + "(SELECT * FROM M_Product p WHERE C_OrderLine.M_Product_ID=p.M_Product_ID" + " AND p.IsBOM='Y' AND p.IsVerified='Y' AND p.IsStocked='N')";
//
String sql = "SELECT COUNT(*) FROM C_OrderLine " + "WHERE C_Order_ID=? " + where;
int count = DB.getSQLValue(get_TrxName(), sql, getC_Order_ID());
while (count != 0) {
retValue = true;
// max 999 bom items
renumberLines(1000);
// Order Lines with non-stocked BOMs
MOrderLine[] lines = getLines(where, MOrderLine.COLUMNNAME_Line);
for (int i = 0; i < lines.length; i++) {
MOrderLine line = lines[i];
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID());
log.fine(product.getName());
// New Lines
int lineNo = line.getLine();
//find default BOM with valid dates and to this product
MPPProductBOM bom = MPPProductBOM.get(product, getAD_Org_ID(), getDatePromised(), get_TrxName());
if (bom != null) {
MPPProductBOMLine[] bomlines = bom.getLines(getDatePromised());
for (int j = 0; j < bomlines.length; j++) {
MPPProductBOMLine bomline = bomlines[j];
MOrderLine newLine = new MOrderLine(this);
newLine.setLine(++lineNo);
newLine.setM_Product_ID(bomline.getM_Product_ID());
newLine.setC_UOM_ID(bomline.getC_UOM_ID());
newLine.setQty(line.getQtyOrdered().multiply(bomline.getQtyBOM()));
if (bomline.getDescription() != null)
newLine.setDescription(bomline.getDescription());
//
newLine.setPrice();
newLine.save(get_TrxName());
}
}
/*MProductBOM[] boms = MProductBOM.getBOMLines (product);
for (int j = 0; j < boms.length; j++)
{
//MProductBOM bom = boms[j];
MPPProductBOMLine bom = boms[j];
MOrderLine newLine = new MOrderLine (this);
newLine.setLine (++lineNo);
//newLine.setM_Product_ID (bom.getProduct ()
// .getM_Product_ID ());
newLine.setM_Product_ID (bom.getM_Product_ID ());
//newLine.setC_UOM_ID (bom.getProduct ().getC_UOM_ID ());
newLine.setC_UOM_ID (bom.getC_UOM_ID ());
//newLine.setQty (line.getQtyOrdered ().multiply (
// bom.getBOMQty ()));
newLine.setQty (line.getQtyOrdered ().multiply (
bom.getQtyBOM()));
if (bom.getDescription () != null)
newLine.setDescription (bom.getDescription ());
//
newLine.setPrice ();
newLine.save (get_TrxName());
}*/
// Convert into Comment Line
line.setM_Product_ID(0);
line.setM_AttributeSetInstance_ID(0);
line.setPrice(Env.ZERO);
line.setPriceLimit(Env.ZERO);
line.setPriceList(Env.ZERO);
line.setLineNetAmt(Env.ZERO);
line.setFreightAmt(Env.ZERO);
//
String description = product.getName();
if (product.getDescription() != null)
description += " " + product.getDescription();
if (line.getDescription() != null)
description += " " + line.getDescription();
line.setDescription(description);
line.save(get_TrxName());
}
// for all lines with BOM
// force requery
m_lines = null;
count = DB.getSQLValue(get_TrxName(), sql, getC_Invoice_ID());
renumberLines(10);
}
// while count != 0
return retValue;
}
use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.
the class WTreeBOM method action_loadBOM.
private void action_loadBOM() {
int M_Product_ID = getM_Product_ID();
if (M_Product_ID == 0)
return;
MProduct product = MProduct.get(getCtx(), M_Product_ID);
DefaultTreeNode parent = new DefaultTreeNode(productSummary(product, false), new ArrayList());
dataBOM.clear();
if (isImplosion()) {
try {
m_tree.setModel(null);
} catch (Exception e) {
}
if (m_tree.getTreecols() != null)
m_tree.getTreecols().detach();
if (m_tree.getTreefoot() != null)
m_tree.getTreefoot().detach();
if (m_tree.getTreechildren() != null)
m_tree.getTreechildren().detach();
for (MPPProductBOMLine bomline : MPPProductBOMLine.getByProduct(product)) {
parent.getChildren().add(parent(bomline));
}
Treecols treeCols = new Treecols();
m_tree.appendChild(treeCols);
Treecol treeCol = new Treecol();
treeCols.appendChild(treeCol);
SimpleTreeModel model = new SimpleTreeModel(parent);
m_tree.setPageSize(-1);
m_tree.setTreeitemRenderer(model);
m_tree.setModel(model);
} else {
try {
m_tree.setModel(null);
} catch (Exception e) {
}
if (m_tree.getTreecols() != null)
m_tree.getTreecols().detach();
if (m_tree.getTreefoot() != null)
m_tree.getTreefoot().detach();
if (m_tree.getTreechildren() != null)
m_tree.getTreechildren().detach();
for (MPPProductBOM bom : MPPProductBOM.getProductBOMs(product)) {
parent.getChildren().add(parent(bom));
}
Treecols treeCols = new Treecols();
m_tree.appendChild(treeCols);
Treecol treeCol = new Treecol();
treeCols.appendChild(treeCol);
SimpleTreeModel model = new SimpleTreeModel(parent);
m_tree.setPageSize(-1);
m_tree.setTreeitemRenderer(model);
m_tree.setModel(model);
}
m_tree.addEventListener(Events.ON_SELECTION, this);
loadTableBOM();
}
Aggregations