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());
}
setEditable(transactionEntries.size() < 1);
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class ReinvestDividendSlipController method buildTransaction.
@NotNull
@Override
public Transaction buildTransaction() {
final List<TransactionEntry> gains = gainLossPane.getTransactions();
final List<TransactionEntry> fees = feePane.getTransactions();
final Transaction transaction = TransactionFactory.generateReinvestDividendXTransaction(accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), datePicker.getValue(), memoTextField.getText(), fees, gains);
transaction.setNumber(numberComboBox.getValue());
return attachmentPane.buildTransaction(transaction);
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class SellShareSlipController method buildTransaction.
@NotNull
@Override
public Transaction buildTransaction() {
final BigDecimal exchangeRate = accountExchangePane.getExchangeRate();
final List<TransactionEntry> gains = gainLossPane.getTransactions();
final List<TransactionEntry> fees = feePane.getTransactions();
final Transaction transaction = TransactionFactory.generateSellXTransaction(accountExchangePane.getSelectedAccount(), accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), exchangeRate, datePicker.getValue(), memoTextField.getText(), fees, gains);
transaction.setNumber(numberComboBox.getValue());
return attachmentPane.buildTransaction(transaction);
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class SlipController method modifyTransaction.
@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
if (transaction.areAccountsLocked()) {
clearForm();
StaticUIMethods.displayError(resources.getString("Message.TransactionModifyLocked"));
return;
}
// load the form
newTransaction(transaction);
// save reference to old transaction
modTrans = transaction;
modTrans = attachmentPane.modifyTransaction(modTrans);
// Set state of memo concatenation
concatenated.setValue(modTrans.isMemoConcatenated());
if (!canModifyTransaction(transaction) && transaction.getTransactionType() == TransactionType.SPLITENTRY) {
for (final TransactionEntry entry : transaction.getTransactionEntries()) {
if (entry.getCreditAccount().equals(accountProperty().get()) || entry.getDebitAccount().equals(accountProperty().get())) {
modEntry.setValue(entry);
// override to allow editing the entry
concatenated.setValue(false);
break;
}
}
if (modEntry.get() == null) {
Logger logger = Logger.getLogger(SlipController.class.getName());
logger.warning("Was not able to modify the transaction");
}
}
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class SplitTransactionDialog method deleteAction.
@Override
void deleteAction() {
final TransactionEntry entry = tableView.getSelectionModel().getSelectedItem();
if (entry != null) {
tableView.getSelectionModel().clearSelection();
((SplitTransactionSlipController) tabPane.getSelectionModel().getSelectedItem().getUserData()).clearForm();
getTransactionEntries().remove(entry);
}
}
Aggregations