use of org.eevolution.model.MPPProductBOM in project adempiere by adempiere.
the class AbstractMakeToOrder 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();
}
//Define Workflow as standardd
workflow = new MWorkflow(getCtx(), AD_Workflow_ID, trxName);
workflow.setValue(product.getValue());
workflow.saveEx();
//int workflow_id = MWorkflow.getWorkflowSearchKey(product);
if (AD_Workflow_ID > 0)
workflow = MWorkflow.get(getCtx(), AD_Workflow_ID);
else
throw new AdempiereException("@NotFound@ @AD_Workflow_ID@");
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 RollupBillOfMaterial method doIt.
// prepare
/**
* Generate Calculate Cost
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
//Get account schema
MAcctSchema acctSchema = MAcctSchema.get(getCtx(), getAccountingSchemaId());
//Get cost type
MCostType costType = MCostType.get(getCtx(), getCostTypeId());
final List<MCostElement> costElements = getCostElementId() > 0 ? Arrays.asList(MCostElement.get(getCtx(), getCostElementId())) : MCostElement.getCostElement(getCtx(), get_TrxName());
//Get max low level
int maxLowLevel = MPPMRP.getMaxLowLevel(getCtx(), get_TrxName());
// Cost Roll-up for all levels
for (int lowLevel = maxLowLevel; lowLevel >= 0; lowLevel--) {
//Iterate product based in parameters
Arrays.stream(getProductIds(lowLevel)).filter(productId -> productId > 0).forEach(productId -> {
MProduct product = MProduct.get(getCtx(), productId);
I_PP_Product_Planning productPlanning = MPPProductPlanning.find(getCtx(), getOrganizationId(), getWarehouseId(), getResourcePlantId(), productId, get_TrxName());
int bomId = 0;
if (productPlanning != null)
bomId = productPlanning.getPP_Product_BOM_ID();
else
createNotice(product, Msg.parseTranslation(getCtx(), "@NotFound@ @PP_Product_Planning_ID@"));
if (bomId <= 0)
bomId = MPPProductBOM.getBOMSearchKey(product);
MPPProductBOM bom = MPPProductBOM.get(getCtx(), bomId);
if (bom == null)
createNotice(product, Msg.parseTranslation(getCtx(), "@NotFound@ @PP_Product_BOM_ID@"));
Trx.run(new TrxRunnable() {
MAcctSchema acctSchema;
MCostType costType;
MProduct product;
MPPProductBOM bom;
public TrxRunnable setParameters(MAcctSchema acctSchema, MCostType costType, MProduct product, MPPProductBOM bom) {
this.acctSchema = acctSchema;
this.costType = costType;
this.product = product;
this.bom = bom;
return this;
}
public void run(String trxName) {
costElements.stream().filter(costElement -> costElement != null).forEach(costElement -> {
rollup(acctSchema, costType, costElement, product, bom, trxName);
});
}
}.setParameters(acctSchema, costType, product, bom));
});
// Products List
}
// for Low Lever
return "@OK@";
}
use of org.eevolution.model.MPPProductBOM in project adempiere by adempiere.
the class VTreeBOM method action_loadBOM.
// actionPerformed
/**
* Action: Fill Tree with all nodes
*/
private void action_loadBOM() {
int M_Product_ID = getM_Product_ID();
if (M_Product_ID == 0)
return;
MProduct product = MProduct.get(getCtx(), M_Product_ID);
DefaultMutableTreeNode parent = new DefaultMutableTreeNode(productSummary(product, false));
dataBOM.clear();
m_level = 0;
if (isImplosion()) {
for (MPPProductBOMLine bomline : MPPProductBOMLine.getByProduct(product)) {
parent.add(parent(bomline));
}
m_tree = new JTree(parent);
} else {
for (MPPProductBOM bom : MPPProductBOM.getProductBOMs(product)) {
parent.add(parent(bom));
}
m_tree = new JTree(parent);
}
m_tree.addTreeSelectionListener(this);
treePane.getViewport().add(m_tree, null);
loadTableBOM();
dataPane.getViewport().add(tableBOM, null);
// 4Layers - Set divider location
splitPane.setDividerLocation(DIVIDER_LOCATION);
// 4Layers - end
}
use of org.eevolution.model.MPPProductBOM in project adempiere by adempiere.
the class VProductConfigurationBOM method getBOMLines.
/**
* Get Array of BOM Lines
* @return MProduct
*/
private MPPProductBOMLine[] getBOMLines(MProduct m_product) {
Collection<MPPProductBOMLine> col = new ArrayList<MPPProductBOMLine>();
try {
StringBuffer sql1 = new StringBuffer("select pp_product_bom_id from pp_product_bom where m_product_id = ?");
PreparedStatement pstmt = DB.prepareStatement(sql1.toString(), null);
pstmt.setInt(1, m_product.get_ID());
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
int m_pp_product_bom_id = rs.getInt(1);
MPPProductBOM m_MPPProductBOM = new MPPProductBOM(Env.getCtx(), m_pp_product_bom_id, null);
MPPProductBOMLine[] bomLines = m_MPPProductBOM.getLines();
//...or pass an explicit array
Collections.addAll(col, bomLines);
}
rs.close();
pstmt.close();
} catch (SQLException s) {
log.log(Level.SEVERE, "ERROR:", s);
}
return (MPPProductBOMLine[]) col.toArray(new MPPProductBOMLine[col.size()]);
}
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;
}
Aggregations