;doc: amount formatting: edits (#2115)

This commit is contained in:
Simon Michael 2023-11-22 14:46:50 -10:00
parent 1744021986
commit b5fd3c767c

View File

@ -4341,30 +4341,37 @@ file.
# PART 3: REPORTING CONCEPTS # PART 3: REPORTING CONCEPTS
# Amount formatting # Amount formatting, ambiguous amounts
When displaying amounts, digit group marks and decimal marks are If you're wondering why your `print` report sometimes shows trailing
handled a little differently depending on the report and output format decimal marks, even when there are no decimal digits; it does this to
and intended consumer. hledger output falls into three rough categories: 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.
**1. "hledger-readable output" should be readable by hledger and by humans** Background: hledger output falls into three rough categories, which
- produced by reports that show full journal entries: `print`, `import`, `close`, `rewrite`.. format amounts a little bit differently to suit different consumers:
- shows amounts with their original journal precisions, which may not be consistent
- adds a trailing decimal mark when needed to disambiguate [ambiguous amounts](decimal-marks-digit-group-marks) **1. "hledger-readable output" - should be readable by hledger and by humans**
(amounts with one digit group mark and no decimal digits)
- can be parsed reliably - It 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.
**2. "human-readable output" - usually for humans** **2. "human-readable output" - usually for humans**
- produced by all other reports
- shows amounts with standard display precisions, which will be consistent within each commodity - It is produced by all other reports.
- can show ambiguous amounts - It shows amounts with standard display precisions, which will be consistent within each commodity.
- can be parsed reliably in the context of a known report (because of consistent style) - It can show ambiguous amounts.
- It can be parsed reliably in the context of a known report (because of consistent style).
**3. "machine-readable output" - usually for other software** **3. "machine-readable output" - usually for other software**
- produced by all reports when an output format like `csv`/`tsv`/`json`/`sql` is selected
- shows no digit group marks - It is produced by all reports when an output format like `csv`/`tsv`/`json`/`sql` is selected.
- shows a period decimal mark (.) when there are decimal digits - It shows no digit group marks.
- can be parsed reliably - It shows a period decimal mark (.) when there are decimal digits.
- It can be parsed reliably.
# Time periods # Time periods