Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: Reverse transactions order within a day #1776

Open
lo48576 opened this issue Mar 14, 2024 · 4 comments
Open

feature request: Reverse transactions order within a day #1776

lo48576 opened this issue Mar 14, 2024 · 4 comments
Labels

Comments

@lo48576
Copy link
Contributor

lo48576 commented Mar 14, 2024

Similar to #493, but this is a feature request with more limited scope.

Summary

I want an option to show transactions within each day in reverse order.
(This is not about the sort order of dates, which is already switchable.)
In other words, if there are multiple transactions with the same date, handle the first transaction in the file as the last transaction in the day, and the last in the file as the first in the day.

This might be a cosmetic stuff rather than the matter of correctness or consistency, but this will reduce confusion in some environment.

Working Example

option "operating_currency" "USD"

2024-03-15 balance Assets:Current:PrepaidCard 6 USD
2024-03-14 * "Store 3" "Yet another random item 3" ; 21:00
  Assets:Current:PrepaidCard -15 USD
  Expenses:SomeRandomItems
; 2024-03-14 balance Assets:Current:PrepaidCard 21 USD
2024-03-14 * "ATM 2" "Charge the prepaid card again" ; 18:00
  Assets:Current:PrepaidCard 20 USD
  Assets:Current:Savings:FooBarBank
; 2024-03-14 balance Assets:Current:PrepaidCard 1 USD
2024-03-14 * "Store 2" "Another random item 2" ; 15:00
  Assets:Current:PrepaidCard -16 USD
  Expenses:SomeRandomItems
; 2024-03-14 balance Assets:Current:PrepaidCard 17 USD
2024-03-14 * "ATM 1" "Charge the prepaid card" ; 12:00
  Assets:Current:PrepaidCard 15 USD
  Assets:Current:Savings:FooBarBank
; 2024-03-14 balance Assets:Current:PrepaidCard 2 USD
2024-03-14 * "Store 1" "Some random item 1" ; 09:00
  Assets:Current:PrepaidCard -8 USD
  Expenses:SomeRandomItems
2024-03-14 balance Assets:Current:PrepaidCard 10 USD


2024-02-01 balance Assets:Current:PrepaidCard 10 USD
2024-02-01 balance Assets:Current:Savings:FooBarBank 100 USD
2024-01-01 pad Assets:Current:PrepaidCard Equity:Opening-Balances
2024-01-01 pad Assets:Current:Savings:FooBarBank Equity:Opening-Balances

;include "_accounts.beancount"
; [BEGIN] _accounts.beancount
2024-01-01 open Assets:Current:PrepaidCard USD
2024-01-01 open Assets:Current:Savings:FooBarBank USD
2024-01-01 open Equity:Opening-Balances USD
2024-01-01 open Expenses:SomeRandomItems USD
; [END] _accounts.beancount

As you see, the first in the file (Store 3, 21:00) is the last in the day, and the last in the file" (Store 1, 09:00) is the first in the day.

Actual Result

The example above results in the capture below. See what happens to the "Balance" column.

2024-03-15-001758+0900

This is quite unintuitive... the balance of the prepaid card looks like going to negative, which usually never happens!

I know this is "correct" as beancount since it does not have smaller granularity than a day, which is the reason why I cannot put multiple balance with different values within a day.
In that sense, this might be "cosmetic" problem... even if the balance looks like "wrong" for human.
However, in this state, I'm sometimes confused as "hey, which is temporarily wrong value and which is the real balance I can trust!?"
This can be mitigated by putting bunch of balances (I do this), ideally everyday, but it is tiring and the confusing values still remain in the table.

Expected Result

What I wanted is, an option to switch the display order as below:

2024-03-15-002233+0900

Now the result looks quite natural, and reflects user's intention.

@lo48576
Copy link
Contributor Author

lo48576 commented Mar 14, 2024

Another easier way to reduce confusion is, to make the text more visually suppressed (e.g. making it light gray) for the balances other than the last transaction of a day?
It will make it clear that which value I can trust while the "storange" balances still remains.
Personally, I prefer the original request (reverse order) to this idea (gray out).

@floriskruisselbrink
Copy link

I don't think this is a fava problem. In your beancount journal, the order is also the wrong way around. Why don't you reverse the entries there? Doesn't that fix the fava-problem you are having?

Don't get me wrong, I know beancount doesn't care about file-order, but it seems fava does, so changing the order in the file could also be the solution.

@lo48576
Copy link
Contributor Author

lo48576 commented Mar 21, 2024

In your beancount journal, the order is also the wrong way around. Why don't you reverse the entries there? Doesn't that fix the fava-problem you are having?

I have entries reversed because it's easy to read and edit the recent transactions even when the editor is poor.
Of course it's easy to scroll to the end when I am using PC to edit this file, but it's not always so when I am using a smartphone.
(More context: I'm using fava as a desktop app in PC using Flatpak, and not having fava server that can be accessed from my phone.)

Reversing the entries ordering in the file (again) will solve the problem, but I'd like to order the entries just like fava does.
I want my files to be pretty as entries shown by fava are.
Changing order within day to old-to-new while ordering days new-to-old will be a possible mitigation on my side ("Twitter-TL-style"?), but it's less consistent so I prefer reversing everything.

I don't know how many people are doing this, but I've started using beancount with this style from the beginning because someone have been recommending this and I felt it's reasonable, so I believe at least another person on the earth would have reversed transactions in their beancount file...😅

@yagebu
Copy link
Member

yagebu commented Sep 15, 2024

Fava and Beancount use the same sortkey, which sorts by line number for entries of the same type on the same day, see beancount.core.data.entry_sortkey. So the file order does indeed matter (although it does not matter for entries on different days, only for the intra-day order of entries of the same type).

So we should stick to that order consistently to make sure that the entries are shown in the order that they are processed (which might be relevant for bookings to the same accounts on a single day) and if we reverse them, they should be fully reversed as well. I don't think there would be an easy way to make this configurable just in Fava.

I think Beancount more expects the other convention of appending new entries at the bottom (and so does Fava when inserting entries for example)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants