payment: note that Stripe has instituted an additional 1% fee for non-US cards
[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") %>
64264243 10<table class="data">
d1d096bb
AC
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 22
64264243 23<table class="data">
208e2cbc
AC
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
64264243 45<table class="data">
104fbeb6
AC
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 %>
64264243 48<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td style="text-align: right"><% #amount trn %></td> <td><% #stamp trn %></td>
104fbeb6
AC
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 65
92855ded 66<table class="data">
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
92855ded 85<table class="data">
8ffa2c9e
AC
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
92855ded 105<table class="data">
711471a2
AC
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 260 <option<% if $"checkout" = "" then %> selected<% end %>>PayPal</option>
dcfe5198
AC
261 <option>Check</option>
262 <option>Direct transfer</option>
263 <option value="">Other:</option>
264</select> <input name="descr2"></td> </tr>
d5f8418b 265<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (Date.fmt "%B %d, %Y" (Date.fromTimeLocal (Time.now ()))) %>"></td> </tr>
b6dd1aaf
AC
266<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
267<tr> <td>Member:</td> <td><select name="usr">
f49e1088 268<% foreach usr in Init.listUsers () do %>
d5f8418b 269 <option value="<% #id usr %>"<% if #id usr = uid then %> selected<% end %>><% #name usr %></option>
f49e1088
AC
270<% end %>
271</select></td> </tr>
272<tr> <td><input type="submit" value="Add"></td> </tr>
273</table>
274</form>
275
276<% elseif $"cmd" = "pay2" then
277 Group.requireGroupName "money";
278 val amount = Web.stor ($"amount");
dcfe5198
AC
279 val descr = $"descr";
280 val descr = iff descr = "" then $"descr2" else descr;
f47fcc40 281 val id = Money.addTransaction (descr, amount, $"d");
f49e1088
AC
282 Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount};
283 Money.applyCharges id;
284
b6dd1aaf 285 %><h3>Payment transaction added.</h3>
f49e1088 286
f8b39e09
CE
287<% elseif $"cmd" = "stripeApply" then
288 val stripePmt = Money.lookupStripePayment ($"stripeId");
289 val txid = Money.applyStripePayment stripePmt;
290%><h3>Stripe Payment Processed (Transaction <% txid %>)</h3>
291
bd5d2441
CE
292<% elseif $"cmd" = "stripeRejected" then
293%><h3>Stripe Payment Rejected!</h3>
294
295<% elseif $"cmd" = "stripeReject" then
296 Group.requireGroupName "money";
297 showNormal := false;
298%>
299<h3>Are you sure you want to reject Stripe Payment <% $"stripeChargeId" %>?</h3>
e4964ef9 300<form method="post" action="/stripe/stripe-admin.cgi">
bd5d2441
CE
301 <input type="hidden" name="cmd" value="reject_member_payment" />
302 <input type="hidden" name="stripeChargeId" value="<% $"stripeChargeId" %>" />
303 <label>Reason for rejection <input type="text" name="reason" /></label>
304 <input type="submit" value="Really Reject Payment" />
305 </form>
306
f49e1088
AC
307<% elseif $"modPay" <> "" then
308 Group.requireGroupName "money";
309 showNormal := false;
310 val id = Web.stoi ($"modPay");
311 val trn = Money.lookupTransaction id %>
312
b6dd1aaf 313<h3>Modify member payment</h3>
f49e1088 314
a4ccdb5e 315<form action="money" method="post">
f49e1088 316<input type="hidden" name="savePay" value="<% id %>">
b6dd1aaf
AC
317<table class="blanks">
318<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
319<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
320<tr> <td>Amount:</td> <td><input name="amount" value="<% #amount trn %>"></td> </tr>
321<tr> <td>Member:</td> <td><select name="usr">
f49e1088
AC
322<% foreach (sel, usr) in Money.listUsers (#id trn) do %>
323 <option value="<% #id usr %>"<% if sel then %> selected<% end %>><% #name usr %></option>
324<% end %>
325</td></tr>
326<tr> <td><input type="submit" value="Save"></td> </tr>
327</table>
328
329<% elseif $"savePay" <> "" then
330 Group.requireGroupName "money";
331 val id = Web.stoi ($"savePay");
332 val trn = Money.lookupTransaction id;
333
334 val amount = Web.stor ($"amount");
335 Money.clearCharges id;
336 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = amount};
337 Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount};
338 Money.applyCharges id;
339
b6dd1aaf 340 %><h3>Member payment modified.</h3>
f49e1088 341
208e2cbc
AC
342<% elseif $"cmd" = "evenForm" then
343 Group.requireGroupName "money";
344 showNormal := false %>
b6dd1aaf 345<h3>New generic/even transaction</h3>
a4ccdb5e 346<form action="money" method="post">
208e2cbc 347<input type="hidden" name="cmd" value="even">
b6dd1aaf
AC
348<table class="blanks">
349<tr> <td>Description:</td> <td><input name="descr"></td> </tr>
350<tr> <td>Date:</td> <td><input name="d"></td> </tr>
351<tr> <td>Amount:</td> <td><input name="amount"></td> </tr>
352<tr> <td>Members:</td> <td><select name="usrs" size="5" multiple>
208e2cbc
AC
353<% foreach usr in Init.listUsers () do %>
354 <option value="<% #id usr %>"><% #name usr %></option>
355<% end %>
356</select></td> </tr>
357<tr> <td><input type="submit" value="Add"></td> </tr>
358</table>
359</form>
360
5c705bcb
AC
361<% elseif $"cmd" = "dues" then
362 Group.requireGroupName "money";
363 showNormal := false %>
364
365<h3>Monthly dues</h3>
366
367<form action="money" method="post">
368<input type="hidden" name="cmd" value="dues2">
369<table class="blanks">
ca39ffcd 370<tr> <td>Description:</td> <td><input name="descr" value="Dues"></td> </tr>
5c705bcb
AC
371<tr> <td>Date:</td> <td><input name="d"></td> </tr>
372<tr> <td>Amount/pledge:</td> <td><input name="base"></td> </tr>
373<tr> <td><input type="submit" value="Add"></td> </tr>
374</table>
375
376<% elseif $"cmd" = "dues2" then
377 Group.requireGroupName "money";
378 Money.billDues {descr = $"descr", base = Web.stor ($"base"), date = $"d"};
379
380 %><h3>Dues debits added.</h3>
381
208e2cbc 382<% elseif $"cmd" = "even" then
f49e1088 383 Group.requireGroupName "money";
208e2cbc
AC
384 val id = Money.addTransaction ($"descr", Web.stor ($"amount"), $"d");
385 Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs"))
386
b6dd1aaf 387 %><h3>Even transaction added.</h3>
208e2cbc
AC
388
389<% elseif $"modEven" <> "" then
f49e1088 390 Group.requireGroupName "money";
208e2cbc
AC
391 showNormal := false;
392 val trn = Money.lookupTransaction (Web.stoi ($"modEven")) %>
b6dd1aaf 393<h3>Modify even transaction</h3>
208e2cbc 394
a4ccdb5e 395<form action="money" method="post">
208e2cbc 396<input type="hidden" name="saveEven" value="<% $"modEven" %>">
b6dd1aaf
AC
397<table class="blanks">
398<tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr trn) %>"></td> </tr>
399<tr> <td>Date:</td> <td><input name="d" value="<% Web.html (#d trn) %>"></td> </tr>
400<tr> <td>Amount:</td> <td><input name="amount" value="<% #amount trn %>"></td> </tr>
401<tr> <td>Members:</td> <td><select name="usrs" size="5" multiple>
208e2cbc
AC
402<% foreach (sel, usr) in Money.listUsers (#id trn) do %>
403 <option value="<% #id usr %>"<% if sel then %> selected<% end %>><% #name usr %></option>
404<% end %>
405</select></td> </tr>
406<tr> <td><input type="submit" value="Save"></td> </tr>
407</table>
408</form>
409
410<% elseif $"saveEven" <> "" then
f49e1088 411 Group.requireGroupName "money";
208e2cbc
AC
412 val id = Web.stoi ($"saveEven");
413 val trn = Money.lookupTransaction id;
414 Money.clearCharges id;
415 Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Web.stor ($"amount")};
416 Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs"))
417
b6dd1aaf 418 %><h3>Even transaction modified</h3>
208e2cbc
AC
419
420<% elseif $"del" <> "" then
f49e1088 421 Group.requireGroupName "money";
208e2cbc
AC
422 showNormal := false;
423 val trn = Money.lookupTransaction (Web.stoi ($"del")) %>
b6dd1aaf 424 <h3>Are you sure you want to delete transaction <a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a>?</h3>
208e2cbc
AC
425 <a href="money?del2=<% $"del" %>">Yes, delete <% Web.html (#descr trn) %>!</a>
426
427<% elseif $"del2" <> "" then
f49e1088 428 Group.requireGroupName "money";
208e2cbc
AC
429 val id = Web.stoi ($"del2");
430 val trn = Money.lookupTransaction id;
431 Money.clearCharges id;
432 Money.deleteTransaction id %>
b6dd1aaf 433 <h3><% Web.html (#descr trn) %> deleted!</h3>
208e2cbc 434
2d795343
AC
435<% elseif $"cmd" = "equalize" then
436 Group.requireGroupName "money";
437 Money.equalizeBalances ();
b6dd1aaf 438 %><h3>Balances equalized</h3>
2d795343 439
208e2cbc
AC
440<% elseif $"trn" <> "" then
441 showNormal := false;
442 val id = Web.stoi ($"trn");
443 val trn = Money.lookupTransaction id %>
b6dd1aaf
AC
444<table class="blanks">
445<tr> <td>TRN#:</td> <td><% id %></td> </tr>
446<tr> <td>Description:</td> <td><% Web.html (#descr trn) %></td> </tr>
447<tr> <td>Date:</td> <td><% #d trn %></td> </tr>
448<tr> <td>Amount:</td> <td>$<% #amount trn %></td> </tr>
449<tr> <td>Distribution:</td>
af6f6078 450
208e2cbc
AC
451<% ref first = true;
452foreach (name, cha) in Money.listChargesWithNames id do
453 if first then
454 first := false
455 else
456 %><tr> <td></td> <%
457 end
458 %><td><a href="user?id=<% #usr cha %>"><% name %></a></td> <td>$<% #amount cha %></td> </tr><%
459end %>
460</table>
461
d5f8418b
AC
462<% elseif $"cmd" = "paypal" then
463 showNormal := false;
464 val apps = App.searchPaypal ($"email");
465 val users = Init.searchPaypal ($"email");
466
467 switch apps of
468 _ :: _ =>
469 %><h3>Approved applications</h3>
470
471 <% foreach appl in apps do %>
472 <br><hr><br>
473 <table class="blanks">
474 <tr> <td>Received:</td> <td><% #applied appl %></td> </tr>
475 <tr> <td>Approved by:</td> <td><%
476 ref first = true;
477 ref found = false;
478 foreach (id, name) in App.votes (#id appl) do
479 if first then
480 first := false
481 else
482 %>, <%
483 end
484 %><a href="user?id=<% id %>"><% name %></a><%
485 end %> </td> </tr>
486 <tr> <td>Username:</td> <td><% #name appl %></td> </tr>
487 <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr>
488 <tr> <td>E-mail address:</td> <td><a href="mailto:<% #email appl %>"><% #email appl %></a></td> </tr>
489 <% switch #paypal appl of
490 SOME s => %><tr> <td>PayPal:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
d5f8418b
AC
491 <% end %>
492 <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr>
493 <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr>
494 <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr>
495 </table>
496
497 <% if root then %>
498 <a href="apps?add=<% #id appl %>">Add this member.</a><br>
499 <% end
500 end
501 end;
502
503 switch users of
504 _ :: _ =>
505 %><h3>Members</h3>
506
507 <% foreach user in users do %>
508 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>">[add payment]</a></li>
509 <% end
510 end;
511
512 switch (apps, users) of
513 (nil, nil) => %>No matches.<%
514 end
515
b1bb018a
CE
516elseif $"cmd" = "realname" then
517 showNormal := false;
518 val users = Init.searchRealName ($"rname");
519
520 switch users of
521 _ :: _ =>
522 %><h3>Members</h3>
523
524 <% foreach user in users do %>
525 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>">[add payment]</a></li>
526 <% end
527 end;
528
529 switch users of
530 nil => %>No matches.<%
531 end
532
d5f8418b
AC
533elseif $"cmd" = "checkout" then
534 showNormal := false;
535 val apps = App.searchCheckout ($"email");
536 val users = Init.searchCheckout ($"email");
537
538 switch apps of
539 _ :: _ =>
540 %><h3>Approved applications</h3>
541
542 <% foreach appl in apps do %>
543 <br><hr><br>
544 <table class="blanks">
545 <tr> <td>Received:</td> <td><% #applied appl %></td> </tr>
546 <tr> <td>Approved by:</td> <td><%
547 ref first = true;
548 ref found = false;
549 foreach (id, name) in App.votes (#id appl) do
550 if first then
551 first := false
552 else
553 %>, <%
554 end
555 %><a href="user?id=<% id %>"><% name %></a><%
556 end %> </td> </tr>
557 <tr> <td>Username:</td> <td><% #name appl %></td> </tr>
558 <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr>
559 <tr> <td>E-mail address:</td> <td><a href="mailto:<% #email appl %>"><% #email appl %></a></td> </tr>
560 <% switch #paypal appl of
561 SOME s => %><tr> <td>PayPal:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr>
d5f8418b
AC
562 <% end %>
563 <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr>
564 <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr>
565 <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr>
566 </table>
567
568 <% if root then %>
569 <a href="apps?add=<% #id appl %>">Add this member.</a><br>
570 <% end
571 end
572 end;
573
574 switch users of
575 _ :: _ =>
576 %><h3>Members</h3>
577
578 <% foreach user in users do %>
579 <li> <a href="user?id=<% #id user %>"><% #name user %></a> <a href="?cmd=pay&user=<% #id user %>&checkout=1">[add payment]</a></li>
580 <% end
581 end;
582
583 switch (apps, users) of
584 (nil, nil) => %>No matches.<%
585 end
586
1b566e48
AC
587elseif $"cmd" = "delinq" then
588 showNormal := false;
589 val dqs = Money.delinquentPledgers () %>
64264243 590<table class="data">
1b566e48
AC
591<tr> <th>Member</th> <th>Pledge</th> <th>Balance</th> </tr>
592<% foreach dq in dqs do %>
593<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td><% #shares dq %></td> <td>$<% #balance dq %></td> </tr>
594<% end %>
595</table>
596
597<a href="?lower=<% String.concatWith "," (List.map (fn dq => Int.toString (#id dq)) dqs) %>">Lower these pledges to 1</a>
598
599<% elseif $"lower" <> "" then
600 Money.resetPledges (List.map Web.stoi (String.tokens (fn ch => ch = #",") ($"lower")))
601
602 %><h3>Pledges reset.</h3><%
603
eafe3d52
AC
604elseif $"cmd" = "freezeworthy" then
605 showNormal := false;
606 val dqs = Money.freezeworthyPledgers () %>
92855ded 607<table class="data">
eafe3d52
AC
608<tr> <th>Member</th> <th>Balance</th> </tr>
609<% foreach dq in dqs do %>
c6a3d7dd
CE
610<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td style="text-align: right">$<% #balance dq %></td>
611<td><a href="money?hist=<% #id dq %>">[History]</a></td>
27e65914 612<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
eafe3d52
AC
613<% end %>
614</table>
615
616<% elseif $"cmd" = "bootworthy" then
617 showNormal := false;
618 val dqs = Money.bootworthyPledgers () %>
92855ded 619<table class="data">
eafe3d52
AC
620<tr> <th>Member</th> <th>Balance</th> </tr>
621<% foreach dq in dqs do %>
c6a3d7dd 622<tr> <td><a href="user?id=<% #id dq %>"><% #name dq %></a></td> <td style="text-align: right">$<% #balance dq %></td><td><a href="money?hist=<% #id dq %>">[History]</a></td>
950a4fad 623<% if #joinedThisMonth dq then %><td><i>(joined this month)</i></td><% end %></tr>
eafe3d52
AC
624<% end %>
625</table>
626
627<% end %>
208e2cbc 628
466c5944
AC
629<% if showNormal then
630 val you = Init.getUser();
631 val bal = Balance.lookupBalance (#bal you);
b5dc79ca
AC
632 val deposit = Balance.depositAmount (#id bal);
633 val showBal = Util.sub (#amount bal, deposit) %>
208e2cbc 634
b5dc79ca 635<h3>Your balance: $<% showBal %><br>
a0399d9e 636Deposit: $<% deposit %> (3 months of dues at the minimal <a href="pledge">pledge level</a>)<br>
a976bf7f 637<!--Co-op balance: $<% #amount (Balance.lookupBalance (valOf (Balance.balanceNameToId "hcoop"))) %>--></h3>
96bd398e 638
96662fd8 639<% if (iff Group.inGroupName "money" then $"lookback" = "" else $"audit" <> "") then %><h3>Sum of all active balances: $<% Balance.sumOwnedBalances () %></h3><% end %>
aaba877a
CE
640<div class="payment-tile">
641 <h3>Financial Information</h3>
208e2cbc 642<a href="money?cmd=list">List all transactions</a><br>
104fbeb6 643<a href="money?cmd=primary">List primary transactions</a><br>
8ffa2c9e 644<a href="money?cmd=bals">List active balances</a><br>
711471a2 645<a href="money?cmd=nbals">List negative active balances</a><br>
eafe3d52
AC
646<a href="money?cmd=freezeworthy">List members who deserve account freezing</a><br>
647<a href="money?cmd=bootworthy">List members who deserve to be kicked out</a><br>
8ffa2c9e 648<a href="money?cmd=deadbals">List retired balances</a><br>
208e2cbc 649
96662fd8 650<% if (Group.inGroupName "money" and $"lookback" = "") or $"audit" <> "" then %>
cf10853e 651
1b566e48 652<a href="?cmd=delinq">Drop pledges of delinquent members</a><br>
cf10853e 653<a href="?lookback=20">Switch to regular member view</a><br>
82c5da3f
CE
654
655<% end %>
aaba877a 656</div>
82c5da3f
CE
657
658<% if (Group.inGroupName "money" and $"lookback" = "") or $"audit" <> "" then %>
aaba877a
CE
659<div class="payment-tile">
660 <h3>New Transaction</h3>
104fbeb6 661<a href="money?cmd=bill">Bill for the co-op</a><br>
f49e1088 662<a href="money?cmd=pay">Payment from member</a><br>
5c705bcb
AC
663<a href="money?cmd=dues">Monthly dues</a><br>
664<a href="money?cmd=hosting">New hosting bill (old style)</a><br>
208e2cbc 665<a href="money?cmd=evenForm">Generic/even</a><br>
2d795343 666<br>
4cc53ef6 667<!-- <a href="money?cmd=equalize">Equalize balances</a><br> -->
d5f8418b 668<br>
aaba877a 669</div>
82c5da3f 670
aaba877a
CE
671<div>
672<div class="payment-tile">
d5f8418b
AC
673<h3>Look up a PayPal e-mail address</h3>
674
675<form method="post">
676<input type="hidden" name="cmd" value="paypal">
677<input name="email"> <input type="submit" value="Look up">
678</form>
aaba877a
CE
679</div>
680
d5f8418b 681
aaba877a 682<div class="payment-tile">
b1bb018a
CE
683<h3>Look up a Real Name</h3>
684
685<form method="post">
686<input type="hidden" name="cmd" value="realname">
687<input name="rname"> <input type="submit" value="Look up">
d5f8418b 688</form>
aaba877a
CE
689</div>
690</div>
208e2cbc 691
f8b39e09
CE
692<h3>Apply Stripe Payments</h3>
693
64264243 694<table class="data">
f8b39e09
CE
695<tr><td><strong>Date</strong></td><td><strong>Member</strong></td>
696 <td><strong>Name on Card</strong></td>
697 <td><strong>Amount</strong> (After Fees)</td><td><td></td>
698</tr>
699<% foreach stripePmt in Money.listAllPendingStripePayments () do %>
700
701<tr>
702 <td><% #name (Init.lookupUser (#webuser_id stripePmt)) %></td>
703 <td><% #paid_on stripePmt %></td>
10e55875 704 <td><% #card_name stripePmt %></td>
64264243 705 <td style="text-align: right">$<% #net stripePmt %></td>
f8b39e09
CE
706 <td><form method="post">
707 <input type="hidden" name="cmd" value="stripeApply" />
708 <input type="hidden" name="stripeId" value="<% #charge_id stripePmt %>" />
709 <input type="submit" value="Apply to Balance" /> <!-- also, refund? -->
710 </form>
711 </td>
bd5d2441
CE
712 <td><form method="post">
713 <input type="hidden" name="cmd" value="stripeReject" />
714 <input type="hidden" name="stripeChargeId" value="<% #charge_id stripePmt %>" />
715 <input type="submit" value="Reject Payment" /> <!-- also, refund? -->
716 </form>
717 </td>
f8b39e09
CE
718</tr>
719<% end %>
720</table>
721
b6dd1aaf 722<h3>Most recent transactions</h3>
208e2cbc 723
f8b39e09
CE
724
725
64264243 726<table class="data">
208e2cbc
AC
727<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>
728<% foreach trn in Money.listTransactionsLimit 20 do %>
64264243 729<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td> <td style="text-align: right"><% #amount trn %></td>
208e2cbc
AC
730<% switch Money.listChargesWithNames (#id trn) of
731 [(name, cha)] => %><td><a href="user?id=<% #usr cha %>"><% name %></a></td><%
732 | _ => %><td><i>multi</i></td><%
733end %>
104fbeb6 734<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 735<td><a href="money?del=<% #id trn %>">[Delete]</a></td> </tr>
208e2cbc
AC
736<% end %>
737</table>
738
96662fd8 739<% else %>
82c5da3f
CE
740<div class="payment-tile">
741<p>
96662fd8 742<a href="?audit=1">Switch to audit view</a><br>
82c5da3f 743</p></div>
60465e67 744<% val lookback = case $"lookback" of "" => 20 | "inf" => 0 | lb => Web.stoi lb;
cf10853e 745 @payment [] %>
b251872c 746
b6dd1aaf 747<h3>Your recent account activity</h3>
208e2cbc 748
cf10853e 749<form>
60465e67 750 Show <input name="lookback" size="5" value="<% iff lookback = 0 then 20 else lookback %>"> most recent transactions.
cf10853e
AC
751 <input type="submit" value="Show">
752</form>
753
60465e67
AC
754<% ref running = showBal;
755val trans = iff lookback = 0 then
756 Money.listUserTransactions (Init.getUserId ())
757 else
758 Money.listUserTransactionsLimit (Init.getUserId (), lookback) %>
64264243 759<table class="data">
60465e67
AC
760<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>
761<% foreach (amount, trn) in trans do %>
762<tr> <td><% #d trn %></td> <td><a href="money?trn=<% #id trn %>"><% Web.html (#descr trn) %></a></td>
64264243
CE
763<td style="text-align: right"><% if Util.lt (amount, 0.0) then %><% amount %><% end %></td>
764<td style="text-align: right"><% if Util.ge (amount, 0.0) then %><% amount %><% end %></td>
765<td style="text-align: right"><% running %></tr>
b5dc79ca
AC
766<% running := Util.sub (running, amount)
767end %>
208e2cbc 768</table>
60465e67
AC
769<% if lookback <> 0 then %>
770<a href="?lookback=inf">Show all transactions</a><br>
771<% end %>
208e2cbc
AC
772
773<% end
774end %>
775
776<% @footer [] %>