amount display tests, fix a case where "auto" amount was displayed as 0
This commit is contained in:
parent
9f565157e0
commit
278e5dde64
@ -201,7 +201,7 @@ showMixedAmountWithoutPrice m = concat $ intersperse "\n" $ map showfixedwidth a
|
|||||||
-- | Get the string representation of a mixed amount, and if it
|
-- | Get the string representation of a mixed amount, and if it
|
||||||
-- appears to be all zero just show a bare 0, ledger-style.
|
-- appears to be all zero just show a bare 0, ledger-style.
|
||||||
showMixedAmountOrZero :: MixedAmount -> String
|
showMixedAmountOrZero :: MixedAmount -> String
|
||||||
showMixedAmountOrZero a
|
showMixedAmountOrZero a | a == missingamt = ""
|
||||||
| isZeroMixedAmount a = "0"
|
| isZeroMixedAmount a = "0"
|
||||||
| otherwise = showMixedAmount a
|
| otherwise = showMixedAmount a
|
||||||
|
|
||||||
@ -270,7 +270,14 @@ missingamt = Mixed [Amount Commodity {symbol="AUTO",side=L,spaced=False,comma=Fa
|
|||||||
tests_Amount = TestList [
|
tests_Amount = TestList [
|
||||||
|
|
||||||
"showMixedAmount" ~: do
|
"showMixedAmount" ~: do
|
||||||
showMixedAmount (Mixed []) ~?= "0"
|
showMixedAmount (Mixed [Amount dollar 0 Nothing]) `is` "$0.00"
|
||||||
|
showMixedAmount (Mixed []) `is` "0"
|
||||||
|
showMixedAmount missingamt `is` ""
|
||||||
|
|
||||||
|
,"showMixedAmountOrZero" ~: do
|
||||||
|
showMixedAmountOrZero (Mixed [Amount dollar 0 Nothing]) `is` "0"
|
||||||
|
showMixedAmountOrZero (Mixed []) `is` "0"
|
||||||
|
showMixedAmountOrZero missingamt `is` ""
|
||||||
|
|
||||||
,"amount arithmetic" ~: do
|
,"amount arithmetic" ~: do
|
||||||
let a1 = dollars 1.23
|
let a1 = dollars 1.23
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user