wip: transportation services in summary
This commit is contained in:
@@ -63,6 +63,9 @@ class ParticipantDto
|
||||
// Parking service for self-organized transportation (boolean: true if parking requested)
|
||||
public bool $parking = false;
|
||||
|
||||
// Parking service object for pricing calculation (new, contains actual service with pricing)
|
||||
public ?Service $parkingService = null;
|
||||
|
||||
// Deprecated properties for backward compatibility - will be removed in future version
|
||||
public ?Service $transportationServiceTo = null;
|
||||
public ?Service $transportationServiceFro = null;
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service;
|
||||
|
||||
use App\BusProNet\Constants;
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\BusProNet\Utility\DirectionMapper;
|
||||
use App\Form\Model\BookingDtoInterface;
|
||||
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
||||
@@ -54,14 +56,23 @@ class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
|
||||
// Check if parking is applicable (outbound transportation is PKW)
|
||||
if (!$this->isParkingApplicable($participant)) {
|
||||
$participant->parking = false; // Clear parking when outbound is not PKW
|
||||
$participant->parkingService = null; // Clear parking service object
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$parkingSelected = $this->getFieldValue($submittedData, $this->getFieldName());
|
||||
$isParkingSelected = (bool) $parkingSelected;
|
||||
|
||||
// Store boolean value directly (true if checkbox checked, false otherwise)
|
||||
$participant->parking = (bool) $parkingSelected;
|
||||
// Store boolean value for backward compatibility
|
||||
$participant->parking = $isParkingSelected;
|
||||
|
||||
// Store parking service object for pricing calculation
|
||||
if (true === $isParkingSelected) {
|
||||
$participant->parkingService = $this->findParkingService($bookingDto);
|
||||
} else {
|
||||
$participant->parkingService = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,4 +88,26 @@ class ParticipantParkingFieldHandler extends AbstractParticipantFieldHandler
|
||||
{
|
||||
return DirectionMapper::SUBTYPE_CAR_API === $participant->transportationOutbound?->subType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the parking service from available services.
|
||||
*
|
||||
* Gets the first (and typically only) parking service for pricing calculation.
|
||||
* Returns null if no parking services are available.
|
||||
*
|
||||
* @param BookingDtoInterface $bookingDto The booking DTO containing travel data
|
||||
*
|
||||
* @return Service|null The parking service object, or null if not found
|
||||
*/
|
||||
private function findParkingService(BookingDtoInterface $bookingDto): ?Service
|
||||
{
|
||||
$parkingServices = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_PARKING, true);
|
||||
|
||||
if (empty($parkingServices)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return the first parking service (there's typically only one parking type)
|
||||
return reset($parkingServices);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user