acc: report --declared and/or --posted accounts
This commit is contained in:
parent
6210613f76
commit
37a4d71f1b
@ -35,11 +35,20 @@ import Hledger.Cli.CliOptions
|
|||||||
accountsmode = (defCommandMode $ ["accounts"] ++ aliases) {
|
accountsmode = (defCommandMode $ ["accounts"] ++ aliases) {
|
||||||
modeHelp = "show account names" `withAliases` aliases
|
modeHelp = "show account names" `withAliases` aliases
|
||||||
,modeHelpSuffix = [
|
,modeHelpSuffix = [
|
||||||
"This command lists the accounts referenced by matched postings (and in tree mode, their parents as well). The accounts can be depth-clipped (--depth N) or have their leading parts trimmed (--drop N)."
|
"This command lists account names, either declared with account directives"
|
||||||
|
,"(--declared), posted to (--posted), or both (default)."
|
||||||
|
,"With query arguments, only matched account names and account names"
|
||||||
|
,"referenced by matched postings are shown."
|
||||||
|
,"It shows a flat list by default. With `--tree`, it uses indentation to"
|
||||||
|
,"show the account hierarchy."
|
||||||
|
,"In flat mode you can add `--drop N` to omit the first few account name components."
|
||||||
|
,"Account names can be depth-clipped with `--depth N` or depth:N."
|
||||||
]
|
]
|
||||||
,modeGroupFlags = C.Group {
|
,modeGroupFlags = C.Group {
|
||||||
groupUnnamed = [
|
groupUnnamed = [
|
||||||
flagNone ["tree"] (\opts -> setboolopt "tree" opts) "show short account names, as a tree"
|
flagNone ["declared"] (\opts -> setboolopt "declared" opts) "show account names declared with account directives"
|
||||||
|
,flagNone ["posted"] (\opts -> setboolopt "posted" opts) "show account names posted to by transactions"
|
||||||
|
,flagNone ["tree"] (\opts -> setboolopt "tree" opts) "show short account names, as a tree"
|
||||||
,flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show full account names, as a list (default)"
|
,flagNone ["flat"] (\opts -> setboolopt "flat" opts) "show full account names, as a list (default)"
|
||||||
,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
|
,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
|
||||||
]
|
]
|
||||||
@ -51,13 +60,19 @@ accountsmode = (defCommandMode $ ["accounts"] ++ aliases) {
|
|||||||
|
|
||||||
-- | The accounts command.
|
-- | The accounts command.
|
||||||
accounts :: CliOpts -> Journal -> IO ()
|
accounts :: CliOpts -> Journal -> IO ()
|
||||||
accounts CliOpts{reportopts_=ropts} j = do
|
accounts CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do
|
||||||
d <- getCurrentDay
|
d <- getCurrentDay
|
||||||
let q = queryFromOpts d ropts
|
let q = queryFromOpts d ropts
|
||||||
nodepthq = dbg1 "nodepthq" $ filterQuery (not . queryIsDepth) q
|
nodepthq = dbg1 "nodepthq" $ filterQuery (not . queryIsDepth) q
|
||||||
depth = dbg1 "depth" $ queryDepth $ filterQuery queryIsDepth q
|
depth = dbg1 "depth" $ queryDepth $ filterQuery queryIsDepth q
|
||||||
ps = dbg1 "ps" $ journalPostings $ filterJournalPostings nodepthq j
|
matcheddeclaredaccts = dbg1 "matcheddeclaredaccts" $ nub $ sort $ filter (matchesAccount q) $ jaccounts j
|
||||||
as = dbg1 "as" $ nub $ filter (not . T.null) $ map (clipAccountName depth) $ sort $ map paccount ps
|
matchedps = dbg1 "ps" $ journalPostings $ filterJournalPostings nodepthq j
|
||||||
|
matchedpostedaccts = dbg1 "matchedpostedaccts" $ nub $ sort $ filter (not . T.null) $ map (clipAccountName depth) $ map paccount matchedps
|
||||||
|
posted = boolopt "posted" rawopts
|
||||||
|
declared = boolopt "declared" rawopts
|
||||||
|
as | declared && not posted = matcheddeclaredaccts
|
||||||
|
| not declared && posted = matchedpostedaccts
|
||||||
|
| otherwise = nub $ sort $ matcheddeclaredaccts ++ matchedpostedaccts
|
||||||
as' | tree_ ropts = expandAccountNames as
|
as' | tree_ ropts = expandAccountNames as
|
||||||
| otherwise = as
|
| otherwise = as
|
||||||
render a | tree_ ropts = T.replicate (2 * (accountNameLevel a - 1)) " " <> accountLeafName a
|
render a | tree_ ropts = T.replicate (2 * (accountNameLevel a - 1)) " " <> accountLeafName a
|
||||||
|
|||||||
@ -1200,8 +1200,18 @@ See also \f[C]hledger\f[] for a more organised command list, and
|
|||||||
Show account names.
|
Show account names.
|
||||||
Alias: a.
|
Alias: a.
|
||||||
.TP
|
.TP
|
||||||
|
.B \f[C]\-\-declared\f[]
|
||||||
|
show account names declared with account directives
|
||||||
|
.RS
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
|
.B \f[C]\-\-posted\f[]
|
||||||
|
show account names posted to by transactions
|
||||||
|
.RS
|
||||||
|
.RE
|
||||||
|
.TP
|
||||||
.B \f[C]\-\-tree\f[]
|
.B \f[C]\-\-tree\f[]
|
||||||
show short account names, as a tree
|
show short account names and their parents, as a tree
|
||||||
.RS
|
.RS
|
||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
@ -1215,16 +1225,17 @@ in flat mode: omit N leading account name parts
|
|||||||
.RS
|
.RS
|
||||||
.RE
|
.RE
|
||||||
.PP
|
.PP
|
||||||
This command lists all account names that are in use (ie, all the
|
This command lists account names, either declared with account
|
||||||
accounts which have at least one transaction posting to them).
|
directives (\[en]declared), posted to (\[en]posted), or both (default).
|
||||||
With query arguments, only matched account names are shown.
|
With query arguments, only matched account names and account names
|
||||||
.PP
|
referenced by matched postings are shown.
|
||||||
It shows a flat list by default.
|
It shows a flat list by default.
|
||||||
With \f[C]\-\-tree\f[], it uses indentation to show the account
|
With \f[C]\-\-tree\f[], it uses indentation to show the account
|
||||||
hierarchy.
|
hierarchy.
|
||||||
.PP
|
|
||||||
In flat mode you can add \f[C]\-\-drop\ N\f[] to omit the first few
|
In flat mode you can add \f[C]\-\-drop\ N\f[] to omit the first few
|
||||||
account name components.
|
account name components.
|
||||||
|
Account names can be depth\-clipped with \f[C]\-\-depth\ N\f[] or
|
||||||
|
depth:N.
|
||||||
.PP
|
.PP
|
||||||
Examples:
|
Examples:
|
||||||
.IP
|
.IP
|
||||||
|
|||||||
@ -887,9 +887,15 @@ File: hledger.info, Node: accounts, Next: activity, Up: COMMANDS
|
|||||||
|
|
||||||
Show account names. Alias: a.
|
Show account names. Alias: a.
|
||||||
|
|
||||||
|
'--declared'
|
||||||
|
|
||||||
|
show account names declared with account directives
|
||||||
|
'--posted'
|
||||||
|
|
||||||
|
show account names posted to by transactions
|
||||||
'--tree'
|
'--tree'
|
||||||
|
|
||||||
show short account names, as a tree
|
show short account names and their parents, as a tree
|
||||||
'--flat'
|
'--flat'
|
||||||
|
|
||||||
show full account names, as a list (default)
|
show full account names, as a list (default)
|
||||||
@ -897,15 +903,14 @@ Show account names. Alias: a.
|
|||||||
|
|
||||||
in flat mode: omit N leading account name parts
|
in flat mode: omit N leading account name parts
|
||||||
|
|
||||||
This command lists all account names that are in use (ie, all the
|
This command lists account names, either declared with account
|
||||||
accounts which have at least one transaction posting to them). With
|
directives (-declared), posted to (-posted), or both (default). With
|
||||||
query arguments, only matched account names are shown.
|
query arguments, only matched account names and account names referenced
|
||||||
|
by matched postings are shown. It shows a flat list by default. With
|
||||||
It shows a flat list by default. With '--tree', it uses indentation
|
'--tree', it uses indentation to show the account hierarchy. In flat
|
||||||
to show the account hierarchy.
|
mode you can add '--drop N' to omit the first few account name
|
||||||
|
components. Account names can be depth-clipped with '--depth N' or
|
||||||
In flat mode you can add '--drop N' to omit the first few account
|
depth:N.
|
||||||
name components.
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@ -2418,95 +2423,95 @@ Node: COMMANDS28399
|
|||||||
Ref: #commands28511
|
Ref: #commands28511
|
||||||
Node: accounts29493
|
Node: accounts29493
|
||||||
Ref: #accounts29591
|
Ref: #accounts29591
|
||||||
Node: activity30584
|
Node: activity30841
|
||||||
Ref: #activity30694
|
Ref: #activity30951
|
||||||
Node: add31054
|
Node: add31311
|
||||||
Ref: #add31153
|
Ref: #add31410
|
||||||
Node: balance33814
|
Node: balance34071
|
||||||
Ref: #balance33925
|
Ref: #balance34182
|
||||||
Node: Flat mode37299
|
Node: Flat mode37556
|
||||||
Ref: #flat-mode37424
|
Ref: #flat-mode37681
|
||||||
Node: Depth limited balance reports37844
|
Node: Depth limited balance reports38101
|
||||||
Ref: #depth-limited-balance-reports38045
|
Ref: #depth-limited-balance-reports38302
|
||||||
Node: Multicolumn balance reports38465
|
Node: Multicolumn balance reports38722
|
||||||
Ref: #multicolumn-balance-reports38660
|
Ref: #multicolumn-balance-reports38917
|
||||||
Node: Budgets43349
|
Node: Budgets43606
|
||||||
Ref: #budgets43496
|
Ref: #budgets43753
|
||||||
Node: Custom balance output47327
|
Node: Custom balance output47584
|
||||||
Ref: #custom-balance-output47489
|
Ref: #custom-balance-output47746
|
||||||
Node: Colour support49582
|
Node: Colour support49839
|
||||||
Ref: #colour-support49741
|
Ref: #colour-support49998
|
||||||
Node: Output destination49914
|
Node: Output destination50171
|
||||||
Ref: #output-destination50070
|
Ref: #output-destination50327
|
||||||
Node: CSV output50340
|
Node: CSV output50597
|
||||||
Ref: #csv-output50457
|
Ref: #csv-output50714
|
||||||
Node: balancesheet50854
|
Node: balancesheet51111
|
||||||
Ref: #balancesheet50990
|
Ref: #balancesheet51247
|
||||||
Node: balancesheetequity53217
|
Node: balancesheetequity53474
|
||||||
Ref: #balancesheetequity53366
|
Ref: #balancesheetequity53623
|
||||||
Node: cashflow53903
|
Node: cashflow54160
|
||||||
Ref: #cashflow54031
|
Ref: #cashflow54288
|
||||||
Node: check-dates56070
|
Node: check-dates56327
|
||||||
Ref: #check-dates56197
|
Ref: #check-dates56454
|
||||||
Node: check-dupes56314
|
Node: check-dupes56571
|
||||||
Ref: #check-dupes56438
|
Ref: #check-dupes56695
|
||||||
Node: close56575
|
Node: close56832
|
||||||
Ref: #close56682
|
Ref: #close56939
|
||||||
Node: help57012
|
Node: help57269
|
||||||
Ref: #help57112
|
Ref: #help57369
|
||||||
Node: import58186
|
Node: import58443
|
||||||
Ref: #import58300
|
Ref: #import58557
|
||||||
Node: incomestatement59030
|
Node: incomestatement59287
|
||||||
Ref: #incomestatement59164
|
Ref: #incomestatement59421
|
||||||
Node: prices61484
|
Node: prices61741
|
||||||
Ref: #prices61599
|
Ref: #prices61856
|
||||||
Node: print61642
|
Node: print61899
|
||||||
Ref: #print61752
|
Ref: #print62009
|
||||||
Node: print-unique66637
|
Node: print-unique66894
|
||||||
Ref: #print-unique66763
|
Ref: #print-unique67020
|
||||||
Node: register66831
|
Node: register67088
|
||||||
Ref: #register66958
|
Ref: #register67215
|
||||||
Node: Custom register output71459
|
Node: Custom register output71716
|
||||||
Ref: #custom-register-output71588
|
Ref: #custom-register-output71845
|
||||||
Node: register-match72885
|
Node: register-match73142
|
||||||
Ref: #register-match73019
|
Ref: #register-match73276
|
||||||
Node: rewrite73202
|
Node: rewrite73459
|
||||||
Ref: #rewrite73319
|
Ref: #rewrite73576
|
||||||
Node: stats73388
|
Node: stats73645
|
||||||
Ref: #stats73491
|
Ref: #stats73748
|
||||||
Node: tags74373
|
Node: tags74630
|
||||||
Ref: #tags74471
|
Ref: #tags74728
|
||||||
Node: test74707
|
Node: test74964
|
||||||
Ref: #test74791
|
Ref: #test75048
|
||||||
Node: ADD-ON COMMANDS75159
|
Node: ADD-ON COMMANDS75416
|
||||||
Ref: #add-on-commands75269
|
Ref: #add-on-commands75526
|
||||||
Node: Official add-ons76556
|
Node: Official add-ons76813
|
||||||
Ref: #official-add-ons76696
|
Ref: #official-add-ons76953
|
||||||
Node: api76783
|
Node: api77040
|
||||||
Ref: #api76872
|
Ref: #api77129
|
||||||
Node: ui76924
|
Node: ui77181
|
||||||
Ref: #ui77023
|
Ref: #ui77280
|
||||||
Node: web77081
|
Node: web77338
|
||||||
Ref: #web77170
|
Ref: #web77427
|
||||||
Node: Third party add-ons77216
|
Node: Third party add-ons77473
|
||||||
Ref: #third-party-add-ons77391
|
Ref: #third-party-add-ons77648
|
||||||
Node: diff77526
|
Node: diff77783
|
||||||
Ref: #diff77623
|
Ref: #diff77880
|
||||||
Node: iadd77722
|
Node: iadd77979
|
||||||
Ref: #iadd77836
|
Ref: #iadd78093
|
||||||
Node: interest77919
|
Node: interest78176
|
||||||
Ref: #interest78040
|
Ref: #interest78297
|
||||||
Node: irr78135
|
Node: irr78392
|
||||||
Ref: #irr78233
|
Ref: #irr78490
|
||||||
Node: Experimental add-ons78311
|
Node: Experimental add-ons78568
|
||||||
Ref: #experimental-add-ons78463
|
Ref: #experimental-add-ons78720
|
||||||
Node: autosync78754
|
Node: autosync79011
|
||||||
Ref: #autosync78866
|
Ref: #autosync79123
|
||||||
Node: budget79105
|
Node: budget79362
|
||||||
Ref: #budget79227
|
Ref: #budget79484
|
||||||
Node: chart79293
|
Node: chart79550
|
||||||
Ref: #chart79410
|
Ref: #chart79667
|
||||||
Node: check79481
|
Node: check79738
|
||||||
Ref: #check79583
|
Ref: #check79840
|
||||||
|
|
||||||
End Tag Table
|
End Tag Table
|
||||||
|
|||||||
@ -806,22 +806,26 @@ COMMANDS
|
|||||||
accounts
|
accounts
|
||||||
Show account names. Alias: a.
|
Show account names. Alias: a.
|
||||||
|
|
||||||
--tree show short account names, as a tree
|
--declared
|
||||||
|
show account names declared with account directives
|
||||||
|
|
||||||
|
--posted
|
||||||
|
show account names posted to by transactions
|
||||||
|
|
||||||
|
--tree show short account names and their parents, as a tree
|
||||||
|
|
||||||
--flat show full account names, as a list (default)
|
--flat show full account names, as a list (default)
|
||||||
|
|
||||||
--drop=N
|
--drop=N
|
||||||
in flat mode: omit N leading account name parts
|
in flat mode: omit N leading account name parts
|
||||||
|
|
||||||
This command lists all account names that are in use (ie, all the
|
This command lists account names, either declared with account direc-
|
||||||
accounts which have at least one transaction posting to them). With
|
tives (-declared), posted to (-posted), or both (default). With query
|
||||||
query arguments, only matched account names are shown.
|
arguments, only matched account names and account names referenced by
|
||||||
|
matched postings are shown. It shows a flat list by default. With
|
||||||
It shows a flat list by default. With --tree, it uses indentation to
|
--tree, it uses indentation to show the account hierarchy. In flat
|
||||||
show the account hierarchy.
|
mode you can add --drop N to omit the first few account name compo-
|
||||||
|
nents. Account names can be depth-clipped with --depth N or depth:N.
|
||||||
In flat mode you can add --drop N to omit the first few account name
|
|
||||||
components.
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
|||||||
@ -26,8 +26,14 @@ for each command: name, synopsis, description, examples.
|
|||||||
## accounts
|
## accounts
|
||||||
Show account names. Alias: a.
|
Show account names. Alias: a.
|
||||||
|
|
||||||
|
`--declared`
|
||||||
|
: show account names declared with account directives
|
||||||
|
|
||||||
|
`--posted`
|
||||||
|
: show account names posted to by transactions
|
||||||
|
|
||||||
`--tree`
|
`--tree`
|
||||||
: show short account names, as a tree
|
: show short account names and their parents, as a tree
|
||||||
|
|
||||||
`--flat`
|
`--flat`
|
||||||
: show full account names, as a list (default)
|
: show full account names, as a list (default)
|
||||||
@ -35,15 +41,14 @@ Show account names. Alias: a.
|
|||||||
`--drop=N`
|
`--drop=N`
|
||||||
: in flat mode: omit N leading account name parts
|
: in flat mode: omit N leading account name parts
|
||||||
|
|
||||||
This command lists all account names that are in use (ie, all the
|
This command lists account names, either declared with account directives
|
||||||
accounts which have at least one transaction posting to them). With
|
(--declared), posted to (--posted), or both (default).
|
||||||
query arguments, only matched account names are shown.
|
With query arguments, only matched account names and account names
|
||||||
|
referenced by matched postings are shown.
|
||||||
It shows a flat list by default. With `--tree`, it uses indentation to
|
It shows a flat list by default. With `--tree`, it uses indentation to
|
||||||
show the account hierarchy.
|
show the account hierarchy.
|
||||||
|
In flat mode you can add `--drop N` to omit the first few account name components.
|
||||||
In flat mode you can add `--drop N` to omit the first few account name
|
Account names can be depth-clipped with `--depth N` or depth:N.
|
||||||
components.
|
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user