summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-21 22:00:00 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-21 22:00:00 -0400
commit8ca91c1196181954e0b3da36110bfe069d2831fe (patch)
treeac294c6f9109e2706ecdb4380f290d25dd1eb8f6
parent018c812fdaead2c7b9ba4794de6ff298262ddd07 (diff)
downloadfork-ledger-8ca91c1196181954e0b3da36110bfe069d2831fe.tar.gz
fork-ledger-8ca91c1196181954e0b3da36110bfe069d2831fe.tar.bz2
fork-ledger-8ca91c1196181954e0b3da36110bfe069d2831fe.zip
Allow balance values to be compared < or > 0
-rw-r--r--src/value.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/value.cc b/src/value.cc
index 90067bba..ad4047cd 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -769,6 +769,27 @@ bool value_t::is_less_than(const value_t& val) const
}
break;
+ case BALANCE:
+ switch (val.type()) {
+ case INTEGER:
+ if (val.as_long() != 0)
+ break;
+ // fall through...
+ case AMOUNT:
+ if (val.is_nonzero())
+ break;
+
+ foreach (const balance_t::amounts_map::value_type& pair,
+ as_balance().amounts) {
+ if (pair.second > 0L)
+ return false;
+ }
+ return true;
+ default:
+ break;
+ }
+ break;
+
case STRING:
if (val.is_string())
return as_string() < val.as_string();
@@ -818,6 +839,27 @@ bool value_t::is_greater_than(const value_t& val) const
}
break;
+ case BALANCE:
+ switch (val.type()) {
+ case INTEGER:
+ if (val.as_long() != 0)
+ break;
+ // fall through...
+ case AMOUNT:
+ if (val.is_nonzero())
+ break;
+
+ foreach (const balance_t::amounts_map::value_type& pair,
+ as_balance().amounts) {
+ if (pair.second < 0L)
+ return false;
+ }
+ return true;
+ default:
+ break;
+ }
+ break;
+
case STRING:
if (val.is_string())
return as_string() > val.as_string();