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