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

Balance assertion fails with lot-priced commodities #2318

Open
riastradh opened this issue Dec 12, 2023 · 1 comment
Open

Balance assertion fails with lot-priced commodities #2318

riastradh opened this issue Dec 12, 2023 · 1 comment

Comments

@riastradh
Copy link

ledger 3.3.2-20230330

Works, even though the units don't exactly match:

$ cat a
2023-01-01 Payee
    Assets:XXX  1.00 XXX {=1.01 USD} = 1.00 XXX
    Liabilities:XXX  -1.00 XXX {=1.01 USD}
$ ledger -f a balance
            1.00 XXX  Assets:XXX
           -1.00 XXX  Liabilities:XXX
--------------------
                   0

Doesn't work but should work:

$ cat b
2023-01-01 Payee
    Assets:XXX  1.00 XXX {=1.01 USD} = 1.00 XXX {=1.01 USD}
    Liabilities:XXX  -1.00 XXX {=1.01 USD}
$ ledger -f ledger b balance
While parsing file "/tmp/riastradh/b", line 2:
While parsing posting:
  Assets:XXX  1.00 XXX {=1.01 USD} = 1.00 XXX {=1.01 USD}
                                     ^^^^^^^^^^^^^^^^^^^^
Error: Balance assertion off by -1.00 XXX
1.00 XXX {=USD1.01} (expected to see 1.00 XXX)

ledger 3.2.1-20200518

Failed as expected because the units don't match:

$ cat a
2023-01-01 Payee
    Assets:XXX  1.00 XXX {=1.01 USD} = 1.00 XXX
    Liabilities:XXX  -1.00 XXX {=1.01 USD}
$ ledger -f a balance
While parsing file "/tmp/riastradh/a", line 2:
While parsing posting:
  Assets:XXX  1.00 XXX {=1.01 USD} = 1.00 XXX
                                     ^^^^^^^^
Error: Balance assertion off by 1.00 XXX
-1.00 XXX {=USD1.01} (expected to see 0.00 XXX
1.00 XXX {=USD1.01})

Worked as expected because the units do match:

$ cat b
2023-01-01 Payee
    Assets:XXX  1.00 XXX {=1.01 USD} = 1.00 XXX {=1.01 USD}
    Liabilities:XXX  -1.00 XXX {=1.01 USD}
$ ledger -f b balance
            1.00 XXX  Assets:XXX
           -1.00 XXX  Liabilities:XXX
--------------------
                   0
@riastradh
Copy link
Author

I bisected it to this commit: ce8fec9

This broke my ledgers with extensive use of foreign currencies, with dated valuations on liabilities in order to correctly report gain and loss due to exchange rate fluctuation when expenses are incurred vs when payments are made, so I'm currently stuck on ledger-3.2.1.

Perhaps it's fine to allow non-valued balance assertions (as in case A above, which I expected to fail), but it's a problem to reject the ledger when the units all match exactly (as in case B above, which I expected to work and which no longer works).

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Mar 3, 2024
This avoids the following regression:

ledger/ledger#2318

Eventually I would like to see this either fixed upstream or worked
around, but keeping an older version is easier for now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant