From dc91fdeff280a85b5157cf0aea56eae0bd1ae209 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 19 Jan 2009 17:47:46 -0400 Subject: Added argument to amount_t::value() for request a market value in terms of a specific commodity. --- src/amount.cc | 6 +++--- src/amount.h | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/amount.cc b/src/amount.cc index 32dbf856..b03f4490 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -663,11 +663,11 @@ amount_t& amount_t::in_place_unreduce() return *this; } -optional amount_t::value(const optional& moment) const +optional amount_t::value(const optional& moment, + const optional& in_terms_of) const { if (quantity) { - // jww (2008-09-21): 'none' is not the right argument here. - optional point(commodity().find_price(none, moment)); + optional point(commodity().find_price(in_terms_of, moment)); if (point) return (point->price * number()).round(); } else { diff --git a/src/amount.h b/src/amount.h index 0667d9c3..12711ce0 100644 --- a/src/amount.h +++ b/src/amount.h @@ -354,10 +354,11 @@ public: * compact form greater than 1.0. That is, 3599s will unreduce to * 59.98m, while 3601 unreduces to 1h. * - * value(optional) returns the historical value for an - * amount -- the default moment returns the most recently known - * price -- based on the price history of its commodity. For - * example, if the amount were 10 AAPL, and on Apr 10, 2000 each + * value(optional, optional) returns the + * historical value for an amount -- the default moment returns the + * most recently known price -- based on the price history for the + * given commodity (or determined automatically, if none is provided). + * For example, if the amount were 10 AAPL, and on Apr 10, 2000 each * share of AAPL was worth $10, then call value() for that moment in * time would yield the amount $100.00. * @@ -419,7 +420,9 @@ public: } amount_t& in_place_unreduce(); - optional value(const optional& moment = none) const; + optional + value(const optional& moment = none, + const optional& in_terms_of = none) const; /** * Truth tests. An amount may be truth test in several ways: -- cgit v1.2.3