Sorting by date doesn't sort same-day transactions correctly

Bug #653697 reported by David D Lowe on 2010-10-02
This bug affects 1 person
Affects Status Importance Assigned to Milestone
David D Lowe

Bug Description

Sorting transactions by date does not sort same-day transactions in the order that they were entered. This leads to an unexpected "Total" (or balance) column.

Steps to reproduce:
- Create a new account
- Create the following transactions in this order:
2008-10-02 Old $10
2009-10-02 BB $40
2009-10-02 AA $50
2010-10-02 Recent $20

The sort the transactions alphabetically by clicking on the "description" column header:
Date | Description | Amount | Total
2009-10-02 | AA | $50 | $100
2009-10-02 | BB | $40 | $50
2008-10-02 | Old | $10 | $10
2010-10-02 | Recent | $20 | $120

Now sort the transactions by date by clicking on the "date" column header:
Date | Description | Amount | Total
2008-10-02 | Old | $10 | $10
2009-10-02 | AA | $50 | $100
2009-10-02 | BB | $40 | $50
2010-10-02 | Recent | $20 | $120

As you can see, AA and BB are not sorted correctly. Because BB was entered before AA, BB should have been displayed before AA. This buggy behaviour leads to a strange "Total" (or balance) column. When sorted by date oldest to newest, one expects the "Total" column to be the sum of the transactions preceding it.

Related branches

Michael Rooney (mrooney) wrote :

Thanks for this report! I think however that this is the intended behavior: column sorts are cumulative when possible. In the example you sorted by Description (ascending), then Date (ascending) so it is using the previous sort (Description ASC) as a tie-breaker. Try sorting by Description descending then Date ascending, and you'll see the opposite effect, and a similar thing with Amount and such.

Do you think this behavior is not preferred? The only issue I see is that there isn't a clear way to "reset" the previous sort columns.

It might be better sort not just be date for that column but also transaction ID, which would give you a more expected result when ordering transactions by Date descending. Right now if I do that I still get BB above AA when it should be swapped. I think I like the idea of that, and it should mean also there are no tie-breakers for dates, what do you think?

Changed in wxbanker:
status: New → Incomplete
David D Lowe (flimm) wrote :

Cumulative sorting makes sense for most cases. However, I think in this particular case, it's not particularly useful. When I sort the transactions by date, I expect them to be sorted by the order in which the balance is calculated, leading to a sensible "Total" column. I don't think I would ever need to sort transactions by the day in which they occurred, with same-day transactions sorted alphabetically. I only have three or four transactions in one day maximum anyway. I imagine most users' accounts are the same, although I can't prove it :)

I like the idea of sorting by transaction ID. Are transaction IDs always in order? If so, that's the behaviour I would like to see.

Changed in wxbanker:
status: Incomplete → New
Michael Rooney (mrooney) wrote :

The transaction ID is always the order entered, so using that as a tie-breaker for transactions with the same date should work.

It will probably require a little wrapper object that we give to the Date column. It will pass through getting and setting but sorts by date and transaction ID.

Changed in wxbanker:
importance: Undecided → Low
milestone: none → 0.9
status: New → Triaged
David D Lowe (flimm) on 2010-12-25
Changed in wxbanker:
assignee: nobody → David D Lowe (flimm)
status: Triaged → In Progress
David D Lowe (flimm) on 2011-06-01
Changed in wxbanker:
status: In Progress → Fix Committed
Michael Rooney (mrooney) on 2013-11-20
Changed in wxbanker:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers