From d55b9961704f913312ae17f837f62d1822802ecf Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Thu, 3 Jan 2019 13:29:56 +0100 Subject: Do not allow negative weights on users (Fixes #362) (#366) --- ihatemoney/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ihatemoney/models.py') diff --git a/ihatemoney/models.py b/ihatemoney/models.py index 3c36e76..b9cff4f 100644 --- a/ihatemoney/models.py +++ b/ihatemoney/models.py @@ -376,8 +376,9 @@ class Bill(db.Model): def pay_each(self): """Compute what each share has to pay""" if self.owers: - # FIXME: SQL might dot that more efficiently - return self.amount / sum(i.weight for i in self.owers) + # FIXME: SQL might do that more efficiently + weights = sum(i.weight for i in self.owers) + return self.amount / weights else: return 0 -- cgit v1.1