Search in sources :

Example 1 with I_PP_Order_BOMLine

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

the class GenerateInOutBound method createBasedOnDemand.

private void createBasedOnDemand(MWMInOutBound outBoundOrder, List<MPPMRP> demands) {
    demands.stream().forEach(demand -> {
        MWMInOutBoundLine outBoundOrderLine = new MWMInOutBoundLine(outBoundOrder);
        outBoundOrderLine.setLine(getLineNo(outBoundOrder));
        outBoundOrderLine.setMovementQty(demand.getQty());
        outBoundOrderLine.setDescription(demand.getDescription());
        outBoundOrderLine.setPP_MRP_ID(demand.getPP_MRP_ID());
        outBoundOrderLine.setM_Product_ID(demand.getM_Product_ID());
        if (MPPMRP.ORDERTYPE_SalesOrder.equals(demand.getOrderType())) {
            I_C_OrderLine orderLine = demand.getC_OrderLine();
            outBoundOrderLine.setC_OrderLine_ID(demand.getC_OrderLine_ID());
            outBoundOrderLine.setC_Order_ID(demand.getC_Order_ID());
            outBoundOrderLine.setC_UOM_ID(orderLine.getC_UOM_ID());
            outBoundOrderLine.setM_AttributeSetInstance_ID(orderLine.getM_AttributeSetInstance_ID());
        }
        if (MPPMRP.ORDERTYPE_DistributionOrder.equals(demand.getOrderType())) {
            I_DD_OrderLine orderLine = demand.getDD_OrderLine();
            outBoundOrderLine.setDD_Order_ID(demand.getDD_Order_ID());
            outBoundOrderLine.setDD_OrderLine_ID(demand.getDD_OrderLine_ID());
            outBoundOrderLine.setC_UOM_ID(orderLine.getC_UOM_ID());
            outBoundOrderLine.setM_AttributeSetInstance_ID(orderLine.getM_AttributeSetInstance_ID());
        }
        if (MPPMRP.ORDERTYPE_ManufacturingOrder.equals(demand.getOrderType())) {
            I_PP_Order_BOMLine orderBomLine = demand.getPP_Order_BOMLine();
            outBoundOrderLine.setPP_Order_ID(demand.getPP_Order_ID());
            outBoundOrderLine.setPP_Order_BOMLine_ID(demand.getPP_Order_BOMLine_ID());
            outBoundOrderLine.setC_UOM_ID(orderBomLine.getC_UOM_ID());
            outBoundOrderLine.setM_AttributeSetInstance_ID(orderBomLine.getM_AttributeSetInstance_ID());
        }
        outBoundOrderLine.setPickDate(outBoundOrder.getPickDate());
        outBoundOrderLine.setShipDate(outBoundOrder.getShipDate());
        outBoundOrderLine.saveEx();
    });
}
Also used : MWMInOutBoundLine(org.eevolution.model.MWMInOutBoundLine) I_C_OrderLine(org.compiere.model.I_C_OrderLine) I_DD_OrderLine(org.eevolution.model.I_DD_OrderLine) I_PP_Order_BOMLine(org.eevolution.model.I_PP_Order_BOMLine)

Example 2 with I_PP_Order_BOMLine

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

the class StandardCostingMethod method createRateVariances.

public void createRateVariances(MPPCostCollector costCollector) {
    MProduct product = null;
    if (costCollector.isCostCollectorType(MPPCostCollector.COSTCOLLECTORTYPE_ActivityControl)) {
        final I_AD_WF_Node node = costCollector.getPP_Order_Node().getAD_WF_Node();
        product = MProduct.forS_Resource_ID(costCollector.getCtx(), node.getS_Resource_ID(), null);
    } else if (costCollector.isCostCollectorType(MPPCostCollector.COSTCOLLECTORTYPE_ComponentIssue)) {
        final I_PP_Order_BOMLine bomLine = costCollector.getPP_Order_BOMLine();
        product = MProduct.get(costCollector.getCtx(), bomLine.getM_Product_ID());
    } else if (MPPCostCollector.COSTCOLLECTORTYPE_RateVariance.equals(costCollector.getCostCollectorType()))
        product = MProduct.get(costCollector.getCtx(), costCollector.getM_Product_ID());
    // Cost Collector - Rate Variance
    MPPCostCollector costCollectorRateVariance = null;
    for (MAcctSchema accountSchema : CostEngine.getAcctSchema(costCollector)) {
        for (MCostElement costElement : MCostElement.getCostElement(costCollector.getCtx(), costCollector.get_TrxName())) {
            final MCostDetail cost = MCostDetail.getCostDetail(costCollector, costElement.getM_CostElement_ID());
            if (cost == null)
                continue;
            //
            final BigDecimal quantity = cost.getQty();
            final BigDecimal priceStandard = getProductStandardCostPrice(costCollector, product, accountSchema, costElement);
            final BigDecimal priceActual = getProductActualCostPrice(costCollector, product, accountSchema, costElement, costCollector.get_TrxName());
            final BigDecimal amountStandard = CostEngine.roundCost(priceStandard.multiply(quantity), accountSchema.getC_AcctSchema_ID());
            final BigDecimal amtActual = CostEngine.roundCost(priceActual.multiply(quantity), accountSchema.getC_AcctSchema_ID());
            if (amountStandard.compareTo(amtActual) == 0)
                continue;
            //
            if (costCollectorRateVariance == null)
                costCollectorRateVariance = MPPCostCollector.createVarianceCostCollector(costCollector, MPPCostCollector.COSTCOLLECTORTYPE_RateVariance);
            List<MCostType> costTypes = MCostType.get(accountSchema.getCtx(), accountSchema.get_TrxName());
            for (MCostType costType : costTypes) {
                createVarianceCostDetail(costCollectorRateVariance, amtActual.abs(), quantity, cost, null, accountSchema, costType, costElement);
                createVarianceCostDetail(costCollectorRateVariance, amountStandard.abs(), quantity, cost, null, accountSchema, costType, costElement);
            }
        }
    }
    //
    if (costCollectorRateVariance != null) {
        boolean ok = costCollectorRateVariance.processIt(MPPCostCollector.ACTION_Complete);
        costCollectorRateVariance.saveEx();
        if (!ok)
            throw new AdempiereException(costCollectorRateVariance.getProcessMsg());
    }
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) MPPCostCollector(org.eevolution.model.MPPCostCollector) BigDecimal(java.math.BigDecimal) I_PP_Order_BOMLine(org.eevolution.model.I_PP_Order_BOMLine)

Aggregations

I_PP_Order_BOMLine (org.eevolution.model.I_PP_Order_BOMLine)2 BigDecimal (java.math.BigDecimal)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 I_C_OrderLine (org.compiere.model.I_C_OrderLine)1 I_DD_OrderLine (org.eevolution.model.I_DD_OrderLine)1 MPPCostCollector (org.eevolution.model.MPPCostCollector)1 MWMInOutBoundLine (org.eevolution.model.MWMInOutBoundLine)1