use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class FeePane 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> feeList = feeDialog.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
feeList.add((TransactionEntry) e.clone());
} catch (CloneNotSupportedException e1) {
Logger.getLogger(FeePane.class.getName()).log(Level.SEVERE, e1.getLocalizedMessage(), e1);
}
setDecimal(sumFees().abs());
}
} else {
for (final TransactionEntry entry : fees) {
// clone the provided set's entries
try {
feeList.add((TransactionEntry) entry.clone());
} catch (CloneNotSupportedException e) {
Logger.getLogger(FeePane.class.getName()).log(Level.SEVERE, e.toString(), e);
}
}
setDecimal(sumFees().abs());
}
setEditable(feeList.size() < 1);
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class FeePane method getTransactions.
public List<TransactionEntry> getTransactions() {
final List<TransactionEntry> feeList = feeDialog.getTransactionEntries();
// adjust the cash balance of the investment account
if (feeList.isEmpty() && getDecimal().compareTo(BigDecimal.ZERO) != 0) {
// ignore zero balance fees
TransactionEntry fee = new TransactionEntry(accountProperty().get(), getDecimal().abs().negate());
fee.setTransactionTag(TransactionTag.INVESTMENT_FEE);
feeList.add(fee);
}
return feeList;
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class FeeTransactionEntrySlipController method buildTransactionEntry.
@Override
TransactionEntry buildTransactionEntry() {
final TransactionEntry entry = super.buildTransactionEntry();
entry.setTransactionTag(TransactionTag.INVESTMENT_FEE);
return entry;
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class AdjustmentSlipController method convertAction.
@FXML
private void convertAction() {
final Optional<Account> accountOptional = StaticAccountsMethods.selectAccount(null, account.get());
accountOptional.ifPresent(opp -> {
final Transaction t = new Transaction();
t.setDate(datePicker.getValue());
t.setNumber(numberComboBox.getValue());
t.setPayee(payeeTextField.getText());
final TransactionEntry entry = new TransactionEntry();
entry.setMemo(memoTextField.getText());
if (amountField.getDecimal().signum() >= 0) {
entry.setCreditAccount(account.get());
entry.setDebitAccount(opp);
} else {
entry.setDebitAccount(account.get());
entry.setCreditAccount(opp);
}
entry.setCreditAmount(amountField.getDecimal().abs());
entry.setDebitAmount(amountField.getDecimal().abs().negate());
t.addTransactionEntry(entry);
ReconcileManager.reconcileTransaction(account.get(), t, getReconciledState());
TransactionDialog.showAndWait(account.get(), t, transaction -> {
if (transaction != null) {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
if (engine.removeTransaction(modTrans)) {
engine.addTransaction(transaction);
}
clearForm();
}
});
});
}
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);
}
}
Aggregations