fix register report and add a test
This commit is contained in:
parent
a1d10691a3
commit
0eb56821e9
@ -48,12 +48,14 @@ showTransactionWithDescription t b =
|
||||
(showEntryDescription $ Entry (date t) False "" (description t) "" [] "")
|
||||
++ (showTransactionFormatted t)
|
||||
++ (showBalance b)
|
||||
++ "\n"
|
||||
|
||||
showTransactionWithoutDescription :: Transaction -> Amount -> String
|
||||
showTransactionWithoutDescription t b =
|
||||
(replicate 32 ' ')
|
||||
++ (showTransactionFormatted t)
|
||||
++ (showBalance b)
|
||||
++ "\n"
|
||||
|
||||
showTransactionFormatted :: Transaction -> String
|
||||
showTransactionFormatted (Transaction eno d desc a amt ttype) =
|
||||
|
||||
15
Tests.hs
15
Tests.hs
@ -218,7 +218,20 @@ registercommandtests = TestList [
|
||||
"register does something" ~:
|
||||
do
|
||||
l <- ledgerfromfile "sample.ledger"
|
||||
assertnotequal "" $ showRegisterReport [] [] l
|
||||
assertequal (
|
||||
"2007/01/01 income assets:checking $1 $1\n" ++
|
||||
" income:salary $-1 0\n" ++
|
||||
"2007/01/01 gift assets:checking $1 $1\n" ++
|
||||
" income:gifts $-1 0\n" ++
|
||||
"2007/01/01 save assets:saving $1 $1\n" ++
|
||||
" assets:checking $-1 0\n" ++
|
||||
"2007/01/01 eat & shop expenses:food $1 $1\n" ++
|
||||
" expenses:supplies $1 $2\n" ++
|
||||
" assets:cash $-2 0\n" ++
|
||||
"2008/01/01 pay off liabilities:debts $1 $1\n" ++
|
||||
" assets:checking $-1 0\n" ++
|
||||
"")
|
||||
$ showRegisterReport [] [] l
|
||||
]
|
||||
|
||||
-- | Assert a parsed thing equals some expected thing, or print a parse error.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user