Files
LarsandClaude Sonnet 5.5 8442d0a3d8 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>
2026-11-05 07:54:11 +01:00

67 lines
2.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Process\Modules\Settlement;
use App\Enums\ActivityState;
use App\Enums\BookingStatus;
use App\Enums\Execution;
use App\Enums\InternalKind;
use App\Models\BookingTask;
use App\Process\Activity;
use App\Process\CaseClosure;
use App\Process\CaseContext;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
/**
* P05 (package 9): closing the stay once nothing is open for it (CaseClosure, overnight or by hand).
*/
final class StayClosure extends Module
{
public static function key(): string
{
return 'case.closure';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Aufenthalt abschließen',
purpose: 'Schließt den Aufenthalt ab, sobald nach der Abreise nichts mehr für ihn offen ist.',
phase: 'P05',
executions: [Execution::Automatic, Execution::Manual],
condition: 'nach der Abreise',
why: 'Ein Aufenthalt wird immer abgeschlossen, damit nichts offen bleibt (E-010).',
effects: ['case_write'],
waits: ['time', 'landlord'],
triggers: ['schedule:daily'],
performers: ['system', 'landlord'],
events: ['task', 'status', 'settled'],
);
}
public function applies(CaseContext $case): bool
{
return ! $case->closed && ($case->booking->isBinding() || $case->booking->status === BookingStatus::Completed);
}
public function activities(CaseContext $case): array
{
$booking = $case->booking;
$today = $case->today;
$completed = $booking->status === BookingStatus::Completed;
$blockers = $booking->isBinding() && ! $completed ? CaseClosure::stayBlockers($booking) : collect();
return [new Activity('closure', $booking->isInternal() && $booking->internal_kind === InternalKind::Block ? 'Sperrzeit abschließen' : 'Aufenthalt abschließen', match (true) {
$completed => ActivityState::Done,
! $booking->isBinding() || $booking->departure > $today => ActivityState::Later,
default => ActivityState::Waiting,
}, match (true) {
$completed => 'abgeschlossen am '.($booking->completed_at ?? $booking->updated_at)?->format('d.m.Y'),
$blockers->isNotEmpty() => 'wartet auf: '.$blockers->map(fn (BookingTask $task): string => $task->label())->implode(', '),
$booking->isBinding() && $booking->departure <= $today => 'geschieht automatisch über Nacht – oder jetzt von Hand',
default => 'nach der Abreise, sobald nichts mehr für den Aufenthalt offen ist',
}, $booking->isBinding() && ! $completed && $booking->departure <= $today ? 'closeStay' : null)];
}
}