From b9458db08ec12ce3645fe21fde71e82bf8fde3d6 Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Sun, 5 Jul 2015 22:16:38 +0200 Subject: [PATCH] Bugfix rounding settle algorithm In some cases, settle algorithm failed to deliver optimal solution due to a rounding bug. --- budget/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/budget/models.py b/budget/models.py index 27bd80b..727200f 100644 --- a/budget/models.py +++ b/budget/models.py @@ -62,7 +62,7 @@ class Project(db.Model): debts.append({"person": person, "balance": -balance[person.id]}) # Try and find exact matches for credit in credits: - match = self.exactmatch(credit["balance"], debts) + match = self.exactmatch(round(credit["balance"], 2), debts) if match: for m in match: transactions.append({"ower": m["person"], "receiver": credit["person"], "amount": m["balance"]})