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)
@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
@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 --}}
| Mes |
Pago Mensual |
Saldo Restante |
@foreach ($amortization as $idx => $item)
@if ($idx < $split)
| {{ $item['month'] }} |
${{ number_format($item['payment'], 2) }} |
${{ number_format($item['balance'], 2) }} |
@endif
@endforeach
{{-- Columna 2 --}}
| Mes |
Pago Mensual |
Saldo Restante |
@foreach ($amortization as $idx => $item)
@if ($idx >= $split)
| {{ $item['month'] }} |
${{ number_format($item['payment'], 2) }} |
${{ number_format($item['balance'], 2) }} |
@endif
@endforeach