lib: more history awareness for account transactions report #392
The account transactions report (and eg hledger-ui's register screen) no longer aborts showing historical balances when -E/--empty/nonzero mode or cur: are in effect.
This commit is contained in:
parent
974b1e3be0
commit
156922e419
@ -26,6 +26,7 @@ module Hledger.Query (
|
|||||||
queryIsSym,
|
queryIsSym,
|
||||||
queryIsReal,
|
queryIsReal,
|
||||||
queryIsStatus,
|
queryIsStatus,
|
||||||
|
queryIsEmpty,
|
||||||
queryStartDate,
|
queryStartDate,
|
||||||
queryEndDate,
|
queryEndDate,
|
||||||
queryDateSpan,
|
queryDateSpan,
|
||||||
@ -480,6 +481,10 @@ queryIsStatus :: Query -> Bool
|
|||||||
queryIsStatus (Status _) = True
|
queryIsStatus (Status _) = True
|
||||||
queryIsStatus _ = False
|
queryIsStatus _ = False
|
||||||
|
|
||||||
|
queryIsEmpty :: Query -> Bool
|
||||||
|
queryIsEmpty (Empty _) = True
|
||||||
|
queryIsEmpty _ = False
|
||||||
|
|
||||||
-- | Does this query specify a start date and nothing else (that would
|
-- | Does this query specify a start date and nothing else (that would
|
||||||
-- filter postings prior to the date) ?
|
-- filter postings prior to the date) ?
|
||||||
-- When the flag is true, look for a starting secondary date instead.
|
-- When the flag is true, look for a starting secondary date instead.
|
||||||
|
|||||||
@ -149,9 +149,9 @@ accountTransactionsReport opts j reportq thisacctq = (label, items)
|
|||||||
|
|
||||||
-- starting balance: if we are filtering by a start date and nothing else,
|
-- starting balance: if we are filtering by a start date and nothing else,
|
||||||
-- this is the sum of the (possibly realness or status-filtered) postings
|
-- this is the sum of the (possibly realness or status-filtered) postings
|
||||||
-- to this account before that date; otherwise zero.
|
-- to this account before that date; otherwise start from zero.
|
||||||
(startbal,label) | queryIsNull q = (nullmixedamt, balancelabel)
|
(startbal,label) | queryIsNull q = (nullmixedamt, balancelabel)
|
||||||
| queryIsStartDateOnly (date2_ opts) q = (sumPostings priorps, balancelabel)
|
| queryIsStartBalancePreserving opts q = (sumPostings priorps, balancelabel)
|
||||||
| otherwise = (nullmixedamt, totallabel)
|
| otherwise = (nullmixedamt, totallabel)
|
||||||
where
|
where
|
||||||
priorps = -- ltrace "priorps" $
|
priorps = -- ltrace "priorps" $
|
||||||
@ -165,6 +165,20 @@ accountTransactionsReport opts j reportq thisacctq = (label, items)
|
|||||||
items = reverse $ -- see also registerChartHtml
|
items = reverse $ -- see also registerChartHtml
|
||||||
accountTransactionsReportItems q thisacctq startbal negate ts
|
accountTransactionsReportItems q thisacctq startbal negate ts
|
||||||
|
|
||||||
|
-- Assuming this query specifies a start date, if we switch that to
|
||||||
|
-- an end date, will the resulting query calculate an accurate
|
||||||
|
-- starting balance ?
|
||||||
|
-- XXX WIP, probably misses many balance-preserving cases,
|
||||||
|
-- not sure how this should work.
|
||||||
|
queryIsStartBalancePreserving :: ReportOpts -> Query -> Bool
|
||||||
|
queryIsStartBalancePreserving opts q =
|
||||||
|
queryIsStartDateOnly (date2_ opts) $
|
||||||
|
filterQuery (\q -> not (
|
||||||
|
queryIsEmpty q
|
||||||
|
|| queryIsSym q
|
||||||
|
-- || queryIsReal q))
|
||||||
|
)) q
|
||||||
|
|
||||||
totallabel = "Running Total"
|
totallabel = "Running Total"
|
||||||
balancelabel = "Historical Balance"
|
balancelabel = "Historical Balance"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user