imp: areg: when restricted by extra query args, show a hint in title
I was confused when using 'areg ACCT QUERY'. Now, the title will show " (matching query)" as a hint when a QUERY is specified, except when it is a date restriction (which is common and not confusing) or a depth restriction (which is ignored).
This commit is contained in:
parent
25b8d51ff2
commit
af38121442
@ -161,12 +161,18 @@ accountTransactionsReportAsText copts reportq thisacctq items = TB.toLazyText $
|
||||
itembal (_,_,_,_,_,a) = a
|
||||
|
||||
-- show a title indicating which account was picked, which can be confusing otherwise
|
||||
title = maybe mempty (\s -> foldMap TB.fromText ["Transactions in ", s, " and subaccounts:"]) macct
|
||||
title = maybe mempty (\s -> foldMap TB.fromText ["Transactions in ", s, " and subaccounts", qmsg, ":"]) macct
|
||||
where
|
||||
-- XXX temporary hack ? recover the account name from the query
|
||||
macct = case filterQuery queryIsAcct thisacctq of
|
||||
Acct r -> Just . T.drop 1 . T.dropEnd 5 $ reString r -- Acct "^JS:expenses(:|$)"
|
||||
_ -> Nothing -- shouldn't happen
|
||||
-- show a hint in the title when results are restricted by an extra query (other than depth or date or date2)
|
||||
qmsg = if hasextraquery then " (matching query)" else ""
|
||||
where
|
||||
hasextraquery =
|
||||
length (querystring_ $ _rsReportOpts $ reportspec_ copts) > 1
|
||||
&& not (queryIsNull $ filterQuery (not.(\q->queryIsDepth q || queryIsDateOrDate2 q)) reportq)
|
||||
|
||||
-- | Render one account register report line item as plain text. Layout is like so:
|
||||
-- @
|
||||
|
||||
@ -36,10 +36,11 @@ Transactions in a and subaccounts:
|
||||
2021-01-02 a:aa 10 11
|
||||
2021-01-03 a:aa:aaa 100 111
|
||||
|
||||
# 4. Any additional arguments are a query, filtering the transactions. This may
|
||||
# cause the running balance to diverge from the real-world running balance.
|
||||
# 4. Any additional arguments are a query filtering the transactions.
|
||||
# This can cause the running balance to diverge from the real-world running balance.
|
||||
# For non-date/date2/depth queries, a hint is shown in the title.
|
||||
$ hledger -f- areg a aaa
|
||||
Transactions in a and subaccounts:
|
||||
Transactions in a and subaccounts (matching query):
|
||||
2021-01-03 a:aa:aaa 100 100
|
||||
|
||||
# 5. Sorts transactions first by transaction date (earliest date of the
|
||||
|
||||
@ -326,7 +326,7 @@ $ hledger -f- register -V -B cur:A "amt:<5"
|
||||
|
||||
# 24. aregister report cur: and amt: query matches currency before valuation/cost
|
||||
$ hledger -f- aregister a -V -B cur:A "amt:<5"
|
||||
Transactions in a and subaccounts:
|
||||
Transactions in a and subaccounts (matching query):
|
||||
2021-01-01 a 1000 B 1000 B
|
||||
>=
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user