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 GainLossDialog method deleteAction.
@Override
void deleteAction() {
final TransactionEntry entry = tableView.getSelectionModel().getSelectedItem();
if (entry != null) {
tableView.getSelectionModel().clearSelection();
gainLossController.clearForm();
getTransactionEntries().remove(entry);
}
}
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());
transaction.setTags(TransactionEntryBuyX.class, tagPane.getSelectedTags());
return attachmentPane.buildTransaction(transaction);
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class FeeDialog method deleteAction.
@Override
void deleteAction() {
final TransactionEntry entry = tableView.getSelectionModel().getSelectedItem();
if (entry != null) {
tableView.getSelectionModel().clearSelection();
feeController.clearForm();
getTransactionEntries().remove(entry);
}
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class GainLossPane method setTransactionEntries.
/**
* Clones a {@code List} of {@code TransactionEntry(s)}.
*
* @param fees {@code List} of fees to clone
*/
void setTransactionEntries(final List<TransactionEntry> fees) {
final List<TransactionEntry> transactionEntries = gainLossDialog.getTransactionEntries();
if (fees.size() == 1) {
TransactionEntry e = fees.get(0);
if (e.getCreditAccount().equals(e.getDebitAccount())) {
setDecimal(e.getAmount(accountProperty().get()).abs());
} else {
try {
// copy over the provided set's entry
transactionEntries.add((TransactionEntry) e.clone());
} catch (CloneNotSupportedException e1) {
Logger.getLogger(GainLossPane.class.getName()).log(Level.SEVERE, e1.getLocalizedMessage(), e1);
}
setDecimal(sumGains().abs());
}
} else {
for (final TransactionEntry entry : fees) {
// clone the provided set's entries
try {
transactionEntries.add((TransactionEntry) entry.clone());
} catch (CloneNotSupportedException e) {
Logger.getLogger(GainLossPane.class.getName()).log(Level.SEVERE, e.toString(), e);
}
}
setDecimal(sumGains().abs());
}
editableProperty().setValue(transactionEntries.isEmpty());
}
Aggregations