Search in sources :

Example 21 with MPPProductBOM

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

the class ImportProductBOM method getMPPProductBOM.

/**
	 * Get Product BOM, if it does not exist then create it
	 * 
	 * @param importBOM
	 *            I_Product_BOM
	 * @return MPPProductBOM Product BOM
	 */
private MPPProductBOM getMPPProductBOM(X_I_Product_BOM importBOM) {
    final String whereClause = I_I_Product_BOM.COLUMNNAME_M_Product_ID + "=? AND " + I_I_Product_BOM.COLUMNNAME_Value + "=?";
    MPPProductBOM bom = new Query(Env.getCtx(), MPPProductBOM.Table_Name, whereClause, get_TrxName()).setClient_ID().setParameters(importBOM.getM_Product_ID(), importBOM.getValue()).firstOnly();
    if (bom == null) {
        bom = new MPPProductBOM(Env.getCtx(), 0, get_TrxName());
        bom.setAD_Org_ID(importBOM.getAD_Org_ID());
        bom.setM_Product_ID(importBOM.getM_Product_ID());
        bom.setValue(((importBOM.getValue() == null || importBOM.getValue().isEmpty()) ? importBOM.getM_Product().getValue() : importBOM.getValue()));
    }
    bom.setName((importBOM.getName() == null || importBOM.getName().isEmpty()) ? importBOM.getM_Product().getName() : importBOM.getName());
    bom.setValidFrom(importBOM.getValidFrom());
    bom.setValidTo(importBOM.getValidTo());
    bom.setBOMType(importBOM.getBOMType());
    bom.setBOMUse(importBOM.getBOMUse());
    bom.setDescription(importBOM.getDescription());
    bom.setDocumentNo(importBOM.getDocumentNo());
    bom.setHelp(importBOM.getHelp());
    bom.setC_UOM_ID(importBOM.getM_Product().getC_UOM_ID());
    bom.saveEx();
    return bom;
}
Also used : Query(org.compiere.model.Query) MPPProductBOM(org.eevolution.model.MPPProductBOM)

Example 22 with MPPProductBOM

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

the class BOMWrapper method getLines.

public BOMLineWrapper[] getLines() {
    int[] ids = null;
    String type = null;
    if (get() instanceof MPPProductBOM) {
        type = BOM_TYPE_PRODUCT;
    } else if (get() instanceof MPPOrderBOM) {
        type = BOM_TYPE_ORDER;
    }
    StorageReasoner mr = new StorageReasoner();
    ids = mr.getPOIDs(BOMLineWrapper.tableName(type), idColumn(type) + " = " + getID(), null);
    BOMLineWrapper[] lines = new BOMLineWrapper[ids.length];
    for (int i = 0; i < ids.length; i++) {
        lines[i] = new BOMLineWrapper(getCtx(), ids[i], null, type);
    }
    return lines;
}
Also used : MPPOrderBOM(org.eevolution.model.MPPOrderBOM) StorageReasoner(org.eevolution.model.reasoner.StorageReasoner) MPPProductBOM(org.eevolution.model.MPPProductBOM)

Example 23 with MPPProductBOM

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

the class VTreeBOM method parent.

//	action_fillTree
public DefaultMutableTreeNode parent(MPPProductBOMLine bomline) {
    //System.out.println("-------------------------Parent:" + bom.getName());
    MProduct M_Product = MProduct.get(getCtx(), bomline.getM_Product_ID());
    MPPProductBOM bomproduct = new MPPProductBOM(getCtx(), bomline.getPP_Product_BOM_ID(), null);
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(productSummary(M_Product, false));
    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(M_Product.getM_Product_ID(), M_Product.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 IsQtyPorcentage
    line.add(new Boolean(bomline.isQtyPercentage()));
    //  8 BatchPercent
    line.add((BigDecimal) bomline.getQtyBatch());
    //  9 QtyBOM
    line.add((BigDecimal) ((bomline.getQtyBOM() != null) ? bomline.getQtyBOM() : new BigDecimal(0)));
    //  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);
    for (MPPProductBOM bom : MPPProductBOM.getProductBOMs((MProduct) bomproduct.getM_Product())) {
        MProduct component = MProduct.get(getCtx(), bom.getM_Product_ID());
        return component(component);
    }
    return parent;
}
Also used : MProduct(org.compiere.model.MProduct) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) KeyNamePair(org.compiere.util.KeyNamePair) MPPProductBOM(org.eevolution.model.MPPProductBOM) Vector(java.util.Vector) BigDecimal(java.math.BigDecimal)

Example 24 with MPPProductBOM

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

Example 25 with MPPProductBOM

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

the class MakeToOrderStandardBOMandWF method test01.

public void test01() throws Exception {
    Qty = new BigDecimal(10);
    //Define Product
    product = MProduct.get(getCtx(), M_Product_ID);
    //Define Business Partner
    BPartner = new MBPartner(getCtx(), C_BPartner_ID, trxName);
    //Setting the BOM
    int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(product);
    if (PP_Product_BOM_ID > 0)
        bom = new MPPProductBOM(getCtx(), PP_Product_BOM_ID, trxName);
    else
        throw new AdempiereException("@NotFound@ @PP_ProductBOM_ID@");
    if (bom != null) {
        bom.setValue(product.getValue());
        bom.setBOMType(MPPProductBOM.BOMTYPE_Make_To_Order);
        bom.setBOMUse(MPPProductBOM.BOMUSE_Manufacturing);
        bom.saveEx();
    }
    //force Workflow as standard
    workflow = new MWorkflow(getCtx(), AD_Workflow_ID, trxName);
    workflow.setValue(product.getValue());
    workflow.saveEx();
    if (AD_Workflow_ID > 0)
        workflow = MWorkflow.get(getCtx(), AD_Workflow_ID);
    else
        throw new AdempiereException("@NotFound@ @AD_Workflow_ID@");
    /* Validate Exception if a Planning data is no defined
		MPPProductPlanning pp = MPPProductPlanning.find(getCtx(), AD_Org_ID, M_Warehouse_ID , S_Resource_ID , M_Product_ID, trxName); 	
		pp.setS_Resource_ID(50000);
		pp.saveEx();*/
    createOrder();
    MPPOrder expected = createPPOrder();
    I_PP_Order actual = MPPOrder.forC_OrderLine_ID(getCtx(), oline.get_ID(), oline.getM_Product_ID(), trxName);
    if (actual == null) {
        throw new AdempiereException("@NotFound@ @PP_Order_ID@ not was generate");
    }
    assertEquals("Confirming Manufacturing Order", expected, actual);
}
Also used : I_PP_Order(org.eevolution.model.I_PP_Order) AdempiereException(org.adempiere.exceptions.AdempiereException) MWorkflow(org.compiere.wf.MWorkflow) MBPartner(org.compiere.model.MBPartner) MPPProductBOM(org.eevolution.model.MPPProductBOM) BigDecimal(java.math.BigDecimal) MPPOrder(org.eevolution.model.MPPOrder)

Aggregations

MPPProductBOM (org.eevolution.model.MPPProductBOM)31 BigDecimal (java.math.BigDecimal)14 MProduct (org.compiere.model.MProduct)14 MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)14 Query (org.compiere.model.Query)11 ArrayList (java.util.ArrayList)8 AdempiereException (org.adempiere.exceptions.AdempiereException)6 MWorkflow (org.compiere.wf.MWorkflow)6 Arrays (java.util.Arrays)5 List (java.util.List)5 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)5 MAcctSchema (org.compiere.model.MAcctSchema)5 MCost (org.compiere.model.MCost)5 MCostElement (org.compiere.model.MCostElement)5 Env (org.compiere.util.Env)5 MPPOrder (org.eevolution.model.MPPOrder)5 MBPartner (org.compiere.model.MBPartner)4 I_PP_Order (org.eevolution.model.I_PP_Order)4 MPPProductPlanning (org.eevolution.model.MPPProductPlanning)4 Vector (java.util.Vector)3