diff --git a/app/controllers/leagues_controller.rb b/app/controllers/leagues_controller.rb index 41edded..6440b71 100644 --- a/app/controllers/leagues_controller.rb +++ b/app/controllers/leagues_controller.rb @@ -958,6 +958,9 @@ def missing_spirit_reports end end + def finances + end + private def load_league_from_params diff --git a/app/views/leagues/_navbar.html.haml b/app/views/leagues/_navbar.html.haml index c74eab2..8d1df59 100644 --- a/app/views/leagues/_navbar.html.haml +++ b/app/views/leagues/_navbar.html.haml @@ -56,3 +56,8 @@ = link_to missing_spirit_reports_league_path do %i.icon-heart-empty Missing Spirit Reports + - if permitted_to? :finances, @league + %li + = link_to finances_league_path(@league) do + %i.icon-money + Finances diff --git a/app/views/leagues/finances.html.erb b/app/views/leagues/finances.html.erb new file mode 100644 index 0000000..51e63fc --- /dev/null +++ b/app/views/leagues/finances.html.erb @@ -0,0 +1,67 @@ +<% content_for :title, @league.name %> +<%=render :partial => '/pageheader', :locals => {subtitle: 'Manage Players', breadcrumbs: {'Leagues' => leagues_path, @league.name => league_path(@league), 'League Finances' => nil}} %> + +<% + comped_registrations = 0 + paid_registrations = 0 + total_paid = 0 + refunded_registrations = 0 + total_refunded = 0 +%> +<% + @league.registrations.each do |r| + if r.comped? + comped_registrations += 1 + end + + pt = r.payment_transactions.first + next if pt.nil? + + if pt.amount > 0 + paid_registrations += 1 + total_paid += pt.amount + end + + if pt.refunded_amount + refunded_registrations += 1 + total_refunded += pt.refunded_amount + end + end + + total_received = total_paid - total_refunded + total_fees = (total_received * 0.0199) + ((paid_registrations - refunded_registrations) * 0.49) +%> +
+ | Count | +Total Amount | +
---|---|---|
Comped Registrations | +<%= comped_registrations %> | +<%=number_to_currency(comped_registrations * @league.price)%> | +
Paid Registrations | +<%= paid_registrations %> | +<%=number_to_currency total_paid %> | +
Refunded Registrations | +<%= refunded_registrations %> | +<%=number_to_currency total_refunded %> | +
Merchant Fees (estimated) | ++ | -<%=number_to_currency(total_fees)%> | +
+ | <%= comped_registrations + paid_registrations - refunded_registrations %> | +<%=number_to_currency(total_received - total_fees)%> | +