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:
1 parent
ef1635e59a
commit
8442d0a3d8
62 files changed
+1818
-69
No files matched your search
@@ -79,15 +79,82 @@ public function profileKey(Channel $channel): string
|
||||
}
|
||||
|
||||
/**
|
||||
* The models the landlord may choose for this channel and intake kind.
|
||||
* Every model of the intake kind with whether this channel fits it and – if not – why and what to do (decision
|
||||
* E2/O2 and V2.1 §3.2: the capabilities of the channel decide, not a fixed list of portals).
|
||||
*
|
||||
* @param array<string, bool|string|null>|null $capabilityDraft unsaved capability values of the configurator
|
||||
* @return array<string, array{model: ProcessModel, admissible: bool, restrictions: list<Restriction>, hints: list<string>}>
|
||||
*/
|
||||
public function modelOptions(Channel $channel, IntakeKind $intake, ?array $capabilityDraft = null): array
|
||||
{
|
||||
$capabilities = app(ChannelCapabilities::class)->resolve($channel, $capabilityDraft);
|
||||
$options = [];
|
||||
foreach ($this->catalogue->admissible($intake) as $key => $model) {
|
||||
if ($channel->isWebsite() !== str_starts_with($key, 'a1.')) {
|
||||
continue;
|
||||
}
|
||||
$restrictions = [];
|
||||
$hints = [];
|
||||
foreach ($model::capabilityRequirements() as $capability => $required) {
|
||||
$actual = $capabilities[$capability] ?? null;
|
||||
$definition = ChannelCapabilities::definitions()[$capability];
|
||||
if ($actual === null || ! $actual->isKnown()) {
|
||||
$hints[] = $definition['label'].' ist noch nicht bekannt – bitte bestätigen.';
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($actual->value !== $required) {
|
||||
$fits = collect($this->catalogue->admissible($intake))->first(fn (ProcessModel $other): bool => $other::key() !== $key && collect($other::capabilityRequirements())->every(fn (bool $value, string $name): bool => ($capabilities[$name] ?? null)?->value === $value));
|
||||
$restrictions[] = new Restriction(
|
||||
Restriction::CAPABILITY,
|
||||
$model::label().' setzt voraus: „'.$definition['question'].'“ – '.($required ? 'ja' : 'nein').'. Für diesen Kanal gilt aber '.($actual->value ? 'ja' : 'nein').' ('.$actual->sourceLabel().').',
|
||||
$fits ? $fits::label() : null,
|
||||
'Wenn das nicht stimmt: oben bei „Was kann dieses Portal?“ „'.$definition['label'].'“ auf '.($required ? 'ja' : 'nein').' stellen und bestätigen.',
|
||||
);
|
||||
}
|
||||
}
|
||||
$options[$key] = ['model' => $model, 'admissible' => $restrictions === [], 'restrictions' => $restrictions, 'hints' => $hints];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* The models the landlord may choose now.
|
||||
*
|
||||
* @param array<string, bool|string|null>|null $capabilityDraft
|
||||
* @return array<string, ProcessModel>
|
||||
*/
|
||||
public function admissibleModels(Channel $channel, IntakeKind $intake): array
|
||||
public function admissibleModels(Channel $channel, IntakeKind $intake, ?array $capabilityDraft = null): array
|
||||
{
|
||||
$allowed = (array) (config('channels.portal_profiles.'.$this->profileKey($channel))[$intake->value] ?? []);
|
||||
return array_map(fn (array $option): ProcessModel => $option['model'], array_filter($this->modelOptions($channel, $intake, $capabilityDraft), fn (array $option): bool => $option['admissible']));
|
||||
}
|
||||
|
||||
return array_filter($this->catalogue->admissible($intake), fn (ProcessModel $model): bool => in_array($model::key(), $allowed, true));
|
||||
/**
|
||||
* Stored settings of the channel that the chosen model fixes differently: saving the model would silently override
|
||||
* them (they would stay stored but not take effect). They are listed so that the landlord confirms their removal.
|
||||
*
|
||||
* @return list<array{setting: ProcessSetting, stored: string, fixed: string, text: string}>
|
||||
*/
|
||||
public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey): array
|
||||
{
|
||||
if (! $this->catalogue->hasModel($modelKey)) {
|
||||
return [];
|
||||
}
|
||||
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
|
||||
$conflicts = [];
|
||||
foreach ($this->catalogue->model($modelKey)::fixes() as $key => $fixed) {
|
||||
$setting = ProcessSetting::tryFrom($key);
|
||||
$value = $setting?->normalize($stored[$key] ?? null);
|
||||
$fixedValue = $setting?->normalize($fixed) ?? $fixed;
|
||||
if ($setting === null || $value === null || (string) $value === (string) $fixedValue) {
|
||||
continue;
|
||||
}
|
||||
$conflicts[] = ['setting' => $setting, 'stored' => $setting->describe($value), 'fixed' => $setting->describe($fixedValue),
|
||||
'text' => $setting->question().' Bisher eingestellt: „'.$setting->describe($value).'“. Das Modell „'.$modelKey.'“ legt fest: „'.$setting->describe($fixedValue).'“.'];
|
||||
}
|
||||
|
||||
return $conflicts;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,11 +262,14 @@ public function problems(Channel $channel, IntakeKind $intake, array $draft, boo
|
||||
$problems[] = 'Dieser Kanal liefert keine '.($intake === IntakeKind::Booking ? 'festen Buchungen' : 'Anfragen').'.';
|
||||
}
|
||||
$key = (string) ($draft['model'] ?? '');
|
||||
$models = $this->admissibleModels($channel, $intake);
|
||||
if ($key === '' || ! array_key_exists($key, $models)) {
|
||||
return [...$problems, 'Das Ablaufmodell „'.$key.'“ ist für diesen Kanal nicht zulässig. Zulässig: '.(implode(', ', array_map(fn (ProcessModel $model): string => $model::label(), $models)) ?: 'keines').'.'];
|
||||
$options = $this->modelOptions($channel, $intake, (array) ($draft['capabilities'] ?? []) ?: null);
|
||||
if ($key === '' || ! array_key_exists($key, $options)) {
|
||||
return [...$problems, 'Das Ablaufmodell „'.$key.'“ gibt es für diese Eingangsart dieses Kanals nicht.'];
|
||||
}
|
||||
$model = $models[$key];
|
||||
if (! $options[$key]['admissible']) {
|
||||
return [...$problems, ...array_map(fn (Restriction $restriction): string => $restriction->text(), $options[$key]['restrictions'])];
|
||||
}
|
||||
$model = $options[$key]['model'];
|
||||
$variant = $model->variant((string) ($draft['variant'] ?? 'standard'));
|
||||
if ($variant === null) {
|
||||
return [...$problems, 'Das Modell hat diese Variante nicht.'];
|
||||
|
||||
Reference in new issue
Block a user