fix bug in eliding of posting amounts
This commit is contained in:
parent
e9a2fbd2e8
commit
f40d561273
@ -67,7 +67,8 @@ showLedgerTransaction' elide t =
|
|||||||
comment = if (length $ ltcomment t) > 0 then " ; "++(ltcomment t) else ""
|
comment = if (length $ ltcomment t) > 0 then " ; "++(ltcomment t) else ""
|
||||||
showdate d = printf "%-10s" (showDate d)
|
showdate d = printf "%-10s" (showDate d)
|
||||||
showpostings ps
|
showpostings ps
|
||||||
| elide && length ps == 2 = [showposting (ps !! 0), showpostingnoamt (ps !! 1)]
|
| elide && length ps > 1 && isLedgerTransactionBalanced t
|
||||||
|
= map showposting (init ps) ++ [showpostingnoamt (last ps)]
|
||||||
| otherwise = map showposting ps
|
| otherwise = map showposting ps
|
||||||
where
|
where
|
||||||
showposting p = showacct p ++ " " ++ (showamount $ pamount p) ++ (showcomment $ pcomment p)
|
showposting p = showacct p ++ " " ++ (showamount $ pamount p) ++ (showcomment $ pcomment p)
|
||||||
|
|||||||
35
Tests.hs
35
Tests.hs
@ -604,7 +604,7 @@ tests = [
|
|||||||
["2008/06/03 * eat & shop"
|
["2008/06/03 * eat & shop"
|
||||||
," expenses:food $1"
|
," expenses:food $1"
|
||||||
," expenses:supplies $1"
|
," expenses:supplies $1"
|
||||||
," assets:cash $-2"
|
," assets:cash"
|
||||||
,""
|
,""
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ tests = [
|
|||||||
,"2008/06/03 * eat & shop"
|
,"2008/06/03 * eat & shop"
|
||||||
," expenses:food $1"
|
," expenses:food $1"
|
||||||
," expenses:supplies $1"
|
," expenses:supplies $1"
|
||||||
," assets:cash $-2"
|
," assets:cash"
|
||||||
,""
|
,""
|
||||||
,"2008/12/31 * pay off"
|
,"2008/12/31 * pay off"
|
||||||
," liabilities:debts $1"
|
," liabilities:debts $1"
|
||||||
@ -762,7 +762,30 @@ tests = [
|
|||||||
,"show hours" ~: show (hours 1) ~?= "1.0h"
|
,"show hours" ~: show (hours 1) ~?= "1.0h"
|
||||||
|
|
||||||
,"showLedgerTransaction" ~: do
|
,"showLedgerTransaction" ~: do
|
||||||
showLedgerTransaction entry1 `is` entry1_str
|
assertEqual "show a balanced transaction, eliding last amount"
|
||||||
|
(unlines
|
||||||
|
["2007/01/28 coopportunity"
|
||||||
|
," expenses:food:groceries $47.18"
|
||||||
|
," assets:checking"
|
||||||
|
,""
|
||||||
|
])
|
||||||
|
(showLedgerTransaction
|
||||||
|
(LedgerTransaction (parsedate "2007/01/28") False "" "coopportunity" ""
|
||||||
|
[Posting False "expenses:food:groceries" (Mixed [dollars 47.18]) "" RegularPosting
|
||||||
|
,Posting False "assets:checking" (Mixed [dollars (-47.18)]) "" RegularPosting
|
||||||
|
] ""))
|
||||||
|
assertEqual "show an unbalanced transaction, should not elide"
|
||||||
|
(unlines
|
||||||
|
["2007/01/28 coopportunity"
|
||||||
|
," expenses:food:groceries $47.18"
|
||||||
|
," assets:checking $-47.19"
|
||||||
|
,""
|
||||||
|
])
|
||||||
|
(showLedgerTransaction
|
||||||
|
(LedgerTransaction (parsedate "2007/01/28") False "" "coopportunity" ""
|
||||||
|
[Posting False "expenses:food:groceries" (Mixed [dollars 47.18]) "" RegularPosting
|
||||||
|
,Posting False "assets:checking" (Mixed [dollars (-47.19)]) "" RegularPosting
|
||||||
|
] ""))
|
||||||
|
|
||||||
,"unicode in balance layout" ~: do
|
,"unicode in balance layout" ~: do
|
||||||
l <- ledgerFromStringWithOpts [] [] sampletime
|
l <- ledgerFromStringWithOpts [] [] sampletime
|
||||||
@ -958,9 +981,9 @@ entry1 =
|
|||||||
|
|
||||||
entry2_str = unlines
|
entry2_str = unlines
|
||||||
["2007/01/27 * joes diner"
|
["2007/01/27 * joes diner"
|
||||||
," expenses:food:dining $10.00"
|
," expenses:food:dining $10.00"
|
||||||
," expenses:gifts $10.00"
|
," expenses:gifts $10.00"
|
||||||
," assets:checking $-20.00"
|
," assets:checking $-20.00"
|
||||||
,""
|
,""
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user