diff options
author | John Wiegley <johnw@newartisans.com> | 2009-03-06 00:19:24 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-03-06 00:27:16 -0400 |
commit | dd23edd5cee8e712e13a3b5eefffcc3c57bf9e10 (patch) | |
tree | 55081ead4eb51ab48a2fe3ceb0a654d8ae226311 /src | |
parent | 6ac79137f74a9257c0079f14cf3ef49e8da6375a (diff) | |
download | fork-ledger-dd23edd5cee8e712e13a3b5eefffcc3c57bf9e10.tar.gz fork-ledger-dd23edd5cee8e712e13a3b5eefffcc3c57bf9e10.tar.bz2 fork-ledger-dd23edd5cee8e712e13a3b5eefffcc3c57bf9e10.zip |
Implemented --unround using value expressions
Diffstat (limited to 'src')
-rw-r--r-- | src/chain.cc | 8 | ||||
-rw-r--r-- | src/filters.h | 23 | ||||
-rw-r--r-- | src/report.cc | 7 | ||||
-rw-r--r-- | src/report.h | 5 |
4 files changed, 14 insertions, 29 deletions
diff --git a/src/chain.cc b/src/chain.cc index 04af1601..e3bf2443 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -90,13 +90,11 @@ post_handler_ptr chain_post_handlers(report_t& report, report, report.HANDLED(revalued_only))); } - // calc_posts computes visited posting values and the running total + // calc_posts computes the running total. When this appears will determine, + // for example, whether filtered posts are included or excluded from the + // running total. handler.reset(new calc_posts(handler, expr, only_preliminaries)); - // unround_posts will unround the amounts in all postings - if (report.HANDLED(unround)) - handler.reset(new unround_posts(handler)); - // filter_posts will only pass through posts matching the // `secondary_predicate'. if (report.HANDLED(only_)) { diff --git a/src/filters.h b/src/filters.h index 69dd9ac7..d3968c51 100644 --- a/src/filters.h +++ b/src/filters.h @@ -82,29 +82,6 @@ public: } }; -/** - * @brief Brief - * - * Long. - */ -class unround_posts : public item_handler<post_t> -{ -public: - unround_posts(post_handler_ptr handler) - : item_handler<post_t>(handler) { - TRACE_CTOR(unround_posts, "posts_list&"); - } - virtual ~unround_posts() { - TRACE_DTOR(unround_posts); - } - - virtual void operator()(post_t& post) { - post.xdata().compound_value = post.amount.unrounded(); - post.xdata().add_flags(POST_EXT_COMPOUND); - item_handler<post_t>::operator()(post); - } -}; - class posts_iterator; /** diff --git a/src/report.cc b/src/report.cc index 0e203213..e4eef741 100644 --- a/src/report.cc +++ b/src/report.cc @@ -196,6 +196,11 @@ value_t report_t::fn_rounded(call_scope_t& args) return args.value().rounded(); } +value_t report_t::fn_unrounded(call_scope_t& args) +{ + return args.value().unrounded(); +} + value_t report_t::fn_quantity(call_scope_t& scope) { interactive_t args(scope, "a"); @@ -858,6 +863,8 @@ expr_t::ptr_op_t report_t::lookup(const string& name) case 'u': if (is_eq(p, "underline")) return WRAP_FUNCTOR(fn_underline); + else if (is_eq(p, "unrounded")) + return MAKE_FUNCTOR(report_t::fn_unrounded); break; case 'w': diff --git a/src/report.h b/src/report.h index 2b973bca..a8f048d3 100644 --- a/src/report.h +++ b/src/report.h @@ -145,6 +145,7 @@ public: 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_unrounded(call_scope_t& scope); value_t fn_truncated(call_scope_t& scope); value_t fn_abs(call_scope_t& scope); value_t fn_justify(call_scope_t& scope); @@ -639,7 +640,9 @@ public: parent->HANDLER(limit_).on("uncleared|pending"); }); - OPTION(report_t, unround); + OPTION_(report_t, unround, DO() { + parent->HANDLER(amount_).set_expr("unrounded(amount)"); + }); OPTION_(report_t, weekly, DO() { // -W parent->HANDLER(period_).on("weekly"); |