;print: cleanup; discuss unbalanced output (#1429)

This commit is contained in:
Simon Michael 2020-12-28 07:05:27 -08:00
parent 9ff53ab1e0
commit 21ce0c30cc

View File

@ -4,12 +4,11 @@ Show transaction journal entries, sorted by date.
_FLAGS _FLAGS
The print command displays full journal entries (transactions) from The print command displays full journal entries (transactions) from
the journal file in date order, tidily formatted. the journal file, sorted by date
With --date2, transactions are sorted by secondary date instead. (or with `--date2`, by [secondary date](#secondary-dates)).
Amounts are shown right-aligned within each transaction (but not across all transactions).
print's output is always a valid [hledger journal](https://hledger.org/hledger.html). Directives and inter-transaction comments are not shown.
It preserves all transaction information, but it does not preserve Eg:
directives or inter-transaction comments
```shell ```shell
$ hledger print $ hledger print
@ -35,6 +34,20 @@ $ hledger print
assets:bank:checking $-1 assets:bank:checking $-1
``` ```
print's output is usually a valid [hledger journal](https://hledger.org/hledger.html), and you can process it again with a second hledger command. This can be useful for certain kinds of search, eg:
```shell
# Show running total of food expenses paid from cash.
# -f- reads from stdin. -I/--ignore-assertions is sometimes needed.
$ hledger print assets:cash | hledger -f- -I reg expenses:food
```
There are some situations where print's output can become unparseable:
- [Rounding](#rounding) amounts according to [commodity display styles](#commodity-display-style) can cause transactions to appear [unbalanced](https://github.com/simonmichael/hledger/issues/931).
- [Valuation](#valuation) affects posting amounts but not [balance assertion](#balance-assertions) or [balance assignment](#balance-assignments) amounts, potentially causing those to [fail](https://github.com/simonmichael/hledger/issues/1429).
- [Auto postings](#auto-postings) can generate postings with [too many missing amounts](https://github.com/simonmichael/hledger/issues/1276).
Normally, the journal entry's explicit or implicit amount style is preserved. Normally, the journal entry's explicit or implicit amount style is preserved.
For example, when an amount is omitted in the journal, it will not appear in the output. For example, when an amount is omitted in the journal, it will not appear in the output.
Similarly, when a transaction price is implied but not written, it will not appear in the output. Similarly, when a transaction price is implied but not written, it will not appear in the output.