diff options
author | John Wiegley <johnw@newartisans.com> | 2009-12-07 21:23:50 -0500 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-12-07 21:23:50 -0500 |
commit | f1a2a5a18d5e7104ad308b2f56a9188f441bb7f2 (patch) | |
tree | eeef84ba9b48e11296793c64a1ce20436cfd4316 /src/pool.cc | |
parent | 6d0ab845eaec51946190c847f1ad08f910e5a003 (diff) | |
download | fork-ledger-f1a2a5a18d5e7104ad308b2f56a9188f441bb7f2.tar.gz fork-ledger-f1a2a5a18d5e7104ad308b2f56a9188f441bb7f2.tar.bz2 fork-ledger-f1a2a5a18d5e7104ad308b2f56a9188f441bb7f2.zip |
Cost of a post with neg. amount should be negative
Diffstat (limited to 'src/pool.cc')
-rw-r--r-- | src/pool.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pool.cc b/src/pool.cc index 70f4eed6..f895a8bc 100644 --- a/src/pool.cc +++ b/src/pool.cc @@ -247,7 +247,7 @@ commodity_pool_t::exchange(const amount_t& amount, current_annotation = &as_annotated_commodity(commodity).details; amount_t per_unit_cost = - (is_per_unit || amount.is_realzero() ? cost : cost / amount).abs(); + (is_per_unit || amount.is_realzero()) ? cost.abs() : (cost / amount).abs(); DEBUG("commodity.prices.add", "exchange: per-unit-cost = " << per_unit_cost); @@ -255,7 +255,7 @@ commodity_pool_t::exchange(const amount_t& amount, exchange(commodity, per_unit_cost, moment ? *moment : CURRENT_TIME()); cost_breakdown_t breakdown; - breakdown.final_cost = ! is_per_unit ? cost : cost * amount; + breakdown.final_cost = ! is_per_unit ? cost : cost * amount.abs(); DEBUG("commodity.prices.add", "exchange: final-cost = " << breakdown.final_cost); |