@extends('layouts.app') @section('title', 'Reporte de Ventas') @push('styles') @vite(['resources/css/reporte.css']) @endpush @section('content') @php $rol = session('usuario.ROL') ?? 'INVITADO'; // ✅ Si es VENDEDOR: $reportes puede venir como Collection (no paginate) // ✅ Si es ADMIN: $reportes viene como paginator // Sacamos "hoy" como el primer item de la lista que llega // - ADMIN: first() será el último reporte (por order desc) // - VENDEDOR: first() será el reporte de HOY (si existe) $hoy = $reportes->first(); $ef = $hoy->EFECTIVO_REPORTE ?? 0; $yp = $hoy->YAPE_PLIN_REPORTE ?? 0; $tj = $hoy->TARJETA_REPORTE ?? 0; $ds = $hoy->TOTAL_DESCUENTOS ?? 0; $tt = $hoy->TOTAL_REPORTE ?? 0; // ✅ Conteo total: // - paginator tiene total() // - collection tiene count() $totalRegistros = method_exists($reportes, 'total') ? $reportes->total() : $reportes->count(); // ✅ Es vendedor y no hay reporte hoy $sinReporteHoy = $rol === 'VENDEDOR' && $totalRegistros === 0; @endphp
@if ($rol === 'ADMIN') Historial diario por métodos de pago (Tulinda). @else Solo se muestra el reporte del día (si está generado). @endif
@if ($reporteHoy)| ID | Fecha | Efectivo | Yape/Plin | Tarjeta | Descuentos | Total | Empleado |
|---|---|---|---|---|---|---|---|
| #{{ $r->ID_REPORTE }} | {{ \Carbon\Carbon::parse($r->FECHA_REPORTE)->format('d/m/Y H:i') }} | S/ {{ number_format($r->EFECTIVO_REPORTE, 2) }} | S/ {{ number_format($r->YAPE_PLIN_REPORTE, 2) }} | S/ {{ number_format($r->TARJETA_REPORTE, 2) }} | S/ {{ number_format($r->TOTAL_DESCUENTOS, 2) }} | S/ {{ number_format($r->TOTAL_REPORTE, 2) }} | {{ $r->ID_EMPLEADO }} |
| @if ($rol === 'VENDEDOR') No hay reporte de hoy aún. @else No hay reportes aún. @endif | |||||||