% @header [("title", ["MoneyMatters"])];
ref showNormal = true;
if $"hist" <> "" then
showNormal := false;
val id = Web.stoi ($"hist") %>
Date Description Amount
<% foreach (amount, trn) in Money.listUserTransactions id do %>
<% #d trn %> <% Web.html (#descr trn) %> <% amount %>/<% #amount trn %>
<% end %>
<% elseif $"cmd" = "list" then
val admin = Group.inGroupName "money";
showNormal := false %>
Transactions
Date Description Amount Last modified Participants
<% foreach trn in Money.listTransactions () do %>
<% #d trn %> <% Web.html (#descr trn) %> <% #amount trn %> <% #stamp trn %>
<% switch Money.listChargesWithNames (#id trn) of
[(name, cha)] => %><% name %> <%
| _ => %>multi <%
end;
if admin then
%>[Hosting] [Payment] [Other]
[Delete] <%
end
%> <%
end %>
<% elseif $"cmd" = "bals" then
showNormal := false %>
Active Balances
<% foreach bal in Balance.listOwnedBalances () do %>
<% #name bal %> <% #amount bal %>
<% switch Balance.listBalanceUsers (#id bal) of
[] =>
| (user :: users) =>
%><% Web.html (#name user) %> <%
foreach user in users do
%>, <% Web.html (#name user) %> <%
end
end %>
<% end %>
<% elseif $"cmd" = "deadbals" then
showNormal := false %>
Retired Balances
<% foreach bal in Balance.listUnownedBalances () do %>
<% #name bal %> <% #amount bal %>
<% switch Balance.listBalanceUsers (#id bal) of
[] =>
| (user :: users) =>
%><% Web.html (#name user) %> <%
foreach user in users do
%>, <% Web.html (#name user) %> <%
end
end %>
<% end %>
<% elseif $"cmd" = "hosting" then
Group.requireGroupName "money";
showNormal := false %>
New hosting bill
<% elseif $"saveHosting" <> "" then
Group.requireGroupName "money";
val id = Web.stoi ($"saveHosting");
val trn = Money.lookupTransaction id;
Money.clearCharges id;
Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Util.neg (Web.stor ($"amount"))};
Money.addHostingCharges {trn = id, cutoff = 1000 * Web.stoi ($"cutoff"), cost = Web.stor ($"cost"), usage = $"usage"};
%>Hosting transaction modified.
<% elseif $"cmd" = "evenForm" then
Group.requireGroupName "money";
showNormal := false %>
New generic/even transaction
<% elseif $"cmd" = "pay" then
Group.requireGroupName "money";
showNormal := false %>
New member payment
<% elseif $"cmd" = "pay2" then
Group.requireGroupName "money";
val amount = Web.stor ($"amount");
val descr = $"descr";
val descr = iff descr = "" then $"descr2" else descr;
val id = Money.addTransaction ($"descr", amount, $"d");
Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount};
Money.applyCharges id;
%>Payment transaction added.
<% elseif $"modPay" <> "" then
Group.requireGroupName "money";
showNormal := false;
val id = Web.stoi ($"modPay");
val trn = Money.lookupTransaction id %>
Modify member payment
<% elseif $"savePay" <> "" then
Group.requireGroupName "money";
val id = Web.stoi ($"savePay");
val trn = Money.lookupTransaction id;
val amount = Web.stor ($"amount");
Money.clearCharges id;
Money.modTransaction {trn with descr = $"descr", d = $"d", amount = amount};
Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount};
Money.applyCharges id;
%>Member payment modified.
<% elseif $"cmd" = "evenForm" then
Group.requireGroupName "money";
showNormal := false %>
New generic/even transaction
<% elseif $"cmd" = "even" then
Group.requireGroupName "money";
val id = Money.addTransaction ($"descr", Web.stor ($"amount"), $"d");
Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs"))
%>Even transaction added.
<% elseif $"modEven" <> "" then
Group.requireGroupName "money";
showNormal := false;
val trn = Money.lookupTransaction (Web.stoi ($"modEven")) %>
Modify even transaction
">
<% elseif $"saveEven" <> "" then
Group.requireGroupName "money";
val id = Web.stoi ($"saveEven");
val trn = Money.lookupTransaction id;
Money.clearCharges id;
Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Web.stor ($"amount")};
Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs"))
%>Even transaction modified
<% elseif $"del" <> "" then
Group.requireGroupName "money";
showNormal := false;
val trn = Money.lookupTransaction (Web.stoi ($"del")) %>
">Yes, delete <% Web.html (#descr trn) %>!
<% elseif $"del2" <> "" then
Group.requireGroupName "money";
val id = Web.stoi ($"del2");
val trn = Money.lookupTransaction id;
Money.clearCharges id;
Money.deleteTransaction id %>
<% Web.html (#descr trn) %> deleted!
<% elseif $"cmd" = "equalize" then
Group.requireGroupName "money";
Money.equalizeBalances ();
%>Balances equalized
<% elseif $"trn" <> "" then
showNormal := false;
val id = Web.stoi ($"trn");
val trn = Money.lookupTransaction id %>
TRN#: <% id %>
Description: <% Web.html (#descr trn) %>
Date: <% #d trn %>
Amount: $<% #amount trn %>
Distribution:
<% ref first = true;
foreach (name, cha) in Money.listChargesWithNames id do
if first then
first := false
else
%> <%
end
%><% name %> $<% #amount cha %> <%
end %>
<% end %>
<% if showNormal then %>
Your balance: $<% #amount (Balance.lookupBalance (#bal (Init.getUser ()))) %>
<% if (iff Group.inGroupName "money" then $"lookback" = "" else $"audit" <> "") then %>Sum of all active balances: $<% Balance.sumOwnedBalances () %> <% end %>
List all transactions
List active balances
List retired balances
<% if (Group.inGroupName "money" and $"lookback" = "") or $"audit" <> "" then %>
Switch to regular member view
New transaction:
Hosting bill
Payment from member
Generic/even
Equalize balances
Most recent transactions
<% else %>
Switch to audit view
<% val lookback = case $"lookback" of "" => 20 | lb => Web.stoi lb;
@payment [] %>
Your recent account activity
Show most recent transactions.
Date Description Amount
<% foreach (amount, trn) in Money.listUserTransactionsLimit (Init.getUserId (), lookback) do %>
<% #d trn %> <% Web.html (#descr trn) %> <% amount %>/<% #amount trn %>
<% end %>
<% end
end %>
<% @footer [] %>