use of jgnash.engine.RecTransaction in project jgnash by ccavanaugh.
the class ReconcileDialogController method setReconciledState.
private void setReconciledState(final List<RecTransaction> transactionList, final ReconciledState reconciledState, final TableView<RecTransaction> tableView) {
readWriteLock.readLock().lock();
try {
for (final RecTransaction recTransaction : transactionList) {
recTransaction.setReconciledState(reconciledState);
}
tableView.refresh();
updateCalculatedValues();
} finally {
readWriteLock.readLock().unlock();
}
}
use of jgnash.engine.RecTransaction in project jgnash by ccavanaugh.
the class ReconcileDialogController method getReconciledTotal.
private BigDecimal getReconciledTotal(final List<RecTransaction> list) {
BigDecimal sum = BigDecimal.ZERO;
readWriteLock.readLock().lock();
try {
for (final RecTransaction t : list) {
if (t.getReconciledState() != ReconciledState.NOT_RECONCILED) {
sum = sum.add(t.getAmount(account));
}
}
} finally {
readWriteLock.readLock().unlock();
}
return AccountBalanceDisplayManager.convertToSelectedBalanceMode(account.getAccountType(), sum);
}
use of jgnash.engine.RecTransaction in project jgnash by ccavanaugh.
the class AbstractReconcileTableModel method toggleReconciledState.
void toggleReconciledState(final int index) {
rwl.readLock().lock();
try {
RecTransaction t = list.get(index);
if (t.getReconciledState() == ReconciledState.RECONCILED) {
t.setReconciledState(ReconciledState.NOT_RECONCILED);
} else {
t.setReconciledState(ReconciledState.RECONCILED);
}
fireTableRowsUpdated(index, index);
} finally {
rwl.readLock().unlock();
}
}
use of jgnash.engine.RecTransaction in project jgnash by ccavanaugh.
the class ReconcileDialogController method messagePosted.
@Override
public void messagePosted(final Message message) {
if (account != null && account.equals(message.getObject(MessageProperty.ACCOUNT))) {
final Transaction transaction = message.getObject(MessageProperty.TRANSACTION);
if (transaction != null) {
switch(message.getEvent()) {
case TRANSACTION_REMOVE:
final RecTransaction trans = findTransaction(transaction);
if (trans != null) {
readWriteLock.writeLock().lock();
try {
transactions.removeAll(trans);
updateCalculatedValues();
} finally {
readWriteLock.writeLock().unlock();
}
}
break;
case TRANSACTION_ADD:
if (reconcilable(transaction)) {
readWriteLock.writeLock().lock();
try {
transactions.add(new RecTransaction(transaction, transaction.getReconciled(account)));
FXCollections.sort(transactions);
updateCalculatedValues();
} finally {
readWriteLock.writeLock().unlock();
}
}
break;
default:
break;
}
}
}
}
use of jgnash.engine.RecTransaction in project jgnash by ccavanaugh.
the class ReconcileDialogController method loadTables.
private void loadTables() {
final TableViewManager<RecTransaction> increaseTableViewManager = new TableViewManager<>(increaseTableView, PREF_NODE);
increaseTableViewManager.setColumnWeightFactory(getColumnWeightFactory());
increaseTableViewManager.setPreferenceKeyFactory(() -> INCREASE_KEY);
final TableViewManager<RecTransaction> decreaseTableViewManager = new TableViewManager<>(decreaseTableView, PREF_NODE);
decreaseTableViewManager.setColumnWeightFactory(getColumnWeightFactory());
decreaseTableViewManager.setPreferenceKeyFactory(() -> DECREASE_KEY);
transactions.addAll(account.getSortedTransactionList().stream().filter(this::reconcilable).map(transaction -> new RecTransaction(transaction, transaction.getReconciled(account))).collect(Collectors.toList()));
configureTableView(increaseTableView, increaseTableViewManager);
configureTableView(decreaseTableView, decreaseTableViewManager);
increaseTableView.setItems(increaseList);
decreaseTableView.setItems(decreaseList);
updateCalculatedValues();
}
Aggregations