@extends('layouts.app') @section('title', $order->document_type . ' ' . $order->full_number) @section('content') @php $color = match($order->sunat_status) { 'ACCEPTED' => 'success', 'OBSERVED' => 'warning', 'PENDING' => 'secondary', 'VOIDED' => 'dark', default => 'danger', }; $colorHex = match($order->sunat_status) { 'ACCEPTED' => '#22c55e', 'OBSERVED' => '#f59e0b', 'PENDING' => '#6b7280', 'VOIDED' => '#1e1b3a', default => '#ef4444', }; @endphp
{{-- Encabezado --}}
Comprobantes

{{ $order->document_type }} {{ $order->full_number }}

@if($order->sunat_status === 'ACCEPTED') ✔ @elseif($order->sunat_status === 'PENDING') ⏳ @elseif($order->sunat_status === 'OBSERVED') ⚠ @else ✗ @endif {{ $order->sunat_status }}
{{ $order->created_at?->format('d/m/Y H:i') }}
{{-- Acciones --}}
PDF A4 Ticket 80mm @if($order->xml_path) XML @endif @if($order->cdr_path) CDR @endif @if(in_array($order->sunat_status, ['PENDING','ERROR','REJECTED']))
@csrf
@endif @if($order->sunat_status === 'ACCEPTED') Nota de Crédito @endif
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif
{{-- COLUMNA IZQUIERDA --}}
{{-- Detalle del comprobante --}}
DETALLE DEL COMPROBANTE
@foreach($order->details as $d) @endforeach
Cant Producto Precio Unit. Subtotal
{{ $d->quantity }} {{ $d->product->name ?? '—' }} S/ {{ number_format($d->price, 2) }} S/ {{ number_format($d->price * $d->quantity, 2) }}
Op. Gravada: S/ {{ number_format($order->total_gravada, 2) }}
IGV (18%): S/ {{ number_format($order->igv, 2) }}
TOTAL: S/ {{ number_format($order->total, 2) }}
{{-- Notas de crédito --}} @if($order->creditNotes->isNotEmpty())
Notas de Crédito
    @foreach($order->creditNotes as $cn)
  • {{ $cn->full_number }} — {{ $cn->reason_description }}
    {{ $cn->sunat_status }}
  • @endforeach
@endif
{{-- COLUMNA DERECHA --}}
{{-- Cliente --}}
Datos del Cliente
{{ strtoupper(substr($order->client_name ?? 'P', 0, 1)) }}
{{ $order->client_name ?? 'Público General' }}
{{ $order->document_type === 'Factura' ? 'RUC' : 'DNI' }}: {{ $order->client_document ?? '—' }}
{{ $order->table->name ?? 'POS Rápido' }} @php $pm = $order->payment_method ?? 'cash'; echo match($pm){'cash'=>'Efectivo','card'=>'Tarjeta','yape'=>'Yape','plin'=>'Plin','transferencia'=>'Transf.',default=>ucfirst($pm)}; @endphp {{ $order->created_at?->format('d/m/Y') }}
{{-- Trazabilidad SUNAT --}}
Trazabilidad SUNAT
{{-- Estado grande --}}
@if($order->sunat_status === 'ACCEPTED') ✔ ACEPTADO @elseif($order->sunat_status === 'PENDING') ⏳ PENDIENTE @elseif($order->sunat_status === 'OBSERVED') ⚠ OBSERVADO @elseif($order->sunat_status === 'VOIDED') 🚫 ANULADO @else ✗ ERROR @endif
@if($order->sunat_description) {{ $order->sunat_description }} @endif
@php $rows = [ ['Código SUNAT', $order->sunat_code ?? '—'], ['Hash', $order->hash ? substr($order->hash, 0, 20).'...' : '—'], ['Enviado', $order->sent_at?->format('d/m/Y H:i:s') ?? '—'], ['XML', $order->xml_path ? basename($order->xml_path) : '—'], ['CDR', $order->cdr_path ? basename($order->cdr_path) : '—'], ]; @endphp @foreach($rows as [$label, $value])
{{ $label }} {{ $value }}
@endforeach
@endsection