Aggiunge fatturazione club, pagina regia condivisibile senza account, roster squadre e rimuove la modalità controller dall'app (v1.1.0). Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
701 B
Ruby
26 lines
701 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
|
|
end
|
|
end
|