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

price = 1 (if there are more recent transactions) #1532

Closed
vorburger opened this issue Jan 8, 2023 · 1 comment
Closed

price = 1 (if there are more recent transactions) #1532

vorburger opened this issue Jan 8, 2023 · 1 comment
Labels

Comments

@vorburger
Copy link

Disclaimer: I'm fairly new to Beancount & Fava.

I ran into something weird related to prices in Fava which I thought would be worth reporting here:

Looking at Fava's /commodities/ page for my Ledger, I had some CHF / USD at 1.1x and all USD / CHF at 1.

That... doesn't really make sense, and should be "impossible" - do you agree? I spent some time narrowing it down to a minimal reproducer:

option "operating_currency" "CHF"
option "operating_currency" "USD"

1850-07-01 commodity CHF
1792-04-02 commodity USD

2020-12-18 price USD 0.88 CHF
2022-12-19 price USD 0.9288 CHF

2021-11-12 open Assets:A CHF
2019-05-01 open Assets:B CHF

2022-12-19 *
    Assets:A  1 CHF
    Assets:B

2022-12-27 *
    Assets:A  1 CHF
    Assets:B

This will show the correct CHF / USD, calculated from the inverse of the price given above:

Date Price
2020-12-18 1.14
2022-12-19 1.08

But the USD / CHF shown is clearly wrong, ignoring the price directives:

Date Price
2020-12-18 1
2022-12-19 1

Adding a price for the day of the last transaction on 2022-12-27 (which only uses CHF no USD...) "fixes" it:

2022-12-27 price USD 0.9294 CHF

now the USD / CHF table is correct:

Date Price
2020-12-18 0.8800
2022-12-19 0.9288
2022-12-27 0.9294
@yagebu
Copy link
Member

yagebu commented Apr 8, 2023

Hi, thank you for opening this issue. In the context of reworking the price logic in Fava (#1589), I've had a look into this. The prices are calculated correctly in Fava, but they are rounded when displayed, since you've only got amounts in the CHF currency that lack any digits after the decimal dot - so the decimal precision with which to display amounts in CHF is inferred to be zero.

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

2 participants