diff options
| author | Alexis Metaireau <alexis@notmyidea.org> | 2019-01-03 13:29:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-03 13:29:56 +0100 |
| commit | d55b9961704f913312ae17f837f62d1822802ecf (patch) | |
| tree | 02bc27f0b6ffdaf15a08b651d2953f35356c0148 /ihatemoney/models.py | |
| parent | 04adfe4155e1bb37609edfe78ae67b361f51e0cf (diff) | |
| download | ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.zip ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.tar.gz ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.tar.bz2 | |
Do not allow negative weights on users (Fixes #362) (#366)
Diffstat (limited to 'ihatemoney/models.py')
| -rw-r--r-- | ihatemoney/models.py | 5 |
1 files changed, 3 insertions, 2 deletions
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 |
