diff options
author | John Wiegley <johnw@newartisans.com> | 2010-05-30 02:28:58 -0600 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-05-30 02:47:40 -0600 |
commit | 647d4aac2fa474085d01f7ea1cebdc34fafd64a6 (patch) | |
tree | c17157d73c3a9d5dd182a4b7b0896e4f31e318be /src/report.h | |
parent | a41d33fba37460587f59ea0349ac4947a4de9f3c (diff) | |
download | fork-ledger-647d4aac2fa474085d01f7ea1cebdc34fafd64a6.tar.gz fork-ledger-647d4aac2fa474085d01f7ea1cebdc34fafd64a6.tar.bz2 fork-ledger-647d4aac2fa474085d01f7ea1cebdc34fafd64a6.zip |
New: --group-by=EXPR and --group-title-format=FMT
The --group-by option allows for most reports to be split up into
sections based on the varying value of EXPR. For example, to see
register subtotals by payee, use:
ledger reg --group-by=payee -s
This works for separated balances too:
ledger bal --group-by=payee
Another interesting possibility is seeing a register of all the accounts
affected by a related account:
ledger reg -r --group-by=payee
The option --group-title-format can be used to add a separator bar to
the group titles. The option --no-titles can be used to drop titles
altogether.
Diffstat (limited to 'src/report.h')
-rw-r--r-- | src/report.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/report.h b/src/report.h index 78dc2165..6fa238f0 100644 --- a/src/report.h +++ b/src/report.h @@ -256,6 +256,8 @@ public: HANDLER(forecast_years_).report(out); HANDLER(format_).report(out); HANDLER(gain).report(out); + HANDLER(group_by_).report(out); + HANDLER(group_title_format_).report(out); HANDLER(head_).report(out); HANDLER(invert).report(out); HANDLER(limit_).report(out); @@ -596,6 +598,22 @@ public: " - get_at(total_expr, 1)"); }); + OPTION__ + (report_t, group_by_, + expr_t expr; + CTOR(report_t, group_by_) {} + void set_expr(const optional<string>& whence, const string& str) { + expr = str; + on(whence, str); + } + DO_(args) { + set_expr(args[0].to_string(), args[1].to_string()); + }); + + OPTION__(report_t, group_title_format_, CTOR(report_t, group_title_format_) { + on(none, "%(value)\n"); + }); + OPTION(report_t, head_); OPTION_(report_t, invert, DO() { |