fix: add missing total_earnings_cents method and payout method to Event model
- Add alias total_earnings_cents for total_gross_cents for template compatibility - Add payout method to get the latest payout for an event - Fixes NoMethodError in promoter events earnings preview template 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -76,6 +76,9 @@ class Event < ApplicationRecord
|
|||||||
tickets.active.sum(:price_cents)
|
tickets.active.sum(:price_cents)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Alias for template compatibility
|
||||||
|
alias_method :total_earnings_cents, :total_gross_cents
|
||||||
|
|
||||||
def total_fees_cents
|
def total_fees_cents
|
||||||
earnings.pending.sum(:fee_cents)
|
earnings.pending.sum(:fee_cents)
|
||||||
end
|
end
|
||||||
@@ -88,6 +91,11 @@ class Event < ApplicationRecord
|
|||||||
event_ended? && (net_earnings_cents > 0) && user.is_professionnal? && payouts.pending.empty?
|
event_ended? && (net_earnings_cents > 0) && user.is_professionnal? && payouts.pending.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get the latest payout for this event
|
||||||
|
def payout
|
||||||
|
payouts.order(created_at: :desc).first
|
||||||
|
end
|
||||||
|
|
||||||
# Check if coordinates were successfully geocoded or are fallback coordinates
|
# Check if coordinates were successfully geocoded or are fallback coordinates
|
||||||
def geocoding_successful?
|
def geocoding_successful?
|
||||||
coordinates_look_valid?
|
coordinates_look_valid?
|
||||||
|
|||||||
Reference in New Issue
Block a user