Files
fewo-stommer/app/Process/CaseContext.php
T
LarsandClaude Opus 5.5 7e22e12cac U-A/U-B: Prozesskern mit Fachmodulen, versionierten Modellen, eingefrorenem Prozessplan, ProcessRunner (harte/weiche Abhängigkeiten), CasePricing, Loyalty nur im Tester
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>
2026-11-04 14:49:44 +01:00

64 lines
2.3 KiB
PHP
Raw 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;
use App\Enums\ActivityState;
use App\Enums\BookingStatus;
use App\Enums\IntakeKind;
use App\Models\Booking;
use Carbon\CarbonImmutable;
/**
* Everything a process module reads about one case at one moment: the case, its frozen profile and plan, the
* parameters of the module and the time. Built fresh for every evaluation – modules keep no state of their own; the
* state of a case stays in its data (bookings, case_facts, booking_tasks, data_requests, booking_events).
*/
final class CaseContext
{
public readonly ProcessProfile $profile;
public readonly bool $closed;
public readonly bool $binding;
public readonly bool $inquiry;
public readonly CarbonImmutable $today;
/** After the end of the case or of its stay: what was not done before is no longer to do. */
public readonly bool $over;
public function __construct(public readonly Booking $booking, public readonly ProcessPlan $plan)
{
$booking->loadMissing(['guest', 'property', 'payments']);
$this->profile = $booking->process();
$this->closed = in_array($booking->status, [BookingStatus::Cancelled, BookingStatus::Declined, BookingStatus::Expired], true);
$this->binding = $booking->isBinding();
$this->inquiry = $booking->intake !== IntakeKind::Booking;
$this->today = CarbonImmutable::today();
$this->over = $this->closed || $booking->status === BookingStatus::Completed || ($this->binding && $booking->departure->isBefore($this->today));
}
public static function of(Booking $booking): self
{
return new self($booking, ProcessPlan::of($booking));
}
/**
* The central rule of the case's end (package 9): after it, an open step is no longer to do – unless it is done
* (by us or externally). Modules apply it where the step belongs to the case's own course.
*/
public function later(ActivityState $state): ActivityState
{
return $this->over && ! in_array($state, [ActivityState::Done, ActivityState::External], true) ? ActivityState::NotApplicable : $state;
}
/**
* A parameter of a module as frozen in the plan (null when the plan does not set it).
*/
public function parameter(string $module, string $name): mixed
{
return $this->plan->parameter($module, $name);
}
}