use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class SplitTransactionSlipController method buildTransactionEntry.
@Override
TransactionEntry buildTransactionEntry() {
TransactionEntry entry = new TransactionEntry();
entry.setMemo(memoField.getText());
int signum = amountField.getDecimal().signum();
if ((slipType == SlipType.DECREASE && signum >= 0) || (slipType == SlipType.INCREASE && signum < 0)) {
entry.setCreditAccount(accountExchangePane.getSelectedAccount());
entry.setDebitAccount(account.get());
if (hasEqualCurrencies()) {
entry.setAmount(amountField.getDecimal().abs());
} else {
entry.setDebitAmount(amountField.getDecimal().abs().negate());
entry.setCreditAmount(accountExchangePane.exchangeAmountProperty().get().abs());
}
} else {
entry.setCreditAccount(account.get());
entry.setDebitAccount(accountExchangePane.getSelectedAccount());
if (hasEqualCurrencies()) {
entry.setAmount(amountField.getDecimal().abs());
} else {
entry.setCreditAmount(amountField.getDecimal().abs());
entry.setDebitAmount(accountExchangePane.exchangeAmountProperty().get().abs().negate());
}
}
entry.setReconciled(account.get(), getReconciledState());
return entry;
}
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 AbstractTransactionEntryPanel method enterAction.
@Override
public void enterAction() {
if (validateForm()) {
TransactionEntry entry = buildTransactionEntry();
if (oldEntry != null) {
model.modifyTransaction(oldEntry, entry);
} else {
model.addTransaction(entry);
}
clearForm();
fireOkAction();
}
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class IncomeTransactionEntryPanel method buildTransactionEntry.
@Override
public TransactionEntry buildTransactionEntry() {
TransactionEntry entry = super.buildTransactionEntry();
entry.setTransactionTag(TransactionTag.GAIN_LOSS);
return entry;
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class RegisterTableWithSplitEntriesModel method updateData.
/**
* Update the internal data from the specified index. Note that this index is not relative to the account
* transaction list but to the internal data.
*
* @param startIndex internal data index from which transactions need to updated.
*/
private void updateData(final int startIndex) {
if (data == null) {
data = new ArrayList<>(0);
}
while (data.size() > startIndex) {
data.remove(startIndex);
}
for (Transaction t : account.getSortedTransactionList()) {
if (data.size() >= startIndex) {
data.add(new TransactionWrapper(t));
if (t.getTransactionType() == TransactionType.SPLITENTRY && showSplitDetails) {
/* Only detail split entries if 2 or more entries impact this account */
int splitImpact = 0;
// count the number of impacting entry(s)
for (TransactionEntry e : t.getTransactionEntries()) {
if (e.getAmount(account).signum() != 0) {
splitImpact++;
}
}
// load only the entries that impact this account
if (splitImpact > 1) {
data.addAll(t.getTransactionEntries().stream().filter(e -> e.getAmount(account).signum() != 0).map(e -> new TransactionWrapper(t, e)).collect(Collectors.toList()));
}
}
}
}
// updating the balance cache too
balanceCache.ensureCapacity(data.size());
balanceCache.clear(startIndex);
}
Aggregations