fix: only assign dummy data to the applicant
This commit is contained in:
@@ -23,8 +23,9 @@ class PersonalDataSynchronizer
|
|||||||
* Processes all active participants (status 'F' or 'A'). Skips canceled participants (status 'S').
|
* Processes all active participants (status 'F' or 'A'). Skips canceled participants (status 'S').
|
||||||
* Updates all personal data fields and communication information.
|
* Updates all personal data fields and communication information.
|
||||||
*
|
*
|
||||||
* For the applicant (index 0), missing mandatory fields are filled with defaults
|
* Also fills missing mandatory fields on the applicant object for company bookings
|
||||||
* to handle company applicants created by travel agencies.
|
* created by travel agencies. The applicant is separate from participant 0 and may
|
||||||
|
* contain only company data without personal fields required by the BPN API.
|
||||||
*
|
*
|
||||||
* IMPORTANT: The applicant's address must never be modified. This method updates
|
* IMPORTANT: The applicant's address must never be modified. This method updates
|
||||||
* participant addresses independently to ensure applicant data remains intact.
|
* participant addresses independently to ensure applicant data remains intact.
|
||||||
@@ -34,17 +35,16 @@ class PersonalDataSynchronizer
|
|||||||
*/
|
*/
|
||||||
public function updateParticipantPersonalData(array $participants, Booking $bookingData): void
|
public function updateParticipantPersonalData(array $participants, Booking $bookingData): void
|
||||||
{
|
{
|
||||||
|
// Fill missing mandatory fields on applicant (for company bookings by travel agencies)
|
||||||
|
// This is separate from participants - applicant may be a company while participants are real people
|
||||||
|
$this->fillMissingApplicantFields($bookingData);
|
||||||
|
|
||||||
foreach ($participants as $participant) {
|
foreach ($participants as $participant) {
|
||||||
// Skip canceled participants (status 'S')
|
// Skip canceled participants (status 'S')
|
||||||
if ('S' === $participant->status) {
|
if ('S' === $participant->status) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill missing mandatory fields for applicant (company bookings by travel agencies)
|
|
||||||
if (0 === $participant->index) {
|
|
||||||
$this->fillMissingMandatoryFields($participant);
|
|
||||||
}
|
|
||||||
|
|
||||||
$bookingData->participants[$participant->index]->firstName = $participant->firstName;
|
$bookingData->participants[$participant->index]->firstName = $participant->firstName;
|
||||||
$bookingData->participants[$participant->index]->name = $participant->lastName;
|
$bookingData->participants[$participant->index]->name = $participant->lastName;
|
||||||
$bookingData->participants[$participant->index]->dateOfBirth = $participant->dateOfBirth;
|
$bookingData->participants[$participant->index]->dateOfBirth = $participant->dateOfBirth;
|
||||||
@@ -78,32 +78,43 @@ class PersonalDataSynchronizer
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills missing mandatory fields with defaults for company applicants.
|
* Fills missing mandatory fields on the applicant for company bookings.
|
||||||
*
|
*
|
||||||
* Travel agencies often create bookings with company data as the applicant,
|
* Travel agencies often create bookings with company data as the applicant,
|
||||||
* which lacks personal data fields. These fields are mandatory for the BPN
|
* which lacks personal data fields. These fields are mandatory for the BPN
|
||||||
* API, so we fill them with sensible defaults.
|
* API, so we fill them with sensible defaults. The applicant is separate from
|
||||||
|
* participants - participant 0 is a real person and must not be modified here.
|
||||||
*/
|
*/
|
||||||
private function fillMissingMandatoryFields(ParticipantDto $participant): void
|
private function fillMissingApplicantFields(Booking $bookingData): void
|
||||||
{
|
{
|
||||||
if (null === $participant->firstName || '' === $participant->firstName) {
|
if (null === $bookingData->applicant) {
|
||||||
$participant->firstName = 'Anmelder';
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $participant->gender || '' === $participant->gender) {
|
$applicant = $bookingData->applicant;
|
||||||
$participant->gender = 'D';
|
|
||||||
|
if (null === $applicant->firstName || '' === $applicant->firstName) {
|
||||||
|
$applicant->firstName = 'Anmelder';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $participant->nationality || '' === $participant->nationality) {
|
if (null === $applicant->gender || '' === $applicant->gender) {
|
||||||
$participant->nationality = 'D';
|
$applicant->gender = 'D';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $participant->dateOfBirth) {
|
if (null === $applicant->nationality || '' === $applicant->nationality) {
|
||||||
$participant->dateOfBirth = new \DateTimeImmutable('-20 years');
|
$applicant->nationality = 'D';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $participant->mobile || '' === $participant->mobile) {
|
if (null === $applicant->dateOfBirth) {
|
||||||
$participant->mobile = '12345';
|
$applicant->dateOfBirth = new \DateTimeImmutable('-20 years');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $applicant->communication) {
|
||||||
|
$applicant->communication = new Communication();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $applicant->communication->mobile || '' === $applicant->communication->mobile) {
|
||||||
|
$applicant->communication->mobile = '12345';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user