+val monthlyCost = 900.0
+val graceMonths = 1
+
+fun delinquentPledgers () =
+ let
+ val costBase = costBase monthlyCost
+
+ fun makeRow [id, name, shares, amount] = {id = C.intFromSql id, name = C.stringFromSql name,
+ shares = C.intFromSql shares, balance = C.realFromSql amount}
+ | makeRow row = Init.rowError ("Bad delinquentPledgers", row)
+ in
+ C.map (getDb ()) makeRow ($`SELECT WebUserPaying.id, WebUserPaying.name, shares, amount
+ FROM WebUserPaying JOIN Balance ON Balance.id = bal
+ WHERE amount < shares * ^(C.realToSql costBase) * ^(C.intToSql graceMonths)
+ AND shares > 1
+ ORDER BY name`)
+ end
+
+fun resetPledges ids =
+ raise Fail ($`UPDATE WebUser SET shares = 1 WHERE id IN (^(String.concatWith ", " (List.map C.intToSql ids)))`)
+