From fdf226535beb2034f5fa8f2489326e1970960c6a Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 5 Nov 2026 08:07:10 +0100 Subject: [PATCH] =?UTF-8?q?V2.1:=20nichtlineare=20Prozessansicht,=20Begr?= =?UTF-8?q?=C3=BCndung=20der=20Pflichtschritte,=20Bedienelemente=20der=20n?= =?UTF-8?q?euen=20Einstellungen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- .../Channels/Pages/ChannelProcess.php | 22 +++++++++++++++---- app/Process/ChannelProcessConfiguration.php | 21 +++++++++++++++++- .../Modules/Intake/PortalConfirmationStep.php | 1 + app/Process/Modules/Offer/Information.php | 1 + .../Modules/Stay/ArrivalInformation.php | 1 + .../channels/channel-process.blade.php | 17 +++++++++++--- .../Feature/Process/ChannelCapabilityTest.php | 19 ++++++++++++++++ tests/Feature/Process/ModuleContractTest.php | 3 +++ 8 files changed, 77 insertions(+), 8 deletions(-) diff --git a/app/Filament/Resources/Channels/Pages/ChannelProcess.php b/app/Filament/Resources/Channels/Pages/ChannelProcess.php index 31b99e9..a8eabb2 100644 --- a/app/Filament/Resources/Channels/Pages/ChannelProcess.php +++ b/app/Filament/Resources/Channels/Pages/ChannelProcess.php @@ -4,6 +4,7 @@ use App\Actions\ConfigureChannelProcess; use App\Enums\AdminMode; +use App\Enums\Execution; use App\Enums\IntakeKind; use App\Enums\ProcessSetting; use App\Filament\Resources\Channels\ChannelResource; @@ -175,13 +176,26 @@ public function steps(): array $profile = $this->profile(); $draft = $this->drafts[$this->intake]; - return array_map(function (array $row) use ($configuration, $catalogue, $model, $profile): array { + $rows = $configuration->preview($this->record, IntakeKind::from($this->intake), $this->draft()); + $labels = collect($rows)->mapWithKeys(fn (array $row): array => [$row['module'] => $row['label']]); + $active = collect($rows)->where('on', true)->pluck('module')->all(); + + return array_map(function (array $row) use ($configuration, $catalogue, $model, $profile, $labels, $active): array { $definition = $catalogue->modules()[$row['module']]::definition(); + // The view of the order is derived from the same definitions the runner uses: only dependencies present in the plan count. + $needs = collect($definition->requires)->filter(fn ($dependency): bool => $dependency->hard && in_array($dependency->module, $active, true))->map(fn ($dependency): string => $labels[$dependency->module])->values()->all(); + $after = collect($definition->requires)->filter(fn ($dependency): bool => ! $dependency->hard && in_array($dependency->module, $active, true))->map(fn ($dependency): string => $labels[$dependency->module])->values()->all(); $controls = ChannelProcessConfiguration::STEP_CONTROLS[$row['module']] ?? []; - $parameters = array_values(array_filter($controls['parameters'] ?? [], fn (ProcessSetting $setting): bool => in_array(IntakeKind::from($this->intake), $setting->channelIntakes(), true) && ! $model::fixesSetting($setting) && ($this->expert() || in_array($setting, [ProcessSetting::HoldHours, ProcessSetting::DataRequestReminderHours, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ClarificationHoldAutoMinutes], true)))); + $parameters = array_values(array_filter($controls['parameters'] ?? [], fn (ProcessSetting $setting): bool => in_array(IntakeKind::from($this->intake), $setting->channelIntakes(), true) && ! $model::fixesSetting($setting) && ($this->expert() || in_array($setting, [ProcessSetting::HoldHours, ProcessSetting::DataRequestReminderHours, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ClarificationHoldAutoMinutes, ProcessSetting::ContractDelivery, ProcessSetting::BookingNotice, ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours], true)))); return [...$row, 'purpose' => $definition->purpose, + 'needs' => $needs, + 'after' => $after, + 'condition' => $definition->condition, + 'why' => $definition->why, + 'executions' => array_map(fn (Execution $execution): string => $execution->getLabel(), $definition->executions), + 'triggers' => $definition->triggers, 'waits' => $definition->waits, 'optional' => $definition->isOptional(), 'version' => $catalogue->modules()[$row['module']]::version(), @@ -189,9 +203,9 @@ public function steps(): array 'mode_options' => $configuration->modeOptions($row['module']), 'performer_setting' => isset($controls['performer']) ? $controls['performer']['setting'] : null, 'performer_options' => $configuration->performerOptions($model, $row['module']), - 'parameters' => array_map(fn (ProcessSetting $setting): array => $this->setting($setting, $profile), $parameters), + 'parameters' => array_map(fn (ProcessSetting $setting): array => [...$this->setting($setting, $profile), 'options' => $configuration->settingOptions($setting)], $parameters), ]; - }, $configuration->preview($this->record, IntakeKind::from($this->intake), $this->draft())); + }, $rows); } /** diff --git a/app/Process/ChannelProcessConfiguration.php b/app/Process/ChannelProcessConfiguration.php index b2b0e54..2dc9eb5 100644 --- a/app/Process/ChannelProcessConfiguration.php +++ b/app/Process/ChannelProcessConfiguration.php @@ -2,7 +2,9 @@ namespace App\Process; +use App\Enums\BookingNoticeMode; use App\Enums\ChannelBookingModel; +use App\Enums\ContractDelivery; use App\Enums\DataRequestMode; use App\Enums\IntakeKind; use App\Enums\ProcessingMode; @@ -31,7 +33,9 @@ final class ChannelProcessConfiguration 'hold' => ['parameters' => [ProcessSetting::ClarificationHoldAutoMinutes, ProcessSetting::ClarificationHoldManualMinutes]], 'offer.binding' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::HoldHours, ProcessSetting::ContractTemplate]], 'offer.information' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::GuestLinkValidDays]], - 'documents.send' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::ContractTemplate]], + 'documents.send' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::ContractDelivery, ProcessSetting::ContractTemplate]], + 'documents.booking_notice' => ['parameters' => [ProcessSetting::BookingNotice]], + 'portal.confirmation' => ['parameters' => [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours]], 'arrival.info' => ['performer' => ['field' => 'guest_messages', 'setting' => ProcessSetting::GuestMessages], 'parameters' => [ProcessSetting::ArrivalInfoDaysBefore]], ]; @@ -193,6 +197,21 @@ public function performerOptions(ProcessModel $model, string $module): array ->all(); } + /** + * The fixed choices of a setting that is not free text (null: free input). + * + * @return array|null + */ + public function settingOptions(ProcessSetting $setting): ?array + { + return match ($setting) { + ProcessSetting::ContractDelivery => collect(ContractDelivery::cases())->mapWithKeys(fn (ContractDelivery $case): array => [$case->value => $case->getLabel()])->all(), + ProcessSetting::BookingNotice => collect(BookingNoticeMode::cases())->mapWithKeys(fn (BookingNoticeMode $case): array => [$case->value => $case->getLabel()])->all(), + ProcessSetting::AwaitPortalConfirmation => ['1' => 'ja, erst nach der Bestätigungsmail', '0' => 'nein, sofort'], + default => null, + }; + } + /** * Allowed modes of a step (as values of its setting). * diff --git a/app/Process/Modules/Intake/PortalConfirmationStep.php b/app/Process/Modules/Intake/PortalConfirmationStep.php index 490fb40..5d17494 100644 --- a/app/Process/Modules/Intake/PortalConfirmationStep.php +++ b/app/Process/Modules/Intake/PortalConfirmationStep.php @@ -39,6 +39,7 @@ public static function definition(): ModuleDefinition label: 'Bestätigung des Portals abwarten', purpose: 'Wartet auf die Bestätigungsmail des Portals, bevor Unterlagen und Nachrichten an den Gast gehen. Die Belegung ist von Anfang an gesichert.', phase: 'P02', + why: 'Solange das Portal die Buchung nicht bestätigt hat, sollen keine Unterlagen an den Gast gehen; die Belegung ist trotzdem gesichert.', executions: [Execution::Automatic, Execution::Manual, Execution::NotRequired], condition: 'nur bei extern verbindlicher Buchung und nur, wenn für den Kanal „Bestätigungsmail abwarten“ eingestellt ist', requires: [Dependency::hard('intake.record')], diff --git a/app/Process/Modules/Offer/Information.php b/app/Process/Modules/Offer/Information.php index adf0fe6..9a8d52a 100644 --- a/app/Process/Modules/Offer/Information.php +++ b/app/Process/Modules/Offer/Information.php @@ -33,6 +33,7 @@ public static function definition(): ModuleDefinition label: 'Unverbindliche Auskunft und Buchungswunsch', purpose: 'Beantwortet die Anfrage mit einer unverbindlichen Auskunft ohne Reservierung; fragt der Gast die Buchung an, wird erneut geprüft und verbindlich bestätigt.', phase: 'P02', + why: 'Der Gast braucht eine Antwort auf seine Anfrage; ob sie automatisch oder von Hand kommt, bestimmen Sie.', executions: [Execution::Automatic, Execution::Manual], condition: 'bei einer Anfrage ohne Reservierung', requires: [Dependency::hard('intake.record'), Dependency::soft('guest.data_request')], diff --git a/app/Process/Modules/Stay/ArrivalInformation.php b/app/Process/Modules/Stay/ArrivalInformation.php index 252e2f8..c0c5f9e 100644 --- a/app/Process/Modules/Stay/ArrivalInformation.php +++ b/app/Process/Modules/Stay/ArrivalInformation.php @@ -28,6 +28,7 @@ public static function definition(): ModuleDefinition label: 'Anreise-Informationen', purpose: 'Wegbeschreibung, Schlüssel und Kontakt vor Ort rechtzeitig vor der Anreise.', phase: 'P04', + why: 'Ohne Anreise-Informationen finden Gäste Schlüssel und Wohnung nicht; wer sie sendet, ist einstellbar.', executions: [Execution::Automatic, Execution::Portal, Execution::ServiceProvider, Execution::NotRequired], condition: 'bei verbindlichen Buchungen', effects: ['guest_mail'], diff --git a/resources/views/filament/resources/channels/channel-process.blade.php b/resources/views/filament/resources/channels/channel-process.blade.php index 20670c2..00ca201 100644 --- a/resources/views/filament/resources/channels/channel-process.blade.php +++ b/resources/views/filament/resources/channels/channel-process.blade.php @@ -112,6 +112,10 @@
{{ $step['purpose'] }}
+ @if ($step['needs'] !== []) braucht zuerst: {{ implode(', ', $step['needs']) }} · @elseif ($step['on']) läuft unabhängig · @endif + @if ($step['after'] !== []) soll nach: {{ implode(', ', $step['after']) }} · @endif + @if ($step['condition']) nur wenn: {{ $step['condition'] }} · @endif + @if ($step['executions'] !== [] && ! $step['optional']) So darf das erfüllt werden: {{ implode(', ', $step['executions']) }}@if ($step['why']) – {{ $step['why'] }}@endif · @endif Wer: {{ $performers[$step['performer']] ?? $step['performer'] ?? '–' }} @if ($step['waits'] !== []) · kann warten auf: {{ implode(', ', array_map(fn ($wait) => ['guest' => 'Gast', 'portal' => 'Portal', 'landlord' => 'Sie', 'time' => 'Frist'][$wait] ?? $wait, $step['waits'])) }}@endif @if (! $step['on'] && $step['reason']) · übersprungen: {{ $step['reason'] }}@endif @@ -140,7 +144,14 @@ @foreach ($step['parameters'] as $parameter)
-
    +
      @foreach ($steps as $step)
    • {{ $step['label'] }} – {{ $step['on'] ? ($performers[$step['performer']] ?? $step['performer'] ?? '').($step['mode'] ? ', '.(\App\Enums\ProcessingMode::tryFrom($step['mode'])?->getLabel() ?? \App\Enums\DataRequestMode::tryFrom($step['mode'])?->getLabel() ?? $step['mode']) : '') : 'übersprungen: '.$step['reason'] }}
    • @endforeach -
+

Gilt für neue Vorgänge. Laufende Vorgänge dieses Kanals ({{ $this->runningCases() }}) behalten ihren bisherigen Ablauf.

Ablauf testen

Spielt einen ausgedachten Vorgang mit genau dieser Einstellung durch – ohne Wirkung auf echte Daten.

diff --git a/tests/Feature/Process/ChannelCapabilityTest.php b/tests/Feature/Process/ChannelCapabilityTest.php index ecff10e..577bdd5 100644 --- a/tests/Feature/Process/ChannelCapabilityTest.php +++ b/tests/Feature/Process/ChannelCapabilityTest.php @@ -103,6 +103,25 @@ public function test_a_stored_old_setting_becomes_a_derived_capability_and_is_no $page->assertSee('abgeleitet aus Ihrer bisherigen Einstellung'); } + /** The order is shown from the module definitions: dependencies, independence, conditions and how a duty may be fulfilled. */ + public function test_the_configurator_shows_dependencies_independence_and_allowed_fulfilment(): void + { + $ds = $this->channel('Destination Solution', []); + $this->actingAs(User::factory()->create()); + + $steps = collect(Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])->set('intake', 'booking')->instance()->steps())->keyBy('module'); + + $this->assertNotEmpty($steps['documents.send']['needs'], 'the contract documents need something first'); + $this->assertSame([], $steps['intake.record']['needs'], 'the intake depends on nothing'); + $this->assertNotNull($steps['documents.booking_notice']['condition']); + foreach ($steps as $step) { + if ($step['toggle'] === 'mandatory' && $step['executions'] !== []) { + $this->assertNotNull($step['why'], $step['module'].': the restriction is explained'); + } + } + $this->assertNotEmpty(collect($steps['documents.send']['parameters'])->firstWhere('key', 'contract_delivery')['options']); + } + public function test_saving_a_model_that_overrides_a_stored_setting_needs_the_confirmation_and_is_recorded(): void { $channel = $this->channel('Sonstiges Portal', ['booking' => ['payments' => 'portal', 'guest_messages' => 'portal']]); diff --git a/tests/Feature/Process/ModuleContractTest.php b/tests/Feature/Process/ModuleContractTest.php index e81454e..ddaefa9 100644 --- a/tests/Feature/Process/ModuleContractTest.php +++ b/tests/Feature/Process/ModuleContractTest.php @@ -57,6 +57,9 @@ public function test_every_module_has_a_complete_definition(): void $this->assertNotSame([], $definition->modes, "{$key}: an automatic module names its modes"); $this->assertNotSame([], $definition->triggers, "{$key}: an automatic module names its triggers"); } + if ($definition->toggle === ModuleDefinition::TOGGLE_MANDATORY && $definition->executions !== []) { + $this->assertNotNull($definition->why, "{$key}: a mandatory duty states why (shown instead of a lock)"); + } if ($definition->isTesterOnly()) { $this->assertNotSame([], $definition->points, "{$key}: a tester-only module sits at an extension point"); }