@php
$lotPrices = $lot->prices;
$prixImmoTTC = $lotPrices->where('type', 'prix_immo_ttc')->first()?->value ?? 0;
// Le prix foncier est calculé : Prix de vente TTC - Total des travaux en read_only
$prixFoncier = $lot->getPrixFoncier();
$prixTravauxTotal = ($lotPrices->where('type', \App\Enums\PriceTypeTravaux::PRIX_TRAVAUX_ELIGIBLE->value)->first()?->value ?? 0) + ($lotPrices->where('type', \App\Enums\PriceTypeTravaux::PRIX_TRAVAUX_NON_ELIGIBLE->value)->first()?->value ?? 0);
$loyerMensuelTTC = $lotPrices->where('type', \App\Enums\PriceTypeLoyer::MENSUEL_TTC->value)->first()?->value ?? 0;
$loyerMensuel = $lotPrices->where('type', 'loyer_mensuel')->first()?->value ?? 0;
// Date de livraison du programme
$program = $lot->program;
$dateLivraison = $program->dates->where('type', 'date_livraison')->first();
$dateLivraisonValue = $dateLivraison ? $dateLivraison->value : null;
// Calcul du nombre d'années de travaux pour la répartition des appels de fonds
$nb_annees_repartiton = $dateLivraisonValue ? (intval(date('Y', strtotime($dateLivraisonValue))) - intval(date('Y')) + 1) : 1;
$nb_annees_repartiton = $nb_annees_repartiton < 1 ? 1 : $nb_annees_repartiton;
// Répartition par défaut en fonction du nombre d'années de travaux
$asl_repartitions = [
1 => [100, 0, 0, 0],
2 => [50, 50, 0, 0],
3 => [40, 30, 30, 0],
4 => [25, 25, 25, 25],
];
$vir_repartitions = [
1 => [100, 0, 0, 0],
2 => [90, 10, 0, 0],
3 => [60, 30, 10, 0],
4 => [30, 30, 30, 10],
];
$repartition = [25, 25, 25, 25];
// Déterminer le type de contrat (ASL ou VIR)
// Le contrat_type est casté en ContratTypeProgram enum dans le modèle Program
$contratType = $program->contrat_type ?? null;
// Utiliser VIR si le type de contrat est VIR, sinon ASL par défaut
if (in_array($nb_annees_repartiton, [1, 2, 3, 4])) {
if ($contratType === \App\Enums\ContratTypeProgram::VIR) {
$repartition = $vir_repartitions[$nb_annees_repartiton];
} else {
// Par défaut ASL (ou si le type n'est pas défini)
$repartition = $asl_repartitions[$nb_annees_repartiton];
}
} else {
$repartition = [100, 0, 0, 0];
}
@endphp
Récapitulatif de l'investissement de votre client
€
€
€
%
Données nécessaires au calcul du financement de votre client