;doc:balance: cleanups

This commit is contained in:
Simon Michael 2024-02-29 23:13:23 -10:00
parent d8f86a9b7d
commit 7e28e38bbc

View File

@ -682,8 +682,8 @@ It has four possible values:
- `--layout=bare`: commodity symbols are in their own column, amounts are bare numbers - `--layout=bare`: commodity symbols are in their own column, amounts are bare numbers
- `--layout=tidy`: data is normalised to easily-consumed "tidy" form, with one row per data value - `--layout=tidy`: data is normalised to easily-consumed "tidy" form, with one row per data value
Here are the `--layout` modes supported by each [output format](#output-format); Here are the `--layout` modes supported by each [output format](#output-format)
note only CSV output supports all of them: Only CSV output supports all of them:
| - | txt | csv | html | json | sql | | - | txt | csv | html | json | sql |
|------|-----|-----|------|------|-----| |------|-----|-----|------|------|-----|
@ -694,7 +694,8 @@ note only CSV output supports all of them:
Examples: Examples:
- Wide layout. With many commodities, reports can be very wide: #### Wide layout
With many commodities, reports can be very wide:
```cli ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide
Balance changes in 2012-01-01..2014-12-31: Balance changes in 2012-01-01..2014-12-31:
@ -706,7 +707,7 @@ Examples:
|| 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT || 10.00 ITOT, 337.18 USD, 12.00 VEA, 106.00 VHT 70.00 GLD, 18.00 ITOT, -98.12 USD, 10.00 VEA, 18.00 VHT -11.00 ITOT, 4881.44 USD, 14.00 VEA, 170.00 VHT 70.00 GLD, 17.00 ITOT, 5120.50 USD, 36.00 VEA, 294.00 VHT
``` ```
- Limited wide layout. A width limit reduces the width, but some commodities will be hidden: A width limit reduces the width, but some commodities will be hidden:
```cli ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide,32 $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=wide,32
Balance changes in 2012-01-01..2014-12-31: Balance changes in 2012-01-01..2014-12-31:
@ -718,7 +719,8 @@ Examples:
|| 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more.. || 10.00 ITOT, 337.18 USD, 2 more.. 70.00 GLD, 18.00 ITOT, 3 more.. -11.00 ITOT, 3 more.. 70.00 GLD, 17.00 ITOT, 3 more..
``` ```
- Tall layout. Each commodity gets a new line (may be different in each column), and account names are repeated: #### Tall layout
Each commodity gets a new line (may be different in each column), and account names are repeated:
```cli ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=tall
Balance changes in 2012-01-01..2014-12-31: Balance changes in 2012-01-01..2014-12-31:
@ -738,7 +740,9 @@ Examples:
|| 18.00 VHT 294.00 VHT || 18.00 VHT 294.00 VHT
``` ```
- Bare layout. Commodity symbols are kept in one column, each commodity gets its own report row, account names are repeated: #### Bare layout
Commodity symbols are kept in one column, each commodity has its own row,
amounts are bare numbers, account names are repeated:
```cli ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -T -Y --layout=bare
Balance changes in 2012-01-01..2014-12-31: Balance changes in 2012-01-01..2014-12-31:
@ -758,7 +762,7 @@ Examples:
|| VHT 106.00 18.00 170.00 294.00 || VHT 106.00 18.00 170.00 294.00
``` ```
- Bare layout also affects [CSV output](#output-format), Bare layout also affects [CSV output](#output-format),
which is useful for producing data that is easier to consume, eg for making charts: which is useful for producing data that is easier to consume, eg for making charts:
```cli ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -O csv --layout=bare $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -O csv --layout=bare
@ -775,16 +779,15 @@ Examples:
"total","VHT","294.00" "total","VHT","294.00"
``` ```
- Note: bare layout will sometimes display an extra row for the no-symbol commodity, Bare layout will sometimes display an extra row for the no-symbol commodity,
because of zero amounts (hledger treats zeroes as commodity-less, usually). because of zero amounts (hledger treats zeroes as commodity-less, usually).
This can break `hledger-bar` confusingly (workaround: add a `cur:` query to exclude This can break `hledger-bar` confusingly (workaround: add a `cur:` query to exclude
the no-symbol row). the no-symbol row).
- Tidy layout produces normalised "tidy data", where every variable #### Tidy layout
has its own column and each row represents a single data point. This produces normalised "tidy data" (see <https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html>)
See <https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html> for more. where every variable has its own column and each row represents a single data point.
This is the easiest kind of data for other software to consume. This is the easiest kind of data for other software to consume:
Here's how it looks:
```cli ```cli
$ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -Y -O csv --layout=tidy $ hledger -f examples/bcexample.hledger bal assets:us:etrade -3 -Y -O csv --layout=tidy
@ -806,7 +809,7 @@ Examples:
"Assets:US:ETrade","2014","2014-01-01","2014-12-31","VHT","170.00" "Assets:US:ETrade","2014","2014-01-01","2014-12-31","VHT","170.00"
``` ```
### Useful balance reports ### Some useful balance reports
Some frequently used `balance` options/reports are: Some frequently used `balance` options/reports are: