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 "";
}
}
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;
}
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;
}
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);
}
});
}
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);
}
}
Aggregations