Files
MatchLiveTv/backend/app/models/billing/payment.rb
Emiliano Frascaro a5e781729c Billing: fatture manuali, profilo obbligatorio e piani Stripe mensile/annuale.
Rimuove link al portale Stripe in area cliente, aggiunge flusso admin per PDF
fattura e email, blocca checkout senza dati di fatturazione, allinea prezzi
a €4,90/€39,90 e €9,90/€69,90, locale italiano e documentazione deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 17:10:12 +02:00

38 lines
967 B
Ruby

module Billing
class Payment < ApplicationRecord
self.table_name = "billing_payments"
STATUSES = %w[paid failed refunded].freeze
belongs_to :club
has_one :invoice, class_name: "Billing::Invoice", foreign_key: :billing_payment_id, dependent: :nullify
validates :amount_cents, numericality: { greater_than: 0 }
validates :currency, presence: true
validates :status, inclusion: { in: STATUSES }
validates :stripe_invoice_id, uniqueness: true, allow_nil: true
scope :recent, -> { order(paid_at: :desc, created_at: :desc) }
def amount_euros
amount_cents / 100.0
end
def formatted_amount
format("%.2f €", amount_euros)
end
def display_description
PaymentDescription.for_payment(self)
end
def display_status
{ "paid" => "Pagato", "failed" => "Non riuscito", "refunded" => "Rimborsato" }[status] || status
end
def invoice_for_display
invoice
end
end
end