Search in sources :

Example 11 with AccountType

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;
    });
}
Also used : LocalDateTime(java.time.LocalDateTime) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) LocalDate(java.time.LocalDate) AccountType(jgnash.engine.AccountType) BigDecimal(java.math.BigDecimal) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction)

Example 12 with AccountType

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()));
}
Also used : AccountType(jgnash.engine.AccountType)

Example 13 with AccountType

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);
    }
}
Also used : AccountType(jgnash.engine.AccountType)

Example 14 with AccountType

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);
}
Also used : ColumnStyle(jgnash.ui.report.jasper.ColumnStyle) Engine(jgnash.engine.Engine) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder) EngineFactory(jgnash.engine.EngineFactory) IconUtils(jgnash.ui.util.IconUtils) ResourceUtils(jgnash.util.ResourceUtils) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) ColumnHeaderStyle(jgnash.ui.report.jasper.ColumnHeaderStyle) ResourceBundle(java.util.ResourceBundle) AccountType(jgnash.engine.AccountType) CurrencyNode(jgnash.engine.CurrencyNode) DateUtils(jgnash.time.DateUtils) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JButton(javax.swing.JButton) Iterator(java.util.Iterator) Collection(java.util.Collection) Set(java.util.Set) DynamicJasperReport(jgnash.ui.report.jasper.DynamicJasperReport) ActionEvent(java.awt.event.ActionEvent) Collectors(java.util.stream.Collectors) Preferences(java.util.prefs.Preferences) AccountGroup(jgnash.engine.AccountGroup) Objects(java.util.Objects) List(java.util.List) AbstractAction(javax.swing.AbstractAction) DatePanel(jgnash.ui.components.DatePanel) FormLayout(com.jgoodies.forms.layout.FormLayout) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) JCheckBox(javax.swing.JCheckBox) Account(jgnash.engine.Account) AbstractReportTableModel(jgnash.ui.report.jasper.AbstractReportTableModel) Collections(java.util.Collections) JPanel(javax.swing.JPanel) Borders(com.jgoodies.forms.factories.Borders) Account(jgnash.engine.Account) ArrayList(java.util.ArrayList) Engine(jgnash.engine.Engine)

Example 15 with AccountType

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;
}
Also used : Account(jgnash.engine.Account) AccountType(jgnash.engine.AccountType) BigDecimal(java.math.BigDecimal)

Aggregations

AccountType (jgnash.engine.AccountType)15 Account (jgnash.engine.Account)8 BigDecimal (java.math.BigDecimal)7 LocalDate (java.time.LocalDate)6 Engine (jgnash.engine.Engine)6 ResourceBundle (java.util.ResourceBundle)3 CurrencyNode (jgnash.engine.CurrencyNode)3 DefaultFormBuilder (com.jgoodies.forms.builder.DefaultFormBuilder)2 FormLayout (com.jgoodies.forms.layout.FormLayout)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Objects (java.util.Objects)2 Set (java.util.Set)2 TreeSet (java.util.TreeSet)2 Preferences (java.util.prefs.Preferences)2 Collectors (java.util.stream.Collectors)2