diff --git a/Ledger.hs b/Ledger.hs index ae52fa0ec..aa6b8eec1 100644 --- a/Ledger.hs +++ b/Ledger.hs @@ -16,7 +16,7 @@ import RawLedger cacheLedger :: RawLedger -> Ledger cacheLedger l = let - ant = trace "caching" $ rawLedgerAccountNameTree l + ant = rawLedgerAccountNameTree l ans = flatten ant ts = rawLedgerTransactions l sortedts = sortBy (comparing account) ts @@ -24,8 +24,11 @@ cacheLedger l = tmap = Map.union (Map.fromList [(account $ head g, g) | g <- groupedts]) (Map.fromList [(a,[]) | a <- ans]) + txns a = tmap ! a + subaccts a = filter (isAccountNamePrefixOf a) ans + subtxns a = concat [txns a | a <- [a] ++ subaccts a] bmap = Map.union - (Map.fromList [(a, sumEntryTransactions $ transactionsWithOrBelowAccountName a ts) | a <- ans]) + (Map.fromList [(a, sumEntryTransactions $ subtxns a) | a <- ans]) (Map.fromList [(a,nullamt) | a <- ans]) amap = Map.fromList [(a, Account a (tmap ! a) (bmap ! a)) | a <- ans] in diff --git a/hledger.hs b/hledger.hs index 0f57c779c..d79d49c1e 100644 --- a/hledger.hs +++ b/hledger.hs @@ -65,7 +65,7 @@ selftest = do doWithLedger :: [Flag] -> (Ledger -> IO ()) -> IO () doWithLedger opts cmd = do - ledgerFilePath opts >>= (trace "parsing" $ parseLedgerFile) >>= doWithParsed cmd + ledgerFilePath opts >>= parseLedgerFile >>= doWithParsed cmd doWithParsed :: (Ledger -> IO ()) -> (Either ParseError RawLedger) -> IO () doWithParsed cmd parsed = do