From 39662260cd12603930f6826174b16ca983a71701 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 13 Jan 2017 13:53:39 -0800 Subject: [PATCH] cli: use a blank acct name for postings without the specified pivot tag Eg. if you --pivot code, postings from transactions with no code value were formerly displayed with the unpivoted account name, so you'd see a mixture of account names and codes. Now we always pivot the account name, to blank if nothing else. This probably makes reports pretty ugly, it's just another step towards making --pivot's behaviour clearer. --- hledger/Hledger/Cli/Utils.hs | 2 +- tests/misc/pivot.test | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hledger/Hledger/Cli/Utils.hs b/hledger/Hledger/Cli/Utils.hs index 4498307af..8dc171092 100644 --- a/hledger/Hledger/Cli/Utils.hs +++ b/hledger/Hledger/Cli/Utils.hs @@ -92,7 +92,7 @@ pivot tag j = j{jtxns = map pivotTrans . jtxns $ j} pivotTrans t = t{tpostings = map pivotPosting . tpostings $ t} pivotPosting p | Just (_ , value) <- tagTuple = p{paccount = value, porigin = Just $ originalPosting p} - | _ <- tagTuple = p + | _ <- tagTuple = p{paccount = T.pack ""} where tagTuple = find ((tag ==) . fst) . postingAllImplicitTags $ p -- | Apply the anonymisation transformation on a journal, if option is present diff --git a/tests/misc/pivot.test b/tests/misc/pivot.test index 743dd5de9..1dbe24196 100644 --- a/tests/misc/pivot.test +++ b/tests/misc/pivot.test @@ -9,8 +9,8 @@ hledger -f- --pivot TAG print ; TAG: value >>> 2016/02/16 Test Transaction - Account1 2 EUR - value -2 EUR + 2 EUR + value -2 EUR ; TAG: value >>>=0 @@ -23,8 +23,8 @@ hledger -f- --pivot member bal --no-total income:member fees -2 EUR ; member: John Doe >>> + 2 EUR -2 EUR John Doe - 2 EUR assets:bank account >>>=0 # check with another example @@ -35,8 +35,8 @@ hledger -f- --pivot budget bal --no-total income:donations -2 EUR ; budget: Freifunk >>> + 2 EUR -2 EUR Freifunk - 2 EUR assets:bank account >>>=0 # query on account will find either effective name or original one