Added a new "cleared" report
This is a balance report with three columns: Current balance | Cleared balance | Last cleared date
This commit is contained in:
parent
88460db2fb
commit
fd23b56a21
3 changed files with 35 additions and 1 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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':
|
||||
|
|
|
|||
14
src/report.h
14
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue