In unmigrated members view, list balances and count number that are negative
authoradamch <adamch>
Wed, 24 Oct 2007 11:48:39 +0000 (11:48 +0000)
committeradamch <adamch>
Wed, 24 Oct 2007 11:48:39 +0000 (11:48 +0000)
balance.sig
balance.sml
users.mlt

index e7f9bf5..2ce2b47 100644 (file)
@@ -16,4 +16,5 @@ sig
     val balanceNameToId : string -> int option
 
     val sumOwnedBalances : unit -> real
+    val isNegative : balance -> bool
 end
index 5b0c684..1d639da 100644 (file)
@@ -103,4 +103,6 @@ fun sumOwnedBalances () =
        [amt] => C.realFromSql amt
       | _ => raise Fail "sumOwnedBalance: no rows"
 
+fun isNegative (bal : balance) = #amount bal < 0.0
+
 end
index 3fdf91b..a4a8cb3 100644 (file)
--- a/users.mlt
+++ b/users.mlt
@@ -102,21 +102,28 @@ elseif $"mod" <> "" then
 
 <% elseif $"cmd" = "unmigrated" then
    showNormal := false;
+   ref negative = 0;
    val users = Init.unmigratedUsers () %>
 
 <h3>Unmigrated members (<% length users %>)</h3>
 
 <table>
 <% foreach user in users do %>
-       <tr> <td><a href="user?id=<% #id user %>"><% Web.html (#name user) %></a></td> <td>
+       <tr> <td><a href="user?id=<% #id user %>"><% Web.html (#name user) %></a></td>
 <% val bal = Balance.lookupBalance (#bal user);
-if #name bal <> #name user then %>
-<i><% Web.html (#name bal) %></i>
+if Balance.isNegative bal then
+   negative := negative + 1
+end %>
+<td><% #amount bal %></td><td>
+<%if #name bal <> #name user then %>
+ <i><% Web.html (#name bal) %></i>
 <% end %>
-       </td> </tr>
+</td> </tr>
 <% end %>
 </table>
 
+<p><% negative %> have negative balances.</p>
+
 <% end %>
 
 <% if showNormal then %>