use of jgnash.engine.AbstractInvestmentTransactionEntry in project jgnash by ccavanaugh.
the class SellShareSlipController method modifyTransaction.
@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
if (!(transaction instanceof InvestmentTransaction) || transaction.getTransactionType() != TransactionType.SELLSHARE) {
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 TransactionEntrySellX).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 {
Logger.getLogger(SellShareSlipController.class.getName()).warning("was not expected");
}
});
modTrans = transaction;
modTrans = attachmentPane.modifyTransaction(modTrans);
setReconciledState(transaction.getReconciled(accountProperty().get()));
}
use of jgnash.engine.AbstractInvestmentTransactionEntry in project jgnash by ccavanaugh.
the class SellSharePanel 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 TransactionEntrySellX).forEach(e -> {
final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityCombo.setSelectedNode(entry.getSecurityNode());
accountExchangePanel.setSelectedAccount(entry.getDebitAccount());
accountExchangePanel.setExchangedAmount(entry.getDebitAmount().abs());
});
updateTotalField();
modTrans = tran;
setReconciledState(tran.getReconciled(getAccount()));
}
use of jgnash.engine.AbstractInvestmentTransactionEntry in project jgnash by ccavanaugh.
the class AbstractInvIncomeSlipController method modifyTransaction.
@Override
public void modifyTransaction(@NotNull Transaction transaction) {
if (transaction.getTransactionType() != getTransactionType()) {
throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
}
clearForm();
datePicker.setValue(transaction.getLocalDate());
numberComboBox.setValue(transaction.getNumber());
final List<TransactionEntry> entries = transaction.getTransactionEntries();
for (final TransactionEntry e : entries) {
if (e instanceof AbstractInvestmentTransactionEntry && ((AbstractInvestmentTransactionEntry) e).getTransactionType() == getTransactionType()) {
memoTextField.setText(e.getMemo());
securityComboBox.setSecurityNode(((AbstractInvestmentTransactionEntry) e).getSecurityNode());
incomeExchangePane.setSelectedAccount(e.getDebitAccount());
incomeExchangePane.setExchangedAmount(e.getDebitAmount().abs());
decimalTextField.setDecimal(e.getAmount(accountProperty().get()));
} else if (e.getTransactionTag() == TransactionTag.INVESTMENT_CASH_TRANSFER) {
accountExchangePane.setSelectedAccount(e.getCreditAccount());
accountExchangePane.setExchangedAmount(e.getCreditAmount());
} else {
logger.warning("Invalid transaction");
}
}
modTrans = transaction;
modTrans = attachmentPane.modifyTransaction(modTrans);
setReconciledState(transaction.getReconciled(accountProperty().get()));
}
use of jgnash.engine.AbstractInvestmentTransactionEntry in project jgnash by ccavanaugh.
the class BuySharePanel 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());
entries.stream().filter(e -> e instanceof TransactionEntryBuyX).forEach(e -> {
AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityCombo.setSelectedNode(entry.getSecurityNode());
if (entry.getCreditAccount().equals(account)) {
accountExchangePanel.setSelectedAccount(entry.getDebitAccount());
accountExchangePanel.setExchangedAmount(entry.getDebitAmount().abs());
} else {
accountExchangePanel.setSelectedAccount(entry.getCreditAccount());
accountExchangePanel.setExchangedAmount(entry.getCreditAmount());
}
});
updateTotalField();
modTrans = tran;
setReconciledState(tran.getReconciled(getAccount()));
}
Aggregations