2 Commits

Author SHA1 Message Date
kbe
8103629370 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>
2025-09-17 12:01:59 +02:00
kbe
dce5d0af12 fix: update seeds file to use correct payout_status enum value
- Change 'not_requested' to 'pending_request' in seeds.rb
- Fixes ArgumentError when running db:seed after enum update
- Ensures seeds file works with the new enum naming

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-17 12:00:05 +02:00
2 changed files with 10 additions and 2 deletions

View File

@@ -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?

View File

@@ -147,8 +147,8 @@ completed_event = Event.find_or_create_by!(name: "Completed Music Festival") do
e.featured = false e.featured = false
e.image = "https://data.bizouk.com/cache1/events/images/10/78/87/b801a9a43266b4cc54bdda73bf34eec8_700_800_auto_97.jpg" e.image = "https://data.bizouk.com/cache1/events/images/10/78/87/b801a9a43266b4cc54bdda73bf34eec8_700_800_auto_97.jpg"
e.user = completed_event_promoter e.user = completed_event_promoter
# Ensure payout status is not_requested # Ensure payout status is pending_request
e.payout_status = :not_requested e.payout_status = :pending_request
end end
# Create ticket types for the completed event # Create ticket types for the completed event