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>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-04 14:49:44 +01:00
1 parent 98df5e9e3b
commit 7e22e12cac
80 files changed
+4628 -445

No files matched your search

@@ -0,0 +1,49 @@
<?php
namespace App\Process\Modules\Intake;
use App\Availability\AvailabilityChecker;
use App\Process\CaseContext;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
use App\Process\Modules\StepState;
/**
* P01/P02: the dates are free (calendar truth of AvailabilityChecker, fresh imports by CalendarClearance). Mandatory
* and never switched off; the offer depends on it hard.
*/
final class AvailabilityCheck extends Module
{
public static function key(): string
{
return 'availability.check';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Verfügbarkeit',
purpose: 'Prüft, ob der Zeitraum frei ist und die Kalender der Portale aktuell sind.',
phase: 'P01',
effects: ['network'],
triggers: ['intake', 'facts.applied'],
);
}
public function applies(CaseContext $case): bool
{
return $case->inquiry && ! $case->binding;
}
public function activities(CaseContext $case): array
{
return [];
}
public function state(CaseContext $case): ?StepState
{
$booking = $case->booking;
return app(AvailabilityChecker::class)->isAvailable($booking->property, $booking->arrival, $booking->departure, ignore: $booking) ? StepState::Done : StepState::Problem;
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Process\Modules\Intake;
use App\Enums\ActivityState;
use App\Enums\ChannelTaskStatus;
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
use App\Models\ChannelTask;
use App\Process\Activity;
use App\Process\CaseContext;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
use App\Process\Modules\StepState;
/**
* Blocking and releasing the dates in portals that need it by hand (requires_manual_blocking): the tasks come from the
* observers (CreateChannelTasks) and are proven per portal (ChannelTaskProof). Mandatory, never switched off.
*/
final class ChannelBlocks extends Module
{
public static function key(): string
{
return 'channels.block';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Andere Kanäle sperren',
purpose: 'Sperrt den Zeitraum in Portalen, die nicht automatisch abgleichen, und gibt ihn bei Ende wieder frei – mit Nachweis je Portal.',
phase: 'P02',
effects: ['channel_task', 'landlord_mail', 'network'],
waits: ['landlord', 'portal'],
triggers: ['booking.occupies', 'booking.released'],
performers: ['landlord', 'system'],
);
}
public function activities(CaseContext $case): array
{
$booking = $case->booking;
return ChannelTask::query()
->with('channel')
->whereHas('channel', fn ($query) => $query->where('property_id', $booking->property_id))
->whereDate('starts_on', $booking->arrival)
->whereDate('ends_on', $booking->departure)
->where('status', '!=', ChannelTaskStatus::Dismissed)
->orderBy('id')
->get()
->map(fn (ChannelTask $task): Activity => new Activity('channel_block', ($task->action->value === 'block' ? 'In ' : 'Freigeben in ').$task->channel?->name.($task->action->value === 'block' ? ' sperren' : ''), $task->status === ChannelTaskStatus::Open ? ActivityState::Open : ActivityState::Done, $task->period().' · '.$task->proofLabel(), url: ChannelTaskResource::getUrl()))
->all();
}
/** Listed on its own in the work list; it never holds another step back. */
public function state(CaseContext $case): ?StepState
{
return null;
}
}
@@ -0,0 +1,95 @@
<?php
namespace App\Process\Modules\Intake;
use App\Actions\RequestCaseData;
use App\Enums\ActivityState;
use App\Enums\ProcessSetting;
use App\Models\DataRequest;
use App\Process\Activity;
use App\Process\CaseContext;
use App\Process\CaseRequirements;
use App\Process\Modules\Dependency;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
use App\Process\Modules\RunsAutomatically;
use App\Process\Modules\StepState;
use App\Process\StepResult;
/**
* P01: asks the guest for missing details by link and reminds (v0.11). It runs in its own mode (automatic / after
* release / by hand) whatever the case's processing is, and independently of the other steps: a clarification hold
* keeps its deadline while the request waits for the guest.
*/
final class GuestDataRequest extends Module implements RunsAutomatically
{
public static function key(): string
{
return 'guest.data_request';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Fehlende Angaben beim Gast anfragen',
purpose: 'Fragt fehlende Pflichtangaben per Link beim Gast an, erinnert und übergibt an Sie, wenn der Gast nicht antwortet.',
phase: 'P01',
requires: [Dependency::hard('intake.record')],
effects: ['case_write', 'guest_mail'],
waits: ['guest', 'landlord', 'time'],
triggers: ['request.created', 'booking.taken_over', 'wish'],
parameters: [ProcessSetting::DataRequest, ProcessSetting::DataRequestRemindersMax, ProcessSetting::DataRequestFollowupsMax, ProcessSetting::DataRequestReminderHours, ProcessSetting::GuestLinkValidDays],
toggle: ModuleDefinition::TOGGLE_OPTIONAL,
performers: ['system', 'landlord'],
modes: ['automatic', 'approval', 'manual'],
events: ['data_request', 'mail_in', 'facts', 'fact'],
);
}
/**
* Shown as a step of its own only for a binding booking (a request shows it inside the guest's details).
*/
public function activities(CaseContext $case): array
{
$request = $case->binding ? $case->booking->openDataRequest() : null;
if ($request === null) {
return [];
}
return [new Activity('data_request', 'Fehlende Angaben beim Gast anfragen', $case->later($request->status === DataRequest::OPEN ? ActivityState::Waiting : ActivityState::Open),
implode(', ', CaseRequirements::labels($request->fields)).' · '.$request->statusLabel(), $request->status === DataRequest::OPEN ? null : 'approveDataRequest')];
}
public function state(CaseContext $case): ?StepState
{
$request = $case->booking->openDataRequest();
return match (true) {
$request === null => RequestCaseData::needs($case->booking) === null ? StepState::Done : StepState::Open,
$request->status === DataRequest::OPEN => StepState::Waiting,
default => StepState::Open,
};
}
public function due(CaseContext $case): bool
{
return RequestCaseData::needs($case->booking) !== null && $case->booking->openDataRequest() === null;
}
public function blockers(CaseContext $case): array
{
return CaseRequirements::isValid('guest.email', $case->booking->guest?->email) ? [] : ['Die E-Mail-Adresse des Gastes fehlt.'];
}
public function run(CaseContext $case): StepResult
{
$request = app(RequestCaseData::class)->forNextStep($case->booking);
return $request === null ? StepResult::blocked(['Nichts anzufragen.']) : StepResult::ran();
}
public function isOutward(): bool
{
return false;
}
}
@@ -0,0 +1,84 @@
<?php
namespace App\Process\Modules\Intake;
use App\Enums\ActivityState;
use App\Enums\ProcessSetting;
use App\Enums\Responsibility;
use App\Models\DataRequest;
use App\Process\Activity;
use App\Process\CaseContext;
use App\Process\CaseRequirements;
use App\Process\Modules\Dependency;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
/**
* P01: who the guest is and whether every detail the next step needs is there and valid (v0.11 G2a). The details
* themselves come in through the common fact intake (ContributeCaseFacts) from every source.
*/
final class GuestDetails extends Module
{
public static function key(): string
{
return 'guest.details';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Angaben des Gastes',
purpose: 'Identifiziert den Gast, führt seine Angaben aus allen Quellen zusammen und prüft, ob alles für den nächsten Schritt da ist.',
phase: 'P01',
requires: [Dependency::hard('intake.record')],
effects: ['case_write'],
waits: ['guest', 'landlord'],
triggers: ['facts.applied'],
parameters: [ProcessSetting::FormRequiresAddress],
performers: ['guest', 'landlord'],
events: ['facts', 'fact', 'guest', 'data_request', 'mail_in'],
);
}
/** We correspond with the guest ourselves (a request, or our documents, messages or payments). */
public function applies(CaseContext $case): bool
{
$profile = $case->profile;
return $case->inquiry || $profile->documents() === Responsibility::Landlord || $profile->guestMessages() === Responsibility::Landlord || $profile->payments() === Responsibility::Landlord;
}
public function activities(CaseContext $case): array
{
$booking = $case->booking;
$profile = $case->profile;
$hasEmail = filled($booking->guest?->email);
// v0.11 (G2a): before the own binding offer – or the binding confirmation of a wish – every required detail.
$action = $profile->preReservation() || $booking->offer_version > 0 ? CaseRequirements::OFFER : CaseRequirements::WISH_CONFIRMATION;
$needsDetails = $case->inquiry && ! $case->binding && $booking->offer_version === 0 && ($action === CaseRequirements::OFFER || $booking->wish_at !== null);
$missing = $hasEmail && $needsDetails ? CaseRequirements::missing($booking, $action) : [];
$request = $booking->openDataRequest();
$asked = $booking->contact_requested_at !== null || $request?->status === DataRequest::OPEN;
$state = match (true) {
$hasEmail && $missing === [] => ActivityState::Done,
$asked => ActivityState::Waiting,
default => ActivityState::Open,
};
$title = match (true) {
$booking->guest === null => 'Name und Kontaktdaten des Gastes eintragen',
! $hasEmail => 'E-Mail-Adresse des Gastes eintragen',
$missing !== [] => $action === CaseRequirements::OFFER ? 'Angaben für das Angebot vervollständigen' : 'Angaben für die Bestätigung vervollständigen',
default => 'Kontaktdaten des Gastes',
};
$detail = match (true) {
$state === ActivityState::Done => $booking->guestName(),
$missing !== [] => 'fehlt: '.implode(', ', CaseRequirements::labels($missing)).($request !== null ? ' · '.$request->statusLabel() : ($asked ? ' · beim Gast angefragt' : '')),
$booking->contact_requested_at !== null => 'beim Gast erfragt am '.$booking->contact_requested_at->format('d.m.Y'),
default => 'fehlt noch',
};
// A prepared data request waits for the landlord's release: that is the next step, otherwise entering the details.
$draft = $needsDetails && $request?->status === DataRequest::DRAFT;
return [new Activity('contact', $title, $case->later($draft ? ActivityState::Open : $state), $detail, $state === ActivityState::Done ? null : ($draft ? 'approveDataRequest' : 'provideContact'))];
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
namespace App\Process\Modules\Intake;
use App\Enums\ProcessSetting;
use App\Models\Booking;
use App\Process\CaseContext;
use App\Process\Modules\Dependency;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
use App\Process\Modules\StepState;
/**
* P01/P02: the hold of a request – clarification hold of an incomplete request or offer hold – and its deadline. It is
* set by the intake (RequestHold under the calendar lock) and by SendOffer, it ends by ExpireReservations or the
* release; this step only watches it. It depends on the intake alone, never on the guest's details, so a request that
* waits for its address keeps its clarification hold running (requirement K1/T1).
*/
final class Hold extends Module
{
public static function key(): string
{
return 'hold';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Reservierung des Zeitraums',
purpose: 'Hält den Zeitraum während der Klärung bzw. der Angebotsfrist frei und gibt ihn nach Ablauf wieder frei.',
phase: 'P01',
requires: [Dependency::hard('intake.record')],
effects: ['calendar_hold'],
waits: ['time'],
triggers: ['intake', 'offer.sent', 'schedule:bookings:expire-holds'],
parameters: [ProcessSetting::PreReservation, ProcessSetting::HoldHours, ProcessSetting::ClarificationHoldAutoMinutes, ProcessSetting::ClarificationHoldManualMinutes],
toggle: ModuleDefinition::TOGGLE_CONDITIONAL,
events: ['hold'],
);
}
public function applies(CaseContext $case): bool
{
return $case->inquiry && $case->profile->preReservation();
}
/** The hold has no line of its own: the offer step and the situation show it. */
public function activities(CaseContext $case): array
{
return [];
}
public function state(CaseContext $case): ?StepState
{
$booking = $case->booking;
return match (true) {
$booking->isHoldActive() => StepState::Waiting,
$booking->hold_expires_at === null && $booking->hold_purpose === Booking::HOLD_CLARIFICATION => StepState::NotApplicable,
default => StepState::Done,
};
}
}
@@ -0,0 +1,43 @@
<?php
namespace App\Process\Modules\Intake;
use App\Enums\ActivityState;
use App\Process\Activity;
use App\Process\CaseContext;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
/**
* P01: the case came in – request, portal booking or internal occasion. Recording it (and the hold of a request,
* under the calendar lock) is done by the intake actions; the step only shows it.
*/
final class IntakeRecord extends Module
{
public static function key(): string
{
return 'intake.record';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Eingang',
purpose: 'Hält den Eingang der Anfrage, Buchung oder Eigenbelegung fest und friert den Ablauf ein.',
phase: 'P01',
effects: ['case_write', 'calendar_hold'],
triggers: ['intake'],
events: ['created', 'intake', 'profile', 'hold', 'mode'],
);
}
public function activities(CaseContext $case): array
{
$booking = $case->booking;
if ($booking->isInternal()) {
return [new Activity('intake', ($booking->internal_kind?->getLabel() ?? 'Eigene Belegung').' eingetragen', ActivityState::Done, $booking->occasion)];
}
return [new Activity('intake', $case->inquiry ? 'Anfrage eingegangen' : 'Buchung beim Portal eingegangen', ActivityState::Done, $booking->created_at?->format('d.m.Y').' · '.$booking->bookingChannelLabel())];
}
}
@@ -0,0 +1,54 @@
<?php
namespace App\Process\Modules\Intake;
use App\Enums\ActivityState;
use App\Process\Activity;
use App\Process\CaseContext;
use App\Process\Modules\Dependency;
use App\Process\Modules\Module;
use App\Process\Modules\ModuleDefinition;
use App\Support\Money;
/**
* P02 for A3–A5: the booking is binding at the portal (E-036) – no second acceptance, no own price. The guest's total
* comes "laut Portal" (RecordPortalAmounts) and is never recalculated.
*/
final class PortalBinding extends Module
{
public static function key(): string
{
return 'binding.portal';
}
public static function definition(): ModuleDefinition
{
return new ModuleDefinition(
label: 'Verbindlichkeit beim Portal',
purpose: 'Stellt fest, dass die Buchung beim Portal verbindlich ist, und übernimmt den Gesamtpreis laut Portal.',
phase: 'P02',
requires: [Dependency::hard('intake.record')],
effects: ['case_write'],
waits: ['portal', 'landlord'],
triggers: ['intake', 'portal.amounts'],
performers: ['portal', 'landlord'],
events: ['status', 'portal_signal', 'price', 'amount'],
readsContractData: true,
);
}
public function applies(CaseContext $case): bool
{
return ! $case->inquiry;
}
public function activities(CaseContext $case): array
{
$booking = $case->booking;
return [
new Activity('binding', 'Beim Portal fest gebucht', $case->binding || $case->closed ? ActivityState::External : ActivityState::Open, $booking->portal_reference ? 'Buchungsnummer '.$booking->portal_reference : null, $case->binding ? null : 'confirm'),
new Activity('price', 'Gesamtpreis laut Portal eintragen', $case->later($booking->total === null ? ActivityState::Open : ActivityState::Done), $booking->total === null ? 'noch nicht bekannt' : Money::format($booking->total), $booking->total === null ? 'portalPrice' : null),
];
}
}