use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class CPOS method generateInvoice.
/**
* Generate Invoice
* @param trxName
* @return void
*/
private void generateInvoice(String trxName) {
List<Integer> selectionIds = new ArrayList<Integer>();
selectionIds.add(getC_Order_ID());
//Generate InvoiceGenerate
ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(134).withTitle(Msg.parseTranslation(getCtx(), "@InvGenerateGen@")).withParameter("Selection", true).withParameter(MInvoice.COLUMNNAME_DocAction, DocAction.ACTION_Complete).withSelectedRecordsIds(selectionIds).withoutTransactionClose().execute(trxName);
if (processInfo.isError())
throw new AdempiereException(processInfo.getSummary());
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class CPOS method generateShipment.
// processOrder
/**
* Generate Shipment
* @param trxName
* @return void
*/
private void generateShipment(String trxName) {
List<Integer> selectionIds = new ArrayList<Integer>();
selectionIds.add(getC_Order_ID());
//Generate Return using InOutGenerate
ProcessInfo processInfo = ProcessBuilder.create(getCtx()).process(199).withTitle(Msg.parseTranslation(getCtx(), "@InOutGenerateGen@")).withParameter(MInOut.COLUMNNAME_M_Warehouse_ID, getM_Warehouse_ID()).withParameter("Selection", true).withSelectedRecordsIds(selectionIds).withoutTransactionClose().execute(trxName);
if (processInfo.isError())
throw new AdempiereException(processInfo.getSummary());
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class CostBillOfMaterial method explodeProduct.
// doIt
/**
* * Generate an Explosion for this product
*
* @param accountSchema
* @param productId
* @param isComponent
*/
private void explodeProduct(MAcctSchema accountSchema, int productId, boolean isComponent) {
MProduct product = MProduct.get(getCtx(), productId);
List<MPPProductBOM> boms = getBOMs(product, isComponent);
if (!isComponent && boms.size() == 0) {
throw new AdempiereException("@Error@ Product is not a BOM");
}
boms.stream().filter(bom -> bom != null).forEach(bom -> {
if (!isComponent)
createLines(accountSchema, bom, null);
levelNo++;
Arrays.stream(bom.getLines()).filter(bomLine -> bomLine != null && bomLine.isActive()).forEach(bomLine -> {
createLines(accountSchema, bom, bomLine);
explodeProduct(accountSchema, bomLine.getM_Product_ID(), true);
});
levelNo--;
});
}
use of org.adempiere.exceptions.AdempiereException in project adempiere by adempiere.
the class CostBillOfMaterial method createLines.
/**
* createLines
*
* @param bom
* @param bomLine
*/
private void createLines(MAcctSchema accountSchema, MPPProductBOM bom, MPPProductBOMLine bomLine) {
MProduct product;
BigDecimal qty;
if (bomLine != null) {
product = MProduct.get(getCtx(), bomLine.getM_Product_ID());
qty = bomLine.getQty();
} else if (bom != null) {
product = MProduct.get(getCtx(), bom.getM_Product_ID());
qty = Env.ONE;
} else {
throw new AdempiereException("@NotFound@ @PP_Product_BOM_ID@");
}
//for (MCostElement costElement : getCostElements())
getCostElements().stream().filter(costElement -> costElement != null).forEach(costElement -> {
X_T_BOMLine reportBOMLine = new X_T_BOMLine(getCtx(), 0, get_TrxName());
reportBOMLine.setAD_Org_ID(getOrganizationId());
reportBOMLine.setM_Warehouse_ID(getWarehouseId());
reportBOMLine.setSel_Product_ID(getProductId());
reportBOMLine.setImplosion(isImplosion);
reportBOMLine.setC_AcctSchema_ID(getAccountingSchemaId());
reportBOMLine.setM_CostType_ID(getCostTypeId());
reportBOMLine.setCostingMethod(getCostingMethod());
reportBOMLine.setAD_PInstance_ID(getAD_PInstance_ID());
reportBOMLine.setM_CostElement_ID(costElement.get_ID());
reportBOMLine.setM_Product_ID(product.get_ID());
reportBOMLine.setM_Warehouse_ID(getWarehouseId());
reportBOMLine.setQtyBOM(qty);
reportBOMLine.setSeqNo(seqNo);
reportBOMLine.setLevelNo(levelNo);
reportBOMLine.setLevels(LEVELS.substring(0, levelNo) + levelNo);
BigDecimal currentCostPrice = Env.ZERO;
BigDecimal currentCostPriceLL = Env.ZERO;
BigDecimal futureCostPrice = Env.ZERO;
BigDecimal futureCostPriceLL = Env.ZERO;
final CostEngine engine = CostEngineFactory.getCostEngine(getAD_Client_ID());
List<MCost> costs = MCost.getByElement(product, accountSchema, getCostTypeId(), getOrganizationId(), getWarehouseId(), 0, costElement.getM_CostElement_ID());
boolean isCostFrozen = false;
for (MCost cost : costs) {
currentCostPrice = currentCostPrice.add(cost.getCurrentCostPrice());
currentCostPriceLL = currentCostPriceLL.add(cost.getCurrentCostPriceLL());
futureCostPrice = futureCostPrice.add(cost.getFutureCostPrice());
futureCostPriceLL = futureCostPriceLL.add(cost.getFutureCostPriceLL());
isCostFrozen = cost.isCostFrozen();
}
reportBOMLine.setCurrentCostPrice(currentCostPrice);
reportBOMLine.setCurrentCostPriceLL(currentCostPriceLL);
reportBOMLine.setFutureCostPrice(currentCostPrice);
reportBOMLine.setFutureCostPriceLL(currentCostPriceLL);
reportBOMLine.setIsCostFrozen(isCostFrozen);
if (bomLine != null) {
reportBOMLine.setPP_Product_BOM_ID(bomLine.getPP_Product_BOM_ID());
reportBOMLine.setPP_Product_BOMLine_ID(bomLine.getPP_Product_BOMLine_ID());
} else if (bom != null) {
reportBOMLine.setPP_Product_BOM_ID(bom.getPP_Product_BOM_ID());
}
reportBOMLine.saveEx();
seqNo++;
});
}
use of org.adempiere.exceptions.AdempiereException 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);
}
Aggregations