V2.1: Kanalfähigkeiten, Ausführungsvarianten, Dokumentenentkopplung, Portalbestätigung

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>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-05 07:54:11 +01:00
1 parent ef1635e59a
commit 8442d0a3d8
62 files changed
+1818 -69

No files matched your search

@@ -2,6 +2,8 @@
namespace App\Filament\Forms;
use App\Enums\BookingNoticeMode;
use App\Enums\ContractDelivery;
use App\Enums\DataRequestMode;
use App\Enums\ProcessingMode;
use App\Enums\ProcessSetting;
@@ -49,6 +51,13 @@ public static function field(string $name, ProcessSetting $setting, string $inhe
ProcessSetting::DataRequestRemindersMax, ProcessSetting::DataRequestFollowupsMax => TextInput::make($name)->integer()->minValue(0)->maxValue(5)->placeholder($placeholder),
ProcessSetting::DataRequestReminderHours => TextInput::make($name)->integer()->minValue(1)->maxValue(336)->suffix('Stunden')->placeholder($placeholder),
ProcessSetting::GuestLinkValidDays => TextInput::make($name)->integer()->minValue(1)->maxValue(60)->suffix('Tage')->placeholder($placeholder),
ProcessSetting::ContractDelivery => Select::make($name)->options(ContractDelivery::class)->placeholder($placeholder)
->helperText('Erstellen und Ablegen sind vom Versand getrennt. Ein nur intern abgelegter Vertrag gilt nicht als gesendet. Gilt für extern verbindliche Buchungen, bei denen wir die Vertragsunterlagen übernehmen.'),
ProcessSetting::BookingNotice => Select::make($name)->options(BookingNoticeMode::class)->placeholder($placeholder)
->helperText('Eine kurze Information über die Buchung – unabhängig vom Vertrag. Das Portal bleibt für seine eigenen Nachrichten zuständig.'),
ProcessSetting::AwaitPortalConfirmation => Select::make($name)->options(['1' => 'Ja – Unterlagen und Nachrichten warten auf die Bestätigungsmail des Portals', '0' => 'Nein – sofort bearbeiten'])->placeholder($placeholder)
->helperText('Die Belegung ist von Anfang an gesichert; es wartet nur, was Sie hier einstellen. Bleibt die Mail aus, erhalten Sie eine Aufgabe.'),
ProcessSetting::PortalConfirmationWaitHours => TextInput::make($name)->integer()->minValue(1)->maxValue(720)->suffix('Stunden')->placeholder($placeholder),
ProcessSetting::FormRequiresAddress => Select::make($name)->options(['1' => 'Ja – ohne vollständige Anschrift kann nicht angefragt werden', '0' => 'Nein – fehlt sie, wird beim Gast nachgefragt'])->placeholder($placeholder),
})->label($setting->question());
}
@@ -11,6 +11,7 @@
use App\Actions\RecordPortalAmounts;
use App\Actions\RequestCaseData;
use App\Actions\SendBookingDocuments;
use App\Actions\SendBookingNotice;
use App\Actions\SendOffer;
use App\Actions\SetBookingStatus;
use App\Documents\OfferTerms;
@@ -18,6 +19,7 @@
use App\Enums\ActivityState;
use App\Enums\AdminMode;
use App\Enums\AmountKind;
use App\Enums\BookingNoticeMode;
use App\Enums\BookingStatus;
use App\Enums\BookingTaskKind;
use App\Enums\BookingTaskStatus;
@@ -50,6 +52,8 @@
use App\Process\CaseAutomation;
use App\Process\CaseLog;
use App\Process\CaseRequirements;
use App\Process\PortalConfirmation;
use App\Process\ProcessRunner;
use App\Support\Countries;
use App\Support\Money;
use Carbon\CarbonImmutable;
@@ -141,6 +145,8 @@ protected function getHeaderActions(): array
$this->confirmAction(),
$this->sendDocumentsAction(),
$this->resendConfirmationAction(),
$this->confirmPortalAction(),
$this->sendBookingNoticeAction(),
$this->portalPriceAction(),
$this->changeAction(),
$this->confirmPortalCancellationAction(),
@@ -492,6 +498,50 @@ private function confirmAction(): Action
});
}
/**
* V2.1: the landlord states that the portal confirmed the booking (e.g. seen in the portal's own interface). The steps that
* wait for it go on; the booking itself was binding from the start.
*/
private function confirmPortalAction(): Action
{
return Action::make('confirmPortal')
->label('Bestätigung des Portals festhalten')
->icon(Heroicon::OutlinedCheckBadge)
->visible(fn (): bool => $this->record->isBinding() && $this->record->process()->awaitsPortalConfirmation() && PortalConfirmation::evidence($this->record) === null)
->modalDescription('Das Portal hat die Buchung bestätigt (z. B. in seiner Oberfläche gesehen). Unterlagen und Nachrichten, die darauf warten, gehen dann weiter. Die Buchung bleibt wie sie ist.')
->schema([Textarea::make('note')->label('Woran haben Sie das gesehen?')->rows(2)->maxLength(500)])
->action(function (array $data): void {
PortalConfirmation::confirm($this->record, CaseLog::actor(), $data['note'] ?? null);
app(ProcessRunner::class)->advance($this->record->fresh(), 'portal.mail');
$this->record->refresh();
Notification::make()->title('Bestätigung festgehalten')->success()->send();
});
}
/**
* V2.1: the short booking information to the guest, sent by hand (also where the automatic dispatch is off).
*/
private function sendBookingNoticeAction(): Action
{
return Action::make('sendBookingNotice')
->label('Buchungsinformation an den Gast senden')
->icon(Heroicon::OutlinedEnvelope)
->visible(fn (): bool => $this->record->isBinding() && $this->record->process()->bookingNotice() !== BookingNoticeMode::Off && ! SendBookingNotice::sent($this->record) && filled($this->record->guest?->email))
->requiresConfirmation()
->modalDescription('Der Gast erhält eine kurze Information über seine Buchung – ohne Vertrag.')
->action(function (SendBookingNotice $notice): void {
try {
$notice->handle($this->record->fresh());
} catch (ReservationException $exception) {
Notification::make()->title('Nicht gesendet')->body($exception->getMessage())->danger()->send();
return;
}
$this->record->refresh();
Notification::make()->title('Buchungsinformation gesendet')->success()->send();
});
}
private function resendConfirmationAction(): Action
{
return Action::make('resendConfirmation')
@@ -10,11 +10,14 @@
use App\Models\Booking;
use App\Models\Channel;
use App\Models\User;
use App\Process\Capability;
use App\Process\ChannelCapabilities;
use App\Process\ChannelProcessConfiguration;
use App\Process\Models\ProcessModel;
use App\Process\ProcessCatalogue;
use App\Process\ProcessProfile;
use App\Process\ProcessSettings;
use App\Process\Restriction;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
@@ -44,6 +47,12 @@ class ChannelProcess extends Page
/** @var array<string, array{model: string, variant: string, steps: array<string, array{on?: bool}>, settings: array<string, mixed>}> */
public array $drafts = [];
/** @var array<string, string> capability key => '1' | '0' | '' (unknown); saving confirms what is shown */
public array $capabilityDraft = [];
/** The landlord confirmed that stored settings the chosen model overrides are removed. */
public bool $acknowledge = false;
public function mount(int|string $record): void
{
$this->record = $this->resolveRecord($record);
@@ -51,8 +60,9 @@ public function mount(int|string $record): void
foreach ($configuration->intakes($this->record) as $intake) {
$current = $configuration->current($this->record, $intake);
$stored = (array) (($this->record->process_overrides ?? [])[$intake->value] ?? []);
$models = $configuration->admissibleModels($this->record, $intake);
$model = array_key_exists($current['model'], $models) || $models === [] ? $current['model'] : (string) array_key_first($models);
// The current (saved or derived) model stays selected even if it is not admissible: the page explains why instead of
// switching silently to another one.
$model = $current['model'];
$this->drafts[$intake->value] = [
'model' => $model,
'variant' => $current['variant'],
@@ -62,6 +72,26 @@ public function mount(int|string $record): void
];
}
$this->intake = (string) array_key_first($this->drafts);
$this->capabilityDraft = $this->record->isWebsite() ? [] : collect(app(ChannelCapabilities::class)->resolve($this->record))
->map(fn (Capability $capability): string => $capability->value === null ? '' : ($capability->value ? '1' : '0'))->all();
}
/**
* The draft of the current intake kind including the capabilities shown (they decide which models fit).
*
* @return array<string, mixed>
*/
private function draft(): array
{
return [...$this->drafts[$this->intake], 'capabilities' => $this->capabilityDraft];
}
/**
* @return array<string, Capability>
*/
public function capabilities(): array
{
return app(ChannelCapabilities::class)->resolve($this->record, $this->capabilityDraft);
}
public function getTitle(): string
@@ -92,15 +122,31 @@ public function question(): string
}
/**
* @return array<string, ProcessModel>
* Every model of this intake kind with whether the channel fits it and why not.
*
* @return array<string, array{model: ProcessModel, admissible: bool, restrictions: list<Restriction>, hints: list<string>}>
*/
public function models(): array
{
return app(ChannelProcessConfiguration::class)->admissibleModels($this->record, IntakeKind::from($this->intake));
return app(ChannelProcessConfiguration::class)->modelOptions($this->record, IntakeKind::from($this->intake), $this->capabilityDraft);
}
/**
* Stored settings the chosen model would silently override.
*
* @return list<array{setting: ProcessSetting, stored: string, fixed: string, text: string}>
*/
public function conflicts(): array
{
return app(ChannelProcessConfiguration::class)->conflicts($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]['model']);
}
public function chooseModel(string $model): void
{
if (! ($this->models()[$model]['admissible'] ?? false)) {
return;
}
$this->acknowledge = false;
$this->drafts[$this->intake]['model'] = $model;
$this->drafts[$this->intake]['variant'] = 'standard';
$this->drafts[$this->intake]['steps'] = [];
@@ -113,7 +159,7 @@ public function model(): ProcessModel
public function profile(): ProcessProfile
{
return app(ChannelProcessConfiguration::class)->profileWith($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]);
return app(ChannelProcessConfiguration::class)->profileWith($this->record, IntakeKind::from($this->intake), $this->draft());
}
/**
@@ -145,7 +191,7 @@ public function steps(): array
'performer_options' => $configuration->performerOptions($model, $row['module']),
'parameters' => array_map(fn (ProcessSetting $setting): array => $this->setting($setting, $profile), $parameters),
];
}, $configuration->preview($this->record, IntakeKind::from($this->intake), $draft));
}, $configuration->preview($this->record, IntakeKind::from($this->intake), $this->draft()));
}
/**
@@ -182,7 +228,7 @@ public function toggleStep(string $module): void
*/
public function problems(): array
{
return app(ChannelProcessConfiguration::class)->problems($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]);
return app(ChannelProcessConfiguration::class)->problems($this->record, IntakeKind::from($this->intake), $this->draft());
}
/**
@@ -200,13 +246,17 @@ public function runningCases(): int
public function save(): void
{
try {
$this->record = app(ConfigureChannelProcess::class)->handle($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]);
$this->record = app(ConfigureChannelProcess::class)->handle($this->record, IntakeKind::from($this->intake), $this->draft(), acknowledgeConflicts: $this->acknowledge);
} catch (ValidationException $exception) {
Notification::make()->title('Nicht gespeichert')->body(collect($exception->errors())->flatten()->implode(' '))->danger()->persistent()->send();
return;
}
$this->drafts[$this->intake]['derived'] = false;
$this->acknowledge = false;
$intake = $this->intake;
$this->mount($this->record->getKey());
$this->intake = $intake;
$running = $this->runningCases();
Notification::make()->title('Ablauf gespeichert')->body('Gilt für neue Vorgänge.'.($running > 0 ? ' '.$running.' laufende Vorgänge behalten ihren bisherigen Ablauf.' : ''))->success()->send();
}
@@ -216,7 +266,7 @@ public function save(): void
*/
public function test(): void
{
session()->put('process-tester.draft.'.$this->record->id.'.'.$this->intake, $this->drafts[$this->intake]);
session()->put('process-tester.draft.'.$this->record->id.'.'.$this->intake, $this->draft());
$this->redirect(ChannelResource::getUrl('test', ['record' => $this->record, 'intake' => $this->intake]));
}