matched the logic for Balance.hs to allow date: for historical queries to be correct

This commit is contained in:
Justin Le 2017-03-27 13:53:24 -07:00
parent 4b0ba0f011
commit b06739f714

View File

@ -79,7 +79,14 @@ balanceviewQueryReport
balanceviewQueryReport ropts q0 j t q = ([view], Sum amt) balanceviewQueryReport ropts q0 j t q = ([view], Sum amt)
where where
q' = And [q0, q j] q' = And [q0, q j]
rep@(_ , amt) = balanceReport ropts q' j rep@(_ , amt)
-- For --historical/--cumulative, we must use multiBalanceReport.
-- (This forces --no-elide.)
-- See Balance.hs's implementation of 'balance' for more information
| balancetype_ ropts `elem` [HistoricalBalance, CumulativeChange]
= singleBalanceReport ropts q' j
| otherwise
= balanceReport ropts q' j
view = intercalate "\n" [t <> ":", balanceReportAsText ropts rep] view = intercalate "\n" [t <> ":", balanceReportAsText ropts rep]
multiBalanceviewQueryReport multiBalanceviewQueryReport
@ -145,9 +152,15 @@ balanceviewReport BalanceView{..} CliOpts{reportopts_=ropts, rawopts_=raw} j = d
"cumulative":_ -> CumulativeChange "cumulative":_ -> CumulativeChange
"change":_ -> PeriodChange "change":_ -> PeriodChange
_ -> bvtype _ -> bvtype
ropts' = emptyMulti . stripBeginDate $ ropts { balancetype_ = balancetype } ropts' = emptyMulti . treeIfNotChange $ ropts { balancetype_ = balancetype }
stripBeginDate = case (balancetype, interval_ ropts) of treeIfNotChange = case (balancetype, interval_ ropts) of
(HistoricalBalance, NoInterval) -> withoutBeginDate -- For --historical/--cumulative, we must use multiBalanceReport.
-- (This forces --no-elide.)
-- These settings format the output in a way that we can convert to
-- a normal balance report using singleBalanceReport. See
-- Balance.hs for more information.
(HistoricalBalance, NoInterval) -> \o -> o { accountlistmode_ = ALTree }
(CumulativeChange , NoInterval) -> \o -> o { accountlistmode_ = ALTree }
_ -> id _ -> id
emptyMulti = case interval_ ropts of emptyMulti = case interval_ ropts of
NoInterval -> id NoInterval -> id
@ -157,7 +170,8 @@ balanceviewReport BalanceView{..} CliOpts{reportopts_=ropts, rawopts_=raw} j = d
withoutBeginDate :: ReportOpts -> ReportOpts withoutBeginDate :: ReportOpts -> ReportOpts
withoutBeginDate ropts@ReportOpts{..} = ropts{period_=p} withoutBeginDate = id
where -- withoutBeginDate ropts@ReportOpts{..} = ropts{period_=p}
p = dateSpanAsPeriod $ DateSpan Nothing (periodEnd period_) -- where
-- p = dateSpanAsPeriod $ DateSpan Nothing (periodEnd period_)