signature BALANCE =
sig
- type balance = {id :int, name : string, amount : real}
+ type balance = {id : int, name : string, amount : real}
val addBalance : string -> int
val lookupBalance : int -> balance
val sumOwnedBalances : unit -> real
val isNegative : balance -> bool
+
+ val depositAmount : int -> real
end
fun isNegative (bal : balance) = #amount bal < 0.0
+fun depositAmount bal =
+ let
+ val db = getDb ()
+
+ val totalShares = case C.oneRow db "SELECT SUM(shares) FROM WebUserPaying" of
+ [n] => C.intFromSql n
+ | row => Init.rowError ("Bad depositAmount share count result", row)
+ in
+ case C.oneRow db ($`SELECT 3.0 * 900.0 * SUM(shares) / ^(C.intToSql totalShares)
+ FROM WebUserPaying
+ WHERE bal = ^(C.intToSql bal)`) of
+ [amount] => C.realFromSql amount
+ | row => Init.rowError ("Bad depositAmount result", row)
+ end
+
end
fun byPledge () =
C.map (getDb ()) mkUserRow ($`SELECT id, name, rname, bal, joined, app, shares, paypal, checkout
- FROM WebUser
+ FROM WebUserPaying
WHERE shares > 1
ORDER BY shares DESC, name`)
end %>
-<% if showNormal then %>
+<% if showNormal then
+ val you = Init.getUser();
+ val bal = Balance.lookupBalance (#bal you);
+ val deposit = Balance.depositAmount (#id bal) %>
-<h3>Your balance: $<% #amount (Balance.lookupBalance (#bal (Init.getUser ()))) %></h3>
+<h3>Your balance: $<% Util.sub (#amount bal, deposit) %><br>
+Deposit: $<% deposit %></b> (3 months of dues at your current <a href="pledge">pledge level</a>)</h3>
<% if (iff Group.inGroupName "money" then $"lookback" = "" else $"audit" <> "") then %><h3>Sum of all active balances: $<% Balance.sumOwnedBalances () %></h3><% end %>
<a href="money?cmd=list">List all transactions</a><br>
<% val you = Init.getUser();
val bal = Balance.lookupBalance (#bal you);
+val deposit = Balance.depositAmount (#id bal);
@header [] %>
<% @payment [] %>
<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% amount %>/<% #amount trn %></td> </tr>
<% end %>
</table>
-<b>Balance: $<% #amount bal %></b>
+<b>Balance: $<% Util.sub (#amount bal, deposit) %></b><br>
+<b>Deposit: $<% deposit %></b> (3 months of dues at your current <a href="pledge">pledge level</a>)
<% val polls = Poll.listCurrentPolls ();
switch polls of
val makeSet : ('a -> string) -> 'a list -> string
val neg : real -> real
val add : real * real -> real
+ val sub : real * real -> real
val mult : int * real -> real
val validHost : string -> bool
fun neg (r : real) = ~r
fun add (r1 : real, r2) = r1 + r2
+fun sub (r1 : real, r2) = r1 - r2
fun mult (r1, r2) = real r1 * r2
fun isIdent ch = Char.isLower ch orelse Char.isDigit ch orelse ch = #"-"