Show running balances on transaction summaries
authorAdam Chlipala <adamc@hcoop.net>
Tue, 15 Jul 2008 16:19:04 +0000 (16:19 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Tue, 15 Jul 2008 16:19:04 +0000 (16:19 +0000)
money.mlt
portal.mlt

index 90f87b3..5977d09 100644 (file)
--- a/money.mlt
+++ b/money.mlt
@@ -598,9 +598,10 @@ elseif $"cmd" = "freezeworthy" then
 <% if showNormal then
    val you = Init.getUser();
    val bal = Balance.lookupBalance (#bal you);
-   val deposit = Balance.depositAmount (#id bal) %>
+   val deposit = Balance.depositAmount (#id bal);
+   val showBal = Util.sub (#amount bal, deposit) %>
 
-<h3>Your balance: $<% Util.sub (#amount bal, deposit) %><br>
+<h3>Your balance: $<% showBal %><br>
 Deposit: $<% deposit %></b> (3 months of dues at the minimal <a href="pledge">pledge level</a>)<br>
 Co-op balance: $<% #amount (Balance.lookupBalance (valOf (Balance.balanceNameToId "hcoop"))) %></h3>
 
@@ -672,11 +673,14 @@ end %>
       <input type="submit" value="Show">
 </form>
 
+<% ref running = showBal %>
 <table>
-<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> </tr>
+<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> <td><b>Balance</b></td></tr>
 <% foreach (amount, trn) in Money.listUserTransactionsLimit (Init.getUserId (), lookback) do %>
-<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% amount %>/<% #amount trn %></td> </tr>
-<% end %>
+<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% amount %>/<% #amount trn %></td>
+<td><% running %></tr>
+<% running := Util.sub (running, amount)
+end %>
 </table>
 
 <% end
index 7fb59ee..a673d77 100644 (file)
@@ -1,19 +1,23 @@
 <% val you = Init.getUser();
 val bal = Balance.lookupBalance (#bal you);
 val deposit = Balance.depositAmount (#id bal);
+val showBal = Util.sub (#amount bal, deposit);
 @header [] %>
 
 <% @payment [] %>
 
 <h3><a href="money">Your recent account activity</a></h3>
 
+<% ref running = showBal %>
 <table>
-<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> </tr>
+<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> <td><b>Balance</b></td></tr>
 <% foreach (amount, trn) in Money.listUserTransactionsLimit (Init.getUserId (), 5) do %>
-<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% amount %>/<% #amount trn %></td> </tr>
-<% end %>
+<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% amount %>/<% #amount trn %></td>
+<td><% running %></tr>
+<% running := Util.sub (running, amount)
+end %>
 </table>
-<b>Balance: $<% Util.sub (#amount bal, deposit) %></b><br>
+<b>Balance: $<% showBal %></b><br>
 <b>Deposit: $<% deposit %></b> (3 months of dues at the minimal <a href="pledge">pledge level</a>)
 
 <!--b>Balance: $<% #amount bal %></b-->