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.
This commit is contained in:
Simon Michael 2017-01-13 13:53:39 -08:00
parent dfbb683573
commit 39662260cd
2 changed files with 5 additions and 5 deletions

View File

@ -92,7 +92,7 @@ pivot tag j = j{jtxns = map pivotTrans . jtxns $ j}
pivotTrans t = t{tpostings = map pivotPosting . tpostings $ t} pivotTrans t = t{tpostings = map pivotPosting . tpostings $ t}
pivotPosting p pivotPosting p
| Just (_ , value) <- tagTuple = p{paccount = value, porigin = Just $ originalPosting 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 where tagTuple = find ((tag ==) . fst) . postingAllImplicitTags $ p
-- | Apply the anonymisation transformation on a journal, if option is present -- | Apply the anonymisation transformation on a journal, if option is present

View File

@ -9,7 +9,7 @@ hledger -f- --pivot TAG print
; TAG: value ; TAG: value
>>> >>>
2016/02/16 Test Transaction 2016/02/16 Test Transaction
Account1 2 EUR 2 EUR
value -2 EUR value -2 EUR
; TAG: value ; TAG: value
@ -23,8 +23,8 @@ hledger -f- --pivot member bal --no-total
income:member fees -2 EUR income:member fees -2 EUR
; member: John Doe ; member: John Doe
>>> >>>
2 EUR
-2 EUR John Doe -2 EUR John Doe
2 EUR assets:bank account
>>>=0 >>>=0
# check with another example # check with another example
@ -35,8 +35,8 @@ hledger -f- --pivot budget bal --no-total
income:donations -2 EUR income:donations -2 EUR
; budget: Freifunk ; budget: Freifunk
>>> >>>
2 EUR
-2 EUR Freifunk -2 EUR Freifunk
2 EUR assets:bank account
>>>=0 >>>=0
# query on account will find either effective name or original one # query on account will find either effective name or original one