Annotate freezeworthy list with whether members joined this month
authorAdam Chlipala <adamc@hcoop.net>
Thu, 22 May 2008 13:31:42 +0000 (13:31 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Thu, 22 May 2008 13:31:42 +0000 (13:31 +0000)
money.mlt
money.sig
money.sml

index 7026421..8ca3486 100644 (file)
--- a/money.mlt
+++ b/money.mlt
@@ -577,7 +577,8 @@ elseif $"cmd" = "freezeworthy" then
 <table>
 <tr> <th>Member</th> <th>Balance</th> </tr>
 <% foreach dq in dqs do %>
-<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td> </tr>
+<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td>
+<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
 <% end %>
 </table>
 
index d54ba3f..511d50c 100644 (file)
--- a/money.sig
+++ b/money.sig
@@ -37,7 +37,7 @@ sig
     val delinquentPledgers : unit -> { id : int, name : string, shares : int, balance : real } list
     val resetPledges : int list -> unit
 
-    val freezeworthyPledgers : unit -> { id : int, name : string, balance : real } list
+    val freezeworthyPledgers : unit -> { id : int, name : string, balance : real, joinedThisMonth : bool } list
     val bootworthyPledgers : unit -> { id : int, name : string, balance : real } list
 
     val billDues : {descr : string, base : real, date : string} -> unit
index 1ce5774..6701459 100644 (file)
--- a/money.sml
+++ b/money.sml
@@ -298,11 +298,11 @@ fun freezeworthyPledgers () =
     let
        val baseDues = 5.0
 
-       fun makeRow [id, name, amount] = {id = C.intFromSql id, name = C.stringFromSql name,
-                                         balance = C.realFromSql amount}
+       fun makeRow [id, name, amount, j] = {id = C.intFromSql id, name = C.stringFromSql name,
+                                            balance = C.realFromSql amount, joinedThisMonth = C.boolFromSql j}
          | makeRow row = Init.rowError ("Bad freezeworthyPledgers", row)
     in
-       C.map (getDb ()) makeRow ($`SELECT WebUserPaying.id, WebUserPaying.name, amount
+       C.map (getDb ()) makeRow ($`SELECT WebUserPaying.id, WebUserPaying.name, amount, CURRENT_TIMESTAMP - joined < INTERVAL '1 month'
                                    FROM WebUserPaying JOIN Balance ON Balance.id = bal
                                    WHERE amount >= ^(C.realToSql baseDues) * ^(C.intToSql graceMonths)
                                      AND amount < ^(C.realToSql baseDues) * ^(C.intToSql (graceMonths + 1))