lib: keep amounts aligned when rendering a transaction with posting flags
Related to #563, when rendering a transaction, we reserve two more chars of width so that amounts remain aligned when there are posting flags. Affects hledger-ui's transaction screen, print, hledger-rewrite etc.
This commit is contained in:
parent
1adc636554
commit
5c09553481
@ -216,8 +216,8 @@ postingAsLines elideamount onelineamounts ps p = concat [
|
|||||||
assertion = maybe "" ((" = " ++) . showAmountWithZeroCommodity) $ pbalanceassertion p
|
assertion = maybe "" ((" = " ++) . showAmountWithZeroCommodity) $ pbalanceassertion p
|
||||||
statusandaccount = indent $ fitString (Just $ minwidth) Nothing False True $ pstatusandacct p
|
statusandaccount = indent $ fitString (Just $ minwidth) Nothing False True $ pstatusandacct p
|
||||||
where
|
where
|
||||||
-- pad to the maximum account name width, to keep amounts aligned
|
-- pad to the maximum account name width, plus 2 to leave room for status flags, to keep amounts aligned
|
||||||
minwidth = maximum $ map (textWidth . T.pack . pacctstr) ps
|
minwidth = maximum $ map ((2+) . textWidth . T.pack . pacctstr) ps
|
||||||
pstatusandacct p' = pstatusprefix p' ++ pacctstr p'
|
pstatusandacct p' = pstatusprefix p' ++ pacctstr p'
|
||||||
pstatusprefix p' | null s = ""
|
pstatusprefix p' | null s = ""
|
||||||
| otherwise = s ++ " "
|
| otherwise = s ++ " "
|
||||||
|
|||||||
@ -222,7 +222,7 @@
|
|||||||
>>>=0
|
>>>=0
|
||||||
|
|
||||||
# Rewrite using diff output
|
# Rewrite using diff output
|
||||||
../../bin/hledger-rewrite --diff -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' --add-posting 'assets:bank $-5'
|
../../bin/hledger-rewrite.hs --diff -f- assets:bank and 'amt:<0' --add-posting 'expenses:fee $5' --add-posting 'assets:bank $-5'
|
||||||
<<<
|
<<<
|
||||||
2016/01/01 withdraw
|
2016/01/01 withdraw
|
||||||
assets:cash $20
|
assets:cash $20
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user