@extends('layouts.app') @section('titulo', 'Cotización ' . $cotizacion->numero) @section('subtitulo', 'Detalle de la propuesta comercial y acciones') @section('content') @php $urlPublica = $cotizacion->url_publica; $nombreCliente = $cotizacion->cliente ? ($cotizacion->cliente->nombre_completo ?? $cotizacion->cliente->nombre) : 'Estimado cliente'; $empresa = $config->nombre_comercial ?? $config->nombre_empresa ?? 'Librería'; // Mensaje predeterminado profesional para WhatsApp $mensajeWhatsapp = "Hola {$nombreCliente}, le saludamos de *{$empresa}*. Le compartimos la cotización comercial *{$cotizacion->numero}* por el total de *" . formato_moneda($cotizacion->total) . "*.\n\nPuede ver y descargar su cotización en PDF aquí:\n{$urlPublica}"; $telefonoWhatsapp = preg_replace('/[^0-9]/', '', $cotizacion->cliente?->telefono ?? ''); if (strlen($telefonoWhatsapp) === 9) { $telefonoWhatsapp = '51' . $telefonoWhatsapp; } // Enlace a WhatsApp Desktop / App instalada en PC $whatsappLink = $telefonoWhatsapp ? "whatsapp://send?phone={$telefonoWhatsapp}&text=" . rawurlencode($mensajeWhatsapp) : "whatsapp://send?text=" . rawurlencode($mensajeWhatsapp); // Fallback web $whatsappWebLink = $telefonoWhatsapp ? "https://wa.me/{$telefonoWhatsapp}?text=" . rawurlencode($mensajeWhatsapp) : "https://api.whatsapp.com/send?text=" . rawurlencode($mensajeWhatsapp); @endphp
← Volver al listado Imprimir / Descargar PDF {{-- Enviar por WhatsApp (invoca WhatsApp Desktop / App de PC) --}} Enviar por WhatsApp {{-- Enviar por Correo Directo del Sistema --}}
@if ($cotizacion->estado !== 'facturada') Editar Cotización
@csrf
@else Ya Facturada @endif
{{-- Modal para Enviar Cotización por Correo --}}

Enviar Cotización por Correo

{{ $cotizacion->numero }}

@csrf

Se enviará el PDF adjunto y el enlace para descarga libre sin usuario ni contraseña.

De: {{ $config->nombre_comercial ?? 'Librería' }}

Propuesta: {{ $cotizacion->numero }} ({{ formato_moneda($cotizacion->total) }})

✓ Incluye documento PDF adjunto y enlace libre.

{{-- Columna Ficha de Información --}}
Cotización {{ $cotizacion->numero }}
Cliente:
{{ $cotizacion->cliente ? ($cotizacion->cliente->nombre_completo ?? $cotizacion->cliente->nombre) : 'Cliente Mostrador' }}
@if ($cotizacion->cliente?->nif)
RUC / DNI:
{{ $cotizacion->cliente->nif }}
@endif
Fecha Emisión:
{{ $cotizacion->fecha->format('d/m/Y') }}
Fecha Vencimiento:
{{ optional($cotizacion->fecha_vencimiento)->format('d/m/Y') ?? 'Sin vencimiento' }}
Validez Oferta:
{{ $cotizacion->validez_dias }}
Condición Pago:
{{ $cotizacion->condicion_pago }}
Emitida por:
{{ $cotizacion->user->name ?? 'Usuario' }}
Estado actual:
@php $badgeStyles = [ 'pendiente' => 'bg-amber-100 text-amber-800', 'aprobada' => 'bg-blue-100 text-blue-800', 'facturada' => 'bg-emerald-100 text-emerald-800', 'rechazada' => 'bg-rose-100 text-rose-800', 'vencida' => 'bg-slate-100 text-slate-700', ]; @endphp {{ $cotizacion->estado }}
{{-- Cambio de estado rápido --}} @if ($cotizacion->estado !== 'facturada')
@csrf
@endif
{{-- Desglose Financiero --}}

Liquidación

Subtotal: {{ formato_moneda($cotizacion->subtotal) }}
@if ($cotizacion->descuento_importe > 0)
Descuento ({{ $cotizacion->descuento_porcentaje }}%): - {{ formato_moneda($cotizacion->descuento_importe) }}
@endif
Op. Gravadas: {{ formato_moneda($cotizacion->op_gravadas) }}
Op. Exoneradas (Ley Libro): {{ formato_moneda($cotizacion->op_exoneradas) }}
IGV (18%): {{ formato_moneda($cotizacion->iva_importe) }}
Total Cotizado: {{ formato_moneda($cotizacion->total) }}
{{-- Columna Tabla de Productos --}}

Líneas de la Cotización

@foreach ($cotizacion->detalles as $det) @endforeach
Ítem Cant. P. Unitario Desc. IGV Total
{{ $det->descripcion }} @if ($det->producto?->codigo) Cód: {{ $det->producto->codigo }} @endif {{ $det->cantidad }} {{ formato_moneda($det->precio_unitario) }} {{ $det->descuento_porcentaje > 0 ? $det->descuento_porcentaje . '%' : '-' }} {{ $det->iva > 0 ? '18%' : 'Exon.' }} {{ formato_moneda($det->total) }}
@if ($cotizacion->observaciones)

Observaciones / Condiciones comerciales:

{{ $cotizacion->observaciones }}

@endif
@endsection