@php $tipoDocNombre = match($venta->tipo) { 'factura' => 'FACTURA ELECTRÓNICA', 'boleta' => 'BOLETA DE VENTA ELECTRÓNICA', 'nota_credito' => 'NOTA DE CRÉDITO ELECTRÓNICA', 'nota_debito' => 'NOTA DE DÉBITO ELECTRÓNICA', 'guia_remision' => 'GUÍA DE REMISIÓN REMITENTE', 'cotizacion' => 'COTIZACIÓN / PROFORMA', default => 'NOTA DE VENTA (TICKET INTERNO)', }; $tipoSunat = match($venta->tipo) { 'factura' => '01', 'boleta' => '03', 'nota_credito' => '07', 'nota_debito' => '08', 'guia_remision' => '09', default => '00' }; @endphp {{-- Encabezado: Datos Empresa y RUC / Tipo Comprobante --}}
@php $logoSrc = $config?->logo_base64; if (!$logoSrc && $config?->logo) { $paths = [ storage_path('app/public/' . $config->logo), public_path('storage/' . $config->logo), public_path($config->logo), base_path('../public_html/storage/' . $config->logo), base_path('../public_html/' . $config->logo), isset($_SERVER['DOCUMENT_ROOT']) ? rtrim($_SERVER['DOCUMENT_ROOT'], '/\\') . '/storage/' . $config->logo : null, isset($_SERVER['DOCUMENT_ROOT']) ? rtrim($_SERVER['DOCUMENT_ROOT'], '/\\') . '/' . $config->logo : null, ]; foreach ($paths as $p) { if ($p && file_exists($p) && is_file($p)) { $ext = strtolower(pathinfo($p, PATHINFO_EXTENSION)); $mime = match($ext) { 'png' => 'image/png', 'jpg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'svg' => 'image/svg+xml', 'webp' => 'image/webp', default => 'image/png', }; $data = @file_get_contents($p); if ($data) { $logoSrc = 'data:' . $mime . ';base64,' . base64_encode($data); break; } } } } @endphp @if ($logoSrc) @endif
{{ $config->nombre_comercial ?: $config->nombre_empresa }}
{{ $config->nombre_empresa }}
@if($config->direccion) {{ $config->direccion }}
@endif @if($config->poblacion || $config->provincia) {{ trim(($config->poblacion ?? '').' - '.($config->provincia ?? '').' - '.($config->pais ?? 'Perú')) }}
@endif @if($config->telefono) Tel: {{ $config->telefono }} | @endif @if($config->email) Email: {{ $config->email }} @endif
R.U.C. N° {{ $config->nif ?? '20000000001' }}
{{ $tipoDocNombre }}
{{ $venta->referencia }}
{{-- Datos del Cliente y Emisión --}}
SEÑOR(ES): {{ $venta->cliente ? $venta->cliente->nombre_completo : 'CLIENTES VARIOS' }} FECHA EMISIÓN: {{ $venta->fecha->format('d/m/Y H:i') }}
{{ ($venta->cliente && strlen($venta->cliente->nif) === 11) ? 'RUC:' : 'DNI / DOC:' }} {{ $venta->cliente?->nif ?: '00000000' }} MONEDA: SOLES (PEN)
DIRECCIÓN: {{ $venta->cliente?->direccion ?: '-' }} FORMA PAGO: {{ $venta->forma_pago === 'yape_plin' ? 'Yape / Plin' : $venta->forma_pago }}
{{-- Tabla de Artículos / Servicios --}} @foreach ($venta->detalles as $idx => $d) @endforeach
ITEM CANT. UNIDAD DESCRIPCIÓN P. UNIT TASA TOTAL
{{ $idx + 1 }} {{ number_format($d->cantidad, 0) }} NIU {{ $d->descripcion }} {{ formato_moneda($d->precio_unitario) }} {{ (float)$d->iva > 0 ? (number_format($d->iva, 0).'%') : 'EXON.' }} {{ formato_moneda($d->total) }}
{{-- Totales y Monto en Letras --}}
{{ numero_a_letras((float)$venta->total) }}
@if($venta->sunat_hash)
Resumen Hash: {{ $venta->sunat_hash }}
@endif @if($config->pie_ticket)
{{ $config->pie_ticket }}
@endif
@if ($venta->op_gravadas > 0) @endif @if ($venta->op_exoneradas > 0) @endif @if ($venta->descuento_importe > 0) @endif
Op. Gravadas: {{ formato_moneda($venta->op_gravadas) }}
Op. Exoneradas: {{ formato_moneda($venta->op_exoneradas) }}
Descuento: -{{ formato_moneda($venta->descuento_importe) }}
I.G.V. (18%): {{ formato_moneda($venta->iva_importe) }}
IMPORTE TOTAL: {{ formato_moneda($venta->total) }}
{{-- Pie Legal SUNAT con QR --}}