Example usage for java.math BigDecimal add

List of usage examples for java.math BigDecimal add

Introduction

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

Prototype

public BigDecimal add(BigDecimal augend) 

Source Link

Document

Returns a BigDecimal whose value is (this + augend) , and whose scale is max(this.scale(), augend.scale()) .

Usage

From source file:me.j360.idgen.impl.test.TableIdGenServiceJdbcTest.java

/**
 * [Flow #-5] Positive, Negative Case : try to get next BigDecimal id from
 * id generator with block size = 10//  w  w  w  .  j  a  va2  s  .  c  om
 * 
 * @throws Exception
 *             fail to test
 */
@Test
public void testBigDecimalRequestIdsSize10() throws Exception {
    if (isBigDecimalImplemented()) {
        IdGenService idGenerator = (IdGenService) applicationContext
                .getBean("Ids-TestBigDecimalRequestIdsSize10");
        try {
            int testCount = 100;
            BigDecimal initial = new BigDecimal(new String(Long.MAX_VALUE + "00"));

            // 1. Initialize the counter in the
            // database.
            initializeNextBigDecimalId("test", initial);

            // 2. get next bigdecimal id
            for (int i = 0; i < testCount; i++) {
                BigDecimal id = idGenerator.getNextBigDecimalId();
                assertEquals("The returned id was not what was expected.",
                        initial.add(new BigDecimal(new Integer(i).doubleValue())), id);
            }

            // 3. get next integer id using query
            // directly.
            assertEquals("The next_id column in the database did not have the expected value.",
                    initial.add(new BigDecimal(new Integer(testCount).doubleValue())),
                    peekNextBigDecimalId("test"));
        } finally {
        }
    } else
        fail("Test failed because BigDecimals are not implemented in current driver.");
}

From source file:com.xumpy.thuisadmin.services.implementations.BedragenSrvImpl.java

@Override
public OverzichtGroepBedragenTotal filterOverzichtGroepBedragenTotalFilter(
        OverzichtGroepBedragenTotal overzichtGroepBedragenTotal, String filter) {
    List<OverzichtGroepBedragen> overzichtGroepBedragen = new ArrayList<OverzichtGroepBedragen>();
    BigDecimal newSomBedrag = new BigDecimal(0);

    OverzichtGroepBedragenTotal newOverzichtGroepBedragenTotal = new OverzichtGroepBedragenTotal();

    if (overzichtGroepBedragenTotal.getOverzichtGroepBedragen() != null) {
        for (OverzichtGroepBedragen overzichtGroepBedrag : overzichtGroepBedragenTotal
                .getOverzichtGroepBedragen()) {
            if (overzichtGroepBedrag.contains(filter)) {
                overzichtGroepBedragen.add(overzichtGroepBedrag);
                newSomBedrag = newSomBedrag.add(overzichtGroepBedrag.getBedrag());
            }/*from  ww w .j a v  a  2s  .co m*/
        }
    }
    newOverzichtGroepBedragenTotal.setSomBedrag(newSomBedrag);
    newOverzichtGroepBedragenTotal.setOverzichtGroepBedragen(overzichtGroepBedragen);

    return newOverzichtGroepBedragenTotal;
}

From source file:br.ufac.sion.service.retorno.ArquivoRetornoCaixaService.java

private void carregarTitulos(ArquivoRetornoCaixa arquivoRetorno) {
    Map<Integer, Collection<SegmentoT>> titulosPorOcorrencia = arquivoRetorno
            .getTransacoesPorCodigoDeOcorrencia();
    BigDecimal valorTotal = BigDecimal.ZERO;
    int totalTitulosPagos = 0;
    for (SegmentoT t : titulosPorOcorrencia.get(SegmentoU.LIQUIDACAO)) {
        br.ufac.sion.model.Boleto cobranca = this.boletoFacade.findByNossoNumero(t.getNossoNumero());
        if (cobranca != null) {
            if (t.getSegmentoU().getValorPago().compareTo(cobranca.getValor()) >= 0) {
                cobranca.getSacado().setStatus(SituacaoInscricao.CONFIRMADA);
                cobranca.getSacado()//from w  w w .j a  v  a2 s.  co m
                        .setJustificativaStatus("Confirmao automtica (via arquivo de retorno)");
                cobranca.getSacado().setDataJustificativaStatus(LocalDateTime.now());
                cobranca.setSituacao(SituacaoBoleto.PAGO);
                cobranca.setDataPagamento(
                        DateConversor.convertDateToLocalDate(t.getSegmentoU().getDataOcorrencia()));
                cobranca.setValorPago(t.getSegmentoU().getValorPago());
                cobranca.setArquivo(ar);
                this.ard.getIncricoesConfirmadas().add(cobranca.getSacado());
                totalTitulosPagos++;
            }
        }
        valorTotal.add(t.getValor());
    }
    this.ard.setTotalTitulosPagos(totalTitulosPagos);
    this.ard.setValorTotalEmCobrancas(valorTotal);
}

From source file:com.citrix.cpbm.portal.fragment.controllers.AbstractHomeController.java

private void drawNormalDashboard(Tenant tenant, String serviceInstanceUUID, HttpServletRequest request,
        User user, List<Map<String, Object>> dashboardItems, AccountStatement currentAccountStatement) {
    ServiceInstance serviceInstance = null;
    int spendIndex = 0;
    if (serviceInstanceUUID != null) {
        serviceInstance = connectorConfigurationManager.getInstanceByUUID(serviceInstanceUUID);

        if (!config.getBooleanValue(Names.com_citrix_cpbm_catalog_payAsYouGoMode)) {
            spendIndex = 1;/*from  w w w . j  a v a 2s.c  om*/
            int activeSubscriptions = subscriptionService.getCountByState(null, user, serviceInstance,
                    Subscription.State.ACTIVE, false);

            Set<Invoice> invoices = currentAccountStatement.getInvoices(user);
            BigDecimal renewalAmount = BigDecimal.ZERO;
            for (Invoice invoice : invoices) {
                if (invoice.getType().equals(Invoice.Type.Renewal)
                        && invoice.getSubscription().getServiceInstance().getUuid().equals(serviceInstanceUUID)
                        && invoice.getRemoved() == null) {
                    renewalAmount = renewalAmount.add(invoice.getAmount());
                }
            }

            Map<String, Object> dashboardItem1 = new HashMap<String, Object>();
            dashboardItem1.put("itemName",
                    messageSource.getMessage("label.active.subscriptions", null, getSessionLocale(request)));
            dashboardItem1.put("itemValue", activeSubscriptions);
            dashboardItem1.put("itemValue2", renewalAmount);
            dashboardItem1.put("itemValue2Type", "currency");
            dashboardItem1.put("itemValue2Prefix",
                    messageSource.getMessage("label.dashboard.renewal.value", null, getSessionLocale(request)));
            dashboardItem1.put("itemImage", "dashboard_active_subscriptions");
            dashboardItem1.put("itemUom",
                    messageSource.getMessage("label.dashboard.subscriptions", null, getSessionLocale(request)));
            dashboardItems.add(dashboardItem1);
        }

        Map<String, List<BigDecimal>> productInvoiceItemsMap = new HashMap<String, List<BigDecimal>>();
        List<ProductUsage> productUsages = null;
        try {
            productUsages = usageService.getAggregatedProductUsageForUser(tenant, user, null, null, false, null,
                    null, serviceInstanceUUID).getProductUsages();
        } catch (UsageServiceException use) {
            // no products found most likely
            logger.error(use);
        }

        if (productUsages != null) {
            for (ProductUsage productUsage : productUsages) {
                List<BigDecimal> productUsageAmountAndQuantity = new ArrayList<BigDecimal>();
                productUsageAmountAndQuantity.add(productUsage.getRawUsage());
                productUsageAmountAndQuantity.add(productUsage.getRatedUsage());
                productInvoiceItemsMap.put(productUsage.getProductCode(), productUsageAmountAndQuantity);
            }
        }

        List<Product> products = productService.listProductsByServiceInstance(serviceInstance, 0, 60);
        // adding perPage as 60 for now so that dashboard UI pagination doesn't break
        int productImageCount = 0;
        BigDecimal totalSpendByInstance = BigDecimal.ZERO;
        for (Product product : products) {
            Map<String, Object> productValues = new HashMap<String, Object>();
            if (productInvoiceItemsMap.containsKey(product.getCode())) {
                float quantityTotal = Math.round(
                        productInvoiceItemsMap.get(product.getCode()).get(0).floatValue() * 100.0f) / 100.0f;
                BigDecimal amount = productInvoiceItemsMap.get(product.getCode()).get(1);
                totalSpendByInstance = totalSpendByInstance.add(amount);
                if (product.getDiscrete()) {
                    // quantity
                    productValues.put("itemValue", new Float(quantityTotal).intValue());
                } else {
                    // quantity
                    productValues.put("itemValue", quantityTotal);
                }
                // amount
                productValues.put("itemValue2", amount);
                productValues.put("itemValue2Type", "currency");
                String customImagePath = product.getImagePath();
                if (customImagePath != null) {
                    productValues.put("itemCustomImage", "/portal/portal/logo/product/" + product.getId());
                    productValues.put("itemId", product.getId());
                } else {
                    if (productImageCount == 3) {
                        productImageCount = 0;
                    }
                    productImageCount = productImageCount + 1;
                    productValues.put("itemImage", "dashboard_product" + productImageCount);
                }

                productValues.put("itemName", product.getName());

                productValues.put("itemValueType", "product");
                productValues.put("itemUom", product.getUom());
                dashboardItems.add(productValues);
            }
        }

        Map<String, Object> dashboardItem2 = new HashMap<String, Object>();
        dashboardItem2.put("itemName",
                messageSource.getMessage("label.total.spend", null, getSessionLocale(request)));
        dashboardItem2.put("itemValue", totalSpendByInstance);
        dashboardItem2.put("itemValueType", "currency");
        dashboardItem2.put("itemImage", "dashboard_total_spend");

        dashboardItems.add(spendIndex, dashboardItem2);

    }
}

From source file:com.sisrni.managedbean.BecaConsultarMB.java

public void cambiarMontoBeca() {
    BigDecimal montoInterno = this.beca.getMontoInterno();
    BigDecimal montoExterno = this.beca.getMontoExterno();
    this.beca.setMontoTotal(montoInterno.add(montoExterno));

}

From source file:com.smi.travel.controller.PaymentStockController.java

@Override
protected ModelAndView process(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
    UtilityFunction utilty = new UtilityFunction();
    SystemUser user = (SystemUser) session.getAttribute("USER");
    String action = request.getParameter("action");
    String payNo = request.getParameter("payNo");
    String payId = request.getParameter("payId");
    String createBy = request.getParameter("createBy");
    String createDate = request.getParameter("createDate");
    //        String totalSale = request.getParameter("totalSaleAll");
    //        String totalCost = request.getParameter("totalCostAll");
    String curCost = request.getParameter("curCost");
    String curSale = request.getParameter("curSale");
    String noStockTable = request.getParameter("noStockTable");
    //        String totalCostAll = request.getParameter("totalCostAll");
    //        String totalSaleAll = request.getParameter("totalSaleAll");
    System.out.println("===== createDate =====" + createDate);

    request.setAttribute(NOSTOCKTABLE, 1);
    String saveresult = "";
    if ("new".equalsIgnoreCase(action)) {

    } else if ("searchPayNo".equalsIgnoreCase(action)) {
        PaymentStock paymentStock = new PaymentStock();
        PaymentStockDetail paymentStockDetail = new PaymentStockDetail();
        PaymentStockItem paymentStockItem = new PaymentStockItem();
        if (!"".equals(payNo)) {
            paymentStock = paymentStockService.getPaymentStockFromPayNo(payNo);
            if (paymentStock != null) {
                if (!paymentStock.getId().isEmpty()) {
                    request.setAttribute("totalCostAll",
                            paymentStock.getCostAmount() == null ? "" : paymentStock.getCostAmount());
                    request.setAttribute("totalSaleAll",
                            paymentStock.getSaleAmount() == null ? "" : paymentStock.getSaleAmount());
                    List<PaymentStockDetail> psdList = new ArrayList<PaymentStockDetail>();
                    List<PaymentStockDetail> paymentStockDetailList = paymentStockService
                            .getListPaymentStockDetailFromPaymentStockId(paymentStock.getId());
                    //                        List<PaymentStockItem> paymentStockItemList = paymentStockService.getListPaymentStockItemFromPaymentStockId(paymentStock.getId());
                    //                        request.setAttribute(PAYMENTSTOCKITEMLIST,paymentStockItemList);
                    List<StockDetail> stockDetailList = new ArrayList<StockDetail>();
                    if (paymentStockDetailList != null) {
                        for (int i = 0; i < paymentStockDetailList.size(); i++) {
                            BigDecimal cost = new BigDecimal(BigInteger.ZERO);
                            BigDecimal sale = new BigDecimal(BigInteger.ZERO);
                            PaymentStockDetail pad = paymentStockDetailList.get(i);
                            List<PaymentStockItem> paymentStockItems = new ArrayList<PaymentStockItem>(
                                    pad.getPaymentStockItems());
                            if (paymentStockItems != null) {
                                for (int k = 0; k < paymentStockItems.size(); k++) {
                                    PaymentStockItem psi = paymentStockItems.get(k);
                                    if (psi.getCost() != null) {
                                        cost = cost.add(psi.getCost());
                                    }/*from w w w . ja  va 2s . c  o m*/
                                    if (psi.getSale() != null) {
                                        sale = sale.add(psi.getSale());
                                    }
                                }
                            }
                            pad.setCost(cost);
                            pad.setSale(sale);
                            psdList.add(pad);
                            if (pad.getStock() != null) {
                                List<StockDetail> stockDetails = new ArrayList<StockDetail>(
                                        pad.getStock().getStockDetails());
                                if (stockDetails != null) {
                                    for (int j = 0; j < stockDetails.size(); j++) {
                                        StockDetail sd = new StockDetail();
                                        sd = stockDetails.get(j);
                                        stockDetailList.add(sd);
                                    }
                                }
                            }
                        }
                    }
                    request.setAttribute(STOCKDETAILLIST, stockDetailList);
                    request.setAttribute(PAYMENTSTOCKDETAILLIST, psdList);

                    if (paymentStockDetailList != null) {
                        request.setAttribute(NOSTOCKTABLE, paymentStockDetailList.size() + 1);
                    }
                    request.setAttribute(PAYMENTSTOCK, paymentStock);
                    request.setAttribute(CREATEDATE, String.valueOf(paymentStock.getCreateDate()));
                    List<PaymentStock> payList = new ArrayList<PaymentStock>();
                    payList.add(paymentStock);
                    request.setAttribute(PAYMENTSTOCKTEMP, payList);
                }
            } else {
                request.setAttribute(SEARCHRESULT, "searchfail");
            }
        }
    } else if ("deletePaymentStock".equalsIgnoreCase(action)) {
        String psdIdDelete = request.getParameter("psdIdDelete");
        System.out.println("psdIdDelete ::: " + psdIdDelete);
        String result = paymentStockService.deletePaymentStock(psdIdDelete);
        if (result == "success") {
            request.setAttribute(DELETERESULT, "delete successful");
        } else {
            request.setAttribute(DELETERESULT, "delete unsuccessful");
        }
    } else if ("savePaymentStock".equalsIgnoreCase(action)) {
        PaymentStock paymentStock = new PaymentStock();
        paymentStock.setId(payId);
        paymentStock.setPayStockNo(payNo);

        if ("".equalsIgnoreCase(payId)) {
            paymentStock.setCreateBy(user.getUsername());
            paymentStock.setCreateDate(new Date());
        } else {
            System.out.println(" createDate " + createDate);
            paymentStock.setCreateBy(createBy);
            paymentStock.setCreateDate(
                    utilty.convertStringToDate(new SimpleDateFormat("yyyy-MM-dd", new Locale("us", "us"))
                            .format(utilty.convertStringToDate(createDate))));
            paymentStock.setUpdateBy(user.getUsername());
            paymentStock.setUpdateDate(new Date());
        }

        //            totalcost = totalcost.add(new BigDecimal(String.valueOf(StringUtils.isNotEmpty(totalCostTempCal) ? totalCostTempCal.replaceAll(",","") : 0)));
        //            totalsale = totalsale.add(new BigDecimal(String.valueOf(StringUtils.isNotEmpty(totalSaleTempCal) ? totalSaleTempCal.replaceAll(",","") : 0)));

        paymentStock.setCurCost(curCost);
        paymentStock.setCurSale(curSale);

        String countRowStock = request.getParameter("countRowStock");
        String countRowDetail = request.getParameter("countRowDetail");
        countRowStock = noStockTable;
        System.out.println(" countRowStock " + countRowStock + "+++++++ countRowDetail " + countRowDetail);

        int rowsStock = Integer.parseInt(countRowStock);
        int rowsDetail = Integer.parseInt(countRowDetail);

        if (paymentStock.getPaymentStockDetails() == null) {
            paymentStock.setPaymentStockDetails(new ArrayList<PaymentStockDetail>());
        }

        for (int i = 1; i < rowsStock; i++) {
            String paymentStockId = request.getParameter("paymentStockId" + i);
            String stockId = request.getParameter("stockId" + i);
            String paymentStockDetailId = request.getParameter("paymentStockDetailId" + i);

            if (!"".equalsIgnoreCase(stockId) && stockId != null) {
                PaymentStockDetail psd = new PaymentStockDetail();
                psd.setId(paymentStockDetailId); // save Payment Stock Detail Id
                psd.setPaymentStock(paymentStock);

                Stock stock = new Stock(); // save Stock Id
                stock.setId(stockId);
                psd.setStock(stock);

                for (int j = 1; j < rowsDetail; j++) {
                    PaymentStockItem psi = new PaymentStockItem();
                    String psiIdTable = request.getParameter("psiIdTableTempCount" + j);
                    String psdIdTable = request.getParameter("psdIdTableTempCount" + j);
                    String stockDetailIdTable = request.getParameter("stockDetailIdTableTempCount" + j);
                    String cost = request.getParameter("costTempCount" + j);
                    String sale = request.getParameter("saleTempCount" + j);
                    String stockIdTable = request.getParameter("stockIdTableTempCount" + j);

                    if ((!"".equalsIgnoreCase(stockIdTable) && stockIdTable != null)
                            && (!"".equalsIgnoreCase(stockId) && stockId != null)) {
                        System.out.println(" stockId " + i + " ____ " + stockId);
                        System.out.println(" stockIdTable " + j + " ____ " + stockIdTable);
                        if (stockId.equalsIgnoreCase(stockIdTable)) {
                            if ((!"".equalsIgnoreCase(cost) && cost != null)
                                    || (!"".equalsIgnoreCase(sale) && sale != null)) {
                                System.out.println(" psiIdTable " + j + " ____ " + psiIdTable);
                                psi.setId(psiIdTable);
                                psi.setPaymentStockDetail(psd);

                                StockDetail stockDetail = new StockDetail();
                                stockDetail.setId(stockDetailIdTable);
                                psi.setStockDetail(stockDetail);
                                //                                    totalCostAll = totalCostAll.add(new BigDecimal(String.valueOf(StringUtils.isNotEmpty(cost) ? cost.replaceAll(",","") : 0)));
                                //                                    totalSaleAll = totalSaleAll.add(new BigDecimal(String.valueOf(StringUtils.isNotEmpty(sale) ? sale.replaceAll(",","") : 0)));
                                psi.setCost(new BigDecimal(String
                                        .valueOf(StringUtils.isNotEmpty(cost) ? cost.replaceAll(",", "") : 0)));
                                psi.setSale(new BigDecimal(String
                                        .valueOf(StringUtils.isNotEmpty(sale) ? sale.replaceAll(",", "") : 0)));
                                psd.getPaymentStockItems().add(psi);
                            }
                        }
                    }
                }
                paymentStock.getPaymentStockDetails().add(psd);
            }
        }
        //            paymentStock.setCostAmount(totalCostAll);
        //            paymentStock.setSaleAmount(totalSaleAll);
        saveresult = paymentStockService.insertOrUpdatePaymentStock(paymentStock);
        System.out.println(" saveresult " + saveresult);
        if ("fail".equalsIgnoreCase(saveresult)) {
            request.setAttribute(SAVERESULT, "save unsuccessful");
        } else if ("success".equalsIgnoreCase(saveresult)) {
            request.setAttribute(SAVERESULT, "save successful");
        } else {
            paymentStock.setPayStockNo(saveresult);
            request.setAttribute(SAVERESULT, "save successful");
        }
        request.setAttribute(PAYMENTSTOCK, paymentStock);

        List<PaymentStockDetail> paymentStockDetailList = paymentStockService
                .getListPaymentStockDetailFromPaymentStockId(paymentStock.getId());
        //            List<PaymentStockItem> paymentStockItemList = paymentStockService.getListPaymentStockItemFromPaymentStockId(paymentStock.getId());
        List<PaymentStock> payList = new ArrayList<PaymentStock>();
        payList.add(paymentStock);
        request.setAttribute(PAYMENTSTOCKTEMP, payList);
        List<PaymentStockDetail> psdList = new ArrayList<PaymentStockDetail>();
        List<StockDetail> stockDetailList = new ArrayList<StockDetail>();

        BigDecimal totalCostAll = new BigDecimal(0);
        BigDecimal totalSaleAll = new BigDecimal(0);

        if (paymentStockDetailList != null) {
            for (int i = 0; i < paymentStockDetailList.size(); i++) {
                BigDecimal cost = new BigDecimal(BigInteger.ZERO);
                BigDecimal sale = new BigDecimal(BigInteger.ZERO);
                PaymentStockDetail pad = paymentStockDetailList.get(i);
                List<PaymentStockItem> paymentStockItems = new ArrayList<PaymentStockItem>(
                        pad.getPaymentStockItems());
                if (paymentStockItems != null) {
                    for (int k = 0; k < paymentStockItems.size(); k++) {
                        PaymentStockItem psi = paymentStockItems.get(k);
                        if (psi.getCost() != null) {
                            cost = cost.add(psi.getCost());
                        }
                        if (psi.getSale() != null) {
                            sale = sale.add(psi.getSale());
                        }
                    }
                }
                pad.setCost(cost);
                pad.setSale(sale);
                totalCostAll = totalCostAll.add(cost);
                totalSaleAll = totalSaleAll.add(sale);
                psdList.add(pad);
                if (pad.getStock() != null) {
                    List<StockDetail> stockDetails = new ArrayList<StockDetail>(
                            pad.getStock().getStockDetails());
                    if (stockDetails != null) {
                        for (int j = 0; j < stockDetails.size(); j++) {
                            StockDetail sd = new StockDetail();
                            sd = stockDetails.get(j);
                            stockDetailList.add(sd);
                        }
                    }
                }
            }
        }
        System.out.println(" totalCostAll :::: " + totalCostAll);
        System.out.println(" totalSaleAll :::: " + totalSaleAll);
        paymentStockService.updateTotalCostAndSale(totalCostAll, totalSaleAll, paymentStock.getId());
        request.setAttribute("totalCostAll", totalCostAll);
        request.setAttribute("totalSaleAll", totalSaleAll);
        request.setAttribute(STOCKDETAILLIST, stockDetailList);
        request.setAttribute(PAYMENTSTOCKDETAILLIST, psdList);
        //            request.setAttribute(PAYMENTSTOCKDETAILLIST,paymentStockDetailList);
        //            request.setAttribute(PAYMENTSTOCKITEMLIST,paymentStockItemList);
        request.setAttribute(CREATEDATE, new SimpleDateFormat("yyyy-MM-dd", new Locale("us", "us"))
                .format(paymentStock.getCreateDate()));
        request.setAttribute(NOSTOCKTABLE, noStockTable);
    }

    setResponseAttribute(request);
    return PaymentStock;
}

From source file:com.gst.accounting.journalentry.service.JournalEntryWritePlatformServiceJpaRepositoryImpl.java

private void checkDebitAndCreditAmounts(final SingleDebitOrCreditEntryCommand[] credits,
        final SingleDebitOrCreditEntryCommand[] debits) {
    // sum of all debits must be = sum of all credits
    BigDecimal creditsSum = BigDecimal.ZERO;
    BigDecimal debitsSum = BigDecimal.ZERO;
    for (final SingleDebitOrCreditEntryCommand creditEntryCommand : credits) {
        if (creditEntryCommand.getAmount() == null || creditEntryCommand.getGlAccountId() == null) {
            throw new JournalEntryInvalidException(
                    GL_JOURNAL_ENTRY_INVALID_REASON.DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, null, null, null);
        }//w  w  w . j  av  a 2  s  .  co m
        creditsSum = creditsSum.add(creditEntryCommand.getAmount());
    }
    for (final SingleDebitOrCreditEntryCommand debitEntryCommand : debits) {
        if (debitEntryCommand.getAmount() == null || debitEntryCommand.getGlAccountId() == null) {
            throw new JournalEntryInvalidException(
                    GL_JOURNAL_ENTRY_INVALID_REASON.DEBIT_CREDIT_ACCOUNT_OR_AMOUNT_EMPTY, null, null, null);
        }
        debitsSum = debitsSum.add(debitEntryCommand.getAmount());
    }
    if (creditsSum.compareTo(debitsSum) != 0) {
        throw new JournalEntryInvalidException(GL_JOURNAL_ENTRY_INVALID_REASON.DEBIT_CREDIT_SUM_MISMATCH, null,
                null, null);
    }
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getAuthorizedStatementAmount() {
    BigDecimal total = new BigDecimal(0.0);
    Invoice[] authorizedStatementInvoices = getAuthorizedStatementInvoices();
    List<Invoice> tempList = new ArrayList<Invoice>();

    if (!ArrayUtils.isEmpty(authorizedStatementInvoices)) {
        for (int i = 0; i < authorizedStatementInvoices.length; i++) {
            total = total.add(authorizedStatementInvoices[i].getAmount());
            tempList.add(authorizedStatementInvoices[i]);
        }/*ww w.j  av a 2  s. com*/
    }
    return total;
}

From source file:com.gst.portfolio.savings.domain.SavingsAccountCharge.java

private BigDecimal calculateOutstanding() {

    BigDecimal amountPaidLocal = BigDecimal.ZERO;
    if (this.amountPaid != null) {
        amountPaidLocal = this.amountPaid;
    }/*from   www.  j a  v  a 2  s .  c om*/

    BigDecimal amountWaivedLocal = BigDecimal.ZERO;
    if (this.amountWaived != null) {
        amountWaivedLocal = this.amountWaived;
    }

    BigDecimal amountWrittenOffLocal = BigDecimal.ZERO;
    if (this.amountWrittenOff != null) {
        amountWrittenOffLocal = this.amountWrittenOff;
    }

    final BigDecimal totalAccountedFor = amountPaidLocal.add(amountWaivedLocal).add(amountWrittenOffLocal);

    return this.amount.subtract(totalAccountedFor);
}

From source file:com.aimluck.eip.project.ProjectTaskSelectData.java

/**
 * ResultData???? <BR>/*from w w w . ja va2  s .c  om*/
 *
 * @param record
 *          
 * @return ResultData
 */
@Override
protected Object getResultData(EipTProjectTask record) {
    ProjectTaskResultData data = ProjectUtils.getProjectTaskResultData(record);
    Integer taskId = (int) data.getTaskId().getValue();

    // ?
    int cntChild = ProjectUtils.getCountChildrenTask(taskId);

    // ??2??true
    // ??
    data.setHasChildren(cntChild >= 2);

    // ?
    data.setHasChildrenForForm(cntChild > 0);

    // ?
    int lapsedDays = ProjectUtils.getLapsedDays(ProjectUtils.toString(record.getStartPlanDate()),
            ProjectUtils.toString(Calendar.getInstance().getTime()));
    // 
    int taskDays = ProjectUtils.getLapsedDays(ProjectUtils.toString(record.getStartPlanDate()),
            ProjectUtils.toString(record.getEndPlanDate()));
    data.setPlanTerm(taskDays);

    if (lapsedDays > taskDays) {
        // ???
        lapsedDays = taskDays;
    }

    // ?
    data.setPlanProgressRate(ProjectUtils.getPlanWorkload(lapsedDays, taskDays));

    // 
    List<ProjectTaskMemberResultData> memberList = data.getMemberList();
    BigDecimal workload = BigDecimal.valueOf(0);
    workload = workload.setScale(1);
    for (int i = 0; i < memberList.size(); i++) {
        ProjectTaskMemberResultData member = memberList.get(i);
        workload = workload.add(member.getWorkload());
    }
    data.setWorkload(workload);

    // 
    BigDecimal forecastWorkload = BigDecimal.valueOf(0);
    if (data.getProgressRate().getValue() != 0) {
        forecastWorkload = workload.multiply(BigDecimal.valueOf(100))
                .divide(BigDecimal.valueOf(data.getProgressRate().getValue()), 2, BigDecimal.ROUND_HALF_UP);
    }
    data.setForecastWorkload(forecastWorkload);

    // 
    data.setIndentFlg(indentFlg);

    data.setEditable(ProjectFormUtils.isEditable(taskId, loginUserId));

    return data;
}