diff --git a/hledger-lib/Hledger/Data/Matching.hs b/hledger-lib/Hledger/Data/Matching.hs index a0b91e6a0..c7325b322 100644 --- a/hledger-lib/Hledger/Data/Matching.hs +++ b/hledger-lib/Hledger/Data/Matching.hs @@ -54,9 +54,8 @@ data Matcher = MatchAny -- ^ always match -- | A query option changes a query's/report's behaviour and output in some way. -- XXX could use regular cli Opts ? -data QueryOpt = QueryOptInAcct AccountName -- ^ show an account register focussed on this account - | QueryOptInAcctSubs AccountName -- ^ as above but include sub-accounts in the account register - | QueryOptInAcctSubsOnly AccountName -- ^ as above plus narrow the accounts sidebar to show just these accounts +data QueryOpt = QueryOptInAcctOnly AccountName -- ^ show an account register focussed on this account + | QueryOptInAcct AccountName -- ^ as above but include sub-accounts in the account register -- | QueryOptCostBasis -- ^ show amounts converted to cost where possible -- | QueryOptEffectiveDate -- ^ show effective dates instead of actual dates deriving (Show, Eq) @@ -65,23 +64,21 @@ data QueryOpt = QueryOptInAcct AccountName -- ^ show an account register focuss -- Just looks at the first query option. inAccount :: [QueryOpt] -> Maybe AccountName inAccount [] = Nothing +inAccount (QueryOptInAcctOnly a:_) = Just a inAccount (QueryOptInAcct a:_) = Just a -inAccount (QueryOptInAcctSubs a:_) = Just a -inAccount (QueryOptInAcctSubsOnly a:_) = Just a -- | A matcher for the account(s) we are currently focussed on, if any. -- Just looks at the first query option. inAccountMatcher :: [QueryOpt] -> Maybe Matcher inAccountMatcher [] = Nothing -inAccountMatcher (QueryOptInAcct a:_) = Just $ MatchAcct True $ accountNameToAccountOnlyRegex a -inAccountMatcher (QueryOptInAcctSubs a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a -inAccountMatcher (QueryOptInAcctSubsOnly a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a +inAccountMatcher (QueryOptInAcctOnly a:_) = Just $ MatchAcct True $ accountNameToAccountOnlyRegex a +inAccountMatcher (QueryOptInAcct a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a --- | A matcher restricting the account(s) to be shown in the sidebar, if any. --- Just looks at the first query option. -showAccountMatcher :: [QueryOpt] -> Maybe Matcher -showAccountMatcher (QueryOptInAcctSubsOnly a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a -showAccountMatcher _ = Nothing +-- -- | A matcher restricting the account(s) to be shown in the sidebar, if any. +-- -- Just looks at the first query option. +-- showAccountMatcher :: [QueryOpt] -> Maybe Matcher +-- showAccountMatcher (QueryOptInAcctSubsOnly a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a +-- showAccountMatcher _ = Nothing -- | Convert a query expression containing zero or more space-separated -- terms to a matcher and zero or more query options. A query term is either: @@ -109,15 +106,14 @@ parseQuery d s = (m,qopts) -- keep synced with patterns below, excluding "not" prefixes = map (++":") [ - "inacct","inaccts","inacctsonly", + "inacct","inacctonly", "desc","acct","date","edate","status","real","empty","depth" ] defaultprefix = "acct" -- | Parse a single query term as either a matcher or a query option. parseMatcher :: Day -> String -> Either Matcher QueryOpt -parseMatcher _ ('i':'n':'a':'c':'c':'t':'s':'o':'n':'l':'y':':':s) = Right $ QueryOptInAcctSubsOnly s -parseMatcher _ ('i':'n':'a':'c':'c':'t':'s':':':s) = Right $ QueryOptInAcctSubs s +parseMatcher _ ('i':'n':'a':'c':'c':'t':'o':'n':'l':'y':':':s) = Right $ QueryOptInAcctOnly s parseMatcher _ ('i':'n':'a':'c':'c':'t':':':s) = Right $ QueryOptInAcct s parseMatcher d ('n':'o':'t':':':s) = case parseMatcher d $ quoteIfSpaced s of Left m -> Left $ negateMatcher m diff --git a/hledger-web/.hledger/web/templates/accountregisterreportitem.hamlet b/hledger-web/.hledger/web/templates/accountregisterreportitem.hamlet index ffe4f2fe4..48dbacb0c 100644 --- a/hledger-web/.hledger/web/templates/accountregisterreportitem.hamlet +++ b/hledger-web/.hledger/web/templates/accountregisterreportitem.hamlet @@ -19,6 +19,6 @@ $if True