register command sorts transactions by date

(unlike ledger)
This commit is contained in:
Simon Michael 2009-04-02 04:42:10 +00:00
parent 8256a4fcbd
commit 7521992e85
2 changed files with 15 additions and 1 deletions

View File

@ -33,7 +33,8 @@ showRegisterReport opts args l
| otherwise = showtxns summaryts nulltxn startbal | otherwise = showtxns summaryts nulltxn startbal
where where
interval = intervalFromOpts opts interval = intervalFromOpts opts
ts = filterempties $ filter matchapats $ filterdepth $ ledgerTransactions l ts = sort $ filterempties $ filter matchapats $ filterdepth $ ledgerTransactions l
where sort = sortBy (\a b -> compare (date a) (date b))
filterdepth | interval == NoInterval = filter (\t -> (accountNameLevel $ account t) <= depth) filterdepth | interval == NoInterval = filter (\t -> (accountNameLevel $ account t) <= depth)
| otherwise = id | otherwise = id
filterempties filterempties

View File

@ -447,6 +447,19 @@ tests = [
," assets:bank:checking $-1 0" ," assets:bank:checking $-1 0"
] ]
,"register report sorts by date" ~:
do
l <- ledgerfromstringwithopts [] [] sampletime $ unlines
["2008/02/02 a"
," b 1"
," c"
,""
,"2008/01/01 d"
," e 1"
," f"
]
registerdates (showRegisterReport [] [] l) `is` ["2008/01/01","2008/02/02"]
,"register report with account pattern" ~: ,"register report with account pattern" ~:
do do
l <- sampleledger l <- sampleledger