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:
@@ -41,4 +41,15 @@ RSpec.describe ClubBillingProfile do
|
||||
club.billing_fiscal_code = "RSSMRA80A01H501U"
|
||||
expect(club.billing_profile_complete?).to be true
|
||||
end
|
||||
|
||||
it "classifies admin billing status" do
|
||||
expect(club.billing_profile_admin_status).to eq(:complete)
|
||||
|
||||
club.billing_recipient_code = nil
|
||||
club.billing_pec = nil
|
||||
expect(club.billing_profile_admin_status).to eq(:incomplete)
|
||||
|
||||
empty = Club.create!(name: "Empty", sport: "volleyball", primary_color: "#e53935", secondary_color: "#ffffff")
|
||||
expect(empty.billing_profile_admin_status).to eq(:absent)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Admin clubs billing profile", type: :request do
|
||||
let!(:admin) { AdminAccount.create!(username: "ops-clubs-billing", password: "Password123") }
|
||||
|
||||
let!(:complete_club) do
|
||||
Club.create!(
|
||||
name: "Club Completo",
|
||||
sport: "volleyball",
|
||||
primary_color: "#e53935",
|
||||
secondary_color: "#ffffff",
|
||||
billing_entity_type: "company",
|
||||
billing_legal_name: "ASD Completo",
|
||||
billing_email: "fatture@completo.it",
|
||||
billing_address_line: "Via Roma 1",
|
||||
billing_city: "Milano",
|
||||
billing_province: "MI",
|
||||
billing_postal_code: "20100",
|
||||
billing_country: "IT",
|
||||
billing_vat_number: "12345678901",
|
||||
billing_recipient_code: "ABCDEFG"
|
||||
)
|
||||
end
|
||||
|
||||
let!(:incomplete_club) do
|
||||
Club.create!(
|
||||
name: "Club Incompleto",
|
||||
sport: "volleyball",
|
||||
primary_color: "#e53935",
|
||||
secondary_color: "#ffffff",
|
||||
billing_entity_type: "company",
|
||||
billing_legal_name: "ASD Incompleto",
|
||||
billing_vat_number: "10987654321"
|
||||
)
|
||||
end
|
||||
|
||||
let!(:absent_club) do
|
||||
Club.create!(
|
||||
name: "Club Assente",
|
||||
sport: "volleyball",
|
||||
primary_color: "#e53935",
|
||||
secondary_color: "#ffffff"
|
||||
)
|
||||
end
|
||||
|
||||
let!(:owner) do
|
||||
user = User.create!(email: "owner-completo@test.it", name: "Mario Rossi", password: "Password123", role: "coach")
|
||||
ClubMembership.create!(user: user, club: complete_club, role: "owner")
|
||||
user
|
||||
end
|
||||
|
||||
before do
|
||||
post admin_login_path, params: { username: "ops-clubs-billing", password: "Password123" }
|
||||
end
|
||||
|
||||
it "mostra i dati fiscali e il titolare nella scheda società" do
|
||||
get admin_club_path(complete_club)
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include("Anagrafica e dati fiscali")
|
||||
expect(response.body).to include("Mario Rossi")
|
||||
expect(response.body).to include("owner-completo@test.it")
|
||||
expect(response.body).to include("ASD Completo")
|
||||
expect(response.body).to include("12345678901")
|
||||
expect(response.body).to include("ABCDEFG")
|
||||
expect(response.body).to include("Completo")
|
||||
end
|
||||
|
||||
it "mostra lo stato incompleto con errori mancanti" do
|
||||
get admin_club_path(incomplete_club)
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include("Incompleto")
|
||||
expect(response.body).to include("ASD Incompleto")
|
||||
expect(response.body).to include("10987654321")
|
||||
end
|
||||
|
||||
it "mostra lo stato assente quando non ci sono dati fiscali" do
|
||||
get admin_club_path(absent_club)
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include("Assenti")
|
||||
expect(response.body).to include("Nessun dato di fatturazione compilato.")
|
||||
end
|
||||
|
||||
it "elenca lo stato del profilo fiscale nella lista società" do
|
||||
get admin_clubs_path
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include("Dati fiscali")
|
||||
expect(response.body).to include("Completo")
|
||||
expect(response.body).to include("Incompleto")
|
||||
expect(response.body).to include("Assenti")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user