Search in sources :

Example 36 with Transaction

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

the class RecurringEntryDialog method editTransactionAction.

private void editTransactionAction() {
    Transaction t = TransactionDialog.showDialog(accountCombo.getSelectedAccount(), transaction);
    if (t != null) {
        transaction = t;
        transactionField.setText(transaction.getPayee());
    }
}
Also used : Transaction(jgnash.engine.Transaction)

Example 37 with Transaction

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

the class AbstractBankTransactionPanel method modifyTransactionForAutoComplete.

/**
     * Modify a transaction before it is used to complete the panel for auto fill. The supplied transaction must be a
     * new or cloned transaction. It can't be a transaction that lives in the map. The returned transaction can be the
     * supplied reference or may be a new instance
     *
     * @param t The transaction to modify
     * @return the modified transaction
     */
private Transaction modifyTransactionForAutoComplete(final Transaction t) {
    // tweak the transaction
    t.setNumber(null);
    // clear both sides        
    t.setReconciled(ReconciledState.NOT_RECONCILED);
    // set the last date as required
    if (!getRememberLastDate()) {
        t.setDate(LocalDate.now());
    } else {
        t.setDate(datePanel.getLocalDate());
    }
    // preserve any transaction entries that may have been entered first
    if (!amountField.isEmpty() && !amountField.getText().isEmpty()) {
        Transaction newTrans = buildTransaction();
        t.clearTransactionEntries();
        t.addTransactionEntries(newTrans.getTransactionEntries());
    }
    // preserve any preexisting memo field info
    if (memoField.getText() != null && !memoField.getText().isEmpty()) {
        t.setMemo(memoField.getText());
    }
    // Do not copy over attachments
    t.setAttachment(null);
    return t;
}
Also used : Transaction(jgnash.engine.Transaction)

Example 38 with Transaction

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

the class AbstractRegisterPanel method messagePosted.

@Override
public void messagePosted(final Message event) {
    final Account account = getAccount();
    // must update on EDT or a deadlock can occur
    EventQueue.invokeLater(() -> {
        Account a = event.getObject(MessageProperty.ACCOUNT);
        if (account.equals(a)) {
            switch(event.getEvent()) {
                case ACCOUNT_MODIFY:
                    updateAccountState();
                    updateAccountInfo();
                    break;
                case TRANSACTION_ADD:
                    final Transaction t = event.getObject(MessageProperty.TRANSACTION);
                    final int index = account.indexOf(t);
                    if (index == account.getTransactionCount() - 1) {
                        autoScroll();
                    }
                    setSelectedTransaction(t);
                    updateAccountInfo();
                    break;
                case TRANSACTION_REMOVE:
                    updateAccountInfo();
                    break;
                default:
                    break;
            }
        }
        if (event.getEvent() == ChannelEvent.SECURITY_HISTORY_ADD || event.getEvent() == ChannelEvent.SECURITY_HISTORY_REMOVE) {
            SecurityNode node = event.getObject(MessageProperty.COMMODITY);
            if (account.containsSecurity(node)) {
                updateAccountInfo();
            }
        }
    });
}
Also used : Account(jgnash.engine.Account) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) SecurityNode(jgnash.engine.SecurityNode)

Example 39 with Transaction

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

the class AbstractRegisterPanel method reconcileAction.

private void reconcileAction(final ReconciledState reconciled) {
    final Transaction t = getSelectedTransaction();
    if (t != null) {
        final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
        Objects.requireNonNull(engine);
        engine.setTransactionReconciled(t, getAccount(), reconciled);
    }
}
Also used : Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) Engine(jgnash.engine.Engine)

Example 40 with Transaction

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

the class ImportPageTwoController method getSettings.

@Override
public void getSettings(final Map<ImportWizard.Settings, Object> map) {
    @SuppressWarnings("unchecked") final ImportBank<ImportTransaction> bank = (ImportBank<ImportTransaction>) map.get(ImportWizard.Settings.BANK);
    if (bank != null) {
        final List<ImportTransaction> list = bank.getTransactions();
        baseAccount = (Account) map.get(ImportWizard.Settings.ACCOUNT);
        final CurrencyNode currencyNode = baseAccount.getCurrencyNode();
        // rescale for consistency
        numberFormat.setMinimumFractionDigits(currencyNode.getScale());
        numberFormat.setMaximumFractionDigits(currencyNode.getScale());
        // List of enabled import filters
        final List<ImportFilter> importFilterList = ImportFilter.getEnabledImportFilters();
        // set to sane account assuming it's going to be a single entry
        for (final ImportTransaction t : list) {
            // Process transactions with the import filter
            for (final ImportFilter importFilter : importFilterList) {
                t.setMemo(importFilter.processMemo(t.getMemo()));
                t.setPayee(importFilter.processPayee(t.getPayee()));
            }
            if (t.getTransactionType() != TransactionType.REINVESTDIV) {
                t.setAccount(baseAccount);
            }
            if (t.isInvestmentTransaction()) {
                switch(t.getTransactionType()) {
                    case BUYSHARE:
                        t.setFeesAccount(baseAccount);
                        break;
                    case SELLSHARE:
                        t.setFeesAccount(baseAccount);
                        t.setGainsAccount(baseAccount);
                        break;
                    case DIVIDEND:
                        t.setGainsAccount(baseAccount);
                        break;
                    case REINVESTDIV:
                        t.setFeesAccount(baseAccount);
                        t.setGainsAccount(baseAccount);
                        break;
                    default:
                }
            }
            // force reset
            t.setState(ImportState.NEW);
        }
        incomeAccountColumn.setVisible(bank.isInvestmentAccount());
        expenseAccountColumn.setVisible(bank.isInvestmentAccount());
        typeColumn.setVisible(bank.isInvestmentAccount());
        // match up any pre-existing transactions
        GenericImport.matchTransactions(list, baseAccount);
        // classify the transactions
        if (Options.globalBayesProperty().get()) {
            final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
            Objects.requireNonNull(engine);
            final List<Transaction> transactions = engine.getTransactions();
            transactions.sort(null);
            BayesImportClassifier.classifyTransactions(list, transactions, baseAccount);
        } else {
            BayesImportClassifier.classifyTransactions(list, baseAccount.getSortedTransactionList(), baseAccount);
        }
        tableView.getItems().setAll(list);
        FXCollections.sort(tableView.getItems());
        tableViewManager.restoreLayout();
    }
    Platform.runLater(tableViewManager::packTable);
    updateDescriptor();
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) ImportFilter(jgnash.convert.imports.ImportFilter) Transaction(jgnash.engine.Transaction) ImportTransaction(jgnash.convert.imports.ImportTransaction) ImportBank(jgnash.convert.imports.ImportBank) Engine(jgnash.engine.Engine) ImportTransaction(jgnash.convert.imports.ImportTransaction)

Aggregations

Transaction (jgnash.engine.Transaction)81 InvestmentTransaction (jgnash.engine.InvestmentTransaction)39 Account (jgnash.engine.Account)27 BigDecimal (java.math.BigDecimal)24 Engine (jgnash.engine.Engine)22 TransactionEntry (jgnash.engine.TransactionEntry)18 NotNull (jgnash.util.NotNull)13 List (java.util.List)10 LocalDate (java.time.LocalDate)9 FXML (javafx.fxml.FXML)9 AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)9 ArrayList (java.util.ArrayList)7 TransactionType (jgnash.engine.TransactionType)7 ResourceBundle (java.util.ResourceBundle)6 TransactionFactory (jgnash.engine.TransactionFactory)6 NumberFormat (java.text.NumberFormat)5 Objects (java.util.Objects)5 ChangeListener (javafx.beans.value.ChangeListener)5 EngineFactory (jgnash.engine.EngineFactory)5 Message (jgnash.engine.message.Message)5