finish interatred promotion
This commit is contained in:
@@ -170,6 +170,7 @@ class ContratController extends AbstractController
|
||||
$totalDays = $totals['days'];
|
||||
$totalHT = $totals['totalHT'];
|
||||
$totalTTC = $totals['totalTTC'];
|
||||
$totalHT_BeforeDiscount = $totals['totalHT_BeforeDiscount']; // Add this line
|
||||
$totalCaution = $totals['totalCaution'];
|
||||
$arrhes = $totals['arrhes'];
|
||||
$solde = $totals['solde']; // This is total contract value
|
||||
@@ -270,7 +271,8 @@ class ContratController extends AbstractController
|
||||
return $this->render('reservation/contrat/view.twig', [
|
||||
'contrat' => $contrat,
|
||||
'days' => $totalDays,
|
||||
'totalHT' => $totalHT,
|
||||
'totalHT' => $totalHT, // Discounted HT
|
||||
'totalHT_BeforeDiscount' => $totalHT_BeforeDiscount, // Raw HT
|
||||
'totalCaution' => $totalCaution,
|
||||
'arrhes' => $arrhes,
|
||||
'totalTTC' => $totalTTC,
|
||||
@@ -410,9 +412,42 @@ class ContratController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
$processedContrats = [];
|
||||
foreach ($customer->getContrats() as $contrat) {
|
||||
$tvaEnabled = isset($_ENV['TVA_ENABLED']) && $_ENV['TVA_ENABLED'] === "true";
|
||||
$totals = $this->calculateContractTotals($contrat, $tvaEnabled);
|
||||
|
||||
$totalDays = $totals['days'];
|
||||
$totalHT = $totals['totalHT'];
|
||||
$totalTTC = $totals['totalTTC'];
|
||||
$totalCaution = $totals['totalCaution'];
|
||||
$arrhes = $totals['arrhes'];
|
||||
$soldeCalculated = $totals['solde']; // This is total contract value before payments
|
||||
|
||||
$totalPaid = 0;
|
||||
foreach ($contrat->getContratsPayments() as $payment) {
|
||||
if ($payment->getState() === "complete") {
|
||||
$totalPaid += $payment->getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
// Augment the contract object with the calculated totals
|
||||
$contrat->totalDays = $totalDays;
|
||||
$contrat->totalHT = $totalHT;
|
||||
$contrat->totalTTC = $totalTTC;
|
||||
$contrat->totalCaution = $totalCaution;
|
||||
$contrat->arrhes = $arrhes;
|
||||
$contrat->totalPaid = $totalPaid;
|
||||
$contrat->soldeCalculated = $soldeCalculated; // Full value before payments
|
||||
|
||||
$processedContrats[] = $contrat;
|
||||
}
|
||||
|
||||
return $this->render('reservation/contrat/gestion_contrat.twig', [
|
||||
'active' => $active,
|
||||
'customer' => $customer
|
||||
'customer' => $customer,
|
||||
'tvaEnabled' => isset($_ENV['TVA_ENABLED']) && $_ENV['TVA_ENABLED'] === "true",
|
||||
'processedContrats' => $processedContrats,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -467,6 +502,8 @@ class ContratController extends AbstractController
|
||||
}
|
||||
}
|
||||
|
||||
$totalHT_BeforeDiscount = $totalHT; // Store total HT before discount
|
||||
|
||||
// --- GESTION PROMOTION ---
|
||||
$promotion = $devis?->getOrderSession()?->getPromotion();
|
||||
if ($promotion && isset($promotion['percentage'])) {
|
||||
@@ -488,7 +525,8 @@ class ContratController extends AbstractController
|
||||
|
||||
return [
|
||||
'days' => $totalDays,
|
||||
'totalHT' => $totalHT,
|
||||
'totalHT' => $totalHT, // This is the discounted HT
|
||||
'totalHT_BeforeDiscount' => $totalHT_BeforeDiscount, // Raw HT before discount
|
||||
'totalTTC' => $totalTTC,
|
||||
'totalCaution' => $totalCaution,
|
||||
'arrhes' => $arrhes,
|
||||
|
||||
@@ -123,7 +123,11 @@
|
||||
{% if active is defined and active != '' %}
|
||||
<div class="bg-white rounded-3xl p-6 md:p-10 shadow-xl border border-gray-100 animate-fade-in">
|
||||
{# Inclusion dynamique sécurisée #}
|
||||
{% include 'reservation/contrat/gestion_contrat/' ~ active ~ '.twig' ignore missing %}
|
||||
{% if active == 'contrats' %}
|
||||
{% include 'reservation/contrat/gestion_contrat/' ~ active ~ '.twig' with {'processedContrats': processedContrats} %}
|
||||
{% else %}
|
||||
{% include 'reservation/contrat/gestion_contrat/' ~ active ~ '.twig' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
{# Message si aucune section n'est sélectionnée #}
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
|
||||
{# --- LISTE DES CONTRATS --- #}
|
||||
<div class="grid grid-cols-1 gap-6">
|
||||
{% for contrat in customer.contrats %}
|
||||
{% for contrat in processedContrats|default(customer.contrats) %}
|
||||
<div class="bg-white rounded-[2.5rem] border border-gray-100 p-6 md:p-8 shadow-sm hover:shadow-xl transition-all duration-300 group">
|
||||
{% set dateAt = contrat.dateAt %}
|
||||
{% set endAt = contrat.endAt %}
|
||||
{% set days = (dateAt and endAt) ? dateAt.diff(endAt).days + 1 : 1 %}
|
||||
<div class="flex flex-col lg:flex-row gap-8">
|
||||
|
||||
{# COLONNE 1 : IDENTIFICATION ET LIEU #}
|
||||
@@ -41,6 +44,42 @@
|
||||
{{ contrat.zipCodeEvent }} {{ contrat.townEvent|upper }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{# Détails de la Réservation: Formule et Promotion #}
|
||||
<div class="bg-gray-50 rounded-2xl p-4 border border-gray-100">
|
||||
<div class="flex items-center gap-2 mb-2 text-gray-400">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01" /></svg>
|
||||
<p class="text-[10px] font-bold uppercase tracking-widest">Détails de la Réservation</p>
|
||||
</div>
|
||||
<p class="text-sm font-bold text-gray-800 leading-snug">
|
||||
Durée: {{ days }} Jour(s)<br>
|
||||
{% if contrat.devis %}
|
||||
{% if contrat.devis.formule %}
|
||||
{% set formule = contrat.devis.formule %}
|
||||
Formule: {{ formule.name|default('N/A') }}<br>
|
||||
{% set fPrice = formule.price1j ?? 0 %}
|
||||
{% if days >= 2 and formule.price2j %}{% set fPrice = formule.price2j %}{% endif %}
|
||||
{% if days >= 5 and formule.price5j %}{% set fPrice = formule.price5j %}{% endif %}
|
||||
|
||||
{% if tvaEnabled %}
|
||||
{% set fPriceDisplay = fPrice * 1.20 %}
|
||||
{% else %}
|
||||
{% set fPriceDisplay = fPrice %}
|
||||
{% endif %}
|
||||
Prix Formule: {{ fPriceDisplay|number_format(2, ',', ' ') }} €<br>
|
||||
{% endif %}
|
||||
|
||||
{% set promotion = contrat.devis.orderSession.promotion|default(null) %}
|
||||
{% if promotion and promotion.percentage %}
|
||||
Promotion: -{{ promotion.percentage }}%
|
||||
{% endif %}
|
||||
{% else %}
|
||||
Formule: N/A<br>
|
||||
Promotion: N/A<br>
|
||||
Prix: N/A
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# COLONNE 2 : FINANCES ET ÉTAT DES PAIEMENTS #}
|
||||
@@ -50,15 +89,15 @@
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4 mb-8">
|
||||
<div class="p-4 bg-blue-50/50 rounded-2xl border border-blue-100/50">
|
||||
<p class="text-[10px] font-bold text-blue-400 uppercase mb-1 tracking-tighter">Total Contrat</p>
|
||||
<p class="text-lg font-black text-blue-700">{{ contrat|totalContrat }} €</p>
|
||||
<p class="text-lg font-black text-blue-700">{{ contrat.totalTTC|number_format(2, ',', ' ') }} €</p>
|
||||
</div>
|
||||
<div class="p-4 bg-orange-50/50 rounded-2xl border border-orange-100/50">
|
||||
<p class="text-[10px] font-bold text-orange-400 uppercase mb-1 tracking-tighter">Arrhes (25%)</p>
|
||||
<p class="text-lg font-black text-orange-700">{{ (contrat|totalContrat * 0.25)|number_format(2, ',', ' ') }} €</p>
|
||||
<p class="text-lg font-black text-orange-700">{{ contrat.arrhes|number_format(2, ',', ' ') }} €</p>
|
||||
</div>
|
||||
<div class="p-4 bg-green-50/50 rounded-2xl border border-green-100/50">
|
||||
<p class="text-[10px] font-bold text-green-400 uppercase mb-1 tracking-tighter">Déjà versé</p>
|
||||
<p class="text-lg font-black text-green-700">{{ contrat|totalContratAccompte }} €</p>
|
||||
<p class="text-lg font-black text-green-700">{{ contrat.totalPaid|number_format(2, ',', ' ') }} €</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -220,20 +220,17 @@
|
||||
{% set promoPercentage = contrat.devis.orderSession.promotion.percentage %}
|
||||
{% endif %}
|
||||
|
||||
{% set totalHT_Discounted = totalHT * (1 - (promoPercentage / 100)) %}
|
||||
{% set totalTTC_Discounted = totalTTC * (1 - (promoPercentage / 100)) %}
|
||||
|
||||
{# TOTAL HT #}
|
||||
<div class="bg-white rounded-[1.5rem] p-6 border border-slate-100 shadow-sm flex justify-between items-center">
|
||||
<div>
|
||||
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Total Prestations</p>
|
||||
<p class="text-xs font-bold text-slate-400 italic">Hors Taxes (HT)</p>
|
||||
{% if promoPercentage > 0 %}
|
||||
<p class="text-[10px] text-slate-400 font-bold line-through decoration-red-400 decoration-2">{{ totalHT|number_format(2, ',', ' ') }}€</p>
|
||||
<p class="text-[10px] text-slate-400 font-bold line-through decoration-red-400 decoration-2">{{ totalHT_BeforeDiscount|number_format(2, ',', ' ') }}€</p>
|
||||
<p class="text-[10px] text-emerald-500 font-black uppercase tracking-wider">Promo -{{ promoPercentage }}%</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<p class="text-3xl font-black text-slate-900 italic tracking-tighter">{{ totalHT_Discounted|number_format(2, ',', ' ') }}€</p>
|
||||
<p class="text-3xl font-black text-slate-900 italic tracking-tighter">{{ totalHT|number_format(2, ',', ' ') }}€</p>
|
||||
</div>
|
||||
|
||||
{% if tvaEnabled %}
|
||||
@@ -242,14 +239,14 @@
|
||||
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Total Prestations</p>
|
||||
<p class="text-xs font-bold text-slate-400 italic">Total TVA</p>
|
||||
</div>
|
||||
<p class="text-3xl font-black text-slate-900 italic tracking-tighter">{{ (totalTTC_Discounted - totalHT_Discounted)|number_format(2, ',', ' ') }}€</p>
|
||||
<p class="text-3xl font-black text-slate-900 italic tracking-tighter">{{ (totalTTC - totalHT)|number_format(2, ',', ' ') }}€</p>
|
||||
</div>
|
||||
<div class="bg-white rounded-[1.5rem] p-6 border border-slate-100 shadow-sm flex justify-between items-center">
|
||||
<div>
|
||||
<p class="text-[9px] font-black text-slate-400 uppercase tracking-widest">Total Prestations</p>
|
||||
<p class="text-xs font-bold text-slate-400 italic">Total TTC</p>
|
||||
</div>
|
||||
<p class="text-3xl font-black text-slate-900 italic tracking-tighter">{{ totalTTC_Discounted|number_format(2, ',', ' ') }}€</p>
|
||||
<p class="text-3xl font-black text-slate-900 italic tracking-tighter">{{ totalTTC|number_format(2, ',', ' ') }}€</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -274,9 +271,9 @@
|
||||
{% for p in paymentCtaList %}{% set totalPaid = totalPaid + p.amount %}{% endfor %}
|
||||
|
||||
{% if tvaEnabled %}
|
||||
{% set newSolde = totalTTC_Discounted - totalPaid %}
|
||||
{% set newSolde = totalTTC - totalPaid %}
|
||||
{% else %}
|
||||
{% set newSolde = totalHT_Discounted - totalPaid %}
|
||||
{% set newSolde = totalHT - totalPaid %}
|
||||
{% endif %}
|
||||
|
||||
{# SOLDE FINAL - Bloc Principal avec saisie du montant #}
|
||||
|
||||
Reference in New Issue
Block a user