1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

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
This commit is contained in:
Baptiste Jonglez 2017-01-02 14:52:59 +01:00
parent 543df7c1d4
commit b507a5afa1

View file

@ -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: