register: make reporting intervals honour a display expression (#18)
This commit is contained in:
parent
86f14b10a9
commit
2edb9e4a79
@ -33,7 +33,7 @@ showRegisterReport opts filterspec l
|
||||
summaryps = concatMap summarisespan spans
|
||||
summarisespan s = summarisePostingsInDateSpan s depth empty (postingsinspan s)
|
||||
postingsinspan s = filter (isPostingInDateSpan s) displayedps
|
||||
spans = splitSpan interval (ledgerDateSpan l)
|
||||
spans = splitSpan interval (postingsDateSpan displayedps)
|
||||
interval = intervalFromOpts opts
|
||||
empty = Empty `elem` opts
|
||||
depth = depthFromOpts opts
|
||||
|
||||
@ -138,11 +138,7 @@ ledgerAccountTreeAt l acct = subtreeat acct $ ledgerAccountTree 9999 l
|
||||
-- | The (fully specified) date span containing all the ledger's (filtered) transactions,
|
||||
-- or DateSpan Nothing Nothing if there are none.
|
||||
ledgerDateSpan :: Ledger -> DateSpan
|
||||
ledgerDateSpan l
|
||||
| null ps = DateSpan Nothing Nothing
|
||||
| otherwise = DateSpan (Just $ postingDate $ head ps) (Just $ addDays 1 $ postingDate $ last ps)
|
||||
where
|
||||
ps = sortBy (comparing postingDate) $ ledgerPostings l
|
||||
ledgerDateSpan = postingsDateSpan . ledgerPostings
|
||||
|
||||
-- | Convenience aliases.
|
||||
accountnames :: Ledger -> [AccountName]
|
||||
|
||||
@ -86,3 +86,10 @@ isPostingInDateSpan (DateSpan (Just b) (Just e)) p = d >= b && d < e where d = p
|
||||
isEmptyPosting :: Posting -> Bool
|
||||
isEmptyPosting = isZeroMixedAmount . pamount
|
||||
|
||||
-- | Get the minimal date span which contains all the postings, or
|
||||
-- DateSpan Nothing Nothing if there are none.
|
||||
postingsDateSpan :: [Posting] -> DateSpan
|
||||
postingsDateSpan [] = DateSpan Nothing Nothing
|
||||
postingsDateSpan ps = DateSpan (Just $ postingDate $ head ps') (Just $ addDays 1 $ postingDate $ last ps')
|
||||
where ps' = sortBy (comparing postingDate) ps
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user