Skip to content

How to read Balance in single-account panels #7218

@georgeef

Description

@georgeef

In single-account panels, column Balance shows the account balance after the execution of each transaction.

Short description (what you see in GUI)

In 1.9.0, Balance is calculated in the order of SN (Sequence Number).

To read Balance in the correct (calculation) order, you should sort by SN in ascending order, i.e., if the current sorting column is anything else, just click once on the SN header.

Sorting by SN shows Balance in calculation order also when scheduled transactions are enabled (with the square button next to the filter selector). This is a new feature in 1.9.0.

Long description (how it works behind the GUI)

In 1.9.0, both SN and Balance are calculated dynamically, when the list of transactions is fetched from DB. They are not stored in DB and they are not re-calculated every time you sort the list by another column. If you add/remove/edit transactions, the list is re-created and it is pre-sorted by Date/ID (or Date/Time/ID if Time is enabled) before SN and Balance is re-calculated. After this, the list is sorted again by the columns you selected, so both SN and Balance may appear out of order.

Be aware that sorting is always by two columns (see the "Sort Order" indicator above the table). When you click a column it becomes the primary sorting column, but there is also a secondary column. SN is unique, so the secondary column doesn’t matter if the primary column is SN (the same is true for ID, but only if scheduled transactions are disabled). [In 1.8.1, Date was coupled to ID; not anymore in 1.9.0, so be careful about the secondary column when the primary column is not unique.]

Sorting by Date may show Balance in correct order, but only under strict conditions: all transactions have been entered in chronological order, and scheduled transactions are disabled. Under these conditions, sorting by Date is equivalent to sorting by Date/ID, which is equivalent to sorting by SN. However, after some use, the above conditions are not valid anymore, so sorting by SN is the recommended (and simpler) way to read Balance in the correct order.

Sorting by ID may show Balance in correct order, but only under strict conditions. After some use, these conditions are usually not valid.

Sorting by Date/ID (i.e., Date as primary and ID as secondary, which can be selected by clicking ID first and Date next), is almost equivalent to SN, but also only under conditions: Time is disabled and scheduled transactions are disabled.

Sorting by Balance serves a different purpose: it sorts the transactions list in order of ascending or descending balance. This is not the same as the balance calculation order, which is mostly chronological.

How to re-order transactions

When a single-account panel is sorted by SN and Time is disabled in settings, the transactions order within the same date is determined by their ID, which is not editable. One way to re-order transactions within the same date, is to Duplicate transactions in the wanted order, and then Delete the original copies. Effectively this process assigns a new (larger) ID and therefore changes the SN.

Example: four transactions within the same date appear in the order A, B, C, D when sorted by SN. They can be re-ordered to A, D, C, B as follows:

  • duplicate C (the new copy of C gets a larger ID than D)
  • duplicate B (the new copy of B gets a larger ID than the new copy of C)
  • the order now is A, B, C, D, C', B' (where primes are the new copies)
  • delete the original copies of B and C
  • the order now is A, D, C', B'

Summary

Sorting by SN, shows Balance in the correct order under any conditions (because both SN and Balance are calculated together, in the same order). Sorting by anything else, usually shows Balance in the wrong order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions