mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-07 21:15:19 +03:00
accounts: filtering by anything other than account name was broken
This commit is contained in:
parent
3f0ab0b008
commit
cf25ef5cf5
@ -70,8 +70,10 @@ accounts CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do
|
||||
declared = boolopt "declared" rawopts
|
||||
used = boolopt "used" rawopts
|
||||
q = queryFromOpts d ropts
|
||||
-- a depth limit will clip and exclude account names later, but should not exclude accounts at this stage
|
||||
-- a depth limit will clip and exclude account names later, but we don't want to exclude accounts at this stage
|
||||
nodepthq = dbg1 "nodepthq" $ filterQuery (not . queryIsDepth) q
|
||||
-- just the acct: part of the query will be reapplied later, after clipping
|
||||
acctq = dbg1 "acctq" $ filterQuery queryIsAcct q
|
||||
depth = dbg1 "depth" $ queryDepth $ filterQuery queryIsDepth q
|
||||
matcheddeclaredaccts = dbg1 "matcheddeclaredaccts" $ filter (matchesAccount nodepthq) $ jdeclaredaccounts j
|
||||
matchedusedaccts = dbg5 "matchedusedaccts" $ map paccount $ journalPostings $ filterJournalPostings nodepthq j
|
||||
@ -86,7 +88,7 @@ accounts CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do
|
||||
-- 3. if there's a depth limit, depth-clip and remove any no longer useful items
|
||||
clippedaccts =
|
||||
dbg1 "clippedaccts" $
|
||||
filter (matchesAccount q) $ -- clipping can leave accounts that no longer visibly match the query
|
||||
filter (matchesAccount acctq) $ -- clipping can leave accounts that no longer match the query, remove such
|
||||
nub $ -- clipping can leave duplicates (adjacent, hopefully)
|
||||
filter (not . T.null) $ -- depth:0 can leave nulls
|
||||
map (clipAccountName depth) $ -- clip at depth if specified
|
||||
|
24
tests/accounts/accounts.test
Normal file
24
tests/accounts/accounts.test
Normal file
@ -0,0 +1,24 @@
|
||||
# accounts command
|
||||
|
||||
# basic accounts report
|
||||
<
|
||||
account a
|
||||
|
||||
2018/1/1 ; foo:
|
||||
(a:aa) 1
|
||||
|
||||
$ hledger -f - accounts
|
||||
a
|
||||
a:aa
|
||||
>=
|
||||
|
||||
# tree mode
|
||||
$ hledger -f - accounts --tree
|
||||
a
|
||||
aa
|
||||
>=
|
||||
|
||||
# filtering transactions by tag
|
||||
$ hledger -f - accounts tag:foo
|
||||
a:aa
|
||||
>=
|
Loading…
Reference in New Issue
Block a user