ui: make --real/-R affect register/txn screens (#354)

This commit is contained in:
Simon Michael 2016-06-01 10:48:57 -07:00
parent a961988a88
commit 788021f5a4
2 changed files with 14 additions and 3 deletions

View File

@ -24,6 +24,7 @@ module Hledger.Query (
queryIsDateOrDate2,
queryIsStartDateOnly,
queryIsSym,
queryIsReal,
queryStartDate,
queryEndDate,
queryDateSpan,
@ -455,6 +456,10 @@ queryIsSym :: Query -> Bool
queryIsSym (Sym _) = True
queryIsSym _ = False
queryIsReal :: Query -> Bool
queryIsReal (Real _) = True
queryIsReal _ = False
-- | Does this query specify a start date and nothing else (that would
-- filter postings prior to the date) ?
-- When the flag is true, look for a starting secondary date instead.

View File

@ -37,6 +37,7 @@ import qualified Data.Text as T
import Hledger.Data
import Hledger.Query
import Hledger.Reports.ReportOptions
-- import Hledger.Utils.Debug
-- | A transactions report includes a list of transactions
@ -114,10 +115,15 @@ type AccountTransactionsReportItem =
accountTransactionsReport :: ReportOpts -> Journal -> Query -> Query -> AccountTransactionsReport
accountTransactionsReport opts j q thisacctquery = (label, items)
where
-- transactions with excluded currencies removed
-- transactions with excluded currencies and excluded virtual postings removed
ts1 = jtxns $
filterJournalAmounts (filterQuery queryIsSym q) $
journalSelectingAmountFromOpts opts j
(if queryIsNull realq then id else filterJournalPostings realq) $ -- apply Real filter if it's in q
(if queryIsNull symq then id else filterJournalAmounts symq) $ -- apply any cur:SYM filters in q
journalSelectingAmountFromOpts opts j -- convert amounts to cost basis if -B
where
realq = filterQuery queryIsReal q
symq = filterQuery queryIsSym q
-- affecting this account
ts2 = filter (matchesTransaction thisacctquery) ts1
-- with dates adjusted for account transactions report