Files
fewo-stommer/app/Enums/DocumentKind.php
T
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

127 lines
5.5 KiB
PHP
Raw 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\Enums;
use App\Models\Booking;
use Filament\Support\Contracts\HasLabel;
/**
* The kinds of documents a case can produce (UMSETZUNGSPLAN_v0.10 §5.4). Which one a case needs follows from its case
* type, never from a choice of the landlord: a request gets a binding offer, a booking we made ourselves gets the
* confirmation with the rental contract, a booking that is already binding on a portal gets the booking documentation
* without an acceptance link (E-004), a request without a hold gets the information "unter Vorbehalt" with the link to
* ask for the booking (package 7, E-026).
*/
enum DocumentKind: string implements HasLabel
{
case Offer = 'offer';
case Information = 'information';
case Confirmation = 'confirmation';
case ExternalRecord = 'external_record';
case StayConfirmation = 'stay_confirmation';
case Internal = 'internal';
case DataRequest = 'data_request';
public function getLabel(): string
{
return match ($this) {
self::Offer => 'Angebot mit Annahmelink',
self::Information => 'Auskunft unter Vorbehalt',
self::Confirmation => 'Buchungsbestätigung mit Mietvertrag',
self::ExternalRecord => 'Buchungsunterlagen (beim Portal gebucht)',
self::StayConfirmation => 'Aufenthaltsbestätigung (privat)',
self::Internal => 'Nur intern, kein Dokument an Gäste',
self::DataRequest => 'Rückfrage nach fehlenden Angaben',
};
}
/**
* What the landlord reads about this kind on the settings page.
*/
public function description(): string
{
return match ($this) {
self::Offer => 'Für Anfragen: Preis, Vertragsentwurf und ein Link, mit dem der Gast verbindlich annimmt.',
self::Information => 'Für Anfragen ohne Reservierung: Preis und Verfügbarkeit zum Zeitpunkt der Prüfung, ohne Reservierung und ohne Zusage. Der Gast kann daraus die Buchung anfragen; verbindlich wird sie erst mit Ihrer (oder der automatischen) Bestätigung nach erneuter Prüfung.',
self::Confirmation => 'Nach der Annahme eines Angebots oder einer direkt vereinbarten Buchung: Bestätigung mit dem Mietvertrag.',
self::ExternalRecord => 'Für Buchungen, die beim Portal bereits verbindlich sind: Buchungsdaten und – falls hinterlegt – Ihre Vorlage, ohne erneute Annahme durch den Gast.',
self::StayConfirmation => 'Für private Überlassungen (Familie, Freunde): Bestätigung des Aufenthalts ohne Mietvertrag, nur auf Wunsch.',
self::Internal => 'Eigennutzung und Wartung: kein Dokument an Gäste.',
self::DataRequest => 'E-Mail an den Gast mit der Bitte um fehlende Angaben (Anschrift, Personenzahl …) und einem persönlichen Link zum Ergänzen, dazu Erinnerungen und gezielte Folgefragen. Sie nennt nur eine tatsächlich bestehende vorläufige Reservierung. Im Testbetrieb gehen die Texte auch ohne Freigabe hinaus (nur an die Testadresse).',
};
}
/**
* The document a case needs at its current stage, or null when nobody needs one from us (e.g. the portal sends it).
*/
public static function forCase(Booking $booking): ?self
{
$profile = $booking->process();
return match (true) {
$booking->intake === IntakeKind::Internal => $booking->guest_id !== null ? self::StayConfirmation : self::Internal,
$booking->caseType()->isExternallyBinding() => $profile->documents() === Responsibility::Portal ? null : self::ExternalRecord,
$booking->isBinding() => $profile->documents() === Responsibility::Portal ? null : self::Confirmation,
$profile->inquiryAnswer() === InquiryAnswer::Information => self::Information,
default => self::Offer,
};
}
/**
* Whether the guest makes the contract by accepting this document (only the offer carries an acceptance link).
*/
public function hasAcceptanceLink(): bool
{
return $this === self::Offer;
}
/**
* Whether a rental contract is part of this document.
*/
public function containsContract(): bool
{
return in_array($this, [self::Offer, self::Confirmation, self::ExternalRecord], true);
}
/**
* Whether this kind can be sent with the current packages (the others exist as working drafts only).
*/
public function isAvailable(): bool
{
return in_array($this, [self::Offer, self::Information, self::Confirmation, self::ExternalRecord, self::StayConfirmation, self::DataRequest], true);
}
/**
* Whether the texts of this kind count as released while the landlord has not decided otherwise: the offer and the
* confirmation are the documents in use since the start; every new kind starts as a working draft.
*/
public function releasedByDefault(): bool
{
return in_array($this, [self::Offer, self::Confirmation], true);
}
/**
* Whether this kind goes to guests at all.
*/
public function isForGuests(): bool
{
return $this !== self::Internal;
}
/**
* File name prefix of the stored PDF.
*/
public function fileName(): string
{
return match ($this) {
self::Offer => 'Angebot',
self::Information => 'Auskunft',
self::Confirmation => 'Mietvertrag',
self::ExternalRecord => 'Buchungsunterlagen',
self::StayConfirmation => 'Aufenthaltsbestaetigung',
self::Internal => 'Intern',
self::DataRequest => 'Rueckfrage',
};
}
}