wip: modernized edit flow, fix insurance tier calculation

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 28831a3b06
commit 5c0814ef9b
31 changed files with 272 additions and 536 deletions
+15 -16
View File
@@ -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);