Search in sources :

Example 71 with AdempiereException

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());
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) ArrayList(java.util.ArrayList) ProcessInfo(org.compiere.process.ProcessInfo)

Example 72 with AdempiereException

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());
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) ArrayList(java.util.ArrayList) ProcessInfo(org.compiere.process.ProcessInfo)

Example 73 with AdempiereException

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--;
    });
}
Also used : CostEngineFactory(org.adempiere.engine.CostEngineFactory) Arrays(java.util.Arrays) Env(org.compiere.util.Env) X_T_BOMLine(org.eevolution.model.X_T_BOMLine) MAcctSchema(org.compiere.model.MAcctSchema) ArrayList(java.util.ArrayList) MPPProductBOM(org.eevolution.model.MPPProductBOM) MCost(org.compiere.model.MCost) BigDecimal(java.math.BigDecimal) List(java.util.List) Query(org.compiere.model.Query) AdempiereException(org.adempiere.exceptions.AdempiereException) MCostElement(org.compiere.model.MCostElement) MProduct(org.compiere.model.MProduct) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) CostEngine(org.adempiere.engine.CostEngine) MProduct(org.compiere.model.MProduct) AdempiereException(org.adempiere.exceptions.AdempiereException) MPPProductBOM(org.eevolution.model.MPPProductBOM)

Example 74 with AdempiereException

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++;
    });
}
Also used : CostEngineFactory(org.adempiere.engine.CostEngineFactory) Arrays(java.util.Arrays) Env(org.compiere.util.Env) X_T_BOMLine(org.eevolution.model.X_T_BOMLine) MAcctSchema(org.compiere.model.MAcctSchema) ArrayList(java.util.ArrayList) MPPProductBOM(org.eevolution.model.MPPProductBOM) MCost(org.compiere.model.MCost) BigDecimal(java.math.BigDecimal) List(java.util.List) Query(org.compiere.model.Query) AdempiereException(org.adempiere.exceptions.AdempiereException) MCostElement(org.compiere.model.MCostElement) MProduct(org.compiere.model.MProduct) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) CostEngine(org.adempiere.engine.CostEngine) MProduct(org.compiere.model.MProduct) CostEngine(org.adempiere.engine.CostEngine) AdempiereException(org.adempiere.exceptions.AdempiereException) MCost(org.compiere.model.MCost) BigDecimal(java.math.BigDecimal) X_T_BOMLine(org.eevolution.model.X_T_BOMLine)

Example 75 with AdempiereException

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);
}
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

AdempiereException (org.adempiere.exceptions.AdempiereException)326 BigDecimal (java.math.BigDecimal)79 SQLException (java.sql.SQLException)46 ArrayList (java.util.ArrayList)36 ResultSet (java.sql.ResultSet)33 PreparedStatement (java.sql.PreparedStatement)31 Timestamp (java.sql.Timestamp)31 MProduct (org.compiere.model.MProduct)28 List (java.util.List)25 Query (org.compiere.model.Query)20 File (java.io.File)17 Properties (java.util.Properties)16 PO (org.compiere.model.PO)16 Env (org.compiere.util.Env)15 MBPartner (org.compiere.model.MBPartner)14 ImmutableList (com.google.common.collect.ImmutableList)12 I_M_HU (de.metas.handlingunits.model.I_M_HU)12 FillMandatoryException (org.adempiere.exceptions.FillMandatoryException)12 ProcessInfo (org.compiere.process.ProcessInfo)12 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)11