diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-27 03:04:05 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-27 03:04:05 -0400 |
commit | c49b98fc4c307a2d08161cebafb348b935c6fcb5 (patch) | |
tree | 02171b10ad660778447058649b17069108165298 /src | |
parent | c57c85c92f352acd6eefa309344dae7f98cf7f31 (diff) | |
download | ledger-c49b98fc4c307a2d08161cebafb348b935c6fcb5.tar.gz ledger-c49b98fc4c307a2d08161cebafb348b935c6fcb5.tar.bz2 ledger-c49b98fc4c307a2d08161cebafb348b935c6fcb5.zip |
Added an --unround option, to show full precision
Diffstat (limited to 'src')
-rw-r--r-- | src/chain.cc | 4 | ||||
-rw-r--r-- | src/filters.h | 23 | ||||
-rw-r--r-- | src/report.cc | 1 | ||||
-rw-r--r-- | src/report.h | 2 |
4 files changed, 30 insertions, 0 deletions
diff --git a/src/chain.cc b/src/chain.cc index d33742a5..9155d4fa 100644 --- a/src/chain.cc +++ b/src/chain.cc @@ -93,6 +93,10 @@ post_handler_ptr chain_post_handlers(report_t& report, handler.reset(new calc_posts(handler, expr)); } + // 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 9ac2a6b9..bd5f5897 100644 --- a/src/filters.h +++ b/src/filters.h @@ -83,6 +83,29 @@ 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().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 3d3e089a..8d673c78 100644 --- a/src/report.cc +++ b/src/report.cc @@ -542,6 +542,7 @@ option_t<report_t> * report_t::lookup_option(const char * p) case 'u': OPT(unbudgeted); else OPT(uncleared); + else OPT(unround); break; case 'w': OPT(weekly); diff --git a/src/report.h b/src/report.h index 5a386616..82c605df 100644 --- a/src/report.h +++ b/src/report.h @@ -643,6 +643,8 @@ public: parent->HANDLER(limit_).on("uncleared|pending"); }); + OPTION(report_t, unround); + OPTION_(report_t, weekly, DO() { // -W parent->HANDLER(period_).on("weekly"); }); |