move raw ledger functions to RawLedger

This commit is contained in:
Simon Michael 2008-10-03 12:10:05 +00:00
parent 26b6130a9b
commit 48700f323f
2 changed files with 16 additions and 18 deletions

View File

@ -287,21 +287,3 @@ pruneBoringBranches =
hasbalance = (/= 0) . abalance hasbalance = (/= 0) . abalance
hastxns = (> 0) . length . atransactions hastxns = (> 0) . length . atransactions
-- helpers
rawLedgerTransactions :: RawLedger -> [Transaction]
rawLedgerTransactions = txns . entries
where
txns :: [Entry] -> [Transaction]
txns es = concat $ map flattenEntry $ zip es (iterate (+1) 1)
rawLedgerAccountNamesUsed :: RawLedger -> [AccountName]
rawLedgerAccountNamesUsed = accountNamesFromTransactions . rawLedgerTransactions
rawLedgerAccountNames :: RawLedger -> [AccountName]
rawLedgerAccountNames = sort . expandAccountNames . rawLedgerAccountNamesUsed
rawLedgerAccountNameTree :: RawLedger -> Tree AccountName
rawLedgerAccountNameTree l = accountNameTreeFrom $ rawLedgerAccountNames l

View File

@ -13,6 +13,7 @@ import Ledger.Utils
import Ledger.Types import Ledger.Types
import Ledger.AccountName import Ledger.AccountName
import Ledger.Entry import Ledger.Entry
import Ledger.Transaction
instance Show RawLedger where instance Show RawLedger where
@ -20,3 +21,18 @@ instance Show RawLedger where
((length $ entries l) + ((length $ entries l) +
(length $ modifier_entries l) + (length $ modifier_entries l) +
(length $ periodic_entries l)) (length $ periodic_entries l))
rawLedgerTransactions :: RawLedger -> [Transaction]
rawLedgerTransactions = txns . entries
where
txns :: [Entry] -> [Transaction]
txns es = concat $ map flattenEntry $ zip es (iterate (+1) 1)
rawLedgerAccountNamesUsed :: RawLedger -> [AccountName]
rawLedgerAccountNamesUsed = accountNamesFromTransactions . rawLedgerTransactions
rawLedgerAccountNames :: RawLedger -> [AccountName]
rawLedgerAccountNames = sort . expandAccountNames . rawLedgerAccountNamesUsed
rawLedgerAccountNameTree :: RawLedger -> Tree AccountName
rawLedgerAccountNameTree l = accountNameTreeFrom $ rawLedgerAccountNames l