Fix low balance reminder script cut-off bug
authorAdam Chlipala <adamc@hcoop.net>
Sat, 10 May 2008 23:19:24 +0000 (23:19 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Sat, 10 May 2008 23:19:24 +0000 (23:19 +0000)
remind/remind.sml

index 61470ca..c7e3f77 100644 (file)
@@ -11,6 +11,8 @@ fun printReal n =
     else
        Real.fmt (StringCvt.FIX (SOME 2)) n
 
+val basePerMonth = 5.0
+
 fun main _ =
     let
        val db = C.conn dbstring
@@ -26,8 +28,8 @@ fun main _ =
                val shares = C.intFromSql shares
                val amount = C.realFromSql amount
 
-               val perMonth = 900.0 * real shares / real totalShares
-               val deposit = 900.0 / real totalShares * 3.0
+               val perMonth = basePerMonth * real shares
+               val deposit = perMonth * 3.0
                val headsUp = deposit + perMonth * 2.0
            in
                if amount >= headsUp then
@@ -75,9 +77,7 @@ fun main _ =
                        write "\nMinimum amount to pay to not see this message again for two months: US$";
                        write (printReal (headsUp - amount));
 
-                       write "\n\nYour deposit requirement was calculated by dividing our total monthly expenses\n";
-                       write "($900) by the sum of all members' pledge amounts and then multiplying by 3.  That\n";
-                       write "is, the amount covers a minimal share of three months' expenses.\n\n";
+                       write "\n\nThe deposit requirement was calculated as three months of dues at $5/mo..\n\n";
 
                        write "To make a payment, visit:\n";
                        write "     https://members.hcoop.net/\n";
@@ -91,7 +91,7 @@ fun main _ =
            end
          | doOne _ = raise Fail "Bad SQL row"
     in
-       C.app db doOne "SELECT Balance.name, COUNT(*), SUM(WebUserPaying.shares) AS shrs, Balance.amount FROM WebUserPaying JOIN Balance ON WebUserPaying.bal = Balance.id GROUP BY Balance.name, Balance.amount HAVING amount < 10";
+       C.app db doOne ("SELECT Balance.name, COUNT(*), SUM(WebUserPaying.shares) AS shrs, Balance.amount FROM WebUserPaying JOIN Balance ON WebUserPaying.bal = Balance.id GROUP BY Balance.name, Balance.amount HAVING amount < " ^ C.realToSql (basePerMonth * 5.0) ^ " * SUM(WebUserPaying.shares)");
        C.close db;
        OS.Process.success
     end handle C.Sql s => (print ("SQL failure: " ^ s ^ "\n");