fix: ensure nationality is assigned when editing booking data

This commit is contained in:
Björn Fromme
2026-01-12 18:23:52 +01:00
parent 830fd2464c
commit 7636ee41af
2 changed files with 20 additions and 0 deletions
@@ -7,6 +7,7 @@ namespace App\BusProNet\DataProcessor;
use App\BusProNet\Model\Address;
use App\BusProNet\Model\Booking;
use App\BusProNet\Model\Communication;
use App\BusProNet\Model\PersonalData;
use App\Form\Model\ParticipantDto;
/**
@@ -50,6 +51,8 @@ class PersonalDataSynchronizer
$bookingData->participants[$participant->index]->dateOfBirth = $participant->dateOfBirth;
$bookingData->participants[$participant->index]->gender = $participant->gender;
$bookingData->participants[$participant->index]->nationality = $participant->nationality;
$this->fillMissingParticipantFields($bookingData->participants[$participant->index]);
$bookingData->participants[$participant->index]->height = $participant->height;
$bookingData->participants[$participant->index]->weight = $participant->weight;
$bookingData->participants[$participant->index]->shoeSize = $participant->shoeSize;
@@ -117,4 +120,19 @@ class PersonalDataSynchronizer
$applicant->communication->mobile = '12345';
}
}
/**
* Fills missing mandatory fields on a participant.
*
* Ensures mandatory fields have sensible defaults before submission to the
* BPN API. Currently handles nationality which defaults to 'D' (German).
*
* @param \App\BusProNet\Model\PersonalData $participant The participant to fill defaults for
*/
private function fillMissingParticipantFields(PersonalData $participant): void
{
if (null === $participant->nationality || '' === $participant->nationality) {
$participant->nationality = 'D';
}
}
}