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

equity --opening produces a journal that cannot be read #2176

Closed
jonasrauber opened this issue Feb 25, 2024 · 2 comments
Closed

equity --opening produces a journal that cannot be read #2176

jonasrauber opened this issue Feb 25, 2024 · 2 comments
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. close journal The journal file format, and its features.

Comments

@jonasrauber
Copy link

Version: hledger 1.32.3, mac-aarch64

Assume we have this journal:

2022-01-01
    assets:aaa  $1,000.22
    assets:bbb  $-1,000.22

2022-01-02
    assets:ccc  $-1234
    assets:ddd  $1234

NOTE: There is no ambiguity about the decimal mark here (hledger -f example.journal balance looks good).

And we then run:

hledger -f example.journal equity --opening > opening.journal

The resulting opening.journal looks like this:

2024-02-25 opening balances
    assets:aaa                            $1,000.22 = $1,000.22
    assets:bbb                           $-1,000.22 = $-1,000.22
    assets:ccc                             $-1,234. = $-1,234
    assets:ddd                              $1,234. = $1,234

NOTE: It's weird that a decimal dot is added on the left but not on the right.

If we now run:

hledger -f opening.journal balance

We get the following error:

hledger: Error: opening.journal:4:53:
  | 2024-02-25 opening balances
  |     assets:aaa                            $1,000.22 = $1,000.22
  |     assets:bbb                           $-1,000.22 = $-1,000.22
4 |     assets:ccc                             $-1,234. = $-1.234
  |                                                     ^^^^^^^^^
  |     assets:ddd                              $1,234. = $1.234
  |     equity:opening/closing balances           $0.00

Balance assertion failed in assets:ccc
In commodity $ at this point, excluding subaccounts, ignoring costs,
the expected balance is:        $-1.234
but the calculated balance is:  $-1,234
(difference: $1,232.766)
To troubleshoot, check this account's running balance with assertions disabled, eg:
hledger reg -I 'assets:ccc$' cur:'\$'

Yes, putting decimal-mark . into the opening.journal would fix it, but opening.journal is itself produced by hledger and not written by hand, so that's not really in my control (I can of course work around it).

If we assume that the way hledger interprets opening.journal (i.e. treating the comma in 1,234 as a decimal mark — which I think is questionable given that the other entries are all using a dot as decimal mark), then the output of hledger -f example.journal equity --opening is wrong because it does not fulfill hledger's own expectations.

@simonmichael simonmichael added journal The journal file format, and its features. close labels Feb 25, 2024
@simonmichael
Copy link
Owner

NOTE: It's weird that a decimal dot is added on the left but not on the right.

You're right, that looks like a bug. It should add it consistently to both, per https://hledger.org/dev/hledger.html#amount-formatting-parseability. Thanks for the report.

@simonmichael simonmichael added the A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. label Feb 25, 2024
simonmichael added a commit that referenced this issue Feb 26, 2024
…lso (#2176)

Add a trailing decimal mark when necessary to disambiguate a single
digit group mark in the balance assertion/assignment amount, also.
@simonmichael
Copy link
Owner

Fixed in master.

adept pushed a commit to adept/hledger that referenced this issue Mar 8, 2024
…lso (simonmichael#2176)

Add a trailing decimal mark when necessary to disambiguate a single
digit group mark in the balance assertion/assignment amount, also.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. close journal The journal file format, and its features.
Projects
None yet
Development

No branches or pull requests

2 participants