summaryrefslogtreecommitdiff
path: root/src/report.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-10-27 08:04:31 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-10-27 08:30:59 -0400
commit88460db2fbb0ab76c0ab3705cc4043e7fb2726d4 (patch)
treea9d6824db1ecc83abf0d2e0d4ea8549f01e002ad /src/report.cc
parenta8768587c8e6850e23ecbbfe4a108515b8ade892 (diff)
downloadfork-ledger-88460db2fbb0ab76c0ab3705cc4043e7fb2726d4.tar.gz
fork-ledger-88460db2fbb0ab76c0ab3705cc4043e7fb2726d4.tar.bz2
fork-ledger-88460db2fbb0ab76c0ab3705cc4043e7fb2726d4.zip
Added a new "budget" report
This is a balance report with four columns: Amount spent | Budgeted Amount | Difference | Percentage
Diffstat (limited to 'src/report.cc')
-rw-r--r--src/report.cc15
1 files changed, 14 insertions, 1 deletions
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<account_t, acct_handler_ptr, &report_t::accounts_report>
(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<account_t, acct_handler_ptr, &report_t::accounts_report>
+ (new format_accounts(*this, report_format(HANDLER(budget_format_))),
+ *this, "#budget"));
+ }
break;
case 'c':