@php $tabs = $tabs ?? []; $activePaneId = $tabs[0]['pane_id'] ?? null; @endphp @if (empty($tabs))

Aucun total disponible pour ce lot.

@else
@php $activeFiscaliteValue = null; $activeFiscaliteLabel = null; foreach ($tabs as $index => $tab) { $paneId = $tab['pane_id'] ?? null; if (! $paneId || $paneId !== $activePaneId) { continue; } $result = $tab['result'] ?? []; $activeFiscaliteValue = $result['fiscalites'][$index]['value'] ?? ($result['fiscalite_utilisee']['value'] ?? null); if (! $activeFiscaliteValue && ($result['sans_fiscalite'] ?? false)) { $activeFiscaliteValue = 'sans_fiscalite'; } $activeFiscaliteLabel = $tab['tab_label'] ?? ('Fiscalité '.($index + 1)); break; } if ($activeFiscaliteLabel === null) { $activeFiscaliteLabel = 'Fiscalité'; } @endphp
@foreach ($tabs as $index => $tab) @php $paneId = $tab['pane_id']; $result = $tab['result'] ?? []; $fiscaliteValue = $result['fiscalites'][$index]['value'] ?? ($result['fiscalite_utilisee']['value'] ?? null); if (! $fiscaliteValue && ($result['sans_fiscalite'] ?? false)) { $fiscaliteValue = 'sans_fiscalite'; } @endphp @endforeach
@foreach ($tabs as $tab) @php $paneId = $tab['pane_id']; $isActive = $paneId === $activePaneId; $result = $tab['result'] ?? []; $note = $result['note'] ?? null; $total = (float) ($result['total'] ?? 0); $lignes = is_array($result['lignes'] ?? null) ? $result['lignes'] : []; $financement = is_array($result['financement'] ?? null) ? $result['financement'] : []; // Masquer les lignes "Prix des annexes" si (inclus + non inclus) = 0 $annexesNonInclus = 0.0; $annexesInclus = 0.0; foreach ($lignes as $ligne) { $code = (string) ($ligne['code'] ?? ''); if ($code === 'annexes_ttc') { $annexesNonInclus = (float) ($ligne['montant'] ?? 0); } elseif ($code === 'annexes_ttc_inclus') { $annexesInclus = (float) ($ligne['montant'] ?? 0); } } $hideAnnexesSection = ($annexesNonInclus <= 0) && ($annexesInclus <= 0); if ($hideAnnexesSection) { $lignes = array_values(array_filter($lignes, function ($ligne): bool { $code = (string) ($ligne['code'] ?? ''); return ! str_starts_with($code, 'annexes_'); })); } // Masquer les lignes annexes à 0 (non incluses / incluses) $lignes = array_values(array_filter($lignes, function ($ligne): bool { $code = (string) ($ligne['code'] ?? ''); if (! str_starts_with($code, 'annexes_')) { return true; } return (float) ($ligne['montant'] ?? 0) > 0; })); $sections = [ 'Prix immo' => [], 'Prix du foncier' => [], 'Prix des travaux' => [], 'Prix des annexes' => [], 'Autres' => [], ]; foreach ($lignes as $ligne) { $code = (string) ($ligne['code'] ?? ''); if (str_starts_with($code, 'immo_')) { $sections['Prix immo'][] = $ligne; continue; } if (str_starts_with($code, 'foncier_')) { $sections['Prix du foncier'][] = $ligne; continue; } if (str_starts_with($code, 'travaux_')) { $sections['Prix des travaux'][] = $ligne; continue; } if (str_starts_with($code, 'annexes_')) { $sections['Prix des annexes'][] = $ligne; continue; } $sections['Autres'][] = $ligne; } $finLignes = is_array($financement['lignes'] ?? null) ? $financement['lignes'] : []; $finAnnexesNonInclus = 0.0; $finAnnexesInclus = 0.0; foreach ($finLignes as $ligne) { $code = (string) ($ligne['code'] ?? ''); if ($code === 'annexes_ttc') { $finAnnexesNonInclus = (float) ($ligne['montant'] ?? 0); } elseif ($code === 'annexes_ttc_inclus') { $finAnnexesInclus = (float) ($ligne['montant'] ?? 0); } } $hideFinAnnexesSection = ($finAnnexesNonInclus <= 0) && ($finAnnexesInclus <= 0); if ($hideFinAnnexesSection) { $finLignes = array_values(array_filter($finLignes, function ($ligne): bool { $code = (string) ($ligne['code'] ?? ''); return ! str_starts_with($code, 'annexes_'); })); } // Masquer les lignes annexes à 0 (non incluses / incluses) $finLignes = array_values(array_filter($finLignes, function ($ligne): bool { $code = (string) ($ligne['code'] ?? ''); if (! str_starts_with($code, 'annexes_')) { return true; } return (float) ($ligne['montant'] ?? 0) > 0; })); $finSections = [ 'Prix du lot' => [], 'Prix du foncier' => [], 'Prix des annexes' => [], 'Frais' => [], 'Autres' => [], ]; foreach ($finLignes as $ligne) { $code = (string) ($ligne['code'] ?? ''); if ($code === 'prix_vente_total') { $finSections['Prix du lot'][] = $ligne; continue; } if (str_starts_with($code, 'foncier_')) { $finSections['Prix du foncier'][] = $ligne; continue; } if (str_starts_with($code, 'annexes_')) { $finSections['Prix des annexes'][] = $ligne; continue; } if ($code === 'frais_notaire') { $finSections['Frais'][] = $ligne; continue; } $finSections['Autres'][] = $ligne; } @endphp
@if (!empty($lignes))
Prix & fiscalité
Informations financières du lot
@foreach ($sections as $sectionTitle => $sectionLines) @if (!empty($sectionLines)) @foreach ($sectionLines as $ligne)
{{ $ligne['libelle'] ?? '' }}
{{ isset($ligne['montant']) ? number_format((float) $ligne['montant'], 0, ',', ' ') : '-' }} €
@endforeach @endif @endforeach
Total
{{ number_format($total, 0, ',', ' ') }} €
@else
Aucun détail disponible.
@endif {{-- décommenté pour afficher Prix de vente total --}} {{-- @if (!empty($financement))
Prix de vente total
Informations financières du lot
Financement
@if (!empty($financement['libelle']))
{{ $financement['libelle'] }}
@endif @foreach ($finSections as $sectionTitle => $sectionLines) @if (!empty($sectionLines)) @foreach ($sectionLines as $fl)
{{ $fl['libelle'] ?? '' }}
{{ isset($fl['montant']) ? number_format((float) $fl['montant'], 0, ',', ' ') : '-' }} €
@endforeach @endif @endforeach
Montant à financer
{{ isset($financement['montant']) ? number_format((float) $financement['montant'], 0, ',', ' ') : '-' }} €
@endif --}} @if ($note)
{{ $note }}
@endif
@endforeach
@endif