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:org.fineract.module.stellar.TestPaymentInIncompleteNetwork.java

@Test
public void paymentWithoutPathFails() throws Exception {
    logger.info("paymentWithoutPathFails test begin");

    final AccountListener accountListener = new AccountListener(serverAddress, thirdTenantId);

    makePayment(firstTenantId, firstTenantApiKey, thirdTenantId, ASSET_CODE, BigDecimal.TEN);

    accountListener.waitForCredits(MAX_PAY_WAIT,
            creditMatcher(secondTenantId, BigDecimal.TEN, ASSET_CODE, thirdTenantId));

    checkBalance(thirdTenantId, thirdTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId),
            BigDecimal.ZERO);
}

From source file:com.roncoo.pay.app.reconciliation.biz.ReconciliationCheckBiz.java

/**
 * ??/*from   www . ja  va2 s  . c  o  m*/
 * 
 * @param platformDateList
 *            ?dilldate??
 * @param bankList
 *            ???
 * 
 * @param misTakeList
 *            list
 * @param screatchRecordList
 *            ??list
 * 
 * @param batch
 *            
 */
private void baseOnPaltForm(List<RpTradePaymentRecord> platformDateList, List<ReconciliationEntityVo> bankList,
        List<RpAccountCheckMistake> misTakeList, List<RpAccountCheckMistakeScratchPool> screatchRecordList,
        RpAccountCheckBatch batch) {
    BigDecimal platTradeAmount = BigDecimal.ZERO;// ??
    BigDecimal platFee = BigDecimal.ZERO;// ?
    Integer tradeCount = 0;// ??
    Integer mistakeCount = 0;

    for (RpTradePaymentRecord record : platformDateList) {
        Boolean flag = false;// ??
        // ??
        platTradeAmount = platTradeAmount.add(record.getOrderAmount());
        platFee = platFee.add(record.getPlatCost() == null ? BigDecimal.ZERO : record.getPlatCost());
        tradeCount++;
        for (ReconciliationEntityVo bankRecord : bankList) {
            // ????
            if (record.getBankOrderNo().equalsIgnoreCase(bankRecord.getBankOrderNo())) {
                flag = true;// ??

                /** step1:??? **/
                // ??
                if (record.getOrderAmount().compareTo(bankRecord.getBankAmount()) == 1) {
                    // ???
                    RpAccountCheckMistake misktake = createMisktake(null, record, bankRecord,
                            ReconciliationMistakeTypeEnum.PLATFORM_OVER_CASH_MISMATCH, batch);
                    misTakeList.add(misktake);
                    mistakeCount++;
                    break;
                }
                // ??
                else if (record.getOrderAmount().compareTo(bankRecord.getBankAmount()) == -1) {
                    // ???
                    RpAccountCheckMistake misktake = createMisktake(null, record, bankRecord,
                            ReconciliationMistakeTypeEnum.PLATFORM_SHORT_CASH_MISMATCH, batch);
                    misTakeList.add(misktake);
                    mistakeCount++;
                    break;
                }

                /** step2:?? **/
                if (record.getPlatCost().compareTo(bankRecord.getBankFee()) != 0) {
                    // ???
                    RpAccountCheckMistake misktake = createMisktake(null, record, bankRecord,
                            ReconciliationMistakeTypeEnum.FEE_MISMATCH, batch);
                    misTakeList.add(misktake);
                    mistakeCount++;
                    break;
                }

            }
        }
        // ??
        if (!flag) {
            RpAccountCheckMistakeScratchPool screatchRecord = getScratchRecord(record, batch);
            screatchRecordList.add(screatchRecord);
        }
    }

    // ??
    batch.setTradeAmount(platTradeAmount);
    batch.setTradeCount(tradeCount);
    batch.setFee(platFee);
    batch.setMistakeCount(mistakeCount);
}

From source file:gda.device.detector.mythen.client.TextClientMythenClient.java

/**
 * Converts the supplied {@link AcquisitionParameters} to a list of text client command line arguments.
 *///  www. j  a  v  a  2  s .  c  om
private static List<String> createCommandLineArgs(AcquisitionParameters params) {
    List<String> args = new ArrayList<String>();

    boolean trigen = (params.getTrigger() == Trigger.SINGLE);
    args.add("-trigen");
    args.add(trigen ? "1" : "0");

    boolean conttrigen = (params.getTrigger() == Trigger.CONTINUOUS);
    args.add("-conttrigen");
    args.add(conttrigen ? "1" : "0");

    args.add("-frames");
    args.add(Integer.toString(params.getFrames()));

    if (params.getDelayBeforeFrames() != BigDecimal.ZERO) {
        args.add("-delbef");
        args.add(params.getDelayBeforeFrames().toPlainString());
    }
    if (params.getExposureTime() != BigDecimal.ZERO) {
        args.add("-time");
        args.add(params.getExposureTime().toPlainString());
    }

    if (params.getDelayAfterFrames() != BigDecimal.ZERO) {
        args.add("-delafter");
        args.add(params.getDelayAfterFrames().toPlainString());
    }
    args.add("-fname");
    args.add(params.getFilename());

    if (params.getStartIndex() != null) {
        args.add("-startindex");
        args.add(Integer.toString(params.getStartIndex()));
    }

    args.add("-gateen");
    args.add(params.getGating() ? "1" : "0");

    args.add("-gates");
    args.add(Integer.toString(params.getGates()));

    args.add("-start");

    return args;
}

From source file:net.bhl.cdt.connector.avl.strategies.AVLProcessGeneratorStrategy.java

private void sweepDimension(AVLProcessGenerator avlProcessGenerator, int dimension,
        List<String> sweppedDimensions, HashMap<String, BigDecimal> dimensionValues, FileWriter fileWriter)
        throws IOException {
    VariableSweep variableSweep = avlProcessGenerator.getVariableSweeps().get(dimension);
    if (variableSweep.getVariableDelta().getValue().compareTo(BigDecimal.ZERO) == 0) {
        dimensionValues.put(variableSweep.getName(), variableSweep.getVariableStart().getValue());
        if (avlProcessGenerator.getVariableSweeps().size() > dimension + 1) {
            sweepDimension(avlProcessGenerator, dimension + 1, sweppedDimensions, dimensionValues, fileWriter);

        } else {/*  w  w w.  j av a2  s .c  o m*/
            writeRunCase(avlProcessGenerator, dimensionValues, sweppedDimensions, fileWriter);

        }
    } else {
        if (!sweppedDimensions.contains(variableSweep.getName())) {
            sweppedDimensions.add(variableSweep.getName());
        }

        for (BigDecimal sweppedvalue = variableSweep.getVariableStart().getValue(); !(sweppedvalue

                .compareTo(variableSweep.getVariableEnd().getValue()) == 1); sweppedvalue = sweppedvalue
                        .add(variableSweep.getVariableDelta().getValue())) {
            dimensionValues.put(variableSweep.getName(), sweppedvalue);
            if (avlProcessGenerator.getVariableSweeps().size() > dimension + 1) {
                sweepDimension(avlProcessGenerator, dimension + 1, sweppedDimensions, dimensionValues,
                        fileWriter);

            } else {
                writeRunCase(avlProcessGenerator, dimensionValues, sweppedDimensions, fileWriter);

            }

        }
    }

}

From source file:pe.gob.mef.gescon.web.ui.MaestroMB.java

public void cleanAttributes() {
    this.setId(BigDecimal.ZERO);
    this.setDescripcion(StringUtils.EMPTY);
    this.setNombre(StringUtils.EMPTY);
    this.setActivo(BigDecimal.ONE);
    //        this.setSelectedMaestro(null);
    Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages();
    if (iter.hasNext() == true) {
        iter.remove();/*from w ww.ja v a 2 s .  com*/
        FacesContext.getCurrentInstance().renderResponse();
    }
}

From source file:it.newfammulfin.api.EntryResource.java

@GET
@Path("template")
public Response template(@PathParam("groupId") @NotNull Long groupId) {
    Group group = (Group) requestContext.getProperty(GroupRetrieverRequestFilter.GROUP);
    Key<RegisteredUser> userKey = Key.create(RegisteredUser.class,
            securityContext.getUserPrincipal().getName());
    Entry entry = new Entry();
    entry.setAmount(Money.of(group.getDefaultCurrencyUnit(), 2.20));
    entry.setDate(LocalDate.now());
    entry.setPayee("Pub");
    entry.setDescription("Beer");
    entry.getTags().add("Fun");
    entry.getByShares().put(userKey, entry.getAmount().getAmount());
    for (Key<RegisteredUser> otherSserKey : group.getUsersMap().keySet()) {
        entry.getForShares().put(otherSserKey, BigDecimal.ZERO);
    }/* w  w  w .  j av  a  2s .c  o m*/
    checkAndBalanceZeroShares(entry.getForShares(), entry.getAmount().getAmount());
    return Response.ok(entry).build();
}

From source file:net.shopxx.controller.shop.OrderController.java

@RequestMapping(value = "/lock", method = RequestMethod.POST)
public @ResponseBody void lock(String sn) {
    Order order = orderService.findBySn(sn);
    Member member = memberService.getCurrent();
    if (order != null && member.equals(order.getMember()) && order.getPaymentMethod() != null
            && PaymentMethod.Method.online.equals(order.getPaymentMethod().getMethod())
            && order.getAmountPayable().compareTo(BigDecimal.ZERO) > 0) {
        orderService.lock(order, member);
    }//from www  .j a  v  a2s . c  om
}

From source file:net.shopxx.dao.impl.OrderDaoImpl.java

public List<Order> findList(Order.Type type, Order.Status status, Member member, Goods goods,
        Boolean isPendingReceive, Boolean isPendingRefunds, Boolean isUseCouponCode, Boolean isExchangePoint,
        Boolean isAllocatedStock, Boolean hasExpired, Integer count, List<Filter> filters,
        List<net.shopxx.Order> orders) {
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<Order> criteriaQuery = criteriaBuilder.createQuery(Order.class);
    Root<Order> root = criteriaQuery.from(Order.class);
    criteriaQuery.select(root);//from   w  ww  .ja v a 2 s .c  o  m
    Predicate restrictions = criteriaBuilder.conjunction();
    if (type != null) {
        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("type"), type));
    }
    if (status != null) {
        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("status"), status));
    }
    if (member != null) {
        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("member"), member));
    }
    if (goods != null) {
        Subquery<Product> productSubquery = criteriaQuery.subquery(Product.class);
        Root<Product> productSubqueryRoot = productSubquery.from(Product.class);
        productSubquery.select(productSubqueryRoot);
        productSubquery.where(criteriaBuilder.equal(productSubqueryRoot.get("goods"), goods));

        Subquery<OrderItem> orderItemSubquery = criteriaQuery.subquery(OrderItem.class);
        Root<OrderItem> orderItemSubqueryRoot = orderItemSubquery.from(OrderItem.class);
        orderItemSubquery.select(orderItemSubqueryRoot);
        orderItemSubquery.where(criteriaBuilder.equal(orderItemSubqueryRoot.get("order"), root),
                criteriaBuilder.in(orderItemSubqueryRoot.get("product")).value(productSubquery));
        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.exists(orderItemSubquery));
    }
    if (isPendingReceive != null) {
        Predicate predicate = criteriaBuilder.and(
                criteriaBuilder.or(root.get("expire").isNull(),
                        criteriaBuilder.greaterThan(root.<Date>get("expire"), new Date())),
                criteriaBuilder.equal(root.get("paymentMethodType"), PaymentMethod.Type.cashOnDelivery),
                criteriaBuilder.notEqual(root.get("status"), Order.Status.completed),
                criteriaBuilder.notEqual(root.get("status"), Order.Status.failed),
                criteriaBuilder.notEqual(root.get("status"), Order.Status.canceled),
                criteriaBuilder.notEqual(root.get("status"), Order.Status.denied),
                criteriaBuilder.lessThan(root.<BigDecimal>get("amountPaid"), root.<BigDecimal>get("amount")));
        if (isPendingReceive) {
            restrictions = criteriaBuilder.and(restrictions, predicate);
        } else {
            restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.not(predicate));
        }
    }
    if (isPendingRefunds != null) {
        Predicate predicate = criteriaBuilder.or(
                criteriaBuilder.and(
                        criteriaBuilder.or(
                                criteriaBuilder.and(root.get("expire").isNotNull(),
                                        criteriaBuilder.lessThanOrEqualTo(root.<Date>get("expire"),
                                                new Date())),
                                criteriaBuilder.equal(root.get("status"), Order.Status.failed),
                                criteriaBuilder.equal(root.get("status"), Order.Status.canceled),
                                criteriaBuilder.equal(root.get("status"), Order.Status.denied)),
                        criteriaBuilder.greaterThan(root.<BigDecimal>get("amountPaid"), BigDecimal.ZERO)),
                criteriaBuilder.and(criteriaBuilder.equal(root.get("status"), Order.Status.completed),
                        criteriaBuilder.greaterThan(root.<BigDecimal>get("amountPaid"),
                                root.<BigDecimal>get("amount"))));
        if (isPendingRefunds) {
            restrictions = criteriaBuilder.and(restrictions, predicate);
        } else {
            restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.not(predicate));
        }
    }
    if (isUseCouponCode != null) {
        restrictions = criteriaBuilder.and(restrictions,
                criteriaBuilder.equal(root.get("isUseCouponCode"), isUseCouponCode));
    }
    if (isExchangePoint != null) {
        restrictions = criteriaBuilder.and(restrictions,
                criteriaBuilder.equal(root.get("isExchangePoint"), isExchangePoint));
    }
    if (isAllocatedStock != null) {
        restrictions = criteriaBuilder.and(restrictions,
                criteriaBuilder.equal(root.get("isAllocatedStock"), isAllocatedStock));
    }
    if (hasExpired != null) {
        if (hasExpired) {
            restrictions = criteriaBuilder.and(restrictions, root.get("expire").isNotNull(),
                    criteriaBuilder.lessThanOrEqualTo(root.<Date>get("expire"), new Date()));
        } else {
            restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.or(root.get("expire").isNull(),
                    criteriaBuilder.greaterThan(root.<Date>get("expire"), new Date())));
        }
    }
    criteriaQuery.where(restrictions);
    return super.findList(criteriaQuery, null, count, filters, orders);
}

From source file:de.hybris.platform.accountsummaryaddon.facade.impl.DefaultB2BAccountSummaryFacade.java

protected BigDecimal validateAndFormatAmount(String amount) {
    try {//  ww w  .  ja va 2  s  . c om
        if (StringUtils.isBlank(amount)) {
            return BigDecimal.ZERO;
        } else {
            return new BigDecimal(amount);
        }
    } catch (final RuntimeException e) {
        throw new EntityValidationException(String.format("Invalid amount [%s]", amount), e);
    }
}

From source file:org.fede.util.Util.java

private static BigDecimal avg(List<BigDecimal> list) {
    if (list.isEmpty()) {
        return BigDecimal.ZERO;
    }//  w  w w. j av a  2  s. c o m
    return list.stream().reduce(BigDecimal.ZERO, (left, right) -> left.add(right))
            .setScale(7, RoundingMode.HALF_UP).divide(new BigDecimal(list.size()), MathContext.DECIMAL32);
}