Skip to content

Commit

Permalink
;doc: amount formatting: edits (#2115)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichael committed Nov 23, 2023
1 parent edf6738 commit 5cda7c5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions hledger/hledger.m4.md
Original file line number Diff line number Diff line change
Expand Up @@ -4345,30 +4345,31 @@ file.

If you're wondering why your `print` report sometimes shows trailing
decimal marks, even when there are no decimal digits; it does this to
disambiguate [ambiguous amounts](decimal-marks-digit-group-marks)
disambiguate [ambiguous amounts](#decimal-marks-digit-group-marks)
(amounts which have one digit group mark and no decimal digits),
allowing them to be re-parsed reliably.
More generally: hledger output falls into three rough categories, which
format amounts a little bit differently to suit different consumers:
**1. "hledger-readable output" - should be readable by hledger and by humans**
**1. "hledger-readable output" - should be readable by hledger (and by humans)**
- It is produced by reports that show full journal entries: `print`, `import`, `close`, `rewrite` etc.
- This is produced by reports that show full journal entries: `print`, `import`, `close`, `rewrite` etc.
- It shows amounts with their original journal precisions, which may not be consistent.
- It adds a trailing decimal mark when needed to avoid showing ambiguous amounts.
- It can be parsed reliably.
- It can be parsed reliably (by hledger and ledger2beancount at least, but perhaps not by Ledger..)
**2. "human-readable output" - usually for humans**
- It is produced by all other reports.
- This is produced by all other reports.
- It shows amounts with standard display precisions, which will be consistent within each commodity.
- It can show ambiguous amounts.
- It can be parsed reliably in the context of a known report (because of consistent style).
- It shows ambiguous amounts unmodified.
- It can be parsed reliably in the context of a known report
(when you know decimals are consistently not being shown, you can assume a single mark is a digit group mark).
**3. "machine-readable output" - usually for other software**
- It is produced by all reports when an output format like `csv`/`tsv`/`json`/`sql` is selected.
- This is produced by all reports when an output format like `csv`, `tsv`, `json`, or `sql` is selected.
- It shows no digit group marks.
- It shows a period decimal mark (.) when there are decimal digits.
- It can be parsed reliably.
Expand Down

0 comments on commit 5cda7c5

Please sign in to comment.