fix register report and add a test

This commit is contained in:
Simon Michael 2008-10-18 03:19:50 +00:00
parent a1d10691a3
commit 0eb56821e9
2 changed files with 16 additions and 1 deletions

View File

@ -48,12 +48,14 @@ showTransactionWithDescription t b =
(showEntryDescription $ Entry (date t) False "" (description t) "" [] "") (showEntryDescription $ Entry (date t) False "" (description t) "" [] "")
++ (showTransactionFormatted t) ++ (showTransactionFormatted t)
++ (showBalance b) ++ (showBalance b)
++ "\n"
showTransactionWithoutDescription :: Transaction -> Amount -> String showTransactionWithoutDescription :: Transaction -> Amount -> String
showTransactionWithoutDescription t b = showTransactionWithoutDescription t b =
(replicate 32 ' ') (replicate 32 ' ')
++ (showTransactionFormatted t) ++ (showTransactionFormatted t)
++ (showBalance b) ++ (showBalance b)
++ "\n"
showTransactionFormatted :: Transaction -> String showTransactionFormatted :: Transaction -> String
showTransactionFormatted (Transaction eno d desc a amt ttype) = showTransactionFormatted (Transaction eno d desc a amt ttype) =

View File

@ -218,7 +218,20 @@ registercommandtests = TestList [
"register does something" ~: "register does something" ~:
do do
l <- ledgerfromfile "sample.ledger" 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. -- | Assert a parsed thing equals some expected thing, or print a parse error.