From ff9cf572fe5054f2e5c5d7ab4e68d63011e4a38a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 5 Mar 2012 17:49:11 -0600 Subject: Added (disabled) code to stop sorting generated balancing postings --- src/xact.cc | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/xact.cc') diff --git a/src/xact.cc b/src/xact.cc index 7dbf097d..5cec9ab0 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -331,12 +331,19 @@ bool xact_base_t::finalize() if (balance.is_balance()) { const balance_t& bal(balance.as_balance()); - typedef std::map sorted_amounts_map; +#if 1 + typedef std::map, + amount_t> sorted_amounts_map; sorted_amounts_map samp; foreach (const balance_t::amounts_map::value_type& pair, bal.amounts) { std::pair result = - samp.insert(sorted_amounts_map::value_type(pair.first->mapping_key(), - pair.second)); + samp.insert(sorted_amounts_map::value_type + (sorted_amounts_map::key_type + (pair.first->symbol(), + pair.first->has_annotation() ? + as_annotated_commodity(*pair.first).details : + annotation_t()), + pair.second)); assert(result.second); } @@ -353,6 +360,21 @@ bool xact_base_t::finalize() add_post(p); } } +#else + bool first = true; + foreach (const balance_t::amounts_map::value_type& pair, bal.amounts) { + if (first) { + null_post->amount = pair.second.negated(); + null_post->add_flags(POST_CALCULATED); + first = false; + } else { + post_t * p = new post_t(null_post->account, pair.second.negated(), + ITEM_GENERATED | POST_CALCULATED); + p->set_state(null_post->state()); + add_post(p); + } + } +#endif } else if (balance.is_amount()) { null_post->amount = balance.as_amount().negated(); -- cgit v1.2.3