Made amount_t::value a bit safer
This commit is contained in:
parent
6fd512cc11
commit
627162acc0
1 changed files with 6 additions and 5 deletions
|
|
@ -743,21 +743,22 @@ 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;
|
||||
}
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue