From 9236c132134891c8255da5fd744f045c86e083fe Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Mon, 21 Jul 2014 22:23:30 +0200 Subject: [PATCH 1/2] Fix rounding error in balances --- budget/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/budget/models.py b/budget/models.py index c1372c0..b3e4eff 100644 --- a/budget/models.py +++ b/budget/models.py @@ -219,7 +219,7 @@ class Bill(db.Model): def pay_each(self): """Compute what each person has to pay""" if self.owers: - return round(self.amount / len(self.owers), 2) + return self.amount / len(self.owers) else: return 0 From 79f24b7cb812f0fa0aa1b4bb82d23cbae87d540e Mon Sep 17 00:00:00 2001 From: Alexandre Avenel Date: Tue, 22 Jul 2014 20:19:35 +0200 Subject: [PATCH 2/2] Format numbers in templates --- budget/models.py | 2 +- budget/templates/list_bills.html | 4 ++-- budget/templates/settle_bills.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/budget/models.py b/budget/models.py index b3e4eff..55a97c1 100644 --- a/budget/models.py +++ b/budget/models.py @@ -45,7 +45,7 @@ class Project(db.Model): for person in self.members: balance = should_receive[person] - should_pay[person] - balances[person.id] = round(balance, 2) + balances[person.id] = balance return balances diff --git a/budget/templates/list_bills.html b/budget/templates/list_bills.html index ee97624..f9d372a 100644 --- a/budget/templates/list_bills.html +++ b/budget/templates/list_bills.html @@ -73,8 +73,8 @@
{% endif %} - - {% if balance[member.id] > 0 %}+{% endif %}{{ balance[member.id] }} + + {% if balance[member.id] > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }} {% endfor %} diff --git a/budget/templates/settle_bills.html b/budget/templates/settle_bills.html index 29d9b26..4066b16 100644 --- a/budget/templates/settle_bills.html +++ b/budget/templates/settle_bills.html @@ -15,7 +15,7 @@ {{ member.name }} - {% if balance[member.id] > 0 %}+{% endif %}{{ balance[member.id] }} + {% if balance[member.id] > 0 %}+{% endif %}{{ "%.2f" | format(balance[member.id]) }} {% endfor %}