register: --average implies --empty
The -A flag now enables -E, so that with a report interval the averages are always per-period and not per-report-line. (Without a report interval, -E is already the default).
This commit is contained in:
parent
d0ad571321
commit
f631e8e063
@ -751,17 +751,9 @@ The `--depth` option limits the amount of sub-account detail displayed:
|
|||||||
|
|
||||||
$ hledger register assets:bank:checking --depth 2
|
$ hledger register assets:bank:checking --depth 2
|
||||||
|
|
||||||
With a [reporting interval](#reporting-interval) it shows aggregated
|
The `--average`/`-A` flag shows the running average posting amount
|
||||||
summary postings within each interval:
|
instead of the running total (so, the final number displayed is the
|
||||||
|
average for the whole report period). This flag implies `--empty` (see below).
|
||||||
$ hledger register --monthly rent
|
|
||||||
$ hledger register --monthly -E food --depth 4
|
|
||||||
|
|
||||||
Note that the report start/end dates will be "enlarged" in this case
|
|
||||||
so that they encompass the displayed intervals. This is so that the
|
|
||||||
first and last intervals will be "full" and comparable to the others.
|
|
||||||
|
|
||||||
The `--average`/`-A` flag shows the running average posting amount instead of the running total.
|
|
||||||
|
|
||||||
The `--related`/`-r` flag shows the *other* postings in the transactions
|
The `--related`/`-r` flag shows the *other* postings in the transactions
|
||||||
of the postings which would normally be shown.
|
of the postings which would normally be shown.
|
||||||
@ -772,6 +764,22 @@ names, use `-w` to increase the width to 120 characters, or `-wN` to set
|
|||||||
any desired width (at least 50 recommended).
|
any desired width (at least 50 recommended).
|
||||||
Note, currently -w/--width can not have a space between flag and value ([#149](https://github.com/simonmichael/hledger/issues/149)).
|
Note, currently -w/--width can not have a space between flag and value ([#149](https://github.com/simonmichael/hledger/issues/149)).
|
||||||
|
|
||||||
|
With a [reporting interval](#reporting-interval) register shows
|
||||||
|
aggregated summary postings, within each interval:
|
||||||
|
|
||||||
|
$ hledger register --monthly rent
|
||||||
|
$ hledger register --monthly -E food --depth 4
|
||||||
|
|
||||||
|
One summary posting will be shown for each account in each interval.
|
||||||
|
Summary postings with a zero amount are not shown; use the `--empty`/`-E` flag to show them.
|
||||||
|
|
||||||
|
If necessary, use the `--depth` option to summarise the accounts.
|
||||||
|
It's often most useful to see just one line per interval.
|
||||||
|
|
||||||
|
When using report intervals, the report's normal start/end dates are
|
||||||
|
"enlarged" to contain a whole number of intervals, so that the first
|
||||||
|
and last intervals will be "full" and comparable to the others.
|
||||||
|
|
||||||
#### balance
|
#### balance
|
||||||
|
|
||||||
The balance command displays accounts and their balances.
|
The balance command displays accounts and their balances.
|
||||||
|
|||||||
@ -71,13 +71,13 @@ postingsReport opts q j = (totallabel, items)
|
|||||||
journalPostings $ journalSelectingAmountFromOpts opts j
|
journalPostings $ journalSelectingAmountFromOpts opts j
|
||||||
(precedingps, reportps) = dbg "precedingps, reportps" $ span (beforestartq `matchesPosting`) pstoend
|
(precedingps, reportps) = dbg "precedingps, reportps" $ span (beforestartq `matchesPosting`) pstoend
|
||||||
|
|
||||||
empty = queryEmpty q
|
showempty = queryEmpty q || average_ opts
|
||||||
-- displayexpr = display_ opts -- XXX
|
-- displayexpr = display_ opts -- XXX
|
||||||
interval = intervalFromOpts opts -- XXX
|
interval = intervalFromOpts opts -- XXX
|
||||||
|
|
||||||
whichdate = whichDateFromOpts opts
|
whichdate = whichDateFromOpts opts
|
||||||
itemps | interval == NoInterval = reportps
|
itemps | interval == NoInterval = reportps
|
||||||
| otherwise = summarisePostingsByInterval interval whichdate depth empty reportspan reportps
|
| otherwise = summarisePostingsByInterval interval whichdate depth showempty reportspan reportps
|
||||||
items = postingsReportItems itemps nullposting whichdate depth startbal runningcalc 1
|
items = postingsReportItems itemps nullposting whichdate depth startbal runningcalc 1
|
||||||
where
|
where
|
||||||
startbal = if balancetype_ opts == HistoricalBalance then sumPostings precedingps else 0
|
startbal = if balancetype_ opts == HistoricalBalance then sumPostings precedingps else 0
|
||||||
@ -117,9 +117,9 @@ mkpostingsReportItem showdate showdesc wd p b = (if showdate then Just date else
|
|||||||
-- are one per account per interval and aggregated to the specified depth
|
-- are one per account per interval and aggregated to the specified depth
|
||||||
-- if any.
|
-- if any.
|
||||||
summarisePostingsByInterval :: Interval -> WhichDate -> Int -> Bool -> DateSpan -> [Posting] -> [Posting]
|
summarisePostingsByInterval :: Interval -> WhichDate -> Int -> Bool -> DateSpan -> [Posting] -> [Posting]
|
||||||
summarisePostingsByInterval interval wd depth empty reportspan ps = concatMap summarisespan $ splitSpan interval reportspan
|
summarisePostingsByInterval interval wd depth showempty reportspan ps = concatMap summarisespan $ splitSpan interval reportspan
|
||||||
where
|
where
|
||||||
summarisespan s = summarisePostingsInDateSpan s wd depth empty (postingsinspan s)
|
summarisespan s = summarisePostingsInDateSpan s wd depth showempty (postingsinspan s)
|
||||||
postingsinspan s = filter (isPostingInDateSpan' wd s) ps
|
postingsinspan s = filter (isPostingInDateSpan' wd s) ps
|
||||||
|
|
||||||
tests_summarisePostingsByInterval = [
|
tests_summarisePostingsByInterval = [
|
||||||
|
|||||||
@ -29,7 +29,7 @@ registermode = (defCommandMode $ ["register"] ++ aliases) {
|
|||||||
,modeGroupFlags = Group {
|
,modeGroupFlags = Group {
|
||||||
groupUnnamed = [
|
groupUnnamed = [
|
||||||
flagNone ["historical","H"] (\opts -> setboolopt "historical" opts) "include prior postings in the running total"
|
flagNone ["historical","H"] (\opts -> setboolopt "historical" opts) "include prior postings in the running total"
|
||||||
,flagNone ["average","A"] (\opts -> setboolopt "average" opts) "show a running average instead of the running total"
|
,flagNone ["average","A"] (\opts -> setboolopt "average" opts) "show a running average instead of the running total (implies --empty)"
|
||||||
,flagNone ["related","r"] (\opts -> setboolopt "related" opts) "show postings' siblings instead"
|
,flagNone ["related","r"] (\opts -> setboolopt "related" opts) "show postings' siblings instead"
|
||||||
,flagReq ["width","w"] (\s opts -> Right $ setopt "width" s opts) "N" "set output width (default: 80)"
|
,flagReq ["width","w"] (\s opts -> Right $ setopt "width" s opts) "N" "set output width (default: 80)"
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user