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.heliumv.api.item.ItemApiV11.java

private BigDecimal getPriceFromPreisfindung(VkpreisfindungDto vkPreisDto) {
    BigDecimal p = getMinimumPrice(null, vkPreisDto.getVkpStufe3());
    if (p != null)
        return p;

    p = getMinimumPrice(null, vkPreisDto.getVkpStufe2());
    if (p != null)
        return p;

    p = getMinimumPrice(null, vkPreisDto.getVkpStufe1());
    if (p != null)
        return p;

    p = getMinimumPrice(null, vkPreisDto.getVkpPreisbasis());
    if (p != null)
        return p;

    return BigDecimal.ZERO;
}

From source file:es.tid.fiware.rss.service.RSSModelsManager.java

/**
 * Check that a RssModels contains all required Information.
 * /* w w w . j  a v  a  2 s.  c o m*/
 * @param aggregatorId
 * @param appProviderId
 * @throws Exception
 */
public void checkValidRSSModel(RSSModel rssModel) throws Exception {
    logger.debug("Into checkValidRSSModel mehtod");
    if (null == rssModel.getAppProviderId() || "".equalsIgnoreCase(rssModel.getAppProviderId())) {
        String[] args = { "Required parameters not found: appProviderId" };
        throw new RSSException(UNICAExceptionType.NON_EXISTENT_RESOURCE_ID, args);
    }
    if (null == rssModel.getPercRevenueShare()) {
        String[] args = { "Required parameters not found: percRevenueShare" };
        throw new RSSException(UNICAExceptionType.NON_EXISTENT_RESOURCE_ID, args);
    } else if (rssModel.getPercRevenueShare().compareTo(BigDecimal.ZERO) <= 0) {
        String[] args = { "percRevenueShare must be greater than 0" };
        throw new RSSException(UNICAExceptionType.INVALID_INPUT_VALUE, args);
    }
}

From source file:com.ksmpartners.ernie.util.TestUtil.java

/**
 * Creates a standard hash of common test values for use with testing getters
 * and setters.//from w  ww  .java2 s.  co m
 */
private static void createTestValues() {
    testValues.put(Long.class, Long.valueOf(123L));
    testValues.put(Integer.class, Integer.valueOf(456));
    testValues.put(String.class, "FOOBAR");
    testValues.put(Double.class, Double.valueOf(123.456));
    testValues.put(Float.class, Float.valueOf(789.123f));
    testValues.put(BigDecimal.class, BigDecimal.ZERO);
    testValues.put(Boolean.class, Boolean.TRUE);
    testValues.put(Byte.class, Mockito.anyByte());
    testValues.put(Character.class, Mockito.anyChar());
    testValues.put(Collection.class, Mockito.anyCollection());
    testValues.put(List.class, Mockito.anyList());
    testValues.put(Set.class, Mockito.anySet());
    testValues.put(Map.class, Mockito.anyMap());
    testValues.put(JobStatus.class, JobStatus.PENDING);
    testValues.put(ReportType.class, ReportType.PDF);
}

From source file:org.businessmanager.web.controller.page.invoice.InvoiceEditController.java

public BigDecimal getTotalVatAmount() {
    BigDecimal totalVatAmount = BigDecimal.ZERO;
    for (LineItemBean lineItem : bean.getLineItems()) {
        BigDecimal amount = lineItem.getVatAmount();
        totalVatAmount = totalVatAmount.add(amount);
    }/*from  w  ww. j av  a2 s  .c o  m*/

    return totalVatAmount.setScale(2, RoundingMode.HALF_UP);
}

From source file:com.autobizlogic.abl.rule.AbstractAggregateRule.java

/**
 * Get the value of a numeric attribute as a big decimal. This version allows the return of null
 * if nullAllowed is true./*from www.java  2 s.  co m*/
 */
protected static BigDecimal getObjectPropertyAsBigDecimal(PersistentBean anObjectState, String aPropertyName,
        boolean nullAllowed) {
    if (anObjectState == null)
        throw new RuntimeException("Cannot get property from null object");
    Number value = (Number) anObjectState.get(aPropertyName);
    if (value == null) {
        if (nullAllowed)
            return null;
        return BigDecimal.ZERO;
    }
    return (BigDecimal) NumberUtil.convertNumberToType(value, BigDecimal.class);
}

From source file:com.aoindustries.creditcards.TransactionRequest.java

/**
 * Sets the amount of the transaction.  This amount should not include any tax, shipping charges, or duty.
 * Thus the total amount of the transaction is the amount + taxAmount + shippingAmount + dutyAmount.
 *
 * The amount is normalized to the proper number of decimal places for the selected currency.
 *
 * @throws  IllegalArgumentException  if amount <= 0 or is incorrectly formatted for the currency.
 *///from www.j  a  v  a  2s  .c o m
public void setAmount(BigDecimal amount) throws IllegalArgumentException {
    if (amount == null) {
        this.amount = null;
    } else {
        if (amount.compareTo(BigDecimal.ZERO) <= 0)
            throw new LocalizedIllegalArgumentException(accessor,
                    "TransactionRequest.setAmount.amount.lessThanEqualZero");
        try {
            this.amount = amount.setScale(currency.getDefaultFractionDigits());
        } catch (ArithmeticException err) {
            throw new LocalizedIllegalArgumentException(err, accessor,
                    "TransactionRequest.setAmount.amount.cannotNormalize");
        }
    }
}

From source file:it.govpay.web.console.pagamenti.service.DistintaService.java

private DistintaBean findPagamentoById(Long key) throws ServiceException {
    try {//from   ww w . j a  va 2s.  c  o  m
        log.debug("findById Pagamento in corso...");

        DistintaModel distintaById = this.distintaEjb.findDistintaById(key);

        log.debug("findById Pagamento completata.");
        if (distintaById != null) {
            List<PendenzaModel> pendenze = pendenzaEjb.getPendenze(key);
            EsitoPagamentoDistinta esitoPagamento = this.distintaEjb.getEsitoPagamentoDistinta(key);
            EnteCreditoreModel enteCreditore = anagraficaEjb
                    .getCreditoreByIdLogico(esitoPagamento.getIdentificativoFiscaleCreditore());
            PagamentoModel pagamento = new PagamentoModel();
            pagamento.setAutenticazione(distintaById.getAutenticazione().toString());
            pagamento.setCcp(distintaById.getCodTransazionePsp());
            pagamento.setDebitore(pendenze.get(0).getDebitore());
            pagamento.setEnteCreditore(enteCreditore);
            pagamento.setGatewayPagamento(anagraficaEjb.getValidGateway(distintaById.getIdGatewayPagamento()));
            pagamento.setIbanAddebito(distintaById.getIbanAddebito());
            pagamento.setImportoDovuto(distintaById.getImportoTotale());
            pagamento.setImportoVersato(esitoPagamento.getImportoTotalePagato());
            pagamento.setIuv(distintaById.getIuv());
            pagamento.setStato(esitoPagamento.getStato().getDescrizione());
            pagamento.setTributo(anagraficaEjb.getTributoById(enteCreditore.getIdEnteCreditore(),
                    pendenze.get(0).getCodiceTributo()));
            pagamento.setVersante(distintaById.getSoggettoVersante());

            List<DettaglioPagamento> dettagliPagamento = new ArrayList<PagamentoModel.DettaglioPagamento>();

            for (it.govpay.ejb.core.model.PagamentoModel pagamentoEjbModel : distintaById.getPagamenti()) {
                PendenzaModel pendenzaModel = null;
                for (PendenzaModel pendenzaModelAct : pendenze) {
                    if (pendenzaModelAct.getCondizioniPagamento().get(0).getIdCondizione()
                            .equals(pagamentoEjbModel.getIdCondizionePagamento())) {
                        pendenzaModel = pendenzaModelAct;
                    }
                }
                DettaglioPagamento dettaglio = pagamento.new DettaglioPagamento();
                dettaglio.setAnnoRiferimento(pendenzaModel.getAnnoRiferimento());
                dettaglio.setCausale(pendenzaModel.getCondizioniPagamento().get(0).getCausale());
                dettaglio.setDataRicevuta(pagamentoEjbModel.getDataPagamento());
                dettaglio.setIbanAccredito(pendenzaModel.getCondizioniPagamento().get(0).getIbanBeneficiario());
                dettaglio.setIdentificativo(pendenzaModel.getCondizioniPagamento().get(0).getIdPagamentoEnte());
                dettaglio.setImportoDovuto(pendenzaModel.getCondizioniPagamento().get(0).getImportoTotale());
                if (pagamentoEjbModel.getStato().equals(EnumStatoPagamento.ES))
                    dettaglio.setImportoVersato(pagamentoEjbModel.getImportoPagato());
                else
                    dettaglio.setImportoVersato(BigDecimal.ZERO);
                dettaglio.setIur(pagamentoEjbModel.getIdRiscossionePSP());
                dettaglio.setStato(pagamentoEjbModel.getStato().getDescrizione());
                dettagliPagamento.add(dettaglio);
            }

            pagamento.setDettagliPagamento(dettagliPagamento);

            RPTModel rptModel = documentiEjb.recuperaRPT(enteCreditore.getIdFiscale(), distintaById.getIuv(),
                    distintaById.getCodTransazionePsp());
            if (rptModel != null) {
                pagamento.setRpt(rptModel.getBytes());
            }

            RTModel rtModel = documentiEjb.recuperaRT(enteCreditore.getIdFiscale(), distintaById.getIuv(),
                    distintaById.getCodTransazionePsp());
            if (rtModel != null) {
                pagamento.setRt(rtModel.getBytes());
            }

            DistintaBean bean = new DistintaBean();

            bean.setDTO(distintaById);
            bean.setDTO(pagamento);

            return bean;
        }
    } catch (Exception e) {
        log.error("Si e' verificato un errore durante la findById Distinta: " + e.getMessage(), e);
    }
    return null;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424_2_0V2_0Generator.java

/**
 *
 * This method is to get estimated project funds for RRSF424
 *
 * @return EstimatedProjectFunding estimated total cost for the project.
 *//*from  w  w  w  .j a v a  2 s.com*/
private EstimatedProjectFunding getProjectFunding() {
    EstimatedProjectFunding funding = EstimatedProjectFunding.Factory.newInstance();
    funding.setTotalEstimatedAmount(BigDecimal.ZERO);
    funding.setTotalNonfedrequested(BigDecimal.ZERO);
    funding.setTotalfedNonfedrequested(BigDecimal.ZERO);
    funding.setEstimatedProgramIncome(BigDecimal.ZERO);
    boolean hasBudgetLineItem = false;

    ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService
            .getBudget(pdDoc.getDevelopmentProposal());
    if (budget != null) {

        ScaleTwoDecimal totalCost = ScaleTwoDecimal.ZERO;

        if (budget.getModularBudgetFlag()) {
            ScaleTwoDecimal fundsRequested = ScaleTwoDecimal.ZERO;
            ScaleTwoDecimal totalDirectCost = ScaleTwoDecimal.ZERO;
            // get modular budget amounts instead of budget detail amounts
            for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) {
                totalDirectCost = totalDirectCost.add(budgetPeriod.getBudgetModular().getTotalDirectCost());
                for (BudgetModularIdcContract budgetModularIdc : budgetPeriod.getBudgetModular()
                        .getBudgetModularIdcs()) {
                    fundsRequested = fundsRequested.add(budgetModularIdc.getFundsRequested());
                }
            }
            totalCost = totalCost.add(totalDirectCost);
            totalCost = totalCost.add(fundsRequested);
        } else {
            totalCost = budget.getTotalCost();
        }

        ScaleTwoDecimal fedNonFedCost = totalCost;
        ScaleTwoDecimal costSharingAmount = ScaleTwoDecimal.ZERO;

        for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) {
            for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) {
                hasBudgetLineItem = true;
                if (budget.getSubmitCostSharingFlag() && lineItem.getSubmitCostSharingFlag()) {
                    costSharingAmount = costSharingAmount.add(lineItem.getCostSharingAmount());
                    List<? extends BudgetLineItemCalculatedAmountContract> calculatedAmounts = lineItem
                            .getBudgetLineItemCalculatedAmounts();
                    for (BudgetLineItemCalculatedAmountContract budgetLineItemCalculatedAmount : calculatedAmounts) {
                        costSharingAmount = costSharingAmount
                                .add(budgetLineItemCalculatedAmount.getCalculatedCostSharing());
                    }

                }
            }
        }
        if (!hasBudgetLineItem && budget.getSubmitCostSharingFlag()) {
            costSharingAmount = budget.getCostSharingAmount();
        }
        fedNonFedCost = fedNonFedCost.add(costSharingAmount);
        funding = EstimatedProjectFunding.Factory.newInstance();
        funding.setTotalEstimatedAmount(totalCost.bigDecimalValue());
        funding.setTotalNonfedrequested(costSharingAmount.bigDecimalValue());
        funding.setTotalfedNonfedrequested(fedNonFedCost.bigDecimalValue());
        funding.setEstimatedProgramIncome(getTotalProjectIncome(budget));
    }
    return funding;
}

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

/**
 * ?//from  w  ww  . j  a  v  a2s  .  c  o m
 * 
 * @param bankList
 *            ??
 * 
 * @param misTakeList
 *            list
 * 
 * @param platScreatchRecordList
 *            ??
 * 
 * @param batch
 *            
 */
private void baseOnBank(List<RpTradePaymentRecord> platAllDateList, List<ReconciliationEntityVo> bankList,
        List<RpAccountCheckMistakeScratchPool> platScreatchRecordList, List<RpAccountCheckMistake> misTakeList,
        RpAccountCheckBatch batch, List<RpAccountCheckMistakeScratchPool> removeScreatchRecordList) {
    BigDecimal platTradeAmount = BigDecimal.ZERO;// ??
    BigDecimal platFee = BigDecimal.ZERO;// ?
    Integer tradeCount = 0;// ??
    Integer mistakeCount = 0;
    // ?
    for (ReconciliationEntityVo bankRecord : bankList) {

        boolean flag = false;// ??
        for (RpTradePaymentRecord record : platAllDateList) {
            /** step1 ?? **/
            if (bankRecord.getBankOrderNo().equals(record.getBankOrderNo())) {
                flag = true;
                /** step2 ???? **/
                /** ????????????? **/
                // ??
                if (!TradeStatusEnum.SUCCESS.name().equals(record.getStatus())) {
                    RpAccountCheckMistake misktake1 = createMisktake(null, record, bankRecord,
                            ReconciliationMistakeTypeEnum.PLATFORM_SHORT_STATUS_MISMATCH, batch);
                    misTakeList.add(misktake1);
                    mistakeCount++;
                    // break;

                    /** ???????????? **/
                    // ??
                    /** 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;
                    }

                }
            }
        }

        /** step3 ?? **/
        if (!flag) {
            // (?????)
            if (platScreatchRecordList != null)
                for (RpAccountCheckMistakeScratchPool scratchRecord : platScreatchRecordList) {

                    // ?
                    if (scratchRecord.getBankOrderNo().equals(bankRecord.getBankOrderNo())) {
                        // ??
                        platTradeAmount = platTradeAmount.add(scratchRecord.getOrderAmount());
                        platFee = platFee.add(scratchRecord.getPlatCost() == null ? BigDecimal.ZERO
                                : scratchRecord.getPlatCost());
                        tradeCount++;
                        flag = true;

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

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

                        /** step3:? **/
                        removeScreatchRecordList.add(scratchRecord);
                    }
                }
        }

        // ?, PLATFORM_MISS("???")
        if (!flag) {
            RpAccountCheckMistake misktake = createMisktake(null, null, bankRecord,
                    ReconciliationMistakeTypeEnum.PLATFORM_MISS, batch);
            misTakeList.add(misktake);
            mistakeCount++;
        }
    }

    // ??
    batch.setTradeAmount(batch.getTradeAmount().add(platTradeAmount));
    batch.setTradeCount(batch.getTradeCount() + tradeCount);
    batch.setFee(batch.getFee().add(platFee));
    batch.setMistakeCount(batch.getMistakeCount() + mistakeCount);
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398ModularBudgetV1_0Generator.java

/**
 * /*from   w w w. j a  v a2s.c om*/
 * This method is used to get Cummulative Budget information from
 * ModularBudget form
 * 
 * @return CummulativeBudgetInfo containing cummulative cost details.
 */
private CummulativeBudgetInfo getCummBudget() {
    CummulativeBudgetInfo cummBudget = CummulativeBudgetInfo.Factory.newInstance();
    EntirePeriodTotalCost entireCost = EntirePeriodTotalCost.Factory.newInstance();
    // Set default values to mandatory fields
    entireCost.setCumulativeDirectCostLessConsortiumFandA(BigDecimal.ZERO);
    entireCost.setCumulativeTotalFundsRequestedDirectCosts(BigDecimal.ZERO);
    entireCost.setCumulativeTotalFundsRequestedDirectIndirectCosts(BigDecimal.ZERO);

    BudgetJustifications budgetJustifications = BudgetJustifications.Factory.newInstance();
    if (!cumulativeTotalFundsRequestedDirectIndirectCosts.toString().equals("0")) {
        entireCost.setCumulativeDirectCostLessConsortiumFandA(
                cumulativeDirectCostLessConsortiumFandA.bigDecimalValue());
        entireCost.setCumulativeTotalFundsRequestedDirectCosts(
                cumulativeTotalFundsRequestedDirectCosts.bigDecimalValue());
        entireCost.setCumulativeConsortiumFandA(cumulativeConsortiumFandA.bigDecimalValue());
        entireCost.setCumulativeTotalFundsRequestedDirectIndirectCosts(
                cumulativeTotalFundsRequestedDirectIndirectCosts.bigDecimalValue());
        entireCost.setCumulativeTotalFundsRequestedIndirectCost(
                cumulativeTotalFundsRequestedIndirectCost.bigDecimalValue());
        cummBudget.setEntirePeriodTotalCost(entireCost);
        budgetJustifications = getBudgetJustifications();
        if (budgetJustifications.getAdditionalNarrativeJustification() != null
                || budgetJustifications.getConsortiumJustification() != null
                || budgetJustifications.getPersonnelJustification() != null) {
            cummBudget.setBudgetJustifications(budgetJustifications);
        }
    }
    cummBudget.setEntirePeriodTotalCost(entireCost);
    return cummBudget;
}