From d792cc0ffce53dd84bbce688e6008c8a77b6065d Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 21 Jun 2010 17:44:19 -0400 Subject: Corrected a major flaw in the transaction finalizer When a transaction has two commodities, but also a null posting, no attempt should be made to resolve the costs in terms of the primary commodity. --- src/xact.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/xact.cc') diff --git a/src/xact.cc b/src/xact.cc index bf18d5b3..1994d353 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -173,14 +173,15 @@ bool xact_base_t::finalize() add_post(null_post); } - if (balance.is_balance() && + if (! null_post && balance.is_balance() && balance.as_balance().amounts.size() == 2) { // When an xact involves two different commodities (regardless of how // many posts there are) determine the conversion ratio by dividing the // total value of one commodity by the total value of the other. This // establishes the per-unit cost for this post for both commodities. - DEBUG("xact.finalize", "there were exactly two commodities"); + DEBUG("xact.finalize", + "there were exactly two commodities, and no null post"); bool saw_cost = false; post_t * top_post = NULL; -- cgit v1.2.3