From 88460db2fbb0ab76c0ab3705cc4043e7fb2726d4 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 27 Oct 2009 08:04:31 -0400 Subject: Added a new "budget" report This is a balance report with four columns: Amount spent | Budgeted Amount | Difference | Percentage --- src/report.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/report.cc') diff --git a/src/report.cc b/src/report.cc index 6fc7626f..2f932115 100644 --- a/src/report.cc +++ b/src/report.cc @@ -700,11 +700,24 @@ expr_t::ptr_op_t report_t::lookup(const string& name) if (WANT_CMD()) { const char * q = p + CMD_PREFIX_LEN; switch (*q) { case 'b': - if (*(q + 1) == '\0' || is_eq(q, "bal") || is_eq(q, "balance")) + if (*(q + 1) == '\0' || is_eq(q, "bal") || is_eq(q, "balance")) { return expr_t::op_t::wrap_functor (reporter (new format_accounts(*this, report_format(HANDLER(balance_format_))), *this, "#balance")); + } + else if (is_eq(q, "budget")) { + HANDLER(amount_).set_expr(string("#budget"), "(amount, 0)"); + + budget_flags |= BUDGET_WRAP_VALUES; + if (! (budget_flags & ~BUDGET_WRAP_VALUES)) + budget_flags |= BUDGET_BUDGETED; + + return expr_t::op_t::wrap_functor + (reporter + (new format_accounts(*this, report_format(HANDLER(budget_format_))), + *this, "#budget")); + } break; case 'c': -- cgit v1.2.3