private void initAdditionalCosts() { this.additionalCosts = this.additionalCostService.getAdditionalCostsByTransportId(this.transport.getId()); for (AdditionalCost additionalCost : additionalCosts) { BigDecimal price = additionalCost.getPrice(); if (price != null) { this.additionalCostsPrice += additionalCost.getPrice().intValue(); } } }
public void addAdditionalCost() { newAdditionalCost.setTransport(transport); boolean added = this.additionalCostService.updateAdditionalCost(newAdditionalCost); FacesMessage message; String messageString; if (added) { this.additionalCosts.add(0, newAdditionalCost); newAdditionalCost = new AdditionalCost(); messageString = resourceBundleBean.get(ResourceBundleBean.SUCCESS_ADDITIONAL_COST_ADDED); message = new FacesMessage(FacesMessage.SEVERITY_INFO, messageString, ""); } else { messageString = resourceBundleBean.get(ResourceBundleBean.ERROR_ADDITIONAL_COST_ADD); message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageString, ""); } FacesContext.getCurrentInstance().addMessage(null, message); }