use of jgnash.engine.Account in project jgnash by ccavanaugh.
the class AbstractCrosstabReport method getAccountList.
private static List<Account> getAccountList(final Set<AccountType> types) {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
List<Account> accounts = engine.getAccountList();
Iterator<Account> i = accounts.iterator();
search: while (i.hasNext()) {
Account a = i.next();
if (a.getTransactionCount() == 0) {
i.remove();
} else {
for (AccountType t : types) {
if (a.getAccountType() == t) {
continue search;
}
}
// made it here.. remove it
i.remove();
}
}
return accounts;
}
use of jgnash.engine.Account 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.Account in project jgnash by ccavanaugh.
the class RegisterTableController method handleJumpAction.
void handleJumpAction() {
Transaction t = selectedTransaction.get();
if (t != null) {
if (t.getTransactionType() == TransactionType.DOUBLEENTRY) {
final Set<Account> set = t.getAccounts();
set.stream().filter(a -> !account.get().equals(a)).forEach(a -> RegisterStage.getRegisterStage(a).show(t));
} else if (t.getTransactionType() == TransactionType.SPLITENTRY) {
final Account common = t.getCommonAccount();
if (!account.get().equals(common)) {
RegisterStage.getRegisterStage(common).show(t);
}
} else if (t instanceof InvestmentTransaction) {
final Account invest = ((InvestmentTransaction) t).getInvestmentAccount();
if (!account.get().equals(invest)) {
RegisterStage.getRegisterStage(invest).show(t);
}
}
}
}
use of jgnash.engine.Account in project jgnash by ccavanaugh.
the class RegisterTableController method initialize.
@FXML
void initialize() {
// table view displays the sorted list of data. The comparator property must be bound
tableView.setItems(sortedList);
sortedList.comparatorProperty().bind(tableView.comparatorProperty());
// Bind the account property
getAccountPropertyWrapper().accountProperty().bind(account);
accountNameLabel.textProperty().bind(getAccountPropertyWrapper().accountNameProperty());
balanceLabel.textProperty().bind(getAccountPropertyWrapper().accountBalanceProperty());
tableView.setTableMenuButtonVisible(true);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
// hide the horizontal scrollbar and prevent ghosting
tableView.getStylesheets().addAll(StyleClass.HIDE_HORIZONTAL_CSS);
// Load the table on change and set the row factory if the account in not locked
accountProperty().addListener((observable, oldValue, newValue) -> {
loadAccount();
if (!newValue.isLocked()) {
tableView.setRowFactory(new TransactionRowFactory());
}
numberFormat = CommodityFormat.getFullNumberFormat(newValue.getCurrencyNode());
});
selectedTransaction.bind(tableView.getSelectionModel().selectedItemProperty());
// Update the selection size property when the selection list changes
tableView.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Transaction>) c -> selectionSize.set(tableView.getSelectionModel().getSelectedIndices().size()));
selectionSize.addListener((observable, oldValue, newValue) -> {
if ((Integer) newValue > 1) {
final List<Transaction> transactions = new ArrayList<>(tableView.getSelectionModel().getSelectedItems());
BigDecimal total = BigDecimal.ZERO;
for (final Transaction transaction : transactions) {
if (transaction != null) {
total = total.add(transaction.getAmount(account.get()));
}
}
selectionSummaryTooltip.setText(numberFormat.format(AccountBalanceDisplayManager.convertToSelectedBalanceMode(account.get().getAccountType(), total)));
} else {
selectionSummaryTooltip.setText(null);
}
});
// For the table view to refresh itself if the mode changes
AccountBalanceDisplayManager.accountBalanceDisplayMode().addListener((observable, oldValue, newValue) -> tableView.refresh());
reconciledStateFilterComboBox.getItems().addAll(ReconciledStateEnum.values());
reconciledStateFilterComboBox.setValue(ReconciledStateEnum.ALL);
transactionAgeFilterComboBox.getItems().addAll(AgeEnum.values());
transactionAgeFilterComboBox.setValue(AgeEnum.ALL);
final ChangeListener<Object> filterChangeListener = (observable, oldValue, newValue) -> handleFilterChange();
reconciledStateFilterComboBox.valueProperty().addListener(filterChangeListener);
transactionAgeFilterComboBox.valueProperty().addListener(filterChangeListener);
// Rebuild filters when regex properties change
Options.regexForFiltersProperty().addListener(filterChangeListener);
if (memoFilterTextField != null) {
// memo filter may not have been initialized for all register types
memoFilterTextField.textProperty().addListener(filterChangeListener);
}
if (payeeFilterTextField != null) {
// payee filter may not have been initialized for all register types
payeeFilterTextField.textProperty().addListener(filterChangeListener);
}
// Repack the table if the font scale changes
ThemeManager.fontScaleProperty().addListener((observable, oldValue, newValue) -> tableViewManager.packTable());
// Listen for transaction events
MessageBus.getInstance().registerListener(messageBusHandler, MessageChannel.TRANSACTION);
}
use of jgnash.engine.Account in project jgnash by ccavanaugh.
the class SlipController method buildTransaction.
@NotNull
@Override
public Transaction buildTransaction() {
Transaction transaction;
final LocalDate date = datePicker.getValue();
if (!transactionEntries.isEmpty()) {
// build a split transaction
transaction = new Transaction();
transaction.setDate(date);
transaction.setNumber(numberComboBox.getValue());
transaction.setMemo(Options.concatenateMemosProperty().get() ? Transaction.CONCATENATE : memoTextField.getText());
transaction.setPayee(payeeTextField.getText());
transaction.addTransactionEntries(transactionEntries);
} else {
// double entry transaction
final int signum = amountField.getDecimal().signum();
final Account selectedAccount;
if (modTrans != null && modTrans.areAccountsHidden()) {
selectedAccount = getOppositeSideAccount(modTrans);
} else {
selectedAccount = accountExchangePane.getSelectedAccount();
}
if (slipType == SlipType.DECREASE && signum >= 0 || slipType == SlipType.INCREASE && signum == -1) {
if (hasEqualCurrencies()) {
transaction = TransactionFactory.generateDoubleEntryTransaction(selectedAccount, account.get(), amountField.getDecimal().abs(), date, memoTextField.getText(), payeeTextField.getText(), numberComboBox.getValue());
} else {
transaction = TransactionFactory.generateDoubleEntryTransaction(selectedAccount, account.get(), accountExchangePane.exchangeAmountProperty().get().abs(), amountField.getDecimal().abs().negate(), date, memoTextField.getText(), payeeTextField.getText(), numberComboBox.getValue());
}
} else {
if (hasEqualCurrencies()) {
transaction = TransactionFactory.generateDoubleEntryTransaction(account.get(), selectedAccount, amountField.getDecimal().abs(), date, memoTextField.getText(), payeeTextField.getText(), numberComboBox.getValue());
} else {
transaction = TransactionFactory.generateDoubleEntryTransaction(account.get(), selectedAccount, amountField.getDecimal().abs(), accountExchangePane.exchangeAmountProperty().get().abs().negate(), date, memoTextField.getText(), payeeTextField.getText(), numberComboBox.getValue());
}
}
}
ReconcileManager.reconcileTransaction(account.get(), transaction, getReconciledState());
return transaction;
}
Aggregations