From 068cec31eb131325b059f3732df7586f90cdf28a Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 9 Jun 2023 08:04:06 -1000 Subject: [PATCH] imp:cli: `desc` is now preferred for pivoting on description. `description` still works for compatibility (undocumented). --- hledger-lib/Hledger/Data/Journal.hs | 3 ++- hledger/hledger.m4.md | 2 +- hledger/test/pivot.test | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 6853d500c..3183d0c34 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -1094,7 +1094,8 @@ pivotComponent :: Text -> Posting -> Text pivotComponent fieldortagname p | fieldortagname == "acct" = paccount p | 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 == "note" = transactionNote t | Just t <- ptransaction p, fieldortagname == "status" = T.pack . show . tstatus $ t diff --git a/hledger/hledger.m4.md b/hledger/hledger.m4.md index 03650f843..684bc9cd9 100644 --- a/hledger/hledger.m4.md +++ b/hledger/hledger.m4.md @@ -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. 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. -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. 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. diff --git a/hledger/test/pivot.test b/hledger/test/pivot.test index b3b90d335..836ac1f82 100644 --- a/hledger/test/pivot.test +++ b/hledger/test/pivot.test @@ -64,7 +64,7 @@ $ hledger -f- --pivot expenses reg not:liabilities 2016/02/16 Freifunk assets:bank account 2 EUR ; date:03/01 income:donations -2 EUR -$ hledger -f- --pivot description reg -M +$ hledger -f- --pivot desc reg -M 2016-02 Freifunk -2 EUR -2 EUR 2016-03 Freifunk 2 EUR 0 @@ -85,7 +85,7 @@ $ hledger -f- --pivot code reg -M $ hledger -f- --pivot code reg ^income 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 assets:bank account @@ -99,7 +99,7 @@ $ hledger -f- --pivot payee bal --no-total --flat ^expense 22 EUR Auchan 5 EUR StarBars -# 10. get daily expenses by description/payee +# 10. get daily expenses by payee < 2016/02/16 (1138) Auchan assets:bank account