Example usage for java.math BigDecimal equals

List of usage examples for java.math BigDecimal equals

Introduction

In this page you can find the example usage for java.math BigDecimal equals.

Prototype

@Override
public boolean equals(Object x) 

Source Link

Document

Compares this BigDecimal with the specified Object for equality.

Usage

From source file:com.konakart.bl.modules.ordertotal.productdiscount.ProductDiscount.java

/**
 * Create and return an OrderTotal object for the discount amount. *
 * <p>//ww  w.j a va  2s .co  m
 * Custom field usage:
 * <p>
 * <ul>
 * <li>custom1 = Minimum Order Value</li>
 * <li>custom2 = Minimum quantity of a single product</li>
 * <li>custom3 = Discount Applied</li>
 * <li>custom4 = Percentage discount if set to true</li>
 * <li>custom5 = Discount applied to pre-tax value if set to true</li>
 * </ul>
 * If the promotion applies to multiple products, we create an array of order total objects and
 * attach the array to the order total that we return (ot.setOrderTotals(otArray)). The reason
 * for doing this is to get a line item of the order for each discounted product. We still need
 * to populate the order total that we return with the total discount amount because this will
 * be used to compare this promotion with other promotions in order to decide which one to use.
 * 
 * @param order
 * @param dispPriceWithTax
 * @param locale
 * @return Returns an OrderTotal object for this module
 * @throws Exception
 */
public OrderTotal getOrderTotal(Order order, boolean dispPriceWithTax, Locale locale) throws Exception {
    OrderTotal ot;
    StaticData sd = staticDataHM.get(getStoreId());

    // Get the resource bundle
    ResourceBundle rb = getResourceBundle(mutex, bundleName, resourceBundleMap, locale);
    if (rb == null) {
        throw new KKException("A resource file cannot be found for the country " + locale.getCountry());
    }

    // Get the promotions
    Promotion[] promArray = getPromMgr().getPromotions(code, order);

    // List to contain an order total for each promotion
    List<OrderTotal> orderTotalList = new ArrayList<OrderTotal>();

    if (promArray != null) {

        for (int i = 0; i < promArray.length; i++) {
            Promotion promotion = promArray[i];

            /*
             * Get the configuration parameters from the promotion
             */

            // Minimum value for order
            BigDecimal minTotalOrderVal = getCustomBigDecimal(promotion.getCustom1(), 1);

            // Need to order at least this quantity of a single product for promotion to apply
            int minProdQuantity = getCustomInt(promotion.getCustom2(), 2);

            // Actual discount. Could be a percentage or an amount.
            BigDecimal discountApplied = getCustomBigDecimal(promotion.getCustom3(), 3);

            // If set to true it is a percentage. Otherwise it is an amount.
            boolean percentageDiscount = getCustomBoolean(promotion.getCustom4(), 4);

            // If set to true, discount is applied to pre-tax value. Only relevant for
            // percentage discount.
            boolean applyBeforeTax = getCustomBoolean(promotion.getCustom5(), 5);

            // Don't bother going any further if there is no discount
            if (discountApplied == null || discountApplied.equals(new BigDecimal(0))) {
                continue;
            }

            // Get the order value
            BigDecimal orderValue = null;
            if (applyBeforeTax) {
                orderValue = order.getSubTotalExTax();
                log.debug("Order value before tax: " + orderValue);
            } else {
                orderValue = order.getSubTotalIncTax();
                log.debug("Order value after tax: " + orderValue);
            }

            // If promotion doesn't cover any of the products in the order then go on to the
            // next promotion
            if (promotion.getApplicableProducts() == null || promotion.getApplicableProducts().length == 0) {
                continue;
            }

            ot = new OrderTotal();
            ot.setSortOrder(sd.getSortOrder());
            ot.setClassName(code);
            ot.setPromotions(new Promotion[] { promotion });

            // Does promotion only apply to a min order value ?
            if (minTotalOrderVal != null) {
                if (orderValue.compareTo(minTotalOrderVal) < 0) {
                    // If we haven't reached the minimum amount then continue to the next
                    // promotion
                    continue;
                }
            }

            // Continue if promotion has no applicable products (should never happen)
            if (promotion.getApplicableProducts() == null) {
                continue;
            }

            /*
             * Create a new Order Total module for each discounted product and store in this
             * list
             */
            ArrayList<OrderTotal> otList = new ArrayList<OrderTotal>();

            // Loop through promotion products to determine whether to apply a discount
            boolean firstLoop = true;
            for (int j = 0; j < promotion.getApplicableProducts().length; j++) {
                OrderProductIf op = promotion.getApplicableProducts()[j];
                if (op != null && op.getQuantity() >= minProdQuantity) {
                    // Get the current total price of the product(s)
                    BigDecimal currentPrice = null;
                    if (applyBeforeTax) {
                        currentPrice = op.getFinalPriceExTax();
                    } else {
                        currentPrice = op.getFinalPriceIncTax();
                    }

                    // Apply the discount
                    BigDecimal discount = null;
                    if (percentageDiscount) {
                        // Apply a percentage discount
                        discount = (currentPrice.multiply(discountApplied)).divide(new BigDecimal(100));
                    } else {
                        // Apply an amount based discount
                        discount = discountApplied.multiply(new BigDecimal(op.getQuantity()));
                    }

                    // Determine whether it is the first discounted product or not
                    String formattedDiscount = getCurrMgr().formatPrice(discount, order.getCurrencyCode());
                    if (firstLoop) {
                        // Set the order total attributes
                        ot.setValue(discount);
                        if (percentageDiscount) {
                            try {
                                ot.setText(String.format(rb.getString(MODULE_ORDER_TOTAL_PRODUCT_DISCOUNT_TEXT),
                                        "-", formattedDiscount));
                                ot.setTitle(
                                        String.format(rb.getString(MODULE_ORDER_TOTAL_PRODUCT_DISCOUNT_TITLE),
                                                "-", discountApplied, "%", op.getName()));
                            } catch (MissingResourceException e) {
                                ot.setText("-" + formattedDiscount);
                                // Title looks like "-10% Philips TV"
                                ot.setTitle("-" + discountApplied + "% " + op.getName());
                            }

                        } else {
                            try {
                                ot.setText(String.format(rb.getString(MODULE_ORDER_TOTAL_PRODUCT_DISCOUNT_TEXT),
                                        "-", formattedDiscount));
                                ot.setTitle(
                                        String.format(rb.getString(MODULE_ORDER_TOTAL_PRODUCT_DISCOUNT_TITLE),
                                                "-", formattedDiscount, "", op.getName()));
                            } catch (MissingResourceException e) {
                                ot.setText("-" + formattedDiscount);
                                // Title looks like "-10EUR Philips TV"
                                ot.setTitle("-" + formattedDiscount + " " + op.getName());
                            }
                        }
                    } else {
                        // Set the order total attributes
                        ot.setValue(ot.getValue().add(discount));
                        ot.setText("-" + getCurrMgr().formatPrice(ot.getValue(), order.getCurrencyCode()));
                        ot.setTitle(ot.getTitle() + "," + op.getName());
                    }
                    firstLoop = false;

                    /*
                     * Create a new Order Total module for each product
                     */
                    OrderTotal singleOt = new OrderTotal();
                    singleOt.setSortOrder(sd.getSortOrder());
                    singleOt.setClassName(code);
                    singleOt.setValue(discount);
                    singleOt.setText("-" + formattedDiscount);
                    if (percentageDiscount) {
                        singleOt.setTitle("-" + discountApplied + "% " + op.getName() + ":");
                    } else {
                        singleOt.setTitle("-" + formattedDiscount + " " + op.getName() + ":");
                    }
                    otList.add(singleOt);
                }
            }

            /*
             * If we have more than one discounted product we create an array of order totals
             * (one for each product) and add the array to the order total to be returned.
             */
            if (otList.size() > 1) {
                OrderTotal[] otArray = new OrderTotal[otList.size()];
                int k = 0;
                for (Iterator<OrderTotal> iterator = otList.iterator(); iterator.hasNext();) {
                    OrderTotal lot = iterator.next();
                    otArray[k++] = lot;
                }
                ot.setOrderTotals(otArray);
            }

            if (ot.getValue() != null) {
                int scale = new Integer(order.getCurrency().getDecimalPlaces()).intValue();
                ot.setValue(ot.getValue().setScale(scale, BigDecimal.ROUND_HALF_UP));
                log.debug("Order total is :" + ot.toString());
                orderTotalList.add(ot);
            }
        }
    } else {
        // Return null if there are no promotions
        return null;
    }

    // Call a helper method to decide which OrderTotal we should return
    OrderTotal retOT = getDiscountOrderTotalFromList(order, orderTotalList);
    log.debug("Selected order total is: " + retOT);

    return retOT;

}

From source file:org.eclipse.jubula.client.archive.XmlExporter.java

/**
 * @param xmlChkConf//from w  w  w.  jav  a  2 s  .com
 *            The xml configuration where the attributes should be saved.
 * @param contexts
 *            The map where the context activation will be saved.
 */
private void fillCheckContext(CheckConfiguration xmlChkConf, Map<String, Boolean> contexts) {
    for (Entry<String, Boolean> e : contexts.entrySet()) {
        checkForCancel();
        CheckActivatedContext c = xmlChkConf.addNewActiveContext();
        c.setClass1(e.getKey());
        Object obj = e.getValue();
        if (obj instanceof BigDecimal) {
            BigDecimal bd = (BigDecimal) obj;
            c.setActive(bd.equals(BigDecimal.ONE) ? true : false);
        } else {
            c.setActive(e.getValue());
        }
    }
}

From source file:services.kpi.PortfolioEntryProgressKpi.java

@Override
public BigDecimal computeMain(IPreferenceManagerPlugin preferenceManagerPlugin, IScriptService scriptService,
        Kpi kpi, Long objectId) {
    PortfolioEntry portfolioEntry = PortfolioEntryDao.getPEById(objectId);

    BigDecimal numerator = BigDecimal.ZERO;
    BigDecimal denominator = BigDecimal.ZERO;
    BigDecimal value = new BigDecimal(100);

    for (PortfolioEntryPlanningPackage planningPackage : portfolioEntry.planningPackages) {

        BigDecimal days = PortfolioEntryResourcePlanDAO
                .getPEPlanAllocatedActorAsDaysByPlanningPackage(planningPackage)
                .add(PortfolioEntryResourcePlanDAO
                        .getPEResourcePlanAllocatedOrgUnitAsDaysByPlanningPackage(planningPackage))
                .add(PortfolioEntryResourcePlanDAO
                        .getPEResourcePlanAllocatedCompetencyAsDaysByPlanningPackage(planningPackage));

        denominator = denominator.add(days);

        switch (planningPackage.status) {
        case CLOSED:
            numerator = numerator.add(days);
            break;
        case ON_GOING:
            numerator = numerator.add(days.multiply(getOnGoingRate(preferenceManagerPlugin)));
            break;
        default:/*w  ww. jav a  2  s .c o m*/
            break;
        }

    }

    if (!denominator.equals(BigDecimal.ZERO)) {
        value = numerator.divide(denominator, RoundingMode.HALF_UP).multiply(value);
    }

    return value;
}

From source file:org.egov.works.contractorbill.service.ContractorBillRegisterService.java

public void validateRefundAmount(final ContractorBillRegister contractorBillRegister,
        final BindingResult resultBinder) {
    int index = 0;
    for (final EgBilldetails egBillDetail : contractorBillRegister.getRefundBillDetails()) {
        if (egBillDetail.getGlcodeid() != null && egBillDetail.getDebitamount() == null)
            resultBinder.rejectValue("refundBillDetails[" + index + "].debitamount",
                    "error.refundamount.required");
        if (egBillDetail.getDebitamount() != null && egBillDetail.getGlcodeid() == null)
            resultBinder.rejectValue("refundBillDetails[" + index + "].glcodeid",
                    "error.refundaccountcode.required");
        if (egBillDetail.getGlcodeid() != null && egBillDetail.getDebitamount() != null) {
            final CChartOfAccounts coa = chartOfAccountsHibernateDAO
                    .findById(egBillDetail.getGlcodeid().longValue(), false);
            final String amounts = getTotalDebitAndCreditAmountByAccountCode(
                    contractorBillRegister.getWorkOrderEstimate().getId(), new BigDecimal(coa.getId()),
                    contractorBillRegister.getId() != null ? contractorBillRegister.getId() : -1);
            if (!org.apache.commons.lang.StringUtils.isBlank(amounts)) {
                final String[] creditDebitAmounts = amounts.split(",");
                BigDecimal withheldAmount = BigDecimal.ZERO;
                BigDecimal refundedAmount = BigDecimal.ZERO;
                if (!creditDebitAmounts[0].equals("0"))
                    withheldAmount = new BigDecimal(creditDebitAmounts[0]);
                if (!creditDebitAmounts[1].equals("0"))
                    refundedAmount = new BigDecimal(creditDebitAmounts[1]);

                if (withheldAmount.equals("0"))
                    resultBinder.reject("error.contractorBill.nowithheldtorefund",
                            new String[] { coa.getGlcode() }, null);
                else {

                    final BigDecimal validRefundAmount = egBillDetail.getDebitamount().add(refundedAmount);
                    final BigDecimal diffAmount = validRefundAmount.subtract(withheldAmount);
                    if (validRefundAmount.compareTo(new BigDecimal(creditDebitAmounts[0])) == 1
                            && !contractorBillRegister.getWorkOrderEstimate().getEstimate()
                                    .getLineEstimateDetails().getLineEstimate().isSpillOverFlag())
                        resultBinder.reject("error.contractorBill.validate.refundAmount",
                                new String[] { coa.getGlcode(), diffAmount.toString() }, null);
                }/*  w w w  . j av  a  2 s .  co  m*/
            }
        }
        index++;
    }

}

From source file:org.kuali.kfs.module.bc.document.service.impl.SalarySettingServiceImpl.java

/**
 * @see org.kuali.kfs.module.bc.document.service.SalarySettingService#normalizePayRateAndAmount(org.kuali.kfs.module.bc.businessobject.PendingBudgetConstructionAppointmentFunding)
 *///from  ww w  .j  a v a2  s . co  m
public void normalizePayRateAndAmount(PendingBudgetConstructionAppointmentFunding appointmentFunding) {
    LOG.debug("normalizePayRateAndAmount() start");

    BigDecimal currentHourlyPayRate = appointmentFunding.getAppointmentRequestedPayRate();
    if (currentHourlyPayRate != null && !currentHourlyPayRate.equals(BigDecimal.ZERO)) {
        KualiInteger annualPayAmount = this.calculateAnnualPayAmount(appointmentFunding);
        appointmentFunding.setAppointmentRequestedAmount(annualPayAmount);
    } else {

        KualiInteger currentAnnualPayAmount = appointmentFunding.getAppointmentRequestedAmount();
        if (currentAnnualPayAmount != null && currentAnnualPayAmount.isNonZero()) {
            BigDecimal hourlyPayRate = this.calculateHourlyPayRate(appointmentFunding);
            appointmentFunding.setAppointmentRequestedPayRate(hourlyPayRate);
        }

        currentHourlyPayRate = appointmentFunding.getAppointmentRequestedPayRate();
        if (currentHourlyPayRate != null) {
            KualiInteger annualPayAmount = this.calculateAnnualPayAmount(appointmentFunding);
            appointmentFunding.setAppointmentRequestedAmount(annualPayAmount);
        } else {
            appointmentFunding.setAppointmentRequestedPayRate(BigDecimal.ZERO);
        }
    }
}

From source file:com.ar.dev.tierra.api.dao.impl.FiscalDAOImpl.java

@Override
public void ticket(List<DetalleFactura> detalles) {
    try (PrintWriter ticket = new PrintWriter("command/ticket.200")) {
        DecimalFormat decimalFormat = new DecimalFormat();
        decimalFormat.setMaximumFractionDigits(1);
        ticket.println("@" + (char) 28 + "T" + (char) 28 + "T");
        BigDecimal descuento = new BigDecimal(BigInteger.ZERO);
        for (DetalleFactura detalle : detalles) {
            if (detalle.getDescuentoDetalle() != null) {
                descuento = descuento.add(detalle.getDescuentoDetalle());
            }//w w  w .  j ava2  s. c o  m
            String price = null;
            BigDecimal sinIVA = detalle.getProducto().getPrecioVenta().subtract(detalle.getProducto()
                    .getPrecioVenta().multiply(new BigDecimal(17.35)).divide(new BigDecimal(100)));
            price = sinIVA.setScale(4, RoundingMode.HALF_UP).toString();
            ticket.println("B" + (char) 28 /*Abrimos linea*/
                    + detalle.getProducto().getDescripcion() + (char) 28 /*Nombre producto*/
                    + detalle.getCantidadDetalle() + ".0" + (char) 28 /*Cantidad*/
                    + price.replace(",", ".") + (char) 28 /*Precio unitario*/
                    + "21.0" + (char) 28 /*Impuestos IVA*/
                    + "M" + (char) 28 /*Suma monto*/
                    + "0.0" + (char) 28 /*Impuestos internos*/
                    + "0" + (char) 28 /*Parametro display*/
                    + "b");
            /*Cierra de linea*/
        }
        if (!descuento.equals(new BigDecimal(BigInteger.ZERO))) {
            ticket.println("T" + (char) 28 /*Abrimos linea descuento*/
                    + "Descuento: " + (char) 28 /*Texto a mostrar*/
                    + descuento + (char) 28 /*Monto descuento*/
                    + "m" + (char) 28 /*m: descuento, M: aumento*/
                    + "0" + (char) 28 /*parametro display*/
                    + "T");
            /*cierre linea descuento*/
        }
        ticket.println("E");
    } catch (FileNotFoundException ex) {
        Logger.getLogger(FiscalDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.ar.dev.tierra.api.dao.impl.FiscalDAOImpl.java

@Override
public void factura_a(List<DetalleFactura> detalles, Cliente cliente) {
    try (PrintWriter ticket = new PrintWriter("command/factura_a.200")) {
        DecimalFormat decimalFormat = new DecimalFormat();
        decimalFormat.setMaximumFractionDigits(1);
        ticket.println("b" + (char) 28 + cliente.getNombreCliente() + (char) 28 + cliente.getDocumento()
                + (char) 28 + cliente.getResponsabilidadIva() + (char) 28 + cliente.getTipoDocumento()
                + (char) 28 + cliente.getDomicilio());
        ticket.println("@" + (char) 28 + "A" + (char) 28 + "T");
        BigDecimal descuento = new BigDecimal(BigInteger.ZERO);
        for (DetalleFactura detalle : detalles) {
            if (detalle.getDescuentoDetalle() != null) {
                descuento = descuento.add(detalle.getDescuentoDetalle());
            }//w  w  w .ja  v  a 2 s. co  m
            String price = null;
            BigDecimal sinIVA = detalle.getProducto().getPrecioVenta().subtract(detalle.getProducto()
                    .getPrecioVenta().multiply(new BigDecimal(17.35)).divide(new BigDecimal(100)));
            price = sinIVA.setScale(4, RoundingMode.HALF_UP).toString();
            ticket.println("B" + (char) 28 /*Abrimos linea*/
                    + detalle.getProducto().getDescripcion() + (char) 28 /*Nombre producto*/
                    + detalle.getCantidadDetalle() + ".0" + (char) 28 /*Cantidad*/
                    + price.replace(",", ".") + (char) 28 /*Precio unitario*/
                    + "21.0" + (char) 28 /*Impuestos IVA*/
                    + "M" + (char) 28 /*Suma monto*/
                    + "0.0" + (char) 28 /*Impuestos internos*/
                    + "0" + (char) 28 /*Parametro display*/
                    + "b");
            /*Cierra de linea*/
        }
        if (!descuento.equals(new BigDecimal(BigInteger.ZERO))) {
            ticket.println("T" + (char) 28 /*Abrimos linea descuento*/
                    + "Descuento: " + (char) 28 /*Texto a mostrar*/
                    + descuento + (char) 28 /*Monto descuento*/
                    + "m" + (char) 28 /*m: descuento, M: aumento*/
                    + "0" + (char) 28 /*parametro display*/
                    + "T");
            /*cierre linea descuento*/
        }
        ticket.println("E");
    } catch (FileNotFoundException ex) {
        Logger.getLogger(FiscalDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.ar.dev.tierra.api.dao.impl.FiscalDAOImpl.java

@Override
public void factura_b(List<DetalleFactura> detalles, Cliente cliente) {
    try (PrintWriter ticket = new PrintWriter("command/factura_b.200")) {
        DecimalFormat decimalFormat = new DecimalFormat();
        decimalFormat.setMaximumFractionDigits(1);
        ticket.println("b" + (char) 28 + cliente.getNombreCliente() + (char) 28 + cliente.getDocumento()
                + (char) 28 + cliente.getResponsabilidadIva() + (char) 28 + cliente.getTipoDocumento()
                + (char) 28 + cliente.getDomicilio());
        ticket.println("@" + (char) 28 + "B" + (char) 28 + "T");
        BigDecimal descuento = new BigDecimal(BigInteger.ZERO);
        for (DetalleFactura detalle : detalles) {
            if (detalle.getDescuentoDetalle() != null) {
                descuento = descuento.add(detalle.getDescuentoDetalle());
            }//from   ww  w. j a  v a  2  s .  co  m
            String price = null;
            BigDecimal sinIVA = detalle.getProducto().getPrecioVenta().subtract(detalle.getProducto()
                    .getPrecioVenta().multiply(new BigDecimal(17.35)).divide(new BigDecimal(100)));
            price = sinIVA.setScale(4, RoundingMode.HALF_UP).toString();
            ticket.println("B" + (char) 28 /*Abrimos linea*/
                    + detalle.getProducto().getDescripcion() + (char) 28 /*Nombre producto*/
                    + detalle.getCantidadDetalle() + ".0" + (char) 28 /*Cantidad*/
                    + price.replace(",", ".") + (char) 28 /*Precio unitario*/
                    + "21.0" + (char) 28 /*Impuestos IVA*/
                    + "M" + (char) 28 /*Suma monto*/
                    + "0.0" + (char) 28 /*Impuestos internos*/
                    + "0" + (char) 28 /*Parametro display*/
                    + "b");
            /*Cierra de linea*/
        }
        if (!descuento.equals(new BigDecimal(BigInteger.ZERO))) {
            ticket.println("T" + (char) 28 /*Abrimos linea descuento*/
                    + "Descuento: " + (char) 28 /*Texto a mostrar*/
                    + descuento + (char) 28 /*Monto descuento*/
                    + "m" + (char) 28 /*m: descuento, M: aumento*/
                    + "0" + (char) 28 /*parametro display*/
                    + "T");
            /*cierre linea descuento*/
        }
        ticket.println("E");
    } catch (FileNotFoundException ex) {
        Logger.getLogger(FiscalDAOImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:nl.strohalm.cyclos.services.accounts.AccountServiceImpl.java

private AccountStatus getStatusAt(final Account account, final Calendar date,
        final boolean onlyIfThereAreDiffs) {
    // Fill the status with basic data
    AccountStatus status = new AccountStatus();
    status.setAccount(account);//from  w w  w. j a  va 2  s.c o  m
    status.setCreditLimit(account.getCreditLimit());
    status.setUpperCreditLimit(account.getUpperCreditLimit());
    status.setDate(date);

    // Get the last closed balance
    ClosedAccountBalance closedBalance = closedAccountBalanceDao.get(account, date);
    Calendar closedDate = closedBalance == null ? null : closedBalance.getDate();
    Calendar endDate = (Calendar) (date == null ? null : date.clone());
    if (endDate != null) {
        endDate.add(Calendar.SECOND, -1);
    }
    Period period = Period.between(closedDate, endDate);

    // Get the balance diff
    BigDecimal balanceDiff = transferDao.balanceDiff(account, period);
    status.setBalance(closedBalance == null ? balanceDiff : closedBalance.getBalance().add(balanceDiff));

    // Get the reserved amount diff
    BigDecimal reservationDiff = amountReservationDao.reservationDiff(account, period);
    status.setReservedAmount(
            closedBalance == null ? reservationDiff : closedBalance.getReserved().add(reservationDiff));

    if (onlyIfThereAreDiffs && balanceDiff.equals(BigDecimal.ZERO) && reservationDiff.equals(BigDecimal.ZERO)) {
        // If should return only if there are diffs, and there were none, return null
        return null;
    }

    return status;

}

From source file:controllers.core.RoadmapController.java

/**
 * Get the allocated days//  w  w w .j  a  v  a  2  s . c  o m
 * 
 * @param days
 *            the days
 * @param forecastDays
 *            forecast days
 */
private BigDecimal getAllocatedDays(BigDecimal days, BigDecimal forecastDays) {
    if (this.getBudgetTrackingService().isActive()) {
        if (forecastDays != null && !forecastDays.equals(BigDecimal.ZERO)) {
            return forecastDays;
        }
    }
    return days;
}