summaryrefslogtreecommitdiff
path: root/src/commodity.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/commodity.cc')
-rw-r--r--src/commodity.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/commodity.cc b/src/commodity.cc
index 6b39d711..18bafc8e 100644
--- a/src/commodity.cc
+++ b/src/commodity.cc
@@ -413,20 +413,21 @@ commodity_t::exchange(const amount_t& amount,
if (commodity.annotated)
current_annotation = &as_annotated_commodity(commodity).details;
- amount_t per_unit_cost(is_per_unit ? cost : (cost / amount).unrounded());
+ amount_t per_unit_cost = (is_per_unit ? cost : cost / amount).abs();
DEBUG("commodity.prices.add", "exchange: per-unit-cost = " << per_unit_cost);
exchange(commodity, per_unit_cost, moment ? *moment : CURRENT_TIME());
cost_breakdown_t breakdown;
- breakdown.final_cost = ! is_per_unit ? cost : (cost * amount).unrounded();
+ breakdown.final_cost = ! is_per_unit ? cost : cost * amount;
DEBUG("commodity.prices.add",
"exchange: final-cost = " << breakdown.final_cost);
if (current_annotation && current_annotation->price)
- breakdown.basis_cost = (*current_annotation->price * amount).unrounded();
+ breakdown.basis_cost
+ = (*current_annotation->price * amount).unrounded();
else
breakdown.basis_cost = breakdown.final_cost;