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.prowidesoftware.swift.model.CurrencyAmount.java

/**
 * @param currency a not null currency code
 * @param amount the value for the amount, may be <code>null</code>
 *//*from   www  .j  a v  a 2 s .  c  o  m*/
CurrencyAmount(final String currency, final BigDecimal amount) {
    super();
    Validate.notNull(currency, "currency can not be null");
    this.currency = currency;
    if (amount == null) {
        this.amount = BigDecimal.ZERO;
    } else {
        this.amount = amount;
    }
}

From source file:com.github.fge.jsonschema.keyword.validator.helpers.DivisorValidator.java

@Override
protected final void validateDecimal(final ProcessingReport report, final MessageBundle bundle,
        final FullData data) throws ProcessingException {
    final JsonNode node = data.getInstance().getNode();
    final BigDecimal instanceValue = node.decimalValue();
    final BigDecimal decimalValue = number.decimalValue();

    final BigDecimal remainder = instanceValue.remainder(decimalValue);

    /*//from w  w w .  j  a v a2  s . c  o m
     * We cannot use equality! As far as BigDecimal goes,
     * "0" and "0.0" are NOT equal. But .compareTo() returns the correct
     * result.
     */
    if (remainder.compareTo(BigDecimal.ZERO) == 0)
        return;

    report.error(newMsg(data, bundle, "err.common.divisor.nonZeroRemainder").putArgument("value", node)
            .putArgument("divisor", number));
}

From source file:org.marat.workflow.demo.task.CalculatePriceTask.java

private BigDecimal calculateTotalPrice(final TaskContext taskContext) {
    BigDecimal totalPrice = BigDecimal.ZERO;

    for (final BigDecimal price : taskContext.getPrices()) {
        totalPrice = totalPrice.add(price);
    }/*from  www  .j ava  2 s .co m*/

    return totalPrice;
}

From source file:org.openmrs.module.billing.web.controller.main.MiscellaneousServiceBillAddController.java

@RequestMapping(method = RequestMethod.POST)
public String onSubmit(Model model, @RequestParam("serviceId") Integer miscellaneousServiceId,
        @RequestParam("name") String name, HttpServletRequest request, Object command, BindingResult binding) {

    BillingService billingService = (BillingService) Context.getService(BillingService.class);

    //07/07/2012:kesavulu: New Requirement #306 Add field quantity in Miscellaneous Services Bill

    MiscellaneousService miscellaneousService = null;
    int quantity = 0;
    Money itemAmount;/*from w  w  w. j a  v a  2  s. co  m*/
    Money totalAmount = new Money(BigDecimal.ZERO);

    miscellaneousService = billingService.getMiscellaneousServiceById(miscellaneousServiceId);
    quantity = Integer.parseInt(request.getParameter(miscellaneousServiceId + "_qty"));

    itemAmount = new Money(new BigDecimal(request.getParameter(miscellaneousServiceId + "_price")));
    itemAmount = itemAmount.times(quantity);
    totalAmount = totalAmount.plus(itemAmount);

    MiscellaneousServiceBill miscellaneousServiceBill = new MiscellaneousServiceBill();
    miscellaneousServiceBill.setCreatedDate(new Date());
    miscellaneousServiceBill.setCreator(Context.getAuthenticatedUser().getUserId());
    miscellaneousServiceBill.setLiableName(name);

    miscellaneousServiceBill.setAmount(totalAmount.getAmount());
    miscellaneousServiceBill.setService(miscellaneousService);
    miscellaneousServiceBill.setQuantity(quantity);
    miscellaneousServiceBill.setReceipt(billingService.createReceipt());
    miscellaneousServiceBill = billingService.saveMiscellaneousServiceBill(miscellaneousServiceBill);

    return "redirect:/module/billing/miscellaneousServiceBill.list?serviceId=" + miscellaneousServiceId
            + "&billId=" + miscellaneousServiceBill.getId();
}

From source file:org.key2gym.business.services.CashServiceBean.java

@Override
public BigDecimal getCashByDate(DateMidnight date) throws SecurityViolationException {

    if (date == null) {
        throw new NullPointerException("The date is null."); //NOI18N
    }/*  w ww.  j  a  v  a2  s .c  o m*/

    if (!date.equals(DateMidnight.now())) {
        if (!callerHasRole(SecurityRoles.MANAGER)) {
            throw new SecurityViolationException(getString("Security.Access.Denied"));
        }
    } else {
        if (!callerHasAnyRole(SecurityRoles.JUNIOR_ADMINISTRATOR, SecurityRoles.SENIOR_ADMINISTRATOR)) {
            throw new SecurityViolationException(getString("Security.Access.Denied"));
        }
    }

    BigDecimal cash = (BigDecimal) em.createNamedQuery("OrderEntity.sumPaymentsForDateRecorded") //NOI18N
            .setParameter("dateRecorded", date.toDate()) //NOI18N
            .getSingleResult();

    /*
     * The sum aggregate function returns null, when there is not 
     * any orders.
     */
    if (cash == null) {
        cash = BigDecimal.ZERO;
    }

    CashAdjustment adjustment = em.find(CashAdjustment.class, date.toDate());

    if (adjustment != null) {
        cash = cash.add(adjustment.getAmount());
    }

    return cash;
}

From source file:cz.muni.fi.dndtroops.test.HeroDaoImplTest.java

@Test
public void testCreateHero() throws ConnectionException {
    Hero heroC = new Hero();
    heroC.setName("Hero");
    heroC.setLevel(1);//  w w  w.j  av  a  2 s .  c  om
    heroC.setRole(RoleName.BARD);
    Troop troopC = new Troop();
    troopC.setName("Angels");
    troopC.setMoney(BigDecimal.ZERO);
    troopC.setMission("mise A");
    heroC.setTroop(troopC);

    troopDao.createTroop(troopC);
    heroDao.createHero(heroC);

    Hero h1 = heroDao.findById(heroC.getId());
    Assert.assertEquals(h1.getName(), "Hero");
    Assert.assertEquals(h1.getRole(), RoleName.BARD);
    Assert.assertEquals(h1.getLevel(), 1);
    Assert.assertEquals(h1.getTroop(), troopC);

}

From source file:com.acc.facades.process.email.context.NotPickedUpConsignmentCanceledEmailContext.java

protected void calculateRefundAmount() {
    BigDecimal refundAmountValue = BigDecimal.ZERO;
    PriceData totalPrice = null;/*from  ww w .j a va2  s  . co  m*/
    for (final ConsignmentEntryData consignmentEntry : getConsignment().getEntries()) {
        totalPrice = consignmentEntry.getOrderEntry().getTotalPrice();
        refundAmountValue = refundAmountValue.add(totalPrice.getValue());
    }
    refundAmount = getPriceDataFactory().create(totalPrice.getPriceType(), refundAmountValue,
            totalPrice.getCurrencyIso());
}

From source file:com.siapa.managedbean.MuestreoManagedBean.java

@Override
public void saveNew(ActionEvent event) {
    Muestreo muestreo = getMuestreo();/* ww  w  . ja  v a2  s . com*/
    muestreo.setIdJaula(jaula);
    muestreo.setUsuarioMuestreo(getUsuario());
    muestreo.setFechaRegistroMuestreo(new Date());
    muestreo.setPesoPromedioMuestreo(BigDecimal.ZERO);
    muestreoService.save(muestreo);
    loadLazyModels();
    FacesContext context = FacesContext.getCurrentInstance();
    context.addMessage(null, new FacesMessage("Successful"));
    try {
        FacesContext context1 = FacesContext.getCurrentInstance();
        context1.getExternalContext().redirect("/siapa/views/muestreo/index.xhtml");
    } catch (IOException e) {

    }
}

From source file:ei.ne.ke.cassandra.cql3.AstyanaxCql3SimpleEntityRepositoryTest.java

private SimpleEntity getEntity1() {
    SimpleEntity e = new SimpleEntity();
    e.setTheKey(ENTITY1_ID);/*  www  . j av  a2 s . co m*/
    e.setaBigInt(0L);
    e.setaBoolean(Boolean.FALSE);
    e.setaDecimal(BigDecimal.ZERO);
    e.setaDouble(1.0d);
    e.setaFloat(1.0f);
    e.setAnInt(23);
    List<String> stringList = Lists.newArrayList("alpha", "beta");
    e.setaListOfString(stringList);
    List<Integer> intList = Lists.newArrayList(23, 42);
    e.setaListOfInt(intList);
    Map<String, String> mapStringString = Maps.newHashMap();
    mapStringString.put("super", "cali");
    mapStringString.put("fragi", "listic");
    e.setaMapOfStringToString(mapStringString);
    Map<Integer, String> mapIntString = Maps.newHashMap();
    mapIntString.put(1, "one");
    mapIntString.put(2, "two");
    e.setaMapOfIntToString(mapIntString);
    Set<String> stringSet = Sets.newHashSet();
    stringSet.add("foo");
    stringSet.add("bar");
    e.setaSetOfString(stringSet);
    Set<Integer> intSet = Sets.newHashSet();
    intSet.add(1234);
    intSet.add(5678);
    e.setaSetOfInt(intSet);
    e.setaString("Pirate");
    e.setaUuid(UUID.randomUUID());
    return e;
}

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

/**
 * ????/*from www .j  a  v a 2 s .  co m*/
 * 
 * @param accountNo
 *            ?
 * @return
 */
public RpAccount getAccountByAccountNo(String accountNo) {
    LOG.info("???");
    RpAccount account = this.rpAccountDao.getByAccountNo(accountNo);
    // ??0
    if (!DateUtils.isSameDayWithToday(account.getEditTime())) {
        account.setTodayExpend(BigDecimal.ZERO);
        account.setTodayIncome(BigDecimal.ZERO);
        account.setEditTime(new Date());
        rpAccountDao.update(account);
    }
    return account;
}