lib: show pending posting flags when rendering a transaction (fix #563)
This affects hledger-ui's transaction screen, print, hledger-rewrite etc. A pending flag on postings is now displayed, just like a cleared flag. Also there will now be a space between flag and account name. And it's slightly better at aligning amounts, due to now considering virtual posting parentheses/brackets or something.
This commit is contained in:
parent
cd70bb1a86
commit
1adc636554
@ -212,14 +212,17 @@ postingAsLines elideamount onelineamounts ps p = concat [
|
|||||||
++ newlinecomments
|
++ newlinecomments
|
||||||
| postingblock <- postingblocks]
|
| postingblock <- postingblocks]
|
||||||
where
|
where
|
||||||
postingblocks = [map rstrip $ lines $ concatTopPadded [account, " ", amount, assertion, samelinecomment] | amount <- shownAmounts]
|
postingblocks = [map rstrip $ lines $ concatTopPadded [statusandaccount, " ", amount, assertion, samelinecomment] | amount <- shownAmounts]
|
||||||
assertion = maybe "" ((" = " ++) . showAmountWithZeroCommodity) $ pbalanceassertion p
|
assertion = maybe "" ((" = " ++) . showAmountWithZeroCommodity) $ pbalanceassertion p
|
||||||
account =
|
statusandaccount = indent $ fitString (Just $ minwidth) Nothing False True $ pstatusandacct p
|
||||||
indent $
|
|
||||||
showstatus p ++ fitString (Just acctwidth) Nothing False True (showAccountName Nothing (ptype p) (paccount p))
|
|
||||||
where
|
where
|
||||||
showstatus p = if pstatus p == Cleared then "* " else ""
|
-- pad to the maximum account name width, to keep amounts aligned
|
||||||
acctwidth = maximum $ map (textWidth . paccount) ps
|
minwidth = maximum $ map (textWidth . T.pack . pacctstr) ps
|
||||||
|
pstatusandacct p' = pstatusprefix p' ++ pacctstr p'
|
||||||
|
pstatusprefix p' | null s = ""
|
||||||
|
| otherwise = s ++ " "
|
||||||
|
where s = show $ pstatus p'
|
||||||
|
pacctstr p' = showAccountName Nothing (ptype p') (paccount p')
|
||||||
|
|
||||||
-- currently prices are considered part of the amount string when right-aligning amounts
|
-- currently prices are considered part of the amount string when right-aligning amounts
|
||||||
shownAmounts
|
shownAmounts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user