From: Scott Torborg Date: Fri, 6 Nov 2009 03:23:00 +0000 (-1000) Subject: fix error with zero-value expenditure X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=1de7ebf118cbe861456c45147497cdd55ed1d951;hp=c0ae50143ea14aec0b6db338674f2c1c29a86a3b;p=bluechips.git fix error with zero-value expenditure --- diff --git a/bluechips/controllers/spend.py b/bluechips/controllers/spend.py index c99d325..0bd830c 100644 --- a/bluechips/controllers/spend.py +++ b/bluechips/controllers/spend.py @@ -73,9 +73,12 @@ class SpendController(BaseController): try: share = [s.share for s in c.expenditure.splits if s.user == user][0] - percent = (Decimal(100) * Decimal(int(share)) / - Decimal(int(c.expenditure.amount))).\ - quantize(Decimal("0.001")) + if c.expenditure.amount == 0: + percent = 0 + else: + percent = (Decimal(100) * Decimal(int(share)) / + Decimal(int(c.expenditure.amount))).\ + quantize(Decimal("0.001")) except IndexError: percent = 0 c.values['shares-%d.amount' % ii] = percent