Search in sources :

Example 61 with Account

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

Example 62 with Account

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);
}
Also used : ColumnStyle(jgnash.ui.report.jasper.ColumnStyle) Engine(jgnash.engine.Engine) EngineFactory(jgnash.engine.EngineFactory) 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) Iterator(java.util.Iterator) Collection(java.util.Collection) CheckBox(javafx.scene.control.CheckBox) Set(java.util.Set) Collectors(java.util.stream.Collectors) Preferences(java.util.prefs.Preferences) AccountGroup(jgnash.engine.AccountGroup) Objects(java.util.Objects) FXML(javafx.fxml.FXML) List(java.util.List) Row(jgnash.ui.report.Row) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) Account(jgnash.engine.Account) AbstractReportTableModel(jgnash.ui.report.jasper.AbstractReportTableModel) Collections(java.util.Collections) DatePickerEx(jgnash.uifx.control.DatePickerEx) Account(jgnash.engine.Account) ArrayList(java.util.ArrayList) Engine(jgnash.engine.Engine)

Example 63 with Account

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);
            }
        }
    }
}
Also used : Engine(jgnash.engine.Engine) TransactionAgePredicate(jgnash.util.function.TransactionAgePredicate) TableViewManager(jgnash.uifx.util.TableViewManager) MessageBus(jgnash.engine.message.MessageBus) BigDecimal(java.math.BigDecimal) MessageProperty(jgnash.engine.message.MessageProperty) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) ComboBox(javafx.scene.control.ComboBox) MessageChannel(jgnash.engine.message.MessageChannel) ContextMenu(javafx.scene.control.ContextMenu) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) TableView(javafx.scene.control.TableView) MemoPredicate(jgnash.util.function.MemoPredicate) MessageListener(jgnash.engine.message.MessageListener) SortedList(javafx.collections.transformation.SortedList) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Predicate(java.util.function.Predicate) RecurringEntryDialog(jgnash.uifx.views.recurring.RecurringEntryDialog) FilteredList(javafx.collections.transformation.FilteredList) Set(java.util.Set) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) TransactionType(jgnash.engine.TransactionType) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) List(java.util.List) ReconciledPredicate(jgnash.util.function.ReconciledPredicate) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) Message(jgnash.engine.message.Message) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Transaction(jgnash.engine.Transaction) EngineFactory(jgnash.engine.EngineFactory) ResourceUtils(jgnash.util.ResourceUtils) FXCollections(javafx.collections.FXCollections) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) ResourceBundle(java.util.ResourceBundle) AccountBalanceDisplayManager(jgnash.uifx.views.AccountBalanceDisplayManager) InvestmentTransaction(jgnash.engine.InvestmentTransaction) Callback(javafx.util.Callback) ThemeManager(jgnash.uifx.skin.ThemeManager) Tooltip(javafx.scene.control.Tooltip) ReconciledState(jgnash.engine.ReconciledState) ObjectProperty(javafx.beans.property.ObjectProperty) Label(javafx.scene.control.Label) TableRow(javafx.scene.control.TableRow) Reminder(jgnash.engine.recurring.Reminder) Menu(javafx.scene.control.Menu) TimeUnit(java.util.concurrent.TimeUnit) CommodityFormat(jgnash.text.CommodityFormat) ChronoUnit(java.time.temporal.ChronoUnit) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) StyleClass(jgnash.uifx.skin.StyleClass) Account(jgnash.engine.Account) PayeePredicate(jgnash.util.function.PayeePredicate) ChangeListener(javafx.beans.value.ChangeListener) Collections(java.util.Collections) Options(jgnash.uifx.Options) Account(jgnash.engine.Account) InvestmentTransaction(jgnash.engine.InvestmentTransaction) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction)

Example 64 with Account

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);
}
Also used : Engine(jgnash.engine.Engine) TransactionAgePredicate(jgnash.util.function.TransactionAgePredicate) TableViewManager(jgnash.uifx.util.TableViewManager) MessageBus(jgnash.engine.message.MessageBus) BigDecimal(java.math.BigDecimal) MessageProperty(jgnash.engine.message.MessageProperty) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) ListChangeListener(javafx.collections.ListChangeListener) ComboBox(javafx.scene.control.ComboBox) MessageChannel(jgnash.engine.message.MessageChannel) ContextMenu(javafx.scene.control.ContextMenu) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) TableView(javafx.scene.control.TableView) MemoPredicate(jgnash.util.function.MemoPredicate) MessageListener(jgnash.engine.message.MessageListener) SortedList(javafx.collections.transformation.SortedList) TextField(javafx.scene.control.TextField) MenuItem(javafx.scene.control.MenuItem) Predicate(java.util.function.Predicate) RecurringEntryDialog(jgnash.uifx.views.recurring.RecurringEntryDialog) FilteredList(javafx.collections.transformation.FilteredList) Set(java.util.Set) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) TransactionType(jgnash.engine.TransactionType) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) List(java.util.List) ReconciledPredicate(jgnash.util.function.ReconciledPredicate) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) Message(jgnash.engine.message.Message) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Transaction(jgnash.engine.Transaction) EngineFactory(jgnash.engine.EngineFactory) ResourceUtils(jgnash.util.ResourceUtils) FXCollections(javafx.collections.FXCollections) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) ResourceBundle(java.util.ResourceBundle) AccountBalanceDisplayManager(jgnash.uifx.views.AccountBalanceDisplayManager) InvestmentTransaction(jgnash.engine.InvestmentTransaction) Callback(javafx.util.Callback) ThemeManager(jgnash.uifx.skin.ThemeManager) Tooltip(javafx.scene.control.Tooltip) ReconciledState(jgnash.engine.ReconciledState) ObjectProperty(javafx.beans.property.ObjectProperty) Label(javafx.scene.control.Label) TableRow(javafx.scene.control.TableRow) Reminder(jgnash.engine.recurring.Reminder) Menu(javafx.scene.control.Menu) TimeUnit(java.util.concurrent.TimeUnit) CommodityFormat(jgnash.text.CommodityFormat) ChronoUnit(java.time.temporal.ChronoUnit) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) StyleClass(jgnash.uifx.skin.StyleClass) Account(jgnash.engine.Account) PayeePredicate(jgnash.util.function.PayeePredicate) ChangeListener(javafx.beans.value.ChangeListener) Collections(java.util.Collections) Options(jgnash.uifx.Options) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal) FXML(javafx.fxml.FXML)

Example 65 with Account

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;
}
Also used : Account(jgnash.engine.Account) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) LocalDate(java.time.LocalDate) NotNull(jgnash.util.NotNull)

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