X-Git-Url: https://git.hcoop.net/hcoop/portal.git/blobdiff_plain/afc975d0463c554c5dd404851f151ba0e63c1353..10e55875c83d1d44a0b8d31ff1e49cfec843e9a2:/money.mlt diff --git a/money.mlt b/money.mlt index c7756f5..af404c5 100644 --- a/money.mlt +++ b/money.mlt @@ -1,11 +1,13 @@ <% @header [("title", ["MoneyMatters"])]; +val root = Group.inGroupNum 0; + ref showNormal = true; if $"hist" <> "" then showNormal := false; val id = Web.stoi ($"hist") %> - +
<% foreach (amount, trn) in Money.listUserTransactions id do %> @@ -16,9 +18,9 @@ if $"hist" <> "" then val admin = Group.inGroupName "money"; showNormal := false %> -

Transactions

+

Transactions

-
Date Description Amount
<% #d trn %> <% Web.html (#descr trn) %> <% amount %>/<% #amount trn %>
+
<% foreach trn in Money.listTransactions () do %> @@ -27,7 +29,29 @@ if $"hist" <> "" then | _ => %><% end; if admin then - %> + %> + <% +end +%><% +end %> +
Date Description Amount Last modified Participants
<% #d trn %> <% Web.html (#descr trn) %> <% #amount trn %> <% #stamp trn %>multi[Hosting] [Payment] [Other][Bill] [Payment] [Other][Delete]
+ +<% elseif $"cmd" = "primary" then + val admin = Group.inGroupName "money"; + showNormal := false %> + +

Primary Transactions

+ + + +<% foreach (amt, trn) in Money.listUserTransactions (valOf (Init.userNameToId "hcoop")) do %> + +<% switch Money.listChargesWithNames (#id trn) of + [(name, cha)] => %><% + | _ => %><% +end; +if admin then + %><% end %><% @@ -37,7 +61,7 @@ end %> <% elseif $"cmd" = "bals" then showNormal := false %> -

Balances

+

Active Balances

Date Description Amount Last modified Participants
<% #d trn %> <% Web.html (#descr trn) %> <% #amount trn %> <% #stamp trn %><% name %>multi[Bill] [Payment] [Other] [Delete]
<% foreach bal in Balance.listOwnedBalances () do %> @@ -45,7 +69,7 @@ end %> <% switch Balance.listBalanceUsers (#id bal) of [] => | (user :: users) => - %><% Web.html (#name user) %><% + %><% Web.html (#name user) %>[History]<% foreach user in users do %>, <% Web.html (#name user) %><% end @@ -53,21 +77,60 @@ end %> <% end %>
+<% elseif $"cmd" = "deadbals" then + showNormal := false %> + +

Retired Balances

+ + +<% foreach bal in Balance.listUnownedBalances () do %> + +<% end %> +
<% #name bal %> <% #amount bal %> +<% switch Balance.listBalanceUsers (#id bal) of + [] => + | (user :: users) => + %><% Web.html (#name user) %> [History]<% + foreach user in users do + %>, <% Web.html (#name user) %> [History]<% + end +end %>
+ +<% elseif $"cmd" = "nbals" then + showNormal := false; + val bals = Balance.listNegativeOwnedBalances () %> + +

Negative Active Balances (<% length bals %>)

+ + +<% foreach bal in bals do %> + +<% end %> +
<% #name bal %> <% #amount bal %> +<% switch Balance.listBalanceUsers (#id bal) of + [] => + | (user :: users) => + %><% Web.html (#name user) %> [History]<% + foreach user in users do + %>, <% Web.html (#name user) %> [History]<% + end +end %>
+ <% elseif $"cmd" = "hosting" then Group.requireGroupName "money"; showNormal := false %> -

New hosting bill

+

New hosting bill

- - - - - - - +
Description:
Date:
Amount:
Free bandwidth cutoff (MB):
Cost/GB:
Member usage:
+ + + + + +
Description:
Date:
Amount:
Free bandwidth cutoff (MB):
Cost/GB:
Member usage:
@@ -76,7 +139,7 @@ end %> val id = Money.addTransaction ($"descr", Util.neg (Web.stor ($"amount")), $"d"); Money.addHostingCharges {trn = id, cutoff = 1000 * Web.stoi ($"cutoff"), cost = Web.stor ($"cost"), usage = $"usage"}; - %>

Hosting transaction added.

+ %>

Hosting transaction added.

<% elseif $"modHosting" <> "" then Group.requireGroupName "money"; @@ -84,17 +147,17 @@ end %> val id = Web.stoi ($"modHosting"); val trn = Money.lookupTransaction id %> -

Modify hosting bill

+

Modify hosting bill

- - - - - - - @@ -110,19 +173,71 @@ end %> 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.

+ %>

Hosting transaction modified.

+ +<% elseif $"cmd" = "bill" then + Group.requireGroupName "money"; + showNormal := false %> + +

New bill for the co-op

+ + + +
Description:
Date:
Amount:
Free bandwidth cutoff (MB):
Cost/GB:
Member usage:
+ + + + +
Description:
Date:
Amount:
+ +<% elseif $"cmd" = "bill2" then + Group.requireGroupName "money"; + val id = Money.addTransaction ($"descr", Util.neg (Web.stor ($"amount")), $"d"); + Money.addCharge {trn = id, usr = valOf (Init.userNameToId "hcoop"), amount = Util.neg (Web.stor ($"amount"))}; + Money.applyCharges id; + + %>

Bill added.

+ +<% elseif $"modBill" <> "" then + Group.requireGroupName "money"; + showNormal := false; + val id = Web.stoi ($"modBill"); + val trn = Money.lookupTransaction id %> + +

Modify bill

+ + + + + + + + +
Description:
Date:
Amount:
+ +<% elseif $"saveBill" <> "" then + Group.requireGroupName "money"; + val id = Web.stoi ($"saveBill"); + val trn = Money.lookupTransaction id; + + Money.clearCharges id; + Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Util.neg (Web.stor ($"amount"))}; + Money.addCharge {trn = id, usr = valOf (Init.userNameToId "hcoop"), amount = Util.neg (Web.stor ($"amount"))}; + Money.applyCharges id; + + %>

Bill modified.

<% elseif $"cmd" = "evenForm" then Group.requireGroupName "money"; showNormal := false %> -

New generic/even transaction

+

New generic/even transaction

- - - - -
Description:
Date:
Amount:
Members: + + + + <% elseif $"cmd" = "pay" then Group.requireGroupName "money"; + val uid = (case $"user" of "" => ~1 | s => Web.stoi s); showNormal := false %> -

New member payment

+

New member payment

-
Description:
Date:
Amount:
Members:
- - - -
Description:
Date:
Amount:
Member: + + + + @@ -155,11 +277,18 @@ end %> <% elseif $"cmd" = "pay2" then Group.requireGroupName "money"; val amount = Web.stor ($"amount"); - val id = Money.addTransaction ($"descr", amount, $"d"); + 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.

+ %>

Payment transaction added.

+ +<% elseif $"cmd" = "stripeApply" then + val stripePmt = Money.lookupStripePayment ($"stripeId"); + val txid = Money.applyStripePayment stripePmt; +%>

Stripe Payment Processed (Transaction <% txid %>)

<% elseif $"modPay" <> "" then Group.requireGroupName "money"; @@ -167,15 +296,15 @@ end %> val id = Web.stoi ($"modPay"); val trn = Money.lookupTransaction id %> -

Modify member payment

+

Modify member payment

-
Description:
Date: ">
Amount:
Member:
- - - -
Description:
Date:
Amount:
Member: + + + + Money.addCharge {trn = id, usr = Web.stoi ($"usr"), amount = amount}; Money.applyCharges id; - %>

Member payment modified.

+ %>

Member payment modified.

<% elseif $"cmd" = "evenForm" then Group.requireGroupName "money"; showNormal := false %> -

New generic/even transaction

+

New generic/even transaction

-
Description:
Date:
Amount:
Member:
- - - -
Description:
Date:
Amount:
Members: + + + +
Description:
Date:
Amount:
Members:
+<% elseif $"cmd" = "dues" then + Group.requireGroupName "money"; + showNormal := false %> + +

Monthly dues

+ +
+ + + + + + +
Description:
Date:
Amount/pledge:
+ +<% elseif $"cmd" = "dues2" then + Group.requireGroupName "money"; + Money.billDues {descr = $"descr", base = Web.stor ($"base"), date = $"d"}; + + %>

Dues debits added.

+ <% 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.

+ %>

Even transaction added.

<% elseif $"modEven" <> "" then Group.requireGroupName "money"; showNormal := false; val trn = Money.lookupTransaction (Web.stoi ($"modEven")) %> -

Modify even transaction

+

Modify even transaction

"> - - - - -
Description:
Date:
Amount:
Members: + + + + Money.modTransaction {trn with descr = $"descr", d = $"d", amount = Web.stor ($"amount")}; Money.addEvenCharges (id, map Web.stoi (Web.getMultiParam "usrs")) - %>

Even transaction modified

+ %>

Even transaction modified

<% elseif $"del" <> "" then Group.requireGroupName "money"; showNormal := false; val trn = Money.lookupTransaction (Web.stoi ($"del")) %> -

Are you sure you want to delete transaction <% Web.html (#descr trn) %>?

+

Are you sure you want to delete transaction <% Web.html (#descr trn) %>?

">Yes, delete <% Web.html (#descr trn) %>! <% elseif $"del2" <> "" then @@ -266,23 +416,23 @@ end %> val trn = Money.lookupTransaction id; Money.clearCharges id; Money.deleteTransaction id %> -

<% Web.html (#descr trn) %> deleted!

+

<% Web.html (#descr trn) %> deleted!

<% elseif $"cmd" = "equalize" then Group.requireGroupName "money"; Money.equalizeBalances (); - %>

Balances equalized

+ %>

Balances equalized

<% elseif $"trn" <> "" then showNormal := false; val id = Web.stoi ($"trn"); val trn = Money.lookupTransaction id %> -
Description:
Date:
Amount:
Members:
- - - - - +
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 @@ -295,49 +445,300 @@ foreach (name, cha) in Money.listChargesWithNames id do end %>
TRN#: <% id %>
Description: <% Web.html (#descr trn) %>
Date: <% #d trn %>
Amount: $<% #amount trn %>
Distribution:
+<% elseif $"cmd" = "paypal" then + showNormal := false; + val apps = App.searchPaypal ($"email"); + val users = Init.searchPaypal ($"email"); + + switch apps of + _ :: _ => + %>

Approved applications

+ + <% foreach appl in apps do %> +


+ + + + + + + <% switch #paypal appl of + SOME s => %> + <% end; + switch #checkout appl of + SOME s => %> + <% end %> + + + +
Received: <% #applied appl %>
Approved by: <% + ref first = true; + ref found = false; + foreach (id, name) in App.votes (#id appl) do + if first then + first := false + else + %>, <% + end + %><% name %><% + end %>
Username: <% #name appl %>
Real name: <% Web.html (#rname appl) %>
E-mail address: <% #email appl %>
PayPal: <% s %>
Google Checkout: <% s %>
Forward e-mail? <% if #forward appl then %>yes<% else %>no<% end %>
Proposed uses: <% Web.htmlNl (#uses appl) %>
Other information: <% Web.htmlNl (#other appl) %>
+ + <% if root then %> + Add this member.
+ <% end + end + end; + + switch users of + _ :: _ => + %>

Members

+ + <% foreach user in users do %> +
  • <% #name user %> [add payment]
  • + <% end + end; + + switch (apps, users) of + (nil, nil) => %>No matches.<% + end + +elseif $"cmd" = "realname" then + showNormal := false; + val users = Init.searchRealName ($"rname"); + + switch users of + _ :: _ => + %>

    Members

    + + <% foreach user in users do %> +
  • <% #name user %> [add payment]
  • + <% end + end; + + switch users of + nil => %>No matches.<% + end + +elseif $"cmd" = "checkout" then + showNormal := false; + val apps = App.searchCheckout ($"email"); + val users = Init.searchCheckout ($"email"); + + switch apps of + _ :: _ => + %>

    Approved applications

    + + <% foreach appl in apps do %> +


    + + + + + + + <% switch #paypal appl of + SOME s => %> + <% end; + switch #checkout appl of + SOME s => %> + <% end %> + + + +
    Received: <% #applied appl %>
    Approved by: <% + ref first = true; + ref found = false; + foreach (id, name) in App.votes (#id appl) do + if first then + first := false + else + %>, <% + end + %><% name %><% + end %>
    Username: <% #name appl %>
    Real name: <% Web.html (#rname appl) %>
    E-mail address: <% #email appl %>
    PayPal: <% s %>
    Google Checkout: <% s %>
    Forward e-mail? <% if #forward appl then %>yes<% else %>no<% end %>
    Proposed uses: <% Web.htmlNl (#uses appl) %>
    Other information: <% Web.htmlNl (#other appl) %>
    + + <% if root then %> + Add this member.
    + <% end + end + end; + + switch users of + _ :: _ => + %>

    Members

    + + <% foreach user in users do %> +
  • <% #name user %> [add payment]
  • + <% end + end; + + switch (apps, users) of + (nil, nil) => %>No matches.<% + end + +elseif $"cmd" = "delinq" then + showNormal := false; + val dqs = Money.delinquentPledgers () %> + + +<% foreach dq in dqs do %> + <% end %> +
    Member Pledge Balance
    <% #name dq %> <% #shares dq %> $<% #balance dq %>
    + + Int.toString (#id dq)) dqs) %>">Lower these pledges to 1 -<% if showNormal then %> +<% elseif $"lower" <> "" then + Money.resetPledges (List.map Web.stoi (String.tokens (fn ch => ch = #",") ($"lower"))) -

    Your balance: $<% #amount (Balance.lookupBalance (#bal (Init.getUser ()))) %>

    + %>

    Pledges reset.

    <% + +elseif $"cmd" = "freezeworthy" then + showNormal := false; + val dqs = Money.freezeworthyPledgers () %> + + +<% foreach dq in dqs do %> + +<% if #joinedThisMonth dq then %><% end %> +<% end %> +
    Member Balance
    <% #name dq %> $<% #balance dq %>(joined this month)
    + +<% elseif $"cmd" = "bootworthy" then + showNormal := false; + val dqs = Money.bootworthyPledgers () %> + + +<% foreach dq in dqs do %> + +<% if #joinedThisMonth dq then %><% end %> +<% end %> +
    Member Balance
    <% #name dq %> $<% #balance dq %>(joined this month)
    + +<% end %> + +<% if showNormal then + val you = Init.getUser(); + val bal = Balance.lookupBalance (#bal you); + val deposit = Balance.depositAmount (#id bal); + val showBal = Util.sub (#amount bal, deposit) %> + +

    Your balance: $<% showBal %>
    +Deposit: $<% deposit %> (3 months of dues at the minimal pledge level)
    +Co-op balance: $<% #amount (Balance.lookupBalance (valOf (Balance.balanceNameToId "hcoop"))) %>

    + + + +<% if (iff Group.inGroupName "money" then $"lookback" = "" else $"audit" <> "") then %>

    Sum of all active balances: $<% Balance.sumOwnedBalances () %>

    <% end %> List all transactions
    -List all balances
    +List primary transactions
    +List active balances
    +List negative active balances
    +List members who deserve account freezing
    +List members who deserve to be kicked out
    +List retired balances
    + +<% if (Group.inGroupName "money" and $"lookback" = "") or $"audit" <> "" then %> -<% if Group.inGroupName "money" then %> +Drop pledges of delinquent members
    +Switch to regular member view

    New transaction:
    -Hosting bill
    +Bill for the co-op
    Payment from member
    +Monthly dues
    +New hosting bill (old style)
    Generic/even

    Equalize balances
    +
    -

    Most recent transactions

    +

    Look up a PayPal e-mail address

    - + + + + + +

    Look up a Real Name

    + + + + + + +

    Apply Stripe Payments

    + +
    + + + + +<% foreach stripePmt in Money.listAllPendingStripePayments () do %> + + + + + + + + +<% end %> +
    DateMemberName on CardAmount (After Fees)
    <% #name (Init.lookupUser (#webuser_id stripePmt)) %><% #paid_on stripePmt %><% #card_name stripePmt %>$<% #net stripePmt %>
    + + + +
    +
    + +

    Most recent transactions

    + + + + <% foreach trn in Money.listTransactionsLimit 20 do %> - + <% switch Money.listChargesWithNames (#id trn) of [(name, cha)] => %><% | _ => %><% end %> - + <% end %>
    Date Description Amount Participants Replace Delete
    <% #d trn %> <% Web.html (#descr trn) %> <% #amount trn %>
    <% #d trn %> <% Web.html (#descr trn) %> <% #amount trn %><% name %>multi[Hosting] [Payment] [Other][Bill] [Payment] [Other] [Delete]
    <% else %> +Switch to audit view
    +<% val lookback = case $"lookback" of "" => 20 | "inf" => 0 | lb => Web.stoi lb; + @payment [] %> -

    Your recent account activity

    +

    Your recent account activity

    - - -<% foreach (amount, trn) in Money.listUserTransactionsLimit (Init.getUserId (), 20) do %> - -<% end %> + + Show most recent transactions. + + + +<% ref running = showBal; +val trans = iff lookback = 0 then + Money.listUserTransactions (Init.getUserId ()) + else + Money.listUserTransactionsLimit (Init.getUserId (), lookback) %> +
    Date Description Amount
    <% #d trn %> <% Web.html (#descr trn) %> <% amount %>/<% #amount trn %>
    + +<% foreach (amount, trn) in trans do %> + + + + +<% running := Util.sub (running, amount) +end %>
    Date Description Debit Credit Balance
    <% #d trn %> <% Web.html (#descr trn) %><% if Util.lt (amount, 0.0) then %><% amount %><% end %><% if Util.ge (amount, 0.0) then %><% amount %><% end %><% running %>
    +<% if lookback <> 0 then %> +Show all transactions
    +<% end %> <% end end %>