Search in sources :

Example 1 with InvestmentTransaction

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

the class DividendPanel method modifyTransaction.

@Override
public void modifyTransaction(Transaction tran) {
    if (!(tran instanceof InvestmentTransaction)) {
        throw new IllegalArgumentException("bad tranType");
    }
    clearForm();
    datePanel.setDate(tran.getLocalDate());
    List<TransactionEntry> entries = tran.getTransactionEntries();
    assert entries.size() <= 2;
    for (TransactionEntry e : entries) {
        if (e instanceof TransactionEntryDividendX) {
            AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
            memoField.setText(e.getMemo());
            securityCombo.setSelectedNode(entry.getSecurityNode());
            incomeExchangePanel.setSelectedAccount(entry.getDebitAccount());
            incomeExchangePanel.setExchangedAmount(entry.getDebitAmount().abs());
            dividendField.setDecimal(entry.getAmount(getAccount()));
        } else if (e.getTransactionTag() == TransactionTag.INVESTMENT_CASH_TRANSFER) {
            accountExchangePanel.setSelectedAccount(e.getCreditAccount());
            accountExchangePanel.setExchangedAmount(e.getCreditAmount());
        } else {
            logger.warning("Invalid transaction");
        }
    }
    modTrans = tran;
    setReconciledState(tran.getReconciled(getAccount()));
}
Also used : InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntryDividendX(jgnash.engine.TransactionEntryDividendX) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry)

Example 2 with InvestmentTransaction

use of jgnash.engine.InvestmentTransaction 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)

Example 3 with InvestmentTransaction

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

the class ReturnOfCapitalPanel method modifyTransaction.

@Override
public void modifyTransaction(Transaction tran) {
    if (!(tran instanceof InvestmentTransaction)) {
        throw new IllegalArgumentException("bad tranType");
    }
    clearForm();
    datePanel.setDate(tran.getLocalDate());
    List<TransactionEntry> entries = tran.getTransactionEntries();
    assert entries.size() <= 2;
    for (TransactionEntry e : entries) {
        if (e instanceof TransactionEntryRocX) {
            AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
            memoField.setText(e.getMemo());
            securityCombo.setSelectedNode(entry.getSecurityNode());
            incomeExchangePanel.setSelectedAccount(entry.getDebitAccount());
            incomeExchangePanel.setExchangedAmount(entry.getDebitAmount().abs());
            dividendField.setDecimal(entry.getAmount(getAccount()));
        } else if (e.getTransactionTag() == TransactionTag.INVESTMENT_CASH_TRANSFER) {
            accountExchangePanel.setSelectedAccount(e.getCreditAccount());
            accountExchangePanel.setExchangedAmount(e.getCreditAmount());
        } else {
            logger.warning("Invalid transaction");
        }
    }
    modTrans = tran;
    setReconciledState(tran.getReconciled(getAccount()));
}
Also used : InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntryRocX(jgnash.engine.TransactionEntryRocX) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry)

Example 4 with InvestmentTransaction

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

the class SplitMergeSharePanel method modifyTransaction.

@Override
public void modifyTransaction(final Transaction tran) {
    assert tran instanceof InvestmentTransaction;
    assert tran.getTransactionType() == TransactionType.SPLITSHARE || tran.getTransactionType() == TransactionType.MERGESHARE;
    InvestmentTransaction _tran = (InvestmentTransaction) tran;
    clearForm();
    modTrans = tran;
    datePanel.setDate(tran.getLocalDate());
    memoField.setText(tran.getTransactionMemo());
    priceField.setDecimal(_tran.getPrice());
    quantityField.setDecimal(_tran.getQuantity());
    securityCombo.setSelectedNode(_tran.getSecurityNode());
    setReconciledState(tran.getReconciled(getAccount()));
    updateTotalField();
}
Also used : InvestmentTransaction(jgnash.engine.InvestmentTransaction)

Example 5 with InvestmentTransaction

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

the class RegisterPanel method modifyTransaction.

@Override
protected void modifyTransaction(final int index) {
    if (index >= model.getRowCount()) {
        throw new IllegalArgumentException("RegisterPanel: should not have exceeded model size");
    }
    Transaction t = model.getTransactionAt(index);
    if (t instanceof InvestmentTransaction) {
        ((AbstractEntryFormPanel) tabbedPane.getSelectedComponent()).clearForm();
        InvestmentTransactionDialog.showDialog((InvestmentTransaction) t);
        return;
    }
    if (t.getTransactionType() == TransactionType.SINGLENTRY) {
        tabbedPane.setSelectedComponent(adjustPanel);
        adjustPanel.modifyTransaction(t);
    } else if (t.getAmount(account).signum() >= 0) {
        tabbedPane.setSelectedComponent(creditPanel);
        creditPanel.modifyTransaction(t);
    } else {
        tabbedPane.setSelectedComponent(debitPanel);
        debitPanel.modifyTransaction(t);
    }
}
Also used : InvestmentTransaction(jgnash.engine.InvestmentTransaction) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction)

Aggregations

InvestmentTransaction (jgnash.engine.InvestmentTransaction)26 Transaction (jgnash.engine.Transaction)17 TransactionEntry (jgnash.engine.TransactionEntry)12 BigDecimal (java.math.BigDecimal)11 AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)8 Account (jgnash.engine.Account)8 List (java.util.List)7 TransactionFactory (jgnash.engine.TransactionFactory)6 ChangeListener (javafx.beans.value.ChangeListener)4 FXML (javafx.fxml.FXML)4 Engine (jgnash.engine.Engine)4 TransactionType (jgnash.engine.TransactionType)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 NumberFormat (java.text.NumberFormat)3 ResourceBundle (java.util.ResourceBundle)3 Logger (java.util.logging.Logger)3