Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
716cf56cb2.url-de-test.ws
/
htdocs
/
src
/
Service
/
/srv/data/web/vhosts/716cf56cb2.url-de-test.ws/htdocs/src/Service/CalculPriceVisit.php
<?php namespace App\Service; use App\Entity\Logement; class CalculPriceVisit { public function totalPrice(array $dates, Logement $logement) { $visitDuration = $dates['start']->diff($dates['end'])->days; $priceOptions = 0; foreach ($logement->getOptions() as $option) { if ($option->isIsRequired()) { $priceOptions += $option->getPrice(); } } $plArray = []; foreach ($logement->getPricesLogements() as $priceLogement) { $plArray[$priceLogement->getDate()->format('Y-m-d')] = $priceLogement; } $priceLogement = 0; $currentDate = new \DateTime($dates['start']->format('Y-m-d')); while ($currentDate < new \DateTime($dates['end']->format('Y-m-d'))) { if ($visitDuration >= 7) { $priceLogement += isset($plArray[$currentDate->format('Y-m-d')]) ? $plArray[$currentDate->format('Y-m-d')]->getPriceWeek() : $logement->getPrice(); } else { $priceLogement += isset($plArray[$currentDate->format('Y-m-d')]) ? $plArray[$currentDate->format('Y-m-d')]->getPriceNight() : $logement->getPrice(); } $currentDate->modify('+1 day'); } $totalPrice = $priceLogement + $priceOptions; return $totalPrice; } public function accompte(int $total) { $accompte = ($total * 30) / 100; $rest = $total - $accompte; return [ 'accompte' => $accompte, 'rest' => $rest ]; } }