scottohara / loot

An implementation of some of the core MS Money features in Ruby on Rails
MIT License
4 stars 3 forks source link

Incorrect reconcile progress totals for multi-page reconcile #114

Closed scottohara closed 1 year ago

scottohara commented 8 years ago

When reconciling, the progress stats on the right are calculated as follows:

reconcileTarget = closingBalance - openingBalance;
clearedTotal = transactions.reduce( /* cleared transactions in batch */ );
unclearedTotal = reconcileTarget - clearedTotal

closingBalance is the value entered by the user in the Reconcile dialog. openingBalance is the account balance immediately prior to the first transaction displayed (only unreconciled transactions are shown).

When the number of unreconciled transactions fits on a single page (NUM_RESULTS = 150) or when on the final page, this works fine.

When not on the final page, clearedTotal is incorrect (as it only sums transaction amounts for the current page). To be correct, it needs to sum ALL cleared transactions for the account (or at least all cleared transactions from the current page forward), regardless of whether they are shown or not.

This may require returning an additional property in the transaction batch, such as:

clearedBalance =
   (total of all cleared transactions for the account) -
   (total of all cleared transactions in the batch)

(in other words, total cleared transactions excluding the current batch)

Further, reconcileTarget may also need to change to either:

  1. balance immediately prior to the first cleared transaction for the account (which may be on an earlier page); or
  2. openingBalance (if there are no cleared transactions yet)
scottohara commented 1 year ago

Fixed by https://github.com/scottohara/loot/commit/fcb9b6a39a4d0d8172771b4b358e8399360e5fdd