wip: group inquiries and bookings
This commit is contained in:
1 parent
eba1a901d6
commit
3c9caeaad0
115 files changed
+8107
-424
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Repository\Groups\AccommodationPriceRepository;
|
||||
|
||||
class AccommodationBookingBreakdownCalculator
|
||||
{
|
||||
public function __construct(
|
||||
private readonly GroupsPriceCalculator $priceCalculator,
|
||||
private readonly AccommodationPriceRepository $priceRepo,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Recomputes the price breakdown from the booking's frozen snapshot data and current
|
||||
* accommodation prices for the same date range.
|
||||
*
|
||||
* @return array<string, mixed>|null null when no accommodation or dates are set
|
||||
*/
|
||||
public function compute(AccommodationBooking $booking): ?array
|
||||
{
|
||||
$accommodation = $booking->getAccommodation();
|
||||
$dateFrom = $booking->getDateFrom();
|
||||
$dateTo = $booking->getDateTo();
|
||||
|
||||
if (null === $accommodation || null === $dateFrom || null === $dateTo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$prices = $this->priceRepo->findByHotelCodeAndDateRange(
|
||||
$accommodation->getCalendarCode() ?? '',
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
);
|
||||
|
||||
return $this->priceCalculator->calculateFromSnapshots(
|
||||
$booking->getPaxCount(),
|
||||
$booking->getMinorsCount(),
|
||||
$booking->getNights(),
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$prices,
|
||||
$booking->getBoardServicePrice(),
|
||||
$booking->getAdditionalServices(),
|
||||
$accommodation->getCurrency(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user