Links to list all transactions; debit/credit columns
authorAdam Chlipala <adamc@hcoop.net>
Tue, 15 Jul 2008 16:32:51 +0000 (16:32 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Tue, 15 Jul 2008 16:32:51 +0000 (16:32 +0000)
money.mlt
portal.mlt
util.sig
util.sml

index 5977d09..dbad9a9 100644 (file)
--- a/money.mlt
+++ b/money.mlt
@@ -663,25 +663,34 @@ end %>
 
 <% else %>
 <a href="?audit=1">Switch to audit view</a><br>
-<% val lookback = case $"lookback" of "" => 20 | lb => Web.stoi lb;
+<% val lookback = case $"lookback" of "" => 20 | "inf" => 0 | lb => Web.stoi lb;
    @payment [] %>
 
 <h3>Your recent account activity</h3>
 
 <form>
-      Show <input name="lookback" size="5" value="<% lookback %>"> most recent transactions.
+      Show <input name="lookback" size="5" value="<% iff lookback = 0 then 20 else lookback %>"> most recent transactions.
       <input type="submit" value="Show">
 </form>
 
-<% ref running = showBal %>
+<% ref running = showBal;
+val trans = iff lookback = 0 then
+        Money.listUserTransactions (Init.getUserId ())
+    else
+       Money.listUserTransactionsLimit (Init.getUserId (), lookback) %>
 <table>
-<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> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Debit</b></td> <td><b>Credit</b></td> <td><b>Balance</b></td></tr>
+<% foreach (amount, trn) in trans do %>
+<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td>
+<td align="right"><% if Util.lt (amount, 0.0) then %><% amount %><% end %></td>
+<td align="right"><% if Util.ge (amount, 0.0) then %><% amount %><% end %></td>
 <td><% running %></tr>
 <% running := Util.sub (running, amount)
 end %>
 </table>
+<% if lookback <> 0 then %>
+<a href="?lookback=inf">Show all transactions</a><br>
+<% end %>
 
 <% end
 end %>
index a673d77..e9d82fe 100644 (file)
@@ -17,6 +17,7 @@ val showBal = Util.sub (#amount bal, deposit);
 <% running := Util.sub (running, amount)
 end %>
 </table>
+<a href="money?lookback=inf">Show all transactions</a><br>
 <b>Balance: $<% showBal %></b><br>
 <b>Deposit: $<% deposit %></b> (3 months of dues at the minimal <a href="pledge">pledge level</a>)
 
index d6f9d5c..f8c38d4 100644 (file)
--- a/util.sig
+++ b/util.sig
@@ -18,6 +18,9 @@ sig
     val sub : real * real -> real
     val mult : int * real -> real
 
+    val lt : real * real -> bool
+    val ge : real * real -> bool
+
     val validHost : string -> bool
     val validDomain : string -> bool
     val validEmail : string -> bool
index 07793bb..9c269c1 100644 (file)
--- a/util.sml
+++ b/util.sml
@@ -32,6 +32,9 @@ fun add (r1 : real, r2) = r1 + r2
 fun sub (r1 : real, r2) = r1 - r2
 fun mult (r1, r2) = real r1 * r2
 
+fun lt (r1 : real, r2) = r1 < r2
+fun ge (r1 : real, r2) = r1 >= r2
+
 fun isIdent ch = Char.isLower ch orelse Char.isDigit ch orelse ch = #"-"
 
 fun validHost s =