Example usage for java.math BigDecimal negate

List of usage examples for java.math BigDecimal negate

Introduction

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

Prototype

public BigDecimal negate() 

Source Link

Document

Returns a BigDecimal whose value is (-this) , and whose scale is this.scale() .

Usage

From source file:com.repay.android.adddebt.AddDebtActivity.java

private void submitToDB() {
    try {// ww w . j  a  v a2s . c o  m
        if (mSelectedFriends.size() == 0) {
            throw new NullPointerException();

        } else if (mSelectedFriends.size() == 1) {
            BigDecimal latestAmount = new BigDecimal(mAmount.toString());
            if (mNegativeDebt) {
                latestAmount = latestAmount.negate();
            }
            if (mSplitAmount) {
                latestAmount = latestAmount.divide(BigDecimal.valueOf(2));
            }
            mDB.addDebt(mSelectedFriends.get(0).getRepayID(), latestAmount, mDescription);
            mSelectedFriends.get(0).setDebt(mSelectedFriends.get(0).getDebt().add(latestAmount));
            mDB.updateFriendRecord(mSelectedFriends.get(0));

        } else if (mSelectedFriends.size() > 1) {
            BigDecimal debtPerPerson;
            if (mSplitAmount) {
                int numOfPeeps = mSelectedFriends.size();
                Log.i(TAG, Integer.toString(numOfPeeps) + " people selected");
                numOfPeeps += (mInclMe) ? 1 : 0; // If is including me then add me into this
                Log.i(TAG, "isIncludingMe=" + Boolean.toString(mInclMe));
                debtPerPerson = new BigDecimal(mAmount.toString());
                debtPerPerson = debtPerPerson.divide(new BigDecimal(numOfPeeps), RoundingMode.CEILING);
            } else {
                debtPerPerson = new BigDecimal(mAmount.toString());
            }
            if (mNegativeDebt) {
                debtPerPerson = debtPerPerson.negate();
            }
            for (int i = 0; i <= mSelectedFriends.size() - 1; i++) {
                mDB.addDebt(mSelectedFriends.get(i).getRepayID(), debtPerPerson, mDescription);
                mSelectedFriends.get(i).setDebt(mSelectedFriends.get(i).getDebt().add(debtPerPerson));
                mDB.updateFriendRecord(mSelectedFriends.get(i));
            }
        }
        requestBackup();
        finish();
    } catch (SQLException e) {
        Toast.makeText(this, "Database Error", Toast.LENGTH_SHORT).show();
    } catch (NullPointerException e) {
        Toast.makeText(this, "Select a person and enter an amount first!", Toast.LENGTH_SHORT).show();
    } catch (NumberFormatException e) {
        Toast.makeText(this, "Please enter a valid amount!", Toast.LENGTH_SHORT).show();
    } catch (ArithmeticException e) {
        Toast.makeText(this, "You can't divide this number between this many people", Toast.LENGTH_SHORT)
                .show();
    }
}

From source file:com.liato.bankdroid.banking.banks.Steam.java

@Override
public void update() throws BankException, LoginException, BankChoiceException {
    super.update();
    if (username == null || password == null || username.length() == 0 || password.length() == 0) {
        throw new LoginException(res.getText(R.string.invalid_username_password).toString());
    }//w  w  w . j  av  a  2 s  .c o m
    urlopen = login();
    Matcher matcher = reBalance.matcher(response);
    if (matcher.find()) {
        /*
         * Capture groups:
         * GROUP                EXAMPLE DATA
         * 1: Amount            0,--&#8364;
         * 
         */
        String amount = Html.fromHtml(matcher.group(1)).toString().trim().replace("--", "00");
        Account account = new Account("Wallet", Helpers.parseBalance(amount), "1");
        String currency = Helpers.parseCurrency(amount, "USD");
        this.setCurrency(currency);
        account.setCurrency(currency);
        balance = balance.add(Helpers.parseBalance(amount));
        ArrayList<Transaction> transactions = new ArrayList<Transaction>();
        matcher = reTransactions.matcher(response);
        while (matcher.find()) {
            /*
             * Capture groups:
             * GROUP                EXAMPLE DATA
             * 1: Date              18 Oct 2007
             * 2: Amount            0,99&#8364;
             * 3: Event             Purchase
             * 4: Item              Team Fortress 2&nbsp;
             * 5: Sub item          Mann Co. Supply Crate Key
             * 
             */
            SimpleDateFormat sdfFrom = new SimpleDateFormat("d MMM yyyy");
            SimpleDateFormat sdfTo = new SimpleDateFormat("yyyy-MM-dd");
            Date transactionDate;
            try {
                transactionDate = sdfFrom.parse(matcher.group(1).trim());
                String strDate = sdfTo.format(transactionDate);
                BigDecimal price = Helpers
                        .parseBalance(Html.fromHtml(matcher.group(2)).toString().trim().replace("--", "00"));
                if ("Purchase".equalsIgnoreCase(matcher.group(3).trim())) {
                    price = price.negate();
                }
                transactions.add(new Transaction(strDate,
                        Html.fromHtml(matcher.group(4)).toString().trim()
                                + (Html.fromHtml(matcher.group(5)).toString().trim().length() > 1
                                        ? " (" + Html.fromHtml(matcher.group(5)).toString().trim() + ")"
                                        : ""),
                        price,
                        Helpers.parseCurrency(Html.fromHtml(matcher.group(2)).toString().trim(), "USD")));
            } catch (ParseException e) {
                Log.e(TAG, "Unable to parse date: " + matcher.group(1).trim());
            }
        }
        Collections.sort(transactions, Collections.reverseOrder());
        account.setTransactions(transactions);
        accounts.add(account);
    }
    if (accounts.isEmpty()) {
        throw new BankException(res.getText(R.string.no_accounts_found).toString());
    }
    super.updateComplete();
}

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

/**
 * Gets the balance of this GL account given child GL account.
 * @param childAccount a <code>GLAccountInTree</code> value
 * @return a <code>BigDecimal</code> value
 *//*from  w w w . ja v a2 s.  c  o  m*/
private BigDecimal getBalanceOfChildrenRec(GLAccountInTree childAccount) {
    if (childAccount == null) {
        return BigDecimal.ZERO;
    }
    BigDecimal balanceOfChildren = childAccount.balance;
    if ((childAccount.isDebitAccount && this.isCreditAccount)
            || (childAccount.isCreditAccount && this.isDebitAccount)) {
        balanceOfChildren = balanceOfChildren.negate();
    }

    for (GLAccountInTree grandchildAccount : childAccount.childAccounts) {
        balanceOfChildren = balanceOfChildren.add(getBalanceOfChildrenRec(grandchildAccount));
    }
    return balanceOfChildren;
}

From source file:org.kuali.kpme.tklm.leave.transfer.web.BalanceTransferMaintainableImpl.java

@Override
public void doRouteStatusChange(DocumentHeader documentHeader) {
    //ProcessDocReport pdr = new ProcessDocReport(true, "");
    String documentId = documentHeader.getDocumentNumber();
    BalanceTransfer balanceTransfer = (BalanceTransfer) this.getDataObject();
    DocumentService documentService = KRADServiceLocatorWeb.getDocumentService();
    balanceTransfer.setDocumentHeaderId(documentId);
    DocumentStatus newDocumentStatus = documentHeader.getWorkflowDocument().getStatus();
    String routedByPrincipalId = documentHeader.getWorkflowDocument().getRoutedByPrincipalId();
    /**/*from ww w .  j ava 2  s. co  m*/
     * TODO:
     * if (!document.getDocumentStatus().equals(statusChangeEvent.getNewRouteStatus())) {
     *    LmServiceLocator.getBalanceTransferService().saveOrUpdate(balanceTransfer)...??
     * }
     * 
     */
    if (DocumentStatus.ENROUTE.equals(newDocumentStatus)
            && CollectionUtils.isEmpty(balanceTransfer.getLeaveBlocks())) {
        // this is a balance transfer on a system scheduled time off leave block
        if (StringUtils.isNotEmpty(balanceTransfer.getSstoId())) {
            try {
                MaintenanceDocument md = (MaintenanceDocument) KRADServiceLocatorWeb.getDocumentService()
                        .getByDocumentHeaderId(documentId);
                balanceTransfer = LmServiceLocator.getBalanceTransferService().transferSsto(balanceTransfer);
                md.getDocumentHeader().setDocumentDescription(TKUtils.getDocumentDescription(
                        balanceTransfer.getPrincipalId(), balanceTransfer.getEffectiveLocalDate()));
                md.getNewMaintainableObject().setDataObject(balanceTransfer);
                documentService.saveDocument(md);
            } catch (WorkflowException e) {
                LOG.error(
                        "caught exception while handling doRouteStatusChange -> documentService.getByDocumentHeaderId("
                                + documentHeader.getDocumentNumber() + "). ",
                        e);
                throw new RuntimeException(
                        "caught exception while handling doRouteStatusChange -> documentService.getByDocumentHeaderId("
                                + documentHeader.getDocumentNumber() + "). ",
                        e);
            }
        } else {
            //when transfer document is routed, initiate the balance transfer - creating the leave blocks
            try {
                MaintenanceDocument md = (MaintenanceDocument) KRADServiceLocatorWeb.getDocumentService()
                        .getByDocumentHeaderId(documentId);
                md.getDocumentHeader().setDocumentDescription(TKUtils.getDocumentDescription(
                        balanceTransfer.getPrincipalId(), balanceTransfer.getEffectiveLocalDate()));
                balanceTransfer = LmServiceLocator.getBalanceTransferService().transfer(balanceTransfer);
                md.getNewMaintainableObject().setDataObject(balanceTransfer);
                documentService.saveDocument(md);
            } catch (WorkflowException e) {
                LOG.error(
                        "caught exception while handling doRouteStatusChange -> documentService.getByDocumentHeaderId("
                                + documentHeader.getDocumentNumber() + "). ",
                        e);
                throw new RuntimeException(
                        "caught exception while handling doRouteStatusChange -> documentService.getByDocumentHeaderId("
                                + documentHeader.getDocumentNumber() + "). ",
                        e);
            }
        }
    } else if (DocumentStatus.DISAPPROVED.equals(newDocumentStatus)) {
        /**
         * TODO: Remove disapproval action
         */
        // this is a balance transfer on a system scheduled time off leave block
        if (StringUtils.isNotEmpty(balanceTransfer.getSstoId())) {
            // put two accrual service generated leave blocks back, one accrued, one usage
            List<LeaveBlock> lbList = buildSstoLeaveBlockList(balanceTransfer);
            LmServiceLocator.getLeaveBlockService().saveLeaveBlocks(lbList);
        }
        //When transfer document is disapproved, set all leave block's request statuses to disapproved.
        for (LeaveBlock lb : balanceTransfer.getLeaveBlocks()) {
            if (ObjectUtils.isNotNull(lb)) {
                //lb.setRequestStatus(HrConstants.REQUEST_STATUS.DISAPPROVED);
                LmServiceLocator.getLeaveBlockService().deleteLeaveBlock(lb.getLmLeaveBlockId(),
                        routedByPrincipalId);
            }
        }
        //update status of document and associated leave blocks.
    } else if (DocumentStatus.FINAL.equals(newDocumentStatus)) {
        //When transfer document moves to final, set all leave block's request statuses to approved.
        for (LeaveBlock lb : balanceTransfer.getLeaveBlocks()) {
            if (ObjectUtils.isNotNull(lb)) {
                //TODO: What happens when an approver edits the fields in the transfer doc before approving?
                LeaveBlock.Builder builder = LeaveBlock.Builder.create(lb);
                builder.setRequestStatus(HrConstants.REQUEST_STATUS.APPROVED);
                LmServiceLocator.getLeaveBlockService().updateLeaveBlock(builder.build(), routedByPrincipalId);
            }
        }
        List<LeaveBlock> leaveBlocks = LmServiceLocator.getLeaveBlockService()
                .getLeaveBlocksForDocumentId(balanceTransfer.getLeaveCalendarDocumentId());
        for (LeaveBlock lb : leaveBlocks) {
            if (StringUtils.equals(lb.getAccrualCategory(), balanceTransfer.getFromAccrualCategory())
                    && StringUtils.equals(lb.getLeaveBlockType(),
                            LMConstants.LEAVE_BLOCK_TYPE.CARRY_OVER_ADJUSTMENT)) {
                BigDecimal adjustment = new BigDecimal(0);
                if (balanceTransfer.getTransferAmount() != null)
                    adjustment = adjustment.add(balanceTransfer.getTransferAmount().abs());
                if (balanceTransfer.getForfeitedAmount() != null)
                    adjustment = adjustment.add(balanceTransfer.getForfeitedAmount().abs());
                BigDecimal adjustedLeaveAmount = lb.getLeaveAmount().abs().subtract(adjustment);
                LeaveBlock.Builder builder = LeaveBlock.Builder.create(lb);
                builder.setLeaveAmount(adjustedLeaveAmount.negate());
                LmServiceLocator.getLeaveBlockService().updateLeaveBlock(builder.build(), routedByPrincipalId);
            }
        }
    } else if (DocumentStatus.CANCELED.equals(newDocumentStatus)) {
        //When transfer document is canceled, set all leave block's request statuses to deferred

        for (LeaveBlock lb : balanceTransfer.getLeaveBlocks()) {
            if (ObjectUtils.isNotNull(lb)) {
                LeaveBlock.Builder builder = LeaveBlock.Builder.create(lb);
                builder.setRequestStatus(HrConstants.REQUEST_STATUS.DEFERRED);
                LmServiceLocator.getLeaveBlockService().updateLeaveBlock(builder.build(), routedByPrincipalId);
            }
        }
    }
}

From source file:org.openvpms.archetype.rules.stock.ChargeStockUpdater.java

/**
 * Updates stock quantities when a charge item is saved.
 *
 * @param act the charge item act/*from  ww w. j  ava  2 s . c  om*/
 * @throws ArchetypeServiceException for any archetype service error
 */
private void updateChargeItem(FinancialAct act) {
    ActBean bean = new ActBean(act, service);
    boolean credit = bean.isA(CustomerAccountArchetypes.CREDIT_ITEM);

    StockQty current = new StockQty(bean);
    StockQty prior = getSavedStockQty(act);
    BigDecimal priorQty = BigDecimal.ZERO;

    if (prior != null && prior.isValid()) {
        priorQty = prior.getQuantity();
        if (!prior.hasProduct(current)) {
            updateStockQuantities(prior, priorQty.negate(), credit);
            priorQty = BigDecimal.ZERO;
        }
    }
    BigDecimal quantity = current.getQuantity();
    if (current.isValid()) {
        if (!MathRules.equals(quantity, priorQty)) {
            BigDecimal diff = quantity.subtract(priorQty);
            updateStockQuantities(current, diff, credit);
        }
    } else {
        bean.removeParticipation(STOCK_LOCATION_PARTICIPATION);
    }
}

From source file:se.frikod.payday.DailyBudgetFragment.java

public void editBudgetItem(final View v, final int currentIndex) {

    LayoutInflater inflater = activity.getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.daily_budget_edit_budget_item, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
    builder.setTitle(getString(R.string.edit_budget_item_title));

    final BudgetItem budgetItem;
    final EditText titleView = (EditText) dialogView.findViewById(R.id.budget_item_title);
    final Spinner typeView = (Spinner) dialogView.findViewById(R.id.budget_item_type);
    final EditText amountView = (EditText) dialogView.findViewById(R.id.budget_item_amount);

    if (currentIndex == NEW_BUDGET_ITEM) {
        budgetItem = null;/*from   w ww .  ja  v a2 s  .co m*/
        builder.setTitle(getString(R.string.add_budget_item_dialog_title));
        builder.setPositiveButton(R.string.add_budget_item, null);
    } else {
        builder.setTitle(getString(R.string.edit_budget_item_title));

        budgetItem = budget.budgetItems.get(currentIndex);

        String title = budgetItem.title;
        BigDecimal amount = budgetItem.amount;
        int type;
        if (amount.signum() < 0) {
            type = 0;
            amount = amount.negate();
        } else {
            type = 1;
        }

        titleView.setText(title);
        typeView.setSelection(type);
        amountView.setText(amount.toString());

        builder.setNeutralButton(getString(R.string.delete_budget_item_yes),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
                        vibrator.vibrate(100);
                        budget.budgetItems.remove(currentIndex);
                        budget.saveBudgetItems();
                        updateBudgetItems();
                        dialog.dismiss();
                    }

                });
        builder.setPositiveButton(R.string.update_budget_item, null);
    }

    builder.setNegativeButton(getString(R.string.delete_budget_item_no), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    /* onClick listener for update needs to be setup like this to
       prevent closing dialog on error
     */

    final AlertDialog d = builder.create();
    d.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
            assert b != null;
            b.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    BigDecimal amount;
                    try {
                        amount = new BigDecimal(amountView.getText().toString());
                        if (typeView.getSelectedItemId() == 0)
                            amount = amount.negate();
                    } catch (NumberFormatException e) {

                        Toast.makeText(activity.getApplicationContext(),
                                getString(R.string.new_budget_item_no_amount_specified), Toast.LENGTH_SHORT)
                                .show();

                        return;
                    }

                    String title = titleView.getText().toString();

                    if (budgetItem != null) {
                        budgetItem.amount = amount;
                        budgetItem.title = title;
                    } else {
                        budget.budgetItems.add(new BudgetItem(title, amount));
                    }

                    budget.saveBudgetItems();
                    updateBudgetItems();
                    d.dismiss();
                }
            });
        }
    });

    d.setView(dialogView);
    d.show();
}

From source file:jgnash.ui.report.compiled.IncomeExpensePieChart.java

private PieDataset createPieDataSet(Account a) {
    DefaultPieDataset returnValue = new DefaultPieDataset();
    if (a != null) {

        BigDecimal total = a.getTreeBalance(startField.getLocalDate(), endField.getLocalDate(),
                a.getCurrencyNode());/*  w ww. j  a  v  a 2 s. co m*/

        // abs() on all values won't work if children aren't of uniform sign,
        // then again, this chart is not right to display those trees
        boolean negate = total != null && total.floatValue() < 0;

        // accounts may have balances independent of their children
        BigDecimal value = a.getBalance(startField.getLocalDate(), endField.getLocalDate());

        if (value.compareTo(BigDecimal.ZERO) != 0) {
            returnValue.setValue(a, negate ? value.negate() : value);
        }

        for (final Account child : a.getChildren(Comparators.getAccountByCode())) {
            value = child.getTreeBalance(startField.getLocalDate(), endField.getLocalDate(),
                    a.getCurrencyNode());

            if (showEmptyCheck.isSelected() || value.compareTo(BigDecimal.ZERO) != 0) {
                returnValue.setValue(child, negate ? value.negate() : value);
            }
        }
    }
    return returnValue;
}

From source file:edu.zipcloud.cloudstreetmarket.core.services.CommunityServiceImpl.java

@Override
public void alterUserBalance(int quantity, StockQuote quote, User user, UserActivityType type,
        @Nullable CurrencyExchange currencyExchange) {
    BigDecimal priceInUserCurrency = TransactionUtil.getPriceInUserCurrency(quote, type, quantity, user,
            currencyExchange);/*from w  w  w  .j  a v  a2 s  .  c  o m*/

    if (UserActivityType.BUY.equals(type)) {
        user.setBalance(user.getBalance().add(priceInUserCurrency.negate()));
    } else if (UserActivityType.SELL.equals(type)) {
        user.setBalance(user.getBalance().add(priceInUserCurrency));
    }

    userRepository.save(user);
}

From source file:org.efaps.esjp.accounting.transaction.TransInfo_Base.java

/**
 * Gets the rel pos infos./* w w  w  .jav  a 2s . c  o m*/
 *
 * @param _parameter Parameter as passed by the eFaps API
 * @param _accInfo the acc info
 * @param _type the type
 * @return the rel pos infos
 * @throws EFapsException on error
 */
protected static List<PositionInfo> getRelPosInfos(final Parameter _parameter, final AccountInfo _accInfo,
        final Type _type) throws EFapsException {
    final List<PositionInfo> ret = new ArrayList<>();
    final boolean isDebitTrans = _type.getUUID().equals(CIAccounting.TransactionPositionDebit.uuid);
    final QueryBuilder queryBldr = new QueryBuilder(CIAccounting.Account2AccountAbstract);
    queryBldr.addWhereAttrEqValue(CIAccounting.Account2AccountAbstract.FromAccountLink, _accInfo.getInstance());
    final MultiPrintQuery multi = queryBldr.getPrint();
    final SelectBuilder selAcc = SelectBuilder.get().linkto(CIAccounting.Account2AccountAbstract.ToAccountLink)
            .instance();
    multi.addSelect(selAcc);
    multi.addAttribute(CIAccounting.Account2AccountAbstract.Numerator,
            CIAccounting.Account2AccountAbstract.Denominator, CIAccounting.Account2AccountAbstract.Config);
    multi.execute();
    int y = 1;
    while (multi.next()) {
        final Instance instance = multi.getCurrentInstance();
        final PositionInfo connPos = new PositionInfo();
        connPos.setPosType(TransPosType.CONNECTION);
        final BigDecimal numerator = new BigDecimal(
                multi.<Integer>getAttribute(CIAccounting.Account2AccountAbstract.Numerator));
        final BigDecimal denominator = new BigDecimal(
                multi.<Integer>getAttribute(CIAccounting.Account2AccountAbstract.Denominator));
        final Collection<Accounting.Account2AccountConfig> configs = multi
                .getAttribute(CIAccounting.Account2AccountAbstract.Config);

        final boolean confCheck = isDebitTrans && configs != null
                && configs.contains(Accounting.Account2AccountConfig.APPLY4DEBIT)
                || !isDebitTrans && configs != null
                        && configs.contains(Accounting.Account2AccountConfig.APPLY4CREDIT);

        if (confCheck) {
            BigDecimal amount = _accInfo.getAmountRate(_parameter).multiply(numerator).divide(denominator,
                    BigDecimal.ROUND_HALF_UP);
            BigDecimal rateAmount = _accInfo.getAmount().multiply(numerator).divide(denominator,
                    BigDecimal.ROUND_HALF_UP);
            if (isDebitTrans) {
                amount = amount.negate();
                rateAmount = rateAmount.negate();
            }
            if (instance.getType().getUUID().equals(CIAccounting.Account2AccountCosting.uuid)) {
                connPos.setType(_type);
            } else if (instance.getType().getUUID().equals(CIAccounting.Account2AccountCostingInverse.uuid)) {
                if (_type.getUUID().equals(CIAccounting.TransactionPositionDebit.uuid)) {
                    connPos.setType(CIAccounting.TransactionPositionCredit.getType());
                } else {
                    connPos.setType(CIAccounting.TransactionPositionDebit.getType());
                }
                amount = amount.negate();
            } else if (instance.getType().getUUID().equals(CIAccounting.Account2AccountCredit.uuid)) {
                if (isDebitTrans) {
                    connPos.setType(CIAccounting.TransactionPositionCredit.getType());
                } else {
                    connPos.setType(CIAccounting.TransactionPositionDebit.getType());
                    amount = amount.negate();
                    rateAmount = rateAmount.negate();
                }
            } else if (instance.getType().getUUID().equals(CIAccounting.Account2AccountDebit.uuid)) {
                if (isDebitTrans) {
                    connPos.setType(CIAccounting.TransactionPositionDebit.getType());
                    amount = amount.negate();
                    rateAmount = rateAmount.negate();
                } else {
                    connPos.setType(CIAccounting.TransactionPositionCredit.getType());
                }
            }
            if (connPos.getType() == null) {
                LOG.error("Missing definition");
            } else {
                connPos.setConnOrder(y).setAccInst(multi.<Instance>getSelect(selAcc)).setAmount(amount)
                        .setRateAmount(rateAmount);
                ret.add(connPos);
            }
            y++;
        }
    }
    return ret;
}

From source file:jgnash.ui.report.compiled.PayeePieChart.java

private PieDataset[] createPieDataSet(final Account a) {
    DefaultPieDataset[] returnValue = new DefaultPieDataset[2];
    returnValue[0] = new DefaultPieDataset();
    returnValue[1] = new DefaultPieDataset();

    if (a != null) {
        //System.out.print("Account = "); System.out.println(a);
        Map<String, BigDecimal> names = new HashMap<>();

        List<TranTuple> list = getTransactions(a, new ArrayList<>(), startField.getLocalDate(),
                endField.getLocalDate());

        CurrencyNode currency = a.getCurrencyNode();

        for (final TranTuple tranTuple : list) {

            Transaction tran = tranTuple.transaction;
            Account account = tranTuple.account;

            String payee = tran.getPayee();
            BigDecimal sum = tran.getAmount(account);

            sum = sum.multiply(account.getCurrencyNode().getExchangeRate(currency));

            //System.out.print("   Transaction = "); System.out.print(payee); System.out.print(" "); System.out.println(sum);

            if (useFilters.isSelected()) {
                for (String aFilterList : filterList) {

                    PayeeMatcher pm = new PayeeMatcher(aFilterList, false);

                    if (pm.matches(tran)) {
                        payee = aFilterList;
                        //System.out.println(filterList.get(i));
                        break;
                    }// w w w  .j a va  2 s .  com
                }
            }

            if (names.containsKey(payee)) {
                sum = sum.add(names.get(payee));
            }

            names.put(payee, sum);
        }

        for (final Map.Entry<String, BigDecimal> entry : names.entrySet()) {
            BigDecimal value = entry.getValue();

            if (value.compareTo(BigDecimal.ZERO) == -1) {
                value = value.negate();
                returnValue[1].setValue(entry.getKey(), value);
            } else {
                returnValue[0].setValue(entry.getKey(), value);
            }
        }
    }
    return returnValue;
}