Search in sources :

Example 76 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class AbstractSlipController method handleEnterAction.

@FXML
@Override
public void handleEnterAction() {
    if (modTrans == null) {
        // new transaction
        Transaction newTrans = buildTransaction();
        ReconcileManager.reconcileTransaction(account.get(), newTrans, getReconciledState());
        // chain the transaction build
        newTrans = attachmentPane.buildTransaction(newTrans);
        final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
        if (engine != null) {
            if (!engine.addTransaction(newTrans)) {
                StaticUIMethods.displayError(resources.getString("Message.Error.TranAddFail"));
            }
        }
    } else {
        Transaction newTrans = buildTransaction();
        // restore the reconciled state of the previous old transaction
        for (final Account a : modTrans.getAccounts()) {
            if (!a.equals(account.get())) {
                ReconcileManager.reconcileTransaction(a, newTrans, modTrans.getReconciled(a));
            }
        }
        /*
                 * Reconcile the modified transaction for this account.
                 * This must be performed last to ensure consistent results per the ReconcileManager rules
                 */
        ReconcileManager.reconcileTransaction(account.get(), newTrans, getReconciledState());
        // chain the transaction build
        newTrans = attachmentPane.buildTransaction(newTrans);
        final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
        if (engine != null && engine.removeTransaction(modTrans)) {
            engine.addTransaction(newTrans);
        }
    }
    clearForm();
    focusFirstComponent();
}
Also used : Account(jgnash.engine.Account) Transaction(jgnash.engine.Transaction) Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 77 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class BudgetTableController method loadChildren.

private synchronized void loadChildren(final TreeItem<Account> parentItem) {
    final Account parent = parentItem.getValue();
    parent.getChildren(Comparators.getAccountByCode()).stream().filter(budgetResultsModel::includeAccount).forEach(child -> {
        final TreeItem<Account> childItem = new TreeItem<>(child);
        childItem.setExpanded(true);
        parentItem.getChildren().add(childItem);
        if (child.getChildCount() > 0) {
            loadChildren(childItem);
        }
    });
}
Also used : Account(jgnash.engine.Account) TreeItem(javafx.scene.control.TreeItem)

Example 78 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class BudgetTableController method calculateMinSummaryWidthColumnWidth.

private double calculateMinSummaryWidthColumnWidth() {
    double max = 0;
    for (final BudgetPeriodDescriptor descriptor : budgetResultsModel.getDescriptorList()) {
        max = Math.max(max, calculateMinColumnWidth(descriptor));
    }
    for (final Account account : expandedAccountList) {
        max = Math.max(max, calculateMinColumnWidth(account));
    }
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Budgeted") + BORDER_MARGIN, null));
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Actual") + BORDER_MARGIN, null));
    max = Math.max(max, JavaFXUtils.getDisplayedTextWidth(resources.getString("Column.Remaining") + BORDER_MARGIN, null));
    return Math.ceil(max);
}
Also used : Account(jgnash.engine.Account) BudgetPeriodDescriptor(jgnash.engine.budget.BudgetPeriodDescriptor)

Example 79 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class BudgetTableController method loadAccountTree.

private void loadAccountTree() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    final TreeItem<Account> root = new TreeItem<>(engine.getRootAccount());
    root.setExpanded(true);
    accountTreeView.setRoot(root);
    loadChildren(root);
}
Also used : Account(jgnash.engine.Account) TreeItem(javafx.scene.control.TreeItem) Engine(jgnash.engine.Engine)

Example 80 with Account

use of jgnash.engine.Account in project jgnash by ccavanaugh.

the class BasicRegisterTableController method getBalanceAt.

private BigDecimal getBalanceAt(final Transaction transaction) {
    BigDecimal balance = BigDecimal.ZERO;
    final Account account = this.account.get();
    if (account != null) {
        final int index = sortedList.indexOf(transaction);
        for (int i = 0; i <= index; i++) {
            balance = balance.add(sortedList.get(i).getAmount(account));
        }
    }
    return balance;
}
Also used : Account(jgnash.engine.Account) BigDecimal(java.math.BigDecimal)

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