Files
MatchLiveTv/backend/spec/models/club_billing_profile_spec.rb
T
eminuxandCursor d7dd744c32 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>
2026-09-10 16:17:20 +02:00

56 lines
1.7 KiB
Ruby

require "rails_helper"
RSpec.describe ClubBillingProfile do
let(:club) do
Club.create!(
name: "Test Club",
sport: "volleyball",
primary_color: "#e53935",
secondary_color: "#ffffff",
billing_entity_type: "company",
billing_legal_name: "ASD Test",
billing_email: "billing@test.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
it "is complete with required fields" do
expect(club.billing_profile_complete?).to be true
end
it "requires SDI or PEC" do
club.billing_recipient_code = nil
club.billing_pec = nil
expect(club.billing_profile_complete?).to be false
end
it "requires P.IVA for companies" do
club.billing_vat_number = nil
expect(club.billing_profile_complete?).to be false
expect(club.billing_profile_errors).to include("Partita IVA")
end
it "requires Codice Fiscale for individuals" do
club.update!(billing_entity_type: "individual", billing_vat_number: nil, billing_fiscal_code: nil)
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