]> asedeno.scripts.mit.edu Git - bluechips.git/commitdiff
added net owed/due row to settling transfers table
authorScott Torborg <scott@crookedmedia.com>
Wed, 6 Jan 2010 05:19:29 +0000 (21:19 -0800)
committerScott Torborg <scott@crookedmedia.com>
Wed, 6 Jan 2010 05:19:29 +0000 (21:19 -0800)
bluechips/controllers/status.py
bluechips/templates/status/index.mako

index 7e81cd505854151136b98797c4659689d6ca413f..df0522e4a359ed8951a67dc4857afdad665767f1 100644 (file)
@@ -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)
index bf4eb7b6b84c1556efd5a94c82d72d0942bf63d9..0d94dce0d95927742cfc6b16662677b7c72eadab 100644 (file)
           <td>${transfer[2]}</td>
         </tr>
       % endfor
+      % if c.net != 0:
+        <tr>
+          <th colspan="2">
+            % if c.net > 0:
+              The group owes you:
+            % elif c.net < 0:
+              You owe the group:
+            % endif
+          </th>
+          <th>${abs(c.net)}</th>
+        </tr>
+      % endif
     </table>
   % endif
 </div>