diff options
-rw-r--r-- | src/xact.cc | 39 | ||||
-rw-r--r-- | test/regress/712.test | 10 |
2 files changed, 15 insertions, 34 deletions
diff --git a/src/xact.cc b/src/xact.cc index 8aecf5d6..7ea15322 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -252,44 +252,15 @@ bool xact_base_t::finalize() const amount_t * x = &(*a++).second; const amount_t * y = &(*a++).second; - if (x->commodity() != top_post->amount.commodity()) { - const amount_t * t = x; - x = y; - y = t; - } - if (*x && *y) { + if (x->commodity() != top_post->amount.commodity()) + std::swap(x, y); + DEBUG("xact.finalize", "primary amount = " << *x); DEBUG("xact.finalize", "secondary amount = " << *y); - commodity_t& comm(x->commodity()); - amount_t per_unit_cost; - amount_t total_cost; - const amount_t * prev_y = y; - - foreach (post_t * post, posts) { - if (post != top_post && post->must_balance() && - ! post->amount.is_null() && - post->amount.has_annotation() && - post->amount.annotation().price) { - amount_t temp = *post->amount.annotation().price * post->amount; - if (total_cost.is_null()) { - total_cost = temp; - y = &total_cost; - } - else if (total_cost.commodity() == temp.commodity()) { - total_cost += temp; - } - else { - DEBUG("xact.finalize", - "multiple price commodities, aborting price calc"); - y = prev_y; - break; - } - DEBUG("xact.finalize", "total_cost = " << total_cost); - } - } - per_unit_cost = (*y / *x).abs().unrounded(); + commodity_t& comm(x->commodity()); + amount_t per_unit_cost = (*y / *x).abs().unrounded(); DEBUG("xact.finalize", "per_unit_cost = " << per_unit_cost); diff --git a/test/regress/712.test b/test/regress/712.test new file mode 100644 index 00000000..e0dbfa5a --- /dev/null +++ b/test/regress/712.test @@ -0,0 +1,10 @@ +2012/09/27 PLN Payment + Accrued 3,547.65 PLN {=$0.315786} + Accrued 5,320.06 PLN {=$0.315786} + Assets:Checking $-2,800.30 + +test -X $ -V reg +12-Sep-27 PLN Payment Accrued $1,120.30 $1,120.30 + Accrued $1,680.00 $2,800.30 + Assets:Checking $-2,800.30 0 +end test |