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.
|
-- | A query option changes a query's/report's behaviour and output in some way.
|
||||||
|
|
||||||
-- XXX could use regular cli Opts ?
|
-- XXX could use regular cli Opts ?
|
||||||
data QueryOpt = QueryOptInAcct AccountName -- ^ show an account register focussed on this account
|
data QueryOpt = QueryOptInAcctOnly AccountName -- ^ show an account register focussed on this account
|
||||||
| QueryOptInAcctSubs AccountName -- ^ as above but include sub-accounts in the account register
|
| QueryOptInAcct 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
|
|
||||||
-- | QueryOptCostBasis -- ^ show amounts converted to cost where possible
|
-- | QueryOptCostBasis -- ^ show amounts converted to cost where possible
|
||||||
-- | QueryOptEffectiveDate -- ^ show effective dates instead of actual dates
|
-- | QueryOptEffectiveDate -- ^ show effective dates instead of actual dates
|
||||||
deriving (Show, Eq)
|
deriving (Show, Eq)
|
||||||
@ -65,23 +64,21 @@ data QueryOpt = QueryOptInAcct AccountName -- ^ show an account register focuss
|
|||||||
-- Just looks at the first query option.
|
-- Just looks at the first query option.
|
||||||
inAccount :: [QueryOpt] -> Maybe AccountName
|
inAccount :: [QueryOpt] -> Maybe AccountName
|
||||||
inAccount [] = Nothing
|
inAccount [] = Nothing
|
||||||
|
inAccount (QueryOptInAcctOnly a:_) = Just a
|
||||||
inAccount (QueryOptInAcct 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.
|
-- | A matcher for the account(s) we are currently focussed on, if any.
|
||||||
-- Just looks at the first query option.
|
-- Just looks at the first query option.
|
||||||
inAccountMatcher :: [QueryOpt] -> Maybe Matcher
|
inAccountMatcher :: [QueryOpt] -> Maybe Matcher
|
||||||
inAccountMatcher [] = Nothing
|
inAccountMatcher [] = Nothing
|
||||||
inAccountMatcher (QueryOptInAcct a:_) = Just $ MatchAcct True $ accountNameToAccountOnlyRegex a
|
inAccountMatcher (QueryOptInAcctOnly a:_) = Just $ MatchAcct True $ accountNameToAccountOnlyRegex a
|
||||||
inAccountMatcher (QueryOptInAcctSubs a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a
|
inAccountMatcher (QueryOptInAcct a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a
|
||||||
inAccountMatcher (QueryOptInAcctSubsOnly a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a
|
|
||||||
|
|
||||||
-- | A matcher restricting the account(s) to be shown in the sidebar, if any.
|
-- -- | A matcher restricting the account(s) to be shown in the sidebar, if any.
|
||||||
-- Just looks at the first query option.
|
-- -- Just looks at the first query option.
|
||||||
showAccountMatcher :: [QueryOpt] -> Maybe Matcher
|
-- showAccountMatcher :: [QueryOpt] -> Maybe Matcher
|
||||||
showAccountMatcher (QueryOptInAcctSubsOnly a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a
|
-- showAccountMatcher (QueryOptInAcctSubsOnly a:_) = Just $ MatchAcct True $ accountNameToAccountRegex a
|
||||||
showAccountMatcher _ = Nothing
|
-- showAccountMatcher _ = Nothing
|
||||||
|
|
||||||
-- | Convert a query expression containing zero or more space-separated
|
-- | 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:
|
-- 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"
|
-- keep synced with patterns below, excluding "not"
|
||||||
prefixes = map (++":") [
|
prefixes = map (++":") [
|
||||||
"inacct","inaccts","inacctsonly",
|
"inacct","inacctonly",
|
||||||
"desc","acct","date","edate","status","real","empty","depth"
|
"desc","acct","date","edate","status","real","empty","depth"
|
||||||
]
|
]
|
||||||
defaultprefix = "acct"
|
defaultprefix = "acct"
|
||||||
|
|
||||||
-- | Parse a single query term as either a matcher or a query option.
|
-- | Parse a single query term as either a matcher or a query option.
|
||||||
parseMatcher :: Day -> String -> Either Matcher QueryOpt
|
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':'o':'n':'l':'y':':':s) = Right $ QueryOptInAcctOnly s
|
||||||
parseMatcher _ ('i':'n':'a':'c':'c':'t':'s':':':s) = Right $ QueryOptInAcctSubs s
|
|
||||||
parseMatcher _ ('i':'n':'a':'c':'c':'t':':':s) = Right $ QueryOptInAcct s
|
parseMatcher _ ('i':'n':'a':'c':'c':'t':':':s) = Right $ QueryOptInAcct s
|
||||||
parseMatcher d ('n':'o':'t':':':s) = case parseMatcher d $ quoteIfSpaced s of
|
parseMatcher d ('n':'o':'t':':':s) = case parseMatcher d $ quoteIfSpaced s of
|
||||||
Left m -> Left $ negateMatcher m
|
Left m -> Left $ negateMatcher m
|
||||||
|
|||||||
@ -19,6 +19,6 @@ $if True
|
|||||||
<tr.item.#{evenodd}.posting.#{displayclass}
|
<tr.item.#{evenodd}.posting.#{displayclass}
|
||||||
<td.date
|
<td.date
|
||||||
<td.description
|
<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.amount align=right>#{mixedAmountAsHtml $ pamount p}
|
||||||
<td.balance align=right>
|
<td.balance align=right>
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
<tr.item.#{inacctclass}
|
<tr.item.#{inacctclass}
|
||||||
<td.account.#{depthclass}
|
<td.account.#{depthclass}
|
||||||
#{indent}
|
#{indent}
|
||||||
<a href="@?{acctquery}" title="Focus on this account">#{adisplay}
|
<a href="@?{acctquery}" title="Show transactions in this account, including subaccounts">#{adisplay}
|
||||||
<span.hoverlinks
|
<span.hoverlinks
|
||||||
$if hassubs
|
$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 -->
|
<a href="@?{acctsonlyquery}" title="Focus on this account and sub-accounts and hide others">-others -->
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
<td
|
<td
|
||||||
<div#search-help.help style="display:none;"
|
<div#search-help.help style="display:none;"
|
||||||
Leave blank to see general journal (all transactions), or #
|
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>
|
<br>
|
||||||
Transactions/postings may additionally be filtered by:
|
Transactions/postings may additionally be filtered by:
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@ -122,11 +122,8 @@ getAccountsJsonR = do
|
|||||||
accountQuery :: AccountName -> String
|
accountQuery :: AccountName -> String
|
||||||
accountQuery a = "inacct:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
accountQuery a = "inacct:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
||||||
|
|
||||||
accountsQuery :: AccountName -> String
|
accountOnlyQuery :: AccountName -> String
|
||||||
accountsQuery a = "inaccts:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
accountOnlyQuery a = "inacctonly:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
||||||
|
|
||||||
accountsOnlyQuery :: AccountName -> String
|
|
||||||
accountsOnlyQuery a = "inacctsonly:" ++ quoteIfSpaced a -- (accountNameToAccountRegex a)
|
|
||||||
|
|
||||||
-- accountUrl :: AppRoute -> AccountName -> (AppRoute,[(String,ByteString)])
|
-- accountUrl :: AppRoute -> AccountName -> (AppRoute,[(String,ByteString)])
|
||||||
accountUrl r a = (r, [("q",pack $ accountQuery a)])
|
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
|
where
|
||||||
l = journalToLedger nullfilterspec j
|
l = journalToLedger nullfilterspec j
|
||||||
inacctmatcher = inAccountMatcher qopts
|
inacctmatcher = inAccountMatcher qopts
|
||||||
showacctmatcher = showAccountMatcher qopts
|
|
||||||
allaccts = isNothing inacctmatcher
|
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 :: ViewData -> BalanceReportItem -> Hamlet AppRoute
|
||||||
itemAsHtml VD{here=here,q=q} (acct, adisplay, aindent, abal) = $(Settings.hamletFile "balancereportitem")
|
itemAsHtml VD{here=here,q=q} (acct, adisplay, aindent, abal) = $(Settings.hamletFile "balancereportitem")
|
||||||
where
|
where
|
||||||
@ -151,8 +147,7 @@ balanceReportAsHtml _ vd@VD{here=here,m=m,q=q,qopts=qopts,j=j} (items',total) =
|
|||||||
Nothing -> "" :: String
|
Nothing -> "" :: String
|
||||||
indent = preEscapedString $ concat $ replicate (2 * aindent) " "
|
indent = preEscapedString $ concat $ replicate (2 * aindent) " "
|
||||||
acctquery = (RegisterR, [("q", pack $ accountQuery acct)])
|
acctquery = (RegisterR, [("q", pack $ accountQuery acct)])
|
||||||
acctsquery = (RegisterR, [("q", pack $ accountsQuery acct)])
|
acctonlyquery = (RegisterR, [("q", pack $ accountOnlyQuery acct)])
|
||||||
acctsonlyquery = (RegisterR, [("q", pack $ accountsOnlyQuery acct)])
|
|
||||||
|
|
||||||
-- | Render a journal report as HTML.
|
-- | Render a journal report as HTML.
|
||||||
journalReportAsHtml :: [Opt] -> ViewData -> JournalReport -> Hamlet AppRoute
|
journalReportAsHtml :: [Opt] -> ViewData -> JournalReport -> Hamlet AppRoute
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user