balance: multicolumn reports now use all data in the displayed periods

Previously, the first period's heading would show the start date of a
full period, but postings after this date but before the user-specified
report start date were not shown. Now those postings will be included,
making the first column's numbers more correct. Similarly, the report
end date is now adjusted to the displayed end date on the last column.
This commit is contained in:
Simon Michael 2014-04-14 13:10:34 -07:00
parent d008c810dc
commit 87e2d49714

View File

@ -69,17 +69,20 @@ multiBalanceReport opts q j = MultiBalanceReport (spans, items, totals)
-- dbg = const id -- exclude from debug output -- dbg = const id -- exclude from debug output
dbg s = let p = "multiBalanceReport" in Hledger.Utils.dbg (p++" "++s) -- add prefix in debug output dbg s = let p = "multiBalanceReport" in Hledger.Utils.dbg (p++" "++s) -- add prefix in debug output
nodepthq = dbg "nodepthq" $ filterQuery (not . queryIsDepth) q symq = dbg "symq" $ filterQuery queryIsSym $ dbg "requested q" q
depthq = dbg "depthq" $ filterQuery queryIsDepth q depthq = dbg "depthq" $ filterQuery queryIsDepth q
depth = queryDepth depthq depth = queryDepth depthq
symq = dbg "symq" $ filterQuery queryIsSym q depthless = dbg "depthless" . filterQuery (not . queryIsDepth)
datelessq = dbg "datelessq" $ filterQuery (not . queryIsDate) q
precedingq = dbg "precedingq" $ And [datelessq, Date $ DateSpan Nothing (spanStart reportspan)]
reportq = dbg "reportq" $ depthless $ And [datelessq, Date reportspan] -- laziness at work
ps :: [Posting] = ps :: [Posting] =
dbg "ps" $ dbg "ps" $
journalPostings $ journalPostings $
filterJournalPostingAmounts symq $ -- exclude amount parts excluded by cur: filterJournalPostingAmounts symq $ -- remove amount parts excluded by cur:
filterJournalPostings nodepthq $ -- exclude unmatched postings, but include all depths filterJournalPostings reportq $ -- remove postings not matched by (adjusted) query
journalSelectingAmountFromOpts opts j journalSelectingAmountFromOpts opts j
(reportspan, spans) = dbg "report spans" $ reportSpans opts q j ps (reportspan, spans) = dbg "report spans" $ reportSpans opts q j ps
@ -123,8 +126,6 @@ multiBalanceReport opts q j = MultiBalanceReport (spans, items, totals)
-- starting balances and accounts from transactions before the report start date -- starting balances and accounts from transactions before the report start date
startacctbals = dbg "startacctbals" $ map (\((a,_,_),b) -> (a,b)) $ startbalanceitems startacctbals = dbg "startacctbals" $ map (\((a,_,_),b) -> (a,b)) $ startbalanceitems
where where
dateless = filterQuery (not . queryIsDate)
precedingq = dbg "precedingq" $ And [dateless q, Date $ DateSpan Nothing (spanStart reportspan)]
(startbalanceitems,_) = dbg "starting balance report" $ balanceReport opts' precedingq j (startbalanceitems,_) = dbg "starting balance report" $ balanceReport opts' precedingq j
where where
opts' | tree_ opts = opts{no_elide_=True} opts' | tree_ opts = opts{no_elide_=True}