Search in sources :

Example 11 with MPPProductBOMLine

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;
}
Also used : MProduct(org.compiere.model.MProduct) MDistributionRunLine(org.compiere.model.MDistributionRunLine) MPPProductBOM(org.eevolution.model.MPPProductBOM) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) BigDecimal(java.math.BigDecimal)

Example 12 with MPPProductBOMLine

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();
    }
}
Also used : X_I_Product_BOM(org.eevolution.model.X_I_Product_BOM) MPPProductBOM(org.eevolution.model.MPPProductBOM) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine)

Example 13 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 14 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 15 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)

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