summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xact.cc40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/xact.cc b/src/xact.cc
index 7f441b49..fa79cb86 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -84,6 +84,29 @@ namespace {
}
}
+ value_t get_cost(xact_t& xact) {
+ if (xact.has_xdata() &&
+ xact.xdata().has_flags(XACT_EXT_COMPOUND)) {
+ return xact.xdata().value.cost();
+ } else {
+ if (xact.cost)
+ return *xact.cost;
+ else
+ return xact.amount;
+ }
+ }
+
+#if 0
+ value_t get_price(xact_t& xact) {
+ if (xact.has_xdata() &&
+ xact.xdata().has_flags(XACT_EXT_COMPOUND)) {
+ return xact.xdata().value;
+ } else {
+ return xact.amount;
+ }
+ }
+#endif
+
value_t get_total(xact_t& xact) {
if (xact.xdata_)
return xact.xdata_->total;
@@ -91,8 +114,13 @@ namespace {
return xact.amount;
}
- value_t get_cost(xact_t& xact) {
- return xact.cost ? *xact.cost : xact.amount;
+ value_t get_total_cost(xact_t& xact) {
+ if (xact.xdata_)
+ return xact.xdata_->total.cost();
+ else if (xact.cost)
+ return *xact.cost;
+ else
+ return xact.amount;
}
value_t get_account(call_scope_t& scope)
@@ -140,16 +168,24 @@ expr_t::ptr_op_t xact_t::lookup(const string& name)
case 'c':
if (name == "code")
return WRAP_FUNCTOR(get_wrapper<&get_code>);
+ else if (name == "cost")
+ return WRAP_FUNCTOR(get_wrapper<&get_cost>);
break;
case 'p':
if (name == "payee")
return WRAP_FUNCTOR(get_wrapper<&get_payee>);
+#if 0
+ else if (name == "price")
+ return WRAP_FUNCTOR(get_wrapper<&get_price>);
+#endif
break;
case 't':
if (name[1] == '\0' || name == "total")
return WRAP_FUNCTOR(get_wrapper<&get_total>);
+ else if (name == "total_cost")
+ return WRAP_FUNCTOR(get_wrapper<&get_total_cost>);
break;
}