From 72f177afd1cd9103cd8fd3b98e9fcb5c695d5902 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Mon, 2 Jan 2017 14:52:59 +0100 Subject: [PATCH] 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 --- budget/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/budget/models.py b/budget/models.py index 852b3e19a..b17fc55ca 100644 --- a/budget/models.py +++ b/budget/models.py @@ -61,9 +61,9 @@ def get_transactions_to_settle_bill(self): 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: