diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/account.cc | 10 | ||||
-rw-r--r-- | src/report.cc | 12 | ||||
-rw-r--r-- | src/report.h | 14 |
3 files changed, 35 insertions, 1 deletions
diff --git a/src/account.cc b/src/account.cc index 4301b5d5..c8fd3a6a 100644 --- a/src/account.cc +++ b/src/account.cc @@ -225,6 +225,11 @@ namespace { return string_value(out.str()); } + value_t get_latest_cleared(account_t& account) + { + return account.self_details().latest_cleared_post; + } + template <value_t (*Func)(account_t&)> value_t get_wrapper(call_scope_t& scope) { return (*Func)(find_scope<account_t>(scope)); @@ -264,6 +269,11 @@ expr_t::ptr_op_t account_t::lookup(const string& name) return WRAP_FUNCTOR(get_wrapper<&get_true>); break; + case 'l': + if (name == "latest_cleared") + return WRAP_FUNCTOR(get_wrapper<&get_latest_cleared>); + break; + case 'p': if (name == "partial_account") return WRAP_FUNCTOR(get_partial_name); diff --git a/src/report.cc b/src/report.cc index 2f932115..7f31b615 100644 --- a/src/report.cc +++ b/src/report.cc @@ -721,11 +721,21 @@ expr_t::ptr_op_t report_t::lookup(const string& name) break; case 'c': - if (is_eq(q, "csv")) + if (is_eq(q, "csv")) { return WRAP_FUNCTOR (reporter<> (new format_posts(*this, report_format(HANDLER(csv_format_))), *this, "#csv")); + } + else if (is_eq(q, "cleared")) { + HANDLER(amount_).set_expr(string("#cleared"), + "(amount, cleared ? amount : 0)"); + + return expr_t::op_t::wrap_functor + (reporter<account_t, acct_handler_ptr, &report_t::accounts_report> + (new format_accounts(*this, report_format(HANDLER(cleared_format_))), + *this, "#cleared")); + } break; case 'e': diff --git a/src/report.h b/src/report.h index baacd28c..8c66c88a 100644 --- a/src/report.h +++ b/src/report.h @@ -209,6 +209,7 @@ public: HANDLER(budget_format_).report(out); HANDLER(by_payee).report(out); HANDLER(cleared).report(out); + HANDLER(cleared_format_).report(out); HANDLER(code_as_payee).report(out); HANDLER(comm_as_payee).report(out); HANDLER(code_as_account).report(out); @@ -395,6 +396,19 @@ public: parent->HANDLER(limit_).on(string("--cleared"), "cleared"); }); + OPTION__(report_t, cleared_format_, CTOR(report_t, cleared_format_) { + on(none, + "%(justify(scrub(get_at(total_expr, 0)), 16, -1, true, color))" + " %(justify(scrub(get_at(total_expr, 1)), 16, -1, true, color))" + " %(latest_cleared ? format_date(latest_cleared) : \" \")" + " %(!options.flat ? depth_spacer : \"\")" + "%-(ansify_if(partial_account(options.flat), blue if color))\n%/" + "%(justify(scrub(get_at(total_expr, 0)), 16, -1, true, color))" + " %(justify(scrub(get_at(total_expr, 1)), 16, -1, true, color))" + " %(latest_cleared ? format_date(latest_cleared) : \" \")\n%/" + "---------------- ---------------- ---------\n"); + }); + OPTION(report_t, code_as_payee); OPTION(report_t, comm_as_payee); OPTION(report_t, code_as_account); |