✨ feat(réservation): Applique les promotions au devis et les affiche dans l'e-mail de confirmation
This commit is contained in:
@@ -101,6 +101,7 @@ class ReserverController extends AbstractController
|
||||
$devis->setEndAt($dates['end']);
|
||||
|
||||
$selectedOptionsMap = $sessionData['options'] ?? [];
|
||||
$runningTotalHT = 0;
|
||||
|
||||
if (!empty($ids)) {
|
||||
$products = $productRepository->findBy(['id' => $ids]);
|
||||
@@ -116,6 +117,8 @@ class ReserverController extends AbstractController
|
||||
$line->setDay($duration);
|
||||
$devis->addDevisLine($line);
|
||||
|
||||
$runningTotalHT += $product->getPriceDay() + ($product->getPriceSup() * max(0, $duration - 1));
|
||||
|
||||
if (isset($selectedOptionsMap[$product->getId()])) {
|
||||
$optionIds = $selectedOptionsMap[$product->getId()];
|
||||
if (!empty($optionIds)) {
|
||||
@@ -127,6 +130,8 @@ class ReserverController extends AbstractController
|
||||
$lineOpt->setPriceHtSup(0);
|
||||
$lineOpt->setDay($duration);
|
||||
$devis->addDevisLine($lineOpt);
|
||||
|
||||
$runningTotalHT += $option->getPriceHt();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,11 +147,24 @@ class ReserverController extends AbstractController
|
||||
$lineOpt->setPriceHtSup(0);
|
||||
$lineOpt->setDay($duration);
|
||||
$devis->addDevisLine($lineOpt);
|
||||
|
||||
$runningTotalHT += $option->getPriceHt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$promoData = $session->getPromotion();
|
||||
if ($promoData && $runningTotalHT > 0) {
|
||||
$discount = $runningTotalHT * ($promoData['percentage'] / 100);
|
||||
$promoLine = new DevisLine();
|
||||
$promoLine->setProduct("Promotion : " . $promoData['name'] . " (-" . $promoData['percentage'] . "%)");
|
||||
$promoLine->setPriceHt(-$discount);
|
||||
$promoLine->setPriceHtSup(0);
|
||||
$promoLine->setDay(1);
|
||||
$devis->addDevisLine($promoLine);
|
||||
}
|
||||
|
||||
$pdfService = new DevisPdfService($this->kernel, $devis, $productRepository);
|
||||
$content = $pdfService->generate();
|
||||
|
||||
|
||||
@@ -34,6 +34,16 @@
|
||||
<b>Lieu :</b> {{ datas.session.adressEvent }} {{ datas.session.zipCodeEvent }} {{ datas.session.townEvent }}
|
||||
</mj-text>
|
||||
|
||||
{% if datas.session.promotion %}
|
||||
<mj-text padding-top="25px" padding-bottom="0px" font-size="10px" font-weight="900" color="#f59e0b" text-transform="uppercase" letter-spacing="1px">
|
||||
Promotion Appliquée
|
||||
</mj-text>
|
||||
<mj-text font-size="15px" color="#0f172a" padding-top="5px">
|
||||
<b>Offre :</b> {{ datas.session.promotion.name }} <br/>
|
||||
<b>Réduction :</b> -{{ datas.session.promotion.percentage }}%
|
||||
</mj-text>
|
||||
{% endif %}
|
||||
|
||||
<mj-text padding-top="25px" padding-bottom="0px" font-size="10px" font-weight="900" color="#94a3b8" text-transform="uppercase" letter-spacing="1px">
|
||||
Lien vers la session
|
||||
</mj-text>
|
||||
|
||||
Reference in New Issue
Block a user