Kanalkonfigurator und Prozess-Tester auf Schablonenbasis
Geschäftsentscheidungen zuerst (Schablonen je Bereich, Voreinstellungen A3–A5), Einzelschritte eingeklappt, Auswirkungsanalyse beim Schablonenwechsel, unbestätigte Portal-Fähigkeiten gekennzeichnet. Tester-Bericht nennt Schablonen, unabhängig laufende Schritte und fehlende Nachweise; alle vier Kombinationen sind als Szenario getestet. Doku: SCHABLONEN.md. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e95ba4f986
commit
c46f4a032b
12 files changed
+810
-10
No files matched your search
@@ -16,6 +16,8 @@
|
||||
use App\Pricing\CaseMoney;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Process\CaseAutomation;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use App\Process\ProcessPlan;
|
||||
use App\Process\ProcessProfile;
|
||||
use App\Support\Money;
|
||||
use Carbon\CarbonImmutable;
|
||||
@@ -121,6 +123,7 @@ public static function configure(Schema $schema): Schema
|
||||
->schema([
|
||||
TextEntry::make('status')->label('Status')->badge(),
|
||||
TextEntry::make('case_type')->label('Vorgangsart')->state(fn (Booking $record): string => strtoupper($record->caseType()->value).' – '.$record->caseType()->getLabel()),
|
||||
TextEntry::make('templates')->label('Funktionsschablonen')->state(fn (Booking $record): ?string => self::templates($record))->placeholder('– (fester Ablauf)'),
|
||||
TextEntry::make('intake')->label('Eingangsart')->state(fn (Booking $record): string => $record->intake?->getLabel() ?? '–'),
|
||||
TextEntry::make('sources')->label('Quellen und Kalenderdarstellungen')->state(fn (Booking $record): HtmlString => self::sources($record))->html()->columnSpanFull(),
|
||||
TextEntry::make('profile')->label('Abwicklungsprofil (eingefroren)')->state(fn (Booking $record): HtmlString => self::profile($record))->html()->columnSpanFull(),
|
||||
@@ -238,6 +241,17 @@ private static function history(Booking $booking): HtmlString
|
||||
return new HtmlString($rows === '' ? 'Noch keine Einträge.' : '<ul style="list-style:none;padding:0;margin:0;font-size:.9rem">'.$rows.'</ul>');
|
||||
}
|
||||
|
||||
/**
|
||||
* The function templates the case was composed with, as frozen in its plan (null for the fixed models).
|
||||
*/
|
||||
private static function templates(Booking $record): ?string
|
||||
{
|
||||
$catalogue = app(ProcessCatalogue::class);
|
||||
$labels = array_map(fn (string $reference): string => ($class = $catalogue->templateClass($reference)) !== null ? $class::label().' ('.$reference.')' : $reference, ProcessPlan::of($record)->templates);
|
||||
|
||||
return $labels === [] ? null : implode(' · ', $labels);
|
||||
}
|
||||
|
||||
private static function profile(Booking $booking): HtmlString
|
||||
{
|
||||
$profile = $booking->process();
|
||||
|
||||
@@ -15,11 +15,14 @@
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\ChannelProcessConfiguration;
|
||||
use App\Process\ConfigurationImpact;
|
||||
use App\Process\Models\ExternalBookingModel;
|
||||
use App\Process\Models\ProcessModel;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use App\Process\ProcessProfile;
|
||||
use App\Process\ProcessSettings;
|
||||
use App\Process\Restriction;
|
||||
use App\Process\Templates\FunctionTemplate;
|
||||
use App\Process\Templates\TemplateArea;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
||||
@@ -46,7 +49,7 @@ class ChannelProcess extends Page
|
||||
|
||||
public string $intake = 'inquiry';
|
||||
|
||||
/** @var array<string, array{model: string, variant: string, steps: array<string, array{on?: bool}>, settings: array<string, mixed>}> */
|
||||
/** @var array<string, array{model: string, variant: string, steps: array<string, array{on?: bool}>, settings: array<string, mixed>, templates: array<string, string>}> */
|
||||
public array $drafts = [];
|
||||
|
||||
/** @var array<string, string> capability key => '1' | '0' | '' (unknown); saving confirms what is shown */
|
||||
@@ -69,6 +72,7 @@ public function mount(int|string $record): void
|
||||
'model' => $model,
|
||||
'variant' => $current['variant'],
|
||||
'steps' => (array) ($stored['steps'] ?? []),
|
||||
'templates' => (array) ($stored['templates'] ?? []),
|
||||
'settings' => array_map(fn (mixed $value): mixed => is_bool($value) ? ($value ? '1' : '0') : $value, array_intersect_key($stored, array_flip(array_map(fn (ProcessSetting $setting): string => $setting->value, ProcessSetting::cases())))),
|
||||
'derived' => $current['derived'],
|
||||
];
|
||||
@@ -140,7 +144,124 @@ public function models(): array
|
||||
*/
|
||||
public function conflicts(): array
|
||||
{
|
||||
return app(ChannelProcessConfiguration::class)->conflicts($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]['model']);
|
||||
return app(ChannelProcessConfiguration::class)->conflicts($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]['model'], $this->drafts[$this->intake]['templates']);
|
||||
}
|
||||
|
||||
/**
|
||||
* The models offered as a choice: the archetypes A3–A5 are presets of the base process, so they only appear while one
|
||||
* of them is the current choice (then with the hint to move to the templates).
|
||||
*
|
||||
* @param array<string, array{model: ProcessModel, admissible: bool, restrictions: list<Restriction>, hints: list<string>}> $models
|
||||
* @return array<string, array{model: ProcessModel, admissible: bool, restrictions: list<Restriction>, hints: list<string>}>
|
||||
*/
|
||||
public function visibleModels(array $models): array
|
||||
{
|
||||
return array_filter($models, fn (array $option, string $key): bool => ! $option['model']::isLegacy() || $key === $this->drafts[$this->intake]['model'], ARRAY_FILTER_USE_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the chosen model composes function templates (otherwise its course is fixed).
|
||||
*/
|
||||
public function composable(): bool
|
||||
{
|
||||
return $this->model()->slots() !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* The business decisions of the chosen base process: per slot the templates with fit, selection and what each stands
|
||||
* for. The first view of the configurator; the single steps stay below.
|
||||
*
|
||||
* @return list<array{area: TemplateArea, selected: ?string, options: list<array{key: string, template: class-string<FunctionTemplate>, admissible: bool, selected: bool, restrictions: list<Restriction>, hints: list<string>, unconfirmed: list<string>, modules: list<string>}>}>
|
||||
*/
|
||||
public function decisions(): array
|
||||
{
|
||||
$model = $this->model();
|
||||
if ($model->slots() === []) {
|
||||
return [];
|
||||
}
|
||||
$configuration = app(ChannelProcessConfiguration::class);
|
||||
$catalogue = app(ProcessCatalogue::class);
|
||||
$resolved = $configuration->templatesOf($model, $this->draft());
|
||||
$options = $configuration->templateOptions($this->record, $model, $this->capabilityDraft);
|
||||
$decisions = [];
|
||||
foreach ($model->slots() as $area) {
|
||||
$selected = isset($resolved[$area->value]) ? explode('@', $resolved[$area->value])[0] : null;
|
||||
$decisions[] = [
|
||||
'area' => $area,
|
||||
'selected' => $selected,
|
||||
'options' => array_values(array_map(fn (array $option, string $key): array => [
|
||||
...$option,
|
||||
'key' => $key,
|
||||
'selected' => $key === $selected,
|
||||
'modules' => array_map(fn (string $module): string => $catalogue->modules()[$module]::definition()->label, $option['template']::modules()),
|
||||
], $options[$area->value] ?? [], array_keys($options[$area->value] ?? []))),
|
||||
];
|
||||
}
|
||||
|
||||
return $decisions;
|
||||
}
|
||||
|
||||
/**
|
||||
* The archetypes as known combinations (presets) the landlord can start from.
|
||||
*
|
||||
* @return array<string, array{label: string, templates: array<string, string>}>
|
||||
*/
|
||||
public function presets(): array
|
||||
{
|
||||
$presets = [];
|
||||
foreach (app(ProcessCatalogue::class)->models() as $key => $candidate) {
|
||||
if ($candidate::isLegacy() && in_array(IntakeKind::from($this->intake), $candidate::intakes(), true)) {
|
||||
$presets[$key] = ['label' => $candidate::label(), 'templates' => $candidate::presetTemplates()];
|
||||
}
|
||||
}
|
||||
|
||||
return $presets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chooses the template of an area. Switches of steps that drop out of the course are removed from the draft; the
|
||||
* consequences are listed by templateImpacts() before anything is saved.
|
||||
*/
|
||||
public function chooseTemplate(string $area, string $key): void
|
||||
{
|
||||
$model = $this->model();
|
||||
$option = app(ChannelProcessConfiguration::class)->templateOptions($this->record, $model, $this->capabilityDraft)[$area][$key] ?? null;
|
||||
if ($option === null || ! $option['admissible']) {
|
||||
return;
|
||||
}
|
||||
$this->acknowledge = false;
|
||||
$this->drafts[$this->intake]['templates'] = [...app(ChannelProcessConfiguration::class)->templatesOf($model, $this->draft()), $area => $key];
|
||||
$this->drafts[$this->intake]['templates'] = array_map(fn (string $reference): string => explode('@', $reference)[0], $this->drafts[$this->intake]['templates']);
|
||||
$modules = $model->modules($this->drafts[$this->intake]['variant'], $this->drafts[$this->intake]['templates']);
|
||||
$this->drafts[$this->intake]['steps'] = array_intersect_key($this->drafts[$this->intake]['steps'], array_flip($modules));
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves from a fixed archetype to the base process with the combination the archetype stands for. Switches and settings
|
||||
* stay as they are; what contradicts the templates shows as a conflict that has to be confirmed.
|
||||
*/
|
||||
public function applyPreset(string $archetype): void
|
||||
{
|
||||
$presets = $this->presets();
|
||||
$base = app(ProcessCatalogue::class)->model(ExternalBookingModel::key());
|
||||
if (! isset($presets[$archetype]) || ! in_array(IntakeKind::from($this->intake), $base::intakes(), true)) {
|
||||
return;
|
||||
}
|
||||
$this->acknowledge = false;
|
||||
$this->drafts[$this->intake]['model'] = $base::key();
|
||||
$this->drafts[$this->intake]['variant'] = 'standard';
|
||||
$this->drafts[$this->intake]['templates'] = $presets[$archetype]['templates'];
|
||||
$this->drafts[$this->intake]['steps'] = array_intersect_key($this->drafts[$this->intake]['steps'], array_flip($base->modules('standard', $presets[$archetype]['templates'])));
|
||||
}
|
||||
|
||||
/**
|
||||
* What the draft's change of templates means (modules, responsibilities, stored switches and settings).
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function templateImpacts(): array
|
||||
{
|
||||
return app(ConfigurationImpact::class)->ofTemplates($this->record, IntakeKind::from($this->intake), $this->draft());
|
||||
}
|
||||
|
||||
public function chooseModel(string $model): void
|
||||
@@ -149,9 +270,13 @@ public function chooseModel(string $model): void
|
||||
return;
|
||||
}
|
||||
$this->acknowledge = false;
|
||||
// Leaving an archetype for a model with slots keeps its combination as the starting point of the templates.
|
||||
$previous = app(ProcessCatalogue::class)->model($this->drafts[$this->intake]['model']);
|
||||
$this->drafts[$this->intake]['model'] = $model;
|
||||
$this->drafts[$this->intake]['variant'] = 'standard';
|
||||
$this->drafts[$this->intake]['steps'] = [];
|
||||
$this->drafts[$this->intake]['templates'] = $this->model()->slots() === [] ? [] : $previous::presetTemplates();
|
||||
// Switches of steps the new course still has stay; only those that have no counterpart there drop out.
|
||||
$this->drafts[$this->intake]['steps'] = array_intersect_key($this->drafts[$this->intake]['steps'], array_flip($this->model()->modules('standard', $this->drafts[$this->intake]['templates'])));
|
||||
}
|
||||
|
||||
public function model(): ProcessModel
|
||||
|
||||
@@ -67,7 +67,7 @@ public function mount(int|string $record): void
|
||||
if ($this->draft === []) {
|
||||
$current = app(ChannelProcessConfiguration::class)->current($this->record, IntakeKind::from($this->intake));
|
||||
$stored = (array) (($this->record->process_overrides ?? [])[$this->intake] ?? []);
|
||||
$this->draft = ['model' => $current['model'], 'variant' => $current['variant'], 'steps' => (array) ($stored['steps'] ?? []), 'settings' => []];
|
||||
$this->draft = ['model' => $current['model'], 'variant' => $current['variant'], 'steps' => (array) ($stored['steps'] ?? []), 'templates' => $current['templates'], 'settings' => []];
|
||||
}
|
||||
$this->scenario = (string) array_key_first($this->scenarios());
|
||||
$this->resetInputs();
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Models\Channel;
|
||||
use App\Process\Models\ExternalBookingModel;
|
||||
use App\Process\Models\ProcessModel;
|
||||
use App\Process\Models\Responsibilities;
|
||||
use App\Process\Templates\FunctionTemplate;
|
||||
@@ -181,6 +182,24 @@ public function templateOptions(Channel $channel, ProcessModel $model, ?array $c
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* The templates in force for new cases of the channel and intake kind (key@version per area): the saved choice of a
|
||||
* model with slots, otherwise the combination a legacy archetype reproduces (empty when there is none).
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function currentTemplates(Channel $channel, IntakeKind $intake): array
|
||||
{
|
||||
$current = $this->current($channel, $intake);
|
||||
$model = $this->catalogue->model($current['model']);
|
||||
|
||||
if ($model->slots() !== []) {
|
||||
return $this->composer->resolve($model, $current['templates']);
|
||||
}
|
||||
|
||||
return $model::presetTemplates() === [] ? [] : $this->composer->resolve($this->catalogue->model(ExternalBookingModel::key()), $model::presetTemplates());
|
||||
}
|
||||
|
||||
/**
|
||||
* The templates a draft uses for the model slots (chosen ones, otherwise the model defaults) as key@version.
|
||||
*
|
||||
@@ -239,6 +258,14 @@ public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey
|
||||
'text' => $setting->question().' Bisher eingestellt: „'.$setting->describe($value).'“. Das Modell „'.$modelKey.'“ erlaubt: „'.$allowed.'“.'];
|
||||
}
|
||||
|
||||
// A model with slots does not narrow the guest communication itself: the portal's capability does.
|
||||
$messages = $model->slots() === [] ? null : (app(ChannelCapabilities::class)->resolve($channel)[ChannelCapabilities::MESSAGES_GUEST] ?? null);
|
||||
$storedMessages = ProcessSetting::GuestMessages->normalize($stored[ProcessSetting::GuestMessages->value] ?? null);
|
||||
if ($messages !== null && $messages->isKnown() && $messages->value === false && $storedMessages === Responsibility::Portal->value) {
|
||||
$conflicts[] = ['setting' => ProcessSetting::GuestMessages, 'stored' => ProcessSetting::GuestMessages->describe($storedMessages), 'fixed' => ProcessSetting::GuestMessages->describe(Responsibility::Landlord->value),
|
||||
'text' => ProcessSetting::GuestMessages->question().' Bisher eingestellt: „'.ProcessSetting::GuestMessages->describe($storedMessages).'“. Laut Fähigkeit des Portals schreibt es den Gast aber nicht an; künftig: „'.ProcessSetting::GuestMessages->describe(Responsibility::Landlord->value).'“.'];
|
||||
}
|
||||
|
||||
return $conflicts;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Models\Channel;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Templates\TemplateComposer;
|
||||
|
||||
/**
|
||||
* Rule-based comparison of a configuration draft (docs/Prozessarchitektur/MODUL_KONFIGURATIONSMATRIX.md §5): for every
|
||||
@@ -15,7 +16,7 @@
|
||||
*/
|
||||
final class ConfigurationImpact
|
||||
{
|
||||
public function __construct(private ProcessCatalogue $catalogue, private ChannelProcessConfiguration $configuration) {}
|
||||
public function __construct(private ProcessCatalogue $catalogue, private ChannelProcessConfiguration $configuration, private TemplateComposer $composer) {}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $draft
|
||||
@@ -61,6 +62,63 @@ public function of(Channel $channel, IntakeKind $intake, array $draft): array
|
||||
return $impacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* What a change of function templates means (docs/Prozessarchitektur/SCHABLONEN.md): per changed area the modules that
|
||||
* drop out, join or stay, the responsibility that changes, the stored switches and settings that no longer apply and
|
||||
* what the new template still needs or does not build yet. Compared with the templates in force for new cases. Pure:
|
||||
* nothing is changed, nothing is dropped silently – the landlord sees every consequence before saving.
|
||||
*
|
||||
* @param array<string, mixed> $draft
|
||||
* @return list<array{area: string, from: ?string, to: string, removed: list<string>, added: list<string>, kept: list<string>, responsibility: ?array{from: string, to: string}, switches_lost: list<string>, settings_replaced: list<string>, needs: list<string>, extensions: list<string>}>
|
||||
*/
|
||||
public function ofTemplates(Channel $channel, IntakeKind $intake, array $draft): array
|
||||
{
|
||||
$model = $this->catalogue->model((string) ($draft['model'] ?? ''));
|
||||
if ($model->slots() === []) {
|
||||
return [];
|
||||
}
|
||||
$current = $this->configuration->currentTemplates($channel, $intake);
|
||||
$target = $this->composer->resolve($model, (array) ($draft['templates'] ?? []));
|
||||
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
|
||||
$labelOf = fn (string $module): string => ($this->catalogue->hasModule($module) ? $this->catalogue->modules()[$module]::definition()->label : $module);
|
||||
$impacts = [];
|
||||
|
||||
foreach ($model->slots() as $area) {
|
||||
$from = $current[$area->value] ?? null;
|
||||
$to = $target[$area->value] ?? null;
|
||||
$toClass = $to === null ? null : $this->catalogue->templateClass($to);
|
||||
if ($toClass === null || $from === $to) {
|
||||
continue;
|
||||
}
|
||||
$fromClass = $from === null ? null : $this->catalogue->templateClass($from);
|
||||
$before = $fromClass === null ? [] : $fromClass::modules();
|
||||
$after = $toClass::modules();
|
||||
$removed = array_values(array_diff($before, $after));
|
||||
$setting = $area->setting();
|
||||
$storedValue = $setting->normalize($stored[$setting->value] ?? null);
|
||||
|
||||
$impacts[] = [
|
||||
'area' => $area->label(),
|
||||
'from' => $fromClass === null ? null : $fromClass::label(),
|
||||
'to' => $toClass::label(),
|
||||
'removed' => array_map($labelOf, $removed),
|
||||
'added' => array_map($labelOf, array_values(array_diff($after, $before))),
|
||||
'kept' => array_map($labelOf, array_values(array_intersect($after, $before))),
|
||||
'responsibility' => $fromClass !== null && $fromClass::responsibility() !== $toClass::responsibility()
|
||||
? ['from' => $setting->describe($fromClass::responsibility()->value), 'to' => $setting->describe($toClass::responsibility()->value)]
|
||||
: null,
|
||||
'switches_lost' => array_map($labelOf, array_values(array_filter($removed, fn (string $module): bool => ($stored['steps'][$module]['on'] ?? true) === false))),
|
||||
'settings_replaced' => $storedValue !== null && (string) $storedValue !== $toClass::responsibility()->value
|
||||
? [$setting->question().' Bisher gespeichert: „'.$setting->describe($storedValue).'“, künftig durch die Schablone: „'.$setting->describe($toClass::responsibility()->value).'“. Der gespeicherte Wert muss beim Speichern ausdrücklich entfernt werden.']
|
||||
: [],
|
||||
'needs' => array_map(fn (string $result): string => 'Voraussetzung: '.$result, $toClass::requires()),
|
||||
'extensions' => $toClass::extensions(),
|
||||
];
|
||||
}
|
||||
|
||||
return $impacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* The results that stay necessary although the step is off: what the steps depending on it still need.
|
||||
*
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\Tenant;
|
||||
use App\Process\Capability;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use App\Process\ProcessPlan;
|
||||
use App\Process\ProcessProfile;
|
||||
@@ -37,6 +39,9 @@ final class ProcessSandboxDriver
|
||||
|
||||
private int $ledgerSeen = 0;
|
||||
|
||||
/** @var list<string> labels of the activities that were done after the previous event */
|
||||
private array $doneBefore = [];
|
||||
|
||||
/** @var list<Email> every mail of the run (simulated: the only mailer is `array`) */
|
||||
private array $sent = [];
|
||||
|
||||
@@ -98,7 +103,7 @@ public function run(array $input): array
|
||||
|
||||
return [
|
||||
'scenario' => ['key' => $scenario::key(), 'label' => $scenario::label(), 'inputs' => $context->inputs, 'available_events' => count($scenario->events($context->inputs))],
|
||||
'plan' => $booking === null ? null : $this->plan($booking),
|
||||
'plan' => $booking === null ? null : $this->plan($booking, $channel),
|
||||
'timeline' => $timeline,
|
||||
'result' => $booking === null ? null : ['status' => $booking->status->getLabel(), 'situation' => CaseActivities::situation($booking), 'next' => CaseActivities::next($booking)?->label],
|
||||
'violations' => EffectLedger::violations(),
|
||||
@@ -122,7 +127,7 @@ private function assertSandbox(): void
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function plan(Booking $booking): array
|
||||
private function plan(Booking $booking, Channel $channel): array
|
||||
{
|
||||
$plan = ProcessPlan::of($booking);
|
||||
$profile = $booking->process();
|
||||
@@ -134,10 +139,49 @@ private function plan(Booking $booking): array
|
||||
'variant' => $plan->variant,
|
||||
'modules' => $plan->modules,
|
||||
'case_type' => strtoupper($profile->caseType->value),
|
||||
'templates' => $this->templates($plan, $channel),
|
||||
'configuration' => collect(ProcessSetting::cases())->map(fn ($setting): array => ['question' => $setting->question(), 'value' => $setting->describe($profile->value($setting)), 'source' => ProcessProfile::sourceLabel($profile->source($setting))])->all(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The function templates the case follows: what each stands for, its modules and the portal capabilities it relies on
|
||||
* with their origin – a capability that is only suggested or derived is shown as not confirmed, never as proven.
|
||||
*
|
||||
* @return list<array{area: string, label: string, reference: string, responsibility: string, modules: list<string>, capabilities: list<array{label: string, required: string, source: string, confirmed: bool}>}>
|
||||
*/
|
||||
private function templates(ProcessPlan $plan, Channel $channel): array
|
||||
{
|
||||
$catalogue = app(ProcessCatalogue::class);
|
||||
$capabilities = app(ChannelCapabilities::class)->resolve($channel);
|
||||
$rows = [];
|
||||
foreach ($plan->templates as $area => $reference) {
|
||||
$class = $catalogue->templateClass($reference);
|
||||
if ($class === null) {
|
||||
continue;
|
||||
}
|
||||
$rows[] = [
|
||||
'area' => $class::area()->label(),
|
||||
'label' => $class::label(),
|
||||
'reference' => $reference,
|
||||
'responsibility' => $class::responsibility()->getLabel(),
|
||||
'modules' => array_values(array_map(fn (string $module): string => $plan->labels[$module] ?? $module, $class::modules())),
|
||||
'capabilities' => array_values(array_map(function (string $key, bool $required) use ($capabilities): array {
|
||||
$capability = $capabilities[$key] ?? null;
|
||||
|
||||
return [
|
||||
'label' => ChannelCapabilities::definitions()[$key]['question'],
|
||||
'required' => $required ? 'ja' : 'nein',
|
||||
'source' => $capability?->sourceLabel() ?? 'noch nicht bekannt',
|
||||
'confirmed' => $capability?->source === Capability::CONFIRMED,
|
||||
];
|
||||
}, array_keys($class::capabilityRequirements()), $class::capabilityRequirements())),
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* The case after one event: its course, the skipped steps, the simulated mails and effects.
|
||||
*
|
||||
@@ -172,9 +216,18 @@ private function capture(SandboxContext $context): array
|
||||
}
|
||||
}
|
||||
|
||||
$activities = CaseActivities::for($booking);
|
||||
$waiting = array_values(array_map(fn ($activity): string => $activity->label, array_filter($activities, fn ($activity): bool => $activity->state->value === 'waiting')));
|
||||
$done = array_values(array_map(fn ($activity): string => $activity->label, array_filter($activities, fn ($activity): bool => in_array($activity->state->value, ['done', 'external'], true))));
|
||||
// Steps that came to an end in this event while others wait: they do not hold each other up.
|
||||
$independent = $waiting === [] ? [] : array_values(array_diff($done, $this->doneBefore));
|
||||
$this->doneBefore = $done;
|
||||
|
||||
return [
|
||||
'status' => $booking->status->getLabel(),
|
||||
'situation' => CaseActivities::situation($booking),
|
||||
'waiting' => $waiting,
|
||||
'independent' => $independent,
|
||||
'activities' => array_map(fn ($activity): array => ['label' => $activity->label, 'state' => $activity->state->getLabel(), 'state_key' => $activity->state->value, 'detail' => $activity->detail], CaseActivities::for($booking)),
|
||||
'skipped' => $skipped,
|
||||
'calendar' => ['occupying' => Booking::query()->occupying()->whereKey($booking->id)->exists(), 'hold_until' => $booking->isHoldActive() ? $booking->hold_expires_at->format('d.m.Y H:i') : null],
|
||||
|
||||
Reference in new issue
Block a user