summaryrefslogtreecommitdiff
path: root/src/annotate.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-06 03:18:10 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-06 03:24:06 -0600
commit97d68ebc8cf2bf88feffaedd6873934dc785c411 (patch)
treeb19e73eb8860dda1bbf8358141ddf1afc2060b50 /src/annotate.cc
parenteb3591f898e194be0cb6c15107e8e41e9dd67206 (diff)
downloadfork-ledger-97d68ebc8cf2bf88feffaedd6873934dc785c411.tar.gz
fork-ledger-97d68ebc8cf2bf88feffaedd6873934dc785c411.tar.bz2
fork-ledger-97d68ebc8cf2bf88feffaedd6873934dc785c411.zip
Added "value" sub-directive for commodity directive
Diffstat (limited to 'src/annotate.cc')
-rw-r--r--src/annotate.cc22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/annotate.cc b/src/annotate.cc
index 83926587..d2e4976e 100644
--- a/src/annotate.cc
+++ b/src/annotate.cc
@@ -34,7 +34,6 @@
#include "amount.h"
#include "commodity.h"
#include "expr.h"
-#include "scope.h"
#include "annotate.h"
#include "pool.h"
@@ -263,24 +262,9 @@ annotated_commodity_t::find_price(const optional<commodity_t&>& commodity,
DEBUG("commodity.price.find", "target commodity: " << target->symbol());
#endif
- if (details.value_expr) {
-#if defined(DEBUG_ON)
- if (SHOW_DEBUG("commodity.price.find")) {
- ledger::_log_buffer << "valuation expr: ";
- details.value_expr->dump(ledger::_log_buffer);
- DEBUG("commodity.price.find", "");
- }
-#endif
- call_scope_t call_args(*scope_t::default_scope);
-
- call_args.push_back(string_value(base_symbol()));
- call_args.push_back(when);
- if (commodity)
- call_args.push_back(string_value(commodity->symbol()));
-
- return price_point_t(when, const_cast<expr_t&>(*details.value_expr)
- .calc(call_args).to_amount());
- }
+ if (details.value_expr)
+ return find_price_from_expr(const_cast<expr_t&>(*details.value_expr),
+ commodity, when);
return commodity_t::find_price(commodity, moment, oldest);
}