public Entity getTechnologyOperationComponent() { if ((getTechnologyOperationComponentId() == null) || (getTechnologyOperationComponentDD() == null)) { return null; } else { return getTechnologyOperationComponentDD().get(getTechnologyOperationComponentId()); } }
public void addMaterialOperationCost(final Entity costCalculation, final Map<Long, ComponentsCalculationHolder> basicComponentsMap, final Map<OperationProductComponentHolder, BigDecimal> materialQuantitiesByOPC) { MathContext mathContext = numberService.getMathContext(); List<CostCalculationMaterial> list = Lists.newArrayList(); Entity order = costCalculation.getBelongsToField(CostCalculationFields.ORDER); for (Map.Entry<OperationProductComponentHolder, BigDecimal> neededProductQuantity : materialQuantitiesByOPC.entrySet()) { Entity product = neededProductQuantity.getKey().getProduct(); Entity productEntity = productsCostCalculationService.getAppropriateCostNormForProduct(product, order, costCalculation.getStringField(CostCalculationFields.SOURCE_OF_MATERIAL_COSTS)); BigDecimal productQuantity = neededProductQuantity.getValue(); BigDecimal costForGivenQuantity = productsCostCalculationService.calculateProductCostForGivenQuantity(productEntity, productQuantity, costCalculation.getStringField(CostCalculationFields.CALCULATE_MATERIAL_COSTS_MODE)); if (basicComponentsMap.containsKey((neededProductQuantity.getKey().getTechnologyOperationComponentId()))) { ComponentsCalculationHolder cc = basicComponentsMap.get(neededProductQuantity.getKey() .getTechnologyOperationComponentId()); BigDecimal materialCost = BigDecimalUtils.convertNullToZero(cc.getMaterialCost()).add( BigDecimalUtils.convertNullToZero(costForGivenQuantity), mathContext); cc.setMaterialCost(numberService.setScaleWithDefaultMathContext(materialCost, 2)); } } }