Example usage for java.math BigDecimal setScale

List of usage examples for java.math BigDecimal setScale

Introduction

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

Prototype

@Deprecated(since = "9")
public BigDecimal setScale(int newScale, int roundingMode) 

Source Link

Document

Returns a BigDecimal whose scale is the specified value, and whose unscaled value is determined by multiplying or dividing this BigDecimal 's unscaled value by the appropriate power of ten to maintain its overall value.

Usage

From source file:org.efaps.esjp.accounting.transaction.FieldValue_Base.java

/**
 * Add the information about the costs of the positions.
 *
 * @param _parameter        Parameter as passed from the eFaps API
 * @param _date             Date the cost will be search for
 * @param _doc              Instance of the Document the form was opened for
 * @return html snipplet//www .  ja  va2s . c  om
 * @throws EFapsException on error
 */
protected StringBuilder getCostInformation(final Parameter _parameter, final DateTime _date,
        final DocumentInfo _doc) throws EFapsException {
    final StringBuilder html = new StringBuilder();
    if (_doc.isStockDoc()) {
        boolean costValidated = true;
        final Map<?, ?> props = (Map<?, ?>) _parameter.get(ParameterValues.PROPERTIES);
        final boolean script = !"true".equalsIgnoreCase((String) props.get("noScript"));
        final Instance periodInst = new Period().evaluateCurrentPeriod(_parameter);
        final RateInfo rate = evaluateRate(_parameter, periodInst, _date == null ? new DateTime() : _date,
                null);
        _doc.setRateInfo(rate);

        html.append("<table>");
        final QueryBuilder queryBldr = new QueryBuilder(CISales.PositionAbstract);
        queryBldr.addWhereAttrEqValue(CISales.PositionAbstract.DocumentAbstractLink,
                _doc.getInstance().getId());
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CISales.PositionAbstract.Quantity, CISales.PositionAbstract.UoM);
        final SelectBuilder sel = new SelectBuilder().linkto(CISales.PositionAbstract.Product);
        final SelectBuilder oidSel = new SelectBuilder(sel).oid();
        final SelectBuilder nameSel = new SelectBuilder(sel).attribute(CIProducts.ProductAbstract.Name);
        final SelectBuilder descSel = new SelectBuilder(sel).attribute(CIProducts.ProductAbstract.Description);
        multi.addSelect(oidSel, nameSel, descSel);
        multi.execute();
        boolean first = true;
        BigDecimal total = BigDecimal.ZERO;
        while (multi.next()) {
            final Instance prodInst = Instance.get(multi.<String>getSelect(oidSel));
            if (first) {
                first = false;
                html.append("<tr>").append("<th>")
                        .append(getLabel(multi.getCurrentInstance(), CISales.PositionAbstract.Quantity))
                        .append("</th>").append("<th>")
                        .append(getLabel(multi.getCurrentInstance(), CISales.PositionAbstract.UoM))
                        .append("</th>").append("<th>")
                        .append(getLabel(prodInst, CIProducts.ProductAbstract.Name)).append("</th>")
                        .append("<th>").append(getLabel(prodInst, CIProducts.ProductAbstract.Description))
                        .append("</th>").append("<th>")
                        .append(DBProperties.getProperty(CIProducts.ProductCost.getType().getName()
                                + "/" + CIProducts.ProductCost.Price.name + ".Label"))
                        .append("</th>").append("<th>")
                        .append(DBProperties.getProperty(CIProducts.ProductCost.getType().getName() + "/"
                                + CIProducts.ProductCost.CurrencyLink.name + ".Label"))
                        .append("</th>").append("<tr>");
            }
            html.append("<tr>");

            final BigDecimal quantity = multi.<BigDecimal>getAttribute(CISales.PositionAbstract.Quantity);
            final UoM uom = Dimension.getUoM(multi.<Long>getAttribute(CISales.PositionAbstract.UoM));
            html.append("<td>").append(quantity).append("</td>").append("<td>").append(uom.getName())
                    .append("</td>").append("<td>").append(multi.<String>getSelect(nameSel)).append("</td>")
                    .append("<td>").append(multi.<String>getSelect(descSel)).append("</td>");

            final QueryBuilder costQueryBuilder = new QueryBuilder(CIProducts.ProductCost);
            costQueryBuilder.addWhereAttrEqValue(CIProducts.ProductCost.ProductLink, prodInst.getId());
            costQueryBuilder.addWhereAttrLessValue(CIProducts.ProductCost.ValidFrom,
                    _date == null ? new DateTime() : _date.plusMinutes(1));
            costQueryBuilder.addWhereAttrGreaterValue(CIProducts.ProductCost.ValidUntil,
                    _date == null ? new DateTime() : _date.minusMinutes(1));
            costQueryBuilder.addOrderByAttributeDesc(CIProducts.ProductCost.ID);
            final InstanceQuery query = costQueryBuilder.getQuery();
            query.setLimit(1);
            query.executeWithoutAccessCheck();
            if (query.next()) {
                final PrintQuery print = new PrintQuery(query.getCurrentValue());
                print.addAttribute(CIProducts.ProductCost.Price);
                final SelectBuilder currSel = new SelectBuilder().linkto(CIProducts.ProductCost.CurrencyLink)
                        .instance();
                print.addSelect(currSel);
                print.executeWithoutAccessCheck();
                final BigDecimal price = print.<BigDecimal>getAttribute(CIProducts.ProductCost.Price);
                final Instance currInst = print.<Instance>getSelect(currSel);

                final RateInfo rateTmp = evaluateRate(_parameter, periodInst,
                        _date == null ? new DateTime() : _date, currInst);

                final BigDecimal cost = quantity.multiply(new BigDecimal(uom.getNumerator()))
                        .divide(new BigDecimal(uom.getDenominator())).multiply(price);
                html.append("<td>").append(NumberFormatter.get().getTwoDigitsFormatter().format(price))
                        .append("</td>").append("<td>").append(rateTmp.getCurrencyInstObj().getSymbol())
                        .append("</td>");

                if (script) {
                    analyzeProduct(_doc, true, prodInst, cost, rate,
                            CIAccounting.AccountBalanceSheetAsset2ProductClass,
                            CIAccounting.AccountBalanceSheetAsset);
                    analyzeProduct(_doc, false, prodInst, cost, rate,
                            CIAccounting.AccountIncomeStatementExpenses2ProductClass,
                            CIAccounting.AccountIncomeStatementExpenses);
                }
                total = total.add(cost.setScale(12, BigDecimal.ROUND_HALF_UP).divide(rateTmp.getRate(),
                        BigDecimal.ROUND_HALF_UP));
            } else {
                html.append("<td></td>").append("<td></td>");
                if (costValidated) {
                    costValidated = false;
                }
            }
            html.append("</tr>");
        }
        html.append("<tr>").append("<td colspan=4></td><td>")
                .append(NumberFormatter.get().getTwoDigitsFormatter().format(total))
                .append("<input type=\"hidden\" name=\"amountExternal\" value=\"").append(total).append("\"/>")
                .append("</td>").append("<td>").append(rate.getCurrencyInstObj().getSymbol())
                .append("<input type=\"hidden\" name=\"currencyExternal\" value=\"")
                .append(rate.getCurrencyInstance().getId()).append("\"/>").append("</td>").append("<tr>")
                .append("</table>");
        _doc.setCostValidated(costValidated);
        _doc.setAmount(total);
    }
    return html;
}

From source file:org.kuali.ole.module.purap.document.service.impl.PaymentRequestServiceImpl.java

/**
 * Calculates the discount item for this paymentRequest.
 *
 * @param paymentRequestDocument The payment request document whose discount to be calculated.
 *///from w  ww  .ja  v a2s.  c o  m
protected void calculateDiscount(PaymentRequestDocument paymentRequestDocument) {
    PaymentRequestItem discountItem = findDiscountItem(paymentRequestDocument);
    // find out if we really need the discount item
    PaymentTermType pt = paymentRequestDocument.getVendorPaymentTerms();
    if ((pt != null) && (pt.getVendorPaymentTermsPercent() != null)
            && (BigDecimal.ZERO.compareTo(pt.getVendorPaymentTermsPercent()) != 0)) {
        if (discountItem == null) {
            // set discountItem and add to items
            // this is probably not the best way of doing it but should work for now if we start excluding discount from below
            // we will need to manually add
            purapService.addBelowLineItems(paymentRequestDocument);

            // fix up below the line items
            removeIneligibleAdditionalCharges(paymentRequestDocument);

            discountItem = findDiscountItem(paymentRequestDocument);
        }

        // Deleted the discountItem.getExtendedPrice() null and isZero
        PaymentRequestItem fullOrderItem = findFullOrderDiscountItem(paymentRequestDocument);
        KualiDecimal fullOrderAmount = KualiDecimal.ZERO;
        KualiDecimal fullOrderTaxAmount = KualiDecimal.ZERO;

        if (fullOrderItem != null) {
            fullOrderAmount = (ObjectUtils.isNotNull(fullOrderItem.getExtendedPrice()))
                    ? fullOrderItem.getExtendedPrice()
                    : KualiDecimal.ZERO;
            fullOrderTaxAmount = (ObjectUtils.isNotNull(fullOrderItem.getItemTaxAmount()))
                    ? fullOrderItem.getItemTaxAmount()
                    : KualiDecimal.ZERO;
        }
        KualiDecimal totalCost = paymentRequestDocument.getTotalPreTaxDollarAmountAboveLineItems()
                .add(fullOrderAmount);
        PurApItem tradeInItem = paymentRequestDocument.getTradeInItem();
        if (ObjectUtils.isNotNull(tradeInItem)) {
            totalCost = totalCost.subtract(tradeInItem.getTotalAmount());
        }
        BigDecimal discountAmount = pt.getVendorPaymentTermsPercent().multiply(totalCost.bigDecimalValue())
                .multiply(new BigDecimal(PurapConstants.PREQ_DISCOUNT_MULT));

        // do we really need to set both, not positive, but probably won't hurt
        discountItem.setItemUnitPrice(discountAmount.setScale(2, KualiDecimal.ROUND_BEHAVIOR));
        discountItem.setExtendedPrice(new KualiDecimal(discountAmount));

        // set tax amount
        boolean salesTaxInd = parameterService.getParameterValueAsBoolean(
                OleParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_SALES_TAX_IND);
        boolean useTaxIndicator = paymentRequestDocument.isUseTaxIndicator();

        if (salesTaxInd == true && useTaxIndicator == false) {
            KualiDecimal totalTax = paymentRequestDocument.getTotalTaxAmountAboveLineItems()
                    .add(fullOrderTaxAmount);
            BigDecimal discountTaxAmount = null;
            if (totalCost.isNonZero()) {
                discountTaxAmount = discountAmount.divide(totalCost.bigDecimalValue())
                        .multiply(totalTax.bigDecimalValue());
            } else {
                discountTaxAmount = BigDecimal.ZERO;
            }

            discountItem.setItemTaxAmount(new KualiDecimal(
                    discountTaxAmount.setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR)));
        }

        // set document
        discountItem.setPurapDocument(paymentRequestDocument);
    } else { // no discount
        if (discountItem != null) {
            paymentRequestDocument.getItems().remove(discountItem);
        }
    }

}

From source file:org.kuali.ole.module.purap.document.service.impl.InvoiceServiceImpl.java

/**
 * Calculates the discount item for this invoice.
 *
 * @param invoiceDocument The payment request document whose discount to be calculated.
 *///from   w w  w . ja v a 2s  . c  o m
protected void calculateDiscount(InvoiceDocument invoiceDocument) {
    InvoiceItem discountItem = findDiscountItem(invoiceDocument);
    // find out if we really need the discount item
    PaymentTermType pt = invoiceDocument.getVendorPaymentTerms();
    if ((pt != null) && (pt.getVendorPaymentTermsPercent() != null)
            && (BigDecimal.ZERO.compareTo(pt.getVendorPaymentTermsPercent()) != 0)) {
        if (discountItem == null) {
            // set discountItem and add to items
            // this is probably not the best way of doing it but should work for now if we start excluding discount from below
            // we will need to manually add
            purapService.addBelowLineItems(invoiceDocument);

            // fix up below the line items
            removeIneligibleAdditionalCharges(invoiceDocument);

            discountItem = findDiscountItem(invoiceDocument);
        }

        // Deleted the discountItem.getExtendedPrice() null and isZero
        InvoiceItem fullOrderItem = findFullOrderDiscountItem(invoiceDocument);
        KualiDecimal fullOrderAmount = KualiDecimal.ZERO;
        KualiDecimal fullOrderTaxAmount = KualiDecimal.ZERO;

        if (fullOrderItem != null) {
            fullOrderAmount = (ObjectUtils.isNotNull(fullOrderItem.getExtendedPrice()))
                    ? fullOrderItem.getExtendedPrice()
                    : KualiDecimal.ZERO;
            fullOrderTaxAmount = (ObjectUtils.isNotNull(fullOrderItem.getItemTaxAmount()))
                    ? fullOrderItem.getItemTaxAmount()
                    : KualiDecimal.ZERO;
        }
        KualiDecimal totalCost = invoiceDocument.getTotalPreTaxDollarAmountAboveLineItems()
                .add(fullOrderAmount);
        PurApItem tradeInItem = invoiceDocument.getTradeInItem();
        if (ObjectUtils.isNotNull(tradeInItem)) {
            totalCost = totalCost.subtract(tradeInItem.getTotalAmount());
        }
        BigDecimal discountAmount = pt.getVendorPaymentTermsPercent().multiply(totalCost.bigDecimalValue())
                .multiply(new BigDecimal(PurapConstants.PRQS_DISCOUNT_MULT));

        // do we really need to set both, not positive, but probably won't hurt
        discountItem.setItemUnitPrice(discountAmount.setScale(4, KualiDecimal.ROUND_BEHAVIOR));
        discountItem.setExtendedPrice(new KualiDecimal(discountAmount));

        // set tax amount
        boolean salesTaxInd = parameterService.getParameterValueAsBoolean(
                OleParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_SALES_TAX_IND);
        boolean useTaxIndicator = invoiceDocument.isUseTaxIndicator();

        if (salesTaxInd == true && useTaxIndicator == false) {
            KualiDecimal totalTax = invoiceDocument.getTotalTaxAmountAboveLineItems().add(fullOrderTaxAmount);
            BigDecimal discountTaxAmount = null;
            if (totalCost.isNonZero()) {
                discountTaxAmount = discountAmount.divide(totalCost.bigDecimalValue())
                        .multiply(totalTax.bigDecimalValue());
            } else {
                discountTaxAmount = BigDecimal.ZERO;
            }

            discountItem.setItemTaxAmount(new KualiDecimal(
                    discountTaxAmount.setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR)));
        }

        // set document
        discountItem.setPurapDocument(invoiceDocument);
    } else { // no discount
        if (discountItem != null) {
            invoiceDocument.getItems().remove(discountItem);
        }
    }

}

From source file:com.dp2345.Setting.java

/**
 * /*  w w w.  ja v  a2s .  c  o  m*/
 * 
 * @param amount
 *            
 * @return 
 */
public BigDecimal setScale(BigDecimal amount) {
    if (amount == null) {
        return null;
    }
    int roundingMode;
    if (getPriceRoundType() == RoundType.roundUp) {
        roundingMode = BigDecimal.ROUND_UP;
    } else if (getPriceRoundType() == RoundType.roundDown) {
        roundingMode = BigDecimal.ROUND_DOWN;
    } else {
        roundingMode = BigDecimal.ROUND_HALF_UP;
    }
    return amount.setScale(getPriceScale(), roundingMode);
}

From source file:net.cbtltd.rest.AbstractReservation.java

private static Double round(double unrounded, int precision, int roundingMode) {
    BigDecimal bd = new BigDecimal(unrounded);
    BigDecimal rounded = bd.setScale(precision, roundingMode);
    return rounded.doubleValue();
}

From source file:org.kuali.kfs.module.purap.document.service.impl.PaymentRequestServiceImpl.java

/**
 * Calculates the discount item for this paymentRequest.
 *
 * @param paymentRequestDocument The payment request document whose discount to be calculated.
 *///from   ww  w .  j  a  v  a 2 s. c  o  m
protected void calculateDiscount(PaymentRequestDocument paymentRequestDocument) {
    PaymentRequestItem discountItem = findDiscountItem(paymentRequestDocument);
    // find out if we really need the discount item
    PaymentTermType pt = paymentRequestDocument.getVendorPaymentTerms();
    if ((pt != null) && (pt.getVendorPaymentTermsPercent() != null)
            && (BigDecimal.ZERO.compareTo(pt.getVendorPaymentTermsPercent()) != 0)) {
        if (discountItem == null) {
            // set discountItem and add to items
            // this is probably not the best way of doing it but should work for now if we start excluding discount from below
            // we will need to manually add
            purapService.addBelowLineItems(paymentRequestDocument);

            // fix up below the line items
            removeIneligibleAdditionalCharges(paymentRequestDocument);

            discountItem = findDiscountItem(paymentRequestDocument);
        }

        // Deleted the discountItem.getExtendedPrice() null and isZero
        PaymentRequestItem fullOrderItem = findFullOrderDiscountItem(paymentRequestDocument);
        KualiDecimal fullOrderAmount = KualiDecimal.ZERO;
        KualiDecimal fullOrderTaxAmount = KualiDecimal.ZERO;

        if (fullOrderItem != null) {
            fullOrderAmount = (ObjectUtils.isNotNull(fullOrderItem.getExtendedPrice()))
                    ? fullOrderItem.getExtendedPrice()
                    : KualiDecimal.ZERO;
            fullOrderTaxAmount = (ObjectUtils.isNotNull(fullOrderItem.getItemTaxAmount()))
                    ? fullOrderItem.getItemTaxAmount()
                    : KualiDecimal.ZERO;
        }
        KualiDecimal totalCost = paymentRequestDocument.getTotalPreTaxDollarAmountAboveLineItems()
                .add(fullOrderAmount);
        PurApItem tradeInItem = paymentRequestDocument.getTradeInItem();
        if (ObjectUtils.isNotNull(tradeInItem)) {
            totalCost = totalCost.add(tradeInItem.getTotalAmount());
        }
        BigDecimal discountAmount = pt.getVendorPaymentTermsPercent().multiply(totalCost.bigDecimalValue())
                .multiply(new BigDecimal(PurapConstants.PREQ_DISCOUNT_MULT));

        // do we really need to set both, not positive, but probably won't hurt
        discountItem.setItemUnitPrice(discountAmount.setScale(2, KualiDecimal.ROUND_BEHAVIOR));
        discountItem.setExtendedPrice(new KualiDecimal(discountAmount));

        // set tax amount
        boolean salesTaxInd = parameterService.getParameterValueAsBoolean(
                KfsParameterConstants.PURCHASING_DOCUMENT.class, PurapParameterConstants.ENABLE_SALES_TAX_IND);
        boolean useTaxIndicator = paymentRequestDocument.isUseTaxIndicator();

        if (salesTaxInd == true && useTaxIndicator == false) {
            KualiDecimal totalTax = paymentRequestDocument.getTotalTaxAmountAboveLineItems()
                    .add(fullOrderTaxAmount);
            BigDecimal discountTaxAmount = null;
            if (totalCost.isNonZero()) {
                discountTaxAmount = discountAmount.divide(totalCost.bigDecimalValue())
                        .multiply(totalTax.bigDecimalValue());
            } else {
                discountTaxAmount = BigDecimal.ZERO;
            }

            discountItem.setItemTaxAmount(new KualiDecimal(
                    discountTaxAmount.setScale(KualiDecimal.SCALE, KualiDecimal.ROUND_BEHAVIOR)));
        }

        // set document
        discountItem.setPurapDocument(paymentRequestDocument);
    } else { // no discount
        if (discountItem != null) {
            paymentRequestDocument.getItems().remove(discountItem);
        }
    }

}

From source file:com.icebreak.p2p.trade.impl.TradeServiceImpl.java

public CalculateLoanCostResult getInterestByRole(List<DivsionRuleRole> list,
        CalculateLoanCostOrder loanCostOrder) {
    CalculateLoanCostResult loanCostResult = new CalculateLoanCostResult();
    double loanInterest = 0;
    double investorInterest = 0;
    String[] roleName = new String[list.size()];
    double[] divisionRule = new double[list.size()];
    int i = 0;/*from   w  ww.j  a v  a2  s  .  c o m*/
    for (DivsionRuleRole d : list) {
        BigDecimal bg = new BigDecimal(d.getRule() * 100);
        loanInterest += bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        if (SysUserRoleEnum.INVESTOR.getValue() == d.getRoleId()) {
            investorInterest += bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        }
        Role role = roleDao.getByRoleId(d.getRoleId());
        roleName[i] = role.getName();
        divisionRule[i] = d.getRule();
        i++;
    }
    if (sysFunctionConfigService.isTradeFeeCharge()) {
        if (loanCostOrder.getLoanAmount() != null && loanCostOrder.getLoanAmount().greaterThan(Money.zero())
                && loanCostOrder.getTimeLimitUnit() != null && loanCostOrder.getTimeLimit() > 0) {
            Money tradeChargeAmount = loanCostOrder.getLoanAmount().multiply(new BigDecimal(0.002));
            BigDecimal rate = new BigDecimal(0);
            if (loanCostOrder.getTimeLimitUnit() == LoanPeriodUnitEnum.LOAN_BY_DAY) {
                rate = tradeChargeAmount.multiply(new BigDecimal(360)).getAmount()
                        .divide(new BigDecimal(loanCostOrder.getTimeLimit()), BigDecimal.ROUND_HALF_UP)
                        .divide(loanCostOrder.getLoanAmount().getAmount(), 3, BigDecimal.ROUND_HALF_UP);
            } else if (loanCostOrder.getTimeLimitUnit() == LoanPeriodUnitEnum.LOAN_BY_YEAR) {
                rate = tradeChargeAmount.getAmount()
                        .divide(new BigDecimal(loanCostOrder.getTimeLimit()), BigDecimal.ROUND_HALF_UP)
                        .divide(loanCostOrder.getLoanAmount().getAmount(), 3, BigDecimal.ROUND_HALF_UP);
            } else {
                rate = tradeChargeAmount.multiply(new BigDecimal(12)).getAmount()
                        .divide(new BigDecimal(loanCostOrder.getTimeLimit()), BigDecimal.ROUND_HALF_UP)
                        .divide(loanCostOrder.getLoanAmount().getAmount(), 3, BigDecimal.ROUND_HALF_UP);
            }
            loanCostResult.setTradeChargeAmount(tradeChargeAmount);
            loanCostResult.setTradeChargeRate(rate.doubleValue() * 100);
        }
    }
    loanCostResult.setDivisionRule(divisionRule);
    loanCostResult.setRoleName(roleName);
    loanCostResult.setSuccess(true);
    loanCostResult.setLoanInterest(loanInterest);
    loanCostResult.setInvestorInterest(investorInterest);
    return loanCostResult;
}

From source file:org.hyperic.hq.measurement.server.session.DataManagerImpl.java

/**
 * Convert a decimal value to something suitable for being thrown into the
 * database with a NUMERIC(24,5) definition
 *///from   w  w w .  ja  v  a 2  s .  co m
private BigDecimal getDecimalInRange(BigDecimal val, Integer metricId) {
    val = val.setScale(5, BigDecimal.ROUND_HALF_EVEN);
    if (val.compareTo(MAX_DB_NUMBER) == 1) {
        log.warn("Value [" + val + "] for metric id=" + metricId
                + "is too big to put into the DB.  Truncating to [" + MAX_DB_NUMBER + "]");
        return MAX_DB_NUMBER;
    }

    return val;
}

From source file:com.icebreak.p2p.trade.impl.TradeServiceImpl.java

private double getDaysRuleRate(double rule, Trade trade) {
    String timeLimitUnit = trade.getTimeLimitUnit();
    double timeLimit = trade.getTimeLimit();
    double days = 0;
    if (LoanLimitUnitEnum.LOAN_BY_DAY.code().equals(timeLimitUnit)) {
        days = timeLimit;//from w w  w  .ja va 2s .  co  m
    } else if (LoanLimitUnitEnum.LOAN_BY_YEAR.code().equals(timeLimitUnit)) {
        days = timeLimit * YrdConstants.TimeRelativeConstants.DAYSOFAYEAR;
    } else {
        days = Math.round(timeLimit * YrdConstants.TimeRelativeConstants.DAYSOFAYEAR / 12);
    }
    BigDecimal bg = new BigDecimal(rule / YrdConstants.TimeRelativeConstants.DAYSOFAYEAR * days);
    double daysRate = bg.setScale(10, BigDecimal.ROUND_HALF_UP).doubleValue();
    return daysRate;
}

From source file:org.kuali.kra.award.printing.xmlstream.AwardBaseStream.java

private BigDecimal getPercentageEffort(AwardPerson awardPerson) {
    BigDecimal percentageEffort = null;
    if (awardPerson.getTotalEffort() != null) {
        BigDecimal bdecAmount = new BigDecimal(awardPerson.getTotalEffort().doubleValue());
        percentageEffort = bdecAmount.setScale(2, BigDecimal.ROUND_HALF_DOWN);
    }/*from w w  w  .jav  a 2s. c  o  m*/
    return percentageEffort;
}