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

1.31: Non-print-like reports are adding decimal marks #2115

Closed
usaAmch opened this issue Nov 22, 2023 · 2 comments
Closed

1.31: Non-print-like reports are adding decimal marks #2115

usaAmch opened this issue Nov 22, 2023 · 2 comments
Labels
A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. aregister balance balancesheet bounty Thar's some kind o' loot on offer.. cashflow incomestatement register regression A backwards step, indicating a weakness in our QA. We don't like these.

Comments

@usaAmch
Copy link

usaAmch commented Nov 22, 2023

Given that a commodity that uses thousand separators and no decimal places is declared, when running non-print-like reports (like bal, reg, bs), the output includes the decimal mark even thought it is not needed.

Steps to reproduce

  • Generate a new ledger file with the following content:
  commodity JPY
     format 1,000. JPY

   payee open
   payee test

   account asset
   account equity
   account expense

   2023-01-01 open
     asset             1,000 JPY
     equity

   2023-01-02 test
     expense               1 JPY
     asset
  • Execute the following command: hledger -f test.journal bal

Expected Result

  • bal report should show equity amount as 1,000 JPY
             999 JPY  asset
          -1,000 JPY  equity
               1 JPY  expense
--------------------
                   0 

Current Result

  • bal report shows equity amount as 1,000. JPY, note the extra . at the end of the amount.
             999 JPY  asset
         -1,000. JPY  equity
               1 JPY  expense
--------------------
                   0 

Extra Info

% hledger --version
hledger 1.31, mac-aarch64
@usaAmch usaAmch added the A-BUG Something wrong, confusing or sub-standard in the software, docs, or user experience. label Nov 22, 2023
@simonmichael simonmichael added register balance balancesheet incomestatement cashflow aregister regression A backwards step, indicating a weakness in our QA. We don't like these. labels Nov 22, 2023
@simonmichael
Copy link
Owner

simonmichael commented Nov 22, 2023

This change in 1.31:

print no longer displays numbers with a single digit group mark and no decimal mark, which are ambiguous and hard to re-parse. Now if a number has digit group marks the decimal mark will always be shown also. Eg 1,000 (where the comma is a thousands separator) is now shown as 1,000..

was intended to affect only print and print-like reports. Thanks for the report! Claim your https://hledger.org/REGRESSIONS.html#regression-bounty when convenient.

As mentioned in chat, I plan to keep this behaviour for the print-like reports and revert it for the others, and document the following policy at hledger manual > PART 3: REPORTING CONCEPTS > Amount formatting:

Three rough categories of hledger output exist, differing in their intended consumers and whether they show ambiguous amounts (amounts with just one digit group mark and no decimal mark):

1. "hledger-readable output" - should be readable by hledger and humans

  • all reports showing full journal entries (print, import, close, rewrite..)
  • shows amounts with their original journal precisions
  • adds a trailing decimal mark to ambiguous amounts
  • can be parsed reliably

2. "human-readable output" - usually for humans

  • all other reports
  • shows amounts with their commodity's standard display precision
  • shows a decimal mark when displaying decimal digits
  • can show ambiguous amounts
  • can be parsed reliably in the context of a known report (because of consistent style, within each commodity)

3. "machine-readable output" - usually for other software

  • the csv/tsv/json/sql output from all reports
  • shows amounts with no digit group marks
  • shows a period decimal mark (.) when displaying decimal digits
  • can be parsed reliably

Today I'm leaning toward not treating HTML output specially, so a print-like HTML report such as the journal view in hledger-web could show trailing decimal marks, like print in the terminal. This would look like:

JKGHqrcRMJUymTyjsYkYtfex

@simonmichael
Copy link
Owner

simonmichael commented Nov 22, 2023

Rationale: we aim to be free of period/comma decimal mark bias, and to support arbitrary digit groups; and print-like reports show original journal precisions which can be inconsistent; so without the trailing decimal mark, print's HTML output could sometimes be hard for humans to read too. If you disagree, let me know.

@simonmichael simonmichael added the bounty Thar's some kind o' loot on offer.. label Nov 23, 2023
@simonmichael simonmichael changed the title Non-print-like reports are adding decimal marks 1.31: Non-print-like reports are adding decimal marks Dec 16, 2023
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. aregister balance balancesheet bounty Thar's some kind o' loot on offer.. cashflow incomestatement register regression A backwards step, indicating a weakness in our QA. We don't like these.
Projects
None yet
Development

No branches or pull requests

2 participants