summaryrefslogtreecommitdiff
path: root/src/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-23 19:31:06 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-23 19:31:06 -0400
commiteda6cbd0146d371653feec70e0eb3ee4e4c56379 (patch)
treeaeb4e1ace0f9b284789f66f3ceb30bed66946b93 /src/amount.cc
parent014fde3418783d1ee1ec7fe4ea6c8b04ae7f6cd8 (diff)
parent93807fade69dd4f0ec575eda78fe1a77a85c24e3 (diff)
downloadfork-ledger-eda6cbd0146d371653feec70e0eb3ee4e4c56379.tar.gz
fork-ledger-eda6cbd0146d371653feec70e0eb3ee4e4c56379.tar.bz2
fork-ledger-eda6cbd0146d371653feec70e0eb3ee4e4c56379.zip
Merge branch 'next'
Diffstat (limited to 'src/amount.cc')
-rw-r--r--src/amount.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/amount.cc b/src/amount.cc
index 9817f464..1fbc96c8 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -743,21 +743,24 @@ amount_t::value(const optional<datetime_t>& moment,
optional<price_point_t> point;
optional<commodity_t&> comm(in_terms_of);
- if (comm && commodity().referent() == comm->referent()) {
- return *this;
- }
- else if (has_annotation() && annotation().price) {
+ if (has_annotation() && annotation().price) {
if (annotation().has_flags(ANNOTATION_PRICE_FIXATED)) {
point = price_point_t();
point->price = *annotation().price;
+ DEBUG("commodity.prices.find",
+ "amount_t::value: fixated price = " << point->price);
}
- else if (! in_terms_of) {
+ else if (! comm) {
comm = annotation().price->commodity();
}
}
if (! point) {
+ if (comm && commodity().referent() == comm->referent())
+ return *this;
+
point = commodity().find_price(comm, moment);
+
// Whether a price was found or not, check whether we should attempt
// to download a price from the Internet. This is done if (a) no
// price was found, or (b) the price is "stale" according to the