wip: check eligibility based on ski pass availability

This commit is contained in:
Björn Fromme
2025-10-01 18:52:50 +02:00
parent fef4997132
commit 8a495346d6
9 changed files with 471 additions and 184 deletions
+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;