From 2dac5754c7accbe3cd5fd50e8bfdc3e490e43fe7 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sun, 15 Mar 2009 04:06:10 +0000 Subject: [PATCH] subAccounts test and bugfix --- Ledger/Ledger.hs | 2 +- Tests.hs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Ledger/Ledger.hs b/Ledger/Ledger.hs index f82e961af..b01df5acd 100644 --- a/Ledger/Ledger.hs +++ b/Ledger/Ledger.hs @@ -111,7 +111,7 @@ accountsMatching pats l = filter (matchpats pats . aname) $ accounts l -- | List a ledger account's immediate subaccounts subAccounts :: Ledger -> Account -> [Account] subAccounts l Account{aname=a} = - map (ledgerAccount l) $ filter (a `isAccountNamePrefixOf`) $ accountnames l + map (ledgerAccount l) $ filter (`isSubAccountNameOf` a) $ accountnames l -- | List a ledger's transactions. ledgerTransactions :: Ledger -> [Transaction] diff --git a/Tests.hs b/Tests.hs index 086c6b788..9c8d718dd 100644 --- a/Tests.hs +++ b/Tests.hs @@ -536,6 +536,12 @@ tests = [ [mkdatespan "2008/01/01" "2008/01/01"] , + "subAccounts" ~: do + l <- sampleledger + let a = ledgerAccount l "assets" + (map aname $ subAccounts l a) `is` ["assets:bank","assets:cash"] + , + "summariseTransactionsInDateSpan" ~: do let (b,e,entryno,depth,showempty,ts) `gives` summaryts = summariseTransactionsInDateSpan (mkdatespan b e) entryno depth showempty ts `is` summaryts