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>
99 lines
3.9 KiB
PHP
99 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace App\Process\Modules\Intake;
|
|
|
|
use App\Actions\RequestCaseData;
|
|
use App\Enums\ActivityState;
|
|
use App\Enums\Execution;
|
|
use App\Enums\ProcessSetting;
|
|
use App\Models\DataRequest;
|
|
use App\Process\Activity;
|
|
use App\Process\CaseContext;
|
|
use App\Process\CaseRequirements;
|
|
use App\Process\Modules\Dependency;
|
|
use App\Process\Modules\Module;
|
|
use App\Process\Modules\ModuleDefinition;
|
|
use App\Process\Modules\RunsAutomatically;
|
|
use App\Process\Modules\StepState;
|
|
use App\Process\StepResult;
|
|
|
|
/**
|
|
* P01: asks the guest for missing details by link and reminds (v0.11). It runs in its own mode (automatic / after
|
|
* release / by hand) whatever the case's processing is, and independently of the other steps: a clarification hold
|
|
* keeps its deadline while the request waits for the guest.
|
|
*/
|
|
final class GuestDataRequest extends Module implements RunsAutomatically
|
|
{
|
|
public static function key(): string
|
|
{
|
|
return 'guest.data_request';
|
|
}
|
|
|
|
public static function definition(): ModuleDefinition
|
|
{
|
|
return new ModuleDefinition(
|
|
label: 'Fehlende Angaben beim Gast anfragen',
|
|
purpose: 'Fragt fehlende Pflichtangaben per Link beim Gast an, erinnert und übergibt an Sie, wenn der Gast nicht antwortet.',
|
|
phase: 'P01',
|
|
executions: [Execution::Automatic, Execution::Approval, Execution::Manual, Execution::NotRequired],
|
|
condition: 'wenn Angaben für den nächsten Schritt fehlen und eine E-Mail-Adresse bekannt ist',
|
|
requires: [Dependency::hard('intake.record')],
|
|
effects: ['case_write', 'guest_mail'],
|
|
waits: ['guest', 'landlord', 'time'],
|
|
triggers: ['request.created', 'booking.taken_over', 'wish'],
|
|
parameters: [ProcessSetting::DataRequest, ProcessSetting::DataRequestRemindersMax, ProcessSetting::DataRequestFollowupsMax, ProcessSetting::DataRequestReminderHours, ProcessSetting::GuestLinkValidDays],
|
|
toggle: ModuleDefinition::TOGGLE_OPTIONAL,
|
|
performers: ['system', 'landlord'],
|
|
modes: ['automatic', 'approval', 'manual'],
|
|
events: ['data_request', 'mail_in', 'facts', 'fact'],
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Shown as a step of its own only for a binding booking (a request shows it inside the guest's details).
|
|
*/
|
|
public function activities(CaseContext $case): array
|
|
{
|
|
$request = $case->binding ? $case->booking->openDataRequest() : null;
|
|
if ($request === null) {
|
|
return [];
|
|
}
|
|
|
|
return [new Activity('data_request', 'Fehlende Angaben beim Gast anfragen', $case->later($request->status === DataRequest::OPEN ? ActivityState::Waiting : ActivityState::Open),
|
|
implode(', ', CaseRequirements::labels($request->fields)).' · '.$request->statusLabel(), $request->status === DataRequest::OPEN ? null : 'approveDataRequest')];
|
|
}
|
|
|
|
public function state(CaseContext $case): ?StepState
|
|
{
|
|
$request = $case->booking->openDataRequest();
|
|
|
|
return match (true) {
|
|
$request === null => RequestCaseData::needs($case->booking) === null ? StepState::Done : StepState::Open,
|
|
$request->status === DataRequest::OPEN => StepState::Waiting,
|
|
default => StepState::Open,
|
|
};
|
|
}
|
|
|
|
public function due(CaseContext $case): bool
|
|
{
|
|
return RequestCaseData::needs($case->booking) !== null && $case->booking->openDataRequest() === null;
|
|
}
|
|
|
|
public function blockers(CaseContext $case): array
|
|
{
|
|
return CaseRequirements::isValid('guest.email', $case->booking->guest?->email) ? [] : ['Die E-Mail-Adresse des Gastes fehlt.'];
|
|
}
|
|
|
|
public function run(CaseContext $case): StepResult
|
|
{
|
|
$request = app(RequestCaseData::class)->forNextStep($case->booking);
|
|
|
|
return $request === null ? StepResult::blocked(['Nichts anzufragen.']) : StepResult::ran();
|
|
}
|
|
|
|
public function isOutward(): bool
|
|
{
|
|
return false;
|
|
}
|
|
}
|