From a2c73120809ba78dfdeb75f5ff0956e5f41e5975 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Mar 2009 22:39:32 -0400 Subject: Renamed some flags and members in post_t --- src/filters.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/filters.h') diff --git a/src/filters.h b/src/filters.h index 68df6e06..eb93e50a 100644 --- a/src/filters.h +++ b/src/filters.h @@ -99,7 +99,7 @@ public: } virtual void operator()(post_t& post) { - post.xdata().value = post.amount.unrounded(); + post.xdata().compound_value = post.amount.unrounded(); post.xdata().add_flags(POST_EXT_COMPOUND); item_handler::operator()(post); } -- cgit v1.2.3 From 6ac79137f74a9257c0079f14cf3ef49e8da6375a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 5 Mar 2009 23:53:07 -0400 Subject: Don't compute running total for balance reports --- src/account.h | 7 ++++--- src/filters.cc | 29 ++++++++++++++++------------- src/filters.h | 6 +++--- 3 files changed, 23 insertions(+), 19 deletions(-) (limited to 'src/filters.h') diff --git a/src/account.h b/src/account.h index d0516e78..dd7ac3d6 100644 --- a/src/account.h +++ b/src/account.h @@ -123,9 +123,10 @@ class account_t : public scope_t #define ACCOUNT_EXT_SORT_CALC 0x01 #define ACCOUNT_EXT_HAS_NON_VIRTUALS 0x02 #define ACCOUNT_EXT_HAS_UNB_VIRTUALS 0x04 -#define ACCOUNT_EXT_VISITED 0x08 -#define ACCOUNT_EXT_MATCHING 0x10 -#define ACCOUNT_EXT_DISPLAYED 0x20 +#define ACCOUNT_EXT_AUTO_VIRTUALIZE 0x08 +#define ACCOUNT_EXT_VISITED 0x10 +#define ACCOUNT_EXT_MATCHING 0x20 +#define ACCOUNT_EXT_DISPLAYED 0x40 struct details_t { diff --git a/src/filters.cc b/src/filters.cc index b66bafae..2895bf7f 100644 --- a/src/filters.cc +++ b/src/filters.cc @@ -194,33 +194,33 @@ void calc_posts::operator()(post_t& post) if (last_post) { assert(last_post->has_xdata()); - add_or_set_value(xdata.total, last_post->xdata().total); + if (! account_wise) + xdata.total = last_post->xdata().total; xdata.count = last_post->xdata().count + 1; } else { xdata.count = 1; } - value_t amount; - post.add_to_value(amount, amount_expr); + post.add_to_value(xdata.visited_value, amount_expr); + xdata.add_flags(POST_EXT_VISITED); - add_or_set_value(xdata.total, amount); - - if (calc_totals) { - account_t * acct = post.reported_account(); + account_t * acct = post.reported_account(); + acct->xdata().add_flags(ACCOUNT_EXT_VISITED); + if (! account_wise) { + add_or_set_value(xdata.total, xdata.visited_value); + } else { account_t::xdata_t * acct_xdata = &acct->xdata(); - add_or_set_value(acct_xdata->self_details.total, amount); + add_or_set_value(acct_xdata->self_details.total, xdata.visited_value); acct_xdata->self_details.posts_count++; acct_xdata->self_details.posts_virtuals_count++; - acct_xdata->add_flags(ACCOUNT_EXT_VISITED); - while (true) { - add_or_set_value(acct_xdata->family_details.total, amount); - acct_xdata->family_details.posts_count++; + add_or_set_value(acct_xdata->family_details.total, xdata.visited_value); + acct_xdata->family_details.posts_count++; if (post.has_flags(POST_VIRTUAL)) acct_xdata->family_details.posts_virtuals_count++; @@ -259,7 +259,8 @@ namespace { // If the account for this post is all virtual, then report the post as // such. This allows subtotal reports to show "(Account)" for accounts // that contain only virtual posts. - if (account && account->has_xdata()) { + if (account && account->has_xdata() && + account->xdata().has_flags(ACCOUNT_EXT_AUTO_VIRTUALIZE)) { if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_NON_VIRTUALS)) { post.add_flags(POST_VIRTUAL); if (! account->xdata().has_flags(ACCOUNT_EXT_HAS_UNB_VIRTUALS)) @@ -567,6 +568,8 @@ void subtotal_posts::operator()(post_t& post) // such, so that `handle_value' can show "(Account)" for accounts // that contain only virtual posts. + post.reported_account()->xdata().add_flags(ACCOUNT_EXT_AUTO_VIRTUALIZE); + if (! post.has_flags(POST_VIRTUAL)) post.reported_account()->xdata().add_flags(ACCOUNT_EXT_HAS_NON_VIRTUALS); else if (! post.has_flags(POST_MUST_BALANCE)) diff --git a/src/filters.h b/src/filters.h index eb93e50a..69dd9ac7 100644 --- a/src/filters.h +++ b/src/filters.h @@ -342,16 +342,16 @@ class calc_posts : public item_handler { post_t * last_post; expr_t& amount_expr; - bool calc_totals; + bool account_wise; calc_posts(); public: calc_posts(post_handler_ptr handler, expr_t& _amount_expr, - bool _calc_totals = false) + bool _account_wise = false) : item_handler(handler), last_post(NULL), - amount_expr(_amount_expr), calc_totals(_calc_totals) { + amount_expr(_amount_expr), account_wise(_account_wise) { TRACE_CTOR(calc_posts, "post_handler_ptr, expr_t&, bool"); } virtual ~calc_posts() { -- cgit v1.2.3 From dd23edd5cee8e712e13a3b5eefffcc3c57bf9e10 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 6 Mar 2009 00:19:24 -0400 Subject: Implemented --unround using value expressions --- src/chain.cc | 8 +++----- src/filters.h | 23 ----------------------- src/report.cc | 7 +++++++ src/report.h | 5 ++++- 4 files changed, 14 insertions(+), 29 deletions(-) (limited to 'src/filters.h') 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 -{ -public: - unround_posts(post_handler_ptr handler) - : item_handler(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::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"); -- cgit v1.2.3