fix: allow updating room assignments in edit mode
This commit is contained in:
@@ -132,6 +132,11 @@ class ParticipantEditDto
|
||||
#[Assert\Callback(groups: ['booking_create', 'booking_edit'])]
|
||||
public function validateEmailUniqueness(ExecutionContextInterface $context): void
|
||||
{
|
||||
// Skip for internal agency bookings — staff use shared placeholder emails
|
||||
if ($this->bookingContext->isInternalAgencyBooking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip validation for applicant (index 0) - applicant's email can be shared with dependents
|
||||
if (true === $this->participant->isApplicant()) {
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service\Condition;
|
||||
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Contract\FieldConditionInterface;
|
||||
|
||||
/**
|
||||
* Condition that checks if accommodation (room assignments) are mutable in the edit flow.
|
||||
*/
|
||||
class AccommodationMutabilityCondition implements FieldConditionInterface
|
||||
{
|
||||
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
|
||||
{
|
||||
return false === $bookingDto->travel->roomsMutable;
|
||||
}
|
||||
|
||||
public function getDependentFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Accommodation is not mutable (edit flow)';
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,10 @@ declare(strict_types=1);
|
||||
namespace App\Form\Service;
|
||||
|
||||
use App\BusProNet\Utility\DirectionMapper;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Abstract\AbstractFieldStateProvider;
|
||||
use App\Form\Service\Condition\AccommodationMutabilityCondition;
|
||||
use App\Form\Service\Condition\AdditionalServicesMutabilityCondition;
|
||||
use App\Form\Service\Condition\AgeRangeCondition;
|
||||
use App\Form\Service\Condition\BookingModeCondition;
|
||||
use App\Form\Service\Condition\CompositeCondition;
|
||||
use App\Form\Service\Condition\DateOfBirthProvidedCondition;
|
||||
use App\Form\Service\Condition\FieldValueCondition;
|
||||
@@ -99,10 +98,10 @@ class EditFieldStateProvider extends AbstractFieldStateProvider
|
||||
'static_text' => $personalDataHiddenCondition,
|
||||
];
|
||||
|
||||
// Room assignments are fixed in edit mode - always render as static text
|
||||
// The assignedRoomId value passes through unchanged from the loaded booking data
|
||||
// Room assignments are readonly when BPN indicates accommodation is not mutable
|
||||
$accommodationMutabilityCondition = new AccommodationMutabilityCondition();
|
||||
$this->fieldStateConditions['assignedRoomId'] = [
|
||||
'static_text' => new BookingModeCondition(BookingDto::MODE_EDIT),
|
||||
'static_text' => $accommodationMutabilityCondition,
|
||||
];
|
||||
|
||||
// Show remarks room field only when room with code 'mbz' (single bed) is selected
|
||||
|
||||
@@ -122,7 +122,14 @@ class ParticipantAssignedRoomFieldHandler extends AbstractParticipantFieldHandle
|
||||
}
|
||||
|
||||
// Calculate total capacity for this room type
|
||||
$totalCapacity = $roomSelection->quantity * $roomSelection->capacity;
|
||||
// In edit mode, use maxQuantity which includes available rooms beyond the booked count.
|
||||
// In create mode, use quantity which is the user's room selection from step 1.
|
||||
if (BookingDto::MODE_EDIT === $bookingDto->getMode()) {
|
||||
$effectiveQuantity = $roomSelection->maxQuantity;
|
||||
} else {
|
||||
$effectiveQuantity = $roomSelection->quantity ?? 0;
|
||||
}
|
||||
$totalCapacity = $effectiveQuantity * $roomSelection->capacity;
|
||||
|
||||
// Count current occupancy (excluding current participant)
|
||||
$occupancy = 0;
|
||||
@@ -174,7 +181,12 @@ class ParticipantAssignedRoomFieldHandler extends AbstractParticipantFieldHandle
|
||||
return; // Shouldn't happen
|
||||
}
|
||||
|
||||
$totalCapacity = $roomSelection->quantity * $roomSelection->capacity;
|
||||
if (BookingDto::MODE_EDIT === $bookingDto->getMode()) {
|
||||
$effectiveQuantity = $roomSelection->maxQuantity;
|
||||
} else {
|
||||
$effectiveQuantity = $roomSelection->quantity ?? 0;
|
||||
}
|
||||
$totalCapacity = $effectiveQuantity * $roomSelection->capacity;
|
||||
$currentOccupancy = count($participantsWithRoom);
|
||||
$spacesNeeded = ($currentOccupancy + 1) - $totalCapacity;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user