@extends('layouts.prestataire') @section('title', 'Détail Transaction') @push('styles') @endpush @section('content')
{{-- Retour --}} Retour @php $statusConfig = [ 'completed' => ['label' => 'Complété', 'bg' => 'from-green-500 to-emerald-600', 'icon' => '✓', 'color' => 'text-green-600'], 'pending' => ['label' => 'En attente', 'bg' => 'from-yellow-500 to-orange-500', 'icon' => '⏳', 'color' => 'text-yellow-600'], 'processing' => ['label' => 'En cours', 'bg' => 'from-blue-500 to-indigo-600', 'icon' => '🔄', 'color' => 'text-blue-600'], 'refunded' => ['label' => 'Remboursé', 'bg' => 'from-red-500 to-pink-600', 'icon' => '↩️', 'color' => 'text-red-600'], 'cancelled' => ['label' => 'Annulé', 'bg' => 'from-gray-500 to-gray-600', 'icon' => '✗', 'color' => 'text-gray-600'], ]; $sConfig = $statusConfig[$payment['status']] ?? ['label' => ucfirst($payment['status']), 'bg' => 'from-gray-500 to-gray-600', 'icon' => '•', 'color' => 'text-gray-600']; $typeConfig = [ 'booking' => ['icon' => '📅', 'label' => 'Réservation', 'bg' => 'bg-blue-500'], 'equipment' => ['icon' => '🔧', 'label' => 'Location', 'bg' => 'bg-purple-500'], 'urgent_sale' => ['icon' => '🔥', 'label' => 'Vente Flash', 'bg' => 'bg-orange-500'], 'food' => ['icon' => '🍽️', 'label' => 'Food', 'bg' => 'bg-green-500'], ]; $tConfig = $typeConfig[$payment['type']] ?? ['icon' => '💰', 'label' => 'Transaction', 'bg' => 'bg-gray-500']; $normalizedType = \App\Services\CommissionService::normalizeType((string) ($payment['type'] ?? 'service')); $platformCommission = $payment['platform_commission'] ?? \App\Services\CommissionService::feeAmount($payment['amount'], $normalizedType, 'prestataire'); $platformCommissionRate = isset($payment['platform_commission_rate']) ? (float) $payment['platform_commission_rate'] : \App\Services\CommissionService::ratePercent($normalizedType, 'prestataire'); if (($payment['type'] ?? '') === 'stripe' && !isset($payment['platform_commission_rate'])) { $platformCommissionRate = ((float) ($payment['amount'] ?? 0) > 0) ? round(((float) $platformCommission / (float) $payment['amount']) * 100, 2) : 0; } $stripeFee = $payment['stripe_fee'] ?? \App\Services\CommissionService::stripeFeesAmount($payment['amount']); $totalDeductions = $payment['total_deductions'] ?? $payment['commission']; $stripeFeePercent = (float) get_setting('stripe_fee_percent', '1.4'); $stripeFeeFixed = (float) get_setting('stripe_fee_fixed', '0.25'); $securityDeposit = (float) ($payment['security_deposit'] ?? 0); $grossAmount = (float) ($payment['gross_amount'] ?? $payment['amount']); $platformRateLabel = rtrim(rtrim(number_format($platformCommissionRate, 2, '.', ''), '0'), '.'); $baseAmountLabel = (($payment['type'] ?? '') === 'equipment' && $securityDeposit > 0) ? 'Montant location (hors caution)' : 'Prix de vente'; @endphp
{{-- Header compact --}}
{{ $tConfig['icon'] }}
{{ $payment['title'] }}
{{ $tConfig['label'] }} • {{ $payment['reference'] }}
{{ $sConfig['icon'] }}
{{ $sConfig['label'] }}
{{-- SECTION: Détail financier --}}
💰 Détail financier
💵 {{ $baseAmountLabel }} {{ number_format($payment['amount'], 2) }} €
@if(($payment['type'] ?? '') === 'equipment' && $securityDeposit > 0)
🔒 Caution client (séquestre) {{ number_format($securityDeposit, 2) }} €
Montant total débité client {{ number_format($grossAmount, 2) }} €
@endif
🏢 Commission ({{ $platformRateLabel }}%) -{{ number_format($platformCommission, 2) }} €
💳 Stripe ({{ rtrim(rtrim(number_format($stripeFeePercent, 2, '.', ''), '0'), '.') }}%+{{ number_format($stripeFeeFixed, 2) }}€) -{{ number_format($stripeFee, 2) }} €
Total déductions -{{ number_format($totalDeductions, 2) }} €
✅ Net viré {{ number_format($payment['net_amount'], 2) }} €
{{-- SECTION: Client + Dates (côte à côte) --}}
👤 Client
{{ $payment['client_name'] }}
{{ $payment['client_email'] }}
📅 Date
{{ \Carbon\Carbon::parse($payment['date'])->format('d/m/Y') }}
{{ \Carbon\Carbon::parse($payment['date'])->format('H:i') }}
{{-- SECTION: Détails spécifiques (compact) --}} @if(($payment['type'] === 'booking' && isset($payment['booking'])) || ($payment['type'] === 'equipment' && isset($payment['rental'])) || ($payment['type'] === 'urgent_sale' && isset($payment['purchase'])) || ($payment['type'] === 'food' && isset($payment['order'])))
📋 Détails
@switch($payment['type']) @case('booking') @php $booking = $payment['booking']; @endphp
Service{{ $booking->service->name ?? 'N/A' }}
@if($booking->event_date)
Date événement{{ \Carbon\Carbon::parse($booking->event_date)->format('d/m/Y') }}
@endif @if($booking->guests)
Invités{{ $booking->guests }}
@endif @break @case('equipment') @php $rental = $payment['rental']; @endphp
Équipement{{ $rental->equipment->name ?? 'N/A' }}
@if($rental->start_date && $rental->end_date)
Période{{ \Carbon\Carbon::parse($rental->start_date)->format('d/m') }} → {{ \Carbon\Carbon::parse($rental->end_date)->format('d/m/Y') }}
@endif @if($rental->quantity)
Quantité{{ $rental->quantity }}
@endif @php $escrowRow = is_object($payment['escrow'] ?? null) ? (array) $payment['escrow'] : []; $escrowMeta = []; try { $escrowMeta = !empty($escrowRow['metadata'] ?? null) ? (json_decode((string) $escrowRow['metadata'], true) ?: []) : []; } catch (\Throwable $e) { $escrowMeta = []; } $depositAmount = (float) ($rental->equipment->security_deposit ?? $rental->security_deposit ?? ($escrowRow['deposit_amount'] ?? 0)); $depositStatus = strtolower((string) (($rental->deposit_status ?? null) ?: ($escrowMeta['deposit_status'] ?? 'pending'))); $depositRetained = (float) (($rental->deposit_retained ?? null) ?? ($escrowMeta['deposit_retained'] ?? 0)); $depositReturned = max(0, $depositAmount - $depositRetained); if (isset($escrowMeta['deposit_returned'])) { $depositReturned = max(0, (float) $escrowMeta['deposit_returned']); } @endphp @if($depositAmount > 0)
Statut caution @if($depositStatus === 'returned') Remboursée ({{ number_format($depositReturned, 2) }} €) @elseif($depositStatus === 'partial') Partielle (retenu {{ number_format($depositRetained, 2) }} €) @elseif($depositStatus === 'retained') Retenue ({{ number_format($depositRetained, 2) }} €) @else En attente @endif
@endif @break @case('urgent_sale') @php $purchase = $payment['purchase']; @endphp
Article{{ $purchase->urgentSale->title ?? 'N/A' }}
@if($purchase->quantity)
Quantité{{ $purchase->quantity }}
@endif @if($purchase->urgentSale && $purchase->urgentSale->original_price)
Prix original{{ number_format($purchase->urgentSale->original_price, 2) }} €
@endif @break @case('food') @php $order = $payment['order']; @endphp
N° commande{{ $order->order_number ?? '#'.$order->id }}
@if($order->items && $order->items->count() > 0)
@foreach($order->items->take(3) as $item)
{{ $item->quantity }}x {{ $item->product_name ?? 'Produit' }} {{ number_format($item->total_price ?? 0, 2) }}€
@endforeach @if($order->items->count() > 3)
+{{ $order->items->count() - 3 }} autres
@endif @endif @break @endswitch
@endif {{-- Boutons d'action --}}
Retour
@endsection