@Override public Map<String, BigDecimal> estimateCostCalculationForHourly(final EntityTreeNode calculationOperationComponent, final BigDecimal productionCostMargin, final BigDecimal plannedQuantity, final OperationTimesContainer realizationTimes, final boolean hourlyCostFromOperation) { checkArgument(calculationOperationComponent != null, "given operationComponent is empty"); Map<String, BigDecimal> costs = Maps.newHashMapWithExpectedSize(L_COST_KEYS.size()); MathContext mathContext = numberService.getMathContext(); for (String costKey : L_COST_KEYS) { costs.put(costKey, BigDecimal.ZERO); } for (EntityTreeNode child : calculationOperationComponent.getChildren()) { Map<String, BigDecimal> unitCosts = estimateCostCalculationForHourly(child, productionCostMargin, plannedQuantity, realizationTimes, hourlyCostFromOperation); for (String costKey : L_COST_KEYS) { BigDecimal unitCost = costs.get(costKey).add(unitCosts.get(costKey), mathContext); costs.put(costKey, numberService.setScaleWithDefaultMathContext(unitCost)); } } OperationTimes operationTimes = realizationTimes.get(calculationOperationComponent.getBelongsToField( "technologyOperationComponent").getId()); Map<String, BigDecimal> costsForSingleOperation = estimateHourlyCostCalculationForSingleOperation(operationTimes, productionCostMargin, hourlyCostFromOperation); saveGeneratedValues(costsForSingleOperation, calculationOperationComponent, true, operationTimes.getTimes(), null); costs.put(L_MACHINE_HOURLY_COST, costs.get(L_MACHINE_HOURLY_COST).add(costsForSingleOperation.get(L_OPERATION_MACHINE_COST), mathContext)); costs.put(L_LABOR_HOURLY_COST, costs.get(L_LABOR_HOURLY_COST).add(costsForSingleOperation.get(L_OPERATION_LABOR_COST), mathContext)); return costs; }