fix: properly assign readonly state to form fields for unavailable services
This commit is contained in:
@@ -64,7 +64,7 @@ class ParticipantEligibilityService
|
||||
return true;
|
||||
}
|
||||
|
||||
$allSkiPasses = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_SKI_PASS, true, true);
|
||||
$allSkiPasses = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_SKI_PASS, true);
|
||||
$availableSkiPasses = array_filter(
|
||||
$allSkiPasses,
|
||||
fn (Service $service) => $this->isSkiPassAvailableForParticipant($service, $bookingDto, $participantIndex)
|
||||
|
||||
@@ -63,12 +63,17 @@ class ServiceAvailabilityCalculator
|
||||
$remainingAvailability = $this->calculateRemainingAvailability($bookingDto, $participantIndex);
|
||||
|
||||
return array_filter($services, function (Service $service) use ($remainingAvailability) {
|
||||
// If service has no availability limit set, treat as unlimited
|
||||
if (null === $service->available || $service->available <= 0) {
|
||||
// If service has no availability limit set (null), treat as unlimited
|
||||
if (null === $service->available) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// For services with availability limits, check remaining availability
|
||||
// If availability is 0, service is sold out at the API level
|
||||
if (0 === $service->available) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For services with positive availability, check remaining availability
|
||||
return ($remainingAvailability[$service->id] ?? $service->available) > 0;
|
||||
});
|
||||
}
|
||||
@@ -94,11 +99,22 @@ class ServiceAvailabilityCalculator
|
||||
}
|
||||
}
|
||||
|
||||
// If service not found or has no availability limit, it's not unavailable
|
||||
if (null === $service || null === $service->available || $service->available <= 0) {
|
||||
// If service not found, treat as available (not unavailable)
|
||||
if (null === $service) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If no availability tracking (null), service is unlimited and available
|
||||
if (null === $service->available) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If availability is 0, service is sold out at the API level
|
||||
if (0 === $service->available) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// For services with positive availability, calculate remaining based on booking selections
|
||||
$remainingAvailability = $this->calculateRemainingAvailability($bookingDto, $participantIndex);
|
||||
|
||||
return ($remainingAvailability[$serviceId] ?? $service->available) <= 0;
|
||||
@@ -195,7 +211,7 @@ class ServiceAvailabilityCalculator
|
||||
{
|
||||
$allServices = [];
|
||||
|
||||
// Get transportation services
|
||||
// Get all transportation services
|
||||
$transportationServices = array_merge(
|
||||
$bookingDto->travel->getTransportationServicesByDirection(DirectionMapper::OUTBOUND_TRAVEL) ?? [],
|
||||
$bookingDto->travel->getTransportationServicesByDirection(DirectionMapper::INBOUND_TRAVEL) ?? []
|
||||
|
||||
Reference in New Issue
Block a user