Skip to content

Expense graph over time and "Convert to <currency>" behavior #1936

Open
@lutorm

Description

It seems the cumulative expense graph that is displayed when you go to the Expenses tab and then click on an account does not handle currency conversion correctly.

This is what our grocery expenses look like over time, converted to SEK:
Screenshot_20250103_105811
As you can see, it is not cumulative. Sometimes the total expenses appear to decrease. I believe what's happening here is that fava (or beancount, I don't know where the calculation is done) accumulates our grocery expenses in USD and SEK separately and then, for each point on the graph, converts the USD value to SEK and adds them. This means that if we have an accumulated expense of 10,000 USD in Jan 2025 and the exchange rate changes such that those USD are now worth less SEK, the expense line will decrease.

This seems like a useless way of doing the currency conversion since those USD were spent at some time in the past, and just because USD is worth less right now doesn't mean that our expenses back at that time changed. I think a more useful way of doing the calculation is that, for each interval, the USD value is converted to SEK using the exchange rate at that point in time, and then the running sum of SEK is displayed.

Ie, instead of plotting, in pseudocode,
y(T)=Sum(USD(t),0,T)*(SEK/USD)(T) + Sum(SEK(t),0,T),
the plot should be
y(T)=Sum(USD(t)*(SEK/USD)(t)+SEK(t),0,T).

I'm doing this with fava 1.29 on Chrome 131.0.6778.139.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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