summaryrefslogtreecommitdiff
path: root/balance.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-03-19 21:11:49 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 02:41:31 -0400
commit32bdfe20d98f1c8e6c0aabe9b26f0507326d2baa (patch)
tree50a4c5490f842ff4241ed6c574d3debd0ed6e1b6 /balance.h
parentab748ed13ed87369e2e4ed5a617b5de12750fda6 (diff)
downloadfork-ledger-32bdfe20d98f1c8e6c0aabe9b26f0507326d2baa.tar.gz
fork-ledger-32bdfe20d98f1c8e6c0aabe9b26f0507326d2baa.tar.bz2
fork-ledger-32bdfe20d98f1c8e6c0aabe9b26f0507326d2baa.zip
Tons of corrections and fixes to value expressions and lot figures.
Diffstat (limited to 'balance.h')
-rw-r--r--balance.h50
1 files changed, 45 insertions, 5 deletions
diff --git a/balance.h b/balance.h
index c115ba45..d18ffd60 100644
--- a/balance.h
+++ b/balance.h
@@ -216,7 +216,15 @@ class balance_t
return true;
}
bool operator<(const amount_t& amt) const {
- return amount(amt.commodity()) < amt;
+ if (amt.commodity())
+ return amount(amt.commodity()) < amt;
+
+ for (amounts_map::const_iterator i = amounts.begin();
+ i != amounts.end();
+ i++)
+ if ((*i).second < amt)
+ return true;
+ return false;
}
template <typename T>
bool operator<(T val) const {
@@ -244,7 +252,15 @@ class balance_t
return true;
}
bool operator<=(const amount_t& amt) const {
- return amount(amt.commodity()) <= amt;
+ if (amt.commodity())
+ return amount(amt.commodity()) <= amt;
+
+ for (amounts_map::const_iterator i = amounts.begin();
+ i != amounts.end();
+ i++)
+ if ((*i).second <= amt)
+ return true;
+ return false;
}
template <typename T>
bool operator<=(T val) const {
@@ -275,7 +291,15 @@ class balance_t
return true;
}
bool operator>(const amount_t& amt) const {
- return amount(amt.commodity()) > amt;
+ if (amt.commodity())
+ return amount(amt.commodity()) > amt;
+
+ for (amounts_map::const_iterator i = amounts.begin();
+ i != amounts.end();
+ i++)
+ if ((*i).second > amt)
+ return true;
+ return false;
}
template <typename T>
bool operator>(T val) const {
@@ -303,7 +327,15 @@ class balance_t
return true;
}
bool operator>=(const amount_t& amt) const {
- return amount(amt.commodity()) >= amt;
+ if (amt.commodity())
+ return amount(amt.commodity()) >= amt;
+
+ for (amounts_map::const_iterator i = amounts.begin();
+ i != amounts.end();
+ i++)
+ if ((*i).second >= amt)
+ return true;
+ return false;
}
template <typename T>
bool operator>=(T val) const {
@@ -327,7 +359,15 @@ class balance_t
return i == amounts.end() && j == bal.amounts.end();
}
bool operator==(const amount_t& amt) const {
- return amounts.size() == 1 && (*amounts.begin()).second == amt;
+ if (amt.commodity())
+ return amounts.size() == 1 && (*amounts.begin()).second == amt;
+
+ for (amounts_map::const_iterator i = amounts.begin();
+ i != amounts.end();
+ i++)
+ if ((*i).second == amt)
+ return true;
+ return false;
}
template <typename T>
bool operator==(T val) const {