Buchungsprozess: Angebots-Snapshot, atomare Annahme, Auto-Angebot, Kanalfreigabe
Deploy FeWo mit PipelineManager / deploy (push) Failing after 3m38s

- Angebotsbedingungen und Zahlungsdaten werden je Version eingefroren (offer_terms, offer_hash)
- Annahme in einer gesperrten Transaktion, idempotent, mit Nachweis; Mail- und Portalfehler
  machen eine gespeicherte Buchung nicht ungueltig (Postfach, Nachversand)
- Je Wohnung: manuelle/automatische Angebote, optionale Vorreservierung
- Automatische Freigabe abhaengig von aktuellen Importen und Feed-Abruf bei Sofortbuchungsportalen
- Deutsche Fehlerseiten, Buchungsseite zeigt Angebots- und Zustellstatus
- Dokumentation: BOOKING-E2E-*.md, BOOKING-COMPLIANCE-HANDOVER.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-10-30 12:01:02 +01:00
1 parent e7cc37a15b
commit eafab8a2cb
47 files changed
+2099 -104

No files matched your search

+43 -1
View File
@@ -3,10 +3,13 @@
namespace App\Actions;
use App\Availability\AvailabilityChecker;
use App\Documents\OfferTerms;
use App\Documents\RentalContract;
use App\Enums\BookingStatus;
use App\Enums\InboxMessageKind;
use App\Enums\QuoteLineType;
use App\Exceptions\ReservationException;
use App\Filament\Resources\Bookings\BookingResource;
use App\Mail\OfferMade;
use App\Models\Booking;
use App\Pricing\PriceCalculator;
@@ -14,11 +17,14 @@
use App\Pricing\QuoteException;
use App\Pricing\QuoteLine;
use App\Pricing\StayRequest;
use App\Support\Inbox;
use Carbon\CarbonImmutable;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\URL;
use Throwable;
/**
* Booking path 1 (docs/KONZEPT.md §6a): the landlord turns a request into an offer. Dates, guests, promo
@@ -32,6 +38,7 @@ public function __construct(
private PriceCalculator $calculator,
private AvailabilityChecker $availability,
private RentalContract $contract,
private Inbox $inbox,
) {}
/**
@@ -51,6 +58,12 @@ public function handle(Booking $booking, array $changes = [], bool $sendMail = t
}
DB::transaction(function () use ($booking, $changes): void {
$booking->lockForTransition();
if (! in_array($booking->status, [BookingStatus::Reserved, BookingStatus::OfferSent, BookingStatus::Expired], true)) {
throw ReservationException::invalidTransition($booking->status->getLabel(), 'als Angebot versendet');
}
$arrival = CarbonImmutable::parse($changes['arrival'] ?? $booking->arrival);
$departure = CarbonImmutable::parse($changes['departure'] ?? $booking->departure);
@@ -84,19 +97,48 @@ public function handle(Booking $booking, array $changes = [], bool $sendMail = t
'offer_version' => $booking->offer_version + 1,
'offer_sent_at' => now(),
'offer_message' => $changes['offer_message'] ?? null,
'offer_terms' => OfferTerms::capture(),
]);
$booking->refresh();
$booking->update(['offer_hash' => OfferTerms::hash($booking)]);
});
$booking->refresh();
$this->contract->generate($booking, draft: true);
if ($sendMail) {
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new OfferMade($booking, $this->offerUrl($booking)));
$this->deliver($booking);
}
return $booking;
}
/**
* Sends the offer mail. The offer is already saved (and its validity runs), so a failing mail server is
* recorded in the admin inbox and reported to the caller instead of being lost.
*
* @throws ReservationException
*/
public function deliver(Booking $booking): void
{
try {
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new OfferMade($booking, $this->offerUrl($booking)));
} catch (Throwable $exception) {
// Only class and booking id are logged: mail errors can contain the recipient's address.
Log::warning('Angebot nicht zugestellt', ['booking' => $booking->id, 'exception' => $exception::class]);
$this->inbox->post(
InboxMessageKind::OfferMailFailed,
'booking-'.$booking->id.':v'.$booking->offer_version,
'Angebot '.$booking->reference.' nicht zugestellt',
'Das Angebot ist gespeichert und der Zeitraum gehalten, aber die E-Mail konnte nicht versendet werden. Auf der Buchungsseite kann der Angebotslink kopiert und dem Gast anders übermittelt werden.',
actionUrl: BookingResource::getUrl('view', ['record' => $booking]),
propertyId: $booking->property_id,
);
throw new ReservationException('Das Angebot wurde gespeichert, aber die E-Mail konnte nicht versendet werden. Der Angebotslink kann über „Angebotslink“ kopiert werden.');
}
}
/**
* The guest's link to the offer page; valid while the offer is valid and only for this offer version.
*/