feat: pre-flight check of agency bookings

addresses #869bqxr4q
This commit is contained in:
Björn Fromme committed 2026-07-10 14:33:09 +02:00
1 parent f9142e3080
commit b41b19d4c6
26 files changed
+1818 -304

No files matched your search

@@ -15,6 +15,7 @@ use App\Form\Model\ParticipantDto;
use App\Form\Model\RoomSelectionDto;
use App\Service\BookingPriceCalculator;
use App\Service\InsuranceManager;
use function Symfony\Component\String\u;
/**
* Processes booking form data and converts it into BusProNet API payload format.
@@ -78,7 +79,7 @@ class BookingDataProcessor
// Copy address if first participant has no street (indicating empty/incomplete address)
$isEmpty = null === $participantData->address
|| null === $participantData->address->street
|| '' === trim($participantData->address->street);
|| u($participantData->address->street)->trim()->isEmpty();
if ($isEmpty) {
$participantData->address = clone $booking->applicant->address;
@@ -155,6 +156,9 @@ class BookingDataProcessor
// Enrich services with data from travel (especially prices)
$this->enrichParticipantServicesFromTravel($participantData, $travel);
// Normalize loaded participant data so the edit flow sees canonical values.
$participantData->normalizeLoadedData();
$dto->participants[$index] = $participantData;
}
+27
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\BusProNet\Model;
use Symfony\Component\Validator\Constraints as Assert;
use function Symfony\Component\String\u;
/**
* Represents a physical address with street, postal code, city, and country information.
@@ -29,6 +30,21 @@ class Address
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['personal_data'])]
public ?string $country = null;
/**
* Normalizes legacy string data loaded from API/session sources.
*
* Trims whitespace and converts empty strings to null so load-time audits
* and form hydration see canonical values.
*/
public function normalize(): void
{
$this->street = $this->normalizeNullableString($this->street);
$this->postCode = $this->normalizeNullableString($this->postCode);
$this->city = $this->normalizeNullableString($this->city);
$this->district = $this->normalizeNullableString($this->district);
$this->country = $this->normalizeNullableString($this->country);
}
/**
* Converts the address to API payload format.
*
@@ -47,4 +63,15 @@ class Address
'land' => $this->country,
];
}
private function normalizeNullableString(?string $value): ?string
{
if (null === $value) {
return null;
}
$trimmed = u($value)->trim()->toString();
return '' === $trimmed ? null : $trimmed;
}
}