feat: complete promoter payout system implementation

- Add comprehensive payout styling with custom CSS classes for status indicators
- Implement payout index and show views with French translations
- Add payout migration with proper indexes and defaults
- Update database schema with payout-related tables and fields
- Add comprehensive seed data for testing payout functionality
- Include payout CSS in application stylesheet
- Document payout system implementation in AGENT.md
- Add payout feature to BACKLOG.md

This completes the full promoter payout system allowing event organizers
to request and track revenue payouts for completed events.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
kbe
2025-09-17 01:38:55 +02:00
parent e4509b1c43
commit 47f4f50e5b
9 changed files with 868 additions and 139 deletions

View File

@@ -122,6 +122,157 @@ promoter = User.find_or_create_by!(email: "kbataille@vivaldi.net") do |u|
u.is_professionnal = true
end
# Create a completed event with earnings for payout demonstration
completed_event_promoter = User.find_or_create_by!(email: "kbataille@vivaldi.net") do |u|
u.password = "password"
u.password_confirmation = "password"
u.first_name = "Event"
u.last_name = "Promoter"
u.is_professionnal = true
# Ensure the promoter has a Stripe account for payouts
u.stripe_connected_account_id = "acct_test_payout_account" unless u.stripe_connected_account_id.present?
end
completed_event = Event.find_or_create_by!(name: "Completed Music Festival") do |e|
e.slug = "completed-music-festival"
e.state = :published
e.description = "An amazing music festival that has already taken place."
e.venue_name = "Central Park"
e.venue_address = "Central Park, New York, NY"
e.latitude = 40.7812
e.longitude = -73.9665
# Set the event to have ended 2 days ago
e.start_time = 2.days.ago
e.end_time = 2.days.ago + 8.hours
e.featured = false
e.image = "https://data.bizouk.com/cache1/events/images/10/78/87/b801a9a43266b4cc54bdda73bf34eec8_700_800_auto_97.jpg"
e.user = completed_event_promoter
# Ensure payout status is not_requested
e.payout_status = :not_requested
end
# Create ticket types for the completed event
general_ticket_type = TicketType.find_or_create_by!(event: completed_event, name: "General Admission") do |tt|
tt.description = "General admission ticket for the Completed Music Festival"
tt.price_cents = 5000 # $50.00
tt.quantity = 200
tt.sale_start_at = 1.month.ago
tt.sale_end_at = completed_event.start_time - 1.hour
tt.minimum_age = 18
end
vip_ticket_type = TicketType.find_or_create_by!(event: completed_event, name: "VIP") do |tt|
tt.description = "VIP access ticket for the Completed Music Festival"
tt.price_cents = 15000 # $150.00
tt.quantity = 50
tt.sale_start_at = 1.month.ago
tt.sale_end_at = completed_event.start_time - 1.hour
tt.minimum_age = 21
end
# Create some orders and tickets for the completed event to generate earnings
buyer_user = User.find_or_create_by!(email: "buyer@example.com") do |u|
u.password = "password"
u.password_confirmation = "password"
u.first_name = "Ticket"
u.last_name = "Buyer"
end
# Create multiple orders with different statuses to demonstrate the payout system
# Order 1: Paid order with general admission tickets
order1 = Order.find_or_create_by!(user: buyer_user, event: completed_event) do |o|
o.status = "paid"
o.total_amount_cents = 15000 # $150.00 for 3 general admission tickets ($50.00 each)
end
# Create tickets for order 1
3.times do |i|
Ticket.find_or_create_by!(order: order1, ticket_type: general_ticket_type) do |t|
t.qr_code = "ORDER1-TICKET#{i + 1}"
t.price_cents = 5000 # $50.00
t.status = "active"
t.first_name = "Attendee"
t.last_name = "#{i + 1}"
end
end
# Calculate platform fees using the actual model: €0.50 + 1.5% per ticket
# For 3 tickets at $50.00 each:
# Fixed fee: 3 tickets × $0.50 = $1.50 (150 cents)
# Percentage fee: 3 tickets × ($50.00 × 1.5%) = 3 × $0.75 = $2.25 (225 cents)
# Total platform fee: $1.50 + $2.25 = $3.75 (375 cents)
# Promoter payout: $150.00 - $3.75 = $146.25 (14625 cents)
# Create earnings for this paid order (this would normally happen automatically)
Earning.find_or_create_by!(event: completed_event, user: completed_event_promoter, order: order1) do |e|
e.amount_cents = 14625 # $146.25 (promoter payout after fees)
e.fee_cents = 375 # $3.75 platform fee
e.status = "pending"
end
# Order 2: Paid order with VIP tickets
order2 = Order.find_or_create_by!(user: buyer_user, event: completed_event) do |o|
o.status = "paid"
o.total_amount_cents = 30000 # $300.00 for 2 VIP tickets ($150.00 each)
end
# Create tickets for order 2
2.times do |i|
Ticket.find_or_create_by!(order: order2, ticket_type: vip_ticket_type) do |t|
t.qr_code = "ORDER2-TICKET#{i + 1}"
t.price_cents = 15000 # $150.00
t.status = "active"
t.first_name = "VIP"
t.last_name = "Attendee #{i + 1}"
end
end
# Calculate platform fees using the actual model: €0.50 + 1.5% per ticket
# For 2 tickets at $150.00 each:
# Fixed fee: 2 tickets × $0.50 = $1.00 (100 cents)
# Percentage fee: 2 tickets × ($150.00 × 1.5%) = 2 × $2.25 = $4.50 (450 cents)
# Total platform fee: $1.00 + $4.50 = $5.50 (550 cents)
# Promoter payout: $300.00 - $5.50 = $294.50 (29450 cents)
# Create earnings for this paid order (this would normally happen automatically)
Earning.find_or_create_by!(event: completed_event, user: completed_event_promoter, order: order2) do |e|
e.amount_cents = 29450 # $294.50 (promoter payout after fees)
e.fee_cents = 550 # $5.50 platform fee
e.status = "pending"
end
# Order 3: Refunded order to demonstrate that refunded tickets are excluded
order3 = Order.find_or_create_by!(user: buyer_user, event: completed_event) do |o|
o.status = "paid"
o.total_amount_cents = 5000 # $50.00 for 1 general admission ticket
end
# Create ticket for order 3 (will be refunded)
refunded_ticket = Ticket.find_or_create_by!(order: order3, ticket_type: general_ticket_type) do |t|
t.qr_code = "ORDER3-TICKET1"
t.price_cents = 5000 # $50.00
t.status = "refunded" # This ticket was refunded
t.first_name = "Refunded"
t.last_name = "Customer"
end
# Calculate platform fees using the actual model: €0.50 + 1.5% per ticket
# For 1 ticket at $50.00:
# Fixed fee: 1 ticket × $0.50 = $0.50 (50 cents)
# Percentage fee: 1 ticket × ($50.00 × 1.5%) = $0.75 (75 cents)
# Total platform fee: $0.50 + $0.75 = $1.25 (125 cents)
# Promoter payout: $50.00 - $1.25 = $48.75 (4875 cents)
# Create earnings for this refunded order (this would normally happen automatically)
Earning.find_or_create_by!(event: completed_event, user: completed_event_promoter, order: order3) do |e|
e.amount_cents = 4875 # $48.75 (promoter payout after fees)
e.fee_cents = 125 # $1.25 platform fee
e.status = "pending"
end
puts "Created 1 completed event with sample orders and earnings for payout demonstration"
belle_epoque_event = Event.find_or_create_by!(name: "LA BELLE ÉPOQUE PAR SISLEY ÉVENTS") do |e|
e.slug = "la-belle-epoque-par-sisley-events"
e.state = :draft