Files
LarsandClaude Sonnet 5.5 221ce8ca81 Anfrage-Basisprozess inquiry.request mit Schablonen für Antwort und Gastkommunikation
Antwortart (Auskunft/Angebot) und Reservierung sind entkoppelt (neue Einstellung inquiry_answer;
pre_reservation bleibt die Reservierungsstrategie). Anlass-bezogene Absender für Anreise-Information
und Bewertungsbitte; Schablonen liefern Standardwerte unterhalb aller einstellbaren Ebenen.
A1/A2 bleiben Voreinstellungen und Altfassungen.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 12:40:22 +01:00

90 lines
4.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\Process\Modules\Intake;
use App\Enums\ActivityState;
use App\Enums\Execution;
use App\Enums\InquiryAnswer;
use App\Enums\ProcessSetting;
use App\Enums\Responsibility;
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;
/**
* P01: who the guest is and whether every detail the next step needs is there and valid (v0.11 G2a). The details
* themselves come in through the common fact intake (ContributeCaseFacts) from every source.
*/
final class GuestDetails extends Module
{
public static function key(): string
{
return 'guest.details';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Angaben des Gastes',
purpose: 'Identifiziert den Gast, führt seine Angaben aus allen Quellen zusammen und prüft, ob alles für den nächsten Schritt da ist.',
phase: 'P01',
executions: [Execution::Automatic, Execution::Manual],
condition: 'wenn wir selbst mit dem Gast schreiben (Anfrage, eigene Unterlagen, Nachrichten oder Zahlung)',
why: 'Ohne die Angaben des Gastes entsteht kein eigenes Angebot und keine Unterlage (G2a).',
requires: [Dependency::hard('intake.record')],
effects: ['case_write'],
waits: ['guest', 'landlord'],
triggers: ['facts.applied'],
parameters: [ProcessSetting::FormRequiresAddress],
performers: ['guest', 'landlord'],
events: ['facts', 'fact', 'guest', 'data_request', 'mail_in'],
);
}
/** We correspond with the guest ourselves (a request, or our documents, messages or payments). */
public function applies(CaseContext $case): bool
{
$profile = $case->profile;
return $case->inquiry || $profile->documents() === Responsibility::Landlord || $profile->guestMessages() === Responsibility::Landlord || $profile->arrivalInfoSender() === Responsibility::Landlord || $profile->reviewRequestSender() === Responsibility::Landlord || $profile->payments() === Responsibility::Landlord;
}
public function activities(CaseContext $case): array
{
$booking = $case->booking;
$profile = $case->profile;
$hasEmail = filled($booking->guest?->email);
// v0.11 (G2a): before the own binding offer – or the binding confirmation of a wish – every required detail.
$action = $profile->inquiryAnswer() === InquiryAnswer::Offer || $booking->offer_version > 0 ? CaseRequirements::OFFER : CaseRequirements::WISH_CONFIRMATION;
$needsDetails = $case->inquiry && ! $case->binding && $booking->offer_version === 0 && ($action === CaseRequirements::OFFER || $booking->wish_at !== null);
$missing = $hasEmail && $needsDetails ? CaseRequirements::missing($booking, $action) : [];
$request = $booking->openDataRequest();
$asked = $booking->contact_requested_at !== null || $request?->status === DataRequest::OPEN;
$state = match (true) {
$hasEmail && $missing === [] => ActivityState::Done,
$asked => ActivityState::Waiting,
default => ActivityState::Open,
};
$title = match (true) {
$booking->guest === null => 'Name und Kontaktdaten des Gastes eintragen',
! $hasEmail => 'E-Mail-Adresse des Gastes eintragen',
$missing !== [] => $action === CaseRequirements::OFFER ? 'Angaben für das Angebot vervollständigen' : 'Angaben für die Bestätigung vervollständigen',
default => 'Kontaktdaten des Gastes',
};
$detail = match (true) {
$state === ActivityState::Done => $booking->guestName(),
$missing !== [] => 'fehlt: '.implode(', ', CaseRequirements::labels($missing)).($request !== null ? ' · '.$request->statusLabel() : ($asked ? ' · beim Gast angefragt' : '')),
$booking->contact_requested_at !== null => 'beim Gast erfragt am '.$booking->contact_requested_at->format('d.m.Y'),
default => 'fehlt noch',
};
// A prepared data request waits for the landlord's release: that is the next step, otherwise entering the details.
$draft = $needsDetails && $request?->status === DataRequest::DRAFT;
return [new Activity('contact', $title, $case->later($draft ? ActivityState::Open : $state), $detail, $state === ActivityState::Done ? null : ($draft ? 'approveDataRequest' : 'provideContact'))];
}
}