wip: check eligibility based on ski pass availability

This commit is contained in:
Björn Fromme committed 2026-03-16 11:59:10 +01:00
1 parent f5913eb947
commit 16c239716b
9 files changed
+471 -184

No files matched your search

+21 -3
View File
@@ -21,6 +21,10 @@ use App\Form\Model\ParticipantDto;
*/
class BookingPriceCalculatorService
{
public function __construct(
private readonly ParticipantEligibilityService $participantEligibilityService
) {
}
/**
* Calculates comprehensive pricing breakdown for a booking.
*
@@ -89,6 +93,8 @@ class BookingPriceCalculatorService
/**
* Calculates pricing for all selected services across all participants, grouped by subtype.
*
* Only includes services from eligible participants (those with available skipasses for their age).
*
* @param BookingDtoInterface $bookingDto The booking data containing participants and their service selections
*
* @return array Array of service groups with each group containing services of the same subtype
@@ -101,10 +107,15 @@ class BookingPriceCalculatorService
return [];
}
// Aggregate service selections across all participants
// Aggregate service selections across all eligible participants
$serviceAggregation = [];
foreach ($participants as $participant) {
foreach ($participants as $participantIndex => $participant) {
// Skip ineligible participants (no skipasses available for their age)
if (false === $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex)) {
continue;
}
$this->aggregateParticipantServices($participant, $serviceAggregation);
}
@@ -285,6 +296,8 @@ class BookingPriceCalculatorService
* - Zustieg: Sum of all pickup prices and base transportation costs (positive and negative)
* - Parkplatz: Sum of all parking service prices
*
* Only includes transportation costs from eligible participants.
*
* Note: Transportation discounts will be handled generically by groupServicesBySubtype as "Beförderung - Rabatt"
*
* @param BookingDtoInterface $bookingDto The booking data containing participants
@@ -301,7 +314,12 @@ class BookingPriceCalculatorService
$pickupParticipants = 0;
$parkingParticipants = 0;
foreach ($participants as $participant) {
foreach ($participants as $participantIndex => $participant) {
// Skip ineligible participants (no skipasses available for their age)
if (false === $this->participantEligibilityService->isParticipantEligible($bookingDto, $participantIndex)) {
continue;
}
$participantPickupCost = 0.0;
$participantParkingCost = 0.0;