Search in sources :

Example 6 with MPPProductBOM

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

the class ReleaseInOutBound method createManufacturingOrder.

/**
	 * Create Manufacturing Order when the Is create supply is define as yes
	 * @param outBoundOrderLine Bound Line
	 * @param product Product
	 * @param qtySupply Quantity to Supply
	 */
public void createManufacturingOrder(MWMInOutBoundLine outBoundOrderLine, MProduct product, BigDecimal qtySupply) {
    MPPOrder order = MPPOrder.forC_OrderLine_ID(outBoundOrderLine.getCtx(), outBoundOrderLine.getC_OrderLine_ID(), product.get_ID(), outBoundOrderLine.get_TrxName());
    if (order == null) {
        MPPProductBOM bom = MPPProductBOM.getDefault(product, get_TrxName());
        if (bom != null) {
            MPPProductPlanning productPlanning = null;
            //Validate the BOM based in planning data 
            if (bom == null) {
                productPlanning = MPPProductPlanning.find(getCtx(), outBoundOrderLine.getAD_Org_ID(), 0, 0, product.getM_Product_ID(), null);
                if (productPlanning != null) {
                    bom = (MPPProductBOM) productPlanning.getPP_Product_BOM();
                }
            }
            if (bom != null) {
                final int plant_id = MPPProductPlanning.getPlantForWarehouse(outBoundOrderLine.getM_Warehouse_ID());
                if (plant_id <= 0) {
                    throw new NoPlantForWarehouseException(outBoundOrderLine.getM_Warehouse_ID());
                }
                MWorkflow workflow = MWorkflow.get(getCtx(), MWorkflow.getWorkflowSearchKey(product));
                //Validate the workflow based in planning data 						
                if (workflow == null && productPlanning != null) {
                    workflow = productPlanning.getAD_Workflow();
                }
                if (plant_id > 0 && workflow != null) {
                    String description = Msg.translate(getCtx(), MWMInOutBound.COLUMNNAME_WM_InOutBound_ID) + " : " + outBoundOrderLine.getParent().getDocumentNo();
                    //Create temporary Product Planning to Create Manufacturing Order 
                    productPlanning = new MPPProductPlanning(getCtx(), 0, get_TrxName());
                    productPlanning.setAD_Org_ID(outBoundOrderLine.getAD_Org_ID());
                    productPlanning.setM_Product_ID(product.getM_Product_ID());
                    productPlanning.setPlanner_ID(outBoundOrderLine.getParent().getSalesRep_ID());
                    productPlanning.setPP_Product_BOM_ID(bom.getPP_Product_BOM_ID());
                    productPlanning.setAD_Workflow_ID(workflow.getAD_Workflow_ID());
                    productPlanning.setM_Warehouse_ID(outBoundOrderLine.getM_Warehouse_ID());
                    productPlanning.setS_Resource_ID(plant_id);
                    order = MPPMRP.createMO(productPlanning, outBoundOrderLine.getC_OrderLine_ID(), outBoundOrderLine.getM_AttributeSetInstance_ID(), qtySupply, outBoundOrderLine.getPickDate(), outBoundOrderLine.getShipDate(), description);
                    MOrderLine orderLine = new MOrderLine(getCtx(), outBoundOrderLine.getC_OrderLine_ID(), get_TrxName());
                    description = "";
                    if (orderLine.getDescription() != null)
                        description = orderLine.getDescription();
                    description = description + " " + Msg.translate(orderLine.getCtx(), MPPOrder.COLUMNNAME_PP_Order_ID) + " : " + order.getDocumentNo();
                    orderLine.setDescription(description);
                    orderLine.saveEx();
                    String boundDescription = "";
                    if (outBoundOrderLine.getDescription() != null)
                        boundDescription = outBoundOrderLine.getDescription();
                    boundDescription = boundDescription + " " + Msg.translate(getCtx(), MPPOrder.COLUMNNAME_PP_Order_ID) + " : " + order.getDocumentNo();
                    outBoundOrderLine.setDescription(boundDescription);
                }
            }
        }
    }
    if (order != null) {
        outBoundOrderLine.setProcessed(true);
        outBoundOrderLine.saveEx();
    }
}
Also used : MPPProductPlanning(org.eevolution.model.MPPProductPlanning) MWorkflow(org.compiere.wf.MWorkflow) MOrderLine(org.compiere.model.MOrderLine) MPPProductBOM(org.eevolution.model.MPPProductBOM) NoPlantForWarehouseException(org.eevolution.exceptions.NoPlantForWarehouseException) MPPOrder(org.eevolution.model.MPPOrder)

Example 7 with MPPProductBOM

use of org.eevolution.model.MPPProductBOM 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 8 with MPPProductBOM

use of org.eevolution.model.MPPProductBOM 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 9 with MPPProductBOM

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

the class CopyFromBOM method doIt.

//	prepare
protected String doIt() throws Exception {
    log.info("From PP_Product_BOM_ID=" + p_PP_Product_BOM_ID + " to " + p_Record_ID);
    if (p_Record_ID == 0)
        throw new IllegalArgumentException("Target PP_Product_BOM_ID == 0");
    if (p_PP_Product_BOM_ID == 0)
        throw new IllegalArgumentException("Source PP_Product_BOM_ID == 0");
    if (p_Record_ID == p_PP_Product_BOM_ID)
        return "";
    MPPProductBOM fromBom = new MPPProductBOM(ctx, p_PP_Product_BOM_ID, get_TrxName());
    MPPProductBOM toBOM = new MPPProductBOM(ctx, p_Record_ID, get_TrxName());
    if (toBOM.getLines().length > 0) {
        throw new AdempiereSystemError("@Error@ Existing BOM Line(s)");
    }
    MPPProductBOMLine[] frombomlines = fromBom.getLines();
    for (MPPProductBOMLine frombomline : frombomlines) {
        MPPProductBOMLine tobomline = new MPPProductBOMLine(ctx, 0, get_TrxName());
        MPPProductBOMLine.copyValues(frombomline, tobomline);
        tobomline.setPP_Product_BOM_ID(toBOM.getPP_Product_BOM_ID());
        tobomline.save();
        ++no;
    }
    return "OK";
}
Also used : AdempiereSystemError(org.compiere.util.AdempiereSystemError) MPPProductBOM(org.eevolution.model.MPPProductBOM) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine)

Example 10 with MPPProductBOM

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

the class VBOMDrop method addBOMLines.

//	createMainPanel
/**
	 * 	Add BOM Lines to this.
	 * 	Called recursively
	 * 	@param product product
	 * 	@param qty quantity
	 */
private void addBOMLines(MProduct product, BigDecimal qty) {
    MPPProductBOM bom = MPPProductBOM.getDefault(product, null);
    MPPProductBOMLine[] bomLines = bom.getLines(true);
    for (int i = 0; i < bomLines.length; i++) addBOMLine(bomLines[i], qty);
    log.fine("#" + bomLines.length);
}
Also used : MPPProductBOM(org.eevolution.model.MPPProductBOM) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

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