subAccounts test and bugfix

This commit is contained in:
Simon Michael 2009-03-15 04:06:10 +00:00
parent c1267ff17c
commit 2dac5754c7
2 changed files with 7 additions and 1 deletions

View File

@ -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]

View File

@ -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