Search in sources :

Example 1 with TransactionEntryReinvestDivX

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

the class ReinvestDividendPanel method modifyTransaction.

@Override
public void modifyTransaction(final Transaction tran) {
    if (!(tran instanceof InvestmentTransaction)) {
        throw new IllegalArgumentException("bad tranType");
    }
    clearForm();
    datePanel.setDate(tran.getLocalDate());
    List<TransactionEntry> entries = tran.getTransactionEntries();
    feePanel.setTransactionEntries(((InvestmentTransaction) tran).getInvestmentFeeEntries());
    gainsPanel.setTransactionEntries(((InvestmentTransaction) tran).getInvestmentGainLossEntries());
    entries.stream().filter(e -> e instanceof TransactionEntryReinvestDivX).forEach(e -> {
        AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
        memoField.setText(e.getMemo());
        priceField.setDecimal(entry.getPrice());
        quantityField.setDecimal(entry.getQuantity());
        securityCombo.setSelectedNode(entry.getSecurityNode());
    });
    updateTotalField();
    modTrans = tran;
    setReconciledState(tran.getReconciled(getAccount()));
}
Also used : FocusListener(java.awt.event.FocusListener) Transaction(jgnash.engine.Transaction) Collection(java.util.Collection) ValidationFactory(jgnash.ui.util.ValidationFactory) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) BigDecimal(java.math.BigDecimal) FocusAdapter(java.awt.event.FocusAdapter) List(java.util.List) FormLayout(com.jgoodies.forms.layout.FormLayout) FocusEvent(java.awt.event.FocusEvent) CellConstraints(com.jgoodies.forms.layout.CellConstraints) Account(jgnash.engine.Account) InvestmentTransaction(jgnash.engine.InvestmentTransaction) JPanel(javax.swing.JPanel) TransactionEntryReinvestDivX(jgnash.engine.TransactionEntryReinvestDivX) TransactionFactory(jgnash.engine.TransactionFactory) InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntryReinvestDivX(jgnash.engine.TransactionEntryReinvestDivX) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry)

Aggregations

CellConstraints (com.jgoodies.forms.layout.CellConstraints)1 FormLayout (com.jgoodies.forms.layout.FormLayout)1 FocusAdapter (java.awt.event.FocusAdapter)1 FocusEvent (java.awt.event.FocusEvent)1 FocusListener (java.awt.event.FocusListener)1 BigDecimal (java.math.BigDecimal)1 Collection (java.util.Collection)1 List (java.util.List)1 JPanel (javax.swing.JPanel)1 AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)1 Account (jgnash.engine.Account)1 InvestmentTransaction (jgnash.engine.InvestmentTransaction)1 Transaction (jgnash.engine.Transaction)1 TransactionEntry (jgnash.engine.TransactionEntry)1 TransactionEntryReinvestDivX (jgnash.engine.TransactionEntryReinvestDivX)1 TransactionFactory (jgnash.engine.TransactionFactory)1 ValidationFactory (jgnash.ui.util.ValidationFactory)1