Skip to content

Commit

Permalink
Fixed Ist import, merge of multiple Participants now does not try to …
Browse files Browse the repository at this point in the history
…delete any P
  • Loading branch information
paaton committed Apr 23, 2024
1 parent f8b4d61 commit e6bea81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/Import/ImportSrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,23 @@ private function mapDataIntoNewIst(array $data, Event $event, ?User $existingUse
'Ano' => true,
default => false,
};
$participant = null;
if ($existingUser == null) {
$existingUser = $this->userService->createSkautisUser(
$event,
(int)$skautisUserId,
$email,
$userStatus,
);

} else {
$participant = $this->participantRepository->findParticipantFromUser($existingUser);
if ($participant !== null) {
$this->participantRepository->delete($participant);
}
$participant = $this->participantRepository->findParticipantFromUser($existingUser);

}
return $this->istService->createIstPayment(
$existingUser,
$event,
$participant,
$contingent,
$data['first_name'],
$data['last_name'],
Expand Down
5 changes: 4 additions & 1 deletion src/Participant/Ist/IstService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct(
public function createIstPayment(
User $user,
Event $event,
?Participant $participant,
string $contingent,
string $firstName,
string $lastName,
Expand Down Expand Up @@ -57,7 +58,9 @@ public function createIstPayment(
string $swift,
DateTimeImmutable $due,
): Participant {
$participant = new Participant();
if ($participant == null) {
$participant = new Participant();
}
$participant->user = $user;
$participant->role = ParticipantRole::Ist;
$participant->contingent = $contingent;
Expand Down

0 comments on commit e6bea81

Please sign in to comment.