Example usage for java.math RoundingMode HALF_UP

List of usage examples for java.math RoundingMode HALF_UP

Introduction

In this page you can find the example usage for java.math RoundingMode HALF_UP.

Prototype

RoundingMode HALF_UP

To view the source code for java.math RoundingMode HALF_UP.

Click Source Link

Document

Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.

Usage

From source file:sv.com.mined.sieni.controller.GestionNotasController.java

public synchronized void guardarNotasExcel() {
    try {// w  w w .jav a 2 s .c om
        boolean error = false;
        List<SieniNota> notas = new ArrayList<>();
        FormatUtils fu = new FormatUtils();
        Date fechaActual = new Date();
        if (this.getEvaluacionSubir() != null && this.getEvaluacionSubir().getIdEvaluacion() != null) {
            HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
                    .getRequest();
            LoginController loginBean = (LoginController) req.getSession().getAttribute("loginController");
            for (SieniNota actual : this.getListaNotasSubidas()) {
                actual.setIdEvaluacion(this.getEvaluacionSubir());
                actual.setNtEstado('A');
                actual.setNtFechaIngreso(fechaActual);
                actual.setNtTipoIngreso("E");
                actual.setNtDocente(loginBean.getDocente().getIdDocente());
                actual.setNtAnio(fu.getFormatedAnioInt(new Date()));
                BigDecimal nota = new BigDecimal(actual.getNtCalificacion());
                actual.setNtCalificacion(nota.setScale(2, RoundingMode.HALF_UP).doubleValue());
                notas.add(actual);
                if (actual.getErrores() != null && !actual.getErrores().isEmpty()) {
                    error = true;
                    break;
                }
            }
            if (!error) {
                for (int i = 0; i < notas.size(); i++) {
                    notas.get(i).setErrores(new ArrayList<String>());
                    if (sieniNotaFacadeRemote.findNotaRegistrada(notas.get(i))) {
                        notas.get(i).getErrores()
                                .add("La nota de la evaluacin para ese alumno ya esta definida");
                        error = true;
                        List<ValidationPojo> errores = new ArrayList<>();
                        errores.add(new ValidationPojo(error,
                                "Debe corregir los errores del archivo excel antes de guardar",
                                FacesMessage.SEVERITY_ERROR));
                        ValidationPojo.printErrores(errores);
                    }
                }
                if (!error) {
                    sieniNotaFacadeRemote.merge(notas);
                    registrarEnBitacora("Crear", "Nota - excel", this.getEvaluacionSubir().getIdEvaluacion());
                    new ValidationPojo().printMsj("Notas creadas Exitosamente", FacesMessage.SEVERITY_INFO);
                }
            } else {
                List<ValidationPojo> errores = new ArrayList<>();
                errores.add(new ValidationPojo(error,
                        "Debe corregir los errores del archivo excel antes de guardar",
                        FacesMessage.SEVERITY_ERROR));
                ValidationPojo.printErrores(errores);
            }
        } else {
            List<ValidationPojo> errores = new ArrayList<>();
            errores.add(new ValidationPojo(true, "La materia no tiene evaluaciones disponibles",
                    FacesMessage.SEVERITY_ERROR));
            ValidationPojo.printErrores(errores);
        }
    } catch (Exception e) {
        new ValidationPojo().printMsj("Ocurri un error:" + e, FacesMessage.SEVERITY_ERROR);
        System.out.println(e.getMessage());
    }
}

From source file:org.kuali.coeus.common.budget.impl.calculator.BudgetPeriodCalculator.java

public boolean syncToPeriodDirectCostLimit(Budget budget, BudgetPeriod budgetPeriodBean,
        BudgetLineItem budgetDetailBean) {
    // If total_cost equals total_cost_limit, disp msg "Cost limit and total cost for this period is already in sync."
    ScaleTwoDecimal directCostLimit = budgetPeriodBean.getDirectCostLimit();
    ScaleTwoDecimal periodDirectTotal = budgetPeriodBean.getTotalDirectCost();
    directCostLimit = budgetPeriodBean.getDirectCostLimit();

    // Set the Difference as TotalCostLimit minus TotalCost.
    BigDecimal difference = directCostLimit.subtract(periodDirectTotal).bigDecimalValue();
    ScaleTwoDecimal lineItemCost = budgetDetailBean.getLineItemCost();
    BigDecimal multifactor;/*from w w  w .ja  va2s  . c  o m*/

    // If line_item_cost is 0 then set the value of line_item_cost in line_items to 10000.
    if (lineItemCost.equals(ScaleTwoDecimal.ZERO)) {
        budgetDetailBean.setLineItemCost(new ScaleTwoDecimal(10000));
    }

    calculate(budget, budgetPeriodBean);

    QueryList<BudgetLineItemCalculatedAmount> vecCalAmts = new QueryList<BudgetLineItemCalculatedAmount>(
            budgetDetailBean.getBudgetLineItemCalculatedAmounts());

    resetRateClassTypeIfNeeded(vecCalAmts);

    ScaleTwoDecimal totalNOHCalcAmount = vecCalAmts.sumObjects("calculatedCost",
            new NotEquals("rateClassType", RateClassType.OVERHEAD.getRateClassType()));
    BigDecimal totalCost = budgetDetailBean.getLineItemCost().add(totalNOHCalcAmount).bigDecimalValue();
    // If the lineItemCost <> 0, set multifactor to TotalCost divided by lineItemCost otherwise multifactor is TotalCost divided
    // by 10000
    if (!lineItemCost.equals(ScaleTwoDecimal.ZERO)) {
        multifactor = totalCost.divide(lineItemCost.bigDecimalValue(), RoundingMode.HALF_UP);
    } else {
        multifactor = totalCost.divide(new ScaleTwoDecimal(10000).bigDecimalValue(), RoundingMode.HALF_UP);
        budgetDetailBean.setLineItemCost(ScaleTwoDecimal.ZERO);
        calculate(budget, budgetPeriodBean);
        totalCost = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    }

    if (isProposalBudget(budget)
            && new ScaleTwoDecimal(totalCost.add(difference)).isLessEqual(ScaleTwoDecimal.ZERO)) {
        return false;
    }

    // Set New Cost
    ScaleTwoDecimal newCost = lineItemCost
            .add(new ScaleTwoDecimal(difference.divide(multifactor, RoundingMode.HALF_UP)));
    budgetDetailBean.setLineItemCost(newCost);
    calculate(budget, budgetPeriodBean);
    return true;

}

From source file:mx.edu.um.mateo.inventario.dao.impl.EntradaDaoHibernate.java

private BigDecimal costoPromedio(LoteEntrada lote) {
    Producto producto = lote.getProducto();

    BigDecimal cantidad = lote.getCantidad();
    BigDecimal viejoBalance = producto.getPrecioUnitario().multiply(producto.getExistencia());
    BigDecimal nuevoBalance = lote.getPrecioUnitario().multiply(cantidad);

    BigDecimal balanceTotal = viejoBalance.add(nuevoBalance);
    BigDecimal articulos = cantidad.add(producto.getExistencia());
    return balanceTotal.divide(articulos, 10, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_UP);
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.SF424AV1_0Generator.java

/**
 * /*w w  w. j  ava2 s .  c  o m*/
 * This method gives the information of BudgetForecastedCashNeeds which consists of budgetFirstYearAmounts,
 * budgetFirstQuarterAmounts budgetSecondQuarterAmounts, budgetThirdQuarterAmounts, budgetFourthQuarterAmounts
 * 
 * @return budgetForecastedCashNeeds budget calculated for every quarter.
 */
private BudgetForecastedCashNeeds getBudgetForecastedCashNeeds() {
    ScaleTwoDecimal totalFedCost = ScaleTwoDecimal.ZERO;
    ScaleTwoDecimal costSharing = ScaleTwoDecimal.ZERO;
    BigDecimal totalEstimation = ScaleTwoDecimal.ZERO.bigDecimalValue();
    BigDecimal costShareEstimation = ScaleTwoDecimal.ZERO.bigDecimalValue();
    BigDecimal totalFedEstimation = ScaleTwoDecimal.ZERO.bigDecimalValue();
    BudgetForecastedCashNeeds budgetForecastedCashNeeds = BudgetForecastedCashNeeds.Factory.newInstance();
    if (budget != null) {
        BudgetFirstYearAmounts budgetFirstYearAmounts = BudgetFirstYearAmounts.Factory.newInstance();
        BudgetFirstQuarterAmounts budgetFirstQuarterAmounts = BudgetFirstQuarterAmounts.Factory.newInstance();
        BudgetSecondQuarterAmounts budgetSecondQuarterAmounts = BudgetSecondQuarterAmounts.Factory
                .newInstance();
        BudgetThirdQuarterAmounts budgetThirdQuarterAmounts = BudgetThirdQuarterAmounts.Factory.newInstance();
        BudgetFourthQuarterAmounts budgetFourthQuarterAmounts = BudgetFourthQuarterAmounts.Factory
                .newInstance();
        for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) {
            for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
                if (budget.getSubmitCostSharingFlag() && lineItem.getSubmitCostSharingFlag()) {
                    if (budgetPeriod.getBudgetPeriod() == BudgetPeriodNum.P1.getNum()) {
                        costSharing = costSharing.add(lineItem.getCostSharingAmount());
                        for (BudgetLineItemCalculatedAmountContract budgetLineItemCalculatedAmount : lineItem
                                .getBudgetLineItemCalculatedAmounts()) {
                            costSharing = costSharing
                                    .add(budgetLineItemCalculatedAmount.getCalculatedCostSharing());
                        }
                    }
                }
            }
            if (budgetPeriod.getBudgetPeriod() == BudgetPeriodNum.P1.getNum()) {
                totalFedCost = budgetPeriod.getTotalCost();
                totalFedEstimation = totalFedCost.bigDecimalValue()
                        .divide(new ScaleTwoDecimal(4).bigDecimalValue(), RoundingMode.HALF_UP);
                costShareEstimation = costSharing.bigDecimalValue()
                        .divide(new ScaleTwoDecimal(4).bigDecimalValue(), RoundingMode.HALF_UP);
                totalEstimation = totalFedEstimation.add(costShareEstimation);
            }
        }

        budgetFirstYearAmounts.setBudgetFederalForecastedAmount(totalFedCost.bigDecimalValue());
        budgetFirstYearAmounts.setBudgetNonFederalForecastedAmount(costSharing.bigDecimalValue());
        budgetFirstYearAmounts.setBudgetTotalForecastedAmount(costSharing.add(totalFedCost).bigDecimalValue());

        budgetForecastedCashNeeds.setBudgetFirstYearAmounts(budgetFirstYearAmounts);

        budgetFirstQuarterAmounts.setBudgetFederalForecastedAmount(totalFedEstimation);
        budgetFirstQuarterAmounts.setBudgetNonFederalForecastedAmount(costShareEstimation);
        budgetFirstQuarterAmounts.setBudgetTotalForecastedAmount(totalEstimation);

        budgetForecastedCashNeeds.setBudgetFirstQuarterAmounts(budgetFirstQuarterAmounts);

        budgetSecondQuarterAmounts.setBudgetFederalForecastedAmount(totalFedEstimation);
        budgetSecondQuarterAmounts.setBudgetNonFederalForecastedAmount(costShareEstimation);
        budgetSecondQuarterAmounts.setBudgetTotalForecastedAmount(totalEstimation);

        budgetForecastedCashNeeds.setBudgetSecondQuarterAmounts(budgetSecondQuarterAmounts);

        budgetThirdQuarterAmounts.setBudgetFederalForecastedAmount(totalFedEstimation);
        budgetThirdQuarterAmounts.setBudgetNonFederalForecastedAmount(costShareEstimation);
        budgetThirdQuarterAmounts.setBudgetTotalForecastedAmount(totalEstimation);

        budgetForecastedCashNeeds.setBudgetThirdQuarterAmounts(budgetThirdQuarterAmounts);

        budgetFourthQuarterAmounts.setBudgetFederalForecastedAmount(totalFedEstimation);
        budgetFourthQuarterAmounts.setBudgetNonFederalForecastedAmount(costShareEstimation);
        budgetFourthQuarterAmounts.setBudgetTotalForecastedAmount(totalEstimation);

        budgetForecastedCashNeeds.setBudgetFourthQuarterAmounts(budgetFourthQuarterAmounts);
    }
    return budgetForecastedCashNeeds;
}

From source file:org.yes.cart.service.payment.impl.PaymentProcessorImpl.java

/**
 * Calculate delivery amount according to shipment sla cost and items in particular delivery.
 *
 * @param order    order/*w ww  .  j a  va 2s .  c  o  m*/
 * @param delivery delivery
 * @param payment  payment
 */
private void fillPaymentAmount(final CustomerOrder order, final CustomerOrderDelivery delivery,
        final Payment payment) {
    BigDecimal rez = BigDecimal.ZERO.setScale(Constants.DEFAULT_SCALE);
    for (PaymentLine paymentLine : payment.getOrderItems()) {
        if (paymentLine.isShipment()) {
            // shipping price already includes shipping level promotions
            rez = rez.add(paymentLine.getUnitPrice()).setScale(Constants.DEFAULT_SCALE,
                    BigDecimal.ROUND_HALF_UP);
        } else {
            // unit price already includes item level promotions
            rez = rez.add(paymentLine.getQuantity().multiply(paymentLine.getUnitPrice())
                    .setScale(Constants.DEFAULT_SCALE, BigDecimal.ROUND_HALF_UP));
        }
    }
    if (order.isPromoApplied()) {
        // work out the percentage of order level promotion per delivery

        // work out the real sub total using item promotional prices
        // DO NOT use the order.getListPrice() as this is the list price in catalog and we calculate
        // promotions against sale price
        BigDecimal orderTotalList = BigDecimal.ZERO;
        for (final CustomerOrderDet detail : order.getOrderDetail()) {
            orderTotalList = orderTotalList.add(detail.getQty().multiply(detail.getGrossPrice())
                    .setScale(Constants.DEFAULT_SCALE, BigDecimal.ROUND_HALF_UP));
        }

        final BigDecimal orderTotal = order.getGrossPrice();
        // take the list price (sub total of items using list price)
        final BigDecimal discount = orderTotalList.subtract(orderTotal).divide(orderTotalList, 10,
                RoundingMode.HALF_UP);
        // scale delivery items total in accordance with order level discount percentage
        rez = rez.multiply(BigDecimal.ONE.subtract(discount)).setScale(Constants.DEFAULT_SCALE,
                BigDecimal.ROUND_HALF_UP);
    }
    payment.setPaymentAmount(rez);
    payment.setOrderCurrency(order.getCurrency());
    payment.setOrderLocale(order.getLocale());
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.directiveCouncil.SummariesControlAction.java

private BigDecimal getDifference(BigDecimal lessonHours, BigDecimal summaryHours) {
    Double difference;//from w  w  w.  ja  v  a  2  s  .  co m
    difference = (1 - ((lessonHours.doubleValue() - summaryHours.doubleValue()) / lessonHours.doubleValue()))
            * 100;
    if (difference.isNaN() || difference.isInfinite()) {
        difference = 0.0;
    }
    return BigDecimal.valueOf(difference).setScale(2, RoundingMode.HALF_UP);
}

From source file:com.wineaccess.winerypermit.WineryPermitHelper.java

/**
 * @param startDate//from   w  w w  .j  av a2 s . c o m
 * @param endDate
 * @return
 */
public static final Integer getMonthsDifference(Date startDate, Date endDate) {

    Calendar startCalendar = new GregorianCalendar();
    startCalendar.setTime(startDate);
    Calendar endCalendar = new GregorianCalendar();
    endCalendar.setTime(endDate);

    int diffYear = endCalendar.get(Calendar.YEAR) - startCalendar.get(Calendar.YEAR);
    BigDecimal temp = new BigDecimal(endCalendar.get(Calendar.MONTH) - startCalendar.get(Calendar.MONTH));
    temp = temp.divide(new BigDecimal(12), 2, RoundingMode.HALF_UP);
    int monthDiff = diffYear + temp.setScale(0, RoundingMode.HALF_UP).intValue();

    return monthDiff * 12;
}

From source file:com.xumpy.thuisadmin.services.implementations.BedragenSrvImpl.java

@Override
public Map<Integer, BigDecimal> findMainBedragen(List<? extends Bedragen> bedragen, String Month) {
    SimpleDateFormat dt = new SimpleDateFormat("MM/yyyy");
    Map<GroepenSrvPojo, BigDecimal> mainBedragenPerGroup = new HashMap<GroepenSrvPojo, BigDecimal>();

    for (Bedragen bedrag : bedragen) {
        if (dt.format(bedrag.getDatum()).equals(Month)) {
            GroepenSrvPojo mainGroup = new GroepenSrvPojo(GroepenSrvImpl.getHoofdGroep(bedrag.getGroep()));
            if (mainBedragenPerGroup.containsKey(mainGroup)) {
                BigDecimal ammount = mainBedragenPerGroup.get(mainGroup);
                if (bedrag.getGroep().getNegatief().equals(1)) {
                    ammount = ammount.add(bedrag.getBedrag());
                } else {
                    ammount = ammount.subtract(bedrag.getBedrag());
                }/*from   ww  w  .jav a2  s . co  m*/
                mainBedragenPerGroup.put(mainGroup, ammount);
            } else {
                if (bedrag.getGroep().getNegatief().equals(1)) {
                    mainBedragenPerGroup.put(mainGroup, bedrag.getBedrag());
                } else {
                    mainBedragenPerGroup.put(mainGroup, bedrag.getBedrag().multiply(new BigDecimal(-1)));
                }
            }
        }
    }

    BigDecimal average = new BigDecimal(0);
    for (Map.Entry bedrag : mainBedragenPerGroup.entrySet()) {
        average = average.add((BigDecimal) bedrag.getValue());
    }
    average = average.divide(new BigDecimal(mainBedragenPerGroup.size()), 2, RoundingMode.HALF_UP);

    Map<Integer, BigDecimal> result = new HashMap<Integer, BigDecimal>();

    result.put(0, average);

    for (Map.Entry bedrag : mainBedragenPerGroup.entrySet()) {
        result.put(((GroepenSrvPojo) bedrag.getKey()).getPk_id(), (BigDecimal) bedrag.getValue());
    }

    return result;
}

From source file:org.kuali.coeus.propdev.impl.print.NIHResearchAndRelatedXmlStream.java

private ProposalPersonType getProposalPersonTypeWithValues(DevelopmentProposal developmentProposal,
        ProposalPerson proposalPerson, Budget budget) {
    ProposalPersonType proposalPersonType = ProposalPersonType.Factory.newInstance();
    String degree = getDegree(proposalPerson);
    proposalPersonType.setDegree(degree);
    proposalPersonType.setGraduationYear(getGraduationYear(proposalPerson));
    proposalPersonType.setEmail(proposalPerson.getEmailAddress());
    proposalPersonType.setName(getProposalPersonFullNameType(proposalPerson));
    proposalPersonType.setPhone(proposalPerson.getPhoneNumber());
    if (PROJECT_ROLE_PI.equals(proposalPerson.getProposalPersonRoleId())) {
        proposalPersonType.setProjectRole(ProjectRoleType.PI_PD);
    } else if (PROJECT_ROLE_COI.equals(proposalPerson.getProposalPersonRoleId())) {
        proposalPersonType.setProjectRole(ProjectRoleType.CO_PI_PD);
    } else {//ww  w  .  j  av  a  2  s .  com
        proposalPersonType.setProjectRole(ProjectRoleType.KEY_PERSON);
    }

    proposalPersonType.setSSN(proposalPerson.getSocialSecurityNumber());
    if (proposalPerson.getDateOfBirth() != null) {
        proposalPersonType.setDOB(getDateTimeService().toDateString(proposalPerson.getDateOfBirth()));
    }

    BigDecimal calendarMonths = ScaleTwoDecimal.ZERO.bigDecimalValue();
    BigDecimal academicMonths = ScaleTwoDecimal.ZERO.bigDecimalValue();
    BigDecimal summerMonths = ScaleTwoDecimal.ZERO.bigDecimalValue();
    if (budget != null)
        for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) {
            if (budgetPeriod.getBudgetPeriod().intValue() == 1) {
                for (BudgetLineItem lineItem : budgetPeriod.getBudgetLineItems()) {
                    for (BudgetPersonnelDetails budgetPersonnelDetails : lineItem
                            .getBudgetPersonnelDetailsList()) {
                        if ((proposalPerson.getPersonId() != null
                                && proposalPerson.getPersonId().equals(budgetPersonnelDetails.getPersonId()))
                                || (proposalPerson.getRolodexId() != null && proposalPerson.getRolodexId()
                                        .toString().equals(budgetPersonnelDetails.getPersonId()))) {
                            proposalPersonType.setPercentEffort(
                                    budgetPersonnelDetails.getPercentEffort().bigDecimalValue());
                            proposalPersonType.setRequestedCost(
                                    budgetPersonnelDetails.getSalaryRequested().bigDecimalValue());
                            if (ACADEMIC_PERIOD.equals(budgetPersonnelDetails.getPeriodTypeCode())) {
                                academicMonths = academicMonths.add(budgetPersonnelDetails.getPercentEffort()
                                        .bigDecimalValue().multiply(POINT_ZERO_ONE)
                                        .multiply(getNumberOfMonths(budgetPersonnelDetails.getStartDate(),
                                                budgetPersonnelDetails.getEndDate()).bigDecimalValue()));
                            } else if (CALENDAR_PERIOD.equals(budgetPersonnelDetails.getPeriodTypeCode())) {
                                calendarMonths = calendarMonths.add(budgetPersonnelDetails.getPercentEffort()
                                        .bigDecimalValue().multiply(POINT_ZERO_ONE)
                                        .multiply(getNumberOfMonths(budgetPersonnelDetails.getStartDate(),
                                                budgetPersonnelDetails.getEndDate()).bigDecimalValue()));
                            } else
                                summerMonths = summerMonths.add(budgetPersonnelDetails.getPercentEffort()
                                        .bigDecimalValue().multiply(POINT_ZERO_ONE)
                                        .multiply(getNumberOfMonths(budgetPersonnelDetails.getStartDate(),
                                                budgetPersonnelDetails.getEndDate()).bigDecimalValue()));
                        }
                    }
                }
            }
        }
    proposalPersonType.setAcademicFundingMonths(academicMonths.setScale(2, RoundingMode.HALF_UP));
    proposalPersonType.setSummerFundingMonths(summerMonths.setScale(2, RoundingMode.HALF_UP));
    proposalPersonType.setFundingMonths(calendarMonths.setScale(2, RoundingMode.HALF_UP));
    return proposalPersonType;
}

From source file:org.openbravo.costing.CostingRuleProcess.java

private void updateInventoriesCostAndProcessInitInventories(String ruleId, Date startingDate,
        boolean existsPreviousRule) {
    CostingRule rule = OBDal.getInstance().get(CostingRule.class, ruleId);
    for (CostingRuleInit cri : rule.getCostingRuleInitList()) {
        for (InventoryCountLine icl : cri.getCloseInventory().getMaterialMgmtInventoryCountLineList()) {
            MaterialTransaction trx = getInventoryLineTransaction(icl);
            // Remove 1 second from transaction date to ensure that cost is calculated with previous
            // costing rule.
            trx.setTransactionProcessDate(DateUtils.addSeconds(startingDate, -1));
            BigDecimal trxCost = BigDecimal.ZERO;
            BigDecimal cost = null;
            Currency cur = FinancialUtils.getLegalEntityCurrency(trx.getOrganization());
            if (existsPreviousRule) {
                trxCost = CostingUtils.getTransactionCost(trx, startingDate, true, cur);
                if (trx.getMovementQuantity().compareTo(BigDecimal.ZERO) != 0) {
                    cost = trxCost.divide(trx.getMovementQuantity().abs(), cur.getCostingPrecision().intValue(),
                            RoundingMode.HALF_UP);
                }//from   w  w  w .  j a va 2 s .  c  o m
            } else {
                // Insert transaction cost record big ZERO cost.
                cur = trx.getClient().getCurrency();
                TransactionCost transactionCost = OBProvider.getInstance().get(TransactionCost.class);
                transactionCost.setInventoryTransaction(trx);
                transactionCost.setCostDate(trx.getTransactionProcessDate());
                transactionCost.setClient(trx.getClient());
                transactionCost.setOrganization(trx.getOrganization());
                transactionCost.setCost(BigDecimal.ZERO);
                transactionCost.setCurrency(trx.getClient().getCurrency());
                transactionCost.setAccountingDate(trx.getGoodsShipmentLine() != null
                        ? trx.getGoodsShipmentLine().getShipmentReceipt().getAccountingDate()
                        : trx.getMovementDate());
                List<TransactionCost> trxCosts = trx.getTransactionCostList();
                trxCosts.add(transactionCost);
                trx.setTransactionCostList(trxCosts);
                OBDal.getInstance().save(trx);
            }

            trx.setCostCalculated(true);
            trx.setCostingStatus("CC");
            trx.setCurrency(cur);
            trx.setTransactionCost(trxCost);
            OBDal.getInstance().save(trx);
            InventoryCountLine initICL = getInitIcl(cri.getInitInventory(), icl);
            initICL.setCost(cost);
            OBDal.getInstance().save(initICL);
        }
        OBDal.getInstance().flush();
        new InventoryCountProcess().processInventory(cri.getInitInventory(), false);
    }
    if (!existsPreviousRule) {
        updateInitInventoriesTrxDate(startingDate, ruleId);
    }
}