Skip to content

Commit

Permalink
Prevent transfers with a zero amount in the settle page
Browse files Browse the repository at this point in the history
This workarounds a rounding issue caused by the (incorrect) usage of
floats for bill amounts.

This fixes #138
  • Loading branch information
Baptiste Jonglez committed Jan 2, 2017
1 parent 4d5c8a5 commit 72f177a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions budget/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 72f177a

Please sign in to comment.