Search in sources :

Example 1 with MPPProductBOMLine

use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.

the class MInvoice method explodeBOM.

//	prepareIt
/**
	 * 	Explode non stocked BOM.
	 */
private void explodeBOM() {
    String where = "AND IsActive='Y' AND EXISTS " + "(SELECT * FROM M_Product p WHERE C_InvoiceLine.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_InvoiceLine " + "WHERE C_Invoice_ID=? " + where;
    int count = DB.getSQLValueEx(get_TrxName(), sql, getC_Invoice_ID());
    while (count != 0) {
        renumberLines(100);
        //	Order Lines with non-stocked BOMs
        MInvoiceLine[] lines = getLines(where);
        for (int i = 0; i < lines.length; i++) {
            MInvoiceLine 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(), getDateInvoiced(), get_TrxName());
            if (bom != null) {
                MPPProductBOMLine[] bomlines = bom.getLines(getDateInvoiced());
                for (int j = 0; j < bomlines.length; j++) {
                    MPPProductBOMLine bomline = bomlines[j];
                    MInvoiceLine newLine = new MInvoiceLine(this);
                    newLine.setLine(++lineNo);
                    newLine.setM_Product_ID(bomline.getM_Product_ID());
                    newLine.setC_UOM_ID(bomline.getC_UOM_ID());
                    newLine.setQty(line.getQtyInvoiced().multiply(//	Invoiced/Entered
                    bomline.getQtyBOM()));
                    if (bomline.getDescription() != null)
                        newLine.setDescription(bomline.getDescription());
                    //
                    newLine.setPrice();
                    newLine.saveEx(get_TrxName());
                }
            }
            /*MProductBOM[] boms = MProductBOM.getBOMLines (product);
				for (int j = 0; j < boms.length; j++)
				{
					MProductBOM bom = boms[j];
					MInvoiceLine newLine = new MInvoiceLine (this);
					newLine.setLine (++lineNo);
					newLine.setM_Product_ID (bom.getProduct().getM_Product_ID(),
						bom.getProduct().getC_UOM_ID());
					newLine.setQty (line.getQtyInvoiced().multiply(
						bom.getBOMQty ()));		//	Invoiced/Entered
					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.setPriceEntered(Env.ZERO);
            line.setPriceActual(Env.ZERO);
            line.setPriceLimit(Env.ZERO);
            line.setPriceList(Env.ZERO);
            line.setLineNetAmt(Env.ZERO);
            //
            String description = product.getName();
            if (product.getDescription() != null)
                description += " " + product.getDescription();
            if (line.getDescription() != null)
                description += " " + line.getDescription();
            line.setDescription(description);
            line.saveEx(get_TrxName());
        }
        //	for all lines with BOM
        m_lines = null;
        count = DB.getSQLValue(get_TrxName(), sql, getC_Invoice_ID());
        renumberLines(10);
    }
//	while count != 0
}
Also used : MPPProductBOM(org.eevolution.model.MPPProductBOM) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine)

Example 2 with MPPProductBOMLine

use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.

the class WTreeBOM method parent.

public DefaultTreeNode parent(MPPProductBOM bom) {
    DefaultTreeNode parent = new DefaultTreeNode(productSummary(bom), new ArrayList());
    for (MPPProductBOMLine bomline : bom.getLines()) {
        MProduct component = MProduct.get(getCtx(), bomline.getM_Product_ID());
        Vector<Object> line = new Vector<Object>(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(), bomline.getC_UOM().getUOMSymbol());
        //  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());
        dataBOM.add(line);
        parent.getChildren().add(component(component));
    }
    return parent;
}
Also used : MProduct(org.compiere.model.MProduct) DefaultTreeNode(org.zkoss.zul.DefaultTreeNode) ArrayList(java.util.ArrayList) KeyNamePair(org.compiere.util.KeyNamePair) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) Vector(java.util.Vector)

Example 3 with MPPProductBOMLine

use of org.eevolution.model.MPPProductBOMLine in project adempiere by adempiere.

the class MergeBOMAction method createBOMLine.

private void createBOMLine(int bomId, DefaultMutableTreeNode node) {
    BOMLineWrapper sourceLine = (BOMLineWrapper) node.getUserObject();
    MPPProductBOMLine targetLine = new MPPProductBOMLine(Env.getCtx(), 0, null);
    targetLine.setPP_Product_BOM_ID(bomId);
    targetLine.setHelp(sourceLine.getHelp());
    targetLine.setM_ChangeNotice_ID(sourceLine.getM_ChangeNotice_ID());
    targetLine.setAssay(sourceLine.getAssay());
    targetLine.setQtyBatch(sourceLine.getQtyBatch());
    targetLine.setQtyBOM(sourceLine.getQtyBOM());
    targetLine.setIsQtyPercentage(sourceLine.isQtyPercentage());
    targetLine.setComponentType(sourceLine.getComponentType());
    targetLine.setC_UOM_ID(sourceLine.getC_UOM_ID());
    targetLine.setForecast(sourceLine.getForecast());
    targetLine.setIsCritical(sourceLine.isCritical());
    targetLine.setIssueMethod(sourceLine.getIssueMethod());
    targetLine.setLine(sourceLine.getLine());
    targetLine.setLeadTimeOffset(sourceLine.getLeadTimeOffset());
    targetLine.setM_AttributeSetInstance_ID(sourceLine.getM_AttributeSetInstance_ID());
    targetLine.setM_Product_ID(sourceLine.getM_Product_ID());
    targetLine.setScrap(sourceLine.getScrap());
    targetLine.setValidFrom(sourceLine.getValidFrom());
    targetLine.setValidTo(sourceLine.getValidTo());
    actionResult = targetLine.save();
}
Also used : MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) BOMLineWrapper(org.eevolution.model.wrapper.BOMLineWrapper)

Example 4 with MPPProductBOMLine

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;
}
Also used : MProduct(org.compiere.model.MProduct) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Query(org.compiere.model.Query) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) KeyNamePair(org.compiere.util.KeyNamePair) Vector(java.util.Vector)

Example 5 with MPPProductBOMLine

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;
}
Also used : MProduct(org.compiere.model.MProduct) MUOM(org.compiere.model.MUOM) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Query(org.compiere.model.Query) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) MPPProductBOM(org.eevolution.model.MPPProductBOM)

Aggregations

MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)33 ArrayList (java.util.ArrayList)14 MProduct (org.compiere.model.MProduct)13 MPPProductBOM (org.eevolution.model.MPPProductBOM)13 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)10 HashMap (java.util.HashMap)8 ResultSet (java.sql.ResultSet)7 Iterator (java.util.Iterator)6 Map (java.util.Map)6 Set (java.util.Set)6 Query (org.compiere.model.Query)6 BigDecimal (java.math.BigDecimal)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 KeyNamePair (org.compiere.util.KeyNamePair)4 Vector (java.util.Vector)3 AdempiereException (org.adempiere.exceptions.AdempiereException)2 MCost (org.compiere.model.MCost)2 X_T_BOMLine (org.eevolution.model.X_T_BOMLine)2 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)2 PreparedStatement (java.sql.PreparedStatement)1