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
+17 -17
View File
@@ -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 = [];