ledger / ledger

Double-entry accounting system with a command-line reporting interface
https://www.ledger-cli.org
Other
5.27k stars 501 forks source link

Regression when specifying format for commodity "h" #2205

Closed Boldewyn closed 1 year ago

Boldewyn commented 1 year ago

We’re using ledger as time management tool and have added the following lines to allow appropriate German formatting of hours:

commodity h
    format 1.000,00 h
    default

When upgrading to ledger 3.3.0, running any ledger command results in the error message:

While parsing file "/time/user.journal", line 722:
Error: commodity directive symbol h and format directive symbol s should be the same

This seems to be the same error as this one reported on reddit which allocates the error message in https://github.com/ledger/ledger/blame/master/src/textual.cc#L1137

This is a regression from 3.2.1 and older where the above statement worked perfectly fine.

tbm commented 1 year ago

I guess the problem is that h is built-in for hours which is somehow treated the same as s?

Adding @jwiegley

So I guess we have to special case this in the case.

A regression introduced in commit 1a70b33b4f8b6f8d4844b1b30dde568ae311d0ac

tbm commented 1 year ago

CC @madroach

afh commented 1 year ago

ℹ️ Wanted to call out the --time-colon option, which changes the time commodity's base from 100 to 60, so that 90 minutes is reported as 1:30 instead of 1,5.

jwiegley commented 1 year ago

This won't just affect builtin commodities, but any commodity that supports conversions. The checking code in 1a70b33 needs to ensure that the commodity are related, not just identical, it seems.

jwiegley commented 1 year ago

The fix seems simple enough.

Boldewyn commented 1 year ago

Cool, thank you very much for this speedy fix!