imp:cli: desc is now preferred for pivoting on description.

`description` still works for compatibility (undocumented).
This commit is contained in:
Simon Michael 2023-06-09 08:04:06 -10:00
parent 103d7142d2
commit 068cec31eb
3 changed files with 6 additions and 5 deletions

View File

@ -1094,7 +1094,8 @@ pivotComponent :: Text -> Posting -> Text
pivotComponent fieldortagname p pivotComponent fieldortagname p
| fieldortagname == "acct" = paccount p | fieldortagname == "acct" = paccount p
| Just t <- ptransaction p, fieldortagname == "code" = tcode t | Just t <- ptransaction p, fieldortagname == "code" = tcode t
| Just t <- ptransaction p, fieldortagname == "description" = tdescription t | Just t <- ptransaction p, fieldortagname == "desc" = tdescription t
| Just t <- ptransaction p, fieldortagname == "description" = tdescription t -- backward compatible with 1.30 and older
| Just t <- ptransaction p, fieldortagname == "payee" = transactionPayee t | Just t <- ptransaction p, fieldortagname == "payee" = transactionPayee t
| Just t <- ptransaction p, fieldortagname == "note" = transactionNote t | Just t <- ptransaction p, fieldortagname == "note" = transactionNote t
| Just t <- ptransaction p, fieldortagname == "status" = T.pack . show . tstatus $ t | Just t <- ptransaction p, fieldortagname == "status" = T.pack . show . tstatus $ t

View File

@ -4742,7 +4742,7 @@ see the discussion at [#1625](https://github.com/simonmichael/hledger/issues/162
Normally, hledger groups and sums amounts within each account. Normally, hledger groups and sums amounts within each account.
The `--pivot FIELD` option substitutes some other transaction field for account names, The `--pivot FIELD` option substitutes some other transaction field for account names,
causing amounts to be grouped and summed by that field's value instead. causing amounts to be grouped and summed by that field's value instead.
FIELD can be any of the transaction fields `acct`, `status`, `code`, `description`, `payee`, `note`, or a tag name. FIELD can be any of the transaction fields `acct`, `status`, `code`, `desc`, `payee`, `note`, or a tag name.
When pivoting on a tag and a posting has multiple values of that tag, only the first value is displayed. When pivoting on a tag and a posting has multiple values of that tag, only the first value is displayed.
Values containing `colon:separated:parts` will be displayed hierarchically, like account names. Values containing `colon:separated:parts` will be displayed hierarchically, like account names.
Multiple, colon-delimited fields can be pivoted simultaneously, generating a hierarchical account name. Multiple, colon-delimited fields can be pivoted simultaneously, generating a hierarchical account name.

View File

@ -64,7 +64,7 @@ $ hledger -f- --pivot expenses reg not:liabilities
2016/02/16 Freifunk 2016/02/16 Freifunk
assets:bank account 2 EUR ; date:03/01 assets:bank account 2 EUR ; date:03/01
income:donations -2 EUR income:donations -2 EUR
$ hledger -f- --pivot description reg -M $ hledger -f- --pivot desc reg -M
2016-02 Freifunk -2 EUR -2 EUR 2016-02 Freifunk -2 EUR -2 EUR
2016-03 Freifunk 2 EUR 0 2016-03 Freifunk 2 EUR 0
@ -85,7 +85,7 @@ $ hledger -f- --pivot code reg -M
$ hledger -f- --pivot code reg ^income $ hledger -f- --pivot code reg ^income
2016-02-16 Donation Freifunk Freifunk -2 EUR -2 EUR 2016-02-16 Donation Freifunk Freifunk -2 EUR -2 EUR
# 9. get expenses balance by description/payee # 9. get expenses balance by payee
< <
2016/02/16 (1138) Auchan | buy a food for tomorrow morning 2016/02/16 (1138) Auchan | buy a food for tomorrow morning
assets:bank account assets:bank account
@ -99,7 +99,7 @@ $ hledger -f- --pivot payee bal --no-total --flat ^expense
22 EUR Auchan 22 EUR Auchan
5 EUR StarBars 5 EUR StarBars
# 10. get daily expenses by description/payee # 10. get daily expenses by payee
< <
2016/02/16 (1138) Auchan 2016/02/16 (1138) Auchan
assets:bank account assets:bank account