Schablonenkomposition: Basisprozess external.booking mit Platz für Finanz- und Dokumentenschablonen

Vier Schablonen (Eigenes/Portal-Inkasso, Eigene/Externe Vertragsdokumentation) in
app/Process/Templates, TemplateComposer prüft Ergebnisse, Verantwortlichkeiten, Ausschlüsse
und harte Modulabhängigkeiten. Der Plan friert die Schablonenversionen ein. A3–A5 bleiben
als Voreinstellungen; die vierte Kombination (eigenes Inkasso + externe Unterlagen) ist
darstellbar. Konfigurator-Logik und ConfigureChannelProcess kennen die Schablonenwahl.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-05 10:48:49 +01:00
1 parent 381720763c
commit e95ba4f986
24 files changed
+1666 -37

No files matched your search

+22 -7
View File
@@ -6,6 +6,7 @@
use App\Models\Booking;
use App\Models\Channel;
use App\Process\Models\ProcessModel;
use App\Process\Templates\TemplateComposer;
use DomainException;
/**
@@ -27,6 +28,7 @@ final class ProcessPlan
* @param array<string, int> $modules module key => frozen version
* @param array<string, array{on?: bool, mode?: ?string, performer?: ?string, params?: array<string, mixed>}> $steps
* @param array<string, string> $labels module key => label at the time of freezing
* @param array<string, string> $templates area => function template key@version the plan was composed with
*/
public function __construct(
public readonly string $model,
@@ -37,6 +39,7 @@ public function __construct(
public readonly string $source = self::DERIVED,
public readonly array $labels = [],
public readonly ?string $notice = null,
public readonly array $templates = [],
) {}
/**
@@ -64,7 +67,7 @@ public static function derive(ProcessProfile $profile): self
* Ablauf), when admissible for the case's type; otherwise the derived one with a notice. Tester-only variants or
* modules are refused outside the process tester (decision E7).
*
* @param array<string, mixed> $configuration model, variant, steps of channels.process_overrides[intake]
* @param array<string, mixed> $configuration model, variant, steps, templates of channels.process_overrides[intake]
*/
public static function freeze(ProcessProfile $profile, array $configuration, bool $sandbox = false): self
{
@@ -96,7 +99,16 @@ public static function freeze(ProcessProfile $profile, array $configuration, boo
}
}
return self::build($model, $variant, (array) ($configuration['steps'] ?? []), $sandbox ? self::TESTER : self::CONFIGURED);
$templates = [];
if ($model->slots() !== []) {
$composer = app(TemplateComposer::class);
$templates = $composer->resolve($model, (array) ($configuration['templates'] ?? []));
if (($problems = $composer->problems($model, $templates, $variant)) !== []) {
return self::derive($profile)->withNotice("Schablonen von {$chosen} nicht zulässig (".implode(' ', $problems).') – abgeleitetes Modell verwendet.');
}
}
return self::build($model, $variant, (array) ($configuration['steps'] ?? []), $sandbox ? self::TESTER : self::CONFIGURED, $templates);
}
/**
@@ -110,29 +122,30 @@ public static function configurationOf(?Channel $channel, IntakeKind $intake): a
return [];
}
return array_intersect_key((array) (($channel->process_overrides ?? [])[$intake->value] ?? []), array_flip(['model', 'variant', 'steps']));
return array_intersect_key((array) (($channel->process_overrides ?? [])[$intake->value] ?? []), array_flip(['model', 'variant', 'steps', 'templates']));
}
/**
* @param array<string, mixed> $steps
* @param array<string, string> $templates area => key@version
*/
private static function build(ProcessModel $model, string $variant, array $steps, string $source): self
private static function build(ProcessModel $model, string $variant, array $steps, string $source, array $templates = []): self
{
$catalogue = app(ProcessCatalogue::class);
$modules = [];
$labels = [];
foreach ($model->modules($variant) as $key) {
foreach ($model->modules($variant, $templates) as $key) {
$class = $catalogue->modules()[$key];
$modules[$key] = $class::version();
$labels[$key] = $class::definition()->label;
}
return new self($model::key(), $model::version(), $variant, $modules, array_intersect_key($steps, $modules), $source, $labels);
return new self($model::key(), $model::version(), $variant, $modules, array_intersect_key($steps, $modules), $source, $labels, null, $templates);
}
private function withNotice(string $notice): self
{
return new self($this->model, $this->modelVersion, $this->variant, $this->modules, $this->steps, $this->source, $this->labels, $notice);
return new self($this->model, $this->modelVersion, $this->variant, $this->modules, $this->steps, $this->source, $this->labels, $notice, $this->templates);
}
public function modelDefinition(): ProcessModel
@@ -204,6 +217,7 @@ public function toArray(): array
'source' => $this->source,
'labels' => $this->labels,
'notice' => $this->notice,
'templates' => $this->templates === [] ? null : $this->templates,
], fn (mixed $value): bool => $value !== null);
}
@@ -221,6 +235,7 @@ public static function fromArray(array $data): self
(string) ($data['source'] ?? self::DERIVED),
(array) ($data['labels'] ?? []),
isset($data['notice']) ? (string) $data['notice'] : null,
array_map('strval', (array) ($data['templates'] ?? [])),
);
}
}