Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
default commodity (D) directive does not limit decimal places #1187
I am experiencing issue. I have set precision to one decimal using journal-wide commodity directive
; commodity-less amounts should be treated as dollars
This journal-wide directive is setting report and hledger-web display precision to one decimal as it was expected.
Please let me know: is it an intended behaviour or do I miss something obvious.
Thank you for helping to make hledger better!
Things that can help us resolve your issue faster:
This is setting decimal precision to proper 1 digit
This will change display precision to 4 decimals resulting in unnecessary clatter in journal and reports.
Example journal with precision settings
Example report with proper output precision:
Example journal with commodity price
P 2020/1/31 EUR 1.1034
Example report with excessive precision due to commodity price
Thanks for the reproducible example. You can enclose things in triple-backtick lines for better formatting, eg:
I think you have pointed out a bug here. The doc and example at https://hledger.org/journal.html#default-commodity implies that
Stop exporting journalAmounts, overJournalAmounts, traverseJournalAmounts. Rename journalAmounts helper to journalStyleInfluencingAmounts. D directives are now a little better at influencing amount canonicalisation, eg in the updated test case.
D directives are now fully equivalent to commodity directives for setting a commodity's display style. (Previously it was equivalent to a posting amount, so it couldn't limit the number of decimal places.) When both kinds of directive exist, commodity directives take precedence. When there are multiple D directives in the journal, only the last one affects display style.
Thanks for the report. https://hledger.org/journal.html#default-commodity is up to date.