summaryrefslogtreecommitdiff
path: root/src/compare.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-19 21:57:17 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-19 21:57:17 -0400
commit2694335e54316606ab169e957034ba71e8274144 (patch)
tree6c0c4ab3a4f525b0afee911a674b47abf1bbc324 /src/compare.cc
parent7fb328707cab288a49bd84c16c2b9eb7a02c5196 (diff)
downloadfork-ledger-2694335e54316606ab169e957034ba71e8274144.tar.gz
fork-ledger-2694335e54316606ab169e957034ba71e8274144.tar.bz2
fork-ledger-2694335e54316606ab169e957034ba71e8274144.zip
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.
Diffstat (limited to 'src/compare.cc')
-rw-r--r--src/compare.cc9
1 files changed, 7 insertions, 2 deletions
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<account_t>::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);
}