Mostra in admin anagrafica e dati fiscali delle società.
Così Ops può emettere fattura dalla scheda club senza cercare il profilo solo tra i pagamenti pending. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,7 +3,7 @@ module Admin
|
||||
before_action :set_club, only: %i[show grant_comped revoke_comped set_quote revoke_quote]
|
||||
|
||||
def index
|
||||
@clubs = Club.includes(:teams, :billing_quote, subscription: %i[plan admin_comped_by])
|
||||
@clubs = Club.includes(:teams, :billing_quote, { club_memberships: :user }, subscription: %i[plan admin_comped_by])
|
||||
.order(:name)
|
||||
end
|
||||
|
||||
@@ -63,7 +63,7 @@ module Admin
|
||||
private
|
||||
|
||||
def set_club
|
||||
@club = Club.find(params[:id])
|
||||
@club = Club.includes(club_memberships: :user).find(params[:id])
|
||||
end
|
||||
|
||||
def redirect_back_or_club(notice: nil, alert: nil)
|
||||
|
||||
@@ -21,7 +21,14 @@ class Club < ApplicationRecord
|
||||
validates :secondary_color, presence: true
|
||||
|
||||
def owner
|
||||
club_memberships.find_by(role: "owner")&.user
|
||||
memberships = club_memberships
|
||||
membership =
|
||||
if memberships.loaded?
|
||||
memberships.detect { |m| m.role == "owner" }
|
||||
else
|
||||
memberships.find_by(role: "owner")
|
||||
end
|
||||
membership&.user
|
||||
end
|
||||
|
||||
def owned_by?(user)
|
||||
|
||||
@@ -59,18 +59,43 @@ module ClubBillingProfile
|
||||
def billing_profile_invoice_lines
|
||||
lines = []
|
||||
lines << ["Tipo", self.class.billing_entity_types[billing_entity_type]] if billing_entity_type.present?
|
||||
lines << ["Intestatario", billing_legal_name]
|
||||
lines << ["Intestatario", billing_legal_name] if billing_legal_name.present?
|
||||
lines << ["P.IVA", billing_vat_number] if billing_vat_number.present?
|
||||
lines << ["Codice fiscale", billing_fiscal_code] if billing_fiscal_code.present?
|
||||
lines << ["Email fatturazione", billing_email]
|
||||
lines << ["Email fatturazione", billing_email] if billing_email.present?
|
||||
lines << ["Telefono", billing_phone] if billing_phone.present?
|
||||
addr = [billing_address_line, billing_postal_code, billing_city, billing_province, billing_country].compact.join(", ")
|
||||
lines << ["Indirizzo", addr] if addr.present?
|
||||
core_address = [billing_address_line, billing_postal_code, billing_city, billing_province].compact_blank
|
||||
if core_address.any?
|
||||
core_address << billing_country if billing_country.present?
|
||||
lines << ["Indirizzo", core_address.join(", ")]
|
||||
end
|
||||
lines << ["SDI", billing_recipient_code] if billing_recipient_code.present?
|
||||
lines << ["PEC", billing_pec] if billing_pec.present?
|
||||
lines
|
||||
end
|
||||
|
||||
# Stato profilo fiscale per badge admin: :complete | :incomplete | :absent
|
||||
def billing_profile_admin_status
|
||||
return :complete if billing_profile_complete?
|
||||
return :absent unless billing_profile_started?
|
||||
|
||||
:incomplete
|
||||
end
|
||||
|
||||
def billing_profile_started?
|
||||
billing_legal_name.present? ||
|
||||
billing_vat_number.present? ||
|
||||
billing_fiscal_code.present? ||
|
||||
billing_email.present? ||
|
||||
billing_phone.present? ||
|
||||
billing_address_line.present? ||
|
||||
billing_city.present? ||
|
||||
billing_postal_code.present? ||
|
||||
billing_province.present? ||
|
||||
billing_recipient_code.present? ||
|
||||
billing_pec.present?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def billing_profile_for_invoicing
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<% owner = club.owner %>
|
||||
<% status = club.billing_profile_admin_status %>
|
||||
<% lines = club.billing_profile_invoice_lines.select { |_label, value| value.present? } %>
|
||||
|
||||
<section class="panel admin-club-profile" style="margin:16px 0 24px">
|
||||
<h3 style="font-size:1rem;margin:0 0 12px"><%= t("admin.clubs.show.profile_title") %></h3>
|
||||
|
||||
<h4 style="font-size:0.9rem;margin:0 0 8px;color:var(--muted)"><%= t("admin.clubs.show.owner_title") %></h4>
|
||||
<% if owner %>
|
||||
<dl class="billing-profile-dl" style="margin-bottom:16px">
|
||||
<dt><%= t("admin.clubs.show.owner_name") %></dt>
|
||||
<dd><%= owner.name %></dd>
|
||||
<dt><%= t("admin.clubs.show.owner_email") %></dt>
|
||||
<dd><%= mail_to owner.email %></dd>
|
||||
</dl>
|
||||
<% else %>
|
||||
<p class="muted" style="margin:0 0 16px"><%= t("admin.clubs.show.owner_none") %></p>
|
||||
<% end %>
|
||||
|
||||
<div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:8px">
|
||||
<h4 style="font-size:0.9rem;margin:0;color:var(--muted)"><%= t("admin.clubs.show.billing_title") %></h4>
|
||||
<span class="admin-billing-status admin-billing-status--<%= status %>">
|
||||
<%= t("admin.clubs.billing_status.#{status}") %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<% if status == :absent || lines.empty? %>
|
||||
<p class="muted" style="margin:0"><%= t("admin.clubs.show.billing_none") %></p>
|
||||
<% else %>
|
||||
<dl class="billing-profile-dl">
|
||||
<% lines.each do |label, value| %>
|
||||
<dt><%= label %></dt>
|
||||
<dd><%= value %></dd>
|
||||
<% end %>
|
||||
</dl>
|
||||
<% end %>
|
||||
|
||||
<% if status == :incomplete %>
|
||||
<ul class="muted" style="margin:12px 0 0;padding-left:1.2rem;font-size:0.88rem">
|
||||
<% club.billing_profile_errors.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</section>
|
||||
@@ -9,6 +9,7 @@
|
||||
<th><%= t("admin.clubs.index.table.club") %></th>
|
||||
<th><%= t("admin.clubs.index.table.plan") %></th>
|
||||
<th><%= t("admin.clubs.index.table.teams") %></th>
|
||||
<th><%= t("admin.clubs.index.table.billing_profile") %></th>
|
||||
<th><%= t("admin.clubs.index.table.comped") %></th>
|
||||
<th><%= t("admin.clubs.index.table.stripe") %></th>
|
||||
<th><%= t("admin.clubs.index.table.quote") %></th>
|
||||
@@ -18,10 +19,16 @@
|
||||
<tbody>
|
||||
<% @clubs.each do |club| %>
|
||||
<% sub = club.subscription %>
|
||||
<% billing_status = club.billing_profile_admin_status %>
|
||||
<tr>
|
||||
<td><strong><%= club.name %></strong></td>
|
||||
<td><%= sub&.plan&.name || t("admin.common.free_plan") %></td>
|
||||
<td><%= club.teams.size %></td>
|
||||
<td>
|
||||
<span class="admin-billing-status admin-billing-status--<%= billing_status %>">
|
||||
<%= t("admin.clubs.billing_status.#{billing_status}") %>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<% if sub&.admin_comped? %>
|
||||
<span style="color:#ffb74d"><%= t("admin.common.yes") %></span>
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
· <%= link_to t("admin.clubs.show.youtube_platform_link"), admin_youtube_platform_path %>
|
||||
</p>
|
||||
|
||||
<%= render "admin/clubs/billing_profile", club: @club %>
|
||||
|
||||
<%= render "admin/clubs/comped_form", club: @club, subscription: @subscription, return_to: admin_club_path(@club) %>
|
||||
<%= render "admin/clubs/quote_form", club: @club, quote: @quote, return_to: admin_club_path(@club) %>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<%= csrf_meta_tags %>
|
||||
<link rel="stylesheet" href="/admin.css?v=19">
|
||||
<link rel="stylesheet" href="/admin.css?v=20">
|
||||
<%= yield :head %>
|
||||
<% if content_for?(:replay_archive_styles) %>
|
||||
<link rel="stylesheet" href="/marketing.css?v=42">
|
||||
|
||||
Reference in New Issue
Block a user