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

+34 -4
View File
@@ -5,11 +5,15 @@
use App\Actions\CreateChannelTasks;
use App\Enums\BookingStatus;
use App\Enums\ChannelTaskAction;
use App\Enums\InboxMessageKind;
use App\Models\Booking;
use App\Models\Property;
use App\Support\Inbox;
use App\Tenancy\TenantContext;
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
/**
* Keeps manually maintained portals in step when a booking starts or stops occupying the calendar.
@@ -42,6 +46,26 @@ public function updated(Booking $booking): void
}
}
private function reportSyncFailure(int $propertyId, int $bookingId, string $reason, Throwable $exception): void
{
Log::error('Portalaufgaben für Buchung nicht angelegt', ['booking' => $bookingId, 'exception' => $exception::class]);
rescue(function () use ($propertyId, $bookingId, $reason): void {
$property = Property::withoutGlobalScope('tenant')->find($propertyId);
if ($property === null) {
return;
}
app(TenantContext::class)->run($property->tenant, fn () => app(Inbox::class)->post(
InboxMessageKind::SyncFailed,
'booking-'.$bookingId.':'.now()->format('YmdH'),
'Portalabgleich für '.$reason.' fehlgeschlagen',
'Die Buchung ist gespeichert, aber die Sperr-/Freigabeaufgaben für die Portale konnten nicht angelegt werden. Bitte den Kalender der Portale prüfen und gegebenenfalls von Hand sperren.',
propertyId: $propertyId,
));
}, report: false);
}
private function occupies(BookingStatus|string|null $status): bool
{
$status = is_string($status) ? BookingStatus::tryFrom($status) : $status;
@@ -58,10 +82,16 @@ private function tasks(Booking $booking, ChannelTaskAction $action, ?CarbonImmut
$startsOn ??= $booking->arrival;
$endsOn ??= $booking->departure;
$reason = "Buchung {$booking->reference}";
DB::afterCommit(function () use ($propertyId, $channelId, $originId, $external, $startsOn, $endsOn, $action, $reason): void {
$property = Property::withoutGlobalScope('tenant')->find($propertyId);
if ($property !== null) {
app(TenantContext::class)->run($property->tenant, fn () => $this->createChannelTasks->handle($property, $startsOn, $endsOn, $action, $reason, $channelId, $originId, $external));
$bookingId = $booking->id;
DB::afterCommit(function () use ($propertyId, $channelId, $originId, $external, $startsOn, $endsOn, $action, $reason, $bookingId): void {
// The booking is already saved: a failing portal task must never turn into an error for the guest.
try {
$property = Property::withoutGlobalScope('tenant')->find($propertyId);
if ($property !== null) {
app(TenantContext::class)->run($property->tenant, fn () => $this->createChannelTasks->handle($property, $startsOn, $endsOn, $action, $reason, $channelId, $originId, $external));
}
} catch (Throwable $exception) {
$this->reportSyncFailure($propertyId, $bookingId, $reason, $exception);
}
});
}