wip: modernized edit flow, fix insurance tier calculation
This commit is contained in:
@@ -8,7 +8,6 @@ use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
|
||||
@@ -57,10 +56,6 @@ class BookingPriceCalculatorService
|
||||
{
|
||||
$roomPricing = [];
|
||||
|
||||
if (false === $bookingDto instanceof BookingCreateDto) {
|
||||
return $roomPricing;
|
||||
}
|
||||
|
||||
$selectedRooms = $bookingDto->getSelectedRooms();
|
||||
if (true === empty($selectedRooms)) {
|
||||
return $roomPricing;
|
||||
@@ -196,16 +191,12 @@ class BookingPriceCalculatorService
|
||||
* including their room allocation (full room price) and all selected services.
|
||||
*
|
||||
* @param BookingDto $bookingDto The booking data containing all participants
|
||||
* @param int $participantIndex The index of the participant to calculate for
|
||||
* @param int $participantIndex The index of the participant to calculate for
|
||||
*
|
||||
* @return float The total price for the specified participant
|
||||
*/
|
||||
public function calculateIndividualParticipantPrice(BookingDto $bookingDto, int $participantIndex): float
|
||||
{
|
||||
if (false === $bookingDto instanceof BookingCreateDto) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
$participant = $bookingDto->getParticipant($participantIndex);
|
||||
if (null === $participant) {
|
||||
return 0.0;
|
||||
@@ -237,10 +228,6 @@ class BookingPriceCalculatorService
|
||||
*/
|
||||
public function calculateAllParticipantIndividualPrices(BookingDto $bookingDto): array
|
||||
{
|
||||
if (false === $bookingDto instanceof BookingCreateDto) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$participantPrices = [];
|
||||
$participants = $bookingDto->getParticipants();
|
||||
|
||||
@@ -257,17 +244,17 @@ class BookingPriceCalculatorService
|
||||
* This method is used for insurance eligibility filtering to avoid circular dependency
|
||||
* where insurance selection affects travel price which affects insurance eligibility.
|
||||
*
|
||||
* @param BookingDto $bookingDto The booking data containing all participants
|
||||
* @param int $participantIndex The index of the participant to calculate for
|
||||
* Only includes services where versicherungsberechnung='J' in the XML. Services with
|
||||
* versicherungsberechnung='N' (like CO² compensation) are excluded from the calculation
|
||||
* as per BPN API requirements for insurance tier determination.
|
||||
*
|
||||
* @return float The total price for the specified participant excluding insurance
|
||||
* @param BookingDto $bookingDto The booking data containing all participants
|
||||
* @param int $participantIndex The index of the participant to calculate for
|
||||
*
|
||||
* @return float The total price for the specified participant excluding insurance and non-calculated services
|
||||
*/
|
||||
public function calculateIndividualParticipantPriceExcludingInsurance(BookingDto $bookingDto, int $participantIndex): float
|
||||
{
|
||||
if (false === $bookingDto instanceof BookingCreateDto) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
$participant = $bookingDto->getParticipant($participantIndex);
|
||||
if (null === $participant) {
|
||||
return 0.0;
|
||||
@@ -285,7 +272,8 @@ class BookingPriceCalculatorService
|
||||
}
|
||||
|
||||
// Add service prices for this participant (excluding insurance)
|
||||
$totalPrice += $this->calculateParticipantServiceTotal($participant, false);
|
||||
// For insurance eligibility calculation, only include services marked with versicherungsberechnung='J'
|
||||
$totalPrice += $this->calculateParticipantServiceTotal($participant, false, null, true);
|
||||
|
||||
return $totalPrice;
|
||||
}
|
||||
@@ -528,23 +516,28 @@ class BookingPriceCalculatorService
|
||||
/**
|
||||
* Calculates the total service cost for a single participant.
|
||||
*
|
||||
* @param ParticipantDto $participant The participant to calculate services for
|
||||
* @param bool $includeInsurance Whether to include insurance pricing (default: true)
|
||||
* @param BookingDto|null $bookingDto Optional booking DTO for bulk insurance resolution
|
||||
* @param ParticipantDto $participant The participant to calculate services for
|
||||
* @param bool $includeInsurance Whether to include insurance pricing (default: true)
|
||||
* @param BookingDto|null $bookingDto Optional booking DTO for bulk insurance resolution
|
||||
* @param bool $onlyInsuranceCalculationServices Only include services with includeInInsuranceCalculation=true (default: false)
|
||||
*
|
||||
* @return float The total service cost for this participant
|
||||
*/
|
||||
private function calculateParticipantServiceTotal(ParticipantDto $participant, bool $includeInsurance = true, ?BookingDto $bookingDto = null): float
|
||||
private function calculateParticipantServiceTotal(ParticipantDto $participant, bool $includeInsurance = true, ?BookingDto $bookingDto = null, bool $onlyInsuranceCalculationServices = false): float
|
||||
{
|
||||
$serviceTotal = 0.0;
|
||||
|
||||
// Single service selections
|
||||
if (null !== $participant->skiPass && null !== $participant->skiPass->price) {
|
||||
$serviceTotal += $participant->skiPass->price;
|
||||
if (false === $onlyInsuranceCalculationServices || true === $participant->skiPass->includeInInsuranceCalculation) {
|
||||
$serviceTotal += $participant->skiPass->price;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $participant->rentalInsurance && null !== $participant->rentalInsurance->price) {
|
||||
$serviceTotal += $participant->rentalInsurance->price;
|
||||
if (false === $onlyInsuranceCalculationServices || true === $participant->rentalInsurance->includeInInsuranceCalculation) {
|
||||
$serviceTotal += $participant->rentalInsurance->price;
|
||||
}
|
||||
}
|
||||
|
||||
// Get effective insurance (considering bulk insurance for dependent participants)
|
||||
@@ -555,11 +548,15 @@ class BookingPriceCalculatorService
|
||||
|
||||
// Transportation services
|
||||
if (null !== $participant->transportationOutbound && null !== $participant->transportationOutbound->price) {
|
||||
$serviceTotal += $participant->transportationOutbound->price;
|
||||
if (false === $onlyInsuranceCalculationServices || true === $participant->transportationOutbound->includeInInsuranceCalculation) {
|
||||
$serviceTotal += $participant->transportationOutbound->price;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $participant->transportationInbound && null !== $participant->transportationInbound->price) {
|
||||
$serviceTotal += $participant->transportationInbound->price;
|
||||
if (false === $onlyInsuranceCalculationServices || true === $participant->transportationInbound->includeInInsuranceCalculation) {
|
||||
$serviceTotal += $participant->transportationInbound->price;
|
||||
}
|
||||
}
|
||||
|
||||
if (null !== $participant->pickup && null !== $participant->pickup->price) {
|
||||
@@ -567,7 +564,9 @@ class BookingPriceCalculatorService
|
||||
}
|
||||
|
||||
if (null !== $participant->parkingService && null !== $participant->parkingService->price) {
|
||||
$serviceTotal += $participant->parkingService->price;
|
||||
if (false === $onlyInsuranceCalculationServices || true === $participant->parkingService->includeInInsuranceCalculation) {
|
||||
$serviceTotal += $participant->parkingService->price;
|
||||
}
|
||||
}
|
||||
|
||||
// Multiple service selections
|
||||
@@ -582,7 +581,9 @@ class BookingPriceCalculatorService
|
||||
if (true === is_array($serviceArray)) {
|
||||
foreach ($serviceArray as $service) {
|
||||
if ($service instanceof Service && null !== $service->price) {
|
||||
$serviceTotal += $service->price;
|
||||
if (false === $onlyInsuranceCalculationServices || true === $service->includeInInsuranceCalculation) {
|
||||
$serviceTotal += $service->price;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -594,7 +595,7 @@ class BookingPriceCalculatorService
|
||||
/**
|
||||
* Retrieves a room by ID from the booking's travel data.
|
||||
*/
|
||||
private function getRoomById(BookingCreateDto $bookingDto, ?int $roomId): ?Room
|
||||
private function getRoomById(BookingDto $bookingDto, ?int $roomId): ?Room
|
||||
{
|
||||
if (null === $roomId) {
|
||||
return null;
|
||||
@@ -644,7 +645,7 @@ class BookingPriceCalculatorService
|
||||
* This method is used for pricing calculations to show correct prices when bulk
|
||||
* insurance is enabled, even though the actual assignment happens in the processor.
|
||||
*
|
||||
* @param ParticipantDto $participant The participant to get insurance for
|
||||
* @param ParticipantDto $participant The participant to get insurance for
|
||||
* @param BookingDto|null $bookingDto Optional booking DTO for bulk insurance check
|
||||
*
|
||||
* @return Insurance|null The effective insurance for pricing purposes
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Exception\BookingSessionNotFoundException;
|
||||
use App\Exception\NoRoomsAvailableException;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\RoomSelectionDto;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -32,7 +31,7 @@ class BookingService
|
||||
* is first loaded, before any HTMX modifications. This ensures accurate change
|
||||
* detection for room assignment resets.
|
||||
*/
|
||||
public function getOrCreateBaselineSnapshot(Request $request, BookingCreateDto $bookingCreateDto): array
|
||||
public function getOrCreateBaselineSnapshot(Request $request, BookingDto $bookingCreateDto): array
|
||||
{
|
||||
$baselineKey = self::BOOKING_CREATE_BASELINE_KEY;
|
||||
|
||||
@@ -66,11 +65,11 @@ class BookingService
|
||||
*
|
||||
* @param Request $request The HTTP request containing session data
|
||||
*
|
||||
* @return BookingCreateDto The booking DTO from session
|
||||
* @return BookingDto The booking DTO from session
|
||||
*
|
||||
* @throws BookingSessionNotFoundException When no valid booking session exists
|
||||
*/
|
||||
public function getOrCreateBookingCreateDto(Request $request): BookingCreateDto
|
||||
public function getOrCreateBookingCreateDto(Request $request): BookingDto
|
||||
{
|
||||
$bookingCreateDto = $request->getSession()->get(self::BOOKING_CREATE_KEY);
|
||||
|
||||
@@ -130,9 +129,9 @@ class BookingService
|
||||
* across multiple HTTP requests during the booking flow.
|
||||
*
|
||||
* @param Request $request The HTTP request with session
|
||||
* @param BookingCreateDto $bookingCreateDto The booking DTO to persist
|
||||
* @param BookingDto $bookingCreateDto The booking DTO to persist
|
||||
*/
|
||||
public function saveBookingCreateDto(Request $request, BookingCreateDto $bookingCreateDto): void
|
||||
public function saveBookingCreateDto(Request $request, BookingDto $bookingCreateDto): void
|
||||
{
|
||||
$this->saveBookingDto($request, $bookingCreateDto, BookingDto::MODE_CREATE);
|
||||
}
|
||||
@@ -164,11 +163,11 @@ class BookingService
|
||||
/**
|
||||
* Creates a fresh booking session with the provided travel parameters.
|
||||
*
|
||||
* This method initializes a new BookingCreateDto with empty room selections
|
||||
* This method initializes a new BookingDto with empty room selections
|
||||
* and saves it to the session. It's designed to be called from the clean
|
||||
* booking entry point without requiring UID parameters.
|
||||
*/
|
||||
public function startFreshBooking(Request $request, int $dateId, int $hotelId, ?int $agencyId = null): BookingCreateDto
|
||||
public function startFreshBooking(Request $request, int $dateId, int $hotelId, ?int $agencyId = null): BookingDto
|
||||
{
|
||||
$travelData = $this->travelDataService->getTravelData($dateId, $hotelId);
|
||||
if (null === $travelData) {
|
||||
@@ -188,7 +187,7 @@ class BookingService
|
||||
$availableRooms
|
||||
);
|
||||
|
||||
$bookingCreateDto = new BookingCreateDto($travelData, $hotelId);
|
||||
$bookingCreateDto = new BookingDto($travelData, $hotelId);
|
||||
$bookingCreateDto->roomSelections = $roomSelections;
|
||||
$bookingCreateDto->currentStep = 1;
|
||||
$bookingCreateDto->agencyId = $agencyId;
|
||||
@@ -344,9 +343,9 @@ class BookingService
|
||||
* invalid assignments. Called when users modify their room selections
|
||||
* in step 1 to ensure participants are reassigned appropriately.
|
||||
*
|
||||
* @param BookingCreateDto $dto The booking DTO to reset assignments for
|
||||
* @param BookingDto $dto The booking DTO to reset assignments for
|
||||
*/
|
||||
public function resetParticipantAssignments(BookingCreateDto $dto): void
|
||||
public function resetParticipantAssignments(BookingDto $dto): void
|
||||
{
|
||||
foreach ($dto->participants as $participant) {
|
||||
$participant->assignedRoomId = null;
|
||||
@@ -358,7 +357,7 @@ class BookingService
|
||||
*
|
||||
* @return array<int, array{int, int}> Array of [roomId, quantity] pairs
|
||||
*/
|
||||
public function createRoomSelectionSnapshot(BookingCreateDto $dto): array
|
||||
public function createRoomSelectionSnapshot(BookingDto $dto): array
|
||||
{
|
||||
return array_map(
|
||||
fn ($roomSelection) => [(int) $roomSelection->roomId, (int) $roomSelection->quantity],
|
||||
@@ -373,11 +372,11 @@ class BookingService
|
||||
* to detect changes that would require participant reassignment.
|
||||
*
|
||||
* @param array $oldSnapshot The baseline room selection snapshot
|
||||
* @param BookingCreateDto $newDto The current booking DTO
|
||||
* @param BookingDto $newDto The current booking DTO
|
||||
*
|
||||
* @return bool True if room selections have changed, false otherwise
|
||||
*/
|
||||
public function hasRoomSelectionChanged(array $oldSnapshot, BookingCreateDto $newDto): bool
|
||||
public function hasRoomSelectionChanged(array $oldSnapshot, BookingDto $newDto): bool
|
||||
{
|
||||
$newSnapshot = $this->createRoomSelectionSnapshot($newDto);
|
||||
|
||||
@@ -395,9 +394,9 @@ class BookingService
|
||||
* have at least one skipass available for their age. Ineligible participants are
|
||||
* skipped to prevent their mandatory services from being included in pricing.
|
||||
*
|
||||
* @param BookingCreateDto $bookingDto The booking DTO to update with mandatory services
|
||||
* @param BookingDto $bookingDto The booking DTO to update with mandatory services
|
||||
*/
|
||||
public function preselectMandatoryServices(BookingCreateDto $bookingDto): void
|
||||
public function preselectMandatoryServices(BookingDto $bookingDto): void
|
||||
{
|
||||
$additionalServices = $bookingDto->travel->getAdditionalServicesBySubTypes(\App\BusProNet\Constants::TOKEN_ADDITIONAL);
|
||||
$mandatoryServices = array_filter($additionalServices, fn ($service) => true === $service->mandatory);
|
||||
|
||||
@@ -6,7 +6,6 @@ namespace App\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Traits\SortByPriceTrait;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Model\InsuranceEligibilityCriteria;
|
||||
@@ -31,9 +30,9 @@ class InsuranceMatchingService
|
||||
/**
|
||||
* Filters insurances based on participant and booking criteria.
|
||||
*
|
||||
* @param array<Insurance> $insurances Available insurances to filter
|
||||
* @param ParticipantDto $participant The participant to match insurances for
|
||||
* @param BookingDto $booking The booking context for additional criteria
|
||||
* @param array<Insurance> $insurances Available insurances to filter
|
||||
* @param ParticipantDto $participant The participant to match insurances for
|
||||
* @param BookingDto $booking The booking context for additional criteria
|
||||
*
|
||||
* @return array<Insurance> Filtered array of eligible insurances
|
||||
*/
|
||||
@@ -60,10 +59,10 @@ class InsuranceMatchingService
|
||||
* current insurance is no longer eligible. It finds the same insurance type
|
||||
* (subType + familyInsurance) with the correct price tier.
|
||||
*
|
||||
* @param array<Insurance> $availableInsurances All available insurances
|
||||
* @param Insurance $currentInsurance The currently selected insurance
|
||||
* @param ParticipantDto $participant The participant to reassign for
|
||||
* @param BookingDto $booking The booking context
|
||||
* @param array<Insurance> $availableInsurances All available insurances
|
||||
* @param Insurance $currentInsurance The currently selected insurance
|
||||
* @param ParticipantDto $participant The participant to reassign for
|
||||
* @param BookingDto $booking The booking context
|
||||
*
|
||||
* @return Insurance|null The reassigned insurance or null if no suitable match found
|
||||
*/
|
||||
@@ -90,9 +89,9 @@ class InsuranceMatchingService
|
||||
* (subType + familyInsurance) to all participants, but selects the appropriate price tier
|
||||
* based on each participant's individual travel price.
|
||||
*
|
||||
* @param array<Insurance> $availableInsurances All available insurances
|
||||
* @param Insurance $selectedInsurance The insurance selected by the applicant
|
||||
* @param BookingDto $booking The booking with all participants
|
||||
* @param array<Insurance> $availableInsurances All available insurances
|
||||
* @param Insurance $selectedInsurance The insurance selected by the applicant
|
||||
* @param BookingDto $booking The booking with all participants
|
||||
*
|
||||
* @return array<int, Insurance|null> Array indexed by participant index with assigned insurances
|
||||
*
|
||||
@@ -187,8 +186,8 @@ class InsuranceMatchingService
|
||||
*/
|
||||
private function checkFamilyInsuranceConstraints(Insurance $insurance, BookingDto $booking): bool
|
||||
{
|
||||
// Family booking detection only available in BookingCreateDto
|
||||
if (!$booking instanceof BookingCreateDto) {
|
||||
// Family booking detection only available in create mode
|
||||
if (BookingDto::MODE_EDIT === $booking->getMode()) {
|
||||
return true; // Skip family constraints for edit mode
|
||||
}
|
||||
|
||||
@@ -316,14 +315,34 @@ class InsuranceMatchingService
|
||||
* affects travel price which then affects insurance eligibility.
|
||||
*
|
||||
* @param BookingDto $booking The booking to calculate price for
|
||||
* @param int $participantIndex The participant index to calculate for
|
||||
* @param int $participantIndex The participant index to calculate for
|
||||
*
|
||||
* @return float The total travel price for the participant excluding insurance
|
||||
*/
|
||||
private function calculateTravelPrice(BookingDto $booking, int $participantIndex): float
|
||||
{
|
||||
$participant = $booking->getParticipant($participantIndex);
|
||||
|
||||
// Debug logging to understand price calculation
|
||||
if (null !== $participant && null !== $participant->insurance) {
|
||||
error_log(sprintf(
|
||||
'[InsuranceMatching] Participant %d: calculating travel price WITH insurance=%d (€%.2f) currently selected',
|
||||
$participantIndex,
|
||||
$participant->insurance->id,
|
||||
$participant->insurance->price ?? 0.0
|
||||
));
|
||||
}
|
||||
|
||||
// Use the price calculator to get the participant's individual price excluding insurance
|
||||
return $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($booking, $participantIndex);
|
||||
$travelPrice = $this->priceCalculatorService->calculateIndividualParticipantPriceExcludingInsurance($booking, $participantIndex);
|
||||
|
||||
error_log(sprintf(
|
||||
'[InsuranceMatching] Participant %d: calculated travel price (excluding insurance) = €%.2f',
|
||||
$participantIndex,
|
||||
$travelPrice
|
||||
));
|
||||
|
||||
return $travelPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
|
||||
/**
|
||||
* Handles automatic room assignment for booking participants.
|
||||
@@ -26,9 +26,9 @@ class RoomAssignmentService
|
||||
* - 2x "Doppelzimmer" (capacity 2) = participants 0-1 → room A, participants 2-3 → room A
|
||||
* - 1x "3-Bett-Zimmer" (capacity 3) = participants 4-6 → room B
|
||||
*
|
||||
* @param BookingCreateDto $dto The booking DTO containing room selections and participants
|
||||
* @param BookingDto $dto The booking DTO containing room selections and participants
|
||||
*/
|
||||
public function assignParticipantsToRooms(BookingCreateDto $dto): void
|
||||
public function assignParticipantsToRooms(BookingDto $dto): void
|
||||
{
|
||||
$participantIndex = 0;
|
||||
$selectedRooms = $dto->getSelectedRooms();
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace App\Service;
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Utility\DirectionMapper;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
|
||||
/**
|
||||
* Calculates dynamic service availability based on current booking selections.
|
||||
@@ -22,12 +22,12 @@ class ServiceAvailabilityCalculator
|
||||
/**
|
||||
* Calculate remaining availability for all services based on current participant selections.
|
||||
*
|
||||
* @param BookingCreateDto $bookingDto The booking data with participant selections
|
||||
* @param int $currentParticipantIndex The index of the participant currently filling the form
|
||||
* @param BookingDto $bookingDto The booking data with participant selections
|
||||
* @param int $currentParticipantIndex The index of the participant currently filling the form
|
||||
*
|
||||
* @return array<int, int> Array mapping service IDs to remaining availability counts
|
||||
*/
|
||||
public function calculateRemainingAvailability(BookingCreateDto $bookingDto, int $currentParticipantIndex): array
|
||||
public function calculateRemainingAvailability(BookingDto $bookingDto, int $currentParticipantIndex): array
|
||||
{
|
||||
$serviceUsage = $this->calculateServiceUsage($bookingDto, $currentParticipantIndex);
|
||||
$remainingAvailability = [];
|
||||
@@ -52,13 +52,13 @@ class ServiceAvailabilityCalculator
|
||||
/**
|
||||
* Filter services array to only include those with remaining availability.
|
||||
*
|
||||
* @param array $services Array of Service objects to filter
|
||||
* @param BookingCreateDto $bookingDto The booking data with participant selections
|
||||
* @param int $participantIndex The index of the participant currently filling the form
|
||||
* @param array $services Array of Service objects to filter
|
||||
* @param BookingDto $bookingDto The booking data with participant selections
|
||||
* @param int $participantIndex The index of the participant currently filling the form
|
||||
*
|
||||
* @return array Filtered array containing only available services
|
||||
*/
|
||||
public function filterAvailableServices(array $services, BookingCreateDto $bookingDto, int $participantIndex): array
|
||||
public function filterAvailableServices(array $services, BookingDto $bookingDto, int $participantIndex): array
|
||||
{
|
||||
$remainingAvailability = $this->calculateRemainingAvailability($bookingDto, $participantIndex);
|
||||
|
||||
@@ -76,13 +76,13 @@ class ServiceAvailabilityCalculator
|
||||
/**
|
||||
* Check if a specific service is unavailable (sold out) for the current participant.
|
||||
*
|
||||
* @param int $serviceId The ID of the service to check
|
||||
* @param BookingCreateDto $bookingDto The booking data with participant selections
|
||||
* @param int $participantIndex The index of the participant currently filling the form
|
||||
* @param int $serviceId The ID of the service to check
|
||||
* @param BookingDto $bookingDto The booking data with participant selections
|
||||
* @param int $participantIndex The index of the participant currently filling the form
|
||||
*
|
||||
* @return bool True if the service is unavailable (has availability limit and remaining is 0)
|
||||
*/
|
||||
public function isServiceUnavailable(int $serviceId, BookingCreateDto $bookingDto, int $participantIndex): bool
|
||||
public function isServiceUnavailable(int $serviceId, BookingDto $bookingDto, int $participantIndex): bool
|
||||
{
|
||||
$allServices = $this->getAllServicesFromTravel($bookingDto);
|
||||
$service = null;
|
||||
@@ -107,12 +107,12 @@ class ServiceAvailabilityCalculator
|
||||
/**
|
||||
* Calculate how many times each service has been selected by other participants.
|
||||
*
|
||||
* @param BookingCreateDto $bookingDto The booking data with participant selections
|
||||
* @param int $currentParticipantIndex The index of the participant currently filling the form
|
||||
* @param BookingDto $bookingDto The booking data with participant selections
|
||||
* @param int $currentParticipantIndex The index of the participant currently filling the form
|
||||
*
|
||||
* @return array<int, int> Array mapping service IDs to usage counts
|
||||
*/
|
||||
private function calculateServiceUsage(BookingCreateDto $bookingDto, int $currentParticipantIndex): array
|
||||
private function calculateServiceUsage(BookingDto $bookingDto, int $currentParticipantIndex): array
|
||||
{
|
||||
$serviceUsage = [];
|
||||
|
||||
@@ -187,11 +187,11 @@ class ServiceAvailabilityCalculator
|
||||
/**
|
||||
* Get all services from the travel data for availability calculation.
|
||||
*
|
||||
* @param BookingCreateDto $bookingDto The booking data containing travel information
|
||||
* @param BookingDto $bookingDto The booking data containing travel information
|
||||
*
|
||||
* @return array<Service> Array of all available services
|
||||
*/
|
||||
private function getAllServicesFromTravel(BookingCreateDto $bookingDto): array
|
||||
private function getAllServicesFromTravel(BookingDto $bookingDto): array
|
||||
{
|
||||
$allServices = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user