- 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>
43 lines
1.6 KiB
PHP
43 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Process;
|
|
|
|
use App\Models\Booking;
|
|
use Carbon\CarbonImmutable;
|
|
|
|
/**
|
|
* What a new request holds when it comes in (v0.11, B1, E-033):
|
|
*
|
|
* - complete for an offer: the offer hold exactly as before (if the settings reserve at all);
|
|
* - incomplete, but with property, dates and a usable e-mail address (V1): only the clarification hold of its data
|
|
* request mode, 0 = none;
|
|
* - otherwise nothing.
|
|
*
|
|
* A request answered with an information "unter Vorbehalt" (no offer hold) needs no details first and holds nothing,
|
|
* as before. The free calendar was checked by the caller under its lock.
|
|
*/
|
|
final class RequestHold
|
|
{
|
|
/**
|
|
* @param Booking $draft the new case, not yet stored, with its guest relation
|
|
* @return array{hold_expires_at: ?CarbonImmutable, hold_purpose: string}
|
|
*/
|
|
public static function for(Booking $draft, ProcessProfile $profile): array
|
|
{
|
|
if (! $profile->preReservation()) {
|
|
return ['hold_expires_at' => null, 'hold_purpose' => Booking::HOLD_OFFER];
|
|
}
|
|
|
|
if (CaseRequirements::isComplete($draft)) {
|
|
return ['hold_expires_at' => now()->addHours($profile->holdHours())->toImmutable(), 'hold_purpose' => Booking::HOLD_OFFER];
|
|
}
|
|
|
|
$minutes = $profile->clarificationHoldMinutes();
|
|
if ($minutes === 0 || ! CaseRequirements::qualifiesForClarificationHold($draft)) {
|
|
return ['hold_expires_at' => null, 'hold_purpose' => Booking::HOLD_CLARIFICATION];
|
|
}
|
|
|
|
return ['hold_expires_at' => now()->addMinutes($minutes)->toImmutable(), 'hold_purpose' => Booking::HOLD_CLARIFICATION];
|
|
}
|
|
}
|