Modellwahl über Kanalfähigkeiten mit erklärten Einschränkungen, Abgleich alter Werte, Ausführungsvarianten je Modul, getrennte Vertrags-/Buchungsinformation, Warten auf die Portalbestätigung mit Eskalation und Wiederaufnahme (Fälle C und D getestet). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
63 lines
2.3 KiB
PHP
63 lines
2.3 KiB
PHP
<?php
|
||
|
||
namespace App\Process\Modules\Offer;
|
||
|
||
use App\Enums\ActivityState;
|
||
use App\Enums\BookingStatus;
|
||
use App\Process\Activity;
|
||
use App\Process\CaseContext;
|
||
use App\Process\Modules\Dependency;
|
||
use App\Process\Modules\Module;
|
||
use App\Process\Modules\ModuleDefinition;
|
||
|
||
/**
|
||
* P02: the guest accepts (AcceptOffer, acceptance record) or declines (RejectOffer); the booking becomes binding
|
||
* (ConfirmBooking). Cannot be switched off – our own way never binds without the guest's acceptance.
|
||
*/
|
||
final class OfferAcceptance extends Module
|
||
{
|
||
public static function key(): string
|
||
{
|
||
return 'offer.acceptance';
|
||
}
|
||
|
||
public static function definition(): ModuleDefinition
|
||
{
|
||
return new ModuleDefinition(
|
||
label: 'Annahme durch den Gast',
|
||
purpose: 'Der Gast nimmt das Angebot an oder lehnt es ab; mit der Annahme wird die Buchung verbindlich.',
|
||
phase: 'P02',
|
||
executions: [],
|
||
condition: 'nach einem verbindlichen Angebot',
|
||
why: 'Der Gast nimmt an – ohne Annahme kommt kein Vertrag zustande (E-003). Eine zweite Freigabe ist nicht nötig.',
|
||
requires: [Dependency::hard('offer.binding')],
|
||
effects: ['case_write', 'guest_mail', 'landlord_mail', 'document'],
|
||
waits: ['guest', 'time'],
|
||
triggers: ['offer.accepted', 'offer.declined'],
|
||
performers: ['guest'],
|
||
events: ['offer', 'status'],
|
||
);
|
||
}
|
||
|
||
public function applies(CaseContext $case): bool
|
||
{
|
||
return app(BindingOffer::class)->applies($case);
|
||
}
|
||
|
||
public function activities(CaseContext $case): array
|
||
{
|
||
$booking = $case->booking;
|
||
|
||
return [new Activity('acceptance', 'Gast nimmt das Angebot an', $case->later(match (true) {
|
||
$case->binding => ActivityState::Done,
|
||
$booking->status === BookingStatus::OfferSent => ActivityState::Waiting,
|
||
default => ActivityState::Later,
|
||
}), match (true) {
|
||
$booking->accepted_at !== null => 'angenommen am '.$booking->accepted_at->format('d.m.Y'),
|
||
$case->binding => 'direkt bestätigt',
|
||
$booking->status === BookingStatus::OfferSent => 'Angebot gültig bis '.$booking->hold_expires_at?->format('d.m.Y, H:i').' Uhr',
|
||
default => null,
|
||
})];
|
||
}
|
||
}
|