@extends('layouts.app') @section('content') @php use App\Enums\TaskType; use App\Enums\TaskState; use App\Enums\Civilite; use App\Enums\Country; use App\Enums\SituationMatrimoniale; use App\Enums\RegimeMatrimonial; use App\Enums\DocumentTypeReservation; use App\Enums\ContratTypeProgram; use App\Enums\Fiscalite as FiscaliteEnum; use App\Enums\DocumentStatus; use App\Enums\SurfaceType; use App\Enums\PriceType; use App\Enums\PriceTypeLoyer; use App\Enums\PriceTypeTravaux; use App\Enums\BuyingCompanyType; use App\Enums\ProductType; use App\Enums\PrestationProgram; use App\Simulator\Calculators\Malraux\MalrauxCore; @endphp

Fiche de réservation

Suivez l'avancement de votre réservation

@if(session('success')) @endif @if(session('error')) @endif
@php $client = $reservation->client; $phoneValue = ''; if ($client) { if (!$client->relationLoaded('phones')) { $client->load('phones'); } $clientPhone = $client->phones->first(); $phoneValue = $clientPhone ? $clientPhone->value : ''; } // Informations du lot $lotNumber = $lot ? ($lot->number ?? '-') : '-'; $programName = $program ? $program->name : '-'; $lotType = $lot && $lot->type ? $lot->type->label() : '-'; // Surface habitable (même logique que le BO via Product::getSurfaceAttribute()) $surfaceHabitable = '-'; if ($lot) { $surfaceValue = $lot->surface; $surfaceHabitable = $surfaceValue !== null && $surfaceValue > 0 ? number_format($surfaceValue, 2, ',', ' ') . ' m²' : '-'; } // Prix TTC $prixTTC = '-'; $prixTravauxTTC = '-'; if ($lot) { if (!$lot->relationLoaded('prices')) { $lot->load('prices'); } $prixTTCValue = $lot->getPrixLotTTC(); $prixTravauxHorsReadOnly = $lot->getTotalTravaux(); $prixTotal = $prixTTCValue + $prixTravauxHorsReadOnly; $prixTTC = $prixTotal > 0 ? number_format($prixTotal, 0, ',', ' ') . ' €' : '-'; $prixTravauxTTC = $prixTravauxHorsReadOnly > 0 ? number_format($prixTravauxHorsReadOnly, 0, ',', ' ') . ' €' : '-'; } // Etage $etage = '-'; if ($lot && $lot->floor) { $etage = $lot->floor->label(); } // Batiment $batiment = '-'; if ($lot && $lot->building_number) { $batiment = $lot->building_number; } // Surface loi Carrez (Surface moins d'1 m²80) $surfaceCarrez = '-'; if ($lot) { if (!$lot->relationLoaded('surfaces')) { $lot->load('surfaces'); } $surfaceCarrezObj = $lot->surfaces->where('type', SurfaceType::SURFACE_180->value)->first(); $surfaceCarrez = $surfaceCarrezObj && $surfaceCarrezObj->value > 0 ? number_format($surfaceCarrezObj->value, 0, ',', ' ') . ' m²' : '-'; } // Surfaces des annexes (balcon, terrasse, jardin) + surfaces détaillées $surfaceAnnexes = '-'; $surfaceBalconDetail = '-'; $surfaceTerrasseDetail = '-'; $surfaceJardinDetail = '-'; $surfaceCaveDetail = '-'; $surfaceParkingDetail = '-'; // Annexes : numéros (parking/garage/cave) $parkingNumbersDisplay = '-'; $garageNumbersDisplay = '-'; $caveNumbersDisplay = '-'; // Ascenseur / orientation $ascenseurLabel = '-'; $orientationDisplay = '-'; // Prix du foncier $prixFoncier = '-'; // Prix parking / garage / cave $prixParking = '-'; $prixGarage = '-'; $prixCave = '-'; // Type parking $typeParking = '-'; if ($lot) { // Charger les relations nécessaires if (!$lot->relationLoaded('surfaces')) { $lot->load('surfaces'); } if (!$lot->relationLoaded('annexes')) { $lot->load('annexes.surfaces'); } if (!$lot->relationLoaded('orientations')) { $lot->load('orientations'); } if (!$lot->relationLoaded('prices')) { $lot->load('prices'); } $lotAnnexes = $lot->annexes; $lotSurfaces = $lot->surfaces; $lotOrientations = $lot->orientations; $lotPrices = $lot->prices; // Annexes de type balcon / terrasse / jardin $balconAnnexes = $lotAnnexes->filter(function($annexe) { return $annexe->type && $annexe->type->value === ProductType::BALCON->value; }); $terrasseAnnexe = $lotAnnexes->filter(function($annexe) { return $annexe->type && $annexe->type->value === ProductType::TERRASSE->value; })->first(); $jardinAnnexe = $lotAnnexes->filter(function($annexe) { return $annexe->type && $annexe->type->value === ProductType::JARDIN->value; })->first(); // Surfaces balcon $surfaceBalcon = 0; foreach ($balconAnnexes as $balcon) { $surfaceAnnexe = $balcon->surfaces->where('type', SurfaceType::ANNEXE->value)->first()?->value ?? 0; $surfaceHabitable = $balcon->surfaces->where('type', SurfaceType::HABITABLE->value)->first()?->value ?? 0; $surfaceBalcon += $surfaceAnnexe > 0 ? $surfaceAnnexe : $surfaceHabitable; } $surfaceBalconDetail = $surfaceBalcon > 0 ? number_format($surfaceBalcon, 2, ',', ' ') . ' m²' : '-'; // Surface terrasse $surfaceTerrasse = 0; if ($terrasseAnnexe) { $surfaceAnnexe = $terrasseAnnexe->surfaces->where('type', SurfaceType::ANNEXE->value)->first()?->value ?? 0; $surfaceHabitable = $terrasseAnnexe->surfaces->where('type', SurfaceType::HABITABLE->value)->first()?->value ?? 0; $surfaceTerrasse = $surfaceAnnexe > 0 ? $surfaceAnnexe : $surfaceHabitable; } $surfaceTerrasseDetail = $surfaceTerrasse > 0 ? number_format($surfaceTerrasse, 2, ',', ' ') . ' m²' : '-'; // Surface jardin $surfaceJardin = 0; if ($jardinAnnexe) { $surfaceAnnexe = $jardinAnnexe->surfaces->where('type', SurfaceType::ANNEXE->value)->first()?->value ?? 0; $surfaceHabitable = $jardinAnnexe->surfaces->where('type', SurfaceType::HABITABLE->value)->first()?->value ?? 0; $surfaceJardin = $surfaceAnnexe > 0 ? $surfaceAnnexe : $surfaceHabitable; } $surfaceJardinDetail = $surfaceJardin > 0 ? number_format($surfaceJardin, 2, ',', ' ') . ' m²' : '-'; $surfaceAnnexesTotal = $surfaceBalcon + $surfaceTerrasse; $surfaceAnnexes = $surfaceAnnexesTotal > 0 ? number_format($surfaceAnnexesTotal, 2, ',', ' ') . ' m²' : '-'; // Grouper les annexes par type $groupedAnnexes = $lotAnnexes->groupBy(function($annexe) { try { return $annexe->type ? $annexe->type->value : 'unknown'; } catch (\Throwable $e) { return 'unknown'; } }); $parkingAnnexes = $groupedAnnexes->get(ProductType::PARKING->value, collect()); $garageAnnexes = $groupedAnnexes->get(ProductType::GARAGE->value, collect()); $caveAnnexes = $groupedAnnexes->get(ProductType::CAVE->value, collect()); // Récupérer les numéros (tous les numéros non vides) $parkingNumbers = $parkingAnnexes->map(function($annexe) { return $annexe->number ?? null; })->filter(function($number) { return !empty($number) && $number !== null; })->values(); $garageNumbers = $garageAnnexes->map(function($annexe) { return $annexe->number ?? null; })->filter(function($number) { return !empty($number) && $number !== null; })->values(); $caveNumbers = $caveAnnexes->map(function($annexe) { return $annexe->number ?? null; })->filter(function($number) { return !empty($number) && $number !== null; })->values(); $parkingNumbersDisplay = $parkingNumbers->isNotEmpty() ? $parkingNumbers->implode(', ') : '-'; $garageNumbersDisplay = $garageNumbers->isNotEmpty() ? $garageNumbers->implode(', ') : '-'; $caveNumbersDisplay = $caveNumbers->isNotEmpty() ? $caveNumbers->implode(', ') : '-'; // Surface cave (somme de toutes les caves) $surfaceCave = 0; foreach ($caveAnnexes as $cave) { $surfaceAnnexe = $cave->surfaces->where('type', SurfaceType::ANNEXE->value)->first()?->value ?? 0; $surfaceHabitable = $cave->surfaces->where('type', SurfaceType::HABITABLE->value)->first()?->value ?? 0; $surfaceCave += $surfaceAnnexe > 0 ? $surfaceAnnexe : $surfaceHabitable; } $surfaceCaveDetail = $surfaceCave > 0 ? number_format($surfaceCave, 2, ',', ' ') . ' m²' : '-'; // Surface parking (somme de tous les parkings) $surfaceParking = 0; foreach ($parkingAnnexes as $parking) { $surfaceAnnexe = $parking->surfaces->where('type', SurfaceType::ANNEXE->value)->first()?->value ?? 0; $surfaceHabitable = $parking->surfaces->where('type', SurfaceType::HABITABLE->value)->first()?->value ?? 0; $surfaceParking += $surfaceAnnexe > 0 ? $surfaceAnnexe : $surfaceHabitable; } $surfaceParkingDetail = $surfaceParking > 0 ? number_format($surfaceParking, 2, ',', ' ') . ' m²' : '-'; // Ascenseur $hasElevator = false; if ($program) { if (!$program->relationLoaded('prestations')) { $program->load('prestations'); } $hasElevator = $program->prestations->contains(function($prestation) { return $prestation->type && $prestation->type->value === PrestationProgram::ASCENSEUR->value; }); } $ascenseurLabel = $hasElevator ? 'Oui' : 'Non'; // Orientation $orientationList = $lotOrientations->map(function($orientation) { return $orientation->type ? $orientation->type->label() : null; })->filter()->implode(', '); $orientationDisplay = !empty($orientationList) ? $orientationList : '-'; // Prix du foncier $prixFoncierValue = $lot->getPrixFoncier(); $prixFoncier = $prixFoncierValue > 0 ? number_format($prixFoncierValue, 0, ',', ' ') . ' €' : '-'; // Prix parking / garage / cave $prixParkingValue = $lot->prices->where('type', 'prix_parking_ttc')->first()?->value ?? 0; $prixGarageValue = $lot->prices->where('type', 'prix_garage_ttc')->first()?->value ?? 0; $prixCaveValue = $lot->prices->where('type', 'prix_cave_ttc')->first()?->value ?? 0; $prixParking = $prixParkingValue > 0 ? number_format($prixParkingValue, 0, ',', ' ') . ' €' : '-'; $prixGarage = $prixGarageValue > 0 ? number_format($prixGarageValue, 0, ',', ' ') . ' €' : '-'; $prixCave = $prixCaveValue > 0 ? number_format($prixCaveValue, 0, ',', ' ') . ' €' : '-'; // Type parking depuis les datas JSON $infoParking = $lot->datas?->first()?->json['info_parking'] ?? null; $typeParking = $infoParking ? $infoParking : '-'; } @endphp
Résumé client
@if($client)

{{ $client->civility ? $client->civility->label() . ' ' : '' }}{{ $client->lastname ?? '' }} {{ $client->firstname ?? '' }}

@if($client->email)

{{ $client->email }}

@endif @if($phoneValue)

{{ $phoneValue }}

@endif
@if($client->token) @endif @else

Aucun client associé à cette réservation.

@endif
Résumé lot
@if($lot)
  • Informations sur le lot
  • N° de lot : {!! $lot->number ? '' . e($lot->number) . '' : '/' !!}
  • Type : {!! $lot->type ? '' . e($lot->type->label()) . '' : '/' !!}
  • Niveau : {!! $lot->floor ? '' . e($lot->floor->label()) . '' : '/' !!}
  • Surface habitable : {!! $surfaceHabitable !== '-' ? '' . e($surfaceHabitable) . '' : '/' !!}
  • @php $surfaceMoins180 = $lotSurfaces->where('type', SurfaceType::SURFACE_180->value)->first()?->value ?? 0; @endphp
  • Surface moins d'1 m280 : {!! $surfaceMoins180 > 0 ? '' . number_format($surfaceMoins180, 0, ',', ' ') . ' m²' : '/' !!}
  • Surface balcon : {!! $surfaceBalcon > 0 ? '' . number_format($surfaceBalcon, 2, ',', ' ') . ' m²' : '/' !!}
  • Surface terrasse : {!! $surfaceTerrasse > 0 ? '' . number_format($surfaceTerrasse, 2, ',', ' ') . ' m²' : '/' !!}
  • Surface jardin : {!! $surfaceJardin > 0 ? '' . number_format($surfaceJardin, 2, ',', ' ') . ' m²' : '/' !!}
  • N° bâtiment : {!! $lot->building_number ? '' . e($lot->building_number) . '' : '/' !!}
  • @php // Vérifier si le programme a la prestation ascenseur $hasElevator = false; if ($program && $program->relationLoaded('prestations')) { $hasElevator = $program->prestations->contains(function($prestation) { return $prestation->type && $prestation->type->value === PrestationProgram::ASCENSEUR->value; }); } elseif ($program) { $hasElevator = $program->prestations()->where('type', PrestationProgram::ASCENSEUR->value)->exists(); } @endphp
  • Ascenseur : {!! $hasElevator ? 'Oui' : 'Non' !!}
  • @php $orientationList = $lotOrientations->map(function($orientation) { return $orientation->type ? $orientation->type->label() : null; })->filter()->implode(', '); @endphp
  • Orientation : {!! !empty($orientationList) ? '' . e($orientationList) . '' : '/' !!}
  • Annexes
  • @php // Grouper les annexes par type (comme dans le BO avec groupBy) $groupedAnnexes = $lotAnnexes->groupBy(function($annexe) { try { return $annexe->type ? $annexe->type->value : 'unknown'; } catch (\Throwable $e) { return 'unknown'; } }); // Récupérer les annexes par type $parkingAnnexes = $groupedAnnexes->get(ProductType::PARKING->value, collect()); $garageAnnexes = $groupedAnnexes->get(ProductType::GARAGE->value, collect()); $caveAnnexes = $groupedAnnexes->get(ProductType::CAVE->value, collect()); // Récupérer les numéros (tous les numéros non vides) $parkingNumbers = $parkingAnnexes->map(function($annexe) { return $annexe->number ?? null; })->filter(function($number) { return !empty($number) && $number !== null; })->values(); $garageNumbers = $garageAnnexes->map(function($annexe) { return $annexe->number ?? null; })->filter(function($number) { return !empty($number) && $number !== null; })->values(); $caveNumbers = $caveAnnexes->map(function($annexe) { return $annexe->number ?? null; })->filter(function($number) { return !empty($number) && $number !== null; })->values(); @endphp
  • N° parking : {!! $parkingNumbers->isNotEmpty() ? '' . e($parkingNumbers->implode(', ')) . '' : '/' !!}
  • N° garage : {!! $garageNumbers->isNotEmpty() ? '' . e($garageNumbers->implode(', ')) . '' : '/' !!}
  • N° cave : {!! $caveNumbers->isNotEmpty() ? '' . e($caveNumbers->implode(', ')) . '' : '/' !!}
  • @php // Calculer la surface totale de toutes les caves (somme) $surfaceCave = 0; foreach ($caveAnnexes as $cave) { // Essayer d'abord avec ANNEXE, puis HABITABLE en fallback $surfaceAnnexe = $cave->surfaces->where('type', SurfaceType::ANNEXE->value)->first()?->value ?? 0; $surfaceHabitable = $cave->surfaces->where('type', SurfaceType::HABITABLE->value)->first()?->value ?? 0; $surfaceCave += $surfaceAnnexe > 0 ? $surfaceAnnexe : $surfaceHabitable; } @endphp
  • Surface cave : {!! $surfaceCave > 0 ? '' . number_format($surfaceCave, 2, ',', ' ') . ' m²' : '/' !!}
  • Informations financières
  • @if($fiscaliteEnum === FiscaliteEnum::RESIDENCE_PRINCIPALE) {{-- Classique --}} @php // S'assurer que les prix et annexes sont chargés if (!$lot->relationLoaded('prices')) { $lot->load('prices'); } if (!$lot->relationLoaded('annexes')) { $lot->load('annexes'); } if (!$lot->relationLoaded('annexes.prices')) { $lot->load('annexes.prices'); } if (!$lot->relationLoaded('annexes.surfaces')) { $lot->load('annexes.surfaces'); } // Grouper les annexes par type (comme pour Malraux) $groupedAnnexes = $lotAnnexes->groupBy(function($annexe) { try { return $annexe->type ? $annexe->type->value : 'unknown'; } catch (\Throwable $e) { return 'unknown'; } }); $parkingAnnexes = $groupedAnnexes->get(ProductType::PARKING->value, collect()); $garageAnnexes = $groupedAnnexes->get(ProductType::GARAGE->value, collect()); $caveAnnexes = $groupedAnnexes->get(ProductType::CAVE->value, collect()); // Récupérer les prix des annexes depuis les annexes elles-mêmes $prixGarageTTC = 0; foreach ($garageAnnexes as $garage) { $prixGarageTTC += $garage->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } $prixCaveTTC = 0; foreach ($caveAnnexes as $cave) { $prixCaveTTC += $cave->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } $prixParkingTTC = 0; foreach ($parkingAnnexes as $parking) { $prixParkingTTC += $parking->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } // Récupérer les autres prix $depotGarantie = $lotPrices->where('type', 'montant_depot_garantie')->first()?->value ?? 0; $fraisNotaire = $lotPrices->where('type', 'frais_notaire')->first()?->value ?? 0; $fraisNotaireTTC = $lotPrices->where('type', 'frais_notaire_ttc')->first()?->value ?? 0; $fraisNotaireFinal = $fraisNotaireTTC > 0 ? $fraisNotaireTTC : $fraisNotaire; $fraisMiseCopro = $lotPrices->where('type', 'frais_mise_en_copro')->first()?->value ?? 0; if ($fraisMiseCopro == 0) { $fraisMiseCopro = $lotPrices->where('type', 'frais_mise_copro')->first()?->value ?? 0; } $tantieme = $lot->tantieme ?? null; $taxeFonciere = $lotPrices->where('type', 'taxe_fonciere')->first()?->value ?? 0; $prixImmoTTC = $lotPrices->where('type', 'prix_immo_ttc')->first()?->value ?? 0; if ($prixImmoTTC == 0) { $prixImmoTTC = $lotPrices->where('type', PriceType::PRIX_TTC->value)->first()?->value ?? 0; } $prixFoncierCalcul = $lot->getPrixFoncier(); @endphp
  • Prix garage TTC : {!! $prixGarageTTC > 0 ? '' . number_format($prixGarageTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix cave TTC : {!! $prixCaveTTC > 0 ? '' . number_format($prixCaveTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Dépôt de garantie : {!! $depotGarantie > 0 ? '' . number_format($depotGarantie, 0, ',', ' ') . ' €' : '/' !!}
  • Frais de notaire : {!! $fraisNotaireFinal > 0 ? '' . number_format($fraisNotaireFinal, 0, ',', ' ') . ' €' : '/' !!}
  • Frais de mise en copro : {!! $fraisMiseCopro > 0 ? '' . number_format($fraisMiseCopro, 0, ',', ' ') . ' €' : '/' !!}
  • Tantième : {!! $tantieme ? '' . e($tantieme) . '' : '/' !!}
  • Taxe foncière : {!! $taxeFonciere > 0 ? '' . number_format($taxeFonciere, 0, ',', ' ') . ' €' : '/' !!}
  • Prix Immo TTC : {!! $prixImmoTTC > 0 ? '' . number_format($prixImmoTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix Foncier : {!! $prixFoncierCalcul > 0 ? '' . number_format($prixFoncierCalcul, 0, ',', ' ') . ' €' : '/' !!}
  • Prix parking TTC : {!! $prixParkingTTC > 0 ? '' . number_format($prixParkingTTC, 0, ',', ' ') . ' €' : '/' !!}
  • @elseif($fiscaliteEnum === FiscaliteEnum::MALRAUX) {{-- Malraux --}} @php // Récupérer tous les prix nécessaires $prixImmoTTC = $lotPrices->where('type', 'prix_immo_ttc')->first()?->value ?? 0; // Le prix foncier utilise d'abord le prix stocké (prix_foncier_ttc ou prix_foncier_ht), sinon calcule automatiquement // S'assurer que les prix et annexes sont chargés avant d'appeler getPrixFoncier() if (!$lot->relationLoaded('prices')) { $lot->load('prices'); } if (!$lot->relationLoaded('annexes')) { $lot->load('annexes'); } if (!$lot->relationLoaded('annexes.prices')) { $lot->load('annexes.prices'); } $prixFoncierCalcul = $lot->getPrixFoncier(); // Récupérer les prix des annexes depuis les annexes elles-mêmes // Les prix des annexes sont stockés dans les annexes, pas dans les prix du lot $prixParkingTTC = 0; foreach ($parkingAnnexes as $parking) { $prixParkingTTC += $parking->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } $prixGarageTTC = 0; foreach ($garageAnnexes as $garage) { $prixGarageTTC += $garage->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } $prixCaveTTC = 0; foreach ($caveAnnexes as $cave) { $prixCaveTTC += $cave->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } // Prix vente TTC = prix_ttc du lot $prixVenteTTC = $lotPrices->where('type', PriceType::PRIX_TTC->value)->first()?->value ?? 0; // Pour Malraux, utiliser loyer_mensuel_ttc pour Loyer marché $loyerMarche = $lotPrices->where('type', PriceTypeLoyer::MENSUEL_TTC->value)->first()?->value ?? 0; // Calcul des frais de notaire selon Simulation_Lib.php // Pour Malraux VIR : utiliser prix_immo_ttc avec taux-normal (correspond aux PDFs : 19 889 €) // Pour Malraux ASL : prix_foncier (ligne 2091 Simulation_Lib.php) // Cas ASL : frais sur le seul foncier (comme Simulation_Lib.php ligne 2091) if ($program && isset($program->contrat_type) && $program->contrat_type === ContratTypeProgram::ASL && $prixFoncierCalcul > 0) { $montantPourNotaire = $prixFoncierCalcul; $typeCalculNotaire = 'taux-reduit'; } else { // Cas VIR : frais sur prix_immo_ttc avec taux-normal (correspond aux PDFs) // Le calcul donne exactement 19 889 € pour prix_immo_ttc = 302 746 € $montantPourNotaire = $prixImmoTTC; $typeCalculNotaire = 'taux-normal'; } // Total des travaux (éligibles + non éligibles) $montantTravauxCommTTC = $lotPrices->where('type', PriceTypeTravaux::PRIX_TRAVAUX_ELIGIBLE->value)->first()?->value ?? 0; $montantTravauxPrivTTC = $lotPrices->where('type', PriceTypeTravaux::PRIX_TRAVAUX_NON_ELIGIBLE->value)->first()?->value ?? 0; $prixTravauxTotal = $montantTravauxCommTTC + $montantTravauxPrivTTC; $fraisNotaireFinal = 0; if ($montantPourNotaire > 0) { $fraisNotaireFinal = MalrauxCore::calculFraisNotaire($montantPourNotaire, $typeCalculNotaire, $lot, true); } $depotGarantie = $lotPrices->where('type', 'montant_depot_garantie')->first()?->value ?? 0; $fraisMiseCopro = $lotPrices->where('type', 'frais_mise_en_copro')->first()?->value ?? 0; if ($fraisMiseCopro == 0) { $fraisMiseCopro = $lotPrices->where('type', 'frais_mise_copro')->first()?->value ?? 0; } @endphp
  • Prix Immo TTC : {!! $prixImmoTTC > 0 ? '' . number_format($prixImmoTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix Foncier : {!! $prixFoncierCalcul > 0 ? '' . number_format($prixFoncierCalcul, 0, ',', ' ') . ' €' : '/' !!}
  • Travaux : {!! $prixTravauxTotal > 0 ? '' . number_format($prixTravauxTotal, 0, ',', ' ') . ' €' : '/' !!}
  • Prix parking TTC : {!! $prixParkingTTC > 0 ? '' . number_format($prixParkingTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix garage TTC : {!! $prixGarageTTC > 0 ? '' . number_format($prixGarageTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix cave TTC : {!! $prixCaveTTC > 0 ? '' . number_format($prixCaveTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix vente TTC : {!! $prixVenteTTC > 0 ? '' . number_format($prixVenteTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Loyer marché : {!! $loyerMarche > 0 ? '' . number_format($loyerMarche, 0, ',', ' ') . ' €' : '/' !!}
  • Frais de notaire : {!! $fraisNotaireFinal > 0 ? '' . number_format($fraisNotaireFinal, 0, ',', ' ') . ' €' : '/' !!}
  • Dépôt de garantie : {!! $depotGarantie > 0 ? '' . number_format($depotGarantie, 0, ',', ' ') . ' €' : '/' !!}
  • Frais de mise en copro : {!! $fraisMiseCopro > 0 ? '' . number_format($fraisMiseCopro, 0, ',', ' ') . ' €' : '/' !!}
  • @elseif($fiscaliteEnum === FiscaliteEnum::MONUMENT_HISTORIQUE) {{-- Monument Historique --}} @if($lotPrices->where('type', 'prix_immo_ttc')->first()?->value > 0)
  • Prix Immo TTC : {{ number_format($lotPrices->where('type', 'prix_immo_ttc')->first()->value, 0, ',', ' ') }} €
  • @endif @php // S'assurer que les prix sont chargés avant d'appeler getPrixFoncier() if (!$lot->relationLoaded('prices')) { $lot->load('prices'); } $prixFoncierCalcul = $lot->getPrixFoncier(); @endphp @if($prixFoncierCalcul > 0)
  • Prix Foncier : {{ number_format($prixFoncierCalcul, 0, ',', ' ') }} €
  • @endif @if($montantTravauxCommTTC > 0)
  • Travaux DF : {{ number_format($montantTravauxCommTTC, 0, ',', ' ') }} € {{ ($prixTTC - $prixParkingTTC) > 0 ? round(($montantTravauxCommTTC / ($prixTTC - $prixParkingTTC)) * 100) : 0 }} %
  • @endif @if($montantTravauxPrivTTC > 0)
  • Travaux Hors DF : {{ number_format($montantTravauxPrivTTC, 0, ',', ' ') }} €
  • @endif @if($lotPrices->where('type', 'prix_parking_ttc')->first()?->value > 0)
  • Prix parking TTC : {{ number_format($lotPrices->where('type', 'prix_parking_ttc')->first()->value, 0, ',', ' ') }} €
  • @endif @if($lotPrices->where('type', 'prix_garage_ttc')->first()?->value > 0)
  • Prix garage TTC : {{ number_format($lotPrices->where('type', 'prix_garage_ttc')->first()->value, 0, ',', ' ') }} €
  • @endif @if($lotPrices->where('type', 'prix_cave_ttc')->first()?->value > 0)
  • Prix cave TTC : {{ number_format($lotPrices->where('type', 'prix_cave_ttc')->first()->value, 0, ',', ' ') }} €
  • @endif @if($lotPrices->where('type', PriceType::PRIX_TTC->value)->first()?->value > 0)
  • Prix vente TTC : {{ number_format($lotPrices->where('type', PriceType::PRIX_TTC->value)->first()->value, 0, ',', ' ') }} €
  • @endif @if($lotPrices->where('type', 'loyer_mensuel')->first()?->value > 0)
  • Loyer marché : {{ number_format($lotPrices->where('type', 'loyer_mensuel')->first()->value, 0, ',', ' ') }} €
  • @endif @elseif($fiscaliteEnum === FiscaliteEnum::DEFICIT_FONCIER) {{-- Déficit Foncier --}} @php // S'assurer que les prix sont chargés avant d'appeler getPrixFoncier() if (!$lot->relationLoaded('prices')) { $lot->load('prices'); } $prixFoncierCalcul = $lot->getPrixFoncier(); // Récupérer tous les prix nécessaires $prixImmoTTC = $lotPrices->where('type', 'prix_immo_ttc')->first()?->value ?? 0; $prixParkingTTCInfo = $lotPrices->where('type', 'prix_parking_ttc')->first()?->value ?? 0; $prixGarageTTCInfo = $lotPrices->where('type', 'prix_garage_ttc')->first()?->value ?? 0; $prixCaveTTCInfo = $lotPrices->where('type', 'prix_cave_ttc')->first()?->value ?? 0; $prixVenteTTCInfo = $lotPrices->where('type', PriceType::PRIX_TTC->value)->first()?->value ?? 0; $loyerMarcheInfo = $lotPrices->where('type', 'loyer_mensuel')->first()?->value ?? 0; // Total des travaux (éligibles + non éligibles) $montantTravauxCommTTC = $lotPrices->where('type', PriceTypeTravaux::PRIX_TRAVAUX_ELIGIBLE->value)->first()?->value ?? 0; $montantTravauxPrivTTC = $lotPrices->where('type', PriceTypeTravaux::PRIX_TRAVAUX_NON_ELIGIBLE->value)->first()?->value ?? 0; // Frais de notaire, dépôt de garantie, frais de mise en copro $fraisNotaire = $lotPrices->where('type', 'frais_notaire')->first()?->value ?? 0; $fraisNotaireTTC = $lotPrices->where('type', 'frais_notaire_ttc')->first()?->value ?? 0; $fraisNotaireFinal = $fraisNotaireTTC > 0 ? $fraisNotaireTTC : $fraisNotaire; $depotGarantie = $lotPrices->where('type', 'montant_depot_garantie')->first()?->value ?? 0; $fraisMiseCopro = $lotPrices->where('type', 'frais_mise_en_copro')->first()?->value ?? 0; if ($fraisMiseCopro == 0) { $fraisMiseCopro = $lotPrices->where('type', 'frais_mise_copro')->first()?->value ?? 0; } // Calculer le pourcentage des Travaux DF $travauxDFPourcentage = 0; $prixTTC = $prixVenteTTCInfo ?? 0; $prixParkingTTC = $prixParkingTTCInfo ?? 0; if ($montantTravauxCommTTC > 0 && ($prixTTC - $prixParkingTTC) > 0) { $travauxDFPourcentage = round(($montantTravauxCommTTC / ($prixTTC - $prixParkingTTC)) * 100); } @endphp
  • Prix Immo TTC : {!! $prixImmoTTC > 0 ? '' . number_format($prixImmoTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix Foncier : {!! $prixFoncierCalcul > 0 ? '' . number_format($prixFoncierCalcul, 0, ',', ' ') . ' €' : '/' !!}
  • Travaux DF : {!! $montantTravauxCommTTC > 0 ? '' . number_format($montantTravauxCommTTC, 0, ',', ' ') . ' € ' . ($travauxDFPourcentage > 0 ? '' . $travauxDFPourcentage . ' %' : '') . '' : '/' !!}
  • Travaux non DF : {!! $montantTravauxPrivTTC > 0 ? '' . number_format($montantTravauxPrivTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix parking TTC : {!! $prixParkingTTCInfo > 0 ? '' . number_format($prixParkingTTCInfo, 0, ',', ' ') . ' €' : '/' !!}
  • Prix garage TTC : {!! $prixGarageTTCInfo > 0 ? '' . number_format($prixGarageTTCInfo, 0, ',', ' ') . ' €' : '/' !!}
  • Prix cave TTC : {!! $prixCaveTTCInfo > 0 ? '' . number_format($prixCaveTTCInfo, 0, ',', ' ') . ' €' : '/' !!}
  • Prix vente TTC : {!! $prixVenteTTCInfo > 0 ? '' . number_format($prixVenteTTCInfo, 0, ',', ' ') . ' €' : '/' !!}
  • Loyer marché : {!! $loyerMarcheInfo > 0 ? '' . number_format($loyerMarcheInfo, 0, ',', ' ') . ' €' : '/' !!}
  • Frais de notaire : {!! $fraisNotaireFinal > 0 ? '' . number_format($fraisNotaireFinal, 0, ',', ' ') . ' €' : '/' !!}
  • Dépôt de garantie : {!! $depotGarantie > 0 ? '' . number_format($depotGarantie, 0, ',', ' ') . ' €' : '/' !!}
  • Frais de mise en copro : {!! $fraisMiseCopro > 0 ? '' . number_format($fraisMiseCopro, 0, ',', ' ') . ' €' : '/' !!}
  • @elseif($fiscaliteEnum === FiscaliteEnum::DENORMANDIE) {{-- Denormandie --}} @php // S'assurer que les prix et annexes sont chargés if (!$lot->relationLoaded('prices')) { $lot->load('prices'); } if (!$lot->relationLoaded('annexes')) { $lot->load('annexes'); } if (!$lot->relationLoaded('annexes.prices')) { $lot->load('annexes.prices'); } // Grouper les annexes par type (comme pour Malraux) $groupedAnnexes = $lotAnnexes->groupBy(function($annexe) { try { return $annexe->type ? $annexe->type->value : 'unknown'; } catch (\Throwable $e) { return 'unknown'; } }); $parkingAnnexes = $groupedAnnexes->get(ProductType::PARKING->value, collect()); $garageAnnexes = $groupedAnnexes->get(ProductType::GARAGE->value, collect()); $caveAnnexes = $groupedAnnexes->get(ProductType::CAVE->value, collect()); // Récupérer les prix des annexes depuis les annexes elles-mêmes $prixParkingTTC = 0; foreach ($parkingAnnexes as $parking) { $prixParkingTTC += $parking->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } $prixGarageTTC = 0; foreach ($garageAnnexes as $garage) { $prixGarageTTC += $garage->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } $prixCaveTTC = 0; foreach ($caveAnnexes as $cave) { $prixCaveTTC += $cave->prices->where('type', 'prix_ttc')->first()?->value ?? 0; } // Utiliser prix_immo_ttc pour Prix Immo TTC $prixImmoTTC = $lotPrices->where('type', 'prix_immo_ttc')->first()?->value ?? 0; $prixFoncierCalcul = $lot->getPrixFoncier(); // Prix vente TTC = prix_ttc du lot $prixVenteTTC = $lotPrices->where('type', PriceType::PRIX_TTC->value)->first()?->value ?? 0; $fraisNotaire = $lotPrices->where('type', 'frais_notaire')->first()?->value ?? 0; $fraisNotaireTTC = $lotPrices->where('type', 'frais_notaire_ttc')->first()?->value ?? 0; $fraisNotaireFinal = $fraisNotaireTTC > 0 ? $fraisNotaireTTC : $fraisNotaire; $depotGarantie = $lotPrices->where('type', 'montant_depot_garantie')->first()?->value ?? 0; $fraisMiseCopro = $lotPrices->where('type', 'frais_mise_en_copro')->first()?->value ?? 0; if ($fraisMiseCopro == 0) { $fraisMiseCopro = $lotPrices->where('type', 'frais_mise_copro')->first()?->value ?? 0; } @endphp
  • Prix Immo TTC : {!! $prixImmoTTC > 0 ? '' . number_format($prixImmoTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix Foncier : {!! $prixFoncierCalcul > 0 ? '' . number_format($prixFoncierCalcul, 0, ',', ' ') . ' €' : '/' !!}
  • Prix parking TTC : {!! $prixParkingTTC > 0 ? '' . number_format($prixParkingTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix garage TTC : {!! $prixGarageTTC > 0 ? '' . number_format($prixGarageTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix cave TTC : {!! $prixCaveTTC > 0 ? '' . number_format($prixCaveTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Prix vente TTC : {!! $prixVenteTTC > 0 ? '' . number_format($prixVenteTTC, 0, ',', ' ') . ' €' : '/' !!}
  • Frais de notaire : {!! $fraisNotaireFinal > 0 ? '' . number_format($fraisNotaireFinal, 0, ',', ' ') . ' €' : '/' !!}
  • Dépôt de garantie : {!! $depotGarantie > 0 ? '' . number_format($depotGarantie, 0, ',', ' ') . ' €' : '/' !!}
  • Frais de mise en copro : {!! $fraisMiseCopro > 0 ? '' . number_format($fraisMiseCopro, 0, ',', ' ') . ' €' : '/' !!}
  • @endif
@else

Aucun lot associé à cette réservation.

@endif
@php $allowedTaskTypes = [ TaskType::FORMULAIRE_RENSEIGNEMENT_BANCAIRE, TaskType::FORMULAIRE_DOCUMENTS_JUSTIFICATIFS, TaskType::RELECTURE_ET_VALIDATION_DU_DOSSIER, TaskType::ENVOI_EN_SIGNATURE_ELECTRONIQUE, ]; $canShowGoBackButton = $currentTask && $workflowData && $workflowData['workflow'] && in_array($currentTask->type, $allowedTaskTypes); @endphp @if($canShowGoBackButton)
@if($previousTask)
@csrf
@else @endif
@endif
@if($workflowData && $workflowData['workflow']) @php // Récupérer toutes les tâches non-catégories dans l'ordre // Utiliser $workflowData['tasks'] qui contient toutes les tâches dans l'ordre $allNonCategoryTasks = collect($workflowData['tasks'] ?? []) ->filter(function ($task) { return $task->type && !$task->type->isCategory(); }) ->values(); @endphp
Progression
@foreach($allNonCategoryTasks as $index => $task) @php $taskReservation = $taskReservations->get($task->id); $taskState = $taskReservation ? $taskReservation->state : null; $isCompleted = $taskState === TaskState::TERMINEE; $isInProgress = $taskState === TaskState::EN_COURS || ($currentTask && $currentTask->id === $task->id); $isFuture = !$isCompleted && !$isInProgress; // Vérifier si la tâche précédente est terminée pour afficher la ligne active $previousTaskCompleted = false; if ($index > 0) { $previousTask = $allNonCategoryTasks->get($index - 1); $previousTaskReservation = $taskReservations->get($previousTask->id); $previousTaskState = $previousTaskReservation ? $previousTaskReservation->state : null; $previousTaskCompleted = $previousTaskState === TaskState::TERMINEE; } // Déterminer si c'est la dernière tâche $isLast = $index === $allNonCategoryTasks->count() - 1; // La ligne est active si cette tâche ou la précédente est terminée/en cours $lineActive = $isCompleted || $isInProgress || $previousTaskCompleted; @endphp
@if($index > 0)
@endif {{ $index + 1 }} @if(!$isLast)
@endif
{{ $task->type === TaskType::CONTRAT_SIGNE ? $task->type->label() : $task->name }}
@if($isCompleted && $taskReservation && $taskReservation->finished_at)
{{ $taskReservation->finished_at->format('d/m/Y à H:i:s') }}
@endif @if($task->type === TaskType::CONTRAT_SIGNE && $reservation->signed_by_clients_at)
{{ $reservation->signed_by_clients_at->format('d/m/Y à H:i:s') }}
@endif
@endforeach
@if($currentTask) @php // Trouver la tâche en cours dans toutes les tâches $currentTaskFound = false; if ($currentTask && isset($workflowData['tasks'])) { foreach ($workflowData['tasks'] as $task) { if ($currentTask->id === $task->id) { $currentTaskFound = true; break; } } } @endphp @if($currentTaskFound)
{{ $currentTask->type === TaskType::CONTRAT_SIGNE ? $currentTask->type->label() : $currentTask->name }}
@endif @endif
@php // Trouver la tâche en cours dans toutes les tâches $currentTaskFound = false; if ($currentTask && isset($workflowData['tasks'])) { foreach ($workflowData['tasks'] as $task) { if ($currentTask->id === $task->id) { $currentTaskFound = true; break; } } } @endphp @if($currentTask && $currentTaskFound) @php $taskDisplayed = false; @endphp @foreach($workflowData['tasks'] as $task) @php $isCurrentTask = $currentTask && $currentTask->id === $task->id; // Ne traiter que les tâches non-catégories $isNonCategory = $task->type && !$task->type->isCategory(); @endphp @if($isCurrentTask && !$taskDisplayed && $isNonCategory) @php $childTask = $task; // Renommer pour compatibilité avec le reste du code $taskDisplayed = true; $currentTaskReservation = $taskReservations->get($childTask->id); // Le message "En attente de signature cliente" s'affiche uniquement pour les tâches // qui ont des sendEmails avec des documents templates contenant des blocs signature // (pas pour "Envoi en signature électronique" qui n'utilise pas les emails) // Logs pour déboguer \Illuminate\Support\Facades\Log::info('Reservation show - Vérification affichage message signature', [ 'task_id' => $childTask->id, 'task_name' => $childTask->name, 'task_type' => $childTask->type?->value ?? null, 'has_current_task_reservation' => $currentTaskReservation !== null, 'need_signature' => $currentTaskReservation?->need_signature ?? null, 'state' => $currentTaskReservation?->state?->value ?? null, 'signature_id' => $currentTaskReservation?->signature_id ?? null, 'has_send_emails' => $childTask->sendEmails !== null, 'send_emails_count' => $childTask->sendEmails?->count() ?? 0, ]); $hasSendEmailsWithSignature = false; if ($childTask->sendEmails && $childTask->sendEmails->count() > 0) { foreach ($childTask->sendEmails as $sendEmail) { if ($sendEmail->documentTemplate) { $hasSignatureBlock = $sendEmail->documentTemplate->datas() ->whereJsonContains('json->is_signature', true) ->exists(); \Illuminate\Support\Facades\Log::info('Reservation show - Vérification sendEmail', [ 'task_id' => $childTask->id, 'send_email_id' => $sendEmail->id, 'document_template_id' => $sendEmail->documentTemplate->id, 'has_signature_block' => $hasSignatureBlock, ]); if ($hasSignatureBlock) { $hasSendEmailsWithSignature = true; break; } } } } \Illuminate\Support\Facades\Log::info('Reservation show - Résultat vérification', [ 'task_id' => $childTask->id, 'has_send_emails_with_signature' => $hasSendEmailsWithSignature, ]); $isWaitingForSignature = $currentTaskReservation && $currentTaskReservation->need_signature && $hasSendEmailsWithSignature && $currentTaskReservation->state === TaskState::EN_COURS; \Illuminate\Support\Facades\Log::info('Reservation show - Résultat final isWaitingForSignature', [ 'task_id' => $childTask->id, 'is_waiting_for_signature' => $isWaitingForSignature, 'conditions' => [ 'has_current_task_reservation' => $currentTaskReservation !== null, 'need_signature' => $currentTaskReservation?->need_signature ?? false, 'has_send_emails_with_signature' => $hasSendEmailsWithSignature, 'state_is_en_cours' => $currentTaskReservation?->state === TaskState::EN_COURS, ], ]); @endphp
@if($isWaitingForSignature)

En attente de signature cliente

@else @if($childTask->description_client)

{{ $childTask->description_client }}

@endif @if($isCurrentTask && $childTask->type === TaskType::ACCEPTER_LES_CONDITIONS)
@csrf
@csrf
@endif @if($isCurrentTask && $childTask->type === TaskType::FORMULAIRE_RENSEIGNEMENT_CLIENT) @php $client = $reservation->client; $address = $client ? $client->addresses->first() : null; $phoneValue = ''; if ($client) { if (!$client->relationLoaded('phones')) { $client->load('phones'); } $phone = $client->phones->first(); $phoneValue = $phone ? $phone->value : ''; } $countries = Country::cases(); // Récupérer les co-acheteurs $cobuyers = $reservation->getCobuyersForDisplay(); $hasCobuyer = $cobuyers->isNotEmpty(); // Vérifier s'il y a déjà une société $hasBuyingCompany = $reservation->buyingCompanies()->exists(); $buyingCompany = $reservation->buyingCompany; $buyingCompanyAddress = $buyingCompany ? $buyingCompany->addresses->first() : null; $buyingCompanyPhone = ''; $buyingCompanyPhoneFixe = ''; $buyingCompanyPhoneMobile = ''; if ($buyingCompany) { if (!$buyingCompany->relationLoaded('phones')) { $buyingCompany->load('phones'); } if (!$buyingCompany->relationLoaded('addresses')) { $buyingCompany->load('addresses'); } // Récupérer le téléphone fixe et mobile séparément $phoneFixe = $buyingCompany->phones->firstWhere('type', \App\Enums\PhoneType::FIXE_BUREAU); $phoneMobile = $buyingCompany->phones->firstWhere('type', \App\Enums\PhoneType::MOBILE); $buyingCompanyPhoneFixe = $phoneFixe ? $phoneFixe->value : ''; $buyingCompanyPhoneMobile = $phoneMobile ? $phoneMobile->value : ''; // Pour compatibilité, utiliser le premier téléphone trouvé $phone = $buyingCompany->phones->first(); $buyingCompanyPhone = $phone ? $phone->value : ''; } // Utiliser BuyingCompany ou old() pour déterminer si c'est une personne morale (old() après erreur de validation) $isPersonneMorale = $buyingCompany !== null || old('type_acheteur') === 'morale'; @endphp
À propos de l'acheteur
@csrf
@csrf
@php $mandataireParts = $buyingCompany && $buyingCompany->mandataire ? explode("\n", $buyingCompany->mandataire, 2) : []; $nomMandataire = $mandataireParts[0] ?? ''; @endphp
@php $adresseMandataire = isset($mandataireParts[1]) ? $mandataireParts[1] : ''; @endphp
@if(!$isPersonneMorale)
@endif @if($cobuyers->isNotEmpty())
Co-acheteur
@foreach($cobuyers as $cobuyer) @php $cobuyerPhoneValue = $cobuyer['phone'] ?? ''; $cobuyerAddress = $cobuyer['address'] ?? null; $cobuyerCivilityLabel = $cobuyer['civility'] ? (Civilite::tryFrom($cobuyer['civility'])?->label() ?? '') . ' ' : ''; $cobuyerBirthdateFormatted = !empty($cobuyer['birthdate']) ? \Carbon\Carbon::parse($cobuyer['birthdate'])->format('d/m/Y') : null; $editData = [ 'civility' => $cobuyer['civility'] ?? '', 'lastname' => $cobuyer['lastname'] ?? '', 'firstname' => $cobuyer['firstname'] ?? '', 'nom_jeune_fille' => $cobuyer['nom_jeune_fille'] ?? '', 'email' => $cobuyer['email'] ?? '', 'phone' => $cobuyerPhoneValue, 'birthdate' => $cobuyer['birthdate'] ?? '', 'birthplace' => $cobuyer['birthplace'] ?? '', 'profession' => $cobuyer['profession'] ?? '', 'nationality' => $cobuyer['nationality'] ?? '', 'situation_matrimoniale' => $cobuyer['situation_matrimoniale'] ?? '', 'date_mariage_pacs' => $cobuyer['date_mariage_pacs'] ?? '', 'lieu_mariage_pacs' => $cobuyer['lieu_mariage_pacs'] ?? '', 'regime_matrimonial' => $cobuyer['regime_matrimonial'] ?? '', 'date_divorce' => $cobuyer['date_divorce'] ?? '', 'address_line_1' => $cobuyerAddress['line_1'] ?? '', 'address_line_2' => $cobuyerAddress['line_2'] ?? '', 'address_zip_code' => $cobuyerAddress['zip_code'] ?? '', 'address_city' => $cobuyerAddress['city'] ?? '', 'address_country' => $cobuyerAddress['country_name'] ?? 'FR', ]; @endphp

{{ $cobuyerCivilityLabel }}{{ $cobuyer['lastname'] }} {{ $cobuyer['firstname'] }}

{{ $cobuyer['email'] }}

{{ $cobuyerPhoneValue ?: '-' }}

@if($cobuyerBirthdateFormatted)

{{ $cobuyerBirthdateFormatted }}

@endif @if(!empty($cobuyer['birthplace']))

{{ $cobuyer['birthplace'] }}

@endif @if($cobuyerAddress && !empty($cobuyerAddress['line_1']))

{{ $cobuyerAddress['line_1'] }}
@if(!empty($cobuyerAddress['line_2'])){{ $cobuyerAddress['line_2'] }}
@endif {{ $cobuyerAddress['zip_code'] ?? '' }} {{ $cobuyerAddress['city'] ?? '' }}
{{ $cobuyerAddress['country_name'] ?? '' }}

@endif
@csrf @method('DELETE')
@endforeach
@endif
Acheter en tant que société
@csrf
@if($hasBuyingCompany && $buyingCompany)
Société
@csrf @method('DELETE')

{{ $buyingCompany->name }}

@if($buyingCompany->rcs_number)

{{ $buyingCompany->rcs_number }}

@endif @if($buyingCompany->rcs_location)

{{ $buyingCompany->rcs_location }}

@endif @if($buyingCompany->type)

{{ $buyingCompany->type->label() }}

@endif @if($buyingCompany->capital)

{{ number_format($buyingCompany->capital, 2, ',', ' ') }} €

@endif

{{ $buyingCompany->email }}

@if($buyingCompanyPhone)

{{ $buyingCompanyPhone }}

@endif @if($buyingCompanyAddress)

{{ $buyingCompanyAddress->line_1 }}
@if($buyingCompanyAddress->line_2){{ $buyingCompanyAddress->line_2 }}
@endif {{ $buyingCompanyAddress->zip_code }} {{ $buyingCompanyAddress->city }}
{{ $buyingCompanyAddress->country ? $buyingCompanyAddress->country->name : '' }}

@endif @if($buyingCompany->mandataire)

{{ $buyingCompany->mandataire }}

@endif
@endif
@endif @if($isCurrentTask && $childTask->type === TaskType::FORMULAIRE_RENSEIGNEMENT_BANCAIRE) @php $bankData = $reservation->datas()->where('json->category', 'Données saisies')->first(); $bankDataJson = $bankData ? $bankData->json : []; $prixVenteTotal = 0; $fraisNotaireDefault = ''; if ($lot) { if (!$lot->relationLoaded('prices')) { $lot->load('prices'); } $prixTTC = $lot->getPrixLotTTC(); $prixTravauxHorsReadOnly = $lot->getTotalTravaux(); $prixVenteTotal = $prixTTC + $prixTravauxHorsReadOnly; $lotPrices = $lot->prices; $fraisNotaire = $lotPrices->where('type', 'frais_notaire')->first()?->value ?? 0; $fraisNotaireTTC = $lotPrices->where('type', 'frais_notaire_ttc')->first()?->value ?? 0; $fraisNotaireFinal = $fraisNotaireTTC > 0 ? $fraisNotaireTTC : $fraisNotaire; if ($fraisNotaireFinal > 0) { $fraisNotaireDefault = number_format($fraisNotaireFinal, 2, '.', ''); } } @endphp
@csrf
@endif @if($isCurrentTask && $childTask->type === TaskType::FORMULAIRE_DOCUMENTS_JUSTIFICATIFS) @php $documents = $reservation->documents() ->whereNotIn('type', ['contrat', 'contrat_signe']) ->orderBy('order') ->get(); $documentsByType = $documents->groupBy('type'); @endphp
@foreach(\App\Enums\DocumentTypeReservation::cases() as $docType) @php $typeDocuments = $documentsByType->get($docType->value, collect()); @endphp
{{ $docType->label() }} @if($typeDocuments->count() > 0) {{ $typeDocuments->count() }} @endif
@if($typeDocuments->count() > 0)
    @foreach($typeDocuments as $document) @php $statusEnum = $document->status ? \App\Enums\DocumentStatus::tryFrom($document->status) : null; $liClass = 'd-flex justify-content-between align-items-center py-1'; if ($statusEnum === \App\Enums\DocumentStatus::VALIDATED) { $liClass .= ' list-group-item-success'; } elseif ($statusEnum === \App\Enums\DocumentStatus::REJECTED) { $liClass .= ' list-group-item-danger'; } else { $liClass .= ' list-group-item-secondary'; } @endphp
  • {{ $document->name }}
    {{ number_format($document->file_size / 1024, 2) }} Ko
  • @if($statusEnum === \App\Enums\DocumentStatus::REJECTED && $document->rejection_reason)
  • {{ $document->rejection_reason }}
  • @endif @endforeach
@endif
@endforeach
@csrf
@endif @php $isRelectureTask = false; if ($childTask->type) { if ($childTask->type instanceof TaskType) { $isRelectureTask = $childTask->type === TaskType::RELECTURE_ET_VALIDATION_DU_DOSSIER; } else { $isRelectureTask = $childTask->type === TaskType::RELECTURE_ET_VALIDATION_DU_DOSSIER->value; } } @endphp @if($isCurrentTask && $isRelectureTask) @php // Récupérer les co-acheteurs pour cette section $cobuyers = $reservation->getCobuyersForDisplay(); // Vérifier si c'est une personne morale $buyingCompanyRelecture = $reservation->buyingCompany; @endphp
@if(!$buyingCompanyRelecture)
Informations client
@php $clientTask = collect($workflowData['tasks'] ?? []) ->filter(function ($t) { return $t->type && !$t->type->isCategory() && $t->type === TaskType::FORMULAIRE_RENSEIGNEMENT_CLIENT; }) ->first(); $clientTaskReservation = $clientTask ? $taskReservations->get($clientTask->id) : null; $clientTaskIsTerminee = $clientTaskReservation && $clientTaskReservation->state === TaskState::TERMINEE; @endphp @if($clientTask && $clientTaskIsTerminee)
@csrf
@endif
@if($client)

{{ $client?->civility ? $client->civility->label() . ' ' : '' }}{{ $client?->lastname }} {{ $client?->firstname }}

{{ $client?->email ?? '-' }}

{{ $phoneValue ?: '-' }}

@if($client?->birthdate)

{{ $client->birthdate->format('d/m/Y') }}

@endif @if($client?->birthplace)

{{ $client->birthplace }}

@endif @if($client?->profession)

{{ $client->profession }}

@endif @if($client?->employeur)

{{ $client->employeur }}

@endif @if($client?->nationality)

{{ $client->nationality }}

@endif @if($client?->nom_jeune_fille)

{{ $client->nom_jeune_fille }}

@endif @if($client?->situation_matrimoniale)

{{ $client->situation_matrimoniale->label() }}

@endif @if($client?->date_mariage_pacs)

{{ $client->date_mariage_pacs->format('d/m/Y') }}

@endif @if($client?->lieu_mariage_pacs)

{{ $client->lieu_mariage_pacs }}

@endif @if($client?->regime_matrimonial)

{{ $client->regime_matrimonial->label() }}

@endif @if($client?->date_divorce)

{{ $client->date_divorce->format('d/m/Y') }}

@endif @if($client && $client->addresses->isNotEmpty()) @php $address = $client->addresses->first(); @endphp

{{ $address->line_1 }}
@if($address->line_2){{ $address->line_2 }}
@endif {{ $address->zip_code }} {{ $address->city }}
{{ $address->country ? $address->country->name : '' }}

@endif
@else

Aucune information client disponible.

@endif
@endif @if(!$buyingCompanyRelecture) @if($cobuyers->isNotEmpty())
Informations co-acheteur
@foreach($cobuyers as $cobuyer) @php $cobuyerPhoneValue = $cobuyer['phone'] ?? ''; $cobuyerAddress = $cobuyer['address'] ?? null; $cobuyerCivilityLabel = $cobuyer['civility'] ? (Civilite::tryFrom($cobuyer['civility'])?->label() ?? '') . ' ' : ''; $cobuyerBirthdateFormatted = !empty($cobuyer['birthdate']) ? \Carbon\Carbon::parse($cobuyer['birthdate'])->format('d/m/Y') : null; $cobuyerDateMariageFormatted = !empty($cobuyer['date_mariage_pacs']) ? \Carbon\Carbon::parse($cobuyer['date_mariage_pacs'])->format('d/m/Y') : null; $cobuyerDateDivorceFormatted = !empty($cobuyer['date_divorce']) ? \Carbon\Carbon::parse($cobuyer['date_divorce'])->format('d/m/Y') : null; $situationLabel = !empty($cobuyer['situation_matrimoniale']) ? (SituationMatrimoniale::tryFrom($cobuyer['situation_matrimoniale'])?->label() ?? $cobuyer['situation_matrimoniale']) : null; $regimeLabel = !empty($cobuyer['regime_matrimonial']) ? (RegimeMatrimonial::tryFrom($cobuyer['regime_matrimonial'])?->label() ?? $cobuyer['regime_matrimonial']) : null; @endphp

{{ $cobuyerCivilityLabel }}{{ $cobuyer['lastname'] }} {{ $cobuyer['firstname'] }}

{{ $cobuyer['email'] }}

{{ $cobuyerPhoneValue ?: '-' }}

@if($cobuyerBirthdateFormatted)

{{ $cobuyerBirthdateFormatted }}

@endif @if(!empty($cobuyer['birthplace']))

{{ $cobuyer['birthplace'] }}

@endif @if(!empty($cobuyer['profession']))

{{ $cobuyer['profession'] }}

@endif @if(!empty($cobuyer['nationality']))

{{ $cobuyer['nationality'] }}

@endif @if(!empty($cobuyer['nom_jeune_fille']))

{{ $cobuyer['nom_jeune_fille'] }}

@endif @if($situationLabel)

{{ $situationLabel }}

@endif @if($cobuyerDateMariageFormatted)

{{ $cobuyerDateMariageFormatted }}

@endif @if(!empty($cobuyer['lieu_mariage_pacs']))

{{ $cobuyer['lieu_mariage_pacs'] }}

@endif @if($regimeLabel)

{{ $regimeLabel }}

@endif @if($cobuyerDateDivorceFormatted)

{{ $cobuyerDateDivorceFormatted }}

@endif @if($cobuyerAddress && !empty($cobuyerAddress['line_1']))

{{ $cobuyerAddress['line_1'] }}
@if(!empty($cobuyerAddress['line_2'])){{ $cobuyerAddress['line_2'] }}
@endif {{ $cobuyerAddress['zip_code'] ?? '' }} {{ $cobuyerAddress['city'] ?? '' }}
{{ $cobuyerAddress['country_name'] ?? '' }}

@endif
@endforeach
@endif @endif @if($buyingCompanyRelecture) @php $buyingCompany = $buyingCompanyRelecture; @endphp
Informations société acquéreuse
@php $clientTask = collect($workflowData['tasks'] ?? []) ->filter(function ($t) { return $t->type && !$t->type->isCategory() && $t->type === TaskType::FORMULAIRE_RENSEIGNEMENT_CLIENT; }) ->first(); $clientTaskReservation = $clientTask ? $taskReservations->get($clientTask->id) : null; $clientTaskIsTerminee = $clientTaskReservation && $clientTaskReservation->state === TaskState::TERMINEE; @endphp @if($clientTask && $clientTaskIsTerminee)
@csrf
@endif
@php $companyAddress = $buyingCompany->addresses->first(); if (!$buyingCompany->relationLoaded('phones')) { $buyingCompany->load('phones'); } $companyPhoneFixe = $buyingCompany->phones->firstWhere('type', \App\Enums\PhoneType::FIXE_BUREAU); $companyPhoneMobile = $buyingCompany->phones->firstWhere('type', \App\Enums\PhoneType::MOBILE); $companyPhoneFixeValue = $companyPhoneFixe ? $companyPhoneFixe->value : ''; $companyPhoneMobileValue = $companyPhoneMobile ? $companyPhoneMobile->value : ''; @endphp

{{ $buyingCompany->name }}

@if($buyingCompany->rcs_number)

{{ $buyingCompany->rcs_number }}

@endif @if($buyingCompany->rcs_location)

{{ $buyingCompany->rcs_location }}

@endif @if($buyingCompany->type)

{{ $buyingCompany->type->label() }}

@endif @if($buyingCompany->capital)

{{ number_format($buyingCompany->capital, 2, ',', ' ') }} €

@endif @if($companyAddress)

{{ $companyAddress->line_1 }}
@if($companyAddress->line_2){{ $companyAddress->line_2 }}
@endif {{ $companyAddress->zip_code }} {{ $companyAddress->city }}
{{ $companyAddress->country ? $companyAddress->country->name : '' }}

@endif @if($buyingCompany->mandataire)

{{ $buyingCompany->mandataire }}

@endif @if($buyingCompany->email)

{{ $buyingCompany->email }}

@endif @if($companyPhoneFixeValue)

{{ $companyPhoneFixeValue }}

@endif @if($companyPhoneMobileValue)

{{ $companyPhoneMobileValue }}

@endif
@endif
Informations financières
@php $bankTask = collect($workflowData['tasks'] ?? []) ->filter(function ($t) { return $t->type && !$t->type->isCategory() && $t->type === TaskType::FORMULAIRE_RENSEIGNEMENT_BANCAIRE; }) ->first(); $bankTaskReservation = $bankTask ? $taskReservations->get($bankTask->id) : null; $bankTaskIsTerminee = $bankTaskReservation && $bankTaskReservation->state === TaskState::TERMINEE; @endphp @if($bankTask && $bankTaskIsTerminee)
@csrf
@endif
@php $bankData = $reservation->datas()->where('json->category', 'Données saisies')->first(); $bankDataJson = $bankData ? $bankData->json : []; @endphp @if(!empty($bankDataJson))

{{ isset($bankDataJson['mode_financement']) ? ($bankDataJson['mode_financement'] === 'credit' ? 'Crédit' : 'Comptant') : '-' }}

{{ isset($bankDataJson['apport_personnel']) ? number_format($bankDataJson['apport_personnel'], 2, ',', ' ') . ' €' : '-' }}

@if(isset($bankDataJson['frais_notaire']) && $bankDataJson['frais_notaire'])

{{ number_format($bankDataJson['frais_notaire'], 2, ',', ' ') . ' €' }}

@endif @if(isset($bankDataJson['mode_financement']) && $bankDataJson['mode_financement'] === 'credit') @if(isset($bankDataJson['duree_pret']) && $bankDataJson['duree_pret'])

{{ $bankDataJson['duree_pret'] }} ans

@endif @if(isset($bankDataJson['taux_pret']) && $bankDataJson['taux_pret'])

{{ number_format($bankDataJson['taux_pret'], 2, ',', ' ') }} %

@endif

{{ $bankDataJson['nom_banque'] ?? '-' }}

{{ isset($bankDataJson['montant_pret']) ? number_format($bankDataJson['montant_pret'], 2, ',', ' ') . ' €' : '-' }}

@if(!empty($bankDataJson['nom_banque_2']) || !empty($bankDataJson['montant_pret_2']))

{{ $bankDataJson['nom_banque_2'] ?? '-' }}

{{ isset($bankDataJson['montant_pret_2']) ? number_format($bankDataJson['montant_pret_2'], 2, ',', ' ') . ' €' : '-' }}

@endif @if(!empty($bankDataJson['nom_banque_3']) || !empty($bankDataJson['montant_pret_3']))

{{ $bankDataJson['nom_banque_3'] ?? '-' }}

{{ isset($bankDataJson['montant_pret_3']) ? number_format($bankDataJson['montant_pret_3'], 2, ',', ' ') . ' €' : '-' }}

@endif @endif @if(isset($bankDataJson['notaire_participation']) && $bankDataJson['notaire_participation'])

{{ $bankDataJson['prenom_notaire'] ?? '' }} {{ $bankDataJson['nom_notaire'] ?? '' }} @if(isset($bankDataJson['ville_notaire'])) à {{ $bankDataJson['ville_notaire'] }}@endif

@endif
@else

Aucune information financière disponible.

@endif
Documents justificatifs
@php $documentsTask = collect($workflowData['tasks'] ?? []) ->filter(function ($t) { return $t->type && !$t->type->isCategory() && $t->type === TaskType::FORMULAIRE_DOCUMENTS_JUSTIFICATIFS; }) ->first(); $documentsTaskReservation = $documentsTask ? $taskReservations->get($documentsTask->id) : null; $documentsTaskIsTerminee = $documentsTaskReservation && $documentsTaskReservation->state === TaskState::TERMINEE; @endphp @if($documentsTask && $documentsTaskIsTerminee)
@csrf
@endif
@php $documents = $reservation->documents() ->whereNotIn('type', ['contrat', 'contrat_signe']) ->orderBy('order') ->get(); $documentsByType = $documents->groupBy('type'); @endphp @if($documents->count() > 0)
@foreach($documentsByType as $type => $typeDocuments)
{{ \App\Enums\DocumentTypeReservation::tryFrom($type)?->label() ?? $type }}
    @foreach($typeDocuments as $document)
  • {{ $document->name }}
    {{ number_format($document->file_size / 1024, 2) }} Ko @if($document->token) @endif
  • @endforeach
@endforeach
@else

Aucun document téléchargé.

@endif
@php $isRelectureTask = $currentTask && $currentTask->type === TaskType::RELECTURE_ET_VALIDATION_DU_DOSSIER; @endphp @if(!$isRelectureTask)
@csrf
@endif @if($isRelectureTask && $currentTask && $currentTask->contract_template_id)
@csrf
@endif
@endif @if($isCurrentTask && $childTask->type === TaskType::ENVOI_EN_SIGNATURE_ELECTRONIQUE) @php $contractDocument = $reservation->documents()->where('type', 'contrat')->first(); $currentTaskReservation = $taskReservations->get($childTask->id); $needSignature = $currentTaskReservation && $currentTaskReservation->need_signature; $hasSignatureId = $currentTaskReservation && $currentTaskReservation->signature_id; \Illuminate\Support\Facades\Log::info('Reservation show - Section ENVOI_EN_SIGNATURE_ELECTRONIQUE', [ 'task_id' => $childTask->id, 'is_current_task' => $isCurrentTask, 'task_type' => $childTask->type?->value, 'has_contract_document' => $contractDocument !== null, 'contract_document_id' => $contractDocument?->id, 'has_current_task_reservation' => $currentTaskReservation !== null, 'task_reservation_id' => $currentTaskReservation?->id, 'need_signature' => $needSignature, 'need_signature_value' => $currentTaskReservation?->need_signature, 'has_signature_id' => $hasSignatureId, 'signature_id_value' => $currentTaskReservation?->signature_id, 'condition_1' => $needSignature && !$hasSignatureId, 'condition_2' => $needSignature && $hasSignatureId, 'condition_3' => !($needSignature && !$hasSignatureId) && !($needSignature && $hasSignatureId), ]); @endphp
@if($contractDocument)
@if($contractDocument->token)
@endif
@endif @if($needSignature && !$hasSignatureId) @php \Illuminate\Support\Facades\Log::info('Reservation show - Affichage: En attente prestataire de signature'); @endphp

En attente prestataire de signature

@elseif($needSignature && $hasSignatureId) @php \Illuminate\Support\Facades\Log::info('Reservation show - Affichage: En attente de signature'); @endphp

En attente de signature

@else @php \Illuminate\Support\Facades\Log::info('Reservation show - Affichage: Bouton Envoyer en signature électronique'); @endphp
@csrf
@endif
@endif @if($isCurrentTask && $childTask->type === TaskType::SIGNATURE_ELECTRONIQUE_EN_ATTENTE) @php // Récupérer la date d'envoi depuis la TaskReservation de ENVOI_EN_SIGNATURE_ELECTRONIQUE $envoiSignatureTask = collect($workflowData['tasks'] ?? []) ->filter(function ($t) { return $t->type && !$t->type->isCategory() && $t->type === TaskType::ENVOI_EN_SIGNATURE_ELECTRONIQUE; }) ->first(); $envoiSignatureTaskReservation = $envoiSignatureTask ? $taskReservations->get($envoiSignatureTask->id) : null; $dateEnvoi = $envoiSignatureTaskReservation && $envoiSignatureTaskReservation->finished_at ? $envoiSignatureTaskReservation->finished_at : null; @endphp
@if($dateEnvoi)

Votre client a reçu un lien YouSign le {{ $dateEnvoi->format('d/m/Y à H:i') }} par mail pour signature électronique de son contrat de réservation. Bonne signature !

@endif
@endif @if($isCurrentTask && $childTask->type === TaskType::CONTRAT_SIGNE) @php $signedContractDocument = $reservation->documents()->where('type', 'contrat_signe')->first(); @endphp
@if($signedContractDocument)
@if($signedContractDocument->token) Télécharger le contrat de réservation signé @endif @if($reservation->signed_by_clients_at)
Date de signature : {{ $reservation->signed_by_clients_at->format('d/m/Y à H:i') }}
@endif
@endif
@endif @endif
@endif @endforeach @else

Aucune tâche en cours.

@endif
@else

Aucun workflow associé à cette réservation.

@endif
@push('scripts') @endpush @endsection