Search in sources :

Example 1 with AbstractInvestmentTransactionEntry

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

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

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

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

the class BuyShareSlipController method modifyTransaction.

@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
    if (transaction.getTransactionType() != TransactionType.BUYSHARE || !(transaction instanceof InvestmentTransaction)) {
        throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
    }
    clearForm();
    datePicker.setValue(transaction.getLocalDate());
    numberComboBox.setValue(transaction.getNumber());
    List<TransactionEntry> entries = transaction.getTransactionEntries();
    feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
    entries.stream().filter(e -> e instanceof TransactionEntryBuyX).forEach(e -> {
        final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
        memoTextField.setText(e.getMemo());
        priceField.setDecimal(entry.getPrice());
        quantityField.setDecimal(entry.getQuantity());
        securityComboBox.setSecurityNode(entry.getSecurityNode());
        if (entry.getCreditAccount().equals(accountProperty().get())) {
            accountExchangePane.setSelectedAccount(entry.getDebitAccount());
            accountExchangePane.setExchangedAmount(entry.getDebitAmount().abs());
        } else {
            accountExchangePane.setSelectedAccount(entry.getCreditAccount());
            accountExchangePane.setExchangedAmount(entry.getCreditAmount());
        }
    });
    modTrans = transaction;
    modTrans = attachmentPane.modifyTransaction(modTrans);
    setReconciledState(transaction.getReconciled(accountProperty().get()));
}
Also used : FXML(javafx.fxml.FXML) BigDecimal(java.math.BigDecimal) List(java.util.List) NotNull(jgnash.util.NotNull) Transaction(jgnash.engine.Transaction) TransactionEntryBuyX(jgnash.engine.TransactionEntryBuyX) InvestmentTransaction(jgnash.engine.InvestmentTransaction) ChangeListener(javafx.beans.value.ChangeListener) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionFactory(jgnash.engine.TransactionFactory) TransactionType(jgnash.engine.TransactionType) InvestmentTransaction(jgnash.engine.InvestmentTransaction) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionEntryBuyX(jgnash.engine.TransactionEntryBuyX)

Example 5 with AbstractInvestmentTransactionEntry

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

the class ReinvestDividendSlipController method modifyTransaction.

@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
    if (!(transaction instanceof InvestmentTransaction) || transaction.getTransactionType() != TransactionType.REINVESTDIV) {
        throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
    }
    clearForm();
    datePicker.setValue(transaction.getLocalDate());
    numberComboBox.setValue(transaction.getNumber());
    feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
    gainLossPane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentGainLossEntries());
    transaction.getTransactionEntries().stream().filter(e -> e instanceof TransactionEntryReinvestDivX).forEach(e -> {
        final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
        memoTextField.setText(e.getMemo());
        priceField.setDecimal(entry.getPrice());
        quantityField.setDecimal(entry.getQuantity());
        securityComboBox.setSecurityNode(entry.getSecurityNode());
    });
    modTrans = transaction;
    modTrans = attachmentPane.modifyTransaction(modTrans);
    setReconciledState(transaction.getReconciled(accountProperty().get()));
}
Also used : FXML(javafx.fxml.FXML) BigDecimal(java.math.BigDecimal) List(java.util.List) NotNull(jgnash.util.NotNull) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) ChangeListener(javafx.beans.value.ChangeListener) TransactionEntry(jgnash.engine.TransactionEntry) TransactionEntryReinvestDivX(jgnash.engine.TransactionEntryReinvestDivX) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionFactory(jgnash.engine.TransactionFactory) TransactionType(jgnash.engine.TransactionType) InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntryReinvestDivX(jgnash.engine.TransactionEntryReinvestDivX) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry)

Aggregations

AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)9 TransactionEntry (jgnash.engine.TransactionEntry)9 InvestmentTransaction (jgnash.engine.InvestmentTransaction)8 BigDecimal (java.math.BigDecimal)6 List (java.util.List)6 Transaction (jgnash.engine.Transaction)6 TransactionFactory (jgnash.engine.TransactionFactory)6 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 ChangeListener (javafx.beans.value.ChangeListener)3 FXML (javafx.fxml.FXML)3 JPanel (javax.swing.JPanel)3 Account (jgnash.engine.Account)3 TransactionType (jgnash.engine.TransactionType)3 ValidationFactory (jgnash.ui.util.ValidationFactory)3 NotNull (jgnash.util.NotNull)3 Collection (java.util.Collection)2