@extends('layouts.app') @section('content') @php use App\Enums\PriceType; use App\Enums\PriceTypeLoyer; use App\Enums\PriceTypeTravaux; use App\Enums\ProductState; use App\Enums\ProductType; use App\Enums\FloorType; use App\Enums\SurfaceType; use App\Enums\Fiscalite as FiscaliteEnum; use App\Enums\DocumentTypeLot; use App\Services\AppContext; @endphp
| Lot | Type | Niveau | Surface | Extérieur | Parking | Garage | Cave | @if($fiscaliteEnum === FiscaliteEnum::RESIDENCE_PRINCIPALE) {{-- Classique --}}Prix Parking TTC | Prix Cave TTC | Prix Vente TTC | @elseif($fiscaliteEnum === FiscaliteEnum::MALRAUX) {{-- Malraux --}}Prix Foncier | Travaux | Prix Parking TTC | Prix Garage TTC | Prix Cave TTC | Loyer Marché | Prix Vente Total | Subvention ANAH | @elseif($fiscaliteEnum === FiscaliteEnum::MONUMENT_HISTORIQUE) {{-- Monument Historique --}}Loyer Mensuel TTC | Prix Foncier | Travaux Déductibles | Travaux Non Déductibles | Travaux Total | Prix Parking TTC | Prix Garage TTC | Prix Cave TTC | Loyer Marché | Prix Vente Total | Subvention ANAH | @elseif($fiscaliteEnum === FiscaliteEnum::DEFICIT_FONCIER) {{-- Déficit Foncier --}}Prix Foncier | Travaux Déductibles | Travaux Total | Prix Cave TTC | Loyer Marché | Prix Vente Total | Subvention ANAH | @elseif($fiscaliteEnum === FiscaliteEnum::DENORMANDIE) {{-- Denormandie --}}Loyer Mensuel Denormandie | Prix Immo TTC | Prix Parking TTC | Prix Vente Total | @elseif($fiscaliteEnum === FiscaliteEnum::LMNP_SEVICES_AVEC_TVA || $fiscaliteEnum === FiscaliteEnum::LMNP_SEVICES_SANS_TVA) {{-- LMNP Services --}}Loyer Annuel HT | Prix Immo HT | Prix Mobilier HT | Prix Parking HT | Prix Garage HT | Loyer Marché | Prix Vente Total HT | Rentabilité Locative | @elseif($fiscaliteEnum === FiscaliteEnum::LMNP_NEUF || $fiscaliteEnum === FiscaliteEnum::LMNP_ANCIEN) {{-- LMNP Neuf/Ancien --}}Loyer Annuel HT | Prix Immo HT | Prix Mobilier HT | Prix Parking HT | Prix Garage HT | Loyer Marché | Prix Vente Total HT | Rentabilité Locative | @endif||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $lot->number ?? '-' }} | {{ $lot->type ? $lot->type->label() : '-' }} | {{ $lot->floor ? $lot->floor->shortLabel() : '-' }} | {{ $surfaceHabitable > 0 ? number_format($surfaceHabitable, 0, ',', ' ') . ' m²' : '-' }} | {!! $hasExterieur ? '' : '' !!} | {!! $hasParking ? '' : '' !!} | {!! $hasGarage ? '' : '' !!} | {!! $hasCave ? '' : '' !!} | @if($fiscaliteEnum === FiscaliteEnum::RESIDENCE_PRINCIPALE) {{-- Classique --}}@if($prixParkingTTC > 0){{ number_format($prixParkingTTC, 0, ',', ' ') }} €@endif | @if($prixCaveTTC > 0){{ number_format($prixCaveTTC, 0, ',', ' ') }} €@endif | @if($prixVenteTTC > 0){{ number_format($prixVenteTTC, 0, ',', ' ') }} €@endif | @elseif($fiscaliteEnum === FiscaliteEnum::MALRAUX) {{-- Malraux --}}@if($prixFoncier > 0){{ number_format($prixFoncier, 0, ',', ' ') }} €@endif | @if($prixTravauxTotal > 0){{ number_format($prixTravauxTotal, 0, ',', ' ') }} € {{ $prixVenteTotal > 0 ? round(($prixTravauxTotal / $prixVenteTotal) * 100) : 0 }} %@endif | @if($prixParkingTTC > 0){{ number_format($prixParkingTTC, 0, ',', ' ') }} €@endif | @if($prixGarageTTC > 0){{ number_format($prixGarageTTC, 0, ',', ' ') }} €@endif | @if($prixCaveTTC > 0){{ number_format($prixCaveTTC, 0, ',', ' ') }} €@endif | @if($loyerMensuelTTC > 0){{ number_format($loyerMensuelTTC, 0, ',', ' ') }} €@endif | @if($prixVenteTotal > 0){{ number_format($prixVenteTotal, 0, ',', ' ') }} €@endif | @if($lot->subvention_anah){{ $lot->subvention_anah }}@endif | @elseif($fiscaliteEnum === FiscaliteEnum::MONUMENT_HISTORIQUE) {{-- Monument Historique --}}@if($loyerMensuelTTC > 0){{ number_format($loyerMensuelTTC, 0, ',', ' ') }} €@endif | @if($prixFoncier > 0){{ number_format($prixFoncier, 0, ',', ' ') }} €@endif | @if($montantTravauxCommTTC > 0){{ number_format($montantTravauxCommTTC, 0, ',', ' ') }} € {{ ($prixVenteTotal - $prixParkingTTC) > 0 ? round(($montantTravauxCommTTC / ($prixVenteTotal - $prixParkingTTC)) * 100) : 0 }} %@endif |
@if($montantTravauxPrivTTC > 0){{ number_format($montantTravauxPrivTTC, 0, ',', ' ') }} €@endif | @if($prixTravauxTotal > 0){{ number_format($prixTravauxTotal, 0, ',', ' ') }} €@endif | @if($prixParkingTTC > 0){{ number_format($prixParkingTTC, 0, ',', ' ') }} €@endif | @if($prixGarageTTC > 0){{ number_format($prixGarageTTC, 0, ',', ' ') }} €@endif | @if($prixCaveTTC > 0){{ number_format($prixCaveTTC, 0, ',', ' ') }} €@endif | @if($loyerMensuel > 0){{ number_format($loyerMensuel, 0, ',', ' ') }} €@endif | @if($prixVenteTotal > 0){{ number_format($prixVenteTotal, 0, ',', ' ') }} €@endif | @if($lot->subvention_anah){{ $lot->subvention_anah }}@endif | @elseif($fiscaliteEnum === FiscaliteEnum::DEFICIT_FONCIER) {{-- Déficit Foncier --}} @php // Pour Déficit Foncier, calculer le prix cave TTC depuis les annexes (comme pour Malraux) // S'assurer que les annexes et leurs prix sont chargés if (!$lot->relationLoaded('annexes')) { $lot->load('annexes'); } if (!$lot->relationLoaded('annexes.prices')) { $lot->load('annexes.prices'); } // Grouper les annexes par type $groupedAnnexesDeficit = $lotAnnexes->groupBy(function($annexe) { try { return $annexe->type ? $annexe->type->value : 'unknown'; } catch (\Throwable $e) { return 'unknown'; } }); $caveAnnexesDeficit = $groupedAnnexesDeficit->get(ProductType::CAVE->value, collect()); // Calculer le prix total des caves depuis les annexes $prixCaveTTCFromAnnexes = 0; foreach ($caveAnnexesDeficit as $cave) { $prixCaveTTCFromAnnexes += $cave->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } // Utiliser le prix des annexes si disponible, sinon celui du lot $prixCaveTTCFinal = $prixCaveTTCFromAnnexes > 0 ? $prixCaveTTCFromAnnexes : $prixCaveTTC; // Loyer marché = loyer_mensuel ou loyer_mensuel_ttc $loyerMarche = $lotPrices->where('type', 'loyer_mensuel')->first()?->value ?? 0; if ($loyerMarche == 0) { $loyerMarche = $lotPrices->where('type', PriceTypeLoyer::MENSUEL_TTC->value)->first()?->value ?? 0; } @endphp@if($prixFoncier > 0){{ number_format($prixFoncier, 0, ',', ' ') }} €@endif | @if($montantTravauxCommTTC > 0){{ number_format($montantTravauxCommTTC, 0, ',', ' ') }} € {{ ($prixVenteTotal - $prixParkingTTC) > 0 ? round(($montantTravauxCommTTC / ($prixVenteTotal - $prixParkingTTC)) * 100) : 0 }} %@endif |
@if($prixTravauxTotal > 0){{ number_format($prixTravauxTotal, 0, ',', ' ') }} €@endif | @if($prixCaveTTCFinal > 0){{ number_format($prixCaveTTCFinal, 0, ',', ' ') }} €@else-@endif | @if($loyerMarche > 0){{ number_format($loyerMarche, 0, ',', ' ') }} €@else-@endif | @if($prixVenteTotal > 0){{ number_format($prixVenteTotal, 0, ',', ' ') }} €@endif | @if($lot->subvention_anah){{ $lot->subvention_anah }}@endif | @elseif($fiscaliteEnum === FiscaliteEnum::DENORMANDIE) {{-- Denormandie --}} @php // Pour Denormandie, calculer les prix des annexes depuis les annexes elles-mêmes (comme pour Malraux) // S'assurer que les annexes et leurs prix sont chargés if (!$lot->relationLoaded('annexes')) { $lot->load('annexes'); } if (!$lot->relationLoaded('annexes.prices')) { $lot->load('annexes.prices'); } // Grouper les annexes par type $groupedAnnexesDenormandie = $lotAnnexes->groupBy(function($annexe) { try { return $annexe->type ? $annexe->type->value : 'unknown'; } catch (\Throwable $e) { return 'unknown'; } }); $parkingAnnexesDenormandie = $groupedAnnexesDenormandie->get(ProductType::PARKING->value, collect()); // Calculer le prix total des parkings depuis les annexes $prixParkingTTCFromAnnexes = 0; foreach ($parkingAnnexesDenormandie as $parking) { $prixParkingTTCFromAnnexes += $parking->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } // Utiliser le prix des annexes si disponible, sinon celui du lot $prixParkingTTCFinal = $prixParkingTTCFromAnnexes > 0 ? $prixParkingTTCFromAnnexes : $prixParkingTTC; @endphp@if($loyerMensuelDenormandieTTC > 0){{ number_format($loyerMensuelDenormandieTTC, 0, ',', ' ') }} €@endif | @if($prixImmobilierTTC > 0){{ number_format($prixImmobilierTTC, 0, ',', ' ') }} €@else-@endif | @if($prixParkingTTCFinal > 0){{ number_format($prixParkingTTCFinal, 0, ',', ' ') }} €@else-@endif | @if($prixVenteTotal > 0){{ number_format($prixVenteTotal, 0, ',', ' ') }} €@endif | @elseif($fiscaliteEnum === FiscaliteEnum::LMNP_SEVICES_AVEC_TVA || $fiscaliteEnum === FiscaliteEnum::LMNP_SEVICES_SANS_TVA) {{-- LMNP Services --}} @php $prixVenteTotalHT = ($prixVenteHT + $prixGarageHT + $prixParkingHT); $rentabiliteLocative = ($loyerAnnuelHT > 0 && $prixVenteTotalHT > 0) ? round(($loyerAnnuelHT / $prixVenteTotalHT) * 100) : 0; @endphp@if($loyerAnnuelHT > 0){{ number_format($loyerAnnuelHT, 0, ',', ' ') }} €@endif | @if($prixImmobilierHT > 0){{ number_format($prixImmobilierHT, 0, ',', ' ') }} €@endif | @if($prixMobilierHT > 0){{ number_format($prixMobilierHT, 0, ',', ' ') }} €@endif | @if($prixParkingHT > 0){{ number_format($prixParkingHT, 0, ',', ' ') }} €@endif | @if($prixGarageHT > 0){{ number_format($prixGarageHT, 0, ',', ' ') }} €@endif | @if($loyerMensuel > 0){{ number_format($loyerMensuel, 0, ',', ' ') }} €@endif | @if($prixVenteTotalHT > 0){{ number_format($prixVenteTotalHT, 0, ',', ' ') }} €@endif | @if($rentabiliteLocative > 0){{ number_format($rentabiliteLocative, 0, ',', ' ') }} %@endif | @elseif($fiscaliteEnum === FiscaliteEnum::LMNP_NEUF || $fiscaliteEnum === FiscaliteEnum::LMNP_ANCIEN) {{-- LMNP Neuf/Ancien --}} @php $prixVenteTotalHT = ($prixVenteHT + $prixGarageHT + $prixParkingHT); $rentabiliteLocative = ($loyerAnnuelHT > 0 && $prixVenteTotalHT > 0) ? round(($loyerAnnuelHT / $prixVenteTotalHT) * 100) : 0; @endphp@if($loyerAnnuelHT > 0){{ number_format($loyerAnnuelHT, 0, ',', ' ') }} €@endif | @if($prixImmobilierHT > 0){{ number_format($prixImmobilierHT, 0, ',', ' ') }} €@endif | @if($prixMobilierHT > 0){{ number_format($prixMobilierHT, 0, ',', ' ') }} €@endif | @if($prixParkingHT > 0){{ number_format($prixParkingHT, 0, ',', ' ') }} €@endif | @if($prixGarageHT > 0){{ number_format($prixGarageHT, 0, ',', ' ') }} €@endif | @if($loyerMensuel > 0){{ number_format($loyerMensuel, 0, ',', ' ') }} €@endif | @if($prixVenteTotalHT > 0){{ number_format($prixVenteTotalHT, 0, ',', ' ') }} €@endif | @if($rentabiliteLocative > 0){{ number_format($rentabiliteLocative, 0, ',', ' ') }} %@endif | @endif@php $availableRang = $lot->available_option_rang ?? null; @endphp @if($state) @if($stateValue === ProductState::VENDU->value) @elseif($stateValue === ProductState::ALLOTE->value) @elseif($availableRang === null) @elseif($availableRang === 1) @elseif($availableRang === 2) @else @endif @else @if($availableRang === null) @elseif($availableRang === 1) @elseif($availableRang === 2) @else @endif @endif |
{{ $lot->type ? $lot->type->label() : '-' }} | {{ $lot->floor ? $lot->floor->shortLabel() : '-' }} | {{ $surfaceHabitable > 0 ? number_format($surfaceHabitable, 0, ',', ' ') . ' m²' : '-' }}
Prix total