fix: prevent generating offer links while booking is in draft

This commit is contained in:
Björn Fromme
2026-08-19 13:00:43 +02:00
parent 2601e46ec4
commit 8617bf6c86
11 changed files with 442 additions and 36 deletions
+18 -4
View File
@@ -436,12 +436,18 @@ class AccommodationBookingService
}
/**
* Sets accessLinkIssuedAt if the booking doesn't have one yet, whatever its status.
* No email side effect — the confirmation email is always sent separately via
* sendCustomerConfirmationEmail(), regardless of whether a link exists.
* Sets accessLinkIssuedAt if the booking doesn't have one yet. No email side effect — the
* confirmation email is always sent separately via sendCustomerConfirmationEmail(),
* regardless of whether a link exists.
* A no-op while the record is not customer accessible: a draft has nothing to show yet, so
* publishing the offer (sendOffer()) moves it out of Entwurf before asking for a link.
*/
public function issueAccessLink(AccommodationBooking $booking): void
{
if (!$booking->isCustomerAccessible()) {
return;
}
if (null !== $booking->getAccessLinkIssuedAt()) {
return;
}
@@ -489,9 +495,15 @@ class AccommodationBookingService
* Explicit admin action: (re)issues the access link, invalidating any previously issued
* link for this booking. No email side effect — sending is a separate, explicit admin
* action via sendCustomerConfirmationEmail().
* A no-op for a record that is not customer accessible yet, for the same reason as
* issueAccessLink().
*/
public function regenerateAccessLink(AccommodationBooking $booking): void
{
if (!$booking->isCustomerAccessible()) {
return;
}
$booking->setAccessLinkIssuedAt(new \DateTimeImmutable());
$this->entityManager->flush();
}
@@ -509,8 +521,10 @@ class AccommodationBookingService
return;
}
$this->issueAccessLink($booking);
// Offen first: the status is what makes the record customer accessible, and only then
// will issueAccessLink() hand out a link (it flushes both changes together).
$booking->setStatus(AccommodationBookingStatus::Open);
$this->issueAccessLink($booking);
$this->entityManager->flush();
$this->sendCustomerConfirmationEmail($booking);