diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-24 15:06:43 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-24 15:06:43 -0400 |
commit | 1ecf62ce25e01def8a0df0a7c59047148c2cd734 (patch) | |
tree | 01afd48f7403482cc6be320a28c3b3ad3707fdf2 /src/post.cc | |
parent | c4207a79d7250f95d259678d0e4077a2a39b1d32 (diff) | |
download | ledger-1ecf62ce25e01def8a0df0a7c59047148c2cd734.tar.gz ledger-1ecf62ce25e01def8a0df0a7c59047148c2cd734.tar.bz2 ledger-1ecf62ce25e01def8a0df0a7c59047148c2cd734.zip |
Output "@ AMOUNT" cost in the print report
Diffstat (limited to 'src/post.cc')
-rw-r--r-- | src/post.cc | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/post.cc b/src/post.cc index 366af008..5c188a6e 100644 --- a/src/post.cc +++ b/src/post.cc @@ -122,6 +122,10 @@ namespace { return post.has_flags(POST_CALCULATED); } + value_t get_is_priced(post_t& post) { + return post.has_flags(POST_PRICED); + } + value_t get_virtual(post_t& post) { return post.has_flags(POST_VIRTUAL); } @@ -162,16 +166,18 @@ namespace { return post.amount.commodity().has_flags(COMMODITY_PRIMARY); } + value_t get_has_cost(post_t& post) { + return post.cost ? true : false; + } + value_t get_cost(post_t& post) { - if (post.has_xdata() && - post.xdata().has_flags(POST_EXT_COMPOUND)) { + if (post.cost) + return *post.cost; + else if (post.has_xdata() && + post.xdata().has_flags(POST_EXT_COMPOUND)) return post.xdata().value; - } else { - if (post.cost) - return *post.cost; - else - return post.amount; - } + else + return post.amount; } value_t get_total(post_t& post) { @@ -250,9 +256,9 @@ expr_t::ptr_op_t post_t::lookup(const string& name) return WRAP_FUNCTOR(get_wrapper<&get_account_depth>); break; - case 'r': - if (name == "real") - return WRAP_FUNCTOR(get_wrapper<&get_real>); + case 'h': + if (name == "has_cost") + return WRAP_FUNCTOR(get_wrapper<&get_has_cost>); break; case 'p': @@ -262,6 +268,13 @@ expr_t::ptr_op_t post_t::lookup(const string& name) return WRAP_FUNCTOR(get_wrapper<&get_payee>); else if (name == "primary") return WRAP_FUNCTOR(get_wrapper<&get_commodity_is_primary>); + else if (name == "priced") + return WRAP_FUNCTOR(get_wrapper<&get_is_priced>); + break; + + case 'r': + if (name == "real") + return WRAP_FUNCTOR(get_wrapper<&get_real>); break; case 't': |