diff --git a/app/models/event.rb b/app/models/event.rb index 837b172..e9bf80e 100755 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -76,6 +76,9 @@ class Event < ApplicationRecord tickets.active.sum(:price_cents) end + # Alias for template compatibility + alias_method :total_earnings_cents, :total_gross_cents + def total_fees_cents earnings.pending.sum(:fee_cents) end @@ -88,6 +91,11 @@ class Event < ApplicationRecord event_ended? && (net_earnings_cents > 0) && user.is_professionnal? && payouts.pending.empty? 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 def geocoding_successful? coordinates_look_valid?