@extends('layouts.app') @section('title', 'Reporte de Comisiones por Vendedor') @section('content')

Reporte de Comisiones por Vendedor

Visualice y analice todas las comisiones generadas y adjudicadas

Imprimir Reporte Exportar Excel
@if(session('success')) @endif @if(session('error')) @endif
Total Comisiones

{{ number_format($stats['total_commissions'] ?? 0, 0) }}

Registros
Total Ganadas

${{ number_format($stats['total_amount_earned'] ?? 0, 2) }}

USD
Total Perdidas

${{ number_format($stats['total_amount_lost'] ?? 0, 2) }}

USD
Pendientes

${{ number_format($stats['total_amount_pending'] ?? 0, 2) }}

USD
Pagadas

${{ number_format($stats['total_amount_paid'] ?? 0, 2) }}

USD
Parciales

${{ number_format($stats['total_amount_partial'] ?? 0, 2) }}

USD
Filtros
Limpiar
Comisiones
@forelse($commissions as $comm) @empty @endforelse
Factura Tipo Doc. Vendedor Fec. Venta Fec. Pago Días P. Mon. Vta. Mon. Pago Monto Base (USD) % Comisión (USD) Estado
@if($comm->salesInvoice) {{ $comm->salesInvoice->invoice_number ?? 'N/A' }} @else N/A @endif {{ ($comm->document_type ?? 'invoice') == 'invoice' ? 'Factura' : 'Nota' }} @if($comm->salesman) {{ $comm->salesman->first_name ?? '' }} {{ $comm->salesman->last_name ?? '' }} @else N/A @endif {{ $comm->invoice_date ? (is_string($comm->invoice_date) ? \Carbon\Carbon::parse($comm->invoice_date)->format('d/m/Y') : $comm->invoice_date->format('d/m/Y')) : 'N/A' }} {{ $comm->payment_date ? (is_string($comm->payment_date) ? \Carbon\Carbon::parse($comm->payment_date)->format('d/m/Y') : $comm->payment_date->format('d/m/Y')) : '-' }} @php $invoice = $comm->salesInvoice; $isInvoicePaid = $invoice && ($invoice->amount_due ?? $invoice->total_amount_usd ?? 0) <= 0.01; $isOverdue = $comm->isOverdue(); if ($comm->days_to_pay !== null && $comm->payment_days_limit !== null) { $daysToPay = $comm->days_to_pay; $isWithinLimit = $daysToPay <= $comm->payment_days_limit; } elseif ($comm->invoice_date) { $daysToPay = \Carbon\Carbon::parse($comm->invoice_date)->diffInDays(now()); $isWithinLimit = $daysToPay <= $comm->payment_days_limit; } else { $daysToPay = null; $isWithinLimit = true; } @endphp @php $daysTooltipText = ''; if ($isOverdue) { $daysTooltipText = 'Comisión fuera de tiempo - Excedió el límite de ' . ($comm->payment_days_limit ?? 30) . ' días'; } elseif (!$isInvoicePaid) { $daysTooltipText = 'Factura pendiente de pago'; } @endphp @if($daysToPay !== null) {{ $daysToPay }} @if($isOverdue) @endif @else - @endif {{ $comm->sale_currency ?? '-' }} {{ $comm->payment_currency ?? '-' }} ${{ number_format($comm->commissionable_amount_usd ?? 0, 2) }} {{ number_format($comm->commission_rate_applied ?? 0, 2) }}% ${{ number_format($comm->commission_amount_usd ?? 0, 2) }} @php $invoice = $comm->salesInvoice; $isInvoicePaid = $invoice && ($invoice->amount_due ?? $invoice->total_amount_usd ?? 0) <= 0.01; $isOverdue = $comm->isOverdue(); $status = $comm->status ?? 'pending'; $statusColors = [ 'pending' => 'warning', 'earned' => 'success', 'lost' => 'danger', 'paid' => 'info', 'partial' => 'secondary', 'cancelled' => 'dark', 'overdue' => 'danger' ]; // Si está fuera de tiempo y es pending, mostrar como "Fuera de Tiempo" if ($isOverdue && $status === 'pending') { $displayStatus = 'overdue'; $displayText = 'Fuera de Tiempo'; $tooltipText = 'Comisión fuera de tiempo - La factura excedió el límite de ' . ($comm->payment_days_limit ?? 30) . ' días sin pagarse'; } elseif (!$isInvoicePaid && $status === 'pending') { $displayStatus = 'pending'; $displayText = 'En Espera'; $tooltipText = 'En espera - La factura aún no está pagada'; } else { $displayStatus = $status; $displayText = $comm->status_text ?? ucfirst($status); $tooltipText = ''; } @endphp {{ $displayText }} @if($isOverdue && $status === 'pending')
Fuera de tiempo @elseif(!$isInvoicePaid && $status === 'pending')
Factura pendiente @endif

No hay comisiones que coincidan con los filtros seleccionados.

@endsection