use of jgnash.engine.TransactionEntry 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.TransactionEntry in project jgnash by ccavanaugh.
the class BuyShareSlipController method buildTransaction.
@NotNull
@Override
public Transaction buildTransaction() {
final BigDecimal exchangeRate = accountExchangePane.getExchangeRate();
final List<TransactionEntry> fees = feePane.getTransactions();
final Transaction transaction = TransactionFactory.generateBuyXTransaction(accountExchangePane.getSelectedAccount(), accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), exchangeRate, datePicker.getValue(), memoTextField.getText(), fees);
transaction.setNumber(numberComboBox.getValue());
return attachmentPane.buildTransaction(transaction);
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class SplitsRegisterTableModel method getValueAt.
@Override
public Object getValueAt(final int row, final int col) {
TransactionEntry t = transaction.getSplitAt(row);
Account creditAccount = t.getCreditAccount();
switch(col) {
case 0:
if (creditAccount != account) {
return creditAccount.getName();
}
return t.getDebitAccount().getName();
case 1:
return t.getReconciled(account).toString();
case 2:
return t.getMemo();
case 3:
if (creditAccount == account) {
return t.getAmount(account);
}
return null;
case 4:
if (creditAccount != account) {
return t.getAmount(account).abs();
}
return null;
case 5:
return transaction.getRunningBalance(row + 1);
default:
return "";
}
}
use of jgnash.engine.TransactionEntry 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()));
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class BuySharePanel method buildTransaction.
@Override
public Transaction buildTransaction() {
BigDecimal exchangeRate = accountExchangePanel.getExchangeRate();
List<TransactionEntry> fees = feePanel.getTransactions();
return TransactionFactory.generateBuyXTransaction(accountExchangePanel.getSelectedAccount(), getAccount(), securityCombo.getSelectedNode(), priceField.getDecimal(), quantityField.getDecimal(), exchangeRate, datePanel.getLocalDate(), memoField.getText(), fees);
}
Aggregations