@extends('layouts.public-quote') @section('content')

🙌 ¡Muchas Gracias por tu interés en nuestro proyecto!
{{ $quote->property->fractional->project->name ?? 'Proyecto' }}

📝 Aquí tienes los detalles de tu cotización.
📞 Si tienes alguna pregunta, no dudes en contactarnos.

{{-- ÁREA A IMPRIMIR --}}
{{-- ENCABEZADO CON LOGO Y DATOS DE LA EMPRESA DEL PROYECTO --}} @php $project = $quote->property->fractional->project; $fractional = $quote->property->fractional ?? null; $section = $fractional?->section; @endphp
{{-- Columna 1: Logo --}}
@if($project?->company_logo)
Logotipo
@else Logo @endif
{{-- Columna 2: Vacía --}}
{{-- Columna 3: Datos de contacto --}}

{{ $project->company_name ?? 'Fractional SJ' }}

@if($project?->company_address)

{{ $project->company_address }}

@endif @if($project?->company_phone)

📞 {{ $project->company_phone }}

@endif @if($project?->company_email)

✉️ {{ $project->company_email }}

@endif
{{-- TÍTULO --}}

Cotización #{{ $quote->slug }}

{{-- SECCIÓN 1: CLIENTE --}}

Datos del Cliente

Nombre: {{ $quote->lead->form_data['name'] ?? '-' }} {{ $quote->lead->form_data['last_name'] ?? '' }}

Email: {{ $quote->lead->form_data['email'] ?? '-' }}

Teléfono: {{ $quote->lead->form_data['country_code'] ?? '' }} {{ $quote->lead->form_data['phone_number'] ?? '' }}

Ubicación: {{ $quote->lead->form_data['location'] ?? '-' }}

Broker: {{ $quote->lead->form_data['is_broker'] ?? '-' }}

Intención de compra: {{ $quote->lead->form_data['purchase_intent'] ?? '-' }}

{{-- SECCIÓN 2: PROPIEDAD --}}

Proyecto: {{ $project->name ?? '—' }}

Sección: {{ $section->code ?? '—' }}

Propiedad: {{ $quote->property->code ?? '-' }}

Tipo: {{ $quote->property->propertyType->name ?? '-' }}

Área total: {{ $quote->property->propertyType->area }} m²

Área techada: {{ $quote->property->propertyType->area_roofed ?? '-' }} m²

@if(($quote->property->propertyType->area_garden ?? 0) > 0)

Área de jardín: {{ $quote->property->propertyType->area_garden }} m²

@endif
{{-- Imagen del Tipo de Propiedad --}} @if($quote->property->propertyType?->image_url)
Imagen de tipo de propiedad
@endif {{-- SECCIÓN 3: COTIZACIÓN --}} @php $montoEnganche = $quote->price * ($quote->advance_percentage / 100); $totalInicial = $montoEnganche + 30000; @endphp
Mes de ocupación: {{ $meses[$quote->month] ?? ucfirst($quote->month) }}
Precio total de la propiedad: ${{ number_format($quote->price, 2) }} MXN
Apartado no reembolsable: $30,000.00 MXN
Enganche: ${{ number_format($montoEnganche, 2) }} MXN ({{ $quote->advance_percentage }}%)
Total inicial (enganche + apartado): ${{ number_format($totalInicial, 2) }} MXN
Pago mensual ({{ $quote->installment_months ?? 48 }} meses): ${{ number_format($quote->monthly_payment, 2) }} MXN
{{-- SECCIÓN 4: TABLA DE AMORTIZACIÓN --}}
@php // ====== Parámetros base ====== $price = (float) $quote->price; $advancePct = (float) $quote->advance_percentage; $enganche = $price * ($advancePct / 100.0); $apartado = 30000.0; // no reembolsable (no reduce el saldo financiado) $months = (int) ($quote->installment_months ?? 48); if ($months <= 0) { $months = 48; } $annualRate = (float) ($quote->used_annual_interest_rate ?? 0.0); $monthlyRate = $annualRate > 0 ? ($annualRate / 100.0) / 12.0 : 0.0; // Saldo financiado (coincide con tu JS: restante = price - enganche) $financed = max($price - $enganche, 0); // Pago mensual: usa el guardado; si no existe, se calcula if (!empty($quote->monthly_payment)) { $payment = (float) $quote->monthly_payment; } else { $payment = $monthlyRate > 0 ? ($financed * ($monthlyRate * pow(1 + $monthlyRate, $months)) / (pow(1 + $monthlyRate, $months) - 1)) : ($months > 0 ? $financed / $months : 0); } // Construcción de amortización (sin mostrar interés, pero respetándolo si existe) $amortization = []; $remaining = $financed; for ($i = 1; $i <= $months; $i++) { if ($monthlyRate > 0) { $interest = $remaining * $monthlyRate; $principalPay = min(max($payment - $interest, 0), $remaining); $actualPay = $principalPay + $interest; // por si el último mes ajusta centavos } else { $interest = 0.0; $principalPay = min($payment, $remaining); $actualPay = $principalPay; } $remaining = max($remaining - $principalPay, 0.0); $amortization[] = [ 'month' => $i, 'payment' => $actualPay, 'balance' => $remaining, ]; } // Partición en dos columnas: mitad y mitad (dinámico según $months) $split = (int) ceil($months / 2); @endphp {{-- Encabezado --}}

Tabla de Amortización

Saldo financiado: ${{ number_format($financed, 2) }} MXN
{{-- Tabla de amortización dividida en dos columnas --}}
{{-- Columna 1 --}}
@foreach ($amortization as $idx => $item) @if ($idx < $split) @endif @endforeach
Mes Pago Mensual Saldo Restante
{{ $item['month'] }} ${{ number_format($item['payment'], 2) }} ${{ number_format($item['balance'], 2) }}
{{-- Columna 2 --}}
@foreach ($amortization as $idx => $item) @if ($idx >= $split) @endif @endforeach
Mes Pago Mensual Saldo Restante
{{ $item['month'] }} ${{ number_format($item['payment'], 2) }} ${{ number_format($item['balance'], 2) }}
{{-- BOTONES --}}
← Volver
@endsection