From 7521992e85de009faecab51ece85c9832015ba29 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 2 Apr 2009 04:42:10 +0000 Subject: [PATCH] register command sorts transactions by date (unlike ledger) --- RegisterCommand.hs | 3 ++- Tests.hs | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RegisterCommand.hs b/RegisterCommand.hs index 344b55449..70562ebbc 100644 --- a/RegisterCommand.hs +++ b/RegisterCommand.hs @@ -33,7 +33,8 @@ showRegisterReport opts args l | otherwise = showtxns summaryts nulltxn startbal where 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) | otherwise = id filterempties diff --git a/Tests.hs b/Tests.hs index 1aa8b2997..64d9dab4a 100644 --- a/Tests.hs +++ b/Tests.hs @@ -447,6 +447,19 @@ tests = [ ," 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" ~: do l <- sampleledger