Search in sources :

Example 86 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class SplitsRegisterTableModel method getValueAt.

@Override
public Object getValueAt(final int row, final int col) {
    TransactionEntry t = transaction.getSplitAt(row);
    Account creditAccount = t.getCreditAccount();
    switch(col) {
        case 0:
            if (creditAccount != account) {
                return creditAccount.getName();
            }
            return t.getDebitAccount().getName();
        case 1:
            return t.getReconciled(account).toString();
        case 2:
            return t.getMemo();
        case 3:
            if (creditAccount == account) {
                return t.getAmount(account);
            }
            return null;
        case 4:
            if (creditAccount != account) {
                return t.getAmount(account).abs();
            }
            return null;
        case 5:
            return transaction.getRunningBalance(row + 1);
        default:
            return "";
    }
}
Also used : Account(jgnash.engine.Account) TransactionEntry(jgnash.engine.TransactionEntry)

Example 87 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class MonthlyAccountBalanceChartCompare method calculateTotal.

private static BigDecimal calculateTotal(final LocalDate start, final LocalDate end, final Account account, boolean recursive, final CurrencyNode baseCurrency) {
    BigDecimal amount;
    AccountType type = account.getAccountType();
    // get the amount for the account                
    amount = AccountBalanceDisplayManager.convertToSelectedBalanceMode(type, account.getBalance(start, end, baseCurrency));
    if (recursive) {
        // add the amount of every sub accounts
        for (final Account child : account.getChildren(Comparators.getAccountByCode())) {
            amount = amount.add(calculateTotal(start, end, child, true, baseCurrency));
        }
    }
    return amount;
}
Also used : Account(jgnash.engine.Account) AccountType(jgnash.engine.AccountType) BigDecimal(java.math.BigDecimal)

Example 88 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class IncomeExpensePieChart method createPieDataSet.

private PieDataset createPieDataSet(Account a) {
    DefaultPieDataset returnValue = new DefaultPieDataset();
    if (a != null) {
        BigDecimal total = a.getTreeBalance(startField.getLocalDate(), endField.getLocalDate(), a.getCurrencyNode());
        // 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;
}
Also used : RootAccount(jgnash.engine.RootAccount) Account(jgnash.engine.Account) DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) BigDecimal(java.math.BigDecimal)

Example 89 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class AbstractAccountTreeController method loadChildren.

private synchronized void loadChildren(final TreeItem<Account> parentItem) {
    final Account parent = parentItem.getValue();
    parent.getChildren(Comparators.getAccountByCode()).stream().filter(child -> !filteredAccounts.contains(child) && isAccountVisible(child)).forEach(child -> {
        final TreeItem<Account> childItem = new TreeItem<>(child);
        childItem.setExpanded(true);
        parentItem.getChildren().add(childItem);
        if (child.getChildCount() > 0) {
            loadChildren(childItem);
        }
    });
}
Also used : Engine(jgnash.engine.Engine) ObservableSet(javafx.collections.ObservableSet) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) Comparators(jgnash.engine.Comparators) TreeItem(javafx.scene.control.TreeItem) EngineFactory(jgnash.engine.EngineFactory) SetChangeListener(javafx.collections.SetChangeListener) FXCollections(javafx.collections.FXCollections) MessageBus(jgnash.engine.message.MessageBus) TreeSet(java.util.TreeSet) TreeView(javafx.scene.control.TreeView) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) Objects(java.util.Objects) Nullable(jgnash.util.Nullable) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) MessageChannel(jgnash.engine.message.MessageChannel) Account(jgnash.engine.Account) Message(jgnash.engine.message.Message) MessageListener(jgnash.engine.message.MessageListener) TreeSearch(jgnash.uifx.util.TreeSearch) Account(jgnash.engine.Account) TreeItem(javafx.scene.control.TreeItem)

Example 90 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class AbstractAccountTreeController method loadAccountTree.

private void loadAccountTree() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    if (engine != null) {
        final TreeItem<Account> root = new TreeItem<>(engine.getRootAccount());
        root.setExpanded(true);
        getTreeView().setRoot(root);
        loadChildren(root);
    } else {
        getTreeView().setRoot(null);
    }
}
Also used : Account(jgnash.engine.Account) TreeItem(javafx.scene.control.TreeItem) Engine(jgnash.engine.Engine)

Aggregations

Account (jgnash.engine.Account)132 Engine (jgnash.engine.Engine)44 BigDecimal (java.math.BigDecimal)40 CurrencyNode (jgnash.engine.CurrencyNode)28 Transaction (jgnash.engine.Transaction)27 ArrayList (java.util.ArrayList)22 LocalDate (java.time.LocalDate)21 ResourceBundle (java.util.ResourceBundle)19 RootAccount (jgnash.engine.RootAccount)18 List (java.util.List)15 AccountType (jgnash.engine.AccountType)15 NumberFormat (java.text.NumberFormat)14 FXML (javafx.fxml.FXML)13 EngineFactory (jgnash.engine.EngineFactory)13 Objects (java.util.Objects)12 Collections (java.util.Collections)11 InvestmentTransaction (jgnash.engine.InvestmentTransaction)11 Tooltip (javafx.scene.control.Tooltip)10 Preferences (java.util.prefs.Preferences)9 Platform (javafx.application.Platform)9