diff options
-rw-r--r-- | doc/ledger.1 | 3 | ||||
-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 |
5 files changed, 32 insertions, 1 deletions
diff --git a/doc/ledger.1 b/doc/ledger.1 index becec762..1c6d6d62 100644 --- a/doc/ledger.1 +++ b/doc/ledger.1 @@ -1,4 +1,4 @@ -.Dd February 25, 2009 +.Dd February 27, 2009 .Dt ledger 1 .Sh NAME .Nm ledger @@ -206,6 +206,7 @@ appeared in the original journal file. .It Fl \-truncate .It Fl \-unbudgeted .It Fl \-uncleared Pq Fl U +.It Fl \-unround .It Fl \-verbose .It Fl \-verify .It Fl \-version 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"); }); |