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";
}
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);
}
use of org.eevolution.model.MPPProductBOM in project adempiere by adempiere.
the class MakeToOrderNotStandardBOMandWF 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);
//force not BOM Standard
bom = new MPPProductBOM(getCtx(), PP_Product_BOM_ID, trxName);
if (bom != null) {
bom.setValue(product.getValue() + "-Alternate");
bom.setBOMType(MPPProductBOM.BOMTYPE_Make_To_Order);
bom.setBOMUse(MPPProductBOM.BOMUSE_Manufacturing);
bom.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);
}
use of org.eevolution.model.MPPProductBOM in project adempiere by adempiere.
the class MakeToOrderStandardBOMNotWF 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.setBOMType(MPPProductBOM.BOMTYPE_Make_To_Order);
bom.setBOMUse(MPPProductBOM.BOMUSE_Manufacturing);
bom.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);
}
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();
}
}
Aggregations