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