Search in sources :

Example 1 with RecTransaction

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();
    }
}
Also used : RecTransaction(jgnash.engine.RecTransaction)

Example 2 with RecTransaction

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);
}
Also used : RecTransaction(jgnash.engine.RecTransaction) BigDecimal(java.math.BigDecimal)

Example 3 with RecTransaction

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();
    }
}
Also used : RecTransaction(jgnash.engine.RecTransaction)

Example 4 with RecTransaction

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;
            }
        }
    }
}
Also used : RecTransaction(jgnash.engine.RecTransaction) Transaction(jgnash.engine.Transaction) RecTransaction(jgnash.engine.RecTransaction)

Example 5 with RecTransaction

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();
}
Also used : RecTransaction(jgnash.engine.RecTransaction) TableViewManager(jgnash.uifx.util.TableViewManager)

Aggregations

RecTransaction (jgnash.engine.RecTransaction)8 BigDecimal (java.math.BigDecimal)3 Transaction (jgnash.engine.Transaction)2 LocalDate (java.time.LocalDate)1 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)1 ChangeListener (javafx.beans.value.ChangeListener)1 ObservableValue (javafx.beans.value.ObservableValue)1 TableColumn (javafx.scene.control.TableColumn)1 TableViewManager (jgnash.uifx.util.TableViewManager)1