From: Scott Torborg Date: Wed, 6 Jan 2010 05:19:29 +0000 (-0800) Subject: added net owed/due row to settling transfers table X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=378790bb6dfd727bb25bb27dde22c484fc957267;hp=711c0937fcfe86e310008a7332069d2efdada68a;p=bluechips.git added net owed/due row to settling transfers table --- diff --git a/bluechips/controllers/status.py b/bluechips/controllers/status.py index 7e81cd5..df0522e 100644 --- a/bluechips/controllers/status.py +++ b/bluechips/controllers/status.py @@ -22,6 +22,13 @@ class StatusController(BaseController): def index(self): c.debts = debts() c.settle = settle(c.debts) + + c.net = 0 + for from_user, to_user, amount in c.settle: + if from_user == request.environ['user']: + c.net -= amount + elif to_user == request.environ['user']: + c.net += amount periods = {} periods['Total'] = (None, None) diff --git a/bluechips/templates/status/index.mako b/bluechips/templates/status/index.mako index bf4eb7b..0d94dce 100644 --- a/bluechips/templates/status/index.mako +++ b/bluechips/templates/status/index.mako @@ -21,6 +21,18 @@ ${transfer[2]} % endfor + % if c.net != 0: + + + % if c.net > 0: + The group owes you: + % elif c.net < 0: + You owe the group: + % endif + + ${abs(c.net)} + + % endif % endif