Files
MatchLiveTv/backend/app/models/subscription.rb
Emiliano Frascaro 566104aff4 Billing upgrade/downgrade, inviti in app e diretta YouTube da mobile.
Upgrade Stripe con addebito immediato; downgrade programmato a fine periodo.
UX billing più sobria con box info; icone piani. API inviti e OAuth YouTube
per staff trasmissione; deep link join; scelta partita programmata o nuova.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 22:15:27 +02:00

34 lines
686 B
Ruby

class Subscription < ApplicationRecord
STATUSES = %w[active trialing past_due canceled incomplete].freeze
ACTIVE_STATUSES = %w[active trialing].freeze
belongs_to :club
belongs_to :plan
belongs_to :pending_plan, class_name: "Plan", optional: true
validates :status, inclusion: { in: STATUSES }
validates :club_id, uniqueness: true
scope :active, -> { where(status: ACTIVE_STATUSES) }
def active?
status.in?(ACTIVE_STATUSES)
end
def premium?
active? && plan.premium?
end
def premium_full?
active? && plan.slug == "premium_full"
end
def free?
plan.slug == "free"
end
def plan_change_pending?
pending_plan_id.present?
end
end