summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-05-23 15:24:02 -0600
committerJohn Wiegley <johnw@newartisans.com>2010-05-23 15:45:51 -0600
commit7bddcd676bc53c6caad7dd283be362fcd53d5721 (patch)
treed76464891f208aa9e97e21e3ee89360964fe4046 /src
parent847a5e4e73afd1c959f7211ceb67d6b9ab0f95d0 (diff)
downloadfork-ledger-7bddcd676bc53c6caad7dd283be362fcd53d5721.tar.gz
fork-ledger-7bddcd676bc53c6caad7dd283be362fcd53d5721.tar.bz2
fork-ledger-7bddcd676bc53c6caad7dd283be362fcd53d5721.zip
Added --rounding option, which is off by default
The purpose of this option is to add special "<Rounding>" postings, to ensure that a regiter's running total is *always* the sum of its postings. Within --rounding, these adjustment postings are missing, which was the behavior in Ledger 2.x. It can be orders of magnitude slower to turn it on for large reports with many commodities.
Diffstat (limited to 'src')
-rw-r--r--src/chain.cc3
-rw-r--r--src/filters.cc13
-rw-r--r--src/filters.h4
-rw-r--r--src/report.cc1
-rw-r--r--src/report.h2
5 files changed, 16 insertions, 7 deletions
diff --git a/src/chain.cc b/src/chain.cc
index 86f639ad..44133391 100644
--- a/src/chain.cc
+++ b/src/chain.cc
@@ -86,7 +86,8 @@ post_handler_ptr chain_post_handlers(report_t& report,
report.HANDLED(unrealized)))
handler.reset(new changed_value_posts(handler, report,
for_accounts_report,
- report.HANDLED(unrealized)));
+ report.HANDLED(unrealized),
+ report.HANDLED(rounding)));
// calc_posts computes the running total. When this appears will determine,
// for example, whether filtered posts are included or excluded from the
diff --git a/src/filters.cc b/src/filters.cc
index 13e188b1..57c95cd3 100644
--- a/src/filters.cc
+++ b/src/filters.cc
@@ -420,10 +420,12 @@ void related_posts::flush()
changed_value_posts::changed_value_posts(post_handler_ptr handler,
report_t& _report,
bool _for_accounts_report,
- bool _show_unrealized)
+ bool _show_unrealized,
+ bool _show_rounding)
: item_handler<post_t>(handler), report(_report),
for_accounts_report(_for_accounts_report),
- show_unrealized(_show_unrealized), last_post(NULL),
+ show_unrealized(_show_unrealized),
+ show_rounding(_show_rounding), last_post(NULL),
revalued_account(temps.create_account(_("<Revalued>"))),
rounding_account(temps.create_account(_("<Rounding>")))
{
@@ -505,9 +507,10 @@ void changed_value_posts::output_revaluation(post_t& post, const date_t& date)
/* total= */ repriced_total,
/* direct_amount= */ false,
/* mark_visited= */ false,
- /* functor= */ (optional<post_functor_t>
+ /* functor= */ (show_rounding ?
+ optional<post_functor_t>
(bind(&changed_value_posts::output_rounding,
- this, _1))));
+ this, _1)) : none));
}
else if (show_unrealized) {
handle_value
@@ -572,7 +575,7 @@ void changed_value_posts::operator()(post_t& post)
if (changed_values_only)
post.xdata().add_flags(POST_EXT_DISPLAYED);
- if (! for_accounts_report)
+ if (! for_accounts_report && show_rounding)
output_rounding(post);
item_handler<post_t>::operator()(post);
diff --git a/src/filters.h b/src/filters.h
index 82fbf687..ced51f3f 100644
--- a/src/filters.h
+++ b/src/filters.h
@@ -381,6 +381,7 @@ class changed_value_posts : public item_handler<post_t>
bool changed_values_only;
bool for_accounts_report;
bool show_unrealized;
+ bool show_rounding;
post_t * last_post;
value_t last_total;
value_t last_display_total;
@@ -396,7 +397,8 @@ public:
changed_value_posts(post_handler_ptr handler,
report_t& _report,
bool _for_accounts_report,
- bool _show_unrealized);
+ bool _show_unrealized,
+ bool _show_rounding);
virtual ~changed_value_posts() {
TRACE_DTOR(changed_value_posts);
diff --git a/src/report.cc b/src/report.cc
index dfdc77cc..486c0fdf 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -954,6 +954,7 @@ option_t<report_t> * report_t::lookup_option(const char * p)
else OPT(revalued);
else OPT(revalued_only);
else OPT(revalued_total_);
+ else OPT(rounding);
break;
case 's':
OPT(sort_);
diff --git a/src/report.h b/src/report.h
index aff4af91..aa72832c 100644
--- a/src/report.h
+++ b/src/report.h
@@ -295,6 +295,7 @@ public:
HANDLER(revalued).report(out);
HANDLER(revalued_only).report(out);
HANDLER(revalued_total_).report(out);
+ HANDLER(rounding).report(out);
HANDLER(seed_).report(out);
HANDLER(sort_).report(out);
HANDLER(sort_all_).report(out);
@@ -818,6 +819,7 @@ public:
set_expr(args[0].to_string(), args[1].to_string());
});
+ OPTION(report_t, rounding);
OPTION(report_t, seed_);
OPTION_(report_t, sort_, DO_(args) { // -S