From 378790bb6dfd727bb25bb27dde22c484fc957267 Mon Sep 17 00:00:00 2001 From: Scott Torborg Date: Tue, 5 Jan 2010 21:19:29 -0800 Subject: [PATCH 1/1] added net owed/due row to settling transfers table --- bluechips/controllers/status.py | 7 +++++++ bluechips/templates/status/index.mako | 12 ++++++++++++ 2 files changed, 19 insertions(+) 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 -- 2.45.2