web: "empty:" to select postings with zero or non-zero amount
This commit is contained in:
parent
68de79b933
commit
4bb0f2efbd
@ -25,17 +25,17 @@ import Text.ParserCombinators.Parsec
|
|||||||
import Hledger.Utils
|
import Hledger.Utils
|
||||||
import Hledger.Data.Types
|
import Hledger.Data.Types
|
||||||
import Hledger.Data.AccountName
|
import Hledger.Data.AccountName
|
||||||
-- import Hledger.Data.Amount
|
import Hledger.Data.Amount
|
||||||
-- import Hledger.Data.Commodity (canonicaliseCommodities)
|
-- import Hledger.Data.Commodity (canonicaliseCommodities)
|
||||||
import Hledger.Data.Dates
|
import Hledger.Data.Dates
|
||||||
import Hledger.Data.Posting
|
import Hledger.Data.Posting
|
||||||
import Hledger.Data.Transaction
|
import Hledger.Data.Transaction
|
||||||
-- import Hledger.Data.TimeLog
|
-- import Hledger.Data.TimeLog
|
||||||
|
|
||||||
-- | A matcher is an arbitrary boolean expression of various search criteria.
|
-- | A matcher is a single, or boolean composition of, search criteria,
|
||||||
-- It can be used to match postings, transactions, accounts and more.
|
-- which can be used to match postings, transactions, accounts and more.
|
||||||
-- If the first boolean is False, it's an inverse match.
|
-- If the first boolean is False, it's an inverse match.
|
||||||
-- Currently used by hledger-web, will probably also replace FilterSpec at some point.
|
-- Currently used by hledger-web, will likely replace FilterSpec at some point.
|
||||||
data Matcher = MatchAny -- ^ always match
|
data Matcher = MatchAny -- ^ always match
|
||||||
| MatchNone -- ^ never match
|
| MatchNone -- ^ never match
|
||||||
| MatchOr [Matcher] -- ^ match if any of these match
|
| MatchOr [Matcher] -- ^ match if any of these match
|
||||||
@ -46,7 +46,8 @@ data Matcher = MatchAny -- ^ always match
|
|||||||
| MatchEDate Bool DateSpan -- ^ match if effective date in this date span
|
| MatchEDate Bool DateSpan -- ^ match if effective date in this date span
|
||||||
| MatchStatus Bool Bool -- ^ match if cleared status has this value
|
| MatchStatus Bool Bool -- ^ match if cleared status has this value
|
||||||
| MatchReal Bool Bool -- ^ match if "realness" (involves a real non-virtual account ?) has this value
|
| MatchReal Bool Bool -- ^ match if "realness" (involves a real non-virtual account ?) has this value
|
||||||
| MatchEmpty Bool Bool -- ^ match if "emptiness" (amount is zero ?) has this value
|
| MatchEmpty Bool Bool -- ^ match if "emptiness" (from the --empty command-line flag) has this value.
|
||||||
|
-- Currently this means a posting with zero amount.
|
||||||
| MatchDepth Bool Int -- ^ match if account depth is less than or equal to this value
|
| MatchDepth Bool Int -- ^ match if account depth is less than or equal to this value
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
|
|
||||||
@ -215,6 +216,8 @@ matchesPosting (MatchStatus True v) p = v == postingCleared p
|
|||||||
matchesPosting (MatchStatus False v) p = v /= postingCleared p
|
matchesPosting (MatchStatus False v) p = v /= postingCleared p
|
||||||
matchesPosting (MatchReal True v) p = v == isReal p
|
matchesPosting (MatchReal True v) p = v == isReal p
|
||||||
matchesPosting (MatchReal False v) p = v /= isReal p
|
matchesPosting (MatchReal False v) p = v /= isReal p
|
||||||
|
matchesPosting (MatchEmpty True v) Posting{pamount=a} = v == isZeroMixedAmount a
|
||||||
|
matchesPosting (MatchEmpty False v) p = not $ (MatchEmpty True v) `matchesPosting` p
|
||||||
matchesPosting _ _ = False
|
matchesPosting _ _ = False
|
||||||
|
|
||||||
-- | Does the match expression match this transaction ?
|
-- | Does the match expression match this transaction ?
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
date:PERIODEXP or edate:PERIODEXP by date or effective date.
|
date:PERIODEXP or edate:PERIODEXP by date or effective date.
|
||||||
<br>
|
<br>
|
||||||
status:BOOL by cleared status, #
|
status:BOOL by cleared status, #
|
||||||
real:BOOL by real/virtualness.
|
real:BOOL by real/virtualness, #
|
||||||
|
empty:BOOL by posting amount==0.
|
||||||
<br>
|
<br>
|
||||||
not: to negate, use single or double quotes to include spaces, multiple patterns are AND'ed.
|
not: to negate, use single or double quotes to include spaces, multiple patterns are AND'ed.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user