Search in sources :

Example 26 with TransactionEntry

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

the class SplitTransactionSlipController method buildTransactionEntry.

@Override
TransactionEntry buildTransactionEntry() {
    TransactionEntry entry = new TransactionEntry();
    entry.setMemo(memoField.getText());
    int signum = amountField.getDecimal().signum();
    if ((slipType == SlipType.DECREASE && signum >= 0) || (slipType == SlipType.INCREASE && signum < 0)) {
        entry.setCreditAccount(accountExchangePane.getSelectedAccount());
        entry.setDebitAccount(account.get());
        if (hasEqualCurrencies()) {
            entry.setAmount(amountField.getDecimal().abs());
        } else {
            entry.setDebitAmount(amountField.getDecimal().abs().negate());
            entry.setCreditAmount(accountExchangePane.exchangeAmountProperty().get().abs());
        }
    } else {
        entry.setCreditAccount(account.get());
        entry.setDebitAccount(accountExchangePane.getSelectedAccount());
        if (hasEqualCurrencies()) {
            entry.setAmount(amountField.getDecimal().abs());
        } else {
            entry.setCreditAmount(amountField.getDecimal().abs());
            entry.setDebitAmount(accountExchangePane.exchangeAmountProperty().get().abs().negate());
        }
    }
    entry.setReconciled(account.get(), getReconciledState());
    return entry;
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Example 27 with TransactionEntry

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

the class FeeDialog method deleteAction.

@Override
void deleteAction() {
    final TransactionEntry entry = tableView.getSelectionModel().getSelectedItem();
    if (entry != null) {
        tableView.getSelectionModel().clearSelection();
        feeController.clearForm();
        getTransactionEntries().remove(entry);
    }
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Example 28 with TransactionEntry

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

the class AbstractTransactionEntryPanel method enterAction.

@Override
public void enterAction() {
    if (validateForm()) {
        TransactionEntry entry = buildTransactionEntry();
        if (oldEntry != null) {
            model.modifyTransaction(oldEntry, entry);
        } else {
            model.addTransaction(entry);
        }
        clearForm();
        fireOkAction();
    }
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Example 29 with TransactionEntry

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

the class IncomeTransactionEntryPanel method buildTransactionEntry.

@Override
public TransactionEntry buildTransactionEntry() {
    TransactionEntry entry = super.buildTransactionEntry();
    entry.setTransactionTag(TransactionTag.GAIN_LOSS);
    return entry;
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Example 30 with TransactionEntry

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

the class RegisterTableWithSplitEntriesModel method updateData.

/**
     * Update the internal data from the specified index. Note that this index is not relative to the account
     * transaction list but to the internal data.
     *
     * @param startIndex internal data index from which transactions need to updated.
     */
private void updateData(final int startIndex) {
    if (data == null) {
        data = new ArrayList<>(0);
    }
    while (data.size() > startIndex) {
        data.remove(startIndex);
    }
    for (Transaction t : account.getSortedTransactionList()) {
        if (data.size() >= startIndex) {
            data.add(new TransactionWrapper(t));
            if (t.getTransactionType() == TransactionType.SPLITENTRY && showSplitDetails) {
                /* Only detail split entries if 2 or more entries impact this account */
                int splitImpact = 0;
                // count the number of impacting entry(s)
                for (TransactionEntry e : t.getTransactionEntries()) {
                    if (e.getAmount(account).signum() != 0) {
                        splitImpact++;
                    }
                }
                // load only the entries that impact this account
                if (splitImpact > 1) {
                    data.addAll(t.getTransactionEntries().stream().filter(e -> e.getAmount(account).signum() != 0).map(e -> new TransactionWrapper(t, e)).collect(Collectors.toList()));
                }
            }
        }
    }
    // updating the balance cache too
    balanceCache.ensureCapacity(data.size());
    balanceCache.clear(startIndex);
}
Also used : EventQueue(java.awt.EventQueue) BigDecimal(java.math.BigDecimal) MessageProperty(jgnash.engine.message.MessageProperty) AccountBalanceDisplayManager(jgnash.ui.register.AccountBalanceDisplayManager) Transaction(jgnash.engine.Transaction) Account(jgnash.engine.Account) InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntry(jgnash.engine.TransactionEntry) Collectors(java.util.stream.Collectors) Message(jgnash.engine.message.Message) ArrayList(java.util.ArrayList) TransactionType(jgnash.engine.TransactionType) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntry(jgnash.engine.TransactionEntry)

Aggregations

TransactionEntry (jgnash.engine.TransactionEntry)52 InvestmentTransaction (jgnash.engine.InvestmentTransaction)16 Transaction (jgnash.engine.Transaction)16 BigDecimal (java.math.BigDecimal)13 AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)12 Account (jgnash.engine.Account)12 List (java.util.List)4 Logger (java.util.logging.Logger)4 TransactionFactory (jgnash.engine.TransactionFactory)4 NotNull (jgnash.util.NotNull)4 CellConstraints (com.jgoodies.forms.layout.CellConstraints)3 FormLayout (com.jgoodies.forms.layout.FormLayout)3 FocusAdapter (java.awt.event.FocusAdapter)3 FocusEvent (java.awt.event.FocusEvent)3 FocusListener (java.awt.event.FocusListener)3 FXML (javafx.fxml.FXML)3 JPanel (javax.swing.JPanel)3 Engine (jgnash.engine.Engine)3 ValidationFactory (jgnash.ui.util.ValidationFactory)3 LocalDate (java.time.LocalDate)2