From a19578a6072d85857e0a9c837db3a8801f83577c Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 7 Mar 2012 10:33:32 -0600 Subject: Added "price" value expression for posts --- src/post.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/post.cc') diff --git a/src/post.cc b/src/post.cc index 7a6667f2..babb1292 100644 --- a/src/post.cc +++ b/src/post.cc @@ -240,6 +240,15 @@ namespace { return post.amount; } + value_t get_price(post_t& post) { + if (post.amount.is_null()) + return 0L; + if (post.amount.has_annotation() && post.amount.annotation().price) + return *post.amount.price(); + else + return get_cost(post); + } + value_t get_total(post_t& post) { if (post.xdata_ && ! post.xdata_->total.is_null()) return post.xdata_->total; @@ -475,6 +484,8 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind, return WRAP_FUNCTOR(get_wrapper<&get_payee>); else if (name == "primary") return WRAP_FUNCTOR(get_wrapper<&get_commodity_is_primary>); + else if (name == "price") + return WRAP_FUNCTOR(get_wrapper<&get_price>); else if (name == "parent") return WRAP_FUNCTOR(get_wrapper<&get_xact>); break; -- cgit v1.2.3