summaryrefslogtreecommitdiff
path: root/src/post.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-07 10:33:32 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-07 10:33:32 -0600
commita19578a6072d85857e0a9c837db3a8801f83577c (patch)
tree18ba8089d8d21250ed7b6e09d962a2a59f73bbfa /src/post.cc
parent755495ee8a019e458f43ea03449e7cd21d3f277f (diff)
downloadfork-ledger-a19578a6072d85857e0a9c837db3a8801f83577c.tar.gz
fork-ledger-a19578a6072d85857e0a9c837db3a8801f83577c.tar.bz2
fork-ledger-a19578a6072d85857e0a9c837db3a8801f83577c.zip
Added "price" value expression for posts
Diffstat (limited to 'src/post.cc')
-rw-r--r--src/post.cc11
1 files changed, 11 insertions, 0 deletions
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;