feat: Implement promoter payout system for event revenue processing
- Add Payout model with associations to User and Event - Create payout requests for completed events with proper earnings calculation - Exclude refunded tickets from payout calculations - Add promoter dashboard views for managing payouts - Implement admin interface for processing payouts - Integrate with Stripe for actual payment processing - Add comprehensive tests for payout functionality Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -1,58 +1,74 @@
|
||||
<div class="container mx-auto px-4 py-8">
|
||||
<h1 class="text-3xl font-bold mb-6"><%= @event.name %> - Payout Details</h1>
|
||||
|
||||
<div class="bg-white rounded-lg shadow-md p-6 mb-6">
|
||||
<h2 class="text-xl font-semibold mb-4">Event Summary</h2>
|
||||
<p><strong>Date:</strong> <%= @event.start_time.strftime('%B %d, %Y at %I:%M %p') %></p>
|
||||
<p><strong>Venue:</strong> <%= @event.venue_name %></p>
|
||||
<p><strong>Payout Status:</strong> <span class="font-medium <%= @event.payout_status %>"><%= @event.payout_status.humanize %></span></p>
|
||||
<% if @event.payout_requested_at %>
|
||||
<p><strong>Requested:</strong> <%= @event.payout_requested_at.strftime('%B %d, %Y at %I:%M %p') %></p>
|
||||
<% end %>
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h1 class="text-3xl font-bold text-gray-900">Payout Details</h1>
|
||||
<%= link_to "Back to Payouts", promoter_payouts_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
|
||||
</div>
|
||||
|
||||
<% if @earnings.any? %>
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<h2 class="text-xl font-semibold mb-4">Earnings Breakdown</h2>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full table-auto">
|
||||
<thead>
|
||||
<tr class="bg-gray-100">
|
||||
<th class="px-4 py-2 text-left">Order</th>
|
||||
<th class="px-4 py-2 text-left">Gross Amount</th>
|
||||
<th class="px-4 py-2 text-left">Fee</th>
|
||||
<th class="px-4 py-2 text-left">Net Amount</th>
|
||||
<th class="px-4 py-2 text-left">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @earnings.each do |earning| %>
|
||||
<tr class="<%= earning.status == 'pending' ? 'bg-yellow-50' : 'bg-green-50' %>">
|
||||
<td class="border px-4 py-2">#<%= earning.order_id %></td>
|
||||
<td class="border px-4 py-2">€<%= (earning.amount_cents / 100.0).round(2) %></td>
|
||||
<td class="border px-4 py-2">€<%= (earning.fee_cents / 100.0).round(2) %></td>
|
||||
<td class="border px-4 py-2">€<%= (earning.net_amount_cents / 100.0).round(2) %></td>
|
||||
<td class="border px-4 py-2">
|
||||
<span class="px-2 py-1 rounded text-xs <%= earning.status == 'pending' ? 'bg-yellow-200 text-yellow-800' : 'bg-green-200 text-green-800' %>">
|
||||
<%= earning.status.humanize %>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<div class="bg-white rounded-lg shadow overflow-hidden">
|
||||
<div class="px-4 py-5 sm:px-6">
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900">Payout Information</h3>
|
||||
<p class="mt-1 max-w-2xl text-sm text-gray-500">Details about this payout request.</p>
|
||||
</div>
|
||||
<div class="border-t border-gray-200">
|
||||
<dl>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Event</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"><%= @payout.event&.name || "Event not found" %></dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Gross Amount</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">€<%= @payout.amount_euros %></dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Platform Fees</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">€<%= @payout.fee_euros %></dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Net Amount</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">€<%= @payout.net_amount_euros %></dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Status</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
||||
<% case @payout.status %>
|
||||
<% when 'pending' %>
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">
|
||||
Pending
|
||||
</span>
|
||||
<% when 'processing' %>
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-blue-100 text-blue-800">
|
||||
Processing
|
||||
</span>
|
||||
<% when 'completed' %>
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
|
||||
Completed
|
||||
</span>
|
||||
<% when 'failed' %>
|
||||
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
|
||||
Failed
|
||||
</span>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 p-4 bg-gray-50 rounded">
|
||||
<h3 class="font-semibold">Total Summary</h3>
|
||||
<p>Gross Total: €<%= (@earnings.sum(:amount_cents) / 100.0).round(2) %></p>
|
||||
<p>Total Fees: €<%= (@earnings.sum(:fee_cents) / 100.0).round(2) %></p>
|
||||
<p>Net Total: €<%= (@earnings.sum(:net_amount_cents) / 100.0).round(2) %></p>
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Total Orders</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"><%= @payout.total_orders_count %></dd>
|
||||
</div>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Refunded Orders</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"><%= @payout.refunded_orders_count %></dd>
|
||||
</div>
|
||||
<div class="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Requested Date</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"><%= @payout.created_at.strftime("%B %d, %Y at %I:%M %p") %></dd>
|
||||
</div>
|
||||
<% if @payout.stripe_payout_id.present? %>
|
||||
<div class="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
||||
<dt class="text-sm font-medium text-gray-500">Stripe Payout ID</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2"><%= @payout.stripe_payout_id %></dd>
|
||||
</div>
|
||||
<% end %>
|
||||
</dl>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="bg-white rounded-lg shadow-md p-6">
|
||||
<p class="text-gray-500">No earnings recorded for this event.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user