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

@@ -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]));
}