Initial support for Stripe (And Improve Paypal)
[hcoop/portal.git] / money.mlt
CommitLineData
208e2cbc
AC
1<% @header [("title", ["MoneyMatters"])];
2
d5f8418b
AC
3val root = Group.inGroupNum 0;
4
208e2cbc
AC
5ref showNormal = true;
6
d1d096bb
AC
7if $"hist" <> "" then
8 showNormal := false;
9 val id = Web.stoi ($"hist") %>
10<table>
11<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> </tr>
12<% foreach (amount, trn) in Money.listUserTransactions id do %>
13<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% amount %>/<% #amount trn %></td> </tr>
14<% end %>
15</table>
16
17<% elseif $"cmd" = "list" then
9bda1e7f 18 val admin = Group.inGroupName "money";
208e2cbc
AC
19 showNormal := false %>
20
b6dd1aaf 21<h3>Transactions</h3>
208e2cbc
AC
22
23<table>
24<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> <td><b>Last modified</b></td> <td><b>Participants</b></td> </tr>
25<% foreach trn in Money.listTransactions () do %>
26<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% #amount trn %></td> <td><% #stamp trn %></td>
27<% switch Money.listChargesWithNames (#id trn) of
9bda1e7f
AC
28 [(name, cha)] => %><td><a href="user?id=<% #usr cha %>"><% name %></a></td><%
29 | _ => %><td><i>multi</i></td><%
30end;
31if admin then
104fbeb6
AC
32 %><td><a href="money?modBill=<% #id trn %>">[Bill]</a> <a href="money?modPay=<% #id trn %>">[Payment]</a> <a href="money?modEven=<% #id trn %>">[Other]</a></td>
33 <td><a href="money?del=<% #id trn %>">[Delete]</a></td><%
34end
35%></tr><%
36end %>
37</table>
38
39<% elseif $"cmd" = "primary" then
40 val admin = Group.inGroupName "money";
41 showNormal := false %>
42
43<h3>Primary Transactions</h3>
44
45<table>
46<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> <td><b>Last modified</b></td> <td><b>Participants</b></td> </tr>
47<% foreach (amt, trn) in Money.listUserTransactions (valOf (Init.userNameToId "hcoop")) do %>
48<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% #amount trn %></td> <td><% #stamp trn %></td>
49<% switch Money.listChargesWithNames (#id trn) of
50 [(name, cha)] => %><td><a href="user?id=<% #usr cha %>"><% name %></a></td><%
51 | _ => %><td><i>multi</i></td><%
52end;
53if admin then
54 %><td><a href="money?modBill=<% #id trn %>">[Bill]</a> <a href="money?modPay=<% #id trn %>">[Payment]</a> <a href="money?modEven=<% #id trn %>">[Other]</a></td>
9bda1e7f 55 <td><a href="money?del=<% #id trn %>">[Delete]</a></td><%
208e2cbc 56end
9bda1e7f 57%></tr><%
208e2cbc
AC
58end %>
59</table>
60
61<% elseif $"cmd" = "bals" then
62 showNormal := false %>
63
8ffa2c9e 64<h3>Active Balances</h3>
208e2cbc
AC
65
66<table>
afc975d0 67<% foreach bal in Balance.listOwnedBalances () do %>
208e2cbc
AC
68<tr><td><% #name bal %></td> <td><% #amount bal %></td> <td>
69<% switch Balance.listBalanceUsers (#id bal) of
70 [] =>
71 | (user :: users) =>
104fbeb6 72 %><a href="money?hist=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
208e2cbc 73 foreach user in users do
d1d096bb 74 %>, <a href="money?hist=<% # id user %>"><% Web.html (#name user) %></a><%
208e2cbc
AC
75 end
76end %></td> </tr>
77<% end %>
78</table>
79
8ffa2c9e
AC
80<% elseif $"cmd" = "deadbals" then
81 showNormal := false %>
82
83<h3>Retired Balances</h3>
84
85<table>
86<% foreach bal in Balance.listUnownedBalances () do %>
87<tr><td><% #name bal %></td> <td><% #amount bal %></td> <td>
88<% switch Balance.listBalanceUsers (#id bal) of
89 [] =>
90 | (user :: users) =>
711471a2 91 %><a href="user?id=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
8ffa2c9e 92 foreach user in users do
711471a2
AC
93 %>, <a href="user?id=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
94 end
95end %></td> </tr>
96<% end %>
97</table>
98
99<% elseif $"cmd" = "nbals" then
100 showNormal := false;
101 val bals = Balance.listNegativeOwnedBalances () %>
102
103<h3>Negative Active Balances (<% length bals %>)</h3>
104
105<table>
106<% foreach bal in bals do %>
107<tr><td><% #name bal %></td> <td><% #amount bal %></td> <td>
108<% switch Balance.listBalanceUsers (#id bal) of
109 [] =>
110 | (user :: users) =>
111 %><a href="user?id=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
112 foreach user in users do
113 %>, <a href="user?id=<% #id user %>"><% Web.html (#name user) %></a> <a href="money?hist=<% #id user %>">[History]</a><%
8ffa2c9e
AC
114 end
115end %></td> </tr>
116<% end %>
117</table>
118
208e2cbc
AC
119<% elseif $"cmd" = "hosting" then
120 Group.requireGroupName "money";
121 showNormal := false %>
122
b6dd1aaf 123<h3>New hosting bill</h3>
208e2cbc 124
a4ccdb5e 125<form action="money" method="post">
208e2cbc 126<input type="hidden" name="cmd" value="hosting2">
b6dd1aaf
AC
127<table class="blanks">
128<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
129<tr> <td>Date:</td> <td><input name="d"></td> </tr>
130<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
131<tr> <td>Free bandwidth cutoff (MB):</td> <td><input name="cutoff" value="200"></td> </tr>
132<tr> <td>Cost/GB:</td> <td><input name="cost" value="4"></td> </tr>
133<tr> <td>Member usage:</td> <td><textarea wrap="soft" name="usage" rows="24" cols="80"></textarea></td> </tr>
208e2cbc
AC
134<tr> <td><input type="submit" value="Add"></td> </tr>
135</table>
136
137<% elseif $"cmd" = "hosting2" then
f49e1088
AC
138 Group.requireGroupName "money";
139 val id = Money.addTransaction ($"descr", Util.neg (Web.stor ($"amount")), $"d");
208e2cbc
AC
140 Money.addHostingCharges {trn = id, cutoff = 1000 * Web.stoi ($"cutoff"), cost = Web.stor ($"cost"), usage = $"usage"};
141
b6dd1aaf 142 %><h3>Hosting transaction added.</h3>
208e2cbc 143
f49e1088
AC
144<% elseif $"modHosting" <> "" then
145 Group.requireGroupName "money";
146 showNormal := false;
147 val id = Web.stoi ($"modHosting");
148 val trn = Money.lookupTransaction id %>
149
b6dd1aaf 150<h3>Modify hosting bill</h3>
f49e1088 151
a4ccdb5e 152<form action="money" method="post">
f49e1088 153<input type="hidden" name="saveHosting" value="<% id %>">
b6dd1aaf
AC
154<table class="blanks">
155<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
156<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
157<tr> <td>Amount:</td> <td><input name="amount" value="<% Util.neg (#amount trn) %>"></td> </tr>
158<tr> <td>Free bandwidth cutoff (MB):</td> <td><input name="cutoff" value="200"></td> </tr>
159<tr> <td>Cost/GB:</td> <td><input name="cost" value="4"></td> </tr>
160<tr> <td>Member usage:</td> <td><textarea wrap="soft" name="usage" rows="24" cols="80"><%
e84acecc
AC
161switch Money.lookupHostingUsage id of
162 SOME s => s
163end %></textarea></td> </tr>
f49e1088
AC
164<tr> <td><input type="submit" value="Save"></td> </tr>
165</table>
166
167<% elseif $"saveHosting" <> "" then
168 Group.requireGroupName "money";
169 val id = Web.stoi ($"saveHosting");
170 val trn = Money.lookupTransaction id;
171
172 Money.clearCharges id;
173 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Util.neg (Web.stor ($"amount"))};
174 Money.addHostingCharges {trn = id, cutoff = 1000 * Web.stoi ($"cutoff"), cost = Web.stor ($"cost"), usage = $"usage"};
175
b6dd1aaf 176 %><h3>Hosting transaction modified.</h3>
f49e1088 177
104fbeb6
AC
178<% elseif $"cmd" = "bill" then
179 Group.requireGroupName "money";
180 showNormal := false %>
181
182<h3>New bill for the co-op</h3>
183
184<form action="money" method="post">
185<input type="hidden" name="cmd" value="bill2">
186<table class="blanks">
187<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
188<tr> <td>Date:</td> <td><input name="d"></td> </tr>
189<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
190<tr> <td><input type="submit" value="Add"></td> </tr>
191</table>
192
193<% elseif $"cmd" = "bill2" then
194 Group.requireGroupName "money";
195 val id = Money.addTransaction ($"descr", Util.neg (Web.stor ($"amount")), $"d");
196 Money.addCharge {trn = id, usr = valOf (Init.userNameToId "hcoop"), amount = Util.neg (Web.stor ($"amount"))};
197 Money.applyCharges id;
198
199 %><h3>Bill added.</h3>
200
201<% elseif $"modBill" <> "" then
202 Group.requireGroupName "money";
203 showNormal := false;
204 val id = Web.stoi ($"modBill");
205 val trn = Money.lookupTransaction id %>
206
207<h3>Modify bill</h3>
208
209<form action="money" method="post">
210<input type="hidden" name="saveBill" value="<% id %>">
211<table class="blanks">
212<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
213<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
214<tr> <td>Amount:</td> <td><input name="amount" value="<% Util.neg (#amount trn) %>"></td> </tr>
215<tr> <td><input type="submit" value="Save"></td> </tr>
216</table>
217
218<% elseif $"saveBill" <> "" then
219 Group.requireGroupName "money";
220 val id = Web.stoi ($"saveBill");
221 val trn = Money.lookupTransaction id;
222
223 Money.clearCharges id;
224 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Util.neg (Web.stor ($"amount"))};
225 Money.addCharge {trn = id, usr = valOf (Init.userNameToId "hcoop"), amount = Util.neg (Web.stor ($"amount"))};
226 Money.applyCharges id;
227
228 %><h3>Bill modified.</h3>
229
f49e1088
AC
230<% elseif $"cmd" = "evenForm" then
231 Group.requireGroupName "money";
232 showNormal := false %>
b6dd1aaf 233<h3>New generic/even transaction</h3>
a4ccdb5e 234<form action="money" method="post">
f49e1088 235<input type="hidden" name="cmd" value="even">
b6dd1aaf
AC
236<table class="blanks">
237<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
238<tr> <td>Date:</td> <td><input name="d"></td> </tr>
239<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
240<tr> <td>Members:</td> <td><select name="usrs" size="5" multiple>
f49e1088
AC
241<% foreach usr in Init.listUsers () do %>
242 <option value="<% #id usr %>"><% #name usr %></option>
243<% end %>
244</select></td> </tr>
245<tr> <td><input type="submit" value="Add"></td> </tr>
246</table>
247</form>
248
249<% elseif $"cmd" = "pay" then
250 Group.requireGroupName "money";
d5f8418b 251 val uid = (case $"user" of "" => ~1 | s => Web.stoi s);
f49e1088
AC
252 showNormal := false %>
253
b6dd1aaf 254<h3>New member payment</h3>
f49e1088 255
a4ccdb5e 256<form action="money" method="post">
f49e1088 257<input type="hidden" name="cmd" value="pay2">
b6dd1aaf 258<table class="blanks">
dcfe5198 259<tr> <td>Description:</td> <td><select name="descr">
ba6996e3
AC
260 <option<% if $"checkout" = "" then %> selected<% end %>>PayPal</option>
261 <option<% if $"checkout" <> "" then %> selected<% end %>>Google Checkout</option>
dcfe5198
AC
262 <option>Check</option>
263 <option>Direct transfer</option>
264 <option value="">Other:</option>
265</select> <input name="descr2"></td> </tr>
d5f8418b 266<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (Date.fmt "%B %d, %Y" (Date.fromTimeLocal (Time.now ()))) %>"></td> </tr>
b6dd1aaf
AC
267<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
268<tr> <td>Member:</td> <td><select name="usr">
f49e1088 269<% foreach usr in Init.listUsers () do %>
d5f8418b 270 <option value="<% #id usr %>"<% if #id usr = uid then %> selected<% end %>><% #name usr %></option>
f49e1088
AC
271<% end %>
272</select></td> </tr>
273<tr> <td><input type="submit" value="Add"></td> </tr>
274</table>
275</form>
276
277<% elseif $"cmd" = "pay2" then
278 Group.requireGroupName "money";
279 val amount = Web.stor ($"amount");
dcfe5198
AC
280 val descr = $"descr";
281 val descr = iff descr = "" then $"descr2" else descr;
f47fcc40 282 val id = Money.addTransaction (descr, amount, $"d");
f49e1088
AC
283 Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount};
284 Money.applyCharges id;
285
b6dd1aaf 286 %><h3>Payment transaction added.</h3>
f49e1088 287
f8b39e09
CE
288<% elseif $"cmd" = "stripeApply" then
289 val stripePmt = Money.lookupStripePayment ($"stripeId");
290 val txid = Money.applyStripePayment stripePmt;
291%><h3>Stripe Payment Processed (Transaction <% txid %>)</h3>
292
f49e1088
AC
293<% elseif $"modPay" <> "" then
294 Group.requireGroupName "money";
295 showNormal := false;
296 val id = Web.stoi ($"modPay");
297 val trn = Money.lookupTransaction id %>
298
b6dd1aaf 299<h3>Modify member payment</h3>
f49e1088 300
a4ccdb5e 301<form action="money" method="post">
f49e1088 302<input type="hidden" name="savePay" value="<% id %>">
b6dd1aaf
AC
303<table class="blanks">
304<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
305<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
306<tr> <td>Amount:</td> <td><input name="amount" value="<% #amount trn %>"></td> </tr>
307<tr> <td>Member:</td> <td><select name="usr">
f49e1088
AC
308<% foreach (sel, usr) in Money.listUsers (#id trn) do %>
309 <option value="<% #id usr %>"<% if sel then %> selected<% end %>><% #name usr %></option>
310<% end %>
311</td></tr>
312<tr> <td><input type="submit" value="Save"></td> </tr>
313</table>
314
315<% elseif $"savePay" <> "" then
316 Group.requireGroupName "money";
317 val id = Web.stoi ($"savePay");
318 val trn = Money.lookupTransaction id;
319
320 val amount = Web.stor ($"amount");
321 Money.clearCharges id;
322 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = amount};
323 Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount};
324 Money.applyCharges id;
325
b6dd1aaf 326 %><h3>Member payment modified.</h3>
f49e1088 327
208e2cbc
AC
328<% elseif $"cmd" = "evenForm" then
329 Group.requireGroupName "money";
330 showNormal := false %>
b6dd1aaf 331<h3>New generic/even transaction</h3>
a4ccdb5e 332<form action="money" method="post">
208e2cbc 333<input type="hidden" name="cmd" value="even">
b6dd1aaf
AC
334<table class="blanks">
335<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
336<tr> <td>Date:</td> <td><input name="d"></td> </tr>
337<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
338<tr> <td>Members:</td> <td><select name="usrs" size="5" multiple>
208e2cbc
AC
339<% foreach usr in Init.listUsers () do %>
340 <option value="<% #id usr %>"><% #name usr %></option>
341<% end %>
342</select></td> </tr>
343<tr> <td><input type="submit" value="Add"></td> </tr>
344</table>
345</form>
346
5c705bcb
AC
347<% elseif $"cmd" = "dues" then
348 Group.requireGroupName "money";
349 showNormal := false %>
350
351<h3>Monthly dues</h3>
352
353<form action="money" method="post">
354<input type="hidden" name="cmd" value="dues2">
355<table class="blanks">
ca39ffcd 356<tr> <td>Description:</td> <td><input name="descr" value="Dues"></td> </tr>
5c705bcb
AC
357<tr> <td>Date:</td> <td><input name="d"></td> </tr>
358<tr> <td>Amount/pledge:</td> <td><input name="base"></td> </tr>
359<tr> <td><input type="submit" value="Add"></td> </tr>
360</table>
361
362<% elseif $"cmd" = "dues2" then
363 Group.requireGroupName "money";
364 Money.billDues {descr = $"descr", base = Web.stor ($"base"), date = $"d"};
365
366 %><h3>Dues debits added.</h3>
367
208e2cbc 368<% elseif $"cmd" = "even" then
f49e1088 369 Group.requireGroupName "money";
208e2cbc
AC
370 val id = Money.addTransaction ($"descr", Web.stor ($"amount"), $"d");
371 Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs"))
372
b6dd1aaf 373 %><h3>Even transaction added.</h3>
208e2cbc
AC
374
375<% elseif $"modEven" <> "" then
f49e1088 376 Group.requireGroupName "money";
208e2cbc
AC
377 showNormal := false;
378 val trn = Money.lookupTransaction (Web.stoi ($"modEven")) %>
b6dd1aaf 379<h3>Modify even transaction</h3>
208e2cbc 380
a4ccdb5e 381<form action="money" method="post">
208e2cbc 382<input type="hidden" name="saveEven" value="<% $"modEven" %>">
b6dd1aaf
AC
383<table class="blanks">
384<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
385<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
386<tr> <td>Amount:</td> <td><input name="amount" value="<% #amount trn %>"></td> </tr>
387<tr> <td>Members:</td> <td><select name="usrs" size="5" multiple>
208e2cbc
AC
388<% foreach (sel, usr) in Money.listUsers (#id trn) do %>
389 <option value="<% #id usr %>"<% if sel then %> selected<% end %>><% #name usr %></option>
390<% end %>
391</select></td> </tr>
392<tr> <td><input type="submit" value="Save"></td> </tr>
393</table>
394</form>
395
396<% elseif $"saveEven" <> "" then
f49e1088 397 Group.requireGroupName "money";
208e2cbc
AC
398 val id = Web.stoi ($"saveEven");
399 val trn = Money.lookupTransaction id;
400 Money.clearCharges id;
401 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Web.stor ($"amount")};
402 Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs"))
403
b6dd1aaf 404 %><h3>Even transaction modified</h3>
208e2cbc
AC
405
406<% elseif $"del" <> "" then
f49e1088 407 Group.requireGroupName "money";
208e2cbc
AC
408 showNormal := false;
409 val trn = Money.lookupTransaction (Web.stoi ($"del")) %>
b6dd1aaf 410 <h3>Are you sure you want to delete transaction <a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a>?</h3>
208e2cbc
AC
411 <a href="money?del2=<% $"del" %>">Yes, delete <% Web.html (#descr trn) %>!</a>
412
413<% elseif $"del2" <> "" then
f49e1088 414 Group.requireGroupName "money";
208e2cbc
AC
415 val id = Web.stoi ($"del2");
416 val trn = Money.lookupTransaction id;
417 Money.clearCharges id;
418 Money.deleteTransaction id %>
b6dd1aaf 419 <h3><% Web.html (#descr trn) %> deleted!</h3>
208e2cbc 420
2d795343
AC
421<% elseif $"cmd" = "equalize" then
422 Group.requireGroupName "money";
423 Money.equalizeBalances ();
b6dd1aaf 424 %><h3>Balances equalized</h3>
2d795343 425
208e2cbc
AC
426<% elseif $"trn" <> "" then
427 showNormal := false;
428 val id = Web.stoi ($"trn");
429 val trn = Money.lookupTransaction id %>
b6dd1aaf
AC
430<table class="blanks">
431<tr> <td>TRN#:</td> <td><% id %></td> </tr>
432<tr> <td>Description:</td> <td><% Web.html (#descr trn) %></td> </tr>
433<tr> <td>Date:</td> <td><% #d trn %></td> </tr>
434<tr> <td>Amount:</td> <td>$<% #amount trn %></td> </tr>
435<tr> <td>Distribution:</td>
af6f6078 436
208e2cbc
AC
437<% ref first = true;
438foreach (name, cha) in Money.listChargesWithNames id do
439 if first then
440 first := false
441 else
442 %><tr> <td></td> <%
443 end
444 %><td><a href="user?id=<% #usr cha %>"><% name %></a></td> <td>$<% #amount cha %></td> </tr><%
445end %>
446</table>
447
d5f8418b
AC
448<% elseif $"cmd" = "paypal" then
449 showNormal := false;
450 val apps = App.searchPaypal ($"email");
451 val users = Init.searchPaypal ($"email");
452
453 switch apps of
454 _ :: _ =>
455 %><h3>Approved applications</h3>
456
457 <% foreach appl in apps do %>
458 <br><hr><br>
459 <table class="blanks">
460 <tr> <td>Received:</td> <td><% #applied appl %></td> </tr>
461 <tr> <td>Approved by:</td> <td><%
462 ref first = true;
463 ref found = false;
464 foreach (id, name) in App.votes (#id appl) do
465 if first then
466 first := false
467 else
468 %>, <%
469 end
470 %><a href="user?id=<% id %>"><% name %></a><%
471 end %> </td> </tr>
472 <tr> <td>Username:</td> <td><% #name appl %></td> </tr>
473 <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr>
474 <tr> <td>E-mail address:</td> <td><a href="mailto:<% #email appl %>"><% #email appl %></a></td> </tr>
475 <% switch #paypal appl of
476 SOME s => %><tr> <td>PayPal:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
477 <% end;
478 switch #checkout appl of
479 SOME s => %><tr> <td>Google Checkout:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
480 <% end %>
481 <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr>
482 <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr>
483 <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr>
484 </table>
485
486 <% if root then %>
487 <a href="apps?add=<% #id appl %>">Add this member.</a><br>
488 <% end
489 end
490 end;
491
492 switch users of
493 _ :: _ =>
494 %><h3>Members</h3>
495
496 <% foreach user in users do %>
497 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>">[add payment]</a></li>
498 <% end
499 end;
500
501 switch (apps, users) of
502 (nil, nil) => %>No matches.<%
503 end
504
b1bb018a
CE
505elseif $"cmd" = "realname" then
506 showNormal := false;
507 val users = Init.searchRealName ($"rname");
508
509 switch users of
510 _ :: _ =>
511 %><h3>Members</h3>
512
513 <% foreach user in users do %>
514 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>">[add payment]</a></li>
515 <% end
516 end;
517
518 switch users of
519 nil => %>No matches.<%
520 end
521
d5f8418b
AC
522elseif $"cmd" = "checkout" then
523 showNormal := false;
524 val apps = App.searchCheckout ($"email");
525 val users = Init.searchCheckout ($"email");
526
527 switch apps of
528 _ :: _ =>
529 %><h3>Approved applications</h3>
530
531 <% foreach appl in apps do %>
532 <br><hr><br>
533 <table class="blanks">
534 <tr> <td>Received:</td> <td><% #applied appl %></td> </tr>
535 <tr> <td>Approved by:</td> <td><%
536 ref first = true;
537 ref found = false;
538 foreach (id, name) in App.votes (#id appl) do
539 if first then
540 first := false
541 else
542 %>, <%
543 end
544 %><a href="user?id=<% id %>"><% name %></a><%
545 end %> </td> </tr>
546 <tr> <td>Username:</td> <td><% #name appl %></td> </tr>
547 <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr>
548 <tr> <td>E-mail address:</td> <td><a href="mailto:<% #email appl %>"><% #email appl %></a></td> </tr>
549 <% switch #paypal appl of
550 SOME s => %><tr> <td>PayPal:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
551 <% end;
552 switch #checkout appl of
553 SOME s => %><tr> <td>Google Checkout:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
554 <% end %>
555 <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr>
556 <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr>
557 <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr>
558 </table>
559
560 <% if root then %>
561 <a href="apps?add=<% #id appl %>">Add this member.</a><br>
562 <% end
563 end
564 end;
565
566 switch users of
567 _ :: _ =>
568 %><h3>Members</h3>
569
570 <% foreach user in users do %>
571 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>&checkout=1">[add payment]</a></li>
572 <% end
573 end;
574
575 switch (apps, users) of
576 (nil, nil) => %>No matches.<%
577 end
578
1b566e48
AC
579elseif $"cmd" = "delinq" then
580 showNormal := false;
581 val dqs = Money.delinquentPledgers () %>
582<table>
583<tr> <th>Member</th> <th>Pledge</th> <th>Balance</th> </tr>
584<% foreach dq in dqs do %>
585<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td><% #shares dq %></td> <td>$<% #balance dq %></td> </tr>
586<% end %>
587</table>
588
589<a href="?lower=<% String.concatWith "," (List.map (fn dq => Int.toString (#id dq)) dqs) %>">Lower these pledges to 1</a>
590
591<% elseif $"lower" <> "" then
592 Money.resetPledges (List.map Web.stoi (String.tokens (fn ch => ch = #",") ($"lower")))
593
594 %><h3>Pledges reset.</h3><%
595
eafe3d52
AC
596elseif $"cmd" = "freezeworthy" then
597 showNormal := false;
598 val dqs = Money.freezeworthyPledgers () %>
599<table>
600<tr> <th>Member</th> <th>Balance</th> </tr>
601<% foreach dq in dqs do %>
27e65914
AC
602<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td>
603<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
eafe3d52
AC
604<% end %>
605</table>
606
607<% elseif $"cmd" = "bootworthy" then
608 showNormal := false;
609 val dqs = Money.bootworthyPledgers () %>
610<table>
611<tr> <th>Member</th> <th>Balance</th> </tr>
612<% foreach dq in dqs do %>
950a4fad
AC
613<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td>$<% #balance dq %></td>
614<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
eafe3d52
AC
615<% end %>
616</table>
617
618<% end %>
208e2cbc 619
466c5944
AC
620<% if showNormal then
621 val you = Init.getUser();
622 val bal = Balance.lookupBalance (#bal you);
b5dc79ca
AC
623 val deposit = Balance.depositAmount (#id bal);
624 val showBal = Util.sub (#amount bal, deposit) %>
208e2cbc 625
b5dc79ca 626<h3>Your balance: $<% showBal %><br>
104fbeb6
AC
627Deposit: $<% deposit %></b> (3 months of dues at the minimal <a href="pledge">pledge level</a>)<br>
628Co-op balance: $<% #amount (Balance.lookupBalance (valOf (Balance.balanceNameToId "hcoop"))) %></h3>
96bd398e 629
c8abf2d9 630<!--h3>Your balance: $<% #amount bal %></h3-->
96bd398e 631
96662fd8 632<% if (iff Group.inGroupName "money" then $"lookback" = "" else $"audit" <> "") then %><h3>Sum of all active balances: $<% Balance.sumOwnedBalances () %></h3><% end %>
ee5c7008 633
208e2cbc 634<a href="money?cmd=list">List all transactions</a><br>
104fbeb6 635<a href="money?cmd=primary">List primary transactions</a><br>
8ffa2c9e 636<a href="money?cmd=bals">List active balances</a><br>
711471a2 637<a href="money?cmd=nbals">List negative active balances</a><br>
eafe3d52
AC
638<a href="money?cmd=freezeworthy">List members who deserve account freezing</a><br>
639<a href="money?cmd=bootworthy">List members who deserve to be kicked out</a><br>
8ffa2c9e 640<a href="money?cmd=deadbals">List retired balances</a><br>
208e2cbc 641
96662fd8 642<% if (Group.inGroupName "money" and $"lookback" = "") or $"audit" <> "" then %>
cf10853e 643
1b566e48 644<a href="?cmd=delinq">Drop pledges of delinquent members</a><br>
cf10853e 645<a href="?lookback=20">Switch to regular member view</a><br>
208e2cbc
AC
646
647<br><b><u>New transaction:</u></b><br>
104fbeb6 648<a href="money?cmd=bill">Bill for the co-op</a><br>
f49e1088 649<a href="money?cmd=pay">Payment from member</a><br>
5c705bcb
AC
650<a href="money?cmd=dues">Monthly dues</a><br>
651<a href="money?cmd=hosting">New hosting bill (old style)</a><br>
208e2cbc 652<a href="money?cmd=evenForm">Generic/even</a><br>
2d795343
AC
653<br>
654<a href="money?cmd=equalize">Equalize balances</a><br>
d5f8418b
AC
655<br>
656
657<h3>Look up a PayPal e-mail address</h3>
658
659<form method="post">
660<input type="hidden" name="cmd" value="paypal">
661<input name="email"> <input type="submit" value="Look up">
662</form>
663
b1bb018a
CE
664<h3>Look up a Real Name</h3>
665
666<form method="post">
667<input type="hidden" name="cmd" value="realname">
668<input name="rname"> <input type="submit" value="Look up">
d5f8418b 669</form>
208e2cbc 670
f8b39e09
CE
671<h3>Apply Stripe Payments</h3>
672
673<table>
674<tr><td><strong>Date</strong></td><td><strong>Member</strong></td>
675 <td><strong>Name on Card</strong></td>
676 <td><strong>Amount</strong> (After Fees)</td><td><td></td>
677</tr>
678<% foreach stripePmt in Money.listAllPendingStripePayments () do %>
679
680<tr>
681 <td><% #name (Init.lookupUser (#webuser_id stripePmt)) %></td>
682 <td><% #paid_on stripePmt %></td>
683 <td><% #card_name stripePmt %>
684 <td>$<% #net stripePmt %></td>
685 <td><form method="post">
686 <input type="hidden" name="cmd" value="stripeApply" />
687 <input type="hidden" name="stripeId" value="<% #charge_id stripePmt %>" />
688 <input type="submit" value="Apply to Balance" /> <!-- also, refund? -->
689 </form>
690 </td>
691</tr>
692<% end %>
693</table>
694
b6dd1aaf 695<h3>Most recent transactions</h3>
208e2cbc 696
f8b39e09
CE
697
698
208e2cbc
AC
699<table>
700<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Amount</b></td> <td><b>Participants</b></td> <td><b>Replace</b></td> <td><b>Delete</b></td> </tr>
701<% foreach trn in Money.listTransactionsLimit 20 do %>
702<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td><% #amount trn %></td>
703<% switch Money.listChargesWithNames (#id trn) of
704 [(name, cha)] => %><td><a href="user?id=<% #usr cha %>"><% name %></a></td><%
705 | _ => %><td><i>multi</i></td><%
706end %>
104fbeb6 707<td><a href="money?modBill=<% #id trn %>">[Bill]</a> <a href="money?modPay=<% #id trn %>">[Payment]</a> <a href="money?modEven=<% #id trn %>">[Other]</a></td>
f49e1088 708<td><a href="money?del=<% #id trn %>">[Delete]</a></td> </tr>
208e2cbc
AC
709<% end %>
710</table>
711
96662fd8
AC
712<% else %>
713<a href="?audit=1">Switch to audit view</a><br>
60465e67 714<% val lookback = case $"lookback" of "" => 20 | "inf" => 0 | lb => Web.stoi lb;
cf10853e 715 @payment [] %>
b251872c 716
b6dd1aaf 717<h3>Your recent account activity</h3>
208e2cbc 718
cf10853e 719<form>
60465e67 720 Show <input name="lookback" size="5" value="<% iff lookback = 0 then 20 else lookback %>"> most recent transactions.
cf10853e
AC
721 <input type="submit" value="Show">
722</form>
723
60465e67
AC
724<% ref running = showBal;
725val trans = iff lookback = 0 then
726 Money.listUserTransactions (Init.getUserId ())
727 else
728 Money.listUserTransactionsLimit (Init.getUserId (), lookback) %>
208e2cbc 729<table>
60465e67
AC
730<tr> <td><b>Date</b></td> <td><b>Description</b></td> <td><b>Debit</b></td> <td><b>Credit</b></td> <td><b>Balance</b></td></tr>
731<% foreach (amount, trn) in trans do %>
732<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td>
733<td align="right"><% if Util.lt (amount, 0.0) then %><% amount %><% end %></td>
734<td align="right"><% if Util.ge (amount, 0.0) then %><% amount %><% end %></td>
b5dc79ca
AC
735<td><% running %></tr>
736<% running := Util.sub (running, amount)
737end %>
208e2cbc 738</table>
60465e67
AC
739<% if lookback <> 0 then %>
740<a href="?lookback=inf">Show all transactions</a><br>
741<% end %>
208e2cbc
AC
742
743<% end
744end %>
745
746<% @footer [] %>