cleanups
This commit is contained in:
parent
60bda57a26
commit
23e3c81acc
@ -71,7 +71,7 @@ instance Show Ledger where
|
|||||||
(length $ accountnames l)
|
(length $ accountnames l)
|
||||||
(showtree $ accountnametree l)
|
(showtree $ accountnametree l)
|
||||||
|
|
||||||
-- | Convert a raw ledger to a more efficient cached type, described above.
|
-- | Convert a journal to a more efficient cached ledger, described above.
|
||||||
cacheLedger :: [String] -> Journal -> Ledger
|
cacheLedger :: [String] -> Journal -> Ledger
|
||||||
cacheLedger apats j = Ledger{journaltext="",journal=j,accountnametree=ant,accountmap=acctmap}
|
cacheLedger apats j = Ledger{journaltext="",journal=j,accountnametree=ant,accountmap=acctmap}
|
||||||
where
|
where
|
||||||
@ -79,11 +79,10 @@ cacheLedger apats j = Ledger{journaltext="",journal=j,accountnametree=ant,accoun
|
|||||||
acctmap = Map.fromList [(a, mkacct a) | a <- flatten ant]
|
acctmap = Map.fromList [(a, mkacct a) | a <- flatten ant]
|
||||||
where mkacct a = Account a (psof a) (inclbalof a)
|
where mkacct a = Account a (psof a) (inclbalof a)
|
||||||
|
|
||||||
-- | Given a list of transactions, return an account name tree and three
|
-- | Given a list of postings, return an account name tree and three query
|
||||||
-- query functions that fetch transactions, balance, and
|
-- functions that fetch postings, balance, and subaccount-including
|
||||||
-- subaccount-including balance by account name.
|
-- balance by account name. This factors out common logic from
|
||||||
-- This is to factor out common logic from cacheLedger and
|
-- cacheLedger and summarisePostingsInDateSpan.
|
||||||
-- summarisePostingsInDateSpan.
|
|
||||||
groupPostings :: [Posting] -> (Tree AccountName,
|
groupPostings :: [Posting] -> (Tree AccountName,
|
||||||
(AccountName -> [Posting]),
|
(AccountName -> [Posting]),
|
||||||
(AccountName -> MixedAmount),
|
(AccountName -> MixedAmount),
|
||||||
|
|||||||
@ -124,17 +124,6 @@ data Journal = Journal {
|
|||||||
filereadtime :: ClockTime
|
filereadtime :: ClockTime
|
||||||
} deriving (Eq)
|
} deriving (Eq)
|
||||||
|
|
||||||
-- | A generic, pure specification of how to filter raw ledger transactions.
|
|
||||||
data FilterSpec = FilterSpec {
|
|
||||||
datespan :: DateSpan -- ^ only include transactions in this date span
|
|
||||||
,cleared :: Maybe Bool -- ^ only include if cleared\/uncleared\/don't care
|
|
||||||
,real :: Bool -- ^ only include if real\/don't care
|
|
||||||
,costbasis :: Bool -- ^ convert all amounts to cost basis
|
|
||||||
,acctpats :: [String] -- ^ only include if matching these account patterns
|
|
||||||
,descpats :: [String] -- ^ only include if matching these description patterns
|
|
||||||
,whichdate :: WhichDate -- ^ which dates to use (transaction or effective)
|
|
||||||
}
|
|
||||||
|
|
||||||
data Account = Account {
|
data Account = Account {
|
||||||
aname :: AccountName,
|
aname :: AccountName,
|
||||||
apostings :: [Posting], -- ^ transactions in this account
|
apostings :: [Posting], -- ^ transactions in this account
|
||||||
@ -148,3 +137,14 @@ data Ledger = Ledger {
|
|||||||
accountmap :: Map.Map AccountName Account
|
accountmap :: Map.Map AccountName Account
|
||||||
} deriving Typeable
|
} deriving Typeable
|
||||||
|
|
||||||
|
-- | A generic, pure specification of how to filter transactions/postings.
|
||||||
|
data FilterSpec = FilterSpec {
|
||||||
|
datespan :: DateSpan -- ^ only include if in this date span
|
||||||
|
,cleared :: Maybe Bool -- ^ only include if cleared\/uncleared\/don't care
|
||||||
|
,real :: Bool -- ^ only include if real\/don't care
|
||||||
|
,costbasis :: Bool -- ^ convert all amounts to cost basis
|
||||||
|
,acctpats :: [String] -- ^ only include if matching these account patterns
|
||||||
|
,descpats :: [String] -- ^ only include if matching these description patterns
|
||||||
|
,whichdate :: WhichDate -- ^ which dates to use (actual or effective)
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user