print: always right-align amounts
print now always right-aligns the amounts in an entry, even when they are wider than 12 characters. If there is a price, it's considered part of the amount for right-alignment. Maybe it would be nicer to put amounts and prices in separate columns ? That will get a little complicated, needs more discussion/design. Also some cleanup of postingAsLines.
This commit is contained in:
parent
155722d7ee
commit
eb75946e64
@ -175,19 +175,25 @@ postingAsLines elideamount ps p =
|
|||||||
postinglines
|
postinglines
|
||||||
++ newlinecomments
|
++ newlinecomments
|
||||||
where
|
where
|
||||||
postinglines = map rstrip $ lines $ concatTopPadded [showacct p, " ", amount, samelinecomment]
|
postinglines = map rstrip $ lines $ concatTopPadded [account, " ", amount, samelinecomment]
|
||||||
amount = if elideamount then "" else showamt (pamount p)
|
|
||||||
|
account =
|
||||||
|
indent $
|
||||||
|
showstatus p ++ fitString (Just acctwidth) Nothing False True (showAccountName Nothing (ptype p) (paccount p))
|
||||||
|
where
|
||||||
|
showstatus p = if pstatus p == Cleared then "* " else ""
|
||||||
|
acctwidth = maximum $ map (strWidth . paccount) ps
|
||||||
|
|
||||||
|
-- currently prices are considered part of the amount string when right-aligning amounts
|
||||||
|
amount
|
||||||
|
| elideamount = ""
|
||||||
|
| otherwise = fitStringMulti (Just amtwidth) Nothing False False $ showMixedAmount $ pamount p
|
||||||
|
where
|
||||||
|
amtwidth = maximum $ 12 : map (strWidth . showMixedAmount . pamount) ps -- min. 12 for backwards compatibility
|
||||||
|
|
||||||
(samelinecomment, newlinecomments) =
|
(samelinecomment, newlinecomments) =
|
||||||
case renderCommentLines (pcomment p) of [] -> ("",[])
|
case renderCommentLines (pcomment p) of [] -> ("",[])
|
||||||
c:cs -> (c,cs)
|
c:cs -> (c,cs)
|
||||||
showacct p =
|
|
||||||
indent $
|
|
||||||
showstatus p ++ fitString (Just w) Nothing False True (showAccountName Nothing (ptype p) (paccount p))
|
|
||||||
where
|
|
||||||
showstatus p = if pstatus p == Cleared then "* " else ""
|
|
||||||
w = maximum $ map (strWidth . paccount) ps
|
|
||||||
showamt =
|
|
||||||
padLeftWide 12 . showMixedAmount
|
|
||||||
|
|
||||||
tests_postingAsLines = [
|
tests_postingAsLines = [
|
||||||
"postingAsLines" ~: do
|
"postingAsLines" ~: do
|
||||||
|
|||||||
@ -1,17 +1,46 @@
|
|||||||
# ALl output should preserve alignment etc. when showing wide characters.
|
# ALl output should preserve alignment etc. when showing wide characters
|
||||||
# XXX For a better test, the sample journals should have commodity symbols.
|
# (in apps and fonts which render wide chars as exactly double width).
|
||||||
# XXX How to test hledger-ui ?
|
#
|
||||||
|
# XXX add commodity symbols and prices to the sample journals
|
||||||
|
# XXX how to test hledger-ui ?
|
||||||
|
|
||||||
# 1.
|
# 1.
|
||||||
hledger -f chinese.journal print
|
# hledger -f chinese.journal print
|
||||||
|
# >>>
|
||||||
|
# 2014/01/01 transaction 1
|
||||||
|
# 㐀 1
|
||||||
|
# 㐀:㐁 -1
|
||||||
|
#
|
||||||
|
# 2014/01/02 transaction 2
|
||||||
|
# 㐀:㐁:㐂 1
|
||||||
|
# 㐀:㐁:㐂:㐃 -1
|
||||||
|
#
|
||||||
|
# 2014/01/03 transaction 3
|
||||||
|
# 㐀:㐁:㐂:㐃:㐄 1
|
||||||
|
# 㐀 -1
|
||||||
|
#
|
||||||
|
# >>>=0
|
||||||
|
hledger -f - print
|
||||||
|
<<<
|
||||||
|
2014-01-01 transaction 1
|
||||||
|
㐀 㐃㐃1 @ 2 㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂
|
||||||
|
㐀:㐁 ;㐃㐃-1
|
||||||
|
|
||||||
|
2014-01-02 transaction 2
|
||||||
|
㐀:㐁:㐂 USD 1
|
||||||
|
㐀:㐁:㐂:㐃 EUR -1
|
||||||
|
|
||||||
|
2014-01-03 transaction 3
|
||||||
|
㐀:㐁:㐂:㐃:㐄 1
|
||||||
|
㐀 -1
|
||||||
>>>
|
>>>
|
||||||
2014/01/01 transaction 1
|
2014/01/01 transaction 1
|
||||||
㐀 1
|
㐀 㐃㐃1 @ 2 㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂
|
||||||
㐀:㐁 -1
|
㐀:㐁 -2 㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂㐂 ; 㐃㐃-1
|
||||||
|
|
||||||
2014/01/02 transaction 2
|
2014/01/02 transaction 2
|
||||||
㐀:㐁:㐂 1
|
㐀:㐁:㐂 USD 1 @@ EUR 1
|
||||||
㐀:㐁:㐂:㐃 -1
|
㐀:㐁:㐂:㐃 EUR -1
|
||||||
|
|
||||||
2014/01/03 transaction 3
|
2014/01/03 transaction 3
|
||||||
㐀:㐁:㐂:㐃:㐄 1
|
㐀:㐁:㐂:㐃:㐄 1
|
||||||
|
|||||||
@ -15,7 +15,7 @@ hledger -f- print
|
|||||||
b
|
b
|
||||||
>>>
|
>>>
|
||||||
2010/04/05 x
|
2010/04/05 x
|
||||||
a 10 "DE 0002 635307"
|
a 10 "DE 0002 635307"
|
||||||
b -10 "DE 0002 635307"
|
b -10 "DE 0002 635307"
|
||||||
|
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|||||||
@ -10,7 +10,7 @@ hledger -f - print
|
|||||||
>>>
|
>>>
|
||||||
2010/01/01 x
|
2010/01/01 x
|
||||||
A 55.3653 C @ 30.92189512 D
|
A 55.3653 C @ 30.92189512 D
|
||||||
A -1712 D
|
A -1712 D
|
||||||
|
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ hledger -f- print
|
|||||||
2015/01/01
|
2015/01/01
|
||||||
c C 10.00 @ D 15.2381
|
c C 10.00 @ D 15.2381
|
||||||
c C 11.00 @ D 15.2381
|
c C 11.00 @ D 15.2381
|
||||||
d D -320.00
|
d D -320.00
|
||||||
|
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|
||||||
@ -157,6 +157,6 @@ hledger -f- print
|
|||||||
2015/01/01
|
2015/01/01
|
||||||
e E 10.0000 @ F 15.2380952
|
e E 10.0000 @ F 15.2380952
|
||||||
e E 11.0000 @ F 15.2380952
|
e E 11.0000 @ F 15.2380952
|
||||||
f F -320.000
|
f F -320.000
|
||||||
|
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|||||||
@ -85,7 +85,7 @@ hledger -f - print
|
|||||||
>>>
|
>>>
|
||||||
2002/09/30 * 1a1a6305d06ce4b284dba0d267c23f69d70c20be
|
2002/09/30 * 1a1a6305d06ce4b284dba0d267c23f69d70c20be
|
||||||
c56a21d23a6535184e7152ee138c28974f14280c 866.231000 GGGGG @@ $17,783.72
|
c56a21d23a6535184e7152ee138c28974f14280c 866.231000 GGGGG @@ $17,783.72
|
||||||
a35e82730cf91569c302b313780e5895f75a62b9 $-17,783.72
|
a35e82730cf91569c302b313780e5895f75a62b9 $-17,783.72
|
||||||
|
|
||||||
>>>=0
|
>>>=0
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user