web: show account+subs by default
This commit is contained in:
parent
05cd38458b
commit
3dccfcad68
@ -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
|
||||
|
||||
@ -19,6 +19,6 @@ $if True
|
||||
<tr.item.#{evenodd}.posting.#{displayclass}
|
||||
<td.date
|
||||
<td.description
|
||||
<td.account> <a href="@?{accountUrl here $ paccount p}" title="Focus on #{paccount p}">#{elideRight 40 $ paccount p}
|
||||
<td.account> <a href="@?{accountUrl here $ paccount p}" title="Show transactions in #{paccount p}">#{elideRight 40 $ paccount p}
|
||||
<td.amount align=right>#{mixedAmountAsHtml $ pamount p}
|
||||
<td.balance align=right>
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<tr.item.#{inacctclass}
|
||||
<td.account.#{depthclass}
|
||||
#{indent}
|
||||
<a href="@?{acctquery}" title="Focus on this account">#{adisplay}
|
||||
<a href="@?{acctquery}" title="Show transactions in this account, including subaccounts">#{adisplay}
|
||||
<span.hoverlinks
|
||||
$if hassubs
|
||||
|
||||
<a href="@?{acctsquery}" title="Focus on this account and sub-accounts">+subs
|
||||
<a href="@?{acctonlyquery}" title="Show transactions in this account only">only
|
||||
<!--
|
||||
|
||||
<a href="@?{acctsonlyquery}" title="Focus on this account and sub-accounts and hide others">-others -->
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<td
|
||||
<div#search-help.help style="display:none;"
|
||||
Leave blank to see general journal (all transactions), or #
|
||||
click account links to see that account, optionally with sub-accounts.
|
||||
click account links to see transactions under that account.
|
||||
<br>
|
||||
Transactions/postings may additionally be filtered by:
|
||||
<br>
|
||||
|
||||
@ -122,11 +122,8 @@ getAccountsJsonR = do
|
||||
accountQuery :: AccountName -> String
|
||||
accountQuery a = "inacct:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
||||
|
||||
accountsQuery :: AccountName -> String
|
||||
accountsQuery a = "inaccts:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
||||
|
||||
accountsOnlyQuery :: AccountName -> String
|
||||
accountsOnlyQuery a = "inacctsonly:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
||||
accountOnlyQuery :: AccountName -> String
|
||||
accountOnlyQuery a = "inacctonly:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
||||
|
||||
-- accountUrl :: AppRoute -> AccountName -> (AppRoute,[(String,ByteString)])
|
||||
accountUrl r a = (r, [("q",pack $ accountQuery a)])
|
||||
@ -137,9 +134,8 @@ balanceReportAsHtml _ vd@VD{here=here,m=m,q=q,qopts=qopts,j=j} (items',total) =
|
||||
where
|
||||
l = journalToLedger nullfilterspec j
|
||||
inacctmatcher = inAccountMatcher qopts
|
||||
showacctmatcher = showAccountMatcher qopts
|
||||
allaccts = isNothing inacctmatcher
|
||||
items = maybe items' (\m -> filter (matchesAccount m . \(a,_,_,_)->a) items') showacctmatcher
|
||||
items = items' -- maybe items' (\m -> filter (matchesAccount m . \(a,_,_,_)->a) items') showacctmatcher
|
||||
itemAsHtml :: ViewData -> BalanceReportItem -> Hamlet AppRoute
|
||||
itemAsHtml VD{here=here,q=q} (acct, adisplay, aindent, abal) = $(Settings.hamletFile "balancereportitem")
|
||||
where
|
||||
@ -151,8 +147,7 @@ balanceReportAsHtml _ vd@VD{here=here,m=m,q=q,qopts=qopts,j=j} (items',total) =
|
||||
Nothing -> "" :: String
|
||||
indent = preEscapedString $ concat $ replicate (2 * aindent) " "
|
||||
acctquery = (RegisterR, [("q", pack $ accountQuery acct)])
|
||||
acctsquery = (RegisterR, [("q", pack $ accountsQuery acct)])
|
||||
acctsonlyquery = (RegisterR, [("q", pack $ accountsOnlyQuery acct)])
|
||||
acctonlyquery = (RegisterR, [("q", pack $ accountOnlyQuery acct)])
|
||||
|
||||
-- | Render a journal report as HTML.
|
||||
journalReportAsHtml :: [Opt] -> ViewData -> JournalReport -> Hamlet AppRoute
|
||||
|
||||
Loading…
Reference in New Issue
Block a user