Search in sources :

Example 1 with ProdResidualProduct

use of com.axelor.apps.production.db.ProdResidualProduct in project axelor-open-suite by axelor.

the class ManufOrderServiceImpl method createToProduceProdProductList.

@Override
public void createToProduceProdProductList(ManufOrder manufOrder) {
    BigDecimal manufOrderQty = manufOrder.getQty();
    BillOfMaterial billOfMaterial = manufOrder.getBillOfMaterial();
    BigDecimal bomQty = billOfMaterial.getQty();
    // add the produced product
    manufOrder.addToProduceProdProductListItem(new ProdProduct(manufOrder.getProduct(), manufOrderQty, billOfMaterial.getUnit()));
    // Add the residual products
    if (appProductionService.getAppProduction().getManageResidualProductOnBom() && billOfMaterial.getProdResidualProductList() != null) {
        for (ProdResidualProduct prodResidualProduct : billOfMaterial.getProdResidualProductList()) {
            Product product = productVariantService.getProductVariant(manufOrder.getProduct(), prodResidualProduct.getProduct());
            BigDecimal qty = bomQty.signum() != 0 ? prodResidualProduct.getQty().multiply(manufOrderQty).divide(bomQty, appBaseService.getNbDecimalDigitForQty(), RoundingMode.HALF_UP) : BigDecimal.ZERO;
            manufOrder.addToProduceProdProductListItem(new ProdProduct(product, qty, prodResidualProduct.getUnit()));
        }
    }
}
Also used : BillOfMaterial(com.axelor.apps.production.db.BillOfMaterial) ProdResidualProduct(com.axelor.apps.production.db.ProdResidualProduct) Product(com.axelor.apps.base.db.Product) ProdResidualProduct(com.axelor.apps.production.db.ProdResidualProduct) ProdProduct(com.axelor.apps.production.db.ProdProduct) ProdProduct(com.axelor.apps.production.db.ProdProduct) BigDecimal(java.math.BigDecimal)

Example 2 with ProdResidualProduct

use of com.axelor.apps.production.db.ProdResidualProduct in project axelor-open-suite by axelor.

the class CostSheetServiceImpl method computeResidualProduct.

protected void computeResidualProduct(BillOfMaterial billOfMaterial) throws AxelorException {
    if (this.manageResidualProductOnBom && billOfMaterial.getProdResidualProductList() != null) {
        for (ProdResidualProduct prodResidualProduct : billOfMaterial.getProdResidualProductList()) {
            CostSheetLine costSheetLine = costSheetLineService.createResidualProductCostSheetLine(prodResidualProduct.getProduct(), prodResidualProduct.getUnit(), prodResidualProduct.getQty(), billOfMaterial.getCompany());
            costSheet.addCostSheetLineListItem(costSheetLine);
        }
    }
}
Also used : ProdResidualProduct(com.axelor.apps.production.db.ProdResidualProduct) CostSheetLine(com.axelor.apps.production.db.CostSheetLine)

Aggregations

ProdResidualProduct (com.axelor.apps.production.db.ProdResidualProduct)2 Product (com.axelor.apps.base.db.Product)1 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)1 CostSheetLine (com.axelor.apps.production.db.CostSheetLine)1 ProdProduct (com.axelor.apps.production.db.ProdProduct)1 BigDecimal (java.math.BigDecimal)1