Admin: voce Fatturazione nel menu e elenco società.

Rende raggiungibili pagamenti e fatture PDF senza passare solo dal dettaglio squadra.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-02 17:27:09 +02:00
parent ef805984ee
commit b073ded6c1
5 changed files with 49 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
module Admin
class BillingController < BaseController
def index
@clubs = Club.order(:name).includes(:billing_payments, :billing_invoices)
end
end
end

View File

@@ -0,0 +1,31 @@
<h2>Pagamenti e fatture</h2>
<p style="color:#666;margin-bottom:16px">
Elenco società: pagamenti da Stripe e fatture PDF da emettere o inviare al cliente.
</p>
<table class="admin-table">
<thead>
<tr>
<th>Società</th>
<th>Pagamenti</th>
<th>Fatture</th>
<th></th>
</tr>
</thead>
<tbody>
<% @clubs.each do |club| %>
<tr>
<td><strong><%= club.name %></strong></td>
<td><%= club.billing_payments.size %></td>
<td><%= club.billing_invoices.size %></td>
<td><%= link_to "Apri", admin_club_billing_invoices_path(club), class: "admin-btn admin-btn--sm" %></td>
</tr>
<% end %>
</tbody>
</table>
<% if @clubs.empty? %>
<p>Nessuna società registrata.</p>
<% end %>
<p style="margin-top:20px"><%= link_to "← Dashboard", admin_root_path %></p>

View File

@@ -1,12 +1,20 @@
<h2>Teams</h2> <h2>Teams</h2>
<table class="admin-table"> <table class="admin-table">
<thead><tr><th>Nome</th><th>Sport</th><th>YouTube</th></tr></thead> <thead><tr><th>Nome</th><th>Società</th><th>Sport</th><th>YouTube</th><th>Fatture</th></tr></thead>
<tbody> <tbody>
<% @teams.each do |t| %> <% @teams.each do |t| %>
<tr> <tr>
<td><%= link_to t.name, admin_team_path(t) %></td> <td><%= link_to t.name, admin_team_path(t) %></td>
<td><%= t.club&.name || "—" %></td>
<td><%= t.sport %></td> <td><%= t.sport %></td>
<td><%= t.youtube_credential.present? ? "✓" : "—" %></td> <td><%= t.youtube_credential.present? ? "✓" : "—" %></td>
<td>
<% if t.club %>
<%= link_to "Pagamenti", admin_club_billing_invoices_path(t.club) %>
<% else %>
<% end %>
</td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@@ -17,6 +17,7 @@
<% if admin_logged_in? %> <% if admin_logged_in? %>
<%= link_to "Dashboard", admin_root_path, class: ("active" if controller_name == "dashboard") %> <%= link_to "Dashboard", admin_root_path, class: ("active" if controller_name == "dashboard") %>
<%= link_to "Teams", admin_teams_path, class: ("active" if controller_name == "teams") %> <%= link_to "Teams", admin_teams_path, class: ("active" if controller_name == "teams") %>
<%= link_to "Fatturazione", admin_billing_path, class: ("active" if controller_name.in?(%w[billing billing_invoices])) %>
<%= link_to "Sessions", admin_sessions_path, class: ("active" if controller_name == "sessions") %> <%= link_to "Sessions", admin_sessions_path, class: ("active" if controller_name == "sessions") %>
<%= link_to "Password", edit_admin_password_path %> <%= link_to "Password", edit_admin_password_path %>
<%= button_to "Esci", admin_logout_path, method: :delete %> <%= button_to "Esci", admin_logout_path, method: :delete %>

View File

@@ -62,6 +62,7 @@ Rails.application.routes.draw do
root to: "dashboard#index" root to: "dashboard#index"
get "metrics", to: "dashboard#metrics" get "metrics", to: "dashboard#metrics"
get "billing", to: "billing#index", as: :billing
resources :teams, only: %i[index show] resources :teams, only: %i[index show]
resources :clubs, only: [] do resources :clubs, only: [] do
resources :billing_invoices, only: %i[index new create edit update], controller: "billing_invoices" resources :billing_invoices, only: %i[index new create edit update], controller: "billing_invoices"