private Map<String, BigDecimal> estimatePieceworkCostCalculationForSingleOperation( final EntityTreeNode calculationOperationComponent, final BigDecimal productionCostMargin, final BigDecimal operationRuns) { Map<String, BigDecimal> costs = Maps.newHashMap(); BigDecimal pieceworkCost = BigDecimalUtils.convertNullToZero(calculationOperationComponent .getDecimalField(CalculationOperationComponentFields.PIECEWORK_COST)); BigDecimal numberOfOperations = BigDecimalUtils.convertNullToOne(calculationOperationComponent .getField(CalculationOperationComponentFields.NUMBER_OF_OPERATIONS)); BigDecimal pieceworkCostPerOperation = pieceworkCost.divide(numberOfOperations, numberService.getMathContext()); BigDecimal operationCost = operationRuns.multiply(pieceworkCostPerOperation, numberService.getMathContext()); BigDecimal operationMarginCost = operationCost.multiply(productionCostMargin.divide(BigDecimal.valueOf(100), numberService.getMathContext())); BigDecimal totalOperationCost = numberService.setScaleWithDefaultMathContext(operationCost.add(operationMarginCost, numberService.getMathContext())); costs.put(L_OPERATION_COST, numberService.setScaleWithDefaultMathContext(operationCost)); costs.put(L_OPERATION_MARGIN_COST, numberService.setScaleWithDefaultMathContext(operationMarginCost)); costs.put(L_PIECES, numberService.setScaleWithDefaultMathContext(operationRuns)); costs.put(L_TOTAL_OPERATION_COST, totalOperationCost); return costs; }