diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-21 19:05:30 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-21 19:05:30 -0400 |
commit | 6b9c83b156d44984ae58f47b173fe743f19d8188 (patch) | |
tree | aece6d07a18dbe154f15fa96cdb1dc6ad9d739a0 | |
parent | 509f4505fcd05069180d9ff3d74245001a1391e3 (diff) | |
download | fork-ledger-6b9c83b156d44984ae58f47b173fe743f19d8188.tar.gz fork-ledger-6b9c83b156d44984ae58f47b173fe743f19d8188.tar.bz2 fork-ledger-6b9c83b156d44984ae58f47b173fe743f19d8188.zip |
Use more general scrub valexpr function in formats
-rw-r--r-- | src/report.cc | 9 | ||||
-rw-r--r-- | src/report.h | 79 |
2 files changed, 46 insertions, 42 deletions
diff --git a/src/report.cc b/src/report.cc index a9c930b0..47e8d8c4 100644 --- a/src/report.cc +++ b/src/report.cc @@ -143,6 +143,11 @@ value_t report_t::fn_market_value(call_scope_t& args) value_t report_t::fn_strip(call_scope_t& args) { + return args[0].strip_annotations(what_to_keep()); +} + +value_t report_t::fn_scrub(call_scope_t& args) +{ value_t temp(args[0].strip_annotations(what_to_keep())); if (HANDLED(base)) return temp; @@ -632,7 +637,9 @@ expr_t::ptr_op_t report_t::lookup(const string& name) break; case 's': - if (is_eq(p, "strip")) + if (is_eq(p, "scrub")) + return MAKE_FUNCTOR(report_t::fn_scrub); + else if (is_eq(p, "strip")) return MAKE_FUNCTOR(report_t::fn_strip); break; diff --git a/src/report.h b/src/report.h index f0408e89..b76bc9f3 100644 --- a/src/report.h +++ b/src/report.h @@ -134,6 +134,7 @@ public: value_t fn_display_total(call_scope_t& scope); value_t fn_market_value(call_scope_t& scope); value_t fn_strip(call_scope_t& scope); + value_t fn_scrub(call_scope_t& scope); value_t fn_quantity(call_scope_t& scope); value_t fn_rounded(call_scope_t& scope); value_t fn_truncate(call_scope_t& scope); @@ -233,10 +234,9 @@ public: }); OPTION__(report_t, balance_format_, CTOR(report_t, balance_format_) { - on( - "%20(print(strip(display_total), 20))" - " %(!options.flat ? depth_spacer : \"\")" - "%-(partial_account(options.flat))\n"); + on("%20(print(scrub(display_total), 20))" + " %(!options.flat ? depth_spacer : \"\")" + "%-(partial_account(options.flat))\n"); }); OPTION(report_t, base); @@ -286,15 +286,14 @@ public: OPTION(report_t, columns_); OPTION__(report_t, csv_format_, CTOR(report_t, csv_format_) { - on( - "%(quoted(date))," - "%(quoted(payee))," - "%(quoted(account))," - "%(quoted(strip(display_amount)))," - "%(quoted((cleared or entry.cleared) ?" - " \"*\" : ((pending or entry.pending) ? \"!\" : \"\")))," - "%(quoted(code))," - "%(quoted(join(note)))\n"); + on("%(quoted(date))," + "%(quoted(payee))," + "%(quoted(account))," + "%(quoted(scrub(display_amount)))," + "%(quoted((cleared or entry.cleared) ?" + " \"*\" : ((pending or entry.pending) ? \"!\" : \"\")))," + "%(quoted(code))," + "%(quoted(join(note)))\n"); }); OPTION_(report_t, current, DO() { // -c @@ -444,11 +443,11 @@ public: OPTION(report_t, period_sort_); OPTION__(report_t, plot_amount_format_, CTOR(report_t, plot_amount_format_) { - on("%(format_date(date, \"%Y-%m-%d\")) %(quantity(strip(amount)))\n"); + on("%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(amount)))\n"); }); OPTION__(report_t, plot_total_format_, CTOR(report_t, plot_total_format_) { - on("%(format_date(date, \"%Y-%m-%d\")) %(quantity(strip(total)))\n"); + on("%(format_date(date, \"%Y-%m-%d\")) %(quantity(scrub(total)))\n"); }); OPTION_(report_t, price, DO() { // -I @@ -459,7 +458,7 @@ public: OPTION(report_t, price_exp_); // -Z OPTION__(report_t, prices_format_, CTOR(report_t, prices_format_) { - on("%-.9(date) %-8(account) %12(strip(display_amount))\n"); + on("%-.9(date) %-8(account) %12(scrub(display_amount))\n"); }); OPTION__(report_t, pricesdb_format_, CTOR(report_t, pricesdb_format_) { @@ -467,16 +466,15 @@ public: }); OPTION__(report_t, print_format_, CTOR(report_t, print_format_) { - on( - "%(format_date(entry.date, \"%Y/%m/%d\"))" - "%(entry.cleared ? \" *\" : (entry.pending ? \" !\" : \"\"))" - "%(code ? \" (\" + code + \")\" : \"\") %(payee)%(entry.comment | \"\")\n" - " %(entry.uncleared ? (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")" - "%-34(account)" - " %12(calculated ? \"\" : strip(amount))%(comment | \"\")\n%/" - " %(entry.uncleared ? (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")" - "%-34(account)" - " %12(calculated ? \"\" : strip(amount))%(comment | \"\")\n%/\n"); + on("%(format_date(entry.date, \"%Y/%m/%d\"))" + "%(entry.cleared ? \" *\" : (entry.pending ? \" !\" : \"\"))" + "%(code ? \" (\" + code + \")\" : \"\") %(payee)%(entry.comment | \"\")\n" + " %(entry.uncleared ? (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")" + "%-34(account)" + " %12(calculated ? \"\" : scrub(amount))%(comment | \"\")\n%/" + " %(entry.uncleared ? (cleared ? \"* \" : (pending ? \"! \" : \"\")) : \"\")" + "%-34(account)" + " %12(calculated ? \"\" : scrub(amount))%(comment | \"\")\n%/\n"); }); OPTION_(report_t, quantity, DO() { // -O @@ -494,21 +492,20 @@ public: }); OPTION__(report_t, register_format_, CTOR(report_t, register_format_) { - on( - "%(print(date, date_width))" - " %(print(truncate(payee, payee_width), payee_width))" - " %(print(truncate(account, account_width, abbrev_len), account_width))" - " %(print(strip(display_amount), amount_width, " - "3 + date_width + payee_width + account_width + amount_width))" - " %(print(strip(display_total), total_width, " - "4 + date_width + payee_width + account_width + amount_width " - "+ total_width))\n%/" - "%(print(\" \", 2 + date_width + payee_width))" - "%(print(truncate(account, account_width, abbrev_len), account_width))" - " %(print(strip(display_amount), amount_width, 3 + date_width " - "+ payee_width + account_width + amount_width))" - " %(print(strip(display_total), total_width, 4 + date_width " - "+ payee_width + account_width + amount_width + total_width))\n"); + on("%(print(date, date_width))" + " %(print(truncate(payee, payee_width), payee_width))" + " %(print(truncate(account, account_width, abbrev_len), account_width))" + " %(print(scrub(display_amount), amount_width, " + "3 + date_width + payee_width + account_width + amount_width))" + " %(print(scrub(display_total), total_width, " + "4 + date_width + payee_width + account_width + amount_width " + "+ total_width))\n%/" + "%(print(\" \", 2 + date_width + payee_width))" + "%(print(truncate(account, account_width, abbrev_len), account_width))" + " %(print(scrub(display_amount), amount_width, 3 + date_width " + "+ payee_width + account_width + amount_width))" + " %(print(scrub(display_total), total_width, 4 + date_width " + "+ payee_width + account_width + amount_width + total_width))\n"); }); OPTION(report_t, related); // -r |