Files
fewo-stommer/app/Actions/ExpireReservations.php
LarsandClaude Opus 5.5 37f48defcc v0.11 U3: Klärungsreservierung für unvollständige Anfragen
- bookings.hold_purpose (offer wie bisher / clarification).
- RequestHold: vollständige Anfrage → Angebots-Hold unverändert;
  unvollständig, aber Wohnung, Zeitraum, verwendbare E-Mail und freier
  Zeitraum → nur Klärungsreservierung (15 min automatisch / 180 min
  Freigabe oder manuell, 0 = keine); sonst nichts (B1). Auch für
  Portalanfragen ohne Gastdaten.
- ExpireReservations beendet nur Angebots-Holds; ein abgelaufener
  Klärungsblock gibt nur den Kalender frei, der Vorgang bleibt offen.
- Vervollständigen erzeugt keinen Hold; erst SendOffer setzt den
  unveränderten Angebots-Hold. AutoOffer prüft danach nur die Verfügbarkeit.
- Booking::clarificationState() liefert den tatsächlichen Sperrstatus.
- Architekturtest: nur die bestehenden Reservierungsschritte schreiben Holds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 13:13:24 +01:00

40 lines
1.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Actions;
use App\Enums\BookingStatus;
use App\Mail\ReservationExpired;
use App\Models\Booking;
use App\Support\Settings;
use Illuminate\Support\Facades\Mail;
/**
* Marks reservations whose hold time is over – and information without a hold whose link expired unanswered – as
* expired and tells the landlord.
* The calendar already treats them as free once the hold time is over; this only updates the status.
*/
class ExpireReservations
{
public function handle(): int
{
$expired = Booking::query()
->whereIn('status', BookingStatus::holding())
->where(fn ($query) => $query
// A lapsed clarification hold (v0.11) only frees the calendar; the request stays open for its details.
->where(fn ($offer) => $offer->where('hold_expires_at', '<=', now())->where('hold_purpose', Booking::HOLD_OFFER))
// An information without a hold (package 7) ends when its link expires and the guest did not ask for the booking.
->orWhere(fn ($information) => $information->where('status', BookingStatus::Reserved)->whereNull('hold_expires_at')
->where('information_valid_until', '<=', now())->whereNull('wish_at')))
->with(['guest', 'property'])
->get();
foreach ($expired as $booking) {
$booking->update(['status' => BookingStatus::Expired]);
Mail::to(Settings::notificationRecipients())->send(new ReservationExpired($booking));
}
return $expired->count();
}
}