Example usage for java.math BigDecimal ZERO

List of usage examples for java.math BigDecimal ZERO

Introduction

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

Prototype

BigDecimal ZERO

To view the source code for java.math BigDecimal ZERO.

Click Source Link

Document

The value 0, with a scale of 0.

Usage

From source file:com.opensourcestrategies.financials.accounts.GLAccountInTree.java

/**
 * Gets the credit of this GL account children GL accounts.
 * @return a <code>BigDecimal</code> value
 *//*from   w w w  . j  a  v  a  2 s .  c o  m*/
public BigDecimal getCreditOfChildren() {
    BigDecimal creditOfChildren = BigDecimal.ZERO;
    for (GLAccountInTree childAccount : childAccounts) {
        creditOfChildren = creditOfChildren.add(getCreditOfChildrenRec(childAccount));
    }
    return creditOfChildren.setScale(AccountsHelper.decimals, AccountsHelper.rounding);
}

From source file:net.sourceforge.fenixedu.domain.Guide.java

public void updateTotalValue() {

    BigDecimal total = BigDecimal.ZERO;

    for (final GuideEntry guideEntry : getGuideEntriesSet()) {
        total = total//from  ww w  .  j ava  2 s . c  om
                .add(guideEntry.getPriceBigDecimal().multiply(BigDecimal.valueOf(guideEntry.getQuantity())));
    }

    total.setScale(2, RoundingMode.HALF_EVEN);

    setTotalBigDecimal(total);

}

From source file:alfio.controller.form.ReservationForm.java

private int additionalServicesSelectionCount(AdditionalServiceRepository additionalServiceRepository,
        int eventId) {
    return (int) selectedAdditionalServices().stream()
            .filter(as -> as.getAdditionalServiceId() != null
                    && (additionalServiceRepository.getById(as.getAdditionalServiceId(), eventId).isFixPrice()
                            || Optional.ofNullable(as.getAmount()).filter(a -> a.compareTo(BigDecimal.ZERO) > 0)
                                    .isPresent()))
            .count();/*from ww w . j a  v  a2s.co  m*/
}

From source file:com.aoindustries.website.clientarea.accounting.MakePaymentNewCardForm.java

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = super.validate(mapping, request);
    if (errors == null)
        errors = new ActionErrors();
    if (GenericValidator.isBlankOrNull(paymentAmount)) {
        errors.add("paymentAmount", new ActionMessage("makePaymentStoredCardForm.paymentAmount.required"));
    } else {/*from w  ww  .j a va  2  s .  c o  m*/
        try {
            // Make sure can parse as int-of-pennies format (Once we no longer use int-of-pennies, this should be removed)
            // Long-term plan is to use BigDecimal exclusively for all monetary values. - DRA 2007-10-09
            int pennies = SQLUtility.getPennies(this.paymentAmount);
            // Make sure can parse as BigDecimal, and is correct value
            BigDecimal pa = new BigDecimal(this.paymentAmount);
            if (pa.compareTo(BigDecimal.ZERO) <= 0) {
                errors.add("paymentAmount",
                        new ActionMessage("makePaymentStoredCardForm.paymentAmount.mustBeGeaterThanZero"));
            } else if (pa.scale() > 2) {
                // Must not have more than 2 decimal places
                errors.add("paymentAmount",
                        new ActionMessage("makePaymentStoredCardForm.paymentAmount.invalid"));
            }
        } catch (NumberFormatException err) {
            errors.add("paymentAmount", new ActionMessage("makePaymentStoredCardForm.paymentAmount.invalid"));
        }
    }
    return errors;
}

From source file:org.openvpms.archetype.rules.finance.till.TillRulesTestCase.java

/**
 * Tests the {@link TillRules#clearTill)} method, with a zero cash float.
 * This should not create an <em>act.tillBalanceAdjustment</e>.
 *//*from w ww  .j  av  a2s  .  co m*/
@Test
public void testClearTillWithNoAdjustment() {
    final BigDecimal cashFloat = BigDecimal.ZERO;
    checkClearTillForUnclearedBalance(cashFloat, cashFloat);
}

From source file:BlogRocksteady2.bean.EditPerfilBean.java

public String cargarPerfil() {
    BigDecimal user = (BigDecimal) FacesContext.getCurrentInstance().getExternalContext().getSessionMap()
            .get("user");

    if (user.compareTo(BigDecimal.ZERO) >= 1) {
        usuario = usuarioFacade.findById(user);

        setEmail(usuario.getEmail());/*from www  .  j a v  a 2  s  . com*/
        setFacebook(usuario.getFacebook());
        setTwitter(usuario.getTwitter());
        setWebsite(usuario.getWebsite());
        setDescription(usuario.getDescription());
        setLinkedin(usuario.getLinkedin());
        setInstagram(usuario.getInstagram());
        return "editProfile.xhtml";
    } else {
        return "index.xhtml";
    }
}

From source file:com.roncoo.pay.account.service.impl.RpAccountQueryServiceImpl.java

/**
 * ?????//  w ww  .  j a  v a2s . c o  m
 * 
 * @param userNO
 *            ?
 * @return
 */
public RpAccount getAccountByUserNo(String userNo) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("userNo", userNo);
    LOG.info("???");
    RpAccount account = this.rpAccountDao.getBy(map);
    if (account == null) {
        throw AccountBizException.ACCOUNT_NOT_EXIT;
    }
    // ??0
    if (!DateUtils.isSameDayWithToday(account.getEditTime())) {
        account.setTodayExpend(BigDecimal.ZERO);
        account.setTodayIncome(BigDecimal.ZERO);
        account.setEditTime(new Date());
        rpAccountDao.update(account);
    }
    return account;
}

From source file:com.qcadoo.model.internal.types.DecimalTypeTest.java

@Test
public final void shouldFormatDecimalTrimTrailingZeroes2() {
    // given/*from  w ww .  j  a va 2s. com*/
    BigDecimal value = BigDecimal.ZERO.setScale(10);

    // when
    String result = decimalType.toString(value, locale);

    // then
    assertEquals("0", result);
}

From source file:br.com.gerenciapessoal.repository.Lancamentos.java

private static Map<Date, BigDecimal> criarMapaVazio(Integer numeroDeDias, Calendar dataInicial) {

    dataInicial = (Calendar) dataInicial.clone();

    Map<Date, BigDecimal> mapaInicial = new TreeMap<>();

    for (int i = 0; i < numeroDeDias; i++) {
        mapaInicial.put(dataInicial.getTime(), BigDecimal.ZERO);
        dataInicial.add(Calendar.DAY_OF_MONTH, 1);
    }//from  www  .  j  a  va2s.c o m

    return mapaInicial;
}

From source file:coffeshop.PaymentPage.java

public PaymentPage(MainPage mmain, int currentOrder, String mtransType, ResultSet memp, List<Button> mproducts,
        String mpromoCode, BigDecimal msubtotal, BigDecimal mpromo, BigDecimal mtax, BigDecimal mtotal) {
    initComponents();/*from   www .j  a  v a2  s .c o m*/
    main = mmain;
    transID = currentOrder;
    rsMan = memp;
    try {
        emp_id = rsMan.getInt(1);
    } catch (SQLException ex) {
        Logger.getLogger(PaymentPage.class.getName()).log(Level.SEVERE, null, ex);
    }
    products = new ArrayList<>();
    for (Button i : mproducts) {
        products.add(i);
    }
    lblQRC.setIcon(defaultQR);
    transType = mtransType;
    promoCode = mpromoCode;
    subtotal = msubtotal;
    promo = mpromo;
    tax = mtax;
    total = mtotal;
    lblPromo.setText(String.valueOf(promo));
    lblSubtotal.setText(String.valueOf(subtotal));
    lblTax.setText(String.valueOf(tax));
    lblTotal.setText(String.valueOf(total));
    paid = BigDecimal.ZERO;
    showPanel("card2");
    paymentMethod = "CA";
    payments = new ArrayList<>();
    calculateDue();
    timeExpired = false;
    timeStop = false;
}