@extends('layouts.app') @section('title', 'Reporte de Gastos — ' . $cliente->nombre_completo) @section('content')
{{-- Header --}}

Reporte de Gastos — {{ $cliente->nombre_completo }}

@php $waText = "⚖ *REPORTE DE GASTOS*\n\n" . "👤 *Cliente:* " . $cliente->nombre_completo . "\n" . "🗓 *Fecha de Reporte:* " . now()->format('d/m/Y H:i') . "\n\n" . "📊 *DETALLE DE GASTOS*\n\n"; if ($gastosDirectos->count() > 0) { $waText .= "🔸 *Gastos Generales (Sin Expediente)*\n"; foreach($gastosDirectos as $gasto) { $fechaGasto = \Carbon\Carbon::parse($gasto->fecha)->format('d/m/y'); $waText .= " ▪ " . $fechaGasto . " - " . $gasto->concepto . ": S/ " . number_format($gasto->monto, 2) . "\n"; } $waText .= " *Subtotal:* S/ " . number_format($gastosDirectos->sum('monto'), 2) . "\n\n"; } foreach($expedientesConGastos as $exp) { $waText .= "📂 *Expediente N° " . $exp->numero_expediente . "*\n"; foreach($exp->gastos as $gasto) { $fechaGasto = \Carbon\Carbon::parse($gasto->fecha)->format('d/m/y'); $waText .= " ▪ " . $fechaGasto . " - " . $gasto->concepto . ": S/ " . number_format($gasto->monto, 2) . "\n"; } $waText .= " *Subtotal:* S/ " . number_format($exp->gastos->sum('monto'), 2) . "\n\n"; } $waText .= "💰 *Total General:* S/ " . number_format($montoTotal, 2) . "\n\n" . "Quedamos a su disposición para cualquier duda."; @endphp
{{-- Filtro de fechas --}}
@if($fechaDesde || $fechaHasta) @endif
{{-- Encabezado solo para impresión --}}
Logo

Cornejo & Cubas
Abogados

Gestión de Expedientes Judiciales

Reporte de Gastos

Cliente: {{ $cliente->nombre_completo }}

@if($cliente->dni_ruc)

DNI/RUC: {{ $cliente->dni_ruc }}

@endif @if($fechaDesde || $fechaHasta)

Período: {{ $fechaDesde ? \Carbon\Carbon::parse($fechaDesde)->format('d/m/Y') : '—' }} al {{ $fechaHasta ? \Carbon\Carbon::parse($fechaHasta)->format('d/m/Y') : '—' }}

@endif

Generado el {{ now()->format('d/m/Y H:i') }}

{{-- Resumen total --}}
TOTAL GASTOS
S/ {{ number_format($montoTotal, 2) }}
EXPEDIENTES CON GASTOS
{{ $expedientesConGastos->count() }}
TOTAL REGISTROS
{{ $gastosDirectos->count() + $expedientesConGastos->sum(fn($e) => $e->gastos->count()) }}
{{-- Gastos por Expediente --}} @forelse($expedientesConGastos as $exp)
Expediente N° {{ $exp->numero_expediente }}

{{ $exp->materia }} @if($exp->tipo_proceso) · {{ $exp->tipo_proceso }} @endif @if($exp->estado) {{ $exp->estado }} @endif

Subtotal: S/ {{ number_format($exp->gastos->sum('monto'), 2) }}
@foreach($exp->gastos as $gas) @endforeach
Fecha Concepto Categoría Registrado por Monto
{{ $gas->fecha->format('d/m/Y') }} {{ $gas->concepto }} {{ $gas->categoria }} {{ optional($gas->user)->name ?? 'N/A' }} S/ {{ number_format($gas->monto, 2) }}
Subtotal Expediente: S/ {{ number_format($exp->gastos->sum('monto'), 2) }}
@empty @endforelse {{-- Gastos directos (sin expediente) --}} @if($gastosDirectos->count() > 0)
Gastos Generales del Cliente (sin expediente asignado)
S/ {{ number_format($gastosDirectos->sum('monto'), 2) }}
@foreach($gastosDirectos as $gas) @endforeach
Fecha Concepto Categoría Registrado por Monto
{{ $gas->fecha->format('d/m/Y') }} {{ $gas->concepto }} {{ $gas->categoria }} {{ optional($gas->user)->name ?? 'N/A' }} S/ {{ number_format($gas->monto, 2) }}
@endif @if($gastosDirectos->count() === 0 && $expedientesConGastos->count() === 0)

No se encontraron gastos para este cliente en el período seleccionado.

@endif {{-- Total general al pie --}} @if($montoTotal > 0)
TOTAL DE GASTOS S/ {{ number_format($montoTotal, 2) }}
@endif
{{-- ============ MODAL PREVISUALIZACIÓN WHATSAPP ============ --}} @section('styles') @endsection @section('scripts') @endsection @endsection