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()));
}
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()));
}
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()));
}
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();
}
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);
}
}
Aggregations