aboutsummaryrefslogtreecommitdiff
path: root/budget/models.py
diff options
context:
space:
mode:
authorBaptiste Jonglez <git@bitsofnetworks.org>2017-01-02 14:52:59 +0100
committerBaptiste Jonglez <git@bitsofnetworks.org>2017-01-03 21:37:19 +0100
commitb507a5afa1b4e3594a3a35f3aae08f7f38989338 (patch)
tree207fbd78e384659ba0c21473744cb7fa7da40740 /budget/models.py
parent543df7c1d43c49fd8cf48e7028524cb760da5654 (diff)
downloadihatemoney-mirror-b507a5afa1b4e3594a3a35f3aae08f7f38989338.zip
ihatemoney-mirror-b507a5afa1b4e3594a3a35f3aae08f7f38989338.tar.gz
ihatemoney-mirror-b507a5afa1b4e3594a3a35f3aae08f7f38989338.tar.bz2
Prevent transfers with a zero amount in the settle page
This workarounds a rounding issue caused by the (incorrect) usage of floats for bill amounts. This fixes #138
Diffstat (limited to 'budget/models.py')
-rw-r--r--budget/models.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/budget/models.py b/budget/models.py
index 852b3e1..b17fc55 100644
--- a/budget/models.py
+++ b/budget/models.py
@@ -61,9 +61,9 @@ class Project(db.Model):
credits, debts, transactions = [],[],[]
# Create lists of credits and debts
for person in self.members:
- if balance[person.id] > 0:
+ if round(balance[person.id], 2) > 0:
credits.append({"person": person, "balance": balance[person.id]})
- elif balance[person.id] < 0:
+ elif round(balance[person.id], 2) < 0:
debts.append({"person": person, "balance": -balance[person.id]})
# Try and find exact matches
for credit in credits: