From 2694335e54316606ab169e957034ba71e8274144 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 19 Feb 2009 21:57:17 -0400 Subject: Simplify account total values before comparison This way, if two account values are BALANCE types containing only a single AMOUNT, then it will do the sorting comparison of the amounts -- since otherwise balances are ignored for the purposes of sorting. --- src/compare.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/compare.cc') diff --git a/src/compare.cc b/src/compare.cc index 6b0cbe0d..015c28bc 100644 --- a/src/compare.cc +++ b/src/compare.cc @@ -53,10 +53,12 @@ namespace { sort_values.push_back(sort_value_t()); sort_values.back().inverted = inverted; - sort_values.back().value = expr_t(node).calc(*scope).reduced(); + sort_values.back().value = + expr_t(node).calc(*scope).reduced().simplified(); if (sort_values.back().value.is_null()) - throw calc_error("Could not determine sorting value based an expression"); + throw_(calc_error, + "Could not determine sorting value based an expression"); } } } @@ -107,6 +109,9 @@ bool compare_items::operator()(account_t * left, account_t * right) rxdata.add_flags(ACCOUNT_EXT_SORT_CALC); } + DEBUG("value.sort", "Comparing accounts " << left->fullname() + << " <> " << right->fullname()); + return sort_value_is_less_than(lxdata.sort_values, rxdata.sort_values); } -- cgit v1.2.3