CaseActivities/CaseAutomation sind Fassaden über ProcessRunner. Verhaltensvergleich v0.11: 11 Abläufe und 198 Konstellationen gleich, beabsichtigte Abweichungen I-004/I-005 (F-001/F-002). Volle Suite vor U-B: 785/785. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 lines
1.8 KiB
PHP
54 lines
1.8 KiB
PHP
<?php
|
||
|
||
namespace App\Process\Modules\Stay;
|
||
|
||
use App\Enums\ActivityState;
|
||
use App\Enums\InternalKind;
|
||
use App\Process\Activity;
|
||
use App\Process\CaseContext;
|
||
use App\Process\Modules\Module;
|
||
use App\Process\Modules\ModuleDefinition;
|
||
|
||
/**
|
||
* P04: the stay itself (or the time of an internal occupation).
|
||
*/
|
||
final class Stay extends Module
|
||
{
|
||
public static function key(): string
|
||
{
|
||
return 'stay';
|
||
}
|
||
|
||
public static function definition(): ModuleDefinition
|
||
{
|
||
return new ModuleDefinition(
|
||
label: 'Aufenthalt',
|
||
purpose: 'Der Aufenthalt vom Anreise- bis zum Abreisetag.',
|
||
phase: 'P04',
|
||
waits: ['time'],
|
||
triggers: ['schedule:daily'],
|
||
performers: ['guest', 'landlord'],
|
||
events: ['task', 'services', 'status'],
|
||
);
|
||
}
|
||
|
||
public function activities(CaseContext $case): array
|
||
{
|
||
$booking = $case->booking;
|
||
if ($booking->isInternal()) {
|
||
$kind = $booking->internal_kind;
|
||
|
||
return [new Activity('stay', $kind === InternalKind::Block ? 'Sperrzeit' : 'Aufenthalt', $case->closed ? ActivityState::NotApplicable : ($booking->departure <= $case->today ? ActivityState::Done : ActivityState::Later), $booking->arrival->format('d.m.Y').' – '.$booking->departure->format('d.m.Y'))];
|
||
}
|
||
|
||
$arrived = $case->binding && $booking->arrival <= $case->today;
|
||
$left = $case->binding && $booking->departure <= $case->today;
|
||
|
||
return [new Activity('stay', 'Aufenthalt', $case->later(match (true) {
|
||
$left => ActivityState::Done,
|
||
$arrived => ActivityState::Waiting,
|
||
default => ActivityState::Later,
|
||
}), $booking->arrival->format('d.m.Y').' – '.$booking->departure->format('d.m.Y'))];
|
||
}
|
||
}
|