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

Bugfix rounding settle algorithm

In some cases, settle algorithm failed to deliver optimal solution due to a rounding bug.
This commit is contained in:
Alexandre Avenel 2015-07-05 22:16:38 +02:00
parent 84aafc850e
commit b9458db08e

View file

@ -62,7 +62,7 @@ class Project(db.Model):
debts.append({"person": person, "balance": -balance[person.id]}) debts.append({"person": person, "balance": -balance[person.id]})
# Try and find exact matches # Try and find exact matches
for credit in credits: for credit in credits:
match = self.exactmatch(credit["balance"], debts) match = self.exactmatch(round(credit["balance"], 2), debts)
if match: if match:
for m in match: for m in match:
transactions.append({"ower": m["person"], "receiver": credit["person"], "amount": m["balance"]}) transactions.append({"ower": m["person"], "receiver": credit["person"], "amount": m["balance"]})