use of jgnash.engine.AccountType in project jgnash by ccavanaugh.
the class BasicRegisterTableController method buildTable.
@Override
protected void buildTable() {
final String[] columnNames = RegisterFactory.getColumnNames(accountProperty().get().getAccountType());
final TableColumn<Transaction, LocalDate> dateColumn = new TableColumn<>(columnNames[0]);
dateColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getLocalDate()));
dateColumn.setCellFactory(cell -> new TransactionDateTableCell());
tableView.getColumns().add(dateColumn);
final TableColumn<Transaction, LocalDateTime> dateTimeColumn = new TableColumn<>(columnNames[1]);
dateTimeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getTimestamp()));
dateTimeColumn.setCellFactory(cell -> new TransactionDateTimeTableCell());
tableView.getColumns().add(dateTimeColumn);
final TableColumn<Transaction, String> numberColumn = new TableColumn<>(columnNames[2]);
numberColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getNumber()));
numberColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(numberColumn);
final TableColumn<Transaction, String> payeeColumn = new TableColumn<>(columnNames[3]);
payeeColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPayee()));
payeeColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(payeeColumn);
final TableColumn<Transaction, String> memoColumn = new TableColumn<>(columnNames[4]);
memoColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getMemo()));
memoColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(memoColumn);
final TableColumn<Transaction, String> accountColumn = new TableColumn<>(columnNames[5]);
accountColumn.setCellValueFactory(param -> new AccountNameWrapper(param.getValue()));
accountColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(accountColumn);
final TableColumn<Transaction, String> reconciledColumn = new TableColumn<>(columnNames[6]);
reconciledColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getReconciled(account.get()).toString()));
reconciledColumn.setCellFactory(cell -> new TransactionStringTableCell());
tableView.getColumns().add(reconciledColumn);
final TableColumn<Transaction, BigDecimal> increaseColumn = new TableColumn<>(columnNames[7]);
increaseColumn.setCellValueFactory(param -> new IncreaseAmountProperty(param.getValue().getAmount(accountProperty().getValue())));
increaseColumn.setCellFactory(cell -> new TransactionCommodityFormatTableCell(CommodityFormat.getShortNumberFormat(account.get().getCurrencyNode())));
tableView.getColumns().add(increaseColumn);
final TableColumn<Transaction, BigDecimal> decreaseColumn = new TableColumn<>(columnNames[8]);
decreaseColumn.setCellValueFactory(param -> new DecreaseAmountProperty(param.getValue().getAmount(accountProperty().getValue())));
decreaseColumn.setCellFactory(cell -> new TransactionCommodityFormatTableCell(CommodityFormat.getShortNumberFormat(account.get().getCurrencyNode())));
tableView.getColumns().add(decreaseColumn);
final TableColumn<Transaction, BigDecimal> balanceColumn = new TableColumn<>(columnNames[9]);
balanceColumn.setCellValueFactory(param -> {
final AccountType accountType = accountProperty().getValue().getAccountType();
return new SimpleObjectProperty<>(AccountBalanceDisplayManager.convertToSelectedBalanceMode(accountType, getBalanceAt(param.getValue())));
});
balanceColumn.setCellFactory(cell -> new TransactionCommodityFormatTableCell(CommodityFormat.getFullNumberFormat(account.get().getCurrencyNode())));
// do not allow a sort on the balance
balanceColumn.setSortable(false);
tableView.getColumns().add(balanceColumn);
tableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
tableViewManager.setColumnFormatFactory(param -> {
if (param == balanceColumn) {
return CommodityFormat.getFullNumberFormat(accountProperty().getValue().getCurrencyNode());
} else if (param == increaseColumn || param == decreaseColumn) {
return CommodityFormat.getShortNumberFormat(accountProperty().getValue().getCurrencyNode());
} else if (param == dateColumn) {
return DateUtils.getShortDateFormatter().toFormat();
} else if (param == dateTimeColumn) {
return DateUtils.getShortDateTimeFormatter().toFormat();
}
return null;
});
}
use of jgnash.engine.AccountType in project jgnash by ccavanaugh.
the class BankRegisterPaneController method buildTabs.
private void buildTabs() {
final AccountType accountType = accountProperty().get().getAccountType();
final String[] tabNames = RegisterFactory.getCreditDebitTabNames(accountType);
creditTab = buildTab(tabNames[0], SlipType.INCREASE);
debitTab = buildTab(tabNames[1], SlipType.DECREASE);
adjustTab = buildAdjustTab();
transactionForms.getTabs().addAll(creditTab, debitTab, buildTransferTab(), adjustTab);
if (accountType == AccountType.CHECKING || accountType == AccountType.CREDIT) {
transactionForms.getSelectionModel().select(debitTab);
} else if (accountType.getAccountGroup() == AccountGroup.INCOME) {
transactionForms.getSelectionModel().select(debitTab);
}
restoreLastTabUsed();
transactionForms.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue) -> saveLastTabUsed(newValue.intValue()));
}
use of jgnash.engine.AccountType in project jgnash by ccavanaugh.
the class TransactionDialog method buildTabs.
private void buildTabs() {
final AccountType accountType = accountProperty().get().getAccountType();
final String[] tabNames = RegisterFactory.getCreditDebitTabNames(accountType);
creditTab = buildTab(tabNames[0], SlipType.INCREASE);
debitTab = buildTab(tabNames[1], SlipType.DECREASE);
tabPane.getTabs().addAll(creditTab, debitTab);
if (accountType == AccountType.CHECKING || accountType == AccountType.CREDIT) {
tabPane.getSelectionModel().select(debitTab);
} else if (accountType.getAccountGroup() == AccountGroup.INCOME) {
tabPane.getSelectionModel().select(debitTab);
}
}
use of jgnash.engine.AccountType in project jgnash by ccavanaugh.
the class AbstractSumByTypeReport method getAccountList.
private static List<Account> getAccountList(final Set<AccountType> types) {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
Set<Account> accountSet = engine.getAccountList().stream().filter(a -> types.contains(a.getAccountType())).collect(Collectors.toCollection(TreeSet::new));
return new ArrayList<>(accountSet);
}
use of jgnash.engine.AccountType 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;
}
Aggregations