test and fix for register --depth

This commit is contained in:
Simon Michael 2009-04-02 02:52:23 +00:00
parent 1fc9d47bd8
commit 7ba0dc06a5
3 changed files with 15 additions and 2 deletions

1
NOTES
View File

@ -10,7 +10,6 @@ clever tricks like the plague." --Edsger Dijkstra
* to do
** errors
*** --depth works with reg -W but not with reg
*** register report should sort by date
** features
*** more ledger features

View File

@ -33,7 +33,8 @@ showRegisterReport opts args l
| otherwise = showtxns summaryts nulltxn startbal
where
interval = intervalFromOpts opts
ts = filterempties $ filter matchapats $ ledgerTransactions l
ts = filterempties $ filter matchapats $ filterdepth $ ledgerTransactions l
filterdepth = filter (\t -> (accountNameLevel $ account t) <= depth)
filterempties
| Empty `elem` opts = id
| otherwise = filter (not . isZeroMixedAmount . amount)

View File

@ -476,6 +476,19 @@ tests = [
]
, "register report with depth arg" ~:
do
l <- sampleledger
showRegisterReport [Depth "2"] [] l `is` unlines
["2008/01/01 income income:salary $-1 $-1"
,"2008/06/01 gift income:gifts $-1 $-2"
,"2008/06/03 eat & shop expenses:food $1 $-1"
," expenses:supplies $1 0"
," assets:cash $-2 $-2"
,"2008/12/31 pay off liabilities:debts $1 $-1"
]
,"show dollars" ~: show (dollars 1) ~?= "$1.00"
,"show hours" ~: show (hours 1) ~?= "1.0h"