mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-09 10:17:34 +03:00
query: drop the empty: query term
This seems to be equivalent to the --empty option, and overlaps a bit confusingly with amt:0. I think we can drop it.
This commit is contained in:
parent
20acc45fbb
commit
87d5ddfb71
@ -1017,7 +1017,6 @@ A query term can be any of the following:
|
||||
- `depth:N` - match (or display, depending on command) accounts at or above this [depth](#depth-limiting)
|
||||
- `status:*` or `status:!` or `status:` - match cleared, pending, or uncleared/pending transactions respectively
|
||||
- `real:1` or `real:0` - match real/virtual-ness
|
||||
- `empty:1` or `empty:0` - match if amount is/is not zero
|
||||
- `amt:N`, `amt:<N`, `amt:<=N`, `amt:>N`, `amt:>=N` - match postings with a single-commodity
|
||||
amount that is equal to, less than, or greater than N.
|
||||
(Multi-commodity amounts are not tested, and will always match.)
|
||||
|
@ -28,7 +28,6 @@ module Hledger.Query (
|
||||
queryDateSpan,
|
||||
queryDateSpan',
|
||||
queryDepth,
|
||||
queryEmpty,
|
||||
inAccount,
|
||||
inAccountQuery,
|
||||
-- * matching
|
||||
@ -541,23 +540,6 @@ queryDepth q = case queryDepth' q of [] -> 99999
|
||||
queryDepth' (And qs) = concatMap queryDepth' qs
|
||||
queryDepth' _ = []
|
||||
|
||||
-- | The empty (zero amount) status specified by this query, defaulting to false.
|
||||
queryEmpty :: Query -> Bool
|
||||
queryEmpty = headDef False . queryEmpty'
|
||||
where
|
||||
queryEmpty' (Empty v) = [v]
|
||||
queryEmpty' (Or qs) = concatMap queryEmpty' qs
|
||||
queryEmpty' (And qs) = concatMap queryEmpty' qs
|
||||
queryEmpty' _ = []
|
||||
|
||||
-- -- | The "include empty" option specified by this query, defaulting to false.
|
||||
-- emptyQueryOpt :: [QueryOpt] -> Bool
|
||||
-- emptyQueryOpt = headDef False . emptyQueryOpt'
|
||||
-- where
|
||||
-- emptyQueryOpt' [] = False
|
||||
-- emptyQueryOpt' (QueryOptEmpty v:_) = v
|
||||
-- emptyQueryOpt' (_:vs) = emptyQueryOpt' vs
|
||||
|
||||
-- | The account we are currently focussed on, if any, and whether subaccounts are included.
|
||||
-- Just looks at the first query option.
|
||||
inAccount :: [QueryOpt] -> Maybe (AccountName,Bool)
|
||||
|
@ -80,7 +80,7 @@ postingsReport opts q j = (totallabel, items)
|
||||
journalPostings $ journalSelectingAmountFromOpts opts j
|
||||
(precedingps, reportps) = dbg1 "precedingps, reportps" $ span (beforestartq `matchesPosting`) pstoend
|
||||
|
||||
showempty = queryEmpty q || average_ opts
|
||||
showempty = empty_ opts || average_ opts
|
||||
-- displayexpr = display_ opts -- XXX
|
||||
interval = intervalFromOpts opts -- XXX
|
||||
|
||||
@ -234,7 +234,7 @@ tests_postingsReport = [
|
||||
-- with query and/or command-line options
|
||||
assertEqual "" 11 (length $ snd $ postingsReport defreportopts Any samplejournal)
|
||||
assertEqual "" 9 (length $ snd $ postingsReport defreportopts{monthly_=True} Any samplejournal)
|
||||
assertEqual "" 19 (length $ snd $ postingsReport defreportopts{monthly_=True} (Empty True) samplejournal)
|
||||
assertEqual "" 19 (length $ snd $ postingsReport defreportopts{monthly_=True, empty_=True} Any samplejournal)
|
||||
assertEqual "" 4 (length $ snd $ postingsReport defreportopts (Acct "assets:bank:checking") samplejournal)
|
||||
|
||||
-- (defreportopts, And [Acct "a a", Acct "'b"], samplejournal2) `gives` 0
|
||||
|
Loading…
Reference in New Issue
Block a user