Search in sources :

Example 6 with CostSheet

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

the class CostSheetController method printCostSheetLineDetail.

public void printCostSheetLineDetail(ActionRequest request, ActionResponse response) {
    try {
        CostSheet costSheet = request.getContext().asType(CostSheet.class);
        Long costSheetId = costSheet.getId();
        String name = I18n.get("Cost sheet");
        String fileLink = ReportFactory.createReport(IReport.COST_SHEET, name + "-${date}").addParam("Locale", ReportSettings.getPrintingLocale(null)).addParam("Timezone", getTimezone(costSheet)).addParam("CostSheetId", costSheetId).addParam("manageCostSheetGroup", Beans.get(AppProductionService.class).getAppProduction().getManageCostSheetGroup()).addParam("BaseUrl", AppSettings.get().getBaseURL()).generate().getFileLink();
        response.setCanClose(true);
        response.setView(ActionView.define(name).add("html", fileLink).map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : CostSheet(com.axelor.apps.production.db.CostSheet)

Example 7 with CostSheet

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

the class CostSheetServiceImpl method computeConsumedProduct.

protected void computeConsumedProduct(int bomLevel, LocalDate previousCostSheetDate, CostSheetLine parentCostSheetLine, List<StockMoveLine> consumedStockMoveLineList, List<ProdProduct> toConsumeProdProductList, BigDecimal ratio) throws AxelorException {
    CostSheet parentCostSheet = parentCostSheetLine.getCostSheet();
    int calculationTypeSelect = parentCostSheet.getCalculationTypeSelect();
    LocalDate calculationDate = parentCostSheet.getCalculationDate();
    Map<List<Object>, BigDecimal> consumedStockMoveLinePerProductAndUnit = getTotalQtyPerProductAndUnit(consumedStockMoveLineList, calculationDate, previousCostSheetDate, calculationTypeSelect);
    for (List<Object> keys : consumedStockMoveLinePerProductAndUnit.keySet()) {
        Iterator<Object> iterator = keys.iterator();
        Product product = (Product) iterator.next();
        Unit unit = (Unit) iterator.next();
        BigDecimal realQty = consumedStockMoveLinePerProductAndUnit.get(keys);
        if (product == null) {
            continue;
        }
        BigDecimal valuationQty = BigDecimal.ZERO;
        if (calculationTypeSelect == CostSheetRepository.CALCULATION_WORK_IN_PROGRESS) {
            BigDecimal plannedConsumeQty = computeTotalQtyPerUnit(toConsumeProdProductList, product, unit);
            valuationQty = realQty.subtract(plannedConsumeQty.multiply(ratio));
        }
        valuationQty = valuationQty.setScale(appBaseService.getNbDecimalDigitForQty(), RoundingMode.HALF_UP);
        if (valuationQty.compareTo(BigDecimal.ZERO) == 0) {
            continue;
        }
        costSheetLineService.createConsumedProductCostSheetLine(parentCostSheet.getManufOrder().getCompany(), product, unit, bomLevel, parentCostSheetLine, valuationQty, CostSheetService.ORIGIN_MANUF_ORDER, null);
    }
}
Also used : ProdProduct(com.axelor.apps.production.db.ProdProduct) Product(com.axelor.apps.base.db.Product) ProdResidualProduct(com.axelor.apps.production.db.ProdResidualProduct) ArrayList(java.util.ArrayList) List(java.util.List) Unit(com.axelor.apps.base.db.Unit) LocalDate(java.time.LocalDate) CostSheet(com.axelor.apps.production.db.CostSheet) BigDecimal(java.math.BigDecimal)

Aggregations

CostSheet (com.axelor.apps.production.db.CostSheet)7 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)2 CostSheetService (com.axelor.apps.production.service.costsheet.CostSheetService)2 Transactional (com.google.inject.persist.Transactional)2 BigDecimal (java.math.BigDecimal)2 LocalDate (java.time.LocalDate)2 AppProduction (com.axelor.apps.base.db.AppProduction)1 Company (com.axelor.apps.base.db.Company)1 Product (com.axelor.apps.base.db.Product)1 Unit (com.axelor.apps.base.db.Unit)1 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 CostSheetLine (com.axelor.apps.production.db.CostSheetLine)1 ManufOrder (com.axelor.apps.production.db.ManufOrder)1 ProdProduct (com.axelor.apps.production.db.ProdProduct)1 ProdResidualProduct (com.axelor.apps.production.db.ProdResidualProduct)1 UnitCostCalcLine (com.axelor.apps.production.db.UnitCostCalcLine)1 ManufOrderRepository (com.axelor.apps.production.db.repo.ManufOrderRepository)1 AxelorException (com.axelor.exception.AxelorException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1