Search in sources :

Example 6 with CostSheetLine

use of com.axelor.apps.production.db.CostSheetLine 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)

Example 7 with CostSheetLine

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

the class CostSheetServiceImpl method computeRealResidualProduct.

protected void computeRealResidualProduct(ManufOrder manufOrder) throws AxelorException {
    for (StockMoveLine stockMoveLine : manufOrder.getProducedStockMoveLineList()) {
        if (stockMoveLine.getProduct() != null && manufOrder.getProduct() != null && (!stockMoveLine.getProduct().equals(manufOrder.getProduct()))) {
            CostSheetLine costSheetLine = costSheetLineService.createResidualProductCostSheetLine(stockMoveLine.getProduct(), stockMoveLine.getUnit(), stockMoveLine.getRealQty(), manufOrder.getCompany());
            costSheet.addCostSheetLineListItem(costSheetLine);
        }
    }
}
Also used : CostSheetLine(com.axelor.apps.production.db.CostSheetLine) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine)

Example 8 with CostSheetLine

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

the class CostSheetServiceImpl method _computeToConsumeProduct.

protected void _computeToConsumeProduct(Company company, BillOfMaterial billOfMaterial, int bomLevel, CostSheetLine parentCostSheetLine, int origin, UnitCostCalculation unitCostCalculation) throws AxelorException {
    if (billOfMaterial.getBillOfMaterialSet() != null) {
        for (BillOfMaterial billOfMaterialLine : billOfMaterial.getBillOfMaterialSet()) {
            Product product = billOfMaterialLine.getProduct();
            if (product != null) {
                CostSheetLine costSheetLine = costSheetLineService.createConsumedProductCostSheetLine(company, product, billOfMaterialLine.getUnit(), bomLevel, parentCostSheetLine, billOfMaterialLine.getQty(), origin, unitCostCalculation);
                BigDecimal wasteRate = billOfMaterialLine.getWasteRate();
                if (wasteRate != null && wasteRate.compareTo(BigDecimal.ZERO) > 0) {
                    costSheetLineService.createConsumedProductWasteCostSheetLine(company, product, billOfMaterialLine.getUnit(), bomLevel, parentCostSheetLine, billOfMaterialLine.getQty(), wasteRate, origin, unitCostCalculation);
                }
                if (billOfMaterialLine.getDefineSubBillOfMaterial()) {
                    this._computeCostPrice(company, billOfMaterialLine, bomLevel, costSheetLine, origin, unitCostCalculation);
                }
            }
        }
    }
}
Also used : BillOfMaterial(com.axelor.apps.production.db.BillOfMaterial) CostSheetLine(com.axelor.apps.production.db.CostSheetLine) ProdProduct(com.axelor.apps.production.db.ProdProduct) Product(com.axelor.apps.base.db.Product) ProdResidualProduct(com.axelor.apps.production.db.ProdResidualProduct) BigDecimal(java.math.BigDecimal)

Example 9 with CostSheetLine

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

the class CostSheetLineServiceImpl method createIndirectCostSheetLine.

protected CostSheetLine createIndirectCostSheetLine(CostSheetLine parentCostSheetLine, CostSheetGroup costSheetGroup, BigDecimal costPrice) {
    CostSheetLine indirectCostSheetLine = this.getCostSheetLine(costSheetGroup, parentCostSheetLine);
    if (indirectCostSheetLine == null) {
        indirectCostSheetLine = this.createCostSheetLine(costSheetGroup.getCode(), costSheetGroup.getName(), parentCostSheetLine.getBomLevel() + 1, BigDecimal.ONE, null, costSheetGroup, null, CostSheetLineRepository.TYPE_INDIRECT_COST, CostSheetLineRepository.TYPE_INDIRECT_COST, null, null, parentCostSheetLine);
        parentCostSheetLine.addCostSheetLineListItem(indirectCostSheetLine);
    }
    indirectCostSheetLine.setCostPrice(indirectCostSheetLine.getCostPrice().add(this.getIndirectCostPrice(costSheetGroup, costPrice)));
    return indirectCostSheetLine;
}
Also used : CostSheetLine(com.axelor.apps.production.db.CostSheetLine)

Example 10 with CostSheetLine

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

the class CostSheetServiceImpl method computeCostPrice.

protected BigDecimal computeCostPrice(CostSheetLine parentCostSheetLine) {
    BigDecimal costPrice = BigDecimal.ZERO;
    if (parentCostSheetLine.getCostSheetLineList() != null) {
        for (CostSheetLine costSheetLine : parentCostSheetLine.getCostSheetLineList()) {
            if (costSheetLine.getCostSheetLineList() != null && !costSheetLine.getCostSheetLineList().isEmpty()) {
                costPrice = costPrice.add(this.computeCostPrice(costSheetLine));
            } else {
                costPrice = costPrice.add(costSheetLine.getCostPrice());
            }
        }
    }
    parentCostSheetLine.setCostPrice(costPrice);
    return costPrice;
}
Also used : CostSheetLine(com.axelor.apps.production.db.CostSheetLine) BigDecimal(java.math.BigDecimal)

Aggregations

CostSheetLine (com.axelor.apps.production.db.CostSheetLine)10 BigDecimal (java.math.BigDecimal)5 Company (com.axelor.apps.base.db.Company)2 Product (com.axelor.apps.base.db.Product)2 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)2 ProdResidualProduct (com.axelor.apps.production.db.ProdResidualProduct)2 Transactional (com.google.inject.persist.Transactional)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 CostSheet (com.axelor.apps.production.db.CostSheet)1 ProdProduct (com.axelor.apps.production.db.ProdProduct)1 UnitCostCalcLine (com.axelor.apps.production.db.UnitCostCalcLine)1 ManufOrderRepository (com.axelor.apps.production.db.repo.ManufOrderRepository)1 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)1 LocalDate (java.time.LocalDate)1