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