Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86965d6d45 | ||
|
|
3cbca35fcb | ||
|
|
664f00e510 | ||
|
|
4554af8056 | ||
|
|
f2b6626f6a | ||
|
|
b1b09a6db4 | ||
|
|
221ce8ca81 | ||
|
|
e40f8639b3 | ||
|
|
eba1a4d094 | ||
|
|
e1d0f6b023 | ||
|
|
6f14437855 | ||
|
|
c46f4a032b | ||
|
|
e95ba4f986 | ||
|
|
381720763c | ||
|
|
a3ab1b6657 |
No files matched your search
@@ -8,6 +8,7 @@
|
|||||||
use App\Documents\DocumentFinding;
|
use App\Documents\DocumentFinding;
|
||||||
use App\Enums\BookingStatus;
|
use App\Enums\BookingStatus;
|
||||||
use App\Enums\DocumentKind;
|
use App\Enums\DocumentKind;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\ProcessingMode;
|
use App\Enums\ProcessingMode;
|
||||||
use App\Exceptions\ReservationException;
|
use App\Exceptions\ReservationException;
|
||||||
use App\Models\Booking;
|
use App\Models\Booking;
|
||||||
@@ -49,14 +50,16 @@ public function blockers(Booking $booking): array
|
|||||||
{
|
{
|
||||||
$property = $booking->property;
|
$property = $booking->property;
|
||||||
$reasons = [];
|
$reasons = [];
|
||||||
$information = ! $booking->process()->preReservation();
|
$information = $booking->process()->inquiryAnswer() === InquiryAnswer::Information;
|
||||||
|
|
||||||
if ($information && ($booking->status !== BookingStatus::Reserved || $booking->information_version > 0)) {
|
if ($information && ($booking->status !== BookingStatus::Reserved || $booking->information_version > 0)) {
|
||||||
$reasons[] = 'Die Anfrage ist bereits beantwortet oder nicht mehr offen.';
|
$reasons[] = 'Die Anfrage ist bereits beantwortet oder nicht mehr offen.';
|
||||||
}
|
}
|
||||||
// A request after its clarification hold (v0.11) only needs free dates, which are checked below.
|
// A request after its clarification hold (v0.11) only needs free dates, which are checked below.
|
||||||
$clarified = $booking->hold_purpose === Booking::HOLD_CLARIFICATION;
|
$clarified = $booking->hold_purpose === Booking::HOLD_CLARIFICATION;
|
||||||
if (! $information && ($booking->status !== BookingStatus::Reserved || (! $clarified && ! $booking->isHoldActive()))) {
|
// Without a reservation at the request (offer without early hold) the offer itself creates the hold; availability is checked below.
|
||||||
|
$holdRequired = $booking->process()->preReservation();
|
||||||
|
if (! $information && ($booking->status !== BookingStatus::Reserved || ($holdRequired && ! $clarified && ! $booking->isHoldActive()))) {
|
||||||
$reasons[] = 'Die Anfrage ist nicht mehr vorgemerkt (Frist abgelaufen oder bereits bearbeitet).';
|
$reasons[] = 'Die Anfrage ist nicht mehr vorgemerkt (Frist abgelaufen oder bereits bearbeitet).';
|
||||||
}
|
}
|
||||||
if (blank($booking->guest?->email)) {
|
if (blank($booking->guest?->email)) {
|
||||||
@@ -87,7 +90,7 @@ public function handle(Booking $booking): array
|
|||||||
{
|
{
|
||||||
$booking->loadMissing(['property', 'guest']);
|
$booking->loadMissing(['property', 'guest']);
|
||||||
|
|
||||||
if ($booking->process()->preReservation()) {
|
if ($booking->process()->inquiryAnswer() === InquiryAnswer::Offer) {
|
||||||
$this->clearance->refresh($booking->property);
|
$this->clearance->refresh($booking->property);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +100,7 @@ public function handle(Booking $booking): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (! $booking->process()->preReservation()) {
|
if ($booking->process()->inquiryAnswer() === InquiryAnswer::Information) {
|
||||||
$this->sendInformation->handle($booking->fresh(), ['expected_version' => 0, 'acknowledged' => true]);
|
$this->sendInformation->handle($booking->fresh(), ['expected_version' => 0, 'acknowledged' => true]);
|
||||||
} else {
|
} else {
|
||||||
$this->sendOffer->handle($booking->fresh(), ['expected_version' => 0]);
|
$this->sendOffer->handle($booking->fresh(), ['expected_version' => 0]);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
use App\Models\Channel;
|
use App\Models\Channel;
|
||||||
use App\Process\ChannelCapabilities;
|
use App\Process\ChannelCapabilities;
|
||||||
use App\Process\ChannelProcessConfiguration;
|
use App\Process\ChannelProcessConfiguration;
|
||||||
|
use App\Process\ProcessCatalogue;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
@@ -23,10 +24,10 @@ class ConfigureChannelProcess
|
|||||||
{
|
{
|
||||||
public const HISTORY_LIMIT = 20;
|
public const HISTORY_LIMIT = 20;
|
||||||
|
|
||||||
public function __construct(private ChannelProcessConfiguration $configuration, private ChannelCapabilities $capabilities) {}
|
public function __construct(private ChannelProcessConfiguration $configuration, private ChannelCapabilities $capabilities, private ProcessCatalogue $catalogue) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array{model: string, variant?: string, steps?: array<string, array{on?: bool}>, settings?: array<string, mixed>, capabilities?: array<string, bool|string|null>} $draft
|
* @param array{model: string, variant?: string, steps?: array<string, array{on?: bool}>, settings?: array<string, mixed>, templates?: array<string, string>, capabilities?: array<string, bool|string|null>} $draft
|
||||||
* @param bool $acknowledgeConflicts the landlord confirmed that stored settings the model overrides are removed
|
* @param bool $acknowledgeConflicts the landlord confirmed that stored settings the model overrides are removed
|
||||||
*
|
*
|
||||||
* @throws ValidationException
|
* @throws ValidationException
|
||||||
@@ -38,7 +39,7 @@ public function handle(Channel $channel, IntakeKind $intake, array $draft, ?stri
|
|||||||
throw ValidationException::withMessages(['process' => $problems]);
|
throw ValidationException::withMessages(['process' => $problems]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$conflicts = $this->configuration->conflicts($channel, $intake, (string) $draft['model']);
|
$conflicts = $this->configuration->conflicts($channel, $intake, (string) $draft['model'], (array) ($draft['templates'] ?? []));
|
||||||
if ($conflicts !== [] && ! $acknowledgeConflicts) {
|
if ($conflicts !== [] && ! $acknowledgeConflicts) {
|
||||||
throw ValidationException::withMessages(['process' => [
|
throw ValidationException::withMessages(['process' => [
|
||||||
'Bisherige Einstellungen widersprechen dem gewählten Modell und würden still überstimmt. Bitte ausdrücklich bestätigen, dass sie entfernt werden:',
|
'Bisherige Einstellungen widersprechen dem gewählten Modell und würden still überstimmt. Bitte ausdrücklich bestätigen, dass sie entfernt werden:',
|
||||||
@@ -71,11 +72,19 @@ public function handle(Channel $channel, IntakeKind $intake, array $draft, ?stri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A model with slots always stores its explicit template choice (keys; the version is frozen with each new case).
|
||||||
|
$model = $this->catalogue->model((string) $draft['model']);
|
||||||
|
$templates = array_map(fn (string $reference): string => explode('@', $reference)[0], $this->configuration->templatesOf($model, $draft));
|
||||||
|
if ($model->slots() === []) {
|
||||||
|
$templates = [];
|
||||||
|
}
|
||||||
|
|
||||||
$overrides[$intake->value] = [
|
$overrides[$intake->value] = [
|
||||||
...$settings,
|
...$settings,
|
||||||
'model' => $draft['model'],
|
'model' => $draft['model'],
|
||||||
'variant' => $draft['variant'] ?? 'standard',
|
'variant' => $draft['variant'] ?? 'standard',
|
||||||
'steps' => $steps,
|
'steps' => $steps,
|
||||||
|
'templates' => $templates,
|
||||||
'configured_at' => now()->toIso8601String(),
|
'configured_at' => now()->toIso8601String(),
|
||||||
'configured_by' => $by,
|
'configured_by' => $by,
|
||||||
];
|
];
|
||||||
@@ -88,7 +97,7 @@ public function handle(Channel $channel, IntakeKind $intake, array $draft, ?stri
|
|||||||
$changes = $confirmed['changes'];
|
$changes = $confirmed['changes'];
|
||||||
}
|
}
|
||||||
$channelSettings['process_history'] = array_slice([...(array) ($channelSettings['process_history'] ?? []), [
|
$channelSettings['process_history'] = array_slice([...(array) ($channelSettings['process_history'] ?? []), [
|
||||||
'at' => now()->toIso8601String(), 'by' => $by, 'intake' => $intake->value, 'model' => $draft['model'], 'variant' => $draft['variant'] ?? 'standard',
|
'at' => now()->toIso8601String(), 'by' => $by, 'intake' => $intake->value, 'model' => $draft['model'], 'variant' => $draft['variant'] ?? 'standard', 'templates' => $templates,
|
||||||
'capabilities' => $changes, 'removed_settings' => array_map(fn (array $conflict): string => $conflict['text'], $conflicts),
|
'capabilities' => $changes, 'removed_settings' => array_map(fn (array $conflict): string => $conflict['text'], $conflicts),
|
||||||
]], -self::HISTORY_LIMIT);
|
]], -self::HISTORY_LIMIT);
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
use App\Enums\DataRequestMode;
|
use App\Enums\DataRequestMode;
|
||||||
use App\Enums\DocumentKind;
|
use App\Enums\DocumentKind;
|
||||||
use App\Enums\FactSource;
|
use App\Enums\FactSource;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Mail\DataRequested;
|
use App\Mail\DataRequested;
|
||||||
use App\Models\Booking;
|
use App\Models\Booking;
|
||||||
@@ -70,7 +71,7 @@ public static function needs(Booking $booking): ?array
|
|||||||
}
|
}
|
||||||
|
|
||||||
$purpose = match (true) {
|
$purpose = match (true) {
|
||||||
$booking->process()->preReservation() => self::FOR_OFFER,
|
$booking->process()->inquiryAnswer() === InquiryAnswer::Offer => self::FOR_OFFER,
|
||||||
$booking->wish_at !== null => self::FOR_WISH,
|
$booking->wish_at !== null => self::FOR_WISH,
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public function handle(): int
|
|||||||
->whereHas('guest', fn ($query) => $query->whereNull('anonymized_at')->whereNotNull('email')->where('email', '!=', ''))
|
->whereHas('guest', fn ($query) => $query->whereNull('anonymized_at')->whereNotNull('email')->where('email', '!=', ''))
|
||||||
->with('guest')
|
->with('guest')
|
||||||
->get()
|
->get()
|
||||||
->filter(fn (Booking $booking): bool => $booking->process()->guestMessages() === Responsibility::Landlord
|
->filter(fn (Booking $booking): bool => $booking->process()->reviewRequestSender() === Responsibility::Landlord
|
||||||
// The step can be switched off per channel (Kanal › Ablauf); an open portal report holds it back (O4).
|
// The step can be switched off per channel (Kanal › Ablauf); an open portal report holds it back (O4).
|
||||||
&& ProcessPlan::of($booking)->enabled('review.request')
|
&& ProcessPlan::of($booking)->enabled('review.request')
|
||||||
&& OutwardSuspension::reason($booking) === null);
|
&& OutwardSuspension::reason($booking) === null);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public function handle(): array
|
|||||||
->whereNull('arrival_info_sent_at')
|
->whereNull('arrival_info_sent_at')
|
||||||
->whereDate('arrival', '>=', $today)
|
->whereDate('arrival', '>=', $today)
|
||||||
->whereDate('arrival', '<=', $today->copy()->addDays(self::ARRIVAL_INFO_MAX_DAYS_BEFORE)))
|
->whereDate('arrival', '<=', $today->copy()->addDays(self::ARRIVAL_INFO_MAX_DAYS_BEFORE)))
|
||||||
->filter(fn (Booking $booking): bool => $booking->process()->guestMessages() === Responsibility::Landlord
|
->filter(fn (Booking $booking): bool => $booking->process()->arrivalInfoSender() === Responsibility::Landlord
|
||||||
&& $booking->arrival->lessThanOrEqualTo($today->copy()->addDays($booking->process()->arrivalInfoDaysBefore()))
|
&& $booking->arrival->lessThanOrEqualTo($today->copy()->addDays($booking->process()->arrivalInfoDaysBefore()))
|
||||||
// Decision O4: an open portal report of a cancellation or change holds the message back until clarified.
|
// Decision O4: an open portal report of a cancellation or change holds the message back until clarified.
|
||||||
&& OutwardSuspension::reason($booking) === null);
|
&& OutwardSuspension::reason($booking) === null);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
use App\Availability\AvailabilityChecker;
|
use App\Availability\AvailabilityChecker;
|
||||||
use App\Enums\BookingStatus;
|
use App\Enums\BookingStatus;
|
||||||
use App\Enums\DocumentKind;
|
use App\Enums\DocumentKind;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
use App\Enums\Responsibility;
|
use App\Enums\Responsibility;
|
||||||
@@ -167,7 +168,7 @@ private function prepareOffer(Booking $booking, Booking $draft, array $changes,
|
|||||||
'offer_message' => $changes['offer_message'] ?? $booking->offer_message,
|
'offer_message' => $changes['offer_message'] ?? $booking->offer_message,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (! $booking->process()->preReservation()) {
|
if ($booking->process()->inquiryAnswer() === InquiryAnswer::Information) {
|
||||||
$findings[] = DocumentFinding::confirm('Nach Ihrer Einstellung reservieren Anfragen den Zeitraum nicht; vorgesehen ist eine unverbindliche Auskunft. Ein Angebot mit Annahmelink reserviert den Zeitraum für diesen Vorgang trotzdem bis '.$draft->hold_expires_at->format('d.m.Y, H:i').' Uhr, und der Gast kann bis dahin verbindlich annehmen.', DocumentFinding::HOLD_ZERO);
|
$findings[] = DocumentFinding::confirm('Nach Ihrer Einstellung reservieren Anfragen den Zeitraum nicht; vorgesehen ist eine unverbindliche Auskunft. Ein Angebot mit Annahmelink reserviert den Zeitraum für diesen Vorgang trotzdem bis '.$draft->hold_expires_at->format('d.m.Y, H:i').' Uhr, und der Gast kann bis dahin verbindlich annehmen.', DocumentFinding::HOLD_ZERO);
|
||||||
}
|
}
|
||||||
if ($booking->offer_version > 0) {
|
if ($booking->offer_version > 0) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public static function forCase(Booking $booking): ?self
|
|||||||
$booking->intake === IntakeKind::Internal => $booking->guest_id !== null ? self::StayConfirmation : self::Internal,
|
$booking->intake === IntakeKind::Internal => $booking->guest_id !== null ? self::StayConfirmation : self::Internal,
|
||||||
$booking->caseType()->isExternallyBinding() => $profile->documents() === Responsibility::Portal ? null : self::ExternalRecord,
|
$booking->caseType()->isExternallyBinding() => $profile->documents() === Responsibility::Portal ? null : self::ExternalRecord,
|
||||||
$booking->isBinding() => $profile->documents() === Responsibility::Portal ? null : self::Confirmation,
|
$booking->isBinding() => $profile->documents() === Responsibility::Portal ? null : self::Confirmation,
|
||||||
! $profile->preReservation() => self::Information,
|
$profile->inquiryAnswer() === InquiryAnswer::Information => self::Information,
|
||||||
default => self::Offer,
|
default => self::Offer,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How a request is answered first: a non-binding information or a binding offer the guest can accept. Independent of the
|
||||||
|
* reservation strategy (ProcessSetting::PreReservation) – except that an information reserves nothing by definition.
|
||||||
|
*/
|
||||||
|
enum InquiryAnswer: string implements HasLabel
|
||||||
|
{
|
||||||
|
case Information = 'information';
|
||||||
|
case Offer = 'offer';
|
||||||
|
|
||||||
|
public function getLabel(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Information => 'Unverbindliche Auskunft',
|
||||||
|
self::Offer => 'Verbindliches Angebot',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,6 +29,9 @@ enum ProcessSetting: string
|
|||||||
case BookingNotice = 'booking_notice';
|
case BookingNotice = 'booking_notice';
|
||||||
case AwaitPortalConfirmation = 'await_portal_confirmation';
|
case AwaitPortalConfirmation = 'await_portal_confirmation';
|
||||||
case PortalConfirmationWaitHours = 'portal_confirmation_wait_hours';
|
case PortalConfirmationWaitHours = 'portal_confirmation_wait_hours';
|
||||||
|
case InquiryAnswer = 'inquiry_answer';
|
||||||
|
case ArrivalInfoSender = 'arrival_info_sender';
|
||||||
|
case ReviewRequestSender = 'review_request_sender';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Built-in default (the behaviour before any landlord setting existed).
|
* Built-in default (the behaviour before any landlord setting existed).
|
||||||
@@ -54,6 +57,8 @@ public function default(): string|int|bool|null
|
|||||||
self::BookingNotice => BookingNoticeMode::Off->value,
|
self::BookingNotice => BookingNoticeMode::Off->value,
|
||||||
self::AwaitPortalConfirmation => false,
|
self::AwaitPortalConfirmation => false,
|
||||||
self::PortalConfirmationWaitHours => 48,
|
self::PortalConfirmationWaitHours => 48,
|
||||||
|
// Not set: derived (ProcessSettings) – the answer from the reservation, the senders from guest_messages.
|
||||||
|
self::InquiryAnswer, self::ArrivalInfoSender, self::ReviewRequestSender => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +88,9 @@ public function question(): string
|
|||||||
self::BookingNotice => 'Bekommt der Gast von uns eine Buchungsinformation (ohne Vertrag)?',
|
self::BookingNotice => 'Bekommt der Gast von uns eine Buchungsinformation (ohne Vertrag)?',
|
||||||
self::AwaitPortalConfirmation => 'Sollen Unterlagen und Nachrichten erst nach der Bestätigungsmail des Portals gehen?',
|
self::AwaitPortalConfirmation => 'Sollen Unterlagen und Nachrichten erst nach der Bestätigungsmail des Portals gehen?',
|
||||||
self::PortalConfirmationWaitHours => 'Wie lange wird auf die Bestätigungsmail des Portals gewartet, bevor Sie benachrichtigt werden?',
|
self::PortalConfirmationWaitHours => 'Wie lange wird auf die Bestätigungsmail des Portals gewartet, bevor Sie benachrichtigt werden?',
|
||||||
|
self::InquiryAnswer => 'Womit wird eine Anfrage zuerst beantwortet?',
|
||||||
|
self::ArrivalInfoSender => 'Wer schickt dem Gast die Anreise-Informationen?',
|
||||||
|
self::ReviewRequestSender => 'Wer bittet den Gast nach dem Aufenthalt um eine Bewertung?',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +102,8 @@ public function question(): string
|
|||||||
public function channelIntakes(): array
|
public function channelIntakes(): array
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Processing, self::Payments, self::GuestMessages, self::ContractTemplate => [IntakeKind::Inquiry, IntakeKind::Booking],
|
self::Processing, self::Payments, self::GuestMessages, self::ContractTemplate, self::ArrivalInfoSender, self::ReviewRequestSender => [IntakeKind::Inquiry, IntakeKind::Booking],
|
||||||
|
self::InquiryAnswer => [IntakeKind::Inquiry],
|
||||||
self::PreReservation, self::HoldHours => [IntakeKind::Inquiry],
|
self::PreReservation, self::HoldHours => [IntakeKind::Inquiry],
|
||||||
self::Documents, self::ContractDelivery, self::BookingNotice, self::AwaitPortalConfirmation, self::PortalConfirmationWaitHours => [IntakeKind::Booking],
|
self::Documents, self::ContractDelivery, self::BookingNotice, self::AwaitPortalConfirmation, self::PortalConfirmationWaitHours => [IntakeKind::Booking],
|
||||||
self::ArrivalInfoDaysBefore, self::GuestLinkValidDays => [],
|
self::ArrivalInfoDaysBefore, self::GuestLinkValidDays => [],
|
||||||
@@ -108,7 +117,7 @@ public function channelIntakes(): array
|
|||||||
*/
|
*/
|
||||||
public function isLandlordSetting(): bool
|
public function isLandlordSetting(): bool
|
||||||
{
|
{
|
||||||
return $this !== self::ContractTemplate;
|
return ! in_array($this, [self::ContractTemplate, self::InquiryAnswer], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +131,8 @@ public function normalize(mixed $value): string|int|bool|null
|
|||||||
|
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Processing => ($value instanceof ProcessingMode ? $value : ProcessingMode::tryFrom((string) $value))?->value,
|
self::Processing => ($value instanceof ProcessingMode ? $value : ProcessingMode::tryFrom((string) $value))?->value,
|
||||||
self::Documents, self::Payments, self::GuestMessages => ($value instanceof Responsibility ? $value : Responsibility::tryFrom((string) $value))?->value,
|
self::Documents, self::Payments, self::GuestMessages, self::ArrivalInfoSender, self::ReviewRequestSender => ($value instanceof Responsibility ? $value : Responsibility::tryFrom((string) $value))?->value,
|
||||||
|
self::InquiryAnswer => ($value instanceof InquiryAnswer ? $value : InquiryAnswer::tryFrom((string) $value))?->value,
|
||||||
self::PreReservation, self::FormRequiresAddress, self::AwaitPortalConfirmation => is_bool($value) ? $value : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
self::PreReservation, self::FormRequiresAddress, self::AwaitPortalConfirmation => is_bool($value) ? $value : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
||||||
self::HoldHours, self::ArrivalInfoDaysBefore, self::ContractTemplate => is_numeric($value) ? (int) $value : null,
|
self::HoldHours, self::ArrivalInfoDaysBefore, self::ContractTemplate => is_numeric($value) ? (int) $value : null,
|
||||||
self::DataRequest => ($value instanceof DataRequestMode ? $value : DataRequestMode::tryFrom((string) $value))?->value,
|
self::DataRequest => ($value instanceof DataRequestMode ? $value : DataRequestMode::tryFrom((string) $value))?->value,
|
||||||
@@ -141,7 +151,8 @@ public function describe(string|int|bool|null $value): string
|
|||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Processing => ProcessingMode::tryFrom((string) $value)?->getLabel() ?? '–',
|
self::Processing => ProcessingMode::tryFrom((string) $value)?->getLabel() ?? '–',
|
||||||
self::Documents, self::Payments, self::GuestMessages => Responsibility::tryFrom((string) $value)?->getLabel() ?? '–',
|
self::Documents, self::Payments, self::GuestMessages, self::ArrivalInfoSender, self::ReviewRequestSender => Responsibility::tryFrom((string) $value)?->getLabel() ?? '–',
|
||||||
|
self::InquiryAnswer => InquiryAnswer::tryFrom((string) $value)?->getLabel() ?? '–',
|
||||||
self::PreReservation => $value ? 'ja' : 'nein',
|
self::PreReservation => $value ? 'ja' : 'nein',
|
||||||
self::HoldHours => $value.' Stunden',
|
self::HoldHours => $value.' Stunden',
|
||||||
self::ArrivalInfoDaysBefore => $value.' Tage vor Anreise',
|
self::ArrivalInfoDaysBefore => $value.' Tage vor Anreise',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
use App\Enums\BookingNoticeMode;
|
use App\Enums\BookingNoticeMode;
|
||||||
use App\Enums\ContractDelivery;
|
use App\Enums\ContractDelivery;
|
||||||
use App\Enums\DataRequestMode;
|
use App\Enums\DataRequestMode;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\ProcessingMode;
|
use App\Enums\ProcessingMode;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
use App\Enums\Responsibility;
|
use App\Enums\Responsibility;
|
||||||
@@ -39,7 +40,8 @@ public static function field(string $name, ProcessSetting $setting, string $inhe
|
|||||||
->helperText('Automatisch: Das System sendet Angebote bzw. Unterlagen selbst, sobald alle Angaben da sind. Sonst bereitet es alles vor und Sie geben frei.'),
|
->helperText('Automatisch: Das System sendet Angebote bzw. Unterlagen selbst, sobald alle Angaben da sind. Sonst bereitet es alles vor und Sie geben frei.'),
|
||||||
ProcessSetting::PreReservation => Select::make($name)->options(['1' => 'Ja – der Zeitraum ist bis zum Ablauf des Angebots reserviert', '0' => 'Nein – der Gast erhält eine unverbindliche Auskunft und kann daraus die Buchung anfragen (erneute Prüfung vor der Bestätigung)'])->placeholder($placeholder),
|
ProcessSetting::PreReservation => Select::make($name)->options(['1' => 'Ja – der Zeitraum ist bis zum Ablauf des Angebots reserviert', '0' => 'Nein – der Gast erhält eine unverbindliche Auskunft und kann daraus die Buchung anfragen (erneute Prüfung vor der Bestätigung)'])->placeholder($placeholder),
|
||||||
ProcessSetting::HoldHours => TextInput::make($name)->integer()->minValue(1)->maxValue(720)->suffix('Stunden')->placeholder($placeholder),
|
ProcessSetting::HoldHours => TextInput::make($name)->integer()->minValue(1)->maxValue(720)->suffix('Stunden')->placeholder($placeholder),
|
||||||
ProcessSetting::Documents, ProcessSetting::Payments, ProcessSetting::GuestMessages => Select::make($name)->options([Responsibility::Landlord->value => Responsibility::Landlord->getLabel(), Responsibility::Portal->value => Responsibility::Portal->getLabel()])->placeholder($placeholder),
|
ProcessSetting::Documents, ProcessSetting::Payments, ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoSender, ProcessSetting::ReviewRequestSender => Select::make($name)->options([Responsibility::Landlord->value => Responsibility::Landlord->getLabel(), Responsibility::Portal->value => Responsibility::Portal->getLabel()])->placeholder($placeholder),
|
||||||
|
ProcessSetting::InquiryAnswer => Select::make($name)->options(InquiryAnswer::class)->placeholder($placeholder),
|
||||||
ProcessSetting::ArrivalInfoDaysBefore => TextInput::make($name)->integer()->minValue(1)->maxValue(14)->suffix('Tage vor Anreise')->placeholder($placeholder),
|
ProcessSetting::ArrivalInfoDaysBefore => TextInput::make($name)->integer()->minValue(1)->maxValue(14)->suffix('Tage vor Anreise')->placeholder($placeholder),
|
||||||
ProcessSetting::ContractTemplate => Select::make($name)
|
ProcessSetting::ContractTemplate => Select::make($name)
|
||||||
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
|
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Pages;
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
use App\Enums\UserRole;
|
use App\Enums\UserRole;
|
||||||
@@ -112,7 +113,9 @@ public static function where(ProcessSetting $setting): string
|
|||||||
public static function answer(ProcessProfile $profile): string
|
public static function answer(ProcessProfile $profile): string
|
||||||
{
|
{
|
||||||
return match ($profile->intake) {
|
return match ($profile->intake) {
|
||||||
IntakeKind::Inquiry => $profile->preReservation() ? 'Angebot mit Annahmelink, Zeitraum reserviert' : 'Unverbindliche Auskunft, „Buchung anfragen“, erneute Prüfung',
|
IntakeKind::Inquiry => $profile->inquiryAnswer() === InquiryAnswer::Offer
|
||||||
|
? 'Angebot mit Annahmelink'.($profile->preReservation() ? ', Zeitraum schon bei der Anfrage reserviert' : ', Zeitraum erst mit dem Angebot reserviert')
|
||||||
|
: 'Unverbindliche Auskunft, „Buchung anfragen“, erneute Prüfung',
|
||||||
IntakeKind::Booking => 'keine – beim Portal bereits verbindlich',
|
IntakeKind::Booking => 'keine – beim Portal bereits verbindlich',
|
||||||
IntakeKind::Internal => 'keine – eigene Belegung',
|
IntakeKind::Internal => 'keine – eigene Belegung',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
use App\Enums\BookingTaskKind;
|
use App\Enums\BookingTaskKind;
|
||||||
use App\Enums\BookingTaskStatus;
|
use App\Enums\BookingTaskStatus;
|
||||||
use App\Enums\DocumentKind;
|
use App\Enums\DocumentKind;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Enums\Responsibility;
|
use App\Enums\Responsibility;
|
||||||
use App\Exceptions\ReservationException;
|
use App\Exceptions\ReservationException;
|
||||||
@@ -52,7 +53,7 @@ private function sendInformationAction(): Action
|
|||||||
->label(fn (): string => $this->record->information_version > 0 ? 'Auskunft ändern & neu senden' : 'Unverbindliche Auskunft prüfen und senden')
|
->label(fn (): string => $this->record->information_version > 0 ? 'Auskunft ändern & neu senden' : 'Unverbindliche Auskunft prüfen und senden')
|
||||||
->icon(Heroicon::OutlinedPaperAirplane)
|
->icon(Heroicon::OutlinedPaperAirplane)
|
||||||
->visible(fn (): bool => in_array($this->record->status, [BookingStatus::Reserved, BookingStatus::Expired], true) && $this->record->intake !== IntakeKind::Booking
|
->visible(fn (): bool => in_array($this->record->status, [BookingStatus::Reserved, BookingStatus::Expired], true) && $this->record->intake !== IntakeKind::Booking
|
||||||
&& ! $this->record->process()->preReservation() && $this->record->offer_version === 0 && ! $this->record->isHoldActive())
|
&& $this->record->process()->inquiryAnswer() === InquiryAnswer::Information && $this->record->offer_version === 0 && ! $this->record->isHoldActive())
|
||||||
->modalHeading('Unverbindliche Auskunft an den Gast')
|
->modalHeading('Unverbindliche Auskunft an den Gast')
|
||||||
->modalDescription('Nach Ihrer Einstellung reservieren Anfragen den Zeitraum nicht. Der Gast erhält Preis und Verfügbarkeit zum heutigen Stand und kann daraus die Buchung anfragen; dann wird erneut geprüft. Verbindlich wird erst Ihre (oder die automatische) Bestätigung.')
|
->modalDescription('Nach Ihrer Einstellung reservieren Anfragen den Zeitraum nicht. Der Gast erhält Preis und Verfügbarkeit zum heutigen Stand und kann daraus die Buchung anfragen; dann wird erneut geprüft. Verbindlich wird erst Ihre (oder die automatische) Bestätigung.')
|
||||||
->modalSubmitActionLabel('Senden')
|
->modalSubmitActionLabel('Senden')
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
use App\Enums\ChangeBasis;
|
use App\Enums\ChangeBasis;
|
||||||
use App\Enums\ChangeStatus;
|
use App\Enums\ChangeStatus;
|
||||||
use App\Enums\DocumentKind;
|
use App\Enums\DocumentKind;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Enums\InternalKind;
|
use App\Enums\InternalKind;
|
||||||
use App\Enums\ProcessingMode;
|
use App\Enums\ProcessingMode;
|
||||||
@@ -190,7 +191,7 @@ private function sendOfferAction(): Action
|
|||||||
return Action::make('sendOffer')
|
return Action::make('sendOffer')
|
||||||
->label(fn (): string => match (true) {
|
->label(fn (): string => match (true) {
|
||||||
$this->record->status === BookingStatus::OfferSent => 'Angebot ändern & neu senden',
|
$this->record->status === BookingStatus::OfferSent => 'Angebot ändern & neu senden',
|
||||||
! $this->record->process()->preReservation() => 'Stattdessen verbindliches Angebot mit Reservierung senden',
|
$this->record->process()->inquiryAnswer() === InquiryAnswer::Information => 'Stattdessen verbindliches Angebot mit Reservierung senden',
|
||||||
default => 'Angebot prüfen und senden',
|
default => 'Angebot prüfen und senden',
|
||||||
})
|
})
|
||||||
->icon(Heroicon::OutlinedPaperAirplane)
|
->icon(Heroicon::OutlinedPaperAirplane)
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
use App\Pricing\CaseMoney;
|
use App\Pricing\CaseMoney;
|
||||||
use App\Process\CaseActivities;
|
use App\Process\CaseActivities;
|
||||||
use App\Process\CaseAutomation;
|
use App\Process\CaseAutomation;
|
||||||
|
use App\Process\ProcessCatalogue;
|
||||||
|
use App\Process\ProcessPlan;
|
||||||
use App\Process\ProcessProfile;
|
use App\Process\ProcessProfile;
|
||||||
use App\Support\Money;
|
use App\Support\Money;
|
||||||
use Carbon\CarbonImmutable;
|
use Carbon\CarbonImmutable;
|
||||||
@@ -121,6 +123,7 @@ public static function configure(Schema $schema): Schema
|
|||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('status')->label('Status')->badge(),
|
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('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('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('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(),
|
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>');
|
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
|
private static function profile(Booking $booking): HtmlString
|
||||||
{
|
{
|
||||||
$profile = $booking->process();
|
$profile = $booking->process();
|
||||||
|
|||||||
@@ -3,9 +3,13 @@
|
|||||||
namespace App\Filament\Resources\Channels\Pages;
|
namespace App\Filament\Resources\Channels\Pages;
|
||||||
|
|
||||||
use App\Actions\ConfigureChannelProcess;
|
use App\Actions\ConfigureChannelProcess;
|
||||||
|
use App\Communication\CommunicationRules;
|
||||||
use App\Enums\AdminMode;
|
use App\Enums\AdminMode;
|
||||||
use App\Enums\Execution;
|
use App\Enums\Execution;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Enums\Medium;
|
||||||
|
use App\Enums\MessageEffect;
|
||||||
|
use App\Enums\MessageIntent;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
use App\Filament\Resources\Channels\ChannelResource;
|
use App\Filament\Resources\Channels\ChannelResource;
|
||||||
use App\Models\Booking;
|
use App\Models\Booking;
|
||||||
@@ -14,11 +18,17 @@
|
|||||||
use App\Process\Capability;
|
use App\Process\Capability;
|
||||||
use App\Process\ChannelCapabilities;
|
use App\Process\ChannelCapabilities;
|
||||||
use App\Process\ChannelProcessConfiguration;
|
use App\Process\ChannelProcessConfiguration;
|
||||||
|
use App\Process\ConfigurationImpact;
|
||||||
use App\Process\Models\ProcessModel;
|
use App\Process\Models\ProcessModel;
|
||||||
|
use App\Process\ProcessBlocks;
|
||||||
use App\Process\ProcessCatalogue;
|
use App\Process\ProcessCatalogue;
|
||||||
|
use App\Process\ProcessLanes;
|
||||||
use App\Process\ProcessProfile;
|
use App\Process\ProcessProfile;
|
||||||
use App\Process\ProcessSettings;
|
use App\Process\ProcessSettings;
|
||||||
use App\Process\Restriction;
|
use App\Process\Restriction;
|
||||||
|
use App\Process\Templates\FunctionTemplate;
|
||||||
|
use App\Process\Templates\TemplateArea;
|
||||||
|
use App\Process\Templates\TemplateComposer;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
||||||
@@ -45,7 +55,7 @@ class ChannelProcess extends Page
|
|||||||
|
|
||||||
public string $intake = 'inquiry';
|
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 = [];
|
public array $drafts = [];
|
||||||
|
|
||||||
/** @var array<string, string> capability key => '1' | '0' | '' (unknown); saving confirms what is shown */
|
/** @var array<string, string> capability key => '1' | '0' | '' (unknown); saving confirms what is shown */
|
||||||
@@ -54,29 +64,90 @@ class ChannelProcess extends Page
|
|||||||
/** The landlord confirmed that stored settings the chosen model overrides are removed. */
|
/** The landlord confirmed that stored settings the chosen model overrides are removed. */
|
||||||
public bool $acknowledge = false;
|
public bool $acknowledge = false;
|
||||||
|
|
||||||
|
/** The business block opened in the detail panel ('' = none). */
|
||||||
|
public string $block = '';
|
||||||
|
|
||||||
public function mount(int|string $record): void
|
public function mount(int|string $record): void
|
||||||
{
|
{
|
||||||
$this->record = $this->resolveRecord($record);
|
$this->record = $this->resolveRecord($record);
|
||||||
$configuration = app(ChannelProcessConfiguration::class);
|
$configuration = app(ChannelProcessConfiguration::class);
|
||||||
foreach ($configuration->intakes($this->record) as $intake) {
|
foreach ($configuration->intakes($this->record) as $intake) {
|
||||||
$current = $configuration->current($this->record, $intake);
|
$this->drafts[$intake->value] = $this->storedDraft($intake);
|
||||||
|
}
|
||||||
|
$this->intake = (string) array_key_first($this->drafts);
|
||||||
|
$this->block = '';
|
||||||
|
$this->capabilityDraft = $this->storedCapabilities();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The draft as it is stored (or derived) now – the reference for "unsaved changes" and for discarding them.
|
||||||
|
* The current (saved or derived) model stays selected even if it is not admissible: the page explains why instead of
|
||||||
|
* switching silently to another one.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function storedDraft(IntakeKind $intake): array
|
||||||
|
{
|
||||||
|
$current = app(ChannelProcessConfiguration::class)->current($this->record, $intake);
|
||||||
$stored = (array) (($this->record->process_overrides ?? [])[$intake->value] ?? []);
|
$stored = (array) (($this->record->process_overrides ?? [])[$intake->value] ?? []);
|
||||||
// The current (saved or derived) model stays selected even if it is not admissible: the page explains why instead of
|
|
||||||
// switching silently to another one.
|
return [
|
||||||
$model = $current['model'];
|
'model' => $current['model'],
|
||||||
$this->drafts[$intake->value] = [
|
|
||||||
'model' => $model,
|
|
||||||
'variant' => $current['variant'],
|
'variant' => $current['variant'],
|
||||||
'steps' => (array) ($stored['steps'] ?? []),
|
'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())))),
|
'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'],
|
'derived' => $current['derived'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
$this->intake = (string) array_key_first($this->drafts);
|
|
||||||
$this->capabilityDraft = $this->record->isWebsite() ? [] : collect(app(ChannelCapabilities::class)->resolve($this->record))
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private function storedCapabilities(): array
|
||||||
|
{
|
||||||
|
return $this->record->isWebsite() ? [] : collect(app(ChannelCapabilities::class)->resolve($this->record))
|
||||||
->map(fn (Capability $capability): string => $capability->value === null ? '' : ($capability->value ? '1' : '0'))->all();
|
->map(fn (Capability $capability): string => $capability->value === null ? '' : ($capability->value ? '1' : '0'))->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the draft of the current intake kind differs from what is stored (nothing is saved by looking or selecting).
|
||||||
|
*/
|
||||||
|
public function dirty(): bool
|
||||||
|
{
|
||||||
|
$normalise = fn (array $draft): array => [
|
||||||
|
'model' => $draft['model'],
|
||||||
|
'variant' => $draft['variant'],
|
||||||
|
'steps' => array_filter((array) $draft['steps']),
|
||||||
|
'templates' => (array) $draft['templates'],
|
||||||
|
'settings' => array_filter((array) $draft['settings'], fn (mixed $value): bool => $value !== null && $value !== ''),
|
||||||
|
];
|
||||||
|
|
||||||
|
return $normalise($this->drafts[$this->intake]) != $normalise($this->storedDraft(IntakeKind::from($this->intake)))
|
||||||
|
|| $this->capabilityDraft != $this->storedCapabilities();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws the unsaved changes away and shows the stored configuration again.
|
||||||
|
*/
|
||||||
|
public function discard(): void
|
||||||
|
{
|
||||||
|
$intake = $this->intake;
|
||||||
|
$this->acknowledge = false;
|
||||||
|
$this->mount($this->record->getKey());
|
||||||
|
$this->intake = $intake;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function selectBlock(string $block): void
|
||||||
|
{
|
||||||
|
$this->block = $this->block === $block ? '' : $block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updatedIntake(): void
|
||||||
|
{
|
||||||
|
$this->block = '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The draft of the current intake kind including the capabilities shown (they decide which models fit).
|
* The draft of the current intake kind including the capabilities shown (they decide which models fit).
|
||||||
*
|
*
|
||||||
@@ -139,7 +210,169 @@ public function models(): array
|
|||||||
*/
|
*/
|
||||||
public function conflicts(): 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();
|
||||||
|
$composedBy = isset($presets[$archetype]) ? app(ProcessCatalogue::class)->model($archetype)::composedBy() : null;
|
||||||
|
if ($composedBy === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$base = app(ProcessCatalogue::class)->model($composedBy);
|
||||||
|
$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'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The course as the runner executes it: parallel, waiting (with what for), event-driven, time-driven, not applying.
|
||||||
|
*
|
||||||
|
* @return array<string, list<array<string, mixed>>>
|
||||||
|
*/
|
||||||
|
public function lanes(): array
|
||||||
|
{
|
||||||
|
return app(ProcessLanes::class)->of($this->steps());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What arrives here and how binding it is (the start of the course).
|
||||||
|
*
|
||||||
|
* @return array{event: string, binding: string, media: list<string>}
|
||||||
|
*/
|
||||||
|
public function entry(): array
|
||||||
|
{
|
||||||
|
$rules = app(CommunicationRules::class);
|
||||||
|
$media = array_values(array_map(fn (Medium $medium): string => $medium->getLabel(), array_filter(Medium::cases(), fn (Medium $medium): bool => $rules->mediumActive($medium))));
|
||||||
|
$booking = $this->intake === IntakeKind::Booking->value;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'event' => $booking ? 'Eine feste Buchung kommt über '.$this->record->name.' an (Portalmail, Kalender).' : ($this->record->isWebsite() ? 'Ein Gast fragt über die Webseite einen Aufenthalt an.' : 'Eine Anfrage kommt über '.$this->record->name.' an.'),
|
||||||
|
'binding' => $booking ? 'Beim Portal bereits verbindlich – wir übernehmen, wir verbinden nichts neu.' : 'Unverbindlich – verbindlich wird sie durch unser Angebot und die Annahme des Gastes.',
|
||||||
|
'media' => $media,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What a message does here, by its intent – the rules (not a process): a general question creates no case.
|
||||||
|
*
|
||||||
|
* @return list<array{intent: string, effects: list<string>, creates_case: bool}>
|
||||||
|
*/
|
||||||
|
public function messageRules(): array
|
||||||
|
{
|
||||||
|
$rules = app(CommunicationRules::class);
|
||||||
|
|
||||||
|
return array_map(fn (MessageIntent $intent): array => [
|
||||||
|
'intent' => $intent->getLabel(),
|
||||||
|
'effects' => array_map(fn (MessageEffect $effect): string => $effect->getLabel(), $rules->effects(Medium::Email, $intent)),
|
||||||
|
'creates_case' => false,
|
||||||
|
], MessageIntent::cases());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
public function chooseModel(string $model): void
|
||||||
@@ -148,9 +381,13 @@ public function chooseModel(string $model): void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->acknowledge = false;
|
$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]['model'] = $model;
|
||||||
$this->drafts[$this->intake]['variant'] = 'standard';
|
$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
|
public function model(): ProcessModel
|
||||||
@@ -163,6 +400,74 @@ public function profile(): ProcessProfile
|
|||||||
return app(ChannelProcessConfiguration::class)->profileWith($this->record, IntakeKind::from($this->intake), $this->draft());
|
return app(ChannelProcessConfiguration::class)->profileWith($this->record, IntakeKind::from($this->intake), $this->draft());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The business blocks of the course with what is effective in each: values and their origin, the template chosen for
|
||||||
|
* its decision, what depends on what (derived from the resolved plan, see {@see ProcessBlocks}), the steps that can
|
||||||
|
* be configured here and the fixed ones (no controls, shown as one line), gaps the template names, open problems.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function blocks(): array
|
||||||
|
{
|
||||||
|
$intake = IntakeKind::from($this->intake);
|
||||||
|
$configuration = app(ChannelProcessConfiguration::class);
|
||||||
|
$profile = $this->profile();
|
||||||
|
$model = $this->model();
|
||||||
|
$rows = $configuration->preview($this->record, $intake, $this->draft());
|
||||||
|
$templates = app(TemplateComposer::class)->classes($configuration->templatesOf($model, $this->draft()));
|
||||||
|
$steps = collect($this->steps())->keyBy('module');
|
||||||
|
$conflicts = collect($this->conflicts())->map(fn (array $conflict): string => $conflict['setting']->value)->all();
|
||||||
|
$problems = $this->problems();
|
||||||
|
|
||||||
|
$blocks = [];
|
||||||
|
foreach (app(ProcessBlocks::class)->of($rows) as $key => $block) {
|
||||||
|
$template = $block['area'] === null ? null : ($templates[$block['area']->value] ?? null);
|
||||||
|
$settings = array_values(array_filter($block['settings'], fn (ProcessSetting $setting): bool => in_array($intake, $setting->channelIntakes(), true)));
|
||||||
|
$blockSteps = array_values(array_filter(array_map(fn (array $row): ?array => $steps[$row['module']] ?? null, $block['modules'])));
|
||||||
|
$configurable = array_values(array_filter($blockSteps, fn (array $step): bool => $step['on'] && ($step['optional'] || $step['mode_setting'] || ($step['performer_setting'] && count($step['performer_options']) > 1) || $step['parameters'] !== [])
|
||||||
|
|| (! $step['on'] && $step['optional'])));
|
||||||
|
$fixed = array_values(array_filter($blockSteps, fn (array $step): bool => $step['on'] && ! in_array($step, $configurable, true)));
|
||||||
|
$blocks[$key] = [...$block,
|
||||||
|
'facts' => array_map(fn (ProcessSetting $setting): array => $this->setting($setting, $profile), $settings),
|
||||||
|
'template' => $template,
|
||||||
|
'extensions' => $template === null ? [] : $template::extensions(),
|
||||||
|
'configurable' => $configurable,
|
||||||
|
'fixed' => $fixed,
|
||||||
|
'off' => array_values(array_filter($blockSteps, fn (array $step): bool => ! $step['on'])),
|
||||||
|
'attention' => count(array_filter($settings, fn (ProcessSetting $setting): bool => in_array($setting->value, $conflicts, true))),
|
||||||
|
'problems' => $this->blockProblems($problems, $block['label'], $template, $settings),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The problems of the draft that concern a block: they name its template or one of its settings.
|
||||||
|
*
|
||||||
|
* @param list<string> $problems
|
||||||
|
* @param class-string<FunctionTemplate>|null $template
|
||||||
|
* @param list<ProcessSetting> $settings
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function blockProblems(array $problems, string $label, ?string $template, array $settings): array
|
||||||
|
{
|
||||||
|
return array_values(array_filter($problems, fn (string $problem): bool => ($template !== null && str_contains($problem, $template::label()))
|
||||||
|
|| collect($settings)->contains(fn (ProcessSetting $setting): bool => str_contains($problem, $setting->question()))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Problems of the draft that belong to no block (shown above the blocks).
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function problemsOutsideBlocks(): array
|
||||||
|
{
|
||||||
|
$inBlocks = collect($this->blocks())->flatMap(fn (array $block): array => $block['problems'])->all();
|
||||||
|
|
||||||
|
return array_values(array_diff($this->problems(), $inBlocks));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The step cards: preview row + controls of each step.
|
* The step cards: preview row + controls of each step.
|
||||||
*
|
*
|
||||||
@@ -245,6 +550,16 @@ public function problems(): array
|
|||||||
return app(ChannelProcessConfiguration::class)->problems($this->record, IntakeKind::from($this->intake), $this->draft());
|
return app(ChannelProcessConfiguration::class)->problems($this->record, IntakeKind::from($this->intake), $this->draft());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the switched-off steps of the draft mean for the others (suggestions only, nothing is changed).
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function impacts(): array
|
||||||
|
{
|
||||||
|
return app(ConfigurationImpact::class)->of($this->record, IntakeKind::from($this->intake), $this->draft());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Running cases of this channel and intake kind (they keep their frozen plan).
|
* Running cases of this channel and intake kind (they keep their frozen plan).
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public function mount(int|string $record): void
|
|||||||
if ($this->draft === []) {
|
if ($this->draft === []) {
|
||||||
$current = app(ChannelProcessConfiguration::class)->current($this->record, IntakeKind::from($this->intake));
|
$current = app(ChannelProcessConfiguration::class)->current($this->record, IntakeKind::from($this->intake));
|
||||||
$stored = (array) (($this->record->process_overrides ?? [])[$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->scenario = (string) array_key_first($this->scenarios());
|
||||||
$this->resetInputs();
|
$this->resetInputs();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Enums\ChannelBookingModel;
|
use App\Enums\ChannelBookingModel;
|
||||||
use App\Enums\ContractDelivery;
|
use App\Enums\ContractDelivery;
|
||||||
use App\Enums\DataRequestMode;
|
use App\Enums\DataRequestMode;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Enums\ProcessingMode;
|
use App\Enums\ProcessingMode;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
@@ -13,6 +14,8 @@
|
|||||||
use App\Models\Channel;
|
use App\Models\Channel;
|
||||||
use App\Process\Models\ProcessModel;
|
use App\Process\Models\ProcessModel;
|
||||||
use App\Process\Models\Responsibilities;
|
use App\Process\Models\Responsibilities;
|
||||||
|
use App\Process\Templates\FunctionTemplate;
|
||||||
|
use App\Process\Templates\TemplateComposer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* What the channel configurator offers and checks (docs/Prozessarchitektur/Architektur/03): per channel and intake
|
* What the channel configurator offers and checks (docs/Prozessarchitektur/Architektur/03): per channel and intake
|
||||||
@@ -30,16 +33,17 @@ final class ChannelProcessConfiguration
|
|||||||
public const STEP_CONTROLS = [
|
public const STEP_CONTROLS = [
|
||||||
'guest.details' => ['parameters' => [ProcessSetting::FormRequiresAddress]],
|
'guest.details' => ['parameters' => [ProcessSetting::FormRequiresAddress]],
|
||||||
'guest.data_request' => ['mode' => ProcessSetting::DataRequest, 'parameters' => [ProcessSetting::DataRequestReminderHours, ProcessSetting::DataRequestRemindersMax, ProcessSetting::DataRequestFollowupsMax, ProcessSetting::GuestLinkValidDays]],
|
'guest.data_request' => ['mode' => ProcessSetting::DataRequest, 'parameters' => [ProcessSetting::DataRequestReminderHours, ProcessSetting::DataRequestRemindersMax, ProcessSetting::DataRequestFollowupsMax, ProcessSetting::GuestLinkValidDays]],
|
||||||
'hold' => ['parameters' => [ProcessSetting::ClarificationHoldAutoMinutes, ProcessSetting::ClarificationHoldManualMinutes]],
|
'hold' => ['parameters' => [ProcessSetting::PreReservation, ProcessSetting::HoldHours, ProcessSetting::ClarificationHoldAutoMinutes, ProcessSetting::ClarificationHoldManualMinutes]],
|
||||||
'offer.binding' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::HoldHours, ProcessSetting::ContractTemplate]],
|
'offer.binding' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::HoldHours, ProcessSetting::ContractTemplate]],
|
||||||
'offer.information' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::GuestLinkValidDays]],
|
'offer.information' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::GuestLinkValidDays]],
|
||||||
'documents.send' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::ContractDelivery, ProcessSetting::ContractTemplate]],
|
'documents.send' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::ContractDelivery, ProcessSetting::ContractTemplate]],
|
||||||
'documents.booking_notice' => ['parameters' => [ProcessSetting::BookingNotice]],
|
'documents.booking_notice' => ['parameters' => [ProcessSetting::BookingNotice]],
|
||||||
'portal.confirmation' => ['parameters' => [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours]],
|
'portal.confirmation' => ['parameters' => [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours]],
|
||||||
'arrival.info' => ['performer' => ['field' => 'guest_messages', 'setting' => ProcessSetting::GuestMessages], 'parameters' => [ProcessSetting::ArrivalInfoDaysBefore]],
|
'arrival.info' => ['performer' => ['field' => 'guest_messages', 'setting' => ProcessSetting::ArrivalInfoSender], 'parameters' => [ProcessSetting::ArrivalInfoDaysBefore]],
|
||||||
|
'review.request' => ['performer' => ['field' => 'guest_messages', 'setting' => ProcessSetting::ReviewRequestSender]],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct(private ProcessCatalogue $catalogue) {}
|
public function __construct(private ProcessCatalogue $catalogue, private TemplateComposer $composer) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The intake kinds the channel delivers.
|
* The intake kinds the channel delivers.
|
||||||
@@ -94,7 +98,8 @@ public function modelOptions(Channel $channel, IntakeKind $intake, ?array $capab
|
|||||||
$capabilities = app(ChannelCapabilities::class)->resolve($channel, $capabilityDraft);
|
$capabilities = app(ChannelCapabilities::class)->resolve($channel, $capabilityDraft);
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach ($this->catalogue->admissible($intake) as $key => $model) {
|
foreach ($this->catalogue->admissible($intake) as $key => $model) {
|
||||||
if ($channel->isWebsite() !== str_starts_with($key, 'a1.')) {
|
// The archetypes of the other way (website: A1, portal: A2) are not offered; the base process fits both.
|
||||||
|
if (($channel->isWebsite() && str_starts_with($key, 'a2.')) || (! $channel->isWebsite() && str_starts_with($key, 'a1.'))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$restrictions = [];
|
$restrictions = [];
|
||||||
@@ -134,20 +139,111 @@ public function admissibleModels(Channel $channel, IntakeKind $intake, ?array $c
|
|||||||
return array_map(fn (array $option): ProcessModel => $option['model'], array_filter($this->modelOptions($channel, $intake, $capabilityDraft), fn (array $option): bool => $option['admissible']));
|
return array_map(fn (array $option): ProcessModel => $option['model'], array_filter($this->modelOptions($channel, $intake, $capabilityDraft), fn (array $option): bool => $option['admissible']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Every function template of each slot of the model with whether this channel fits it and – if not – why. The
|
||||||
|
* portal's confirmed capabilities decide; an unknown capability is never taken as proven (shown as "please confirm").
|
||||||
|
*
|
||||||
|
* @param array<string, bool|string|null>|null $capabilityDraft
|
||||||
|
* @return array<string, array<string, array{template: class-string<FunctionTemplate>, admissible: bool, restrictions: list<Restriction>, hints: list<string>, unconfirmed: list<string>}>> area value => template key => option
|
||||||
|
*/
|
||||||
|
public function templateOptions(Channel $channel, ProcessModel $model, ?array $capabilityDraft = null): array
|
||||||
|
{
|
||||||
|
$capabilities = app(ChannelCapabilities::class)->resolve($channel, $capabilityDraft);
|
||||||
|
$options = [];
|
||||||
|
foreach ($model->slots() as $area) {
|
||||||
|
foreach ($this->catalogue->templates($area) as $key => $class) {
|
||||||
|
$restrictions = $hints = $unconfirmed = [];
|
||||||
|
if (isset($model::templateRestrictions()[$key])) {
|
||||||
|
$restrictions[] = new Restriction(Restriction::BUSINESS, '„'.$class::label().'“ passt nicht zu „'.$model::label().'“: '.$model::templateRestrictions()[$key]);
|
||||||
|
}
|
||||||
|
if ($channel->isWebsite() && in_array(true, $class::capabilityRequirements(), true)) {
|
||||||
|
$restrictions[] = new Restriction(Restriction::BUSINESS, '„'.$class::label().'“ setzt ein Portal voraus; die eigene Webseite hat keines.');
|
||||||
|
}
|
||||||
|
foreach ($class::capabilityRequirements() as $capability => $required) {
|
||||||
|
$actual = $capabilities[$capability] ?? null;
|
||||||
|
$definition = ChannelCapabilities::definitions()[$capability];
|
||||||
|
if ($actual === null || ! $actual->isKnown()) {
|
||||||
|
$hints[] = $definition['label'].' ist noch nicht bekannt – bitte bestätigen.';
|
||||||
|
$unconfirmed[] = $capability;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($actual->source !== Capability::CONFIRMED) {
|
||||||
|
$unconfirmed[] = $capability;
|
||||||
|
$hints[] = $definition['label'].' gilt nur als „'.($actual->source === Capability::SUGGESTED ? 'Vorschlag des Kanalprofils' : 'abgeleitet').'“, nicht als bestätigt.';
|
||||||
|
}
|
||||||
|
if ($actual->value !== $required) {
|
||||||
|
$other = collect($this->catalogue->templates($area))->first(fn (string $candidate): bool => $candidate !== $class && collect($candidate::capabilityRequirements())->every(fn (bool $value, string $name): bool => ($capabilities[$name] ?? null)?->value === $value));
|
||||||
|
$restrictions[] = new Restriction(
|
||||||
|
Restriction::CAPABILITY,
|
||||||
|
'„'.$class::label().'“ setzt voraus: „'.$definition['question'].'“ – '.($required ? 'ja' : 'nein').'. Für diesen Kanal gilt aber '.($actual->value ? 'ja' : 'nein').' ('.$actual->sourceLabel().').',
|
||||||
|
$other ? $other::label() : null,
|
||||||
|
'Wenn das nicht stimmt: oben bei „Was kann dieses Portal?“ „'.$definition['label'].'“ auf '.($required ? 'ja' : 'nein').' stellen und bestätigen.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$options[$area->value][$key] = ['template' => $class, 'admissible' => $restrictions === [], 'restrictions' => $restrictions, 'hints' => $hints, 'unconfirmed' => $unconfirmed];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$base = $model::composedBy();
|
||||||
|
|
||||||
|
return $base === null || $model::presetTemplates() === [] ? [] : $this->composer->resolve($this->catalogue->model($base), $model::presetTemplates());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The templates a draft uses for the model slots (chosen ones, otherwise the model defaults) as key@version.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $draft
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function templatesOf(ProcessModel $model, array $draft): array
|
||||||
|
{
|
||||||
|
return $this->composer->resolve($model, (array) ($draft['templates'] ?? []));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stored settings of the channel that the chosen model fixes differently: saving the model would silently override
|
* Stored settings of the channel that the chosen model fixes differently: saving the model would silently override
|
||||||
* them (they would stay stored but not take effect). They are listed so that the landlord confirms their removal.
|
* them (they would stay stored but not take effect). They are listed so that the landlord confirms their removal.
|
||||||
*
|
*
|
||||||
|
* @param array<string, string> $templates area => template key chosen in the draft (templates fix responsibilities just like models)
|
||||||
* @return list<array{setting: ProcessSetting, stored: string, fixed: string, text: string}>
|
* @return list<array{setting: ProcessSetting, stored: string, fixed: string, text: string}>
|
||||||
*/
|
*/
|
||||||
public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey): array
|
public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey, array $templates = []): array
|
||||||
{
|
{
|
||||||
if (! $this->catalogue->hasModel($modelKey)) {
|
if (! $this->catalogue->hasModel($modelKey)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
|
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
|
||||||
$conflicts = [];
|
$conflicts = [];
|
||||||
foreach ($this->catalogue->model($modelKey)::fixes() as $key => $fixed) {
|
$model = $this->catalogue->model($modelKey);
|
||||||
|
$fixes = $model::fixes();
|
||||||
|
$fixedBy = array_fill_keys(array_keys($fixes), 'Das Modell „'.$modelKey.'“');
|
||||||
|
foreach ($this->composer->classes($this->composer->resolve($model, $templates)) as $class) {
|
||||||
|
foreach ($class::fixes() as $key => $fixed) {
|
||||||
|
$fixes[$key] = $fixed;
|
||||||
|
$fixedBy[$key] = 'Die Schablone „'.$class::label().'“';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($fixes as $key => $fixed) {
|
||||||
$setting = ProcessSetting::tryFrom($key);
|
$setting = ProcessSetting::tryFrom($key);
|
||||||
$value = $setting?->normalize($stored[$key] ?? null);
|
$value = $setting?->normalize($stored[$key] ?? null);
|
||||||
$fixedValue = $setting?->normalize($fixed) ?? $fixed;
|
$fixedValue = $setting?->normalize($fixed) ?? $fixed;
|
||||||
@@ -155,29 +251,73 @@ public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$conflicts[] = ['setting' => $setting, 'stored' => $setting->describe($value), 'fixed' => $setting->describe($fixedValue),
|
$conflicts[] = ['setting' => $setting, 'stored' => $setting->describe($value), 'fixed' => $setting->describe($fixedValue),
|
||||||
'text' => $setting->question().' Bisher eingestellt: „'.$setting->describe($value).'“. Das Modell „'.$modelKey.'“ legt fest: „'.$setting->describe($fixedValue).'“.'];
|
'text' => $setting->question().' Bisher eingestellt: „'.$setting->describe($value).'“. '.$fixedBy[$key].' legt fest: „'.$setting->describe($fixedValue).'“.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stored responsibilities the model does not allow (variable ones, not fixed through fixes()) are just as stale.
|
||||||
|
$responsibilities = $this->catalogue->model($modelKey)::responsibilities();
|
||||||
|
foreach (Responsibilities::SETTINGS as $field => $setting) {
|
||||||
|
$value = $setting->normalize($stored[$setting->value] ?? null);
|
||||||
|
$responsibility = $value === null ? null : Responsibility::tryFrom((string) $value);
|
||||||
|
if ($responsibility === null || $responsibilities->admits($setting, $responsibility) || in_array($setting, array_column($conflicts, 'setting'), true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$allowed = collect($responsibilities->allowed($field))->map(fn (Responsibility $allowedValue): string => $setting->describe($allowedValue->value))->implode(' oder ');
|
||||||
|
$conflicts[] = ['setting' => $setting, 'stored' => $setting->describe($value), 'fixed' => $allowed,
|
||||||
|
'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);
|
||||||
|
foreach ($model->slots() === [] ? [] : [ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoSender, ProcessSetting::ReviewRequestSender] as $sender) {
|
||||||
|
$storedSender = $sender->normalize($stored[$sender->value] ?? null);
|
||||||
|
if ($messages !== null && $messages->isKnown() && $messages->value === false && $storedSender === Responsibility::Portal->value) {
|
||||||
|
$conflicts[] = ['setting' => $sender, 'stored' => $sender->describe($storedSender), 'fixed' => $sender->describe(Responsibility::Landlord->value),
|
||||||
|
'text' => $sender->question().' Bisher eingestellt: „'.$sender->describe($storedSender).'“. Laut Fähigkeit des Portals schreibt es den Gast aber nicht an; künftig: „'.$sender->describe(Responsibility::Landlord->value).'“.'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $conflicts;
|
return $conflicts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The draft without the stored settings the chosen model overrides (see conflicts()): the landlord has to confirm their
|
||||||
|
* removal when saving, so they are neither validated against the model nor saved again.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $draft
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function withoutOverriddenSettings(Channel $channel, IntakeKind $intake, array $draft): array
|
||||||
|
{
|
||||||
|
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
|
||||||
|
foreach ($this->conflicts($channel, $intake, (string) ($draft['model'] ?? ''), (array) ($draft['templates'] ?? [])) as $conflict) {
|
||||||
|
$key = $conflict['setting']->value;
|
||||||
|
$value = $draft['settings'][$key] ?? null;
|
||||||
|
if (array_key_exists($key, (array) ($draft['settings'] ?? [])) && (string) $conflict['setting']->normalize($value) === (string) $conflict['setting']->normalize($stored[$key] ?? null)) {
|
||||||
|
unset($draft['settings'][$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $draft;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model a new case of this channel and intake would follow now: the chosen one, or the one derived from the
|
* The model a new case of this channel and intake would follow now: the chosen one, or the one derived from the
|
||||||
* settings as before (marked as derived).
|
* settings as before (marked as derived).
|
||||||
*
|
*
|
||||||
* @return array{model: string, variant: string, derived: bool}
|
* @return array{model: string, variant: string, derived: bool, templates: array<string, string>}
|
||||||
*/
|
*/
|
||||||
public function current(Channel $channel, IntakeKind $intake): array
|
public function current(Channel $channel, IntakeKind $intake): array
|
||||||
{
|
{
|
||||||
$config = ProcessPlan::configurationOf($channel, $intake);
|
$config = ProcessPlan::configurationOf($channel, $intake);
|
||||||
if (filled($config['model'] ?? null) && $this->catalogue->hasModel((string) $config['model'])) {
|
if (filled($config['model'] ?? null) && $this->catalogue->hasModel((string) $config['model'])) {
|
||||||
return ['model' => (string) $config['model'], 'variant' => (string) ($config['variant'] ?? 'standard'), 'derived' => false];
|
return ['model' => (string) $config['model'], 'variant' => (string) ($config['variant'] ?? 'standard'), 'derived' => false, 'templates' => (array) ($config['templates'] ?? [])];
|
||||||
}
|
}
|
||||||
|
|
||||||
$property = $channel->property;
|
$property = $channel->property;
|
||||||
$profile = app(ProcessSettings::class)->resolve($property, $channel, $intake);
|
$profile = app(ProcessSettings::class)->resolve($property, $channel, $intake);
|
||||||
|
|
||||||
return ['model' => $this->catalogue->derivedModel($profile), 'variant' => 'standard', 'derived' => true];
|
return ['model' => $this->catalogue->derivedModel($profile), 'variant' => 'standard', 'derived' => true, 'templates' => []];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -231,26 +371,33 @@ public function modeOptions(string $module): array
|
|||||||
* with whether it takes part and why not, who carries it out and how.
|
* with whether it takes part and why not, who carries it out and how.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $draft model, variant, steps, settings of channels.process_overrides[intake]
|
* @param array<string, mixed> $draft model, variant, steps, settings of channels.process_overrides[intake]
|
||||||
* @return list<array{module: string, label: string, phase: string, on: bool, reason: ?string, performer: ?string, mode: ?string, toggle: string, tester_only: bool, inserted: bool}>
|
* @return list<array{module: string, label: string, phase: string, on: bool, reason: ?string, performer: ?string, mode: ?string, toggle: string, tester_only: bool, inserted: bool, template: ?string}>
|
||||||
*/
|
*/
|
||||||
public function preview(Channel $channel, IntakeKind $intake, array $draft): array
|
public function preview(Channel $channel, IntakeKind $intake, array $draft): array
|
||||||
{
|
{
|
||||||
$model = $this->catalogue->model((string) ($draft['model'] ?? $this->current($channel, $intake)['model']));
|
$model = $this->catalogue->model((string) ($draft['model'] ?? $this->current($channel, $intake)['model']));
|
||||||
$variant = (string) ($draft['variant'] ?? 'standard');
|
$variant = (string) ($draft['variant'] ?? 'standard');
|
||||||
$profile = $this->profileWith($channel, $intake, $draft);
|
$profile = $this->profileWith($channel, $intake, $draft);
|
||||||
$standard = $model->modules('standard');
|
$templates = $this->templatesOf($model, $draft);
|
||||||
|
$standard = $model->modules('standard', $templates);
|
||||||
|
$owners = [];
|
||||||
|
foreach ($this->composer->classes($templates) as $class) {
|
||||||
|
foreach ($class::modules() as $module) {
|
||||||
|
$owners[$module] = $class::label();
|
||||||
|
}
|
||||||
|
}
|
||||||
$rows = [];
|
$rows = [];
|
||||||
foreach ($model->modules($variant) as $key) {
|
foreach ($model->modules($variant, $templates) as $key) {
|
||||||
$class = $this->catalogue->modules()[$key];
|
$class = $this->catalogue->modules()[$key];
|
||||||
$definition = $class::definition();
|
$definition = $class::definition();
|
||||||
$on = ($draft['steps'][$key]['on'] ?? true) !== false || ! $definition->isOptional();
|
$on = ($draft['steps'][$key]['on'] ?? true) !== false || ! $definition->isOptional();
|
||||||
$reason = match (true) {
|
$reason = match (true) {
|
||||||
! $on => 'im Kanal abgeschaltet',
|
! $on => 'im Kanal abgeschaltet',
|
||||||
$key === 'hold' && ! $profile->preReservation() => 'keine Vorreservierung in diesem Modell',
|
$key === 'hold' && ! $profile->preReservation() => 'keine Reservierung bei der Anfrage',
|
||||||
$key === 'offer.information' && $profile->preReservation() => 'nicht in diesem Modell (verbindliches Angebot)',
|
$key === 'offer.information' && $profile->inquiryAnswer() === InquiryAnswer::Offer => 'nicht bei verbindlichem Angebot',
|
||||||
$key === 'offer.binding' && ! $profile->preReservation() => 'erst, wenn ein Angebot von Hand gesendet wird',
|
$key === 'offer.binding' && $profile->inquiryAnswer() === InquiryAnswer::Information => 'erst, wenn ein Angebot von Hand gesendet wird',
|
||||||
$key === 'portal.payout' && $profile->payments() !== Responsibility::Portal => 'wir kassieren selbst',
|
$key === 'portal.payout' && $profile->payments() !== Responsibility::Portal => 'wir kassieren selbst',
|
||||||
$key === 'review.request' && $profile->guestMessages() !== Responsibility::Landlord => 'das Portal schreibt dem Gast',
|
$key === 'review.request' && $profile->reviewRequestSender() !== Responsibility::Landlord => 'die Bewertungsbitte kommt nicht von uns',
|
||||||
$key === 'guest.details' && $intake === IntakeKind::Booking && $profile->documents() === Responsibility::Portal && $profile->payments() === Responsibility::Portal && $profile->guestMessages() === Responsibility::Portal => 'wir schreiben dem Gast nicht',
|
$key === 'guest.details' && $intake === IntakeKind::Booking && $profile->documents() === Responsibility::Portal && $profile->payments() === Responsibility::Portal && $profile->guestMessages() === Responsibility::Portal => 'wir schreiben dem Gast nicht',
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
@@ -258,11 +405,12 @@ public function preview(Channel $channel, IntakeKind $intake, array $draft): arr
|
|||||||
$performer = match ($key) {
|
$performer = match ($key) {
|
||||||
'documents.send' => $profile->documents()->value,
|
'documents.send' => $profile->documents()->value,
|
||||||
'payments.monitor' => $profile->payments()->value,
|
'payments.monitor' => $profile->payments()->value,
|
||||||
'arrival.info' => $profile->guestMessages()->value,
|
'arrival.info' => $profile->arrivalInfoSender()->value,
|
||||||
|
'review.request' => $profile->reviewRequestSender()->value,
|
||||||
default => $definition->performers[0] ?? null,
|
default => $definition->performers[0] ?? null,
|
||||||
};
|
};
|
||||||
$rows[] = ['module' => $key, 'label' => $definition->label, 'phase' => $definition->phase, 'on' => $on && $reason === null, 'reason' => $reason,
|
$rows[] = ['module' => $key, 'label' => $definition->label, 'phase' => $definition->phase, 'on' => $on && $reason === null, 'reason' => $reason,
|
||||||
'performer' => $performer, 'mode' => $mode, 'toggle' => $definition->toggle, 'tester_only' => $definition->isTesterOnly(), 'inserted' => ! in_array($key, $standard, true)];
|
'performer' => $performer, 'mode' => $mode, 'toggle' => $definition->toggle, 'tester_only' => $definition->isTesterOnly(), 'inserted' => ! in_array($key, $standard, true), 'template' => $owners[$key] ?? null];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
@@ -276,6 +424,7 @@ public function preview(Channel $channel, IntakeKind $intake, array $draft): arr
|
|||||||
*/
|
*/
|
||||||
public function problems(Channel $channel, IntakeKind $intake, array $draft, bool $sandbox = false): array
|
public function problems(Channel $channel, IntakeKind $intake, array $draft, bool $sandbox = false): array
|
||||||
{
|
{
|
||||||
|
$draft = $this->withoutOverriddenSettings($channel, $intake, $draft);
|
||||||
$problems = [];
|
$problems = [];
|
||||||
if (! in_array($intake, $this->intakes($channel), true)) {
|
if (! in_array($intake, $this->intakes($channel), true)) {
|
||||||
$problems[] = 'Dieser Kanal liefert keine '.($intake === IntakeKind::Booking ? 'festen Buchungen' : 'Anfragen').'.';
|
$problems[] = 'Dieser Kanal liefert keine '.($intake === IntakeKind::Booking ? 'festen Buchungen' : 'Anfragen').'.';
|
||||||
@@ -297,8 +446,9 @@ public function problems(Channel $channel, IntakeKind $intake, array $draft, boo
|
|||||||
$problems[] = 'Die Variante „'.$variant->label.'“ ist nur im Prozess-Tester verwendbar und kann nicht gespeichert werden.';
|
$problems[] = 'Die Variante „'.$variant->label.'“ ist nur im Prozess-Tester verwendbar und kann nicht gespeichert werden.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$templates = $this->templatesOf($model, $draft);
|
||||||
foreach ((array) ($draft['steps'] ?? []) as $module => $step) {
|
foreach ((array) ($draft['steps'] ?? []) as $module => $step) {
|
||||||
if (! $this->catalogue->hasModule($module) || ! in_array($module, $model->modules($variant->key), true)) {
|
if (! $this->catalogue->hasModule($module) || ! in_array($module, $model->modules($variant->key, $templates), true)) {
|
||||||
$problems[] = "Der Schritt {$module} gehört nicht zu diesem Modell.";
|
$problems[] = "Der Schritt {$module} gehört nicht zu diesem Modell.";
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -325,7 +475,46 @@ public function problems(Channel $channel, IntakeKind $intake, array $draft, boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_values(array_unique($problems));
|
return array_values(array_unique([...$problems, ...$this->templateProblems($channel, $model, $draft)]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What is wrong with the function templates of a draft: composition, the confirmed capabilities of the portal and
|
||||||
|
* responsibilities set by hand that contradict a template.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $draft
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function templateProblems(Channel $channel, ProcessModel $model, array $draft): array
|
||||||
|
{
|
||||||
|
$variant = (string) ($draft['variant'] ?? 'standard');
|
||||||
|
$problems = $this->composer->problems($model, (array) ($draft['templates'] ?? []), $variant);
|
||||||
|
if ($model->slots() === []) {
|
||||||
|
return $problems;
|
||||||
|
}
|
||||||
|
$capabilities = (array) ($draft['capabilities'] ?? []) ?: null;
|
||||||
|
$options = $this->templateOptions($channel, $model, $capabilities);
|
||||||
|
foreach ($this->composer->classes($this->templatesOf($model, $draft)) as $area => $class) {
|
||||||
|
foreach ($options[$area][$class::key()]['restrictions'] ?? [] as $restriction) {
|
||||||
|
$problems[] = $restriction->text();
|
||||||
|
}
|
||||||
|
foreach ($class::fixes() as $key => $fixed) {
|
||||||
|
$setting = ProcessSetting::tryFrom($key);
|
||||||
|
$value = $setting?->normalize($draft['settings'][$key] ?? null);
|
||||||
|
$fixedValue = $setting?->normalize($fixed) ?? $fixed;
|
||||||
|
if ($setting !== null && $value !== null && (string) $value !== (string) $fixedValue) {
|
||||||
|
$problems[] = $setting->question().' „'.$setting->describe($value).'“ widerspricht der Schablone „'.$class::label().'“ ('.$setting->describe($fixedValue).').';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$messages = app(ChannelCapabilities::class)->resolve($channel, $capabilities)[ChannelCapabilities::MESSAGES_GUEST] ?? null;
|
||||||
|
foreach ([ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoSender, ProcessSetting::ReviewRequestSender] as $sender) {
|
||||||
|
if (($draft['settings'][$sender->value] ?? null) === Responsibility::Portal->value && $messages !== null && $messages->isKnown() && $messages->value === false) {
|
||||||
|
$problems[] = $sender->question().' „Das Portal“ ist eingestellt, das Portal schreibt den Gast laut Fähigkeit aber nicht an.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $problems;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -335,9 +524,10 @@ public function problems(Channel $channel, IntakeKind $intake, array $draft, boo
|
|||||||
*/
|
*/
|
||||||
public function profileWith(Channel $channel, IntakeKind $intake, array $draft): ProcessProfile
|
public function profileWith(Channel $channel, IntakeKind $intake, array $draft): ProcessProfile
|
||||||
{
|
{
|
||||||
|
$draft = $this->withoutOverriddenSettings($channel, $intake, $draft);
|
||||||
$preview = clone $channel;
|
$preview = clone $channel;
|
||||||
$overrides = (array) ($channel->process_overrides ?? []);
|
$overrides = (array) ($channel->process_overrides ?? []);
|
||||||
$overrides[$intake->value] = [...array_filter((array) ($draft['settings'] ?? []), fn (mixed $value): bool => $value !== null && $value !== ''), 'model' => $draft['model'] ?? null, 'variant' => $draft['variant'] ?? 'standard', 'steps' => (array) ($draft['steps'] ?? [])];
|
$overrides[$intake->value] = [...array_filter((array) ($draft['settings'] ?? []), fn (mixed $value): bool => $value !== null && $value !== ''), 'model' => $draft['model'] ?? null, 'variant' => $draft['variant'] ?? 'standard', 'steps' => (array) ($draft['steps'] ?? []), 'templates' => (array) ($draft['templates'] ?? [])];
|
||||||
$preview->setAttribute('process_overrides', $overrides);
|
$preview->setAttribute('process_overrides', $overrides);
|
||||||
|
|
||||||
return app(ProcessSettings::class)->resolve($channel->property, $preview, $intake);
|
return app(ProcessSettings::class)->resolve($channel->property, $preview, $intake);
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process;
|
||||||
|
|
||||||
|
use App\Enums\Execution;
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Enums\ProcessSetting;
|
||||||
|
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
|
||||||
|
* step the landlord switched off it names the steps that depend on it, what stays required, the admissible ways to
|
||||||
|
* achieve the result otherwise and what the configurator suggests. Derived from the module definitions the runner uses –
|
||||||
|
* no second set of rules. Pure: it reads and explains, it never changes a setting.
|
||||||
|
*/
|
||||||
|
final class ConfigurationImpact
|
||||||
|
{
|
||||||
|
public function __construct(private ProcessCatalogue $catalogue, private ChannelProcessConfiguration $configuration, private TemplateComposer $composer) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $draft
|
||||||
|
* @return list<array{module: string, label: string, valid: bool, affected: list<string>, relaxed: list<string>, remains: list<string>, alternatives: list<string>, suggestion: string}>
|
||||||
|
*/
|
||||||
|
public function of(Channel $channel, IntakeKind $intake, array $draft): array
|
||||||
|
{
|
||||||
|
$rows = collect($this->configuration->preview($channel, $intake, $draft));
|
||||||
|
$active = $rows->where('on', true)->pluck('module')->all();
|
||||||
|
$labels = $rows->mapWithKeys(fn (array $row): array => [$row['module'] => $row['label']])->all();
|
||||||
|
$impacts = [];
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$definition = $this->catalogue->modules()[$row['module']]::definition();
|
||||||
|
if (($draft['steps'][$row['module']]['on'] ?? true) !== false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$affected = $relaxed = [];
|
||||||
|
foreach ($active as $other) {
|
||||||
|
foreach ($this->catalogue->modules()[$other]::definition()->requires as $dependency) {
|
||||||
|
if ($dependency->module !== $row['module']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($dependency->hard) {
|
||||||
|
$affected[] = $labels[$other];
|
||||||
|
} else {
|
||||||
|
$relaxed[] = $labels[$other];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$alternatives = array_values(array_map(fn (Execution $execution): string => $execution->getLabel(), array_filter($definition->executions, fn (Execution $execution): bool => $execution !== Execution::NotRequired)));
|
||||||
|
$valid = $definition->isOptional();
|
||||||
|
|
||||||
|
$impacts[] = [
|
||||||
|
'module' => $row['module'], 'label' => $row['label'], 'valid' => $valid,
|
||||||
|
'affected' => array_values(array_unique($affected)), 'relaxed' => array_values(array_unique($relaxed)),
|
||||||
|
'remains' => $this->remains($definition, $affected, $labels),
|
||||||
|
'alternatives' => $alternatives,
|
||||||
|
'suggestion' => $this->suggestion($row['label'], $definition, $valid, $alternatives),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
$changedFixes = [];
|
||||||
|
$replaced = [];
|
||||||
|
foreach ([...array_keys($toClass::fixes()), ...array_keys($toClass::defaults())] as $key) {
|
||||||
|
$changed = ProcessSetting::tryFrom($key);
|
||||||
|
$wanted = $toClass::fixes()[$key] ?? $toClass::defaults()[$key];
|
||||||
|
$previous = $fromClass === null ? null : ($fromClass::fixes()[$key] ?? $fromClass::defaults()[$key] ?? null);
|
||||||
|
if ($changed === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($previous !== null && (string) $changed->normalize($previous) !== (string) $changed->normalize($wanted)) {
|
||||||
|
$changedFixes[] = $changed->question().' '.$changed->describe($changed->normalize($previous)).' → '.$changed->describe($changed->normalize($wanted)).(array_key_exists($key, $toClass::fixes()) ? '' : ' (nur ein Vorschlag – ausdrücklich gesetzte Werte bleiben)');
|
||||||
|
}
|
||||||
|
$storedValue = $changed->normalize($stored[$key] ?? null);
|
||||||
|
if (array_key_exists($key, $toClass::fixes()) && $storedValue !== null && (string) $storedValue !== (string) $changed->normalize($wanted)) {
|
||||||
|
$replaced[] = $changed->question().' Bisher gespeichert: „'.$changed->describe($storedValue).'“, künftig durch die Schablone: „'.$changed->describe($changed->normalize($wanted)).'“. Der gespeicherte Wert muss beim Speichern ausdrücklich entfernt werden.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$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,
|
||||||
|
'changed_settings' => $changedFixes,
|
||||||
|
'switches_lost' => array_map($labelOf, array_values(array_filter($removed, fn (string $module): bool => ($stored['steps'][$module]['on'] ?? true) === false))),
|
||||||
|
'settings_replaced' => $replaced,
|
||||||
|
'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.
|
||||||
|
*
|
||||||
|
* @param list<string> $affected
|
||||||
|
* @param array<string, string> $labels
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function remains(ModuleDefinition $definition, array $affected, array $labels): array
|
||||||
|
{
|
||||||
|
$remains = [];
|
||||||
|
if ($affected !== []) {
|
||||||
|
$remains[] = 'Weiterhin nötig, damit „'.implode('“, „', array_unique($affected)).'“ laufen kann: '.lcfirst($definition->purpose);
|
||||||
|
}
|
||||||
|
if ($definition->why !== null) {
|
||||||
|
$remains[] = $definition->why;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $remains;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $alternatives
|
||||||
|
*/
|
||||||
|
private function suggestion(string $label, ModuleDefinition $definition, bool $valid, array $alternatives): string
|
||||||
|
{
|
||||||
|
if (! $valid) {
|
||||||
|
return '„'.$label.'“ ist Pflicht und kann nicht abgeschaltet werden.'.($alternatives !== [] ? ' Zulässig sind stattdessen: '.implode('; ', $alternatives).'.' : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $alternatives === []
|
||||||
|
? '„'.$label.'“ entfällt ersatzlos; es ist nichts weiter einzustellen.'
|
||||||
|
: 'Statt abzuschalten, können Sie „'.$label.'“ auch so erledigen lassen: '.implode('; ', $alternatives).'. Es wird nichts anderes automatisch geändert.';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,21 @@ public static function caseTypes(): array
|
|||||||
return [CaseType::A1];
|
return [CaseType::A1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isLegacy(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function composedBy(): ?string
|
||||||
|
{
|
||||||
|
return 'inquiry.request';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function presetTemplates(): array
|
||||||
|
{
|
||||||
|
return ['inquiry_answer' => 'inquiry.information'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function fixes(): array
|
public static function fixes(): array
|
||||||
{
|
{
|
||||||
return ['pre_reservation' => false];
|
return ['pre_reservation' => false];
|
||||||
|
|||||||
@@ -34,6 +34,21 @@ public static function caseTypes(): array
|
|||||||
return [CaseType::A1];
|
return [CaseType::A1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isLegacy(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function composedBy(): ?string
|
||||||
|
{
|
||||||
|
return 'inquiry.request';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function presetTemplates(): array
|
||||||
|
{
|
||||||
|
return ['inquiry_answer' => 'inquiry.binding_offer'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function fixes(): array
|
public static function fixes(): array
|
||||||
{
|
{
|
||||||
return ['pre_reservation' => true];
|
return ['pre_reservation' => true];
|
||||||
|
|||||||
@@ -35,6 +35,21 @@ public static function caseTypes(): array
|
|||||||
return [CaseType::A2];
|
return [CaseType::A2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isLegacy(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function composedBy(): ?string
|
||||||
|
{
|
||||||
|
return 'inquiry.request';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function presetTemplates(): array
|
||||||
|
{
|
||||||
|
return ['inquiry_answer' => 'inquiry.information'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function fixes(): array
|
public static function fixes(): array
|
||||||
{
|
{
|
||||||
return ['pre_reservation' => false];
|
return ['pre_reservation' => false];
|
||||||
|
|||||||
@@ -35,6 +35,21 @@ public static function caseTypes(): array
|
|||||||
return [CaseType::A2];
|
return [CaseType::A2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isLegacy(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function composedBy(): ?string
|
||||||
|
{
|
||||||
|
return 'inquiry.request';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function presetTemplates(): array
|
||||||
|
{
|
||||||
|
return ['inquiry_answer' => 'inquiry.binding_offer'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function fixes(): array
|
public static function fixes(): array
|
||||||
{
|
{
|
||||||
return ['pre_reservation' => true];
|
return ['pre_reservation' => true];
|
||||||
|
|||||||
@@ -48,6 +48,21 @@ public static function responsibilities(): Responsibilities
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isLegacy(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function composedBy(): ?string
|
||||||
|
{
|
||||||
|
return 'external.booking';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function presetTemplates(): array
|
||||||
|
{
|
||||||
|
return ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function fixes(): array
|
public static function fixes(): array
|
||||||
{
|
{
|
||||||
return ['payments' => 'landlord', 'documents' => 'landlord'];
|
return ['payments' => 'landlord', 'documents' => 'landlord'];
|
||||||
|
|||||||
@@ -48,6 +48,21 @@ public static function responsibilities(): Responsibilities
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isLegacy(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function composedBy(): ?string
|
||||||
|
{
|
||||||
|
return 'external.booking';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function presetTemplates(): array
|
||||||
|
{
|
||||||
|
return ['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.own'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function fixes(): array
|
public static function fixes(): array
|
||||||
{
|
{
|
||||||
return ['payments' => 'portal', 'documents' => 'landlord'];
|
return ['payments' => 'portal', 'documents' => 'landlord'];
|
||||||
|
|||||||
@@ -48,6 +48,21 @@ public static function responsibilities(): Responsibilities
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isLegacy(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function composedBy(): ?string
|
||||||
|
{
|
||||||
|
return 'external.booking';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function presetTemplates(): array
|
||||||
|
{
|
||||||
|
return ['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.external'];
|
||||||
|
}
|
||||||
|
|
||||||
public static function fixes(): array
|
public static function fixes(): array
|
||||||
{
|
{
|
||||||
return ['payments' => 'portal', 'documents' => 'portal'];
|
return ['payments' => 'portal', 'documents' => 'portal'];
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Models;
|
||||||
|
|
||||||
|
use App\Enums\CaseType;
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
use App\Process\Templates\TemplateArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base process of a booking that is already binding at a portal (E-036), with slots for the function templates
|
||||||
|
* of collection and contract documentation. It replaces the fixed combinations A3/A4/A5: who collects and who provides
|
||||||
|
* the contract documents are chosen independently (docs/Prozessarchitektur/SCHABLONEN.md); the case type stays a derived
|
||||||
|
* classification. The course is the one A3–A5 share, with the slots at the positions of the modules they replace.
|
||||||
|
*/
|
||||||
|
class ExternalBookingModel extends ProcessModel
|
||||||
|
{
|
||||||
|
/** Results the base process provides to the templates. */
|
||||||
|
public const PROVIDES = ['case.recorded', 'guest.identified', 'binding.portal_total', 'price.known'];
|
||||||
|
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'external.booking';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Extern verbindliche Portalbuchung';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function description(): string
|
||||||
|
{
|
||||||
|
return 'Das Portal bestätigt verbindlich. Wer das Geld einzieht und wer die Vertragsunterlagen bereitstellt, wählen Sie unabhängig voneinander; die Einzelschritte bleiben einstellbar.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function caseTypes(): array
|
||||||
|
{
|
||||||
|
return [CaseType::A3, CaseType::A4, CaseType::A5];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function intakes(): array
|
||||||
|
{
|
||||||
|
return [IntakeKind::Booking];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collection and contract documentation are chosen by template; guest communication is limited by the portal's
|
||||||
|
* confirmed capability, not by a fixed model.
|
||||||
|
*/
|
||||||
|
public static function responsibilities(): Responsibilities
|
||||||
|
{
|
||||||
|
return Responsibilities::of(
|
||||||
|
fixed: ['contract' => Responsibility::Portal],
|
||||||
|
variable: [
|
||||||
|
'collection' => [Responsibility::Landlord, Responsibility::Portal],
|
||||||
|
'contract_documents' => [Responsibility::Landlord, Responsibility::Portal],
|
||||||
|
'guest_messages' => [Responsibility::Landlord, Responsibility::Portal],
|
||||||
|
'supplementary_documents' => [Responsibility::Landlord, Responsibility::Nobody],
|
||||||
|
'local_services' => [Responsibility::Landlord],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function providedResults(): array
|
||||||
|
{
|
||||||
|
return self::PROVIDES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function defaultTemplates(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
TemplateArea::Collection->value => 'collection.own',
|
||||||
|
TemplateArea::ContractDocuments->value => 'contract_docs.own',
|
||||||
|
TemplateArea::GuestCommunication->value => 'guest_comm.own',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function steps(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Step::module('intake.record'),
|
||||||
|
Step::module('guest.details'),
|
||||||
|
Step::point(Point::AfterGuestIdentified),
|
||||||
|
Step::module('binding.portal'),
|
||||||
|
Step::module('portal.confirmation'),
|
||||||
|
Step::point(Point::AfterBinding),
|
||||||
|
Step::slot(TemplateArea::ContractDocuments),
|
||||||
|
Step::module('channels.block'),
|
||||||
|
Step::slot(TemplateArea::Collection),
|
||||||
|
Step::module('case.tasks'),
|
||||||
|
Step::module('change.proposal'),
|
||||||
|
Step::slot(TemplateArea::GuestCommunication),
|
||||||
|
Step::module('guest.data_request'),
|
||||||
|
Step::point(Point::BeforeStay),
|
||||||
|
Step::module('stay'),
|
||||||
|
Step::module('review.request'),
|
||||||
|
Step::point(Point::BeforeSettlement),
|
||||||
|
Step::module('case.closure'),
|
||||||
|
Step::module('case.settlement'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Models;
|
||||||
|
|
||||||
|
use App\Enums\CaseType;
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
use App\Process\Templates\TemplateArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The base process of a request (own website, portal inquiry, phone, e-mail) – the one course A1 and A2 shared, with
|
||||||
|
* slots for how it is answered (information or binding offer), the contract documentation, the collection and the
|
||||||
|
* guest communication. A1/A2 stay as presets, classification and for historical cases. The reservation is not part
|
||||||
|
* of the answer template: the hold module and the reservation setting stay independent of it (docs/Prozessarchitektur/
|
||||||
|
* SCHABLONENKATALOG.md §4.3).
|
||||||
|
*/
|
||||||
|
class InquiryRequestModel extends ProcessModel
|
||||||
|
{
|
||||||
|
/** Results the base process provides to the templates. */
|
||||||
|
public const PROVIDES = ['case.recorded', 'guest.identified', 'availability.checked', 'price.known'];
|
||||||
|
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'inquiry.request';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Anfrage';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function description(): string
|
||||||
|
{
|
||||||
|
return 'Eine Anfrage – von der eigenen Webseite oder einem Portal. Sie wählen, womit Sie antworten (Auskunft oder verbindliches Angebot) und wer wem schreibt; Datenbeschaffung und Reservierung laufen unabhängig davon.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function caseTypes(): array
|
||||||
|
{
|
||||||
|
return [CaseType::A1, CaseType::A2];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function intakes(): array
|
||||||
|
{
|
||||||
|
return [IntakeKind::Inquiry];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibilities(): Responsibilities
|
||||||
|
{
|
||||||
|
return Responsibilities::of(
|
||||||
|
fixed: ['contract' => Responsibility::Landlord, 'collection' => Responsibility::Landlord, 'contract_documents' => Responsibility::Landlord],
|
||||||
|
variable: [
|
||||||
|
'guest_messages' => [Responsibility::Landlord, Responsibility::Portal],
|
||||||
|
'supplementary_documents' => [Responsibility::Landlord, Responsibility::Nobody],
|
||||||
|
'local_services' => [Responsibility::Landlord],
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function providedResults(): array
|
||||||
|
{
|
||||||
|
return self::PROVIDES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function templateRestrictions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'collection.portal' => 'Bei einer Anfrage schließen wir den Vertrag selbst (Annahme des Angebots) und kassieren selbst; Inkasso beim Portal gibt es nur bei bereits verbindlich gebuchten Portalbuchungen.',
|
||||||
|
'contract_docs.external' => 'Bei einer Anfrage entsteht der Vertrag erst durch unser Angebot und die Annahme des Gastes; das Portal kann keine Vertragsunterlagen dafür bereitstellen.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function defaultTemplates(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
TemplateArea::InquiryAnswer->value => 'inquiry.binding_offer',
|
||||||
|
TemplateArea::ContractDocuments->value => 'contract_docs.own',
|
||||||
|
TemplateArea::Collection->value => 'collection.own',
|
||||||
|
TemplateArea::GuestCommunication->value => 'guest_comm.own',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function steps(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Step::module('intake.record'),
|
||||||
|
Step::module('guest.details'),
|
||||||
|
Step::point(Point::AfterGuestIdentified),
|
||||||
|
Step::module('hold'),
|
||||||
|
Step::module('availability.check'),
|
||||||
|
Step::slot(TemplateArea::InquiryAnswer),
|
||||||
|
Step::point(Point::BeforePriceFixing),
|
||||||
|
Step::module('offer.binding'),
|
||||||
|
Step::point(Point::BeforeBindingOffer),
|
||||||
|
Step::module('offer.acceptance'),
|
||||||
|
Step::point(Point::AfterBinding),
|
||||||
|
Step::slot(TemplateArea::ContractDocuments),
|
||||||
|
Step::module('channels.block'),
|
||||||
|
Step::slot(TemplateArea::Collection),
|
||||||
|
Step::module('case.tasks'),
|
||||||
|
Step::module('change.proposal'),
|
||||||
|
Step::slot(TemplateArea::GuestCommunication),
|
||||||
|
Step::module('guest.data_request'),
|
||||||
|
Step::point(Point::BeforeStay),
|
||||||
|
Step::module('stay'),
|
||||||
|
Step::module('review.request'),
|
||||||
|
Step::point(Point::BeforeSettlement),
|
||||||
|
Step::module('case.closure'),
|
||||||
|
Step::module('case.settlement'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The extension variants of the architecture proof (tester only), as on the former offer model.
|
||||||
|
*
|
||||||
|
* @return list<Variant>
|
||||||
|
*/
|
||||||
|
public function variants(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Variant::make('standard', 'Standard'),
|
||||||
|
Variant::make('loyalty', 'Mit Stammgastrabatt (Architekturnachweis, nur im Prozess-Tester)')
|
||||||
|
->testerOnly()
|
||||||
|
->insert(Point::AfterGuestIdentified, 'guest.loyalty_status')
|
||||||
|
->insert(Point::BeforePriceFixing, 'pricing.loyalty_discount'),
|
||||||
|
Variant::make('address_check', 'Mit Anschriftsprüfung (Zusatzschritt, nur im Prozess-Tester)')
|
||||||
|
->testerOnly()
|
||||||
|
->insert(Point::AfterGuestIdentified, 'guest.address_check'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
use App\Enums\CaseType;
|
use App\Enums\CaseType;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
|
use App\Process\ProcessCatalogue;
|
||||||
|
use App\Process\Templates\TemplateArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A centrally defined, versioned process model (docs/Prozessarchitektur/Architektur/02 §5): its course of steps with
|
* A centrally defined, versioned process model (docs/Prozessarchitektur/Architektur/02 §5): its course of steps with
|
||||||
@@ -74,17 +76,92 @@ public function variant(string $key): ?Variant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The modules of the course in order, with the variant's modules at their points.
|
* The function template areas this model offers a slot for (empty: the model's course is fixed).
|
||||||
|
*
|
||||||
|
* @return list<TemplateArea>
|
||||||
|
*/
|
||||||
|
public function slots(): array
|
||||||
|
{
|
||||||
|
return array_values(array_map(fn (Step $step): TemplateArea => $step->slot, array_filter($this->steps(), fn (Step $step): bool => $step->isSlot())));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Templates a model does not take, with the business reason (template key => reason). Everything not listed fits.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function templateRestrictions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For a legacy model: the key of the base process whose template combination it reproduces.
|
||||||
|
*/
|
||||||
|
public static function composedBy(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The results the base course provides to the templates of its slots (see FunctionTemplate::requires()).
|
||||||
*
|
*
|
||||||
* @return list<string>
|
* @return list<string>
|
||||||
*/
|
*/
|
||||||
public function modules(?string $variant = 'standard'): array
|
public static function providedResults(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The template (key) every slot gets when none was chosen: area value => template key.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function defaultTemplates(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the model is kept for compatibility (existing channels and frozen plans) and no longer offered as a
|
||||||
|
* choice: its combination is a preset of a composable model.
|
||||||
|
*/
|
||||||
|
public static function isLegacy(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The template combination that reproduces this legacy model (area value => template key), or empty.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function presetTemplates(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The modules of the course in order, with the variant's modules at their points and the chosen templates' modules
|
||||||
|
* at their slots.
|
||||||
|
*
|
||||||
|
* @param array<string, string> $templates area value => template key or key@version (missing areas: the default)
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function modules(?string $variant = 'standard', array $templates = []): array
|
||||||
{
|
{
|
||||||
$chosen = $this->variant($variant ?? 'standard');
|
$chosen = $this->variant($variant ?? 'standard');
|
||||||
|
$catalogue = app(ProcessCatalogue::class);
|
||||||
$modules = [];
|
$modules = [];
|
||||||
foreach ($this->steps() as $step) {
|
foreach ($this->steps() as $step) {
|
||||||
if ($step->isPoint()) {
|
if ($step->isPoint()) {
|
||||||
array_push($modules, ...($chosen?->modulesAt($step->point) ?? []));
|
array_push($modules, ...($chosen?->modulesAt($step->point) ?? []));
|
||||||
|
} elseif ($step->isSlot()) {
|
||||||
|
$reference = $templates[$step->slot->value] ?? static::defaultTemplates()[$step->slot->value] ?? null;
|
||||||
|
if ($reference !== null && ($class = $catalogue->templateClass($reference)) !== null) {
|
||||||
|
array_push($modules, ...$class::modules());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$modules[] = $step->module;
|
$modules[] = $step->module;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,15 @@
|
|||||||
|
|
||||||
namespace App\Process\Models;
|
namespace App\Process\Models;
|
||||||
|
|
||||||
|
use App\Process\Templates\TemplateArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One entry of a model's course: a module or an extension point where variants insert modules.
|
* One entry of a model's course: a module, an extension point where variants insert modules, or a slot where the
|
||||||
|
* function template chosen for its area puts its modules.
|
||||||
*/
|
*/
|
||||||
final readonly class Step
|
final readonly class Step
|
||||||
{
|
{
|
||||||
private function __construct(public ?string $module, public ?Point $point) {}
|
private function __construct(public ?string $module, public ?Point $point, public ?TemplateArea $slot = null) {}
|
||||||
|
|
||||||
public static function module(string $key): self
|
public static function module(string $key): self
|
||||||
{
|
{
|
||||||
@@ -19,8 +22,18 @@ public static function point(Point $point): self
|
|||||||
return new self(null, $point);
|
return new self(null, $point);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function slot(TemplateArea $area): self
|
||||||
|
{
|
||||||
|
return new self(null, null, $area);
|
||||||
|
}
|
||||||
|
|
||||||
public function isPoint(): bool
|
public function isPoint(): bool
|
||||||
{
|
{
|
||||||
return $this->point !== null;
|
return $this->point !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isSlot(): bool
|
||||||
|
{
|
||||||
|
return $this->slot !== null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Enums\ActivityState;
|
use App\Enums\ActivityState;
|
||||||
use App\Enums\Execution;
|
use App\Enums\Execution;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
use App\Enums\Responsibility;
|
use App\Enums\Responsibility;
|
||||||
use App\Models\DataRequest;
|
use App\Models\DataRequest;
|
||||||
@@ -49,7 +50,7 @@ public function applies(CaseContext $case): bool
|
|||||||
{
|
{
|
||||||
$profile = $case->profile;
|
$profile = $case->profile;
|
||||||
|
|
||||||
return $case->inquiry || $profile->documents() === Responsibility::Landlord || $profile->guestMessages() === Responsibility::Landlord || $profile->payments() === Responsibility::Landlord;
|
return $case->inquiry || $profile->documents() === Responsibility::Landlord || $profile->guestMessages() === Responsibility::Landlord || $profile->arrivalInfoSender() === Responsibility::Landlord || $profile->reviewRequestSender() === Responsibility::Landlord || $profile->payments() === Responsibility::Landlord;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activities(CaseContext $case): array
|
public function activities(CaseContext $case): array
|
||||||
@@ -58,7 +59,7 @@ public function activities(CaseContext $case): array
|
|||||||
$profile = $case->profile;
|
$profile = $case->profile;
|
||||||
$hasEmail = filled($booking->guest?->email);
|
$hasEmail = filled($booking->guest?->email);
|
||||||
// v0.11 (G2a): before the own binding offer – or the binding confirmation of a wish – every required detail.
|
// 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;
|
$action = $profile->inquiryAnswer() === InquiryAnswer::Offer || $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);
|
$needsDetails = $case->inquiry && ! $case->binding && $booking->offer_version === 0 && ($action === CaseRequirements::OFFER || $booking->wish_at !== null);
|
||||||
$missing = $hasEmail && $needsDetails ? CaseRequirements::missing($booking, $action) : [];
|
$missing = $hasEmail && $needsDetails ? CaseRequirements::missing($booking, $action) : [];
|
||||||
$request = $booking->openDataRequest();
|
$request = $booking->openDataRequest();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Enums\ActivityState;
|
use App\Enums\ActivityState;
|
||||||
use App\Enums\BookingStatus;
|
use App\Enums\BookingStatus;
|
||||||
use App\Enums\Execution;
|
use App\Enums\Execution;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\ProcessingMode;
|
use App\Enums\ProcessingMode;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
use App\Process\Activity;
|
use App\Process\Activity;
|
||||||
@@ -59,7 +60,7 @@ public static function definition(): ModuleDefinition
|
|||||||
/** The binding way: the request reserves (pre-reservation) or an offer was made anyway. */
|
/** The binding way: the request reserves (pre-reservation) or an offer was made anyway. */
|
||||||
public function applies(CaseContext $case): bool
|
public function applies(CaseContext $case): bool
|
||||||
{
|
{
|
||||||
return $case->inquiry && ! ($case->profile->preReservation() === false && $case->booking->offer_version === 0);
|
return $case->inquiry && ! ($case->profile->inquiryAnswer() === InquiryAnswer::Information && $case->booking->offer_version === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activities(CaseContext $case): array
|
public function activities(CaseContext $case): array
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
use App\Enums\ActivityState;
|
use App\Enums\ActivityState;
|
||||||
use App\Enums\BookingStatus;
|
use App\Enums\BookingStatus;
|
||||||
use App\Enums\Execution;
|
use App\Enums\Execution;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\ProcessingMode;
|
use App\Enums\ProcessingMode;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
use App\Process\Activity;
|
use App\Process\Activity;
|
||||||
@@ -49,7 +50,7 @@ public static function definition(): ModuleDefinition
|
|||||||
|
|
||||||
public function applies(CaseContext $case): bool
|
public function applies(CaseContext $case): bool
|
||||||
{
|
{
|
||||||
return $case->inquiry && ! $case->profile->preReservation() && $case->booking->offer_version === 0;
|
return $case->inquiry && $case->profile->inquiryAnswer() === InquiryAnswer::Information && $case->booking->offer_version === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activities(CaseContext $case): array
|
public function activities(CaseContext $case): array
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public static function definition(): ModuleDefinition
|
|||||||
effects: ['guest_mail'],
|
effects: ['guest_mail'],
|
||||||
waits: ['time', 'portal'],
|
waits: ['time', 'portal'],
|
||||||
triggers: ['schedule:reminders'],
|
triggers: ['schedule:reminders'],
|
||||||
parameters: [ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoDaysBefore],
|
parameters: [ProcessSetting::ArrivalInfoSender, ProcessSetting::ArrivalInfoDaysBefore],
|
||||||
performers: ['system', 'portal', 'service_provider'],
|
performers: ['system', 'portal', 'service_provider'],
|
||||||
events: ['document', 'mail'],
|
events: ['document', 'mail'],
|
||||||
);
|
);
|
||||||
@@ -45,7 +45,7 @@ public function activities(CaseContext $case): array
|
|||||||
$booking = $case->booking;
|
$booking = $case->booking;
|
||||||
$profile = $case->profile;
|
$profile = $case->profile;
|
||||||
|
|
||||||
return [$profile->guestMessages() === Responsibility::Portal
|
return [$profile->arrivalInfoSender() === Responsibility::Portal
|
||||||
? new Activity('arrival_info', 'Anreise-Informationen an den Gast', ActivityState::External, 'durch '.($booking->processChannel()?->name ?? 'das Portal').' (angekündigt) – eine Zustellung ist damit nicht nachgewiesen')
|
? new Activity('arrival_info', 'Anreise-Informationen an den Gast', ActivityState::External, 'durch '.($booking->processChannel()?->name ?? 'das Portal').' (angekündigt) – eine Zustellung ist damit nicht nachgewiesen')
|
||||||
: new Activity('arrival_info', 'Anreise-Informationen an den Gast (automatisch)', $case->later($booking->arrival_info_sent_at !== null ? ActivityState::Done : ActivityState::Later), $booking->arrival_info_sent_at ? 'gesendet am '.$booking->arrival_info_sent_at->format('d.m.Y') : $profile->arrivalInfoDaysBefore().' Tage vor Anreise')];
|
: new Activity('arrival_info', 'Anreise-Informationen an den Gast (automatisch)', $case->later($booking->arrival_info_sent_at !== null ? ActivityState::Done : ActivityState::Later), $booking->arrival_info_sent_at ? 'gesendet am '.$booking->arrival_info_sent_at->format('d.m.Y') : $profile->arrivalInfoDaysBefore().' Tage vor Anreise')];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Enums\ActivityState;
|
use App\Enums\ActivityState;
|
||||||
use App\Enums\Execution;
|
use App\Enums\Execution;
|
||||||
|
use App\Enums\ProcessSetting;
|
||||||
use App\Enums\Responsibility;
|
use App\Enums\Responsibility;
|
||||||
use App\Process\Activity;
|
use App\Process\Activity;
|
||||||
use App\Process\CaseContext;
|
use App\Process\CaseContext;
|
||||||
@@ -35,6 +36,7 @@ public static function definition(): ModuleDefinition
|
|||||||
waits: ['time'],
|
waits: ['time'],
|
||||||
triggers: ['schedule:reviews'],
|
triggers: ['schedule:reviews'],
|
||||||
toggle: ModuleDefinition::TOGGLE_OPTIONAL,
|
toggle: ModuleDefinition::TOGGLE_OPTIONAL,
|
||||||
|
parameters: [ProcessSetting::ReviewRequestSender],
|
||||||
performers: ['system'],
|
performers: ['system'],
|
||||||
events: ['mail'],
|
events: ['mail'],
|
||||||
);
|
);
|
||||||
@@ -42,7 +44,7 @@ public static function definition(): ModuleDefinition
|
|||||||
|
|
||||||
public function applies(CaseContext $case): bool
|
public function applies(CaseContext $case): bool
|
||||||
{
|
{
|
||||||
return $case->profile->guestMessages() === Responsibility::Landlord && ! $case->booking->isInternal();
|
return $case->profile->reviewRequestSender() === Responsibility::Landlord && ! $case->booking->isInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function activities(CaseContext $case): array
|
public function activities(CaseContext $case): array
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process;
|
||||||
|
|
||||||
|
use App\Enums\ProcessSetting;
|
||||||
|
use App\Process\Modules\ModuleDefinition;
|
||||||
|
use App\Process\Templates\TemplateArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The business blocks of a resolved course (docs/Prozessarchitektur P01–P05) as the configurator's main view shows them:
|
||||||
|
* a grouping of modules for the reader, nothing more. What a block depends on is derived from the hard and soft
|
||||||
|
* dependencies of the modules that are really in the plan and apply (the facts the {@see ProcessRunner} uses, the same
|
||||||
|
* as {@see ProcessLanes}) – there is no hand-written order between blocks and no arrow between merely adjacent phases.
|
||||||
|
* Pure: it reads, it never changes anything.
|
||||||
|
*/
|
||||||
|
final class ProcessBlocks
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Grouping of the modules and the settings a block reports. A module that is in no block would show up under "other",
|
||||||
|
* so a new module is never lost (a test keeps the catalogue and this table in step).
|
||||||
|
*
|
||||||
|
* @var array<string, array{label: string, phase: string, area: ?TemplateArea, modules: list<string>, settings: list<ProcessSetting>}>
|
||||||
|
*/
|
||||||
|
public const BLOCKS = [
|
||||||
|
'intake' => ['label' => 'Eingang und Gastdaten', 'phase' => 'P01', 'area' => null,
|
||||||
|
'modules' => ['intake.record', 'guest.details', 'guest.data_request', 'guest.address_check', 'guest.loyalty_status', 'pricing.loyalty_discount'],
|
||||||
|
'settings' => [ProcessSetting::FormRequiresAddress, ProcessSetting::DataRequest, ProcessSetting::DataRequestReminderHours]],
|
||||||
|
'availability' => ['label' => 'Verfügbarkeit und Reservierung', 'phase' => 'P01', 'area' => null,
|
||||||
|
'modules' => ['availability.check', 'hold', 'binding.portal', 'channels.block'],
|
||||||
|
'settings' => [ProcessSetting::PreReservation, ProcessSetting::HoldHours, ProcessSetting::ClarificationHoldAutoMinutes]],
|
||||||
|
'answer' => ['label' => 'Antwort und Angebot', 'phase' => 'P02', 'area' => TemplateArea::InquiryAnswer,
|
||||||
|
'modules' => ['offer.information', 'offer.binding', 'offer.acceptance'],
|
||||||
|
'settings' => [ProcessSetting::InquiryAnswer, ProcessSetting::Processing, ProcessSetting::GuestLinkValidDays]],
|
||||||
|
'portal_wait' => ['label' => 'Bestätigung des Portals', 'phase' => 'P02', 'area' => null,
|
||||||
|
'modules' => ['portal.confirmation'],
|
||||||
|
'settings' => [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours]],
|
||||||
|
'documents' => ['label' => 'Dokumentation', 'phase' => 'P03', 'area' => TemplateArea::ContractDocuments,
|
||||||
|
'modules' => ['documents.send', 'documents.booking_notice', 'documents.stay_confirmation'],
|
||||||
|
'settings' => [ProcessSetting::Documents, ProcessSetting::ContractDelivery, ProcessSetting::BookingNotice, ProcessSetting::ContractTemplate]],
|
||||||
|
'finance' => ['label' => 'Finanzabwicklung', 'phase' => 'P03', 'area' => TemplateArea::Collection,
|
||||||
|
'modules' => ['payments.monitor', 'payments.internal', 'portal.payout'],
|
||||||
|
'settings' => [ProcessSetting::Payments]],
|
||||||
|
'communication' => ['label' => 'Gastkommunikation und Aufenthalt', 'phase' => 'P04', 'area' => TemplateArea::GuestCommunication,
|
||||||
|
'modules' => ['arrival.details', 'arrival.info', 'stay', 'review.request'],
|
||||||
|
'settings' => [ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoSender, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ReviewRequestSender]],
|
||||||
|
'closure' => ['label' => 'Aufgaben und Abschluss', 'phase' => 'P05', 'area' => null,
|
||||||
|
'modules' => ['case.tasks', 'change.proposal', 'case.closure', 'case.settlement'],
|
||||||
|
'settings' => []],
|
||||||
|
];
|
||||||
|
|
||||||
|
public const OTHER = 'other';
|
||||||
|
|
||||||
|
public function __construct(private ProcessCatalogue $catalogue) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The blocks of the course the preview rows describe. A block without a step in the plan is left out.
|
||||||
|
*
|
||||||
|
* @param list<array{module: string, label: string, on: bool, reason: ?string, template: ?string}> $rows ChannelProcessConfiguration::preview
|
||||||
|
* @return array<string, array{key: string, label: string, phase: string, area: ?TemplateArea, settings: list<ProcessSetting>, modules: list<array{module: string, label: string, on: bool, reason: ?string, template: ?string}>, active: bool, waits_for: list<array{block: string, label: string, steps: list<string>}>, after: list<array{block: string, label: string}>, independent: bool, events: list<string>, scheduled: list<string>, conditional: list<array{label: string, reason: ?string}>, may_wait: list<string>}>
|
||||||
|
*/
|
||||||
|
public function of(array $rows): array
|
||||||
|
{
|
||||||
|
$blockOf = [];
|
||||||
|
foreach (self::BLOCKS as $key => $block) {
|
||||||
|
foreach ($block['modules'] as $module) {
|
||||||
|
$blockOf[$module] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$other = ['label' => 'Weitere Schritte', 'phase' => 'P03', 'area' => null, 'modules' => [], 'settings' => []];
|
||||||
|
$blocks = [];
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$key = $blockOf[$row['module']] ?? self::OTHER;
|
||||||
|
$blocks[$key] ??= [...(self::BLOCKS[$key] ?? $other), 'key' => $key, 'modules' => []];
|
||||||
|
$blocks[$key]['modules'][] = $row;
|
||||||
|
}
|
||||||
|
// Presentation order is the table's, the plan decides which blocks exist.
|
||||||
|
$blocks = array_merge(array_intersect_key(array_flip([...array_keys(self::BLOCKS), self::OTHER]), $blocks), $blocks);
|
||||||
|
|
||||||
|
$active = [];
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($row['on']) {
|
||||||
|
$active[$row['module']] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($blocks as $key => &$block) {
|
||||||
|
$block['active'] = collect($block['modules'])->contains('on', true);
|
||||||
|
$block = [...$block, 'waits_for' => [], 'after' => [], 'events' => [], 'scheduled' => [], 'conditional' => [], 'may_wait' => []];
|
||||||
|
foreach ($block['modules'] as $row) {
|
||||||
|
$definition = $this->catalogue->modules()[$row['module']]::definition();
|
||||||
|
if (! $row['on']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach ($definition->requires as $dependency) {
|
||||||
|
$targetBlock = $blockOf[$dependency->module] ?? self::OTHER;
|
||||||
|
if ($dependency->module === 'intake.record' || ! isset($active[$dependency->module]) || $targetBlock === $key) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$list = $dependency->hard ? 'waits_for' : 'after';
|
||||||
|
$label = $blocks[$targetBlock]['label'] ?? self::BLOCKS[$targetBlock]['label'] ?? $other['label'];
|
||||||
|
$entry = $block[$list][$targetBlock] ?? ['block' => $targetBlock, 'label' => $label, 'steps' => []];
|
||||||
|
$entry['steps'][] = $active[$dependency->module]['label'];
|
||||||
|
$block[$list][$targetBlock] = $entry;
|
||||||
|
}
|
||||||
|
if ($definition->toggle === ModuleDefinition::TOGGLE_EVENT_DRIVEN) {
|
||||||
|
$block['events'][] = $row['label'];
|
||||||
|
} elseif ($definition->triggers !== [] && collect($definition->triggers)->every(fn (string $trigger): bool => str_starts_with($trigger, 'schedule:'))) {
|
||||||
|
$block['scheduled'][] = $row['label'];
|
||||||
|
}
|
||||||
|
if ($definition->toggle === ModuleDefinition::TOGGLE_CONDITIONAL) {
|
||||||
|
$block['conditional'][] = ['label' => $row['label'], 'reason' => $definition->condition];
|
||||||
|
}
|
||||||
|
foreach ($definition->waits as $wait) {
|
||||||
|
$block['may_wait'][] = ['guest' => 'den Gast', 'portal' => 'das Portal', 'landlord' => 'Sie', 'time' => 'eine Frist'][$wait] ?? $wait;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$block['waits_for'] = array_values($block['waits_for']);
|
||||||
|
$block['after'] = array_values($block['after']);
|
||||||
|
$block['may_wait'] = array_values(array_unique($block['may_wait']));
|
||||||
|
$block['independent'] = $block['active'] && $block['waits_for'] === [];
|
||||||
|
}
|
||||||
|
unset($block);
|
||||||
|
|
||||||
|
return $blocks;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,10 +3,13 @@
|
|||||||
namespace App\Process;
|
namespace App\Process;
|
||||||
|
|
||||||
use App\Enums\CaseType;
|
use App\Enums\CaseType;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Process\Models\ProcessModel;
|
use App\Process\Models\ProcessModel;
|
||||||
use App\Process\Modules\ProcessModule;
|
use App\Process\Modules\ProcessModule;
|
||||||
use App\Process\Modules\RunsAutomatically;
|
use App\Process\Modules\RunsAutomatically;
|
||||||
|
use App\Process\Templates\FunctionTemplate;
|
||||||
|
use App\Process\Templates\TemplateArea;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,6 +100,53 @@ public function models(): array
|
|||||||
return $models;
|
return $models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<int, class-string<FunctionTemplate>>>
|
||||||
|
*/
|
||||||
|
public function templateVersions(): array
|
||||||
|
{
|
||||||
|
return (array) config('process.templates', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class of a template named by key (latest version) or key@version; null when it is not registered.
|
||||||
|
*
|
||||||
|
* @return class-string<FunctionTemplate>|null
|
||||||
|
*/
|
||||||
|
public function templateClass(string $reference): ?string
|
||||||
|
{
|
||||||
|
[$key, $version] = array_pad(explode('@', $reference, 2), 2, null);
|
||||||
|
$versions = $this->templateVersions()[$key] ?? [];
|
||||||
|
if ($versions === []) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $versions[$version === null ? max(array_keys($versions)) : (int) $version] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasTemplate(string $reference): bool
|
||||||
|
{
|
||||||
|
return $this->templateClass($reference) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The latest version of every template, optionally of one area.
|
||||||
|
*
|
||||||
|
* @return array<string, class-string<FunctionTemplate>>
|
||||||
|
*/
|
||||||
|
public function templates(?TemplateArea $area = null): array
|
||||||
|
{
|
||||||
|
$templates = [];
|
||||||
|
foreach (array_keys($this->templateVersions()) as $key) {
|
||||||
|
$class = $this->templateClass($key);
|
||||||
|
if ($area === null || $class::area() === $area) {
|
||||||
|
$templates[$key] = $class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $templates;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model a case follows when nobody chose one: derived from its frozen profile exactly as the v0.11 course
|
* The model a case follows when nobody chose one: derived from its frozen profile exactly as the v0.11 course
|
||||||
* branched (legacy mapping, docs/Prozessarchitektur/Architektur/06 §4).
|
* branched (legacy mapping, docs/Prozessarchitektur/Architektur/06 §4).
|
||||||
@@ -105,7 +155,7 @@ public function derivedModel(ProcessProfile $profile): string
|
|||||||
{
|
{
|
||||||
return match ($profile->intake) {
|
return match ($profile->intake) {
|
||||||
IntakeKind::Internal => 'a6.internal',
|
IntakeKind::Internal => 'a6.internal',
|
||||||
IntakeKind::Inquiry => ($profile->caseType === CaseType::A2 ? 'a2' : 'a1').($profile->preReservation() ? '.offer' : '.information'),
|
IntakeKind::Inquiry => ($profile->caseType === CaseType::A2 ? 'a2' : 'a1').($profile->inquiryAnswer() === InquiryAnswer::Offer ? '.offer' : '.information'),
|
||||||
IntakeKind::Booking => match ($profile->caseType) {
|
IntakeKind::Booking => match ($profile->caseType) {
|
||||||
CaseType::A5 => 'a5.portal_booking',
|
CaseType::A5 => 'a5.portal_booking',
|
||||||
CaseType::A4 => 'a4.portal_booking',
|
CaseType::A4 => 'a4.portal_booking',
|
||||||
@@ -151,12 +201,48 @@ public function problems(): array
|
|||||||
$problems[] = 'Zyklische harte Abhängigkeit: '.implode(' → ', $cycle);
|
$problems[] = 'Zyklische harte Abhängigkeit: '.implode(' → ', $cycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->templateVersions() as $key => $versions) {
|
||||||
|
foreach ($versions as $version => $class) {
|
||||||
|
if ($class::key() !== $key || $class::version() !== $version) {
|
||||||
|
$problems[] = "Schablone {$key}@{$version}: Klasse {$class} meldet ".$class::reference().'.';
|
||||||
|
}
|
||||||
|
foreach ($class::modules() as $module) {
|
||||||
|
if (! $this->hasModule($module)) {
|
||||||
|
$problems[] = "Schablone {$class::reference()}: Modul {$module} ist nicht registriert.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! in_array($class::area()->result(), $class::provides(), true)) {
|
||||||
|
$problems[] = "Schablone {$class::reference()}: liefert das Ergebnis ihres Bereichs ({$class::area()->result()}) nicht.";
|
||||||
|
}
|
||||||
|
$allowed = array_map(fn ($setting): string => $setting->value, $class::area()->settings());
|
||||||
|
if (array_diff([...array_keys($class::fixes()), ...array_keys($class::defaults())], $allowed) !== []) {
|
||||||
|
$problems[] = "Schablone {$class::reference()}: darf nur Einstellungen ihres Bereichs ({$class::area()->label()}) festlegen oder vorschlagen.";
|
||||||
|
}
|
||||||
|
foreach ($class::configures() as $module) {
|
||||||
|
if (! $this->hasModule($module)) {
|
||||||
|
$problems[] = "Schablone {$class::reference()}: konfiguriertes Modul {$module} ist nicht registriert.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->modelVersions() as $key => $versions) {
|
foreach ($this->modelVersions() as $key => $versions) {
|
||||||
foreach ($versions as $version => $class) {
|
foreach ($versions as $version => $class) {
|
||||||
if ($class::key() !== $key || $class::version() !== $version) {
|
if ($class::key() !== $key || $class::version() !== $version) {
|
||||||
$problems[] = "Modell {$key}@{$version}: Klasse {$class} meldet ".$class::key().'@'.$class::version().'.';
|
$problems[] = "Modell {$key}@{$version}: Klasse {$class} meldet ".$class::key().'@'.$class::version().'.';
|
||||||
}
|
}
|
||||||
$model = app($class);
|
$model = app($class);
|
||||||
|
foreach ($model->slots() as $area) {
|
||||||
|
$default = $class::defaultTemplates()[$area->value] ?? null;
|
||||||
|
if ($default === null || ! $this->hasTemplate($default) || $this->templateClass($default)::area() !== $area) {
|
||||||
|
$problems[] = "Modell {$key}@{$version}: Platz {$area->value} hat keine gültige Standardschablone.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($class::presetTemplates() as $area => $reference) {
|
||||||
|
if (! $this->hasTemplate($reference) || $this->templateClass($reference)::area()->value !== $area) {
|
||||||
|
$problems[] = "Modell {$key}@{$version}: Voreinstellung {$area} nennt die Schablone {$reference} nicht (richtig).";
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach ($model->variants() as $variant) {
|
foreach ($model->variants() as $variant) {
|
||||||
foreach ($model->modules($variant->key) as $module) {
|
foreach ($model->modules($variant->key) as $module) {
|
||||||
if (! $this->hasModule($module)) {
|
if (! $this->hasModule($module)) {
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process;
|
||||||
|
|
||||||
|
use App\Process\Modules\ModuleDefinition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The course of a resolved plan as the runner executes it: which steps start at once and run in parallel, which wait
|
||||||
|
* for others, which are conditional, event-driven or time-driven. Derived only from the same facts the
|
||||||
|
* {@see ProcessRunner} uses – the hard dependencies among the steps that are in the plan and apply, `applies()` (as the
|
||||||
|
* preview row's reason), the trigger kinds and what a step waits for. No grouping by phase, no hand-written text.
|
||||||
|
* Pure: it reads, it never changes anything.
|
||||||
|
*/
|
||||||
|
final class ProcessLanes
|
||||||
|
{
|
||||||
|
public function __construct(private ProcessCatalogue $catalogue) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array{module: string, label: string, on: bool, reason: ?string}> $rows the preview rows of a draft (ChannelProcessConfiguration::preview)
|
||||||
|
* @return array{parallel: list<array{module: string, label: string, note: ?string}>, waiting: list<array{module: string, label: string, note: ?string, after: list<string>}>, event: list<array{module: string, label: string, note: ?string}>, later: list<array{module: string, label: string, note: ?string}>, off: list<array{module: string, label: string, note: ?string}>}
|
||||||
|
*/
|
||||||
|
public function of(array $rows): array
|
||||||
|
{
|
||||||
|
$active = [];
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($row['on']) {
|
||||||
|
$active[$row['module']] = $row['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$lanes = ['parallel' => [], 'waiting' => [], 'event' => [], 'later' => [], 'off' => []];
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$definition = $this->catalogue->modules()[$row['module']]::definition();
|
||||||
|
if (! $row['on']) {
|
||||||
|
$lanes['off'][] = ['module' => $row['module'], 'label' => $row['label'], 'note' => $row['reason']];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($row['module'] === 'intake.record') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$hard = array_values(array_map(fn ($dependency): string => $active[$dependency->module], array_filter($definition->requires, fn ($dependency): bool => $dependency->hard && $dependency->module !== 'intake.record' && isset($active[$dependency->module]))));
|
||||||
|
$item = ['module' => $row['module'], 'label' => $row['label'], 'note' => $this->note($definition)];
|
||||||
|
|
||||||
|
$lanes[match (true) {
|
||||||
|
$hard !== [] => 'waiting',
|
||||||
|
$definition->toggle === ModuleDefinition::TOGGLE_EVENT_DRIVEN => 'event',
|
||||||
|
$definition->triggers !== [] && collect($definition->triggers)->every(fn (string $trigger): bool => str_starts_with($trigger, 'schedule:')) => 'later',
|
||||||
|
default => 'parallel',
|
||||||
|
}][] = $hard !== [] ? [...$item, 'after' => $hard] : $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lanes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function note(ModuleDefinition $definition): ?string
|
||||||
|
{
|
||||||
|
$waits = array_map(fn (string $wait): string => ['guest' => 'den Gast', 'portal' => 'das Portal', 'landlord' => 'Sie', 'time' => 'eine Frist'][$wait] ?? $wait, $definition->waits);
|
||||||
|
|
||||||
|
return $waits === [] ? null : 'kann warten auf '.implode(', ', $waits);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Models\Booking;
|
use App\Models\Booking;
|
||||||
use App\Models\Channel;
|
use App\Models\Channel;
|
||||||
use App\Process\Models\ProcessModel;
|
use App\Process\Models\ProcessModel;
|
||||||
|
use App\Process\Templates\TemplateComposer;
|
||||||
use DomainException;
|
use DomainException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,6 +28,7 @@ final class ProcessPlan
|
|||||||
* @param array<string, int> $modules module key => frozen version
|
* @param array<string, int> $modules module key => frozen version
|
||||||
* @param array<string, array{on?: bool, mode?: ?string, performer?: ?string, params?: array<string, mixed>}> $steps
|
* @param array<string, array{on?: bool, mode?: ?string, performer?: ?string, params?: array<string, mixed>}> $steps
|
||||||
* @param array<string, string> $labels module key => label at the time of freezing
|
* @param array<string, string> $labels module key => label at the time of freezing
|
||||||
|
* @param array<string, string> $templates area => function template key@version the plan was composed with
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public readonly string $model,
|
public readonly string $model,
|
||||||
@@ -37,6 +39,7 @@ public function __construct(
|
|||||||
public readonly string $source = self::DERIVED,
|
public readonly string $source = self::DERIVED,
|
||||||
public readonly array $labels = [],
|
public readonly array $labels = [],
|
||||||
public readonly ?string $notice = null,
|
public readonly ?string $notice = null,
|
||||||
|
public readonly array $templates = [],
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,7 +67,7 @@ public static function derive(ProcessProfile $profile): self
|
|||||||
* Ablauf), when admissible for the case's type; otherwise the derived one with a notice. Tester-only variants or
|
* Ablauf), when admissible for the case's type; otherwise the derived one with a notice. Tester-only variants or
|
||||||
* modules are refused outside the process tester (decision E7).
|
* modules are refused outside the process tester (decision E7).
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $configuration model, variant, steps of channels.process_overrides[intake]
|
* @param array<string, mixed> $configuration model, variant, steps, templates of channels.process_overrides[intake]
|
||||||
*/
|
*/
|
||||||
public static function freeze(ProcessProfile $profile, array $configuration, bool $sandbox = false): self
|
public static function freeze(ProcessProfile $profile, array $configuration, bool $sandbox = false): self
|
||||||
{
|
{
|
||||||
@@ -96,7 +99,16 @@ public static function freeze(ProcessProfile $profile, array $configuration, boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::build($model, $variant, (array) ($configuration['steps'] ?? []), $sandbox ? self::TESTER : self::CONFIGURED);
|
$templates = [];
|
||||||
|
if ($model->slots() !== []) {
|
||||||
|
$composer = app(TemplateComposer::class);
|
||||||
|
$templates = $composer->resolve($model, (array) ($configuration['templates'] ?? []));
|
||||||
|
if (($problems = $composer->problems($model, $templates, $variant)) !== []) {
|
||||||
|
return self::derive($profile)->withNotice("Schablonen von {$chosen} nicht zulässig (".implode(' ', $problems).') – abgeleitetes Modell verwendet.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::build($model, $variant, (array) ($configuration['steps'] ?? []), $sandbox ? self::TESTER : self::CONFIGURED, $templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,29 +122,30 @@ public static function configurationOf(?Channel $channel, IntakeKind $intake): a
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_intersect_key((array) (($channel->process_overrides ?? [])[$intake->value] ?? []), array_flip(['model', 'variant', 'steps']));
|
return array_intersect_key((array) (($channel->process_overrides ?? [])[$intake->value] ?? []), array_flip(['model', 'variant', 'steps', 'templates']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $steps
|
* @param array<string, mixed> $steps
|
||||||
|
* @param array<string, string> $templates area => key@version
|
||||||
*/
|
*/
|
||||||
private static function build(ProcessModel $model, string $variant, array $steps, string $source): self
|
private static function build(ProcessModel $model, string $variant, array $steps, string $source, array $templates = []): self
|
||||||
{
|
{
|
||||||
$catalogue = app(ProcessCatalogue::class);
|
$catalogue = app(ProcessCatalogue::class);
|
||||||
$modules = [];
|
$modules = [];
|
||||||
$labels = [];
|
$labels = [];
|
||||||
foreach ($model->modules($variant) as $key) {
|
foreach ($model->modules($variant, $templates) as $key) {
|
||||||
$class = $catalogue->modules()[$key];
|
$class = $catalogue->modules()[$key];
|
||||||
$modules[$key] = $class::version();
|
$modules[$key] = $class::version();
|
||||||
$labels[$key] = $class::definition()->label;
|
$labels[$key] = $class::definition()->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new self($model::key(), $model::version(), $variant, $modules, array_intersect_key($steps, $modules), $source, $labels);
|
return new self($model::key(), $model::version(), $variant, $modules, array_intersect_key($steps, $modules), $source, $labels, null, $templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function withNotice(string $notice): self
|
private function withNotice(string $notice): self
|
||||||
{
|
{
|
||||||
return new self($this->model, $this->modelVersion, $this->variant, $this->modules, $this->steps, $this->source, $this->labels, $notice);
|
return new self($this->model, $this->modelVersion, $this->variant, $this->modules, $this->steps, $this->source, $this->labels, $notice, $this->templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function modelDefinition(): ProcessModel
|
public function modelDefinition(): ProcessModel
|
||||||
@@ -204,6 +217,7 @@ public function toArray(): array
|
|||||||
'source' => $this->source,
|
'source' => $this->source,
|
||||||
'labels' => $this->labels,
|
'labels' => $this->labels,
|
||||||
'notice' => $this->notice,
|
'notice' => $this->notice,
|
||||||
|
'templates' => $this->templates === [] ? null : $this->templates,
|
||||||
], fn (mixed $value): bool => $value !== null);
|
], fn (mixed $value): bool => $value !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +235,7 @@ public static function fromArray(array $data): self
|
|||||||
(string) ($data['source'] ?? self::DERIVED),
|
(string) ($data['source'] ?? self::DERIVED),
|
||||||
(array) ($data['labels'] ?? []),
|
(array) ($data['labels'] ?? []),
|
||||||
isset($data['notice']) ? (string) $data['notice'] : null,
|
isset($data['notice']) ? (string) $data['notice'] : null,
|
||||||
|
array_map('strval', (array) ($data['templates'] ?? [])),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Enums\CaseType;
|
use App\Enums\CaseType;
|
||||||
use App\Enums\ContractDelivery;
|
use App\Enums\ContractDelivery;
|
||||||
use App\Enums\DataRequestMode;
|
use App\Enums\DataRequestMode;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Enums\ProcessingMode;
|
use App\Enums\ProcessingMode;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
@@ -32,6 +33,15 @@ final class ProcessProfile
|
|||||||
/** Fixed by the process model chosen for the channel (Architektur V2). */
|
/** Fixed by the process model chosen for the channel (Architektur V2). */
|
||||||
public const MODEL = 'model';
|
public const MODEL = 'model';
|
||||||
|
|
||||||
|
/** Fixed by a function template chosen for the channel (Schablonenkomposition). */
|
||||||
|
public const TEMPLATE = 'template';
|
||||||
|
|
||||||
|
/** Suggested by a function template (lowest level above the built-in default; every explicit level wins). */
|
||||||
|
public const TEMPLATE_DEFAULT = 'template_default';
|
||||||
|
|
||||||
|
/** Not set anywhere: derived from a related setting (the answer from the reservation, a sender from guest_messages). */
|
||||||
|
public const DERIVED = 'derived';
|
||||||
|
|
||||||
/** Fixed by the case type (A6), not settable. */
|
/** Fixed by the case type (A6), not settable. */
|
||||||
public const CASE_TYPE = 'case_type';
|
public const CASE_TYPE = 'case_type';
|
||||||
|
|
||||||
@@ -53,7 +63,9 @@ public function __construct(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The case type of a constellation: internal occasions are A6; requests are A1 (own way) or A2 (intermediary);
|
* The case type of a constellation: internal occasions are A6; requests are A1 (own way) or A2 (intermediary);
|
||||||
* binding external bookings are A3–A5 by who handles documents and payments.
|
* binding external bookings are A3–A5 by who handles documents and payments. Only a classification (labels, reports,
|
||||||
|
* compatibility): the course follows the composed plan, and a combination without an archetype of its own –
|
||||||
|
* collection by us, contract documents by the portal – is classified A3 (we collect), never by a new case type.
|
||||||
*/
|
*/
|
||||||
public static function caseTypeFor(IntakeKind $intake, bool $viaChannel, Responsibility $documents, Responsibility $payments): CaseType
|
public static function caseTypeFor(IntakeKind $intake, bool $viaChannel, Responsibility $documents, Responsibility $payments): CaseType
|
||||||
{
|
{
|
||||||
@@ -61,7 +73,7 @@ public static function caseTypeFor(IntakeKind $intake, bool $viaChannel, Respons
|
|||||||
IntakeKind::Internal => CaseType::A6,
|
IntakeKind::Internal => CaseType::A6,
|
||||||
IntakeKind::Inquiry => $viaChannel ? CaseType::A2 : CaseType::A1,
|
IntakeKind::Inquiry => $viaChannel ? CaseType::A2 : CaseType::A1,
|
||||||
IntakeKind::Booking => match (true) {
|
IntakeKind::Booking => match (true) {
|
||||||
$documents === Responsibility::Portal => CaseType::A5,
|
$documents === Responsibility::Portal && $payments === Responsibility::Portal => CaseType::A5,
|
||||||
$payments === Responsibility::Portal => CaseType::A4,
|
$payments === Responsibility::Portal => CaseType::A4,
|
||||||
default => CaseType::A3,
|
default => CaseType::A3,
|
||||||
},
|
},
|
||||||
@@ -103,6 +115,27 @@ public function payments(): Responsibility
|
|||||||
return Responsibility::tryFrom((string) $this->value(ProcessSetting::Payments)) ?? Responsibility::Landlord;
|
return Responsibility::tryFrom((string) $this->value(ProcessSetting::Payments)) ?? Responsibility::Landlord;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How a request is answered first. Profiles frozen before the setting existed derive it from the reservation (an
|
||||||
|
* information reserved nothing, an offer did) – exactly the former behaviour.
|
||||||
|
*/
|
||||||
|
public function inquiryAnswer(): InquiryAnswer
|
||||||
|
{
|
||||||
|
return InquiryAnswer::tryFrom((string) ($this->values[ProcessSetting::InquiryAnswer->value] ?? '')) ?? ($this->preReservation() ? InquiryAnswer::Offer : InquiryAnswer::Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Who sends the arrival information; not set: whoever writes to the guest (guest_messages). */
|
||||||
|
public function arrivalInfoSender(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::tryFrom((string) ($this->values[ProcessSetting::ArrivalInfoSender->value] ?? '')) ?? $this->guestMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Who asks for the review; not set: whoever writes to the guest (guest_messages). */
|
||||||
|
public function reviewRequestSender(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::tryFrom((string) ($this->values[ProcessSetting::ReviewRequestSender->value] ?? '')) ?? $this->guestMessages();
|
||||||
|
}
|
||||||
|
|
||||||
public function guestMessages(): Responsibility
|
public function guestMessages(): Responsibility
|
||||||
{
|
{
|
||||||
return Responsibility::tryFrom((string) $this->value(ProcessSetting::GuestMessages)) ?? Responsibility::Landlord;
|
return Responsibility::tryFrom((string) $this->value(ProcessSetting::GuestMessages)) ?? Responsibility::Landlord;
|
||||||
@@ -193,6 +226,9 @@ public static function sourceLabel(string $source): string
|
|||||||
self::WEBSITE => 'Einstellung der eigenen Webseite',
|
self::WEBSITE => 'Einstellung der eigenen Webseite',
|
||||||
self::CASE_TYPE => 'fest für diese Vorgangsart',
|
self::CASE_TYPE => 'fest für diese Vorgangsart',
|
||||||
self::MODEL => 'festgelegt durch das gewählte Ablaufmodell',
|
self::MODEL => 'festgelegt durch das gewählte Ablaufmodell',
|
||||||
|
self::TEMPLATE => 'festgelegt durch die gewählte Funktionsschablone',
|
||||||
|
self::TEMPLATE_DEFAULT => 'Vorschlag der gewählten Funktionsschablone',
|
||||||
|
self::DERIVED => 'abgeleitet aus einer verwandten Einstellung',
|
||||||
'migration' => 'aus dem bisherigen Stand übernommen',
|
'migration' => 'aus dem bisherigen Stand übernommen',
|
||||||
default => 'Grundeinstellung',
|
default => 'Grundeinstellung',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Process;
|
namespace App\Process;
|
||||||
|
|
||||||
use App\Enums\ChannelBookingModel;
|
use App\Enums\ChannelBookingModel;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Enums\ProcessSetting;
|
use App\Enums\ProcessSetting;
|
||||||
use App\Enums\Responsibility;
|
use App\Enums\Responsibility;
|
||||||
@@ -11,6 +12,8 @@
|
|||||||
use App\Models\Property;
|
use App\Models\Property;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
use App\Process\Models\ProcessModel;
|
use App\Process\Models\ProcessModel;
|
||||||
|
use App\Process\Templates\FunctionTemplate;
|
||||||
|
use App\Process\Templates\TemplateComposer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves the effective process settings: built-in default → landlord default (tenant) → deviation of the property
|
* Resolves the effective process settings: built-in default → landlord default (tenant) → deviation of the property
|
||||||
@@ -32,11 +35,23 @@ public function resolve(Property $property, ?Channel $channel, IntakeKind $intak
|
|||||||
($channel?->isWebsite() ? ProcessProfile::WEBSITE : ProcessProfile::CHANNEL) => $intake === IntakeKind::Internal || $channel === null ? [] : (array) (($channel->process_overrides ?? [])[$intake->value] ?? []),
|
($channel?->isWebsite() ? ProcessProfile::WEBSITE : ProcessProfile::CHANNEL) => $intake === IntakeKind::Internal || $channel === null ? [] : (array) (($channel->process_overrides ?? [])[$intake->value] ?? []),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$model = $this->chosenModel($channel, $intake);
|
||||||
|
$templates = $this->chosenTemplates($channel, $intake, $model);
|
||||||
|
$suggested = [];
|
||||||
|
foreach ($templates as $class) {
|
||||||
|
$suggested = [...$suggested, ...$class::defaults()];
|
||||||
|
}
|
||||||
|
|
||||||
$values = [];
|
$values = [];
|
||||||
$sources = [];
|
$sources = [];
|
||||||
foreach (ProcessSetting::cases() as $setting) {
|
foreach (ProcessSetting::cases() as $setting) {
|
||||||
$values[$setting->value] = $setting->default();
|
$values[$setting->value] = $setting->default();
|
||||||
$sources[$setting->value] = ProcessProfile::SYSTEM;
|
$sources[$setting->value] = ProcessProfile::SYSTEM;
|
||||||
|
// A function template only suggests: below every level the landlord can set.
|
||||||
|
if (($suggestion = $setting->normalize($suggested[$setting->value] ?? null)) !== null) {
|
||||||
|
$values[$setting->value] = $suggestion;
|
||||||
|
$sources[$setting->value] = ProcessProfile::TEMPLATE_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($levels as $level => $settings) {
|
foreach ($levels as $level => $settings) {
|
||||||
if (in_array($level, [ProcessProfile::CHANNEL, ProcessProfile::WEBSITE], true) && ! in_array($intake, $setting->channelIntakes(), true)) {
|
if (in_array($level, [ProcessProfile::CHANNEL, ProcessProfile::WEBSITE], true) && ! in_array($intake, $setting->channelIntakes(), true)) {
|
||||||
@@ -52,7 +67,6 @@ public function resolve(Property $property, ?Channel $channel, IntakeKind $intak
|
|||||||
|
|
||||||
// Architektur V2: the process model chosen for the channel and intake kind fixes some settings (e.g. the
|
// Architektur V2: the process model chosen for the channel and intake kind fixes some settings (e.g. the
|
||||||
// pre-reservation of the offer model, the responsibilities of A3–A5); these win over every level.
|
// pre-reservation of the offer model, the responsibilities of A3–A5); these win over every level.
|
||||||
$model = $this->chosenModel($channel, $intake);
|
|
||||||
foreach ($model === null ? [] : $model::fixes() as $key => $fixed) {
|
foreach ($model === null ? [] : $model::fixes() as $key => $fixed) {
|
||||||
$setting = ProcessSetting::tryFrom($key);
|
$setting = ProcessSetting::tryFrom($key);
|
||||||
if ($setting !== null) {
|
if ($setting !== null) {
|
||||||
@@ -61,6 +75,14 @@ public function resolve(Property $property, ?Channel $channel, IntakeKind $intak
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function templates chosen for the model's slots fix the responsibility of their area.
|
||||||
|
foreach ($templates as $class) {
|
||||||
|
foreach ($class::fixes() as $key => $fixed) {
|
||||||
|
$values[$key] = ProcessSetting::tryFrom($key)?->normalize($fixed) ?? $fixed;
|
||||||
|
$sources[$key] = ProcessProfile::TEMPLATE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($intake === IntakeKind::Internal) {
|
if ($intake === IntakeKind::Internal) {
|
||||||
// Own use, private stays and blocks (A6): no rental documents, no payment reminders, no guest mails – fixed by
|
// Own use, private stays and blocks (A6): no rental documents, no payment reminders, no guest mails – fixed by
|
||||||
// the case type, not by a setting.
|
// the case type, not by a setting.
|
||||||
@@ -74,12 +96,39 @@ public function resolve(Property $property, ?Channel $channel, IntakeKind $intak
|
|||||||
$sources[ProcessSetting::Documents->value] = ProcessProfile::SYSTEM;
|
$sources[ProcessSetting::Documents->value] = ProcessProfile::SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// What was set nowhere follows the related setting, as it always did.
|
||||||
|
foreach ([ProcessSetting::ArrivalInfoSender, ProcessSetting::ReviewRequestSender] as $sender) {
|
||||||
|
if ($values[$sender->value] === null && $intake !== IntakeKind::Internal) {
|
||||||
|
$values[$sender->value] = $values[ProcessSetting::GuestMessages->value];
|
||||||
|
$sources[$sender->value] = ProcessProfile::DERIVED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($values[ProcessSetting::InquiryAnswer->value] === null && $intake === IntakeKind::Inquiry) {
|
||||||
|
$values[ProcessSetting::InquiryAnswer->value] = $values[ProcessSetting::PreReservation->value] ? InquiryAnswer::Offer->value : InquiryAnswer::Information->value;
|
||||||
|
$sources[ProcessSetting::InquiryAnswer->value] = ProcessProfile::DERIVED;
|
||||||
|
}
|
||||||
|
|
||||||
$documents = Responsibility::from((string) $values[ProcessSetting::Documents->value]);
|
$documents = Responsibility::from((string) $values[ProcessSetting::Documents->value]);
|
||||||
$payments = Responsibility::from((string) $values[ProcessSetting::Payments->value]);
|
$payments = Responsibility::from((string) $values[ProcessSetting::Payments->value]);
|
||||||
|
|
||||||
return new ProcessProfile($intake, ProcessProfile::caseTypeFor($intake, $channel?->isPortal() ?? false, $documents, $payments), $values, $sources);
|
return new ProcessProfile($intake, ProcessProfile::caseTypeFor($intake, $channel?->isPortal() ?? false, $documents, $payments), $values, $sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The function templates in force for the chosen model's slots (chosen ones, otherwise the model's defaults).
|
||||||
|
*
|
||||||
|
* @return array<string, class-string<FunctionTemplate>>
|
||||||
|
*/
|
||||||
|
private function chosenTemplates(?Channel $channel, IntakeKind $intake, ?ProcessModel $model): array
|
||||||
|
{
|
||||||
|
if ($model === null || $model->slots() === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$composer = app(TemplateComposer::class);
|
||||||
|
|
||||||
|
return $composer->classes($composer->resolve($model, (array) (ProcessPlan::configurationOf($channel, $intake)['templates'] ?? [])));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model chosen for the channel and intake kind (Kanal › Ablauf), when it is registered and fits the intake.
|
* The model chosen for the channel and intake kind (Kanal › Ablauf), when it is registered and fits the intake.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The portal provides the binding contract documents to the guest. We create and send no contract of our own; the
|
||||||
|
* evidence is the portal's confirmation. Whatever the portal's documents say about payments, our payment handling
|
||||||
|
* follows the collection template – the two areas are independent.
|
||||||
|
*/
|
||||||
|
final class ExternalContractDocuments extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'contract_docs.external';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::ContractDocuments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Externe Vertragsunterlagen';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Das Portal stellt dem Gast die verbindlichen Vertragsunterlagen bereit. Wir halten Buchungsdaten und den Nachweis der Portalbestätigung fest und versenden keinen eigenen Vertrag.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['documents.send', 'documents.booking_notice'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Portal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function capabilityRequirements(): array
|
||||||
|
{
|
||||||
|
return ['provides_contract_documents' => true];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function provides(): array
|
||||||
|
{
|
||||||
|
return [TemplateArea::ContractDocuments->result(), 'contract.documents_by_portal'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Vertragsbedingungen' => 'Das Portal verantwortet Abschluss und Bedingungen.',
|
||||||
|
'Erstellung' => 'Durch das Portal.',
|
||||||
|
'Bereitstellung / Versand' => 'Durch das Portal; wir senden keinen Vertrag. Die Buchungsinformation bleibt einzeln einstellbar.',
|
||||||
|
'Nachweis' => 'Bestätigung des Portals (E-Mail oder Vermerk des Vermieters).',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A centrally defined, versioned function template (docs/Prozessarchitektur/SCHABLONEN.md): a business combination of
|
||||||
|
* already existing modules for one slot of a process model. A template is no second process engine – it only names
|
||||||
|
* the modules the plan gets at its slot, what it needs, what it provides, who answers for the result and which
|
||||||
|
* portal capability it presupposes. The modules stay individually configurable (MODUL_KONFIGURATIONSMATRIX).
|
||||||
|
*/
|
||||||
|
abstract class FunctionTemplate
|
||||||
|
{
|
||||||
|
abstract public static function key(): string;
|
||||||
|
|
||||||
|
abstract public static function version(): int;
|
||||||
|
|
||||||
|
abstract public static function area(): TemplateArea;
|
||||||
|
|
||||||
|
abstract public static function label(): string;
|
||||||
|
|
||||||
|
/** The business purpose in plain words. */
|
||||||
|
abstract public static function purpose(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The modules this template puts at its slot, in order.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
abstract public static function modules(): array;
|
||||||
|
|
||||||
|
/** Who answers for the result of the area (we, unless the template hands it to the portal). */
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The portal capability that must hold for the template to fit: capability key => required value (the channel's
|
||||||
|
* confirmed capabilities decide; an unknown one is a hint, never taken as proven).
|
||||||
|
*
|
||||||
|
* @return array<string, bool>
|
||||||
|
*/
|
||||||
|
public static function capabilityRequirements(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Results of the process this template needs (provided by the base process or another template).
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public static function requires(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Results this template provides. The result of its area is always among them.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public static function provides(): array
|
||||||
|
{
|
||||||
|
return [static::area()->result()];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard configuration the template suggests (setting key => value). It sits below every level the landlord can set
|
||||||
|
* – landlord, property, channel – so it never overrides an explicit value, and every module stays configurable.
|
||||||
|
*
|
||||||
|
* @return array<string, string|int|bool>
|
||||||
|
*/
|
||||||
|
public static function defaults(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modules outside the template's own slot that its defaults or fixes configure (shown with the template).
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public static function configures(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Templates (keys) that must not be combined with this one, with the reason.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function incompatibleWith(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the template stands for along the business dimensions of its area (shown in the configurator):
|
||||||
|
* dimension label => statement.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capabilities that are not built yet; they appear as extensions, never as promises.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public static function extensions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The settings the template fixes for the cases that follow it (setting key => value).
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function fixes(): array
|
||||||
|
{
|
||||||
|
return [static::area()->setting()->value => static::responsibility()->value];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function reference(): string
|
||||||
|
{
|
||||||
|
return static::key().'@'.static::version();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A request is answered with a non-binding information; the guest can ask for the booking from it, we check again and
|
||||||
|
* confirm. By definition (DocumentKind::Information) an information reserves nothing, so this template – and only
|
||||||
|
* this one – fixes the reservation to "no". Everything else (processing mode, deadlines, data request) stays free.
|
||||||
|
*/
|
||||||
|
final class InformationAnswer extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'inquiry.information';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::InquiryAnswer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Unverbindliche Auskunft';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Der Gast erhält Preis und Verfügbarkeit zum Stand der Prüfung, ohne Reservierung und ohne Zusage. Er kann daraus die Buchung anfragen; verbindlich wird sie erst mit unserer Bestätigung nach erneuter Prüfung.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['offer.information'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function requires(): array
|
||||||
|
{
|
||||||
|
return ['guest.identified', 'availability.checked'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fixes(): array
|
||||||
|
{
|
||||||
|
return ['inquiry_answer' => 'information', 'pre_reservation' => false];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Verbindlichkeit' => 'Keine; der Vertrag entsteht erst nach dem Buchungswunsch und unserer Bestätigung.',
|
||||||
|
'Reservierung' => 'Keine (Festlegung der Auskunft, nicht des Prozesses).',
|
||||||
|
'Ausführung' => 'Automatisch, nach Freigabe oder von Hand (Modul „Unverbindliche Auskunft“).',
|
||||||
|
'Nachweis' => 'Versendete Auskunft mit Version und Stand der Prüfung.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A request is answered with a binding offer (contract draft, signed link) the guest accepts. The reservation strategy
|
||||||
|
* is not part of the template: it only suggests to reserve at the request (clarification hold, offer hold). Whoever
|
||||||
|
* prefers to offer without holding the dates at the request sets the reservation to "no" – the offer itself still
|
||||||
|
* holds the dates for its validity, and availability is checked before it goes out.
|
||||||
|
*/
|
||||||
|
final class OfferAnswer extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'inquiry.binding_offer';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::InquiryAnswer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Verbindliches Angebot';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Der Gast erhält ein verbindliches Angebot mit Vertragsentwurf und nimmt es mit einem Klick an. Danach ist die Buchung verbindlich.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function requires(): array
|
||||||
|
{
|
||||||
|
return ['guest.identified', 'availability.checked'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fixes(): array
|
||||||
|
{
|
||||||
|
return ['inquiry_answer' => 'offer'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function defaults(): array
|
||||||
|
{
|
||||||
|
return ['pre_reservation' => true];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Verbindlichkeit' => 'Mit der Annahme des Gastes (Annahmeprotokoll).',
|
||||||
|
'Reservierung' => 'Vorschlag: Zeitraum schon bei der Anfrage reservieren; frei einstellbar. Das Angebot hält den Zeitraum in jedem Fall für seine Gültigkeit.',
|
||||||
|
'Ausführung' => 'Automatisch, nach Freigabe oder von Hand; Preisänderungen nur als Anpassungszeile.',
|
||||||
|
'Nachweis' => 'Angebotsversion, Annahme mit Zeitstempel und Prüfsumme.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We collect the guest's money (e.g. Destination Solutions): payment monitoring on our side. Multi-stage dunning is
|
||||||
|
* not built – it is listed as an extension, not promised.
|
||||||
|
*/
|
||||||
|
final class OwnCollection extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'collection.own';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::Collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Eigenes Inkasso';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Wir fordern Anzahlung und Restzahlung vom Gast an, überwachen die Zahlungseingänge, erinnern an offene Beträge und schließen die Forderung kaufmännisch ab.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['payments.monitor'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function capabilityRequirements(): array
|
||||||
|
{
|
||||||
|
return ['collects_payment' => false];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function requires(): array
|
||||||
|
{
|
||||||
|
return ['price.known'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function provides(): array
|
||||||
|
{
|
||||||
|
return [TemplateArea::Collection->result(), 'money.guest_payments_monitored'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Zahlungsplan' => 'Anzahlung und Restzahlung nach den Zahlungsfristen des Vermieters.',
|
||||||
|
'Zahlungsanforderung' => 'Aufgabe vor Fälligkeit; Versand durch uns.',
|
||||||
|
'Zahlungseingang' => 'Wir erfassen die Zahlungen des Gastes.',
|
||||||
|
'Erinnerung' => 'Aufgabe mit Versand per Klick (nicht automatisch).',
|
||||||
|
'Abschluss' => 'Kaufmännischer Abschluss mit tatsächlichen Nachweisen.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function extensions(): array
|
||||||
|
{
|
||||||
|
return ['Mehrstufige Mahnungen (rechtliche Ausgestaltung offen)', 'Bank-Abgleich der Zahlungseingänge'];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We create and send the contract documentation (booking record with our terms). Creation, filing, provision and
|
||||||
|
* dispatch remain configurable at the module (processing, contract_delivery, template).
|
||||||
|
*/
|
||||||
|
final class OwnContractDocumentation extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'contract_docs.own';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::ContractDocuments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Eigene Vertragsdokumentation';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Wir erstellen die Vertragsunterlagen aus Buchungsdaten und unseren Bedingungen, legen sie ab und stellen sie dem Gast bereit.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['documents.send', 'documents.booking_notice'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function capabilityRequirements(): array
|
||||||
|
{
|
||||||
|
return ['provides_contract_documents' => false];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function requires(): array
|
||||||
|
{
|
||||||
|
return ['guest.identified'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function provides(): array
|
||||||
|
{
|
||||||
|
return [TemplateArea::ContractDocuments->result(), 'contract.documents_by_us'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Vertragsbedingungen' => 'Das Portal verantwortet den Vertragsabschluss; die Bedingungen der Unterlagen sind unsere.',
|
||||||
|
'Erstellung' => 'Durch uns (Vorlage der Wohnung oder des Kanals).',
|
||||||
|
'Bereitstellung / Versand' => 'Durch uns; automatisch, nach Freigabe oder von Hand, per E-Mail oder nur intern abgelegt.',
|
||||||
|
'Nachweis' => 'Gespeichertes Dokument und Versandvermerk am Vorgang.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard: we write to the guest. It only suggests; each occasion (arrival information, review request) has its own
|
||||||
|
* sender setting and stays individually configurable – there is no all-or-nothing responsibility for guest messages.
|
||||||
|
*/
|
||||||
|
final class OwnGuestCommunication extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'guest_comm.own';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::GuestCommunication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Gastkommunikation durch uns';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Anreise-Informationen und Bewertungsbitte gehen von uns an den Gast. Einzelne Anlässe lassen sich trotzdem dem Portal zuweisen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['arrival.details', 'arrival.info'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function configures(): array
|
||||||
|
{
|
||||||
|
return ['review.request'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fixes(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function defaults(): array
|
||||||
|
{
|
||||||
|
return ['guest_messages' => 'landlord'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Anreise-Information' => 'Von uns, N Tage vor Anreise (einstellbar).',
|
||||||
|
'Bewertungsbitte' => 'Von uns nach dem Aufenthalt.',
|
||||||
|
'Medium' => 'E-Mail (über das Mail-Tor; weitere Medien sind nicht angebunden).',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The portal collects the guest's money (e.g. FeWo-direkt): we record what the portal reports and check the payout.
|
||||||
|
* No payment request towards the guest arises from this template.
|
||||||
|
*/
|
||||||
|
final class PortalCollection extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'collection.portal';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::Collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Portal-Inkasso';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Das Portal zieht das Geld des Gastes ein. Wir erfassen die gemeldeten Beträge, kontrollieren die Auszahlung gegen Nachweise, bearbeiten Differenzen und schließen kaufmännisch ab.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['payments.monitor', 'portal.payout'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Portal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function capabilityRequirements(): array
|
||||||
|
{
|
||||||
|
return ['collects_payment' => true];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function requires(): array
|
||||||
|
{
|
||||||
|
return ['price.known'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function provides(): array
|
||||||
|
{
|
||||||
|
return [TemplateArea::Collection->result(), 'money.portal_payout_checked'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Zahlungsplan' => 'Beim Portal; wir zeigen nur „laut Portal“.',
|
||||||
|
'Zahlungsanforderung' => 'Keine eigene gegenüber dem Gast.',
|
||||||
|
'Zahlungseingang' => 'Angaben des Portals werden erfasst (kein Geld auf unserem Konto).',
|
||||||
|
'Auszahlung' => 'Kontrolle gegen Nachweis; Differenzen werden bearbeitet.',
|
||||||
|
'Abschluss' => 'Kaufmännischer Abschluss erst mit tatsächlichem Nachweis der Auszahlung.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard: the portal writes to the guest (e.g. FeWo-direkt). Suggests the portal as sender of the arrival information
|
||||||
|
* and the review request; each occasion can still be taken back by us individually. Needs the portal to write to guests.
|
||||||
|
*/
|
||||||
|
final class PortalGuestCommunication extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'guest_comm.portal';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::GuestCommunication;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Gastkommunikation durch das Portal';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Das Portal schreibt dem Gast zu Anreise und Bewertung. Wir halten fest, dass es angekündigt ist – eine Zustellung gilt damit nicht als nachgewiesen. Einzelne Anlässe lassen sich trotzdem von uns übernehmen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['arrival.details', 'arrival.info'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function configures(): array
|
||||||
|
{
|
||||||
|
return ['review.request'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Portal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function capabilityRequirements(): array
|
||||||
|
{
|
||||||
|
return ['messages_guest' => true];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fixes(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function defaults(): array
|
||||||
|
{
|
||||||
|
return ['guest_messages' => 'portal', 'arrival_info_sender' => 'portal', 'review_request_sender' => 'portal'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function dimensions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Anreise-Information' => 'Durch das Portal (angekündigt, nicht nachgewiesen).',
|
||||||
|
'Bewertungsbitte' => 'Durch das Portal.',
|
||||||
|
'Medium' => 'Das des Portals.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
use App\Enums\ProcessSetting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A functional area of a process where a model offers a slot for a function template. Each area answers one business
|
||||||
|
* decision and stands for exactly one result of the process (so the same result is never produced twice).
|
||||||
|
*/
|
||||||
|
enum TemplateArea: string
|
||||||
|
{
|
||||||
|
case Collection = 'collection';
|
||||||
|
case ContractDocuments = 'contract_documents';
|
||||||
|
case InquiryAnswer = 'inquiry_answer';
|
||||||
|
case GuestCommunication = 'guest_communication';
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Collection => 'Finanzabwicklung (Inkasso)',
|
||||||
|
self::ContractDocuments => 'Vertragsdokumentation',
|
||||||
|
self::InquiryAnswer => 'Beantwortung der Anfrage',
|
||||||
|
self::GuestCommunication => 'Gastkommunikation',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function question(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Collection => 'Wer zieht das Geld des Gastes ein?',
|
||||||
|
self::ContractDocuments => 'Wer stellt dem Gast die Vertragsunterlagen bereit?',
|
||||||
|
self::InquiryAnswer => 'Womit antworten wir zuerst auf eine Anfrage?',
|
||||||
|
self::GuestCommunication => 'Wer schreibt dem Gast zu welchem Anlass? (Standard – jeder Anlass bleibt einzeln einstellbar)',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The process result every template of this area provides – exactly once per process. */
|
||||||
|
public function result(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Collection => 'money.collection_handled',
|
||||||
|
self::ContractDocuments => 'contract.documented',
|
||||||
|
self::InquiryAnswer => 'inquiry.answered',
|
||||||
|
self::GuestCommunication => 'guest.communication_assigned',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The responsibility setting the chosen template fixes. */
|
||||||
|
public function setting(): ProcessSetting
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Collection => ProcessSetting::Payments,
|
||||||
|
self::ContractDocuments => ProcessSetting::Documents,
|
||||||
|
self::InquiryAnswer => ProcessSetting::InquiryAnswer,
|
||||||
|
self::GuestCommunication => ProcessSetting::GuestMessages,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Every setting a template of this area may fix or suggest – nothing else (no hidden coupling to other areas).
|
||||||
|
*
|
||||||
|
* @return list<ProcessSetting>
|
||||||
|
*/
|
||||||
|
public function settings(): array
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Collection, self::ContractDocuments => [$this->setting()],
|
||||||
|
// An information reserves nothing by definition; for an offer the reservation is only suggested.
|
||||||
|
self::InquiryAnswer => [ProcessSetting::InquiryAnswer, ProcessSetting::PreReservation],
|
||||||
|
self::GuestCommunication => [ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoSender, ProcessSetting::ReviewRequestSender],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Process\Templates;
|
||||||
|
|
||||||
|
use App\Process\Models\ProcessModel;
|
||||||
|
use App\Process\ProcessCatalogue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks and resolves a combination of function templates for the slots of a model. Pure: it reads the registered
|
||||||
|
* definitions and returns what is wrong in plain words (empty = the combination yields a valid plan). It is no second
|
||||||
|
* engine – the plan it leads to is run by the ProcessRunner with the dependencies the modules declare.
|
||||||
|
*/
|
||||||
|
final class TemplateComposer
|
||||||
|
{
|
||||||
|
public function __construct(private ProcessCatalogue $catalogue) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The template reference (key@version) every slot of the model gets: the chosen one, otherwise the model's default.
|
||||||
|
* References that are not registered are kept as given so that problems() can name them.
|
||||||
|
*
|
||||||
|
* @param array<string, string> $chosen area value => template key or key@version
|
||||||
|
* @return array<string, string> area value => key@version
|
||||||
|
*/
|
||||||
|
public function resolve(ProcessModel $model, array $chosen): array
|
||||||
|
{
|
||||||
|
$resolved = [];
|
||||||
|
foreach ($model->slots() as $area) {
|
||||||
|
$reference = (string) ($chosen[$area->value] ?? $model::defaultTemplates()[$area->value] ?? '');
|
||||||
|
$class = $reference === '' ? null : $this->catalogue->templateClass($reference);
|
||||||
|
$resolved[$area->value] = $class === null ? $reference : $class::reference();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The template classes behind a resolved combination (unknown references are left out).
|
||||||
|
*
|
||||||
|
* @param array<string, string> $resolved
|
||||||
|
* @return array<string, class-string<FunctionTemplate>>
|
||||||
|
*/
|
||||||
|
public function classes(array $resolved): array
|
||||||
|
{
|
||||||
|
$classes = [];
|
||||||
|
foreach ($resolved as $area => $reference) {
|
||||||
|
if (($class = $this->catalogue->templateClass($reference)) !== null) {
|
||||||
|
$classes[$area] = $class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $chosen area value => template key or key@version
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function problems(ProcessModel $model, array $chosen, string $variant = 'standard'): array
|
||||||
|
{
|
||||||
|
$problems = [];
|
||||||
|
$slots = array_map(fn (TemplateArea $area): string => $area->value, $model->slots());
|
||||||
|
foreach (array_keys($chosen) as $area) {
|
||||||
|
if (! in_array($area, $slots, true)) {
|
||||||
|
$problems[] = 'Das Modell „'.$model::label().'“ hat keinen Platz für „'.$area.'“.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($slots === []) {
|
||||||
|
return $problems;
|
||||||
|
}
|
||||||
|
|
||||||
|
$resolved = $this->resolve($model, array_intersect_key($chosen, array_flip($slots)));
|
||||||
|
$classes = [];
|
||||||
|
foreach ($resolved as $area => $reference) {
|
||||||
|
$class = $this->catalogue->templateClass($reference);
|
||||||
|
if ($class !== null && isset($model::templateRestrictions()[$class::key()])) {
|
||||||
|
$problems[] = '„'.$class::label().'“ passt nicht zu „'.$model::label().'“: '.$model::templateRestrictions()[$class::key()];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($class === null) {
|
||||||
|
$problems[] = 'Die Schablone „'.$reference.'“ gibt es nicht.';
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($class::area()->value !== $area) {
|
||||||
|
$problems[] = 'Die Schablone „'.$class::label().'“ gehört zu „'.$class::area()->label().'“, nicht zu „'.TemplateArea::from($area)->label().'“.';
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$classes[$area] = $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
$problems = [...$problems, ...$this->resultProblems($model, $classes), ...$this->pairProblems($classes), ...$this->planProblems($model, $classes, $variant)];
|
||||||
|
|
||||||
|
return array_values(array_unique($problems));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prerequisites and double effects at the level of business results.
|
||||||
|
*
|
||||||
|
* @param array<string, class-string<FunctionTemplate>> $classes
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function resultProblems(ProcessModel $model, array $classes): array
|
||||||
|
{
|
||||||
|
$problems = [];
|
||||||
|
$providers = [];
|
||||||
|
foreach ($model::providedResults() as $result) {
|
||||||
|
$providers[$result][] = 'der Basisprozess';
|
||||||
|
}
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
foreach ($class::provides() as $result) {
|
||||||
|
$providers[$result][] = '„'.$class::label().'“';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($providers as $result => $by) {
|
||||||
|
if (count($by) > 1) {
|
||||||
|
$problems[] = 'Das Ergebnis „'.$result.'“ würde doppelt erzeugt: '.implode(' und ', $by).'.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
foreach ($class::requires() as $needed) {
|
||||||
|
if (! isset($providers[$needed])) {
|
||||||
|
$problems[] = '„'.$class::label().'“ setzt das Ergebnis „'.$needed.'“ voraus, das in dieser Kombination niemand liefert.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $problems;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mutually exclusive templates and contradictory responsibilities.
|
||||||
|
*
|
||||||
|
* @param array<string, class-string<FunctionTemplate>> $classes
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function pairProblems(array $classes): array
|
||||||
|
{
|
||||||
|
$problems = [];
|
||||||
|
$fixed = [];
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
foreach ($class::incompatibleWith() as $other => $reason) {
|
||||||
|
if (collect($classes)->contains(fn (string $chosen): bool => $chosen::key() === $other)) {
|
||||||
|
$problems[] = '„'.$class::label().'“ und „'.$this->catalogue->templateClass($other)::label().'“ lassen sich nicht kombinieren: '.$reason;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($class::fixes() as $setting => $value) {
|
||||||
|
if (isset($fixed[$setting]) && $fixed[$setting]['value'] !== $value) {
|
||||||
|
$problems[] = 'Widersprüchliche Verantwortlichkeit ('.$setting.'): „'.$fixed[$setting]['by'].'“ und „'.$class::label().'“ legen Unterschiedliches fest.';
|
||||||
|
}
|
||||||
|
$fixed[$setting] = ['value' => $value, 'by' => $class::label()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $problems;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the composed course needs from the modules: no module twice, and a hard dependency on a module that one of the
|
||||||
|
* templates of this model's slots would have supplied must be in the plan.
|
||||||
|
*
|
||||||
|
* @param array<string, class-string<FunctionTemplate>> $classes
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function planProblems(ProcessModel $model, array $classes, string $variant): array
|
||||||
|
{
|
||||||
|
$problems = [];
|
||||||
|
$modules = $model->modules($variant, array_map(fn (string $class): string => $class::reference(), $classes));
|
||||||
|
foreach (array_count_values($modules) as $module => $count) {
|
||||||
|
if ($count > 1) {
|
||||||
|
$problems[] = 'Das Modul „'.$module.'“ wäre mehrfach im Ablauf.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$templateOwned = [];
|
||||||
|
foreach ($model->slots() as $area) {
|
||||||
|
foreach ($this->catalogue->templates($area) as $class) {
|
||||||
|
array_push($templateOwned, ...$class::modules());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (array_unique($modules) as $key) {
|
||||||
|
if (! $this->catalogue->hasModule($key)) {
|
||||||
|
$problems[] = 'Das Modul „'.$key.'“ ist nicht registriert.';
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach ($this->catalogue->modules()[$key]::definition()->requires as $dependency) {
|
||||||
|
if ($dependency->hard && ! in_array($dependency->module, $modules, true) && in_array($dependency->module, $templateOwned, true)) {
|
||||||
|
$problems[] = 'Das Modul „'.$key.'“ braucht zwingend „'.$dependency->module.'“, das in dieser Kombination fehlt.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $problems;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,8 +8,10 @@
|
|||||||
use App\Models\Channel;
|
use App\Models\Channel;
|
||||||
use App\Models\Property;
|
use App\Models\Property;
|
||||||
use App\Models\Tenant;
|
use App\Models\Tenant;
|
||||||
|
use App\Process\Capability;
|
||||||
use App\Process\CaseActivities;
|
use App\Process\CaseActivities;
|
||||||
use App\Process\CaseContext;
|
use App\Process\CaseContext;
|
||||||
|
use App\Process\ChannelCapabilities;
|
||||||
use App\Process\ProcessCatalogue;
|
use App\Process\ProcessCatalogue;
|
||||||
use App\Process\ProcessPlan;
|
use App\Process\ProcessPlan;
|
||||||
use App\Process\ProcessProfile;
|
use App\Process\ProcessProfile;
|
||||||
@@ -37,6 +39,9 @@ final class ProcessSandboxDriver
|
|||||||
|
|
||||||
private int $ledgerSeen = 0;
|
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`) */
|
/** @var list<Email> every mail of the run (simulated: the only mailer is `array`) */
|
||||||
private array $sent = [];
|
private array $sent = [];
|
||||||
|
|
||||||
@@ -98,7 +103,7 @@ public function run(array $input): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'scenario' => ['key' => $scenario::key(), 'label' => $scenario::label(), 'inputs' => $context->inputs, 'available_events' => count($scenario->events($context->inputs))],
|
'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,
|
'timeline' => $timeline,
|
||||||
'result' => $booking === null ? null : ['status' => $booking->status->getLabel(), 'situation' => CaseActivities::situation($booking), 'next' => CaseActivities::next($booking)?->label],
|
'result' => $booking === null ? null : ['status' => $booking->status->getLabel(), 'situation' => CaseActivities::situation($booking), 'next' => CaseActivities::next($booking)?->label],
|
||||||
'violations' => EffectLedger::violations(),
|
'violations' => EffectLedger::violations(),
|
||||||
@@ -122,7 +127,7 @@ private function assertSandbox(): void
|
|||||||
/**
|
/**
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
private function plan(Booking $booking): array
|
private function plan(Booking $booking, Channel $channel): array
|
||||||
{
|
{
|
||||||
$plan = ProcessPlan::of($booking);
|
$plan = ProcessPlan::of($booking);
|
||||||
$profile = $booking->process();
|
$profile = $booking->process();
|
||||||
@@ -134,10 +139,49 @@ private function plan(Booking $booking): array
|
|||||||
'variant' => $plan->variant,
|
'variant' => $plan->variant,
|
||||||
'modules' => $plan->modules,
|
'modules' => $plan->modules,
|
||||||
'case_type' => strtoupper($profile->caseType->value),
|
'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(),
|
'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.
|
* 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 [
|
return [
|
||||||
'status' => $booking->status->getLabel(),
|
'status' => $booking->status->getLabel(),
|
||||||
'situation' => CaseActivities::situation($booking),
|
'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)),
|
'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,
|
'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],
|
'calendar' => ['occupying' => Booking::query()->occupying()->whereKey($booking->id)->exists(), 'hold_until' => $booking->isHoldActive() ? $booking->hold_expires_at->format('d.m.Y H:i') : null],
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public static function build(Channel $channel, IntakeKind $intake, array $draft)
|
|||||||
foreach ($tables['channels'] ?? [] as $index => $row) {
|
foreach ($tables['channels'] ?? [] as $index => $row) {
|
||||||
if ((int) $row['id'] === $channel->id) {
|
if ((int) $row['id'] === $channel->id) {
|
||||||
$overrides = (array) json_decode((string) ($row['process_overrides'] ?? '[]'), true);
|
$overrides = (array) json_decode((string) ($row['process_overrides'] ?? '[]'), true);
|
||||||
$overrides[$intake->value] = [...array_filter((array) ($draft['settings'] ?? []), fn (mixed $value): bool => $value !== null && $value !== ''), 'model' => $draft['model'] ?? null, 'variant' => $draft['variant'] ?? 'standard', 'steps' => (array) ($draft['steps'] ?? [])];
|
$overrides[$intake->value] = [...array_filter((array) ($draft['settings'] ?? []), fn (mixed $value): bool => $value !== null && $value !== ''), 'model' => $draft['model'] ?? null, 'variant' => $draft['variant'] ?? 'standard', 'steps' => (array) ($draft['steps'] ?? []), 'templates' => (array) ($draft['templates'] ?? [])];
|
||||||
$tables['channels'][$index]['process_overrides'] = json_encode($overrides);
|
$tables['channels'][$index]['process_overrides'] = json_encode($overrides);
|
||||||
$tables['channels'][$index]['case_intake'] = 'create';
|
$tables['channels'][$index]['case_intake'] = 'create';
|
||||||
// In the run the tested portal is active, so its (synthetic) booking mails are recognised.
|
// In the run the tested portal is active, so its (synthetic) booking mails are recognised.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
use App\Actions\AcceptOffer;
|
use App\Actions\AcceptOffer;
|
||||||
use App\Actions\SendOffer;
|
use App\Actions\SendOffer;
|
||||||
use App\Enums\BookingStatus;
|
use App\Enums\BookingStatus;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Process\Tester\SandboxContext;
|
use App\Process\Tester\SandboxContext;
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ public function events(array $inputs): array
|
|||||||
new ScenarioEvent('Gast fragt mit allen Angaben an', fn (SandboxContext $context) => $context->request(['street' => 'Teststraße 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'])),
|
new ScenarioEvent('Gast fragt mit allen Angaben an', fn (SandboxContext $context) => $context->request(['street' => 'Teststraße 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'])),
|
||||||
new ScenarioEvent('Sie senden das Angebot (falls es nicht automatisch ging)', function (SandboxContext $context): void {
|
new ScenarioEvent('Sie senden das Angebot (falls es nicht automatisch ging)', function (SandboxContext $context): void {
|
||||||
$booking = $context->booking->fresh();
|
$booking = $context->booking->fresh();
|
||||||
if ($booking->status === BookingStatus::Reserved && $booking->offer_version === 0 && $booking->process()->preReservation()) {
|
if ($booking->status === BookingStatus::Reserved && $booking->offer_version === 0 && $booking->process()->inquiryAnswer() === InquiryAnswer::Offer) {
|
||||||
app(SendOffer::class)->handle($booking);
|
app(SendOffer::class)->handle($booking);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Actions\SendOffer;
|
use App\Actions\SendOffer;
|
||||||
use App\Enums\BookingStatus;
|
use App\Enums\BookingStatus;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
use App\Enums\IntakeKind;
|
use App\Enums\IntakeKind;
|
||||||
use App\Models\Booking;
|
use App\Models\Booking;
|
||||||
use App\Models\Guest;
|
use App\Models\Guest;
|
||||||
@@ -55,7 +56,7 @@ public function events(array $inputs): array
|
|||||||
new ScenarioEvent('Gast fragt mit allen Angaben an', fn (SandboxContext $context) => $context->request(['street' => 'Teststraße 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'])),
|
new ScenarioEvent('Gast fragt mit allen Angaben an', fn (SandboxContext $context) => $context->request(['street' => 'Teststraße 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'])),
|
||||||
new ScenarioEvent('Sie senden das Angebot (falls es nicht automatisch ging)', function (SandboxContext $context): void {
|
new ScenarioEvent('Sie senden das Angebot (falls es nicht automatisch ging)', function (SandboxContext $context): void {
|
||||||
$booking = $context->booking->fresh();
|
$booking = $context->booking->fresh();
|
||||||
if ($booking->status === BookingStatus::Reserved && $booking->offer_version === 0 && $booking->process()->preReservation()) {
|
if ($booking->status === BookingStatus::Reserved && $booking->offer_version === 0 && $booking->process()->inquiryAnswer() === InquiryAnswer::Offer) {
|
||||||
app(SendOffer::class)->handle($booking);
|
app(SendOffer::class)->handle($booking);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
use App\Process\Modules\Offer;
|
use App\Process\Modules\Offer;
|
||||||
use App\Process\Modules\Settlement;
|
use App\Process\Modules\Settlement;
|
||||||
use App\Process\Modules\Stay;
|
use App\Process\Modules\Stay;
|
||||||
|
use App\Process\Templates;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -72,5 +73,23 @@
|
|||||||
'a4.portal_booking' => [1 => Models\A4PortalBookingModelV1::class, 2 => Models\A4PortalBookingModel::class],
|
'a4.portal_booking' => [1 => Models\A4PortalBookingModelV1::class, 2 => Models\A4PortalBookingModel::class],
|
||||||
'a5.portal_booking' => [1 => Models\A5PortalBookingModelV1::class, 2 => Models\A5PortalBookingModel::class],
|
'a5.portal_booking' => [1 => Models\A5PortalBookingModelV1::class, 2 => Models\A5PortalBookingModel::class],
|
||||||
'a6.internal' => [1 => Models\A6InternalModel::class],
|
'a6.internal' => [1 => Models\A6InternalModel::class],
|
||||||
|
// Base process with slots for function templates; A3–A5 above are its presets (compatibility).
|
||||||
|
'external.booking' => [1 => Models\ExternalBookingModel::class],
|
||||||
|
'inquiry.request' => [1 => Models\InquiryRequestModel::class],
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
| Function templates (docs/Prozessarchitektur/SCHABLONEN.md): versioned combinations of the modules above for the slots
|
||||||
|
| of a model. A plan freezes the template versions it was built with.
|
||||||
|
*/
|
||||||
|
'templates' => [
|
||||||
|
'collection.own' => [1 => Templates\OwnCollection::class],
|
||||||
|
'collection.portal' => [1 => Templates\PortalCollection::class],
|
||||||
|
'contract_docs.own' => [1 => Templates\OwnContractDocumentation::class],
|
||||||
|
'contract_docs.external' => [1 => Templates\ExternalContractDocuments::class],
|
||||||
|
'inquiry.information' => [1 => Templates\InformationAnswer::class],
|
||||||
|
'inquiry.binding_offer' => [1 => Templates\OfferAnswer::class],
|
||||||
|
'guest_comm.own' => [1 => Templates\OwnGuestCommunication::class],
|
||||||
|
'guest_comm.portal' => [1 => Templates\PortalGuestCommunication::class],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -2,30 +2,33 @@ # Modulmatrix (erzeugt)
|
|||||||
|
|
||||||
Erzeugt von `php artisan process:check --matrix` aus `config/process.php` – nicht von Hand ändern. Spalten: Modelle (Standardablauf; `V` = nur in einer Variante).
|
Erzeugt von `php artisan process:check --matrix` aus `config/process.php` – nicht von Hand ändern. Spalten: Modelle (Standardablauf; `V` = nur in einer Variante).
|
||||||
|
|
||||||
| Modul | Version | Phase | Aktivierung | Verfügbarkeit | hart abhängig von | a1.offer | a1.information | a2.offer | a2.information | a3.portal_booking | a4.portal_booking | a5.portal_booking | a6.internal | Testgruppe |
|
| Modul | Version | Phase | Aktivierung | Verfügbarkeit | hart abhängig von | a1.offer | a1.information | a2.offer | a2.information | a3.portal_booking | a4.portal_booking | a5.portal_booking | a6.internal | external.booking | inquiry.request | Testgruppe |
|
||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||
| `intake.record` | 1 | P01 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:intake.record` |
|
| `intake.record` | 1 | P01 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | `module:intake.record` |
|
||||||
| `guest.details` | 1 | P01 | mandatory | production | intake.record | ● | ● | ● | ● | ● | ● | ● | | `module:guest.details` |
|
| `guest.details` | 1 | P01 | mandatory | production | intake.record | ● | ● | ● | ● | ● | ● | ● | | ● | ● | `module:guest.details` |
|
||||||
| `guest.data_request` | 1 | P01 | optional | production | intake.record | ● | ● | ● | ● | ● | ● | ● | | `module:guest.data_request` |
|
| `guest.data_request` | 1 | P01 | optional | production | intake.record | ● | ● | ● | ● | ● | ● | ● | | ● | ● | `module:guest.data_request` |
|
||||||
| `hold` | 1 | P01 | conditional | production | intake.record | ● | ● | ● | ● | | | | | `module:hold` |
|
| `hold` | 1 | P01 | conditional | production | intake.record | ● | ● | ● | ● | | | | | | ● | `module:hold` |
|
||||||
| `availability.check` | 1 | P01 | mandatory | production | | ● | ● | ● | ● | | | | | `module:availability.check` |
|
| `availability.check` | 1 | P01 | mandatory | production | | ● | ● | ● | ● | | | | | | ● | `module:availability.check` |
|
||||||
| `binding.portal` | 1 | P02 | mandatory | production | intake.record | | | | | ● | ● | ● | | `module:binding.portal` |
|
| `binding.portal` | 1 | P02 | mandatory | production | intake.record | | | | | ● | ● | ● | | ● | | `module:binding.portal` |
|
||||||
| `channels.block` | 1 | P02 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:channels.block` |
|
| `channels.block` | 1 | P02 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | `module:channels.block` |
|
||||||
| `offer.information` | 1 | P02 | mandatory | production | intake.record | ● | ● | ● | ● | | | | | `module:offer.information` |
|
| `portal.confirmation` | 1 | P02 | conditional | production | intake.record | | | | | ● | ● | ● | | ● | | `module:portal.confirmation` |
|
||||||
| `offer.binding` | 2 | P02 | mandatory | production | guest.details, availability.check | ● | ● | ● | ● | | | | | `module:offer.binding` |
|
| `offer.information` | 1 | P02 | mandatory | production | intake.record | ● | ● | ● | ● | | | | | | | `module:offer.information` |
|
||||||
| `offer.acceptance` | 1 | P02 | mandatory | production | offer.binding | ● | ● | ● | ● | | | | | `module:offer.acceptance` |
|
| `offer.binding` | 2 | P02 | mandatory | production | guest.details, availability.check | ● | ● | ● | ● | | | | | | ● | `module:offer.binding` |
|
||||||
| `documents.send` | 1 | P03 | mandatory | production | guest.details | ● | ● | ● | ● | ● | ● | ● | | `module:documents.send` |
|
| `offer.acceptance` | 1 | P02 | mandatory | production | offer.binding | ● | ● | ● | ● | | | | | | ● | `module:offer.acceptance` |
|
||||||
| `documents.stay_confirmation` | 1 | P03 | optional | production | | | | | | | | | ● | `module:documents.stay_confirmation` |
|
| `documents.send` | 2 | P03 | mandatory | production | guest.details, portal.confirmation | ● | ● | ● | ● | ● | ● | ● | | ● | ● | `module:documents.send` |
|
||||||
| `case.tasks` | 1 | P03 | event_driven | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.tasks` |
|
| `documents.booking_notice` | 1 | P03 | conditional | production | portal.confirmation, guest.details | | | | | ● | ● | ● | | ● | ● | `module:documents.booking_notice` |
|
||||||
| `change.proposal` | 1 | P03 | event_driven | production | | ● | ● | ● | ● | ● | ● | ● | | `module:change.proposal` |
|
| `documents.stay_confirmation` | 1 | P03 | optional | production | | | | | | | | | ● | | | `module:documents.stay_confirmation` |
|
||||||
| `case.closure` | 1 | P05 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.closure` |
|
| `case.tasks` | 1 | P03 | event_driven | production | | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.tasks` |
|
||||||
| `case.settlement` | 1 | P05 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.settlement` |
|
| `change.proposal` | 1 | P03 | event_driven | production | | ● | ● | ● | ● | ● | ● | ● | | ● | ● | `module:change.proposal` |
|
||||||
| `payments.monitor` | 1 | P03 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | `module:payments.monitor` |
|
| `case.closure` | 1 | P05 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.closure` |
|
||||||
| `portal.payout` | 1 | P03 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | `module:portal.payout` |
|
| `case.settlement` | 1 | P05 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.settlement` |
|
||||||
| `payments.internal` | 1 | P03 | conditional | production | | | | | | | | | ● | `module:payments.internal` |
|
| `payments.monitor` | 1 | P03 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | ● | ● | `module:payments.monitor` |
|
||||||
| `arrival.details` | 1 | P04 | optional | production | | ● | ● | ● | ● | ● | ● | ● | | `module:arrival.details` |
|
| `portal.payout` | 1 | P03 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | | | `module:portal.payout` |
|
||||||
| `arrival.info` | 1 | P04 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | `module:arrival.info` |
|
| `payments.internal` | 1 | P03 | conditional | production | | | | | | | | | ● | | | `module:payments.internal` |
|
||||||
| `stay` | 1 | P04 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:stay` |
|
| `arrival.details` | 1 | P04 | optional | production | | ● | ● | ● | ● | ● | ● | ● | | ● | ● | `module:arrival.details` |
|
||||||
| `review.request` | 1 | P05 | optional | production | stay | ● | ● | ● | ● | ● | ● | ● | | `module:review.request` |
|
| `arrival.info` | 1 | P04 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | ● | ● | `module:arrival.info` |
|
||||||
| `guest.loyalty_status` | 1 | P01 | optional | tester_only | guest.details | V | | | | | | | | `module:guest.loyalty_status` |
|
| `stay` | 1 | P04 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | `module:stay` |
|
||||||
| `pricing.loyalty_discount` | 1 | P02 | optional | tester_only | guest.loyalty_status | V | | | | | | | | `module:pricing.loyalty_discount` |
|
| `review.request` | 1 | P05 | optional | production | stay | ● | ● | ● | ● | ● | ● | ● | | ● | ● | `module:review.request` |
|
||||||
|
| `guest.address_check` | 1 | P01 | optional | tester_only | guest.details | V | | | | | | | | | V | `module:guest.address_check` |
|
||||||
|
| `guest.loyalty_status` | 1 | P01 | optional | tester_only | guest.details | V | | | | | | | | | V | `module:guest.loyalty_status` |
|
||||||
|
| `pricing.loyalty_discount` | 1 | P02 | optional | tester_only | guest.loyalty_status | V | | | | | | | | | V | `module:pricing.loyalty_discount` |
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
# Modul-Konfigurationsmatrix
|
||||||
|
|
||||||
|
Stand: 05.11.2026 (nach V2.1). **Die** verbindliche Übersicht, was an jedem registrierten Fachmodul tatsächlich einstellbar ist – und was nicht. Quelle: `config/process.php` (28 Module), `ModuleDefinition` der Module, `ChannelProcessConfiguration::STEP_CONTROLS`, `ProcessSetting`, die Modelle A1–A6 und der Code der Aktionen. Die technische Modul-/Modell-Tabelle (`Architektur/MODULMATRIX.md`) wird von `process:check --matrix` erzeugt; dieses Dokument ergänzt die **fachliche** Sicht und wird von Hand gepflegt.
|
||||||
|
|
||||||
|
Ein Modul gilt erst dann als konfigurierbar, wenn seine Varianten **auswählbar, speicherbar, wirksam und testbar** sind. Spalte „Zustand“ benennt das je Modul ehrlich.
|
||||||
|
|
||||||
|
## 1. Einordnung der Einschränkungen
|
||||||
|
|
||||||
|
| Kürzel | Bedeutung |
|
||||||
|
|---|---|
|
||||||
|
| **V** | Technisch vorhanden, im Konfigurator nicht (mehr) sichtbar |
|
||||||
|
| **R** | Unnötig restriktive Validierung oder historische Implementierungsentscheidung |
|
||||||
|
| **P** | Zulässige Option, aber der Konfigurationsparameter fehlt |
|
||||||
|
| **F** | Fachliche Fähigkeit fehlt (Implementierungsumfang angegeben) |
|
||||||
|
| **S** | Unveränderliche Sicherheitsregel (nicht Gegenstand der Konfiguration) |
|
||||||
|
| **O** | Fachliche Festlegung offen (blockiert die Umsetzung nicht) |
|
||||||
|
|
||||||
|
Grundregeln, die für **alle** Module gelten (S): Pflichtschritte sind nicht abschaltbar; Verbindlichkeit beim Portal wird nie von uns aufgehoben (E-036); Verfügbarkeit wird immer geprüft (E-027); Preise kommen nur aus `PriceCalculator` bzw. dem Portal; kein Versand an Gäste außerhalb des Mail-Tores (`EnforceMailTestMode`); laufende Vorgänge behalten ihren eingefrorenen Plan (E3); Nachrichten werden nur über einen verifizierten Bezug einem Vorgang zugeordnet (CH-07).
|
||||||
|
|
||||||
|
Wirkungsweise einer Einstellung: Landlord → Wohnung → Kanal je Eingangsart (`ProcessSettings`); das Modell kann Werte festlegen (`fixes()`), bestätigte Altwerte, die das Modell überstimmt, werden nach ausdrücklicher Bestätigung entfernt (`ConfigureChannelProcess`, Konflikte). Neue Vorgänge folgen der neuen Konfiguration, laufende nicht.
|
||||||
|
|
||||||
|
## 2. Übersicht
|
||||||
|
|
||||||
|
| Modul | Ablauf | Abschaltbar | Einstellbar im Konfigurator | Zustand |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| `intake.record` | alle | nein (S) | – | vollständig, nichts einzustellen |
|
||||||
|
| `guest.details` | A1–A5 | nein (S) | Anschrift im Formular Pflicht | vollständig |
|
||||||
|
| `guest.data_request` | A1–A5 | ja | Modus, Erinnerungen, Folgefragen, Abstand, Linkdauer | vollständig |
|
||||||
|
| `hold` | A1/A2 | bedingt | Vorreservierung, Frist, Klärungsfrist | vollständig |
|
||||||
|
| `availability.check` | A1/A2 | nein (S) | – | vollständig |
|
||||||
|
| `binding.portal` | A3–A5 | nein (S) | – | vollständig |
|
||||||
|
| `channels.block` | alle | nein (S) | – | Aufgabenweg je Portal über Kanaldaten |
|
||||||
|
| `portal.confirmation` | A3–A5 | bedingt | Warten ja/nein, Wartefrist | Nachweis-Mindestumfang **O** |
|
||||||
|
| `offer.information` | A1/A2 | nein | Modus, Linkdauer | vollständig |
|
||||||
|
| `offer.binding` | A1/A2 | nein | Modus, Haltefrist, Vorlage | vollständig |
|
||||||
|
| `offer.acceptance` | A1/A2 | nein (S) | – | vollständig |
|
||||||
|
| `documents.send` | A1–A5 | nein | Modus, Zustellung, Vorlage | Zustellwege vollständig, Varianten siehe 3.12 |
|
||||||
|
| `documents.booking_notice` | A3–A5 | bedingt | Buchungsinformation: Art | vollständig |
|
||||||
|
| `documents.stay_confirmation` | A6 | ja | – | nur manuell (P) |
|
||||||
|
| `case.tasks` | alle | – | – | ereignisgesteuert |
|
||||||
|
| `change.proposal` | A1–A5 | – | – | ereignisgesteuert |
|
||||||
|
| `case.closure` | alle | nein (S) | – | – |
|
||||||
|
| `case.settlement` | alle | nein (S) | – | – |
|
||||||
|
| `payments.monitor` | A1–A5 | nein | Zahler (durch Modell) | **Zahlungsanforderung, Erinnerung, Mahnung nicht konfigurierbar (F/P)** |
|
||||||
|
| `portal.payout` | A1–A5 | nein | – | Nachweis-Mindestumfang **O** |
|
||||||
|
| `payments.internal` | A6 | bedingt | – | – |
|
||||||
|
| `arrival.details` | A1–A5 | ja | nur Schalter | Parameter fehlen (P) |
|
||||||
|
| `arrival.info` | A1–A5 | nein | Absender, Tage vor Anreise | Zustellweg Dienstleister nicht ausgeführt (F) |
|
||||||
|
| `stay` | alle | nein (S) | – | – |
|
||||||
|
| `review.request` | A1–A5 | ja | Absender (über Gastkommunikation) | Zeitpunkt nur mandantenweit (P) |
|
||||||
|
| `guest.address_check` | Tester | ja | – | nur Prozess-Tester (Erweiterungsnachweis) |
|
||||||
|
| `guest.loyalty_status` | Tester | ja | Mindestbesuche, Rückblick | nur Prozess-Tester (E7) |
|
||||||
|
| `pricing.loyalty_discount` | Tester | ja | Prozent, Höchstbetrag | nur Prozess-Tester (E7) |
|
||||||
|
|
||||||
|
## 3. Module im Einzelnen
|
||||||
|
|
||||||
|
Die zwölf Punkte je Modul sind in der Kurzform: **Ergebnis/Invarianten · Aktivierung · Varianten · Auslöser · Voraussetzungen · Parameter · Kommunikation/Nachweis · Alternativen · Wirkung auf andere · Fehler/Warten/Eskalation · Ist (Code/UI) · Fehlt**. Was nicht aufgeführt ist, gibt es für das Modul nicht und wird nicht gebraucht.
|
||||||
|
|
||||||
|
### 3.1 `intake.record` – Eingang
|
||||||
|
Ergebnis: Vorgang mit eingefrorenem Plan, Belegung gesetzt. Invarianten (S): immer; friert Modell und Version ein. Auslöser: `intake`. Alle anderen Module hängen hart daran. Keine Parameter. Ist: vollständig. Fehlt: nichts.
|
||||||
|
|
||||||
|
### 3.2 `guest.details` – Angaben des Gastes
|
||||||
|
Ergebnis: Gast identifiziert, Angaben aus allen Quellen zusammengeführt, Vollständigkeit geprüft (G2a). Pflicht, wenn wir selbst schreiben. Varianten (Ausführung): automatisch, von Hand. Auslöser: `facts.applied`. Parameter: `form_requires_address` (Anschrift im Formular Pflicht; nur Anfragen). Beschaffung der fehlenden Angaben ist **unabhängig** vom Modul `guest.data_request`; beim Wegfall der Anfrage bleiben die Pflichtangaben erforderlich, die Alternative ist die manuelle Erfassung/Aufgabe. Ist: vollständig. Fehlt: Pflichtfeldliste je Kanal (P, später).
|
||||||
|
|
||||||
|
### 3.3 `guest.data_request` – Fehlende Angaben anfragen
|
||||||
|
Ergebnis: fehlende Pflichtangaben kommen per Link vom Gast. Optional (V2.1 unabhängig). Varianten: automatisch, nach Freigabe, von Hand, nicht erforderlich. Auslöser: `request.created`, `booking.taken_over`, Wunsch. Parameter (alle einstellbar): `data_request_mode`, `data_request_reminders_max`, `data_request_followups_max`, `data_request_reminder_hours`, `guest_link_valid_days` (nur Landlord-/Wohnungsebene, nicht je Kanal). Kommunikation: Mail mit signiertem Link; Nachweis: Antwort-Fakten (Provenienz). Warten: Gast, Zeit, danach Übergabe an Sie. Wirkung: bei „nicht erforderlich“ bleiben `guest.details` und alles, was es voraussetzt, bestehen – der Konfigurator zeigt die Ersatzwege (siehe Abschnitt 5). Ist: vollständig. Fehlt: Medium je Anfrage (WhatsApp usw.) – F, hängt an F4/F5.
|
||||||
|
|
||||||
|
### 3.4 `hold` – Reservierung
|
||||||
|
Ergebnis: Zeitraum frei halten, nach Ablauf freigeben (`Booking::occupying()` ignoriert abgelaufene Haltefristen). Varianten: nur Anfragen mit Vorreservierung. Parameter: `pre_reservation`, `hold_hours`, `clarification_hold_auto_minutes`, `clarification_hold_manual_minutes`. Zustand: vollständig. Fehlt: nichts.
|
||||||
|
|
||||||
|
### 3.5 `availability.check` – Verfügbarkeit
|
||||||
|
Pflicht (S, E-027). Keine Parameter. Fehlt nichts.
|
||||||
|
|
||||||
|
### 3.6 `binding.portal` – Verbindlichkeit beim Portal
|
||||||
|
Ergebnis: Buchung verbindlich beim Portal (E-036), Gesamtpreis laut Portal übernommen. Pflicht (S). Ausführung: Portal, von Hand. Auslöser: `intake`, `portal.amounts`. Fehlt nichts.
|
||||||
|
|
||||||
|
### 3.7 `channels.block` – Andere Kanäle sperren
|
||||||
|
Ergebnis: Belegung in Portalen nachgezogen, Nachweis je Portal. Pflicht (S). Ausführung: automatisch (iCal/Connector) oder von Hand (`ChannelTask`). Parameter je Portal in den Kanaldaten (`requires_manual_blocking`, iCal-URL); Erinnerung `task_reminder_after_minutes` (Betrieb). Eskalation: Aufgabe, Erinnerung, Postfach. Fehlt: nichts im Ablauf.
|
||||||
|
|
||||||
|
### 3.8 `portal.confirmation` – Bestätigung des Portals abwarten
|
||||||
|
Ergebnis: Nachweis der Portalbestätigung (PortalEmail-Buchung deterministisch verknüpft oder Ereignis des Vermieters). Bedingt: nur bei extern verbindlicher Buchung. Varianten: automatisch, von Hand, nicht erforderlich. Parameter: `await_portal_confirmation`, `portal_confirmation_wait_hours` (Vorschlag 48). Wirkung: **nur** `documents.send` und `documents.booking_notice` warten; Belegung, Datenbeschaffung, Zahlungsüberwachung nicht. Fristablauf: genau eine Aufgabe `PortalConfirmationMissing`, kein automatisches Aufheben. Fortsetzung: `portal.mail`, `schedule:waiting`. **O**: Mindestnachweis (D3) und akzeptierte Angaben (D4) = F2; Wartefrist = F3 (Vorschlag steht). Ist: vollständig im Rahmen der Vorschläge.
|
||||||
|
|
||||||
|
### 3.9 `offer.information` / `offer.binding` / `offer.acceptance`
|
||||||
|
Ergebnis: Auskunft (A1/A2 ohne Reservierung) bzw. verbindliches Angebot mit Vertragsentwurf (Version, signierter Link) und Annahme durch den Gast. Annahme ist Pflicht (S, E-003). Parameter: `processing` (automatisch/Freigabe/von Hand), `hold_hours`, `contract_template_id`, `guest_link_valid_days`. Preisänderungen nur als `Adjustment`-Zeile. Fehlt: nichts; ein Zahlungsplan im Angebot (Anzahlungsanteil/Termine) ist nicht je Kanal einstellbar (siehe 3.17).
|
||||||
|
|
||||||
|
### 3.10 `documents.send` – Buchungsunterlagen (Vertragsdokumentation)
|
||||||
|
Ergebnis: die Vertragsdokumentation erreicht den Gast – von uns oder vom Portal (O1). Pflicht (S). Varianten (`Execution`): automatisch, nach Freigabe, von Hand, durch das Portal (A5). Parameter: `documents` (Verantwortung; durch das Modell festgelegt), `processing`, `contract_delivery` (folgt dem Modus / automatisch / von Hand / intern), `contract_template_id`. Auslöser: `automation`, `booking.taken_over`, `portal.mail`, `schedule:waiting`. Voraussetzungen hart: `guest.details`, `portal.confirmation` (sofern im Plan). Fehlt: Auswahl mehrerer Dokumentenarten (z. B. nur Buchungsbestätigung ohne Vertrag) – der Weg dafür ist `documents.booking_notice`; Dokumentenarten selbst sind **F** (mittel).
|
||||||
|
|
||||||
|
### 3.11 `documents.booking_notice` – Buchungsinformation
|
||||||
|
Ergebnis: kurze Information ohne Vertrag, unabhängig von den Vertragsunterlagen. Parameter: `booking_notice` (aus/automatisch/von Hand/Portal). Wartet auf `portal.confirmation`, falls im Plan. Vollständig.
|
||||||
|
|
||||||
|
### 3.12 `documents.stay_confirmation` (A6)
|
||||||
|
Nur manuell oder nicht erforderlich. Kein Parameter nötig. Fehlt nichts.
|
||||||
|
|
||||||
|
### 3.13 `case.tasks`, `change.proposal` (ereignisgesteuert)
|
||||||
|
Zeigen Aufgaben bzw. Änderungsvorschläge. Keine Einstellung; Eskalation über Postfach/Digest (`reminder_interval_days`, Betrieb).
|
||||||
|
|
||||||
|
### 3.14 `case.closure`, `case.settlement`, `stay`
|
||||||
|
Pflicht (S). Abschluss erst, wenn nichts mehr offen ist (E-010); kaufmännischer Abschluss braucht tatsächliche Nachweise (O5), eine Portalmeldung ersetzt sie nicht. Keine Parameter. Fehlt: Storno-/Erstattungsregeln je Modell (F, **O**: DS-06/FW-05).
|
||||||
|
|
||||||
|
### 3.15 `payments.monitor` – Zahlungen des Gastes
|
||||||
|
Ergebnis: Anzahlung/Restzahlung überwacht (wir) oder „laut Portal“ (Portal zieht ein). Wer kassiert, legt das **Modell** fest (A3 wir, A4/A5 Portal); bei A1–A3 sind die Fristen:
|
||||||
|
|
||||||
|
| Teil | Ist | Zustand |
|
||||||
|
|---|---|---|
|
||||||
|
| Frist Anzahlung | `deposit_due_days` (Betrieb, mandantenweit; im Angebot eingefroren) | **P**: nicht je Kanal/Eingang |
|
||||||
|
| Zahlungsanforderung (Restzahlung) | Aufgabe 7 Tage vor Fälligkeit (`SendBookingReminders::BALANCE_REQUEST_DAYS_BEFORE`, Konstante) | **P**: Konstante, einstellbar machen |
|
||||||
|
| Zahlungserinnerung | Aufgabe für den Vermieter, Versand per Klick (`SendPaymentReminder`) | vorhanden, **nicht automatisch** (bewusst, S); Modus automatisch/Freigabe = **F** (klein) |
|
||||||
|
| Mahnung (mehrstufig) | gibt es nicht | **F** (mittel): Stufen, Fristen, Texte, Gebühren-Regel; rechtlich zu prüfen **O** |
|
||||||
|
| Zahlungseingang | Vermieter erfasst (`RecordPayment`); Bank-Abgleich nicht vorhanden | **F** (groß, später) |
|
||||||
|
|
||||||
|
Fehlt (Referenzfall A3): konfigurierbare Zahlungsanforderungen/-erinnerungen/Mahnungen. Priorisiert in Abschnitt 6.
|
||||||
|
|
||||||
|
### 3.16 `portal.payout`
|
||||||
|
Nachweis des tatsächlichen Eingangs der Auszahlung (O5). Nur wo das Portal einzieht (A4/A5). Manuell. **O**: DS-Inkasso F7.
|
||||||
|
|
||||||
|
### 3.17 `arrival.details`, `arrival.info`
|
||||||
|
`arrival.details` (optional): Telefon, Anreisezeit; keine Parameter (P: Pflichtfelder, Erinnerungsabstand). `arrival.info`: Absender (wir/Portal/Dienstleister/nicht erforderlich) über `guest_messages` (nach Modell erlaubt), Zeitpunkt `arrival_info_days_before` (≤ 14, Konstante). Zurückgehalten bei offener Portalmeldung (O4). **F**: Zustellung durch Dienstleister (Ausführung „service_provider“ ohne Anbindung – klein, nur Aufgabe).
|
||||||
|
|
||||||
|
### 3.18 `review.request`
|
||||||
|
Optional. Absender wie `arrival.info` (Portal schreibt dem Gast → Schritt entfällt). Zeitpunkt `review_request_after_days` nur mandantenweit (**P**). Vollständig sonst.
|
||||||
|
|
||||||
|
### 3.19 `payments.internal` (A6)
|
||||||
|
Zahlung ohne Erinnerungen, manuell. Fehlt nichts.
|
||||||
|
|
||||||
|
### 3.20 Tester-Module
|
||||||
|
`guest.address_check`, `guest.loyalty_status`, `pricing.loyalty_discount`: Erweiterungsnachweis (E7); nur im Prozess-Tester, nie im Plan eines echten Vorgangs (S). Parameter dort sichtbar. Bleiben so, solange nicht ausdrücklich freigegeben.
|
||||||
|
|
||||||
|
## 4. Technisch vorhanden, im Konfigurator nicht sichtbar (V) – Ergebnis der Prüfung
|
||||||
|
|
||||||
|
Geprüft wurde jede der 20 Einstellungen aus `ProcessSetting` gegen `STEP_CONTROLS`: **17 sitzen an einem Schritt; die übrigen drei (`pre_reservation`, `documents`, `payments`) werden durch die Wahl des Modells entschieden** (A1/A2 Angebot oder Auskunft, A3–A5 Verantwortung für Unterlagen und Inkasso) und sind deshalb bewusst kein Schrittparameter. Es gibt keine versteckte, bereits implementierte Variante, die nur freizulegen wäre. Gefunden wurden stattdessen:
|
||||||
|
|
||||||
|
| Befund | Art | Maßnahme |
|
||||||
|
|---|---|---|
|
||||||
|
| Veralteter Altwert (`payments`/`guest_messages = portal`) blockierte den Wechsel zu A3 trotz Bestätigung | Implementierungsdefekt | **behoben** (`a3ab1b6`): Konflikte umfassen auch nicht mehr erlaubte variable Verantwortlichkeiten; bestätigte Altwerte werden nicht mehr gegen das neue Modell geprüft |
|
||||||
|
| Balance-Anforderung 7 Tage, Anreise-Info Obergrenze 14 Tage, Bewertungsbitte-Tage, Anzahlungsfrist | **P** | als Einstellung einführen (Abschnitt 6, Prio 2) |
|
||||||
|
| Linkdauer/Erinnerungsparameter der Datenanfrage nur auf Landlord-/Wohnungsebene | **R** (historisch) | je Kanal ermöglichen, wenn gewünscht (klein) |
|
||||||
|
| Auswahl der Ersatzstrategie bei Wegfall eines Moduls | fehlte als Hilfe | **neu**: Auswirkungs-Abgleich (Abschnitt 5) |
|
||||||
|
|
||||||
|
## 5. Auswirkungs-Abgleich (Auftrag 4)
|
||||||
|
|
||||||
|
`App\Process\ConfigurationImpact` wertet die Moduldefinitionen aus (`requires` hart/weich, `executions`, `why`, Plan des Modells) für den **Entwurf** des Konfigurators und liefert je Änderung: betroffene abhängige Schritte, weiterhin erforderliche fachliche Ergebnisse, zulässige Ersatzwege und einen Vorschlag. Er ändert nie selbst etwas. Das Beispiel „automatische Datenanfrage aus“ ergibt: Pflichtangaben bleiben erforderlich (`guest.details`), Ersatz: „nach Freigabe“, „von Hand“ (Aufgabe).
|
||||||
|
|
||||||
|
## 6. Fehlende Fähigkeiten, priorisiert
|
||||||
|
|
||||||
|
| Prio | Fähigkeit | Umfang | Abhängigkeit |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 1 | Zahlungsplan je Kanal/Eingang: Anzahlungsanteil, Fristen (Tage), Anforderung X Tage vor Fälligkeit als `ProcessSetting` | klein–mittel: Enum-Fall(e), ConfirmBooking/TakeOver, `SendBookingReminders`, Konfigurator, Tests | F7 (wer kassiert) |
|
||||||
|
| 1 | Zahlungserinnerung automatisch/mit Freigabe statt nur Aufgabe | klein, aber Tor `EnforceMailTestMode` und Gastkommunikation beachten | Prio 1 oben |
|
||||||
|
| 2 | Mahnstufen (Fristen, Texte, Stufen) | mittel; rechtliche Prüfung nötig **O** | Zahlungsplan |
|
||||||
|
| 2 | Einstellbare Zeitpunkte: Anreise-Info Obergrenze, Bewertungsbitte je Kanal | klein | – |
|
||||||
|
| 3 | Nachweis-Mindestumfang Portalbestätigung (D3/D4) | klein, nach Beschluss F2 | **O** F2 |
|
||||||
|
| 3 | Dienstleister-Zustellung Anreise-Info | klein (Aufgabe) bis mittel (Anbindung) | – |
|
||||||
|
| 4 | Dokumentenarten je Kanal wählbar | mittel | – |
|
||||||
|
| 4 | Kommunikationskanal je Anfrage (WhatsApp usw.) | groß, Anbindung ausgeschlossen | F4/F5 |
|
||||||
|
| 4 | Bank-Abgleich Zahlungseingang | groß | – |
|
||||||
|
|
||||||
|
## 7. Offene Festlegungen (blockieren nichts)
|
||||||
|
|
||||||
|
F2 Mindestnachweis, F3 Wartefrist (Vorschlag 48 h), F4/F5 Messenger, F6 DS-01…06/FW-01…07 Prüfpunkte, F7 Inkasso Destination Solutions, Storno/Erstattung je Modell (DS-06/FW-05), rechtliche Ausgestaltung der Mahnung. Siehe `V2.1/01_KONFIGURATIONSLUECKEN.md`.
|
||||||
|
|
||||||
|
## 8. Referenzfall Destination Solutions A3 – was heute **ohne Quellcodeänderung** einstellbar ist
|
||||||
|
|
||||||
|
| Anforderung | Einstellbar? |
|
||||||
|
|---|---|
|
||||||
|
| Extern verbindliche Buchung | ja (Modell A3, `binding.portal`) |
|
||||||
|
| Eigene Zahlungsabwicklung | ja (A3, Inkasso beim Vermieter; Wechsel A4↔A3 inkl. Bestätigung getestet) |
|
||||||
|
| Dokumentenerstellung/-übermittlung | ja: `processing`, `contract_delivery`, Vorlage, Buchungsinformation |
|
||||||
|
| Zahlungsanforderung, Fristen | **teilweise**: Anzahlungsfrist mandantenweit; Rest-Anforderung fest 7 Tage (P) |
|
||||||
|
| Zahlungserinnerung | **teilweise**: Aufgabe + Versand per Klick |
|
||||||
|
| Mahnung | **nein** (F) |
|
||||||
|
| Warten auf Portalbestätigung für Folgeaktionen | ja (Schalter + Frist) |
|
||||||
|
| Unabhängige Datenbeschaffung | ja (`guest.data_request`, eigene Modi) |
|
||||||
|
| Fristen, Nachweise, Eskalationen | ja (Aufgaben, Postfach, Digest); Zahlungs-Eskalation siehe oben |
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Funktionsschablonen und Basisprozess „Extern verbindliche Portalbuchung“
|
||||||
|
|
||||||
|
Stand: 05.11.2026 · Branch `feature/schablonenkomposition` · kurze technische Umsetzungsgrundlage, keine neue Architekturstudie.
|
||||||
|
|
||||||
|
## 1. Prinzip
|
||||||
|
|
||||||
|
Der Basisprozess bleibt (P01–P05, `ProcessRunner`, Moduldefinitionen, harte/weiche Abhängigkeiten). Neu ist nur:
|
||||||
|
|
||||||
|
- **Platz (Slot)** im Modell (`Step::slot(TemplateArea)`), an dem die gewählte **Funktionsschablone** ihre bereits vorhandenen Module einsetzt.
|
||||||
|
- **Schablone** (`App\Process\Templates\FunctionTemplate`, versioniert, in `config/process.php › templates`): Zweck, Module, benötigte/gelieferte Ergebnisse, Verantwortlichkeit, Portal-Fähigkeit, Ausschlüsse, Dimensionen, noch nicht gebaute Erweiterungen.
|
||||||
|
- **`TemplateComposer`** (rein lesend): löst die Wahl auf, prüft Plätze/Bereiche, Voraussetzungen, doppelte Ergebnisse, Ausschlüsse, widersprüchliche Verantwortlichkeiten, doppelte Module und harte Modulabhängigkeiten. Keine Regelsprache, keine zweite Engine.
|
||||||
|
- Der **Plan** (`ProcessPlan`) friert Schablonen mit Version ein (`bookings.profile.plan.templates`, optional – alte Pläne bleiben lesbar). Die Schablone legt die Verantwortlichkeit ihres Bereichs fest (`ProcessSettings`, Quelle `template`); alle anderen Parameter laufen weiter über Systemstandard → Vermieter → Wohnung → Kanal × Eingangsart → eingefroren.
|
||||||
|
- `CaseType` A1–A6 bleibt **abgeleitete Klassifikation** (Berichte, Altfälle). Die vierte Kombination (eigenes Inkasso + externe Unterlagen) wird als A3 klassifiziert („wir kassieren“); es gibt kein A7.
|
||||||
|
|
||||||
|
## 2. Zuordnung: bisheriger Funktionsblock → Module → Schablone
|
||||||
|
|
||||||
|
| Funktionsblock (Prozesslandkarte) | Module | Zuordnung |
|
||||||
|
|---|---|---|
|
||||||
|
| Eingang, Gastangaben, Verbindlichkeit beim Portal, Bestätigung abwarten, Kalender sperren | `intake.record`, `guest.details`, `binding.portal`, `portal.confirmation`, `channels.block` | fester Bestandteil des Basisprozesses |
|
||||||
|
| Datenbeschaffung | `guest.data_request` | fest, Ausführung am Modul wählbar (automatisch/Freigabe/von Hand/nicht erforderlich) – eigene Schablone erst bei echten Alternativen |
|
||||||
|
| **Vertragsdokumentation** | `documents.send`, `documents.booking_notice` | **Schablonen** `contract_docs.own` / `contract_docs.external` |
|
||||||
|
| **Finanzabwicklung** | `payments.monitor` (+ `portal.payout`) | **Schablonen** `collection.own` (Zahlungsüberwachung) / `collection.portal` (Portalzahlungen + Auszahlungskontrolle) |
|
||||||
|
| Aufgaben, Änderungen | `case.tasks`, `change.proposal` | fest (ereignisgesteuert) |
|
||||||
|
| Anreise, Aufenthalt, Bewertung | `arrival.details`, `arrival.info`, `stay`, `review.request` | fest, Absender am Modul wählbar (Gastkommunikation) |
|
||||||
|
| Abschluss | `case.closure`, `case.settlement` | fest (Pflicht, Nachweise nach O5) |
|
||||||
|
| Angebot/Annahme (A1/A2), interne Belegung (A6), Tester-Module | `offer.*`, `hold`, `availability.check`, `payments.internal`, `documents.stay_confirmation`, `guest.*`/`pricing.*` (Tester) | nicht Teil dieses Umbaus; spätere Schablonen nutzen dasselbe Prinzip |
|
||||||
|
|
||||||
|
Es wurden bewusst **nur zwei Bereiche** zu Schablonen: dort liegen die unterschiedlichen Verantwortlichkeiten. Module wurden nicht zusammengefasst.
|
||||||
|
|
||||||
|
## 3. Die vier Schablonen
|
||||||
|
|
||||||
|
| Schablone | Module | Verantwortung | Portal-Fähigkeit | Liefert | Braucht |
|
||||||
|
|---|---|---|---|---|---|
|
||||||
|
| `collection.own@1` Eigenes Inkasso | `payments.monitor` | wir | Portal zieht **nicht** ein | `money.collection_handled`, `money.guest_payments_monitored` | `binding.portal_total` |
|
||||||
|
| `collection.portal@1` Portal-Inkasso | `payments.monitor`, `portal.payout` | Portal | Portal zieht ein | `money.collection_handled`, `money.portal_payout_checked` | `binding.portal_total` |
|
||||||
|
| `contract_docs.own@1` Eigene Vertragsdokumentation | `documents.send`, `documents.booking_notice` | wir | Portal stellt **keine** Unterlagen bereit | `contract.documented`, `contract.documents_by_us` | `guest.identified` |
|
||||||
|
| `contract_docs.external@1` Externe Vertragsunterlagen | dieselben Module | Portal | Portal stellt Unterlagen bereit | `contract.documented`, `contract.documents_by_portal` | – |
|
||||||
|
|
||||||
|
Die Schablonen der Dokumente unterscheiden sich nicht in den Modulen, sondern in **Verantwortung, Ausführungsart (Portal statt wir) und Nachweis** (§4.2 des Auftrags): Vertragsbedingungen – Erstellung – Bereitstellung/Versand – Nachweis stehen als `dimensions()` an der Schablone; Erstellung, Ablage, Bereitstellung und Versand bleiben am Modul einzeln einstellbar (`processing`, `contract_delivery`, Vorlage). Was die Unterlagen des Portals über Zahlungen sagen, ändert nichts an der Zahlungsüberwachung: sie folgt allein der Finanzschablone.
|
||||||
|
|
||||||
|
## 4. Die vier Pflichtkombinationen
|
||||||
|
|
||||||
|
| # | Inkasso | Dokumente | Klassifikation | Entspricht |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| 1 | eigenes | eigene | A3 | A3 v2 |
|
||||||
|
| 2 | Portal | eigene | A4 | A4 v2 |
|
||||||
|
| 3 | Portal | externe | A5 | A5 v2 |
|
||||||
|
| 4 | eigenes | externe | A3 | – (bisher nicht darstellbar) |
|
||||||
|
|
||||||
|
`TemplateCompositionTest` beweist: Kombinationen 1–3 haben dasselbe wirksame Profil, dieselben Aktivitäten/Zustände und denselben Ablauf wie A3–A5 (nur `portal.payout` entfällt, wo wir selbst kassieren). `TemplateProcessTesterTest` spielt alle vier im isolierten Prozess-Tester durch.
|
||||||
|
|
||||||
|
## 5. Unbestätigte Portal-Fähigkeiten
|
||||||
|
|
||||||
|
Die Schablonenwahl prüft die **bestätigten** Fähigkeiten des Kanals. Widerspruch → Schablone nicht wählbar, mit Begründung und Weg. Unbekannt oder nur vorgeschlagen/abgeleitet → nicht gesperrt, aber überall als „nicht bestätigt“ gekennzeichnet (Konfigurator, Tester-Bericht); sie gilt nie als nachgewiesen.
|
||||||
|
|
||||||
|
## 6. Umgang mit A3–A5
|
||||||
|
|
||||||
|
`external.booking@1` ist der Basisprozess für neue Konfigurationen. A3/A4/A5 (v1/v2) bleiben registriert (eingefrorene Pläne, Altkanäle) und sind im Konfigurator **Voreinstellungen** („Auf Schablonen umstellen“ / „Bekannte Kombinationen“). Gespeicherte Kanäle ändern sich nicht, bis jemand ausdrücklich speichert. `ProcessCatalogue::derivedModel` und die Altfall-Ableitung bleiben unverändert.
|
||||||
|
|
||||||
|
Stellen, an denen `CaseType`/A3–A5 vorher etwas entschieden, und was jetzt gilt:
|
||||||
|
|
||||||
|
| Stelle | Vorher | Jetzt |
|
||||||
|
|---|---|---|
|
||||||
|
| `ProcessProfile::caseTypeFor` | Dokumente = Portal ⇒ immer A5 | A5 nur, wenn Portal Dokumente **und** Inkasso hat; sonst A4 (Inkasso Portal) bzw. A3 – reine Klassifikation |
|
||||||
|
| `ProcessPlan::freeze` (Modell zulässig für Vorgangsart) | Modell nennt genau eine Art | `external.booking` nennt A3–A5; die Schablonenwahl bestimmt den Ablauf |
|
||||||
|
| `ProcessCatalogue::derivedModel` | Altfall-/Ableitungspfad nach Vorgangsart | unverändert (Altfälle, Kanäle ohne gewähltes Modell) |
|
||||||
|
| `isExternallyBinding()` (Änderung/Storno/Anzeige) | A3–A5 | unverändert, gilt für alle vier Kombinationen |
|
||||||
|
| `payments()` / `documents()` (Zahlungsaufgaben, Dokumentenart, Abschluss, Auszahlung) | Wert aus Modell-`fixes()` | Wert aus der Schablone (Quelle `template`); die Module selbst blieben unverändert |
|
||||||
|
|
||||||
|
## 7. Bewusste Grenzen / offen
|
||||||
|
|
||||||
|
- Mahnstufen, Zahlungsplan je Kanal, Bank-Abgleich: Erweiterungen (`OwnCollection::extensions()`), nicht erfunden.
|
||||||
|
- Weitere Bereiche (Gastkommunikation, Datenbeschaffung, Aufenthalt) nutzen später dasselbe Prinzip (`TemplateArea` um einen Fall und einen Platz im Modell erweitern).
|
||||||
|
- A1/A2 und A6 haben noch keine Plätze.
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
# Schablonenkatalog – alle Geschäftsvorfälle aus Basisprozess, Schablonen und Fachmodulen
|
||||||
|
|
||||||
|
Stand: 05.11.2026 (Umsetzungsstand siehe Abschnitt 10) · Grundlage: Prozesslandkarte P01–P05, `MODUL_KONFIGURATIONSMATRIX.md`, Modelle A1–A6, `external.booking@1` ([SCHABLONEN.md](SCHABLONEN.md)), `ProcessRunner`, Prozess-Tester, `CommunicationRules`. Kein Code, keine neue Engine, kein neuer Archetyp. **Gebaut** heißt: im Code vorhanden und getestet; **vorgesehen** heißt: aus vorhandenen Modulen bildbar, aber noch nicht im Code.
|
||||||
|
|
||||||
|
## 1. Vier Achsen statt „Kanal = Prozess“
|
||||||
|
|
||||||
|
Ein Geschäftskanal kann mehrere Vorgangsarten liefern. Heute sind die Achsen bereits getrennt vorhanden, nur nicht zusammen sichtbar:
|
||||||
|
|
||||||
|
| Achse | Werte (Code) | Entscheidet |
|
||||||
|
|---|---|---|
|
||||||
|
| Geschäftskanal | `Channel` (eigene Webseite, Portal; `booking_model` inquiry/portal_booking/mixed, Portalprofil + bestätigte Fähigkeiten) | welche Eingangsarten und welche Schablonen überhaupt passen |
|
||||||
|
| Eingangsmedium | `Medium` (E-Mail, Formular aktiv; WhatsApp, Chat vorbereitet, `config/communication.php`), Portalmail, iCal | wie etwas ankommt, Einwilligung, Zustellweg – **nicht** den Ablauf |
|
||||||
|
| Nachrichtenabsicht | `MessageIntent`: Allgemeine Frage · Aufenthaltsanfrage · Antwort zum Vorgang · Daten liefern · Änderungswunsch · unklar | ob ein Vorgang entsteht oder ein bestehender fortgeführt wird (`MessageEffect`, nur über verifizierten Bezug) |
|
||||||
|
| Verbindlichkeit | `IntakeKind`: Anfrage (unverbindlich) · Buchung (extern schon verbindlich) · Intern | **welcher Basisprozess** gilt |
|
||||||
|
|
||||||
|
Daraus folgen **drei Basisprozesse** (kein vierter, kein A7): *Anfrage*, *Extern verbindliche Buchung* (gebaut: `external.booking`), *Interne Belegung*. Wer verbindlich macht, ist Teil des Basisprozesses: bei der Anfrage wir (Angebot → Annahme, E-003), bei der Buchung das Portal (E-036), intern niemand. Die Frage „welche Schablone“ stellt sich erst danach.
|
||||||
|
|
||||||
|
## 2. Geschäftsvorfälle und ihr Weg
|
||||||
|
|
||||||
|
| Vorfall | Heute | Basisprozess + Schablonen |
|
||||||
|
|---|---|---|
|
||||||
|
| Allgemeine Informationsfrage | **kein Vorgang**: `GeneralQuestion → AnswerInformation + Review` (Regel, nicht Prozessmodell) | Nachrichtenbearbeitung (Basisfunktion `MessageIntake`); kein Slot, kein Modul |
|
||||||
|
| Unverbindliche Verfügbarkeits-/Buchungsanfrage | `a1.information` / `a2.information` | Anfrage + *Anfragebeantwortung: Auskunft* |
|
||||||
|
| Anfrage mit verbindlichem Angebot | `a1.offer` / `a2.offer` | Anfrage + *Anfragebeantwortung: Verbindliches Angebot* |
|
||||||
|
| Extern verbindliche Buchung | `external.booking` (A3–A5 als Voreinstellung) | Buchung + *Finanz* + *Dokumente* (+ *Kommunikation*) |
|
||||||
|
| Interne Belegung (Sperre, Eigennutzung, private Überlassung) | `a6.internal` | Intern; Aufenthaltsbestätigung und Zahlung als optionale Fähigkeiten |
|
||||||
|
| Spätere Kommunikation/Änderung | `CaseReply`/`ProvideData`/`ChangeRequest` → `ReportToCase`/`ContributeFacts`; `change.proposal`, `case.tasks` | **kein eigener Ablauf**: ereignisgesteuerte Basisfunktionen jedes Vorgangs |
|
||||||
|
|
||||||
|
A1 und A2 unterscheiden sich im Code nur durch Klassifikation und die erlaubte Gastkommunikation (Portal darf bei A2 schreiben). Sie sind **ein** Anfrage-Basisprozess mit einer Kanalfähigkeit, nicht zwei Prozesse.
|
||||||
|
|
||||||
|
## 3. Ebenen und Zuordnung aller 28 Module
|
||||||
|
|
||||||
|
Legende: **Basis** = fester Bestandteil des Basisprozesses · **Schablone** · **optional** = eigenständige Fähigkeit (Schalter/Modus am Modul, keine Schablone, weil es keine fachlich verschiedenen Ausprägungen mit anderen Modulen gibt).
|
||||||
|
|
||||||
|
| Modul | Phase | Zuordnung | Basisprozess |
|
||||||
|
|---|---|---|---|
|
||||||
|
| `intake.record` | P01 | Basis (Pflicht) | alle |
|
||||||
|
| `guest.details` | P01 | Basis (Pflicht, wenn wir schreiben) | Anfrage, Buchung |
|
||||||
|
| `guest.data_request` | P01 | **optional** *Datenbeschaffung* (Modus: automatisch/Freigabe/Hand/nicht erforderlich) | Anfrage, Buchung |
|
||||||
|
| `hold` | P01 | **optional** *Reservierung* (Vorreservierung, Frist, Klärungsfrist) | Anfrage |
|
||||||
|
| `availability.check` | P01 | Basis (Pflicht, E-027) | Anfrage |
|
||||||
|
| `binding.portal` | P02 | Basis des Buchungs-Basisprozesses (Pflicht, E-036) | Buchung |
|
||||||
|
| `portal.confirmation` | P02 | Basis, bedingt (Warten ja/nein, Frist) | Buchung |
|
||||||
|
| `channels.block` | P02 | Basis (Pflicht) | alle |
|
||||||
|
| `offer.information` | P02 | **Schablone** Anfragebeantwortung – *Auskunft* | Anfrage |
|
||||||
|
| `offer.binding` | P02 | **Schablone** Anfragebeantwortung – *Verbindliches Angebot* (in beiden, bei Auskunft erst auf Buchungswunsch) | Anfrage |
|
||||||
|
| `offer.acceptance` | P02 | **Schablone** Anfragebeantwortung (Pflicht, E-003) | Anfrage |
|
||||||
|
| `documents.send` | P03 | **Schablone** Vertragsdokumentation | Anfrage, Buchung |
|
||||||
|
| `documents.booking_notice` | P03 | **Schablone** Vertragsdokumentation (einzeln schaltbar) | Buchung |
|
||||||
|
| `payments.monitor` | P03 | **Schablone** Finanzabwicklung | Anfrage, Buchung |
|
||||||
|
| `portal.payout` | P03 | **Schablone** Finanzabwicklung – *Portal-Inkasso* | Buchung |
|
||||||
|
| `arrival.details` | P04 | **Schablone** Gastkommunikation (optional im Modul) | Anfrage, Buchung |
|
||||||
|
| `arrival.info` | P04 | **Schablone** Gastkommunikation (Absender) | Anfrage, Buchung |
|
||||||
|
| `review.request` | P05 | **Schablone** Gastkommunikation (entfällt, wo das Portal schreibt) | Anfrage, Buchung |
|
||||||
|
| `stay` | P04 | Basis (Pflicht) | alle |
|
||||||
|
| `case.tasks` | P03 | Basis, ereignisgesteuert | alle |
|
||||||
|
| `change.proposal` | P03 | Basis, ereignisgesteuert (Portalmeldungen, Gästewünsche) | Anfrage, Buchung |
|
||||||
|
| `case.closure` | P05 | Basis (Pflicht, E-010) | alle |
|
||||||
|
| `case.settlement` | P05 | Basis (Pflicht, Nachweise nach O5) | alle |
|
||||||
|
| `documents.stay_confirmation` | P03 | **optional** (private Überlassung) | Intern |
|
||||||
|
| `payments.internal` | P03 | **optional** (Zahlung ohne Erinnerung) | Intern |
|
||||||
|
| `guest.address_check`, `guest.loyalty_status`, `pricing.loyalty_discount` | – | nur Prozess-Tester (E7); später Schablone *Gästebindung* (V02), nicht jetzt | – |
|
||||||
|
|
||||||
|
**Befund zur früheren Zerlegung:** Zusammengehörig sind (a) `offer.information`/`offer.binding`/`offer.acceptance` (Anfragebeantwortung, heute nur über das Modell-`fixes()` `pre_reservation` getrennt), (b) `arrival.details`/`arrival.info`/`review.request` (alle hängen am Setting `guest_messages`), (c) `payments.monitor`/`portal.payout` (bereits Schablone), (d) `documents.send`/`documents.booking_notice` (bereits Schablone). Es wird **nichts zusammengelegt**; die Module bleiben einzeln konfigurierbar. Dass die Zerlegung die Komposition eingeschränkt hat, zeigte sich nur bei Inkasso/Dokumenten (behoben) – bei Anfrage und Kommunikation steckt die Kopplung im Modell, nicht in den Modulen.
|
||||||
|
|
||||||
|
## 4. Katalog der Schablonen
|
||||||
|
|
||||||
|
Je Bereich genau eine Entscheidung; Bereiche sind unabhängig kombinierbar, soweit in 5 nichts anderes steht.
|
||||||
|
|
||||||
|
### 4.1 Finanzabwicklung – **gebaut** (`collection.own@1`, `collection.portal@1`)
|
||||||
|
- Zweck/Module/Ergebnisse/Fähigkeiten: siehe [SCHABLONEN.md §3](SCHABLONEN.md).
|
||||||
|
- Parameter: heute `deposit_due_days` (nur Vermieter-Ebene), Wer-kassiert (durch Schablone). Fehlend: Anforderung X Tage vor Fälligkeit (Konstante 7), Erinnerung automatisch/Freigabe, Mahnstufen, Bank-Abgleich (Matrix §6, Prio 1–2).
|
||||||
|
- Nachweise: Zahlungseingang (`RecordPayment`), Portalbeträge (`portal.amounts`), Auszahlungsnachweis (O5).
|
||||||
|
- Geschäftsvorfälle: Buchung (beide), Anfrage (nur *eigenes Inkasso*).
|
||||||
|
|
||||||
|
### 4.2 Vertragsdokumentation – **gebaut** (`contract_docs.own@1`, `contract_docs.external@1`)
|
||||||
|
- Parameter: `processing`, `contract_delivery`, `contract_template_id`, `booking_notice`.
|
||||||
|
- Wartet hart auf `guest.details` und `portal.confirmation` (falls im Plan); Nachweis: Dokument/Versandvermerk bzw. Portalbestätigung.
|
||||||
|
- Geschäftsvorfälle: Buchung (beide), Anfrage (nur *eigene*: der Vertrag entsteht erst mit unserem Angebot und der Annahme).
|
||||||
|
|
||||||
|
### 4.3 Anfragebeantwortung – **vorgesehen** (`inquiry.information`, `inquiry.binding_offer`)
|
||||||
|
- Zweck: wie wir auf eine Anfrage antworten und wann sie verbindlich wird.
|
||||||
|
- *Auskunft* = `offer.information` (+ `offer.binding`/`offer.acceptance` auf Buchungswunsch), setzt `pre_reservation=false`. *Verbindliches Angebot* = `offer.binding` + `offer.acceptance`, setzt `pre_reservation=true`.
|
||||||
|
- Eingaben: Gast identifiziert, Verfügbarkeit geprüft (harte Abhängigkeit von `guest.details`, `availability.check`); Ergebnis: Angebot Version n mit Vertragsentwurf, Annahmeprotokoll, danach Verbindlichkeit (`ConfirmBooking`).
|
||||||
|
- Parameter: `processing` (automatisch/Freigabe/Hand), `hold_hours`, `contract_template_id`, `guest_link_valid_days`; Preisänderung nur als `Adjustment`-Zeile.
|
||||||
|
- Nachweise: Annahme mit Zeitstempel/Prüfsumme (E-003). Inkompatibel mit Basisprozess *Buchung*.
|
||||||
|
- Geschäftsvorfälle: unverbindliche und verbindliche Anfrage (Website und Portalanfrage).
|
||||||
|
|
||||||
|
### 4.4 Gastkommunikation – **vorgesehen** (`guest_comm.own`, `guest_comm.portal`)
|
||||||
|
- Zweck: wer dem Gast Anreise-Information und Bewertungsbitte schickt. *Eigene* = `arrival.details`, `arrival.info`, `review.request`; *Portal* = `arrival.details`, `arrival.info` (Zustand „extern“), `review.request` entfällt. *Dienstleister* ist als Ausführung am Modul nur als Aufgabe vorhanden, keine Schablone.
|
||||||
|
- Heute gesteuert über das Setting `guest_messages` (Landlord/Portal) und die Fähigkeit `messages_guest`; Zulässigkeit je Modell in `Responsibilities`.
|
||||||
|
- Parameter: `arrival_info_days_before` (≤14, Konstante), Absender; Bewertungszeitpunkt nur mandantenweit.
|
||||||
|
- Fähigkeit: *Portal* nur, wenn `messages_guest` bestätigt; sonst Hinweis „nicht bestätigt“.
|
||||||
|
- Geschäftsvorfälle: Buchung, Anfrage (nur *eigene*, außer Portalanfrage mit Fähigkeit).
|
||||||
|
|
||||||
|
### 4.5 Bewusst **keine** Schablonen
|
||||||
|
Datenbeschaffung, Reservierung, Portalbestätigung, Aufenthaltsbestätigung/interne Zahlung: je ein Modul mit Modus/Parametern, ohne wechselnde Modulmengen. Eine Schablone dafür wäre eine Kleinstschablone. Auch Bereiche wie Gästebindung (Loyalty) oder Messenger bleiben, bis es echte Alternativen gibt.
|
||||||
|
|
||||||
|
## 5. Kombinationen und Unverträglichkeiten
|
||||||
|
|
||||||
|
| Basisprozess | Finanz | Dokumente | Anfragebeantwortung | Kommunikation |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| Buchung (`external.booking`) | own / portal (Fähigkeit `collects_payment`) | own / external (`provides_contract_documents`) | – | own / portal (`messages_guest`) |
|
||||||
|
| Anfrage (A1/A2) | **nur own** | **nur own** | information / binding_offer | own; portal nur bei Portalanfrage mit Fähigkeit |
|
||||||
|
| Intern (A6) | – | – | – | – (Aufenthaltsbestätigung/Zahlung optional) |
|
||||||
|
|
||||||
|
Unzulässig mit Begründung: *portal-Inkasso* bzw. *externe Unterlagen* im Anfrage-Basisprozess (wir schließen den Vertrag, E-003); Anfragebeantwortung im Buchungs-Basisprozess (schon verbindlich beim Portal, E-036); zwei Schablonen eines Bereichs (doppeltes Ergebnis); *eigenes Inkasso* bei bestätigter Portal-Einziehung (Doppelforderung). Die ersten beiden Regeln sind der fehlende Teil 7.1.
|
||||||
|
|
||||||
|
## 6. Abhängigkeiten und Parallelität (aus den Moduldefinitionen)
|
||||||
|
|
||||||
|
- **Anfrage:** `intake.record` → { `guest.details`, `hold`, `guest.data_request` } laufen **parallel**; `offer.binding` hängt hart an `guest.details` + `availability.check` (weich nach `guest.data_request`); `offer.acceptance` hart an `offer.binding`; erst danach Dokumente, Zahlungen, Anreise. Wartezustände: Gast (Daten, Annahme), Zeit (Hold-Ablauf → `ExpireReservations`).
|
||||||
|
- **Buchung:** `intake.record` → `binding.portal`; `portal.confirmation` wartet nur `documents.send`/`documents.booking_notice` (hart); Zahlungsüberwachung, Datenbeschaffung, Anreise, Kalender laufen unabhängig weiter (im Tester belegt).
|
||||||
|
- **Intern:** linear kurz, ohne Wartezustand.
|
||||||
|
- Bedingte Schritte (`applies()`): `portal.payout` nur bei Portal-Inkasso, `offer.information` nur ohne Vorreservierung, `review.request` nur wenn wir schreiben. Ereignisgesteuert: `case.tasks`, `change.proposal`.
|
||||||
|
|
||||||
|
## 7. Konkret fehlende Voraussetzungen (echte Lücken)
|
||||||
|
|
||||||
|
1. **Plätze in `InquiryModel`** (A1/A2): `TemplateArea` um *Anfragebeantwortung* und *Gastkommunikation* erweitern, `Step::slot` einsetzen. Die Schablonen-`fixes()` dürfen heute nur das Verantwortlichkeits-Setting ihres Bereichs setzen (`ProcessCatalogue::problems`); für `pre_reservation` muss der Bereich sein Setting nennen.
|
||||||
|
2. **Zulässige Schablonen je Basisprozess** (`allowedTemplates(area)` am Modell), damit *portal*-Inkasso/externe Unterlagen im Anfrage-Basisprozess begründet abgelehnt werden. Heute wirkt dort nur die Kanalfähigkeit.
|
||||||
|
3. **A1/A2 zu einem Anfrage-Basisprozess** (neues Modell `inquiry.request`, A1–A2 als Voreinstellungen). Alte Modelle und `derivedModel` bleiben für Altfälle.
|
||||||
|
4. **Nachrichtenregeln sichtbar machen:** `CommunicationRules` (Absicht → Wirkung) ist global und nur im Code; die allgemeine Informationsfrage braucht eine Anzeige (und später Einstellung) im Konfigurator, aber keinen Ablauf.
|
||||||
|
5. **Medium je Kanal:** aktivierte Medien sind global; ein Kanal kann sie nicht einschränken. Erst nötig mit WhatsApp/Chat.
|
||||||
|
6. **Ablaufspuren-Lesemodell** (siehe 8): rein lesend aus `requires`/`waits`/`triggers`/`applies`-Beschreibung; es fehlt nur die Aufbereitung, keine neuen Daten.
|
||||||
|
7. **Schon bekannte Fachlücken** (unverändert, nicht Teil dieses Katalogs): Zahlungsplan/Mahnstufen/Bank-Abgleich, Dienstleister-Zustellung, Mindestnachweis Portalbestätigung (F2), Dokumentenarten je Kanal, Storno/Erstattung (Matrix §6–7).
|
||||||
|
|
||||||
|
## 8. Bedienentwurf Kanal › Ablauf
|
||||||
|
|
||||||
|
Hauptansicht = Entscheidungen und Zusammenhang; die Schrittliste ist eine Detailebene.
|
||||||
|
|
||||||
|
```
|
||||||
|
Destination Solution [Feste Buchungen] [Anfragen: –] Modus: einfach | Experte
|
||||||
|
Fähigkeiten: Inkasso: nein ✓ bestätigt · Vertragsunterlagen: ja ⚠ nicht bestätigt · Gastnachrichten: nein ✓
|
||||||
|
|
||||||
|
1 So kommt es an Feste Buchung per Portalmail · Verbindlich beim Portal · Medium: E-Mail
|
||||||
|
2 Entscheidungen ( ) Finanz (•) Eigenes Inkasso ( ) Portal-Inkasso (nicht passend: Portal zieht nicht ein)
|
||||||
|
Dokumente ( ) Eigene (•) Externe Unterlagen ⚠ Fähigkeit nicht bestätigt
|
||||||
|
Kommunikation (•) Wir ( ) Portal
|
||||||
|
Immer dabei Datenbeschaffung [automatisch ▾] Portalbestätigung abwarten [48 h ▾]
|
||||||
|
3 Ablauf im Zusammenhang (aus den Abhängigkeiten, nicht aus einer Liste)
|
||||||
|
läuft sofort Eingang ▸ Gastangaben ▸ Kalender sperren ▸ Datenbeschaffung ▸ Zahlungsüberwachung
|
||||||
|
wartet auf Portal ⏳ Bestätigung ──▸ Buchungsinformation
|
||||||
|
bedingt Auszahlungskontrolle (nur Portal-Inkasso) · Bewertungsbitte (nur wenn wir schreiben)
|
||||||
|
später Anreise ▸ Aufenthalt ▸ Abschluss (braucht Nachweise)
|
||||||
|
4 Was ändert sich? Impact: Module, Verantwortung, Schalter/Einstellungen, Ersatzwege – nichts still
|
||||||
|
5 Einzelschritte ▸ (eingeklappt, gruppiert nach Schablone; je Modul Modus, Absender, Fristen, geerbter Wert + Herkunft)
|
||||||
|
[Ablauf testen] [Speichern – gilt für neue Vorgänge, 3 laufende bleiben]
|
||||||
|
```
|
||||||
|
|
||||||
|
Regeln: je Bereich eine Karte mit Zweck, Dimensionen, Fähigkeits-/Unverträglichkeitsgrund; *einfacher Modus* zeigt Punkte 1–4, *Experte* zusätzlich 5 mit Modulkennungen/Versionen; Spuren in 3 kommen aus `ProcessRunner`-Abhängigkeiten (hart = „wartet auf“, weich = „danach“, `applies()` = „bedingt“, `triggers` = „ereignisgesteuert“).
|
||||||
|
|
||||||
|
### Referenzfälle
|
||||||
|
- **Destination Solutions** (oben): Buchung + `collection.own` + `contract_docs.external` + `guest_comm.own` – heute bis auf die Kommunikationsschablone gebaut; der Katalog erklärt sie als Kombination 4.
|
||||||
|
- **Website – allgemeine Informationsfrage:** keine Ablaufkarte. Hauptansicht zeigt unter „Nachrichten“: Absicht *Allgemeine Frage* → Antwort mit Information + Prüfung durch Sie; kein Vorgang. (Lücke 7.4.)
|
||||||
|
- **Website – Buchungsanfrage:** Anfrage + `inquiry.binding_offer` (oder *Auskunft*) + `collection.own` + `contract_docs.own` + `guest_comm.own`; Spuren: *sofort parallel* Reservierung (`hold`, überwacht Ablauf) und Datenbeschaffung (wartet auf Gast, Folgefragen, Klärungsfrist); *wartet auf Gast* Angebotsannahme; *danach* Dokumente/Zahlung. Reservierungsüberwachung und Datenbeschaffung blockieren sich nicht, weil beide nur hart an `intake.record` hängen.
|
||||||
|
|
||||||
|
## 9. Präzisierungen (umgesetzt)
|
||||||
|
|
||||||
|
- **Kommunikation je Anlass, nicht global:** Statt einer Entweder-oder-Zuständigkeit gibt es je Anlass eine eigene Einstellung (`arrival_info_sender`, `review_request_sender`; Datenanfrage und Buchungsinformation hatten ihren eigenen Modus schon). Nicht gesetzt folgen sie dem bisherigen Sammelwert `guest_messages` – so verhalten sich Altfälle und Altkanäle wie zuvor. Die Schablonen `guest_comm.own` / `guest_comm.portal` liefern nur **Standardwerte** (unterste Ebene, jede ausdrücklich gesetzte Einstellung gewinnt) und setzen nichts fest.
|
||||||
|
- **Antwort ≠ Reservierung:** Neu ist die Einstellung `inquiry_answer` (Auskunft/Angebot), gesetzt von der Anfrageschablone. `pre_reservation` bleibt die Reservierungsstrategie (Klärungs- und Anfragereservierung) und ist unabhängig: *Verbindliches Angebot* schlägt „reservieren“ vor, erlaubt aber auch „nicht schon bei der Anfrage reservieren“ (das Angebot hält den Zeitraum trotzdem für seine Gültigkeit; Verfügbarkeit wird vor dem Versand geprüft). *Auskunft* legt „keine Reservierung“ fest – das ist die dokumentierte Definition einer Auskunft (`DocumentKind::Information`), nicht eine Prozessvorgabe.
|
||||||
|
- **Finanz/Dokumente:** unverändert unabhängig; nur Zuständigkeit wird festgelegt, Modus, Versand und Vorlage bleiben am Modul. Im Anfrage-Basisprozess sind Portal-Inkasso und externe Unterlagen mit Begründung ausgeschlossen (`ProcessModel::templateRestrictions`).
|
||||||
|
- **Darstellung aus dem Plan:** `ProcessLanes` leitet „läuft sofort / wartet auf / ereignisgesteuert / zeitgesteuert / entfällt“ aus den tatsächlichen harten Abhängigkeiten, den Auslösern und `applies()` des aufgelösten Plans ab – nicht aus Phasen oder Texten (Test vergleicht mit `ProcessRunner::unmetHardDependencies`).
|
||||||
|
|
||||||
|
## 10. Umsetzungsstand (Branch `feature/anfrage-basisprozess`)
|
||||||
|
|
||||||
|
| Punkt | Stand |
|
||||||
|
|---|---|
|
||||||
|
| Anfrage-Basisprozess `inquiry.request@1` (A1/A2 als Voreinstellung/Klassifikation/Altfassung) | gebaut |
|
||||||
|
| Schablonen `inquiry.information`, `inquiry.binding_offer`, `guest_comm.own`, `guest_comm.portal` | gebaut; `external.booking` hat jetzt ebenfalls den Kommunikationsplatz |
|
||||||
|
| Zulässigkeit je Basisprozess (Lücke 7.2) | gebaut (`templateRestrictions`) |
|
||||||
|
| Nachrichtenregeln im Kanalkonfigurator sichtbar (7.4) | gebaut, nur Anzeige |
|
||||||
|
| Ablaufspuren aus dem Plan (7.6) | gebaut |
|
||||||
|
| Medium je Kanal (7.5), Dienstleister-Zustellung, Zahlungsplan/Mahnung | offen, unverändert |
|
||||||
|
|
||||||
|
## 11. Ergebnis
|
||||||
|
|
||||||
|
Alle bisherigen Vorfälle lassen sich aus **drei Basisprozessen** und **vier Schablonenbereichen** (zwei gebaut, zwei vorgesehen) plus unabhängigen Modulparametern zusammensetzen; A1–A6 bleiben Voreinstellungen und Klassifikation. Zur Umsetzung fehlen nur die Punkte in 7.1–7.3 und die Anzeige 7.4/7.6 – kein neuer Prozess pro Variante.
|
||||||
@@ -1,5 +1,37 @@
|
|||||||
# Projektstand
|
# Projektstand
|
||||||
|
|
||||||
|
## Nachtrag (05.11.2026): Visueller Prozesskonfigurator (Branch `feature/prozess-konfigurator`)
|
||||||
|
|
||||||
|
- **Befund Steuerung:** Für neue Vorgänge gibt es eine maßgebliche Definition: den beim Eingang eingefrorenen `ProcessPlan` (`CaseRecorder` → `ProcessPlan::freeze`), den der `ProcessRunner` liest. Die Modelle A1–A5 wirken nur (a) in alten Fällen mit eingefrorenem oder abgeleitetem Plan und (b) als Adapter `ProcessCatalogue::derivedModel` für Kanäle, in denen noch kein Modell gewählt wurde; dort ist der Plan eine reine Funktion des aufgelösten Profils. Ein gewähltes Modell wird nie durch das abgeleitete ersetzt. Scheduler, Actions und Ereignisse führen aus, entscheiden aber über `ProcessPlan::of($booking)`. Nachweis: `VisualProcessConfiguratorTest::test_the_derived_legacy_model_is_only_used_where_nothing_is_chosen`.
|
||||||
|
- **Konfiguratorseite (Kanal › Ablauf):** Hauptansicht sind fachliche Prozessblöcke (`App\Process\ProcessBlocks`; die Zuordnung der Module zu Blöcken dient nur der Darstellung, ein Test hält Katalog und Tabelle gleich). Je Block: gewählte Schablone, wirksame Werte mit Herkunft, harte/weiche Abhängigkeiten zu anderen Blöcken, ereignis-/zeitgesteuert, bedingt – abgeleitet aus denselben Abhängigkeiten wie im Runner. Klick öffnet das Detailpanel: Schablonenwahl mit Folgenanalyse, Verbindungen, einstellbare Schritte (Schalter, Ausführung, Zuständigkeit, Parameter), feste Schritte nur als eine Zeile, „noch nicht vorhanden“ aus den Erweiterungen der Schablone.
|
||||||
|
- **Entwurf:** Auswählen/Öffnen speichert nichts; `dirty()` zeigt ungespeicherte Änderungen, „Änderungen verwerfen“ (`discard`), der Tester bekommt denselben Entwurf. Die endlose Einzelschrittliste ist entfernt; die Basisprozess-Auswahl ist eingeklappt, sobald das Modell Schablonen hat. Widersprüche zu gespeicherten Altwerten bleiben bestätigungspflichtige Konflikte (Test C).
|
||||||
|
- Tests: `VisualProcessConfiguratorTest` (A Webseite, B Destination Solutions inkl. Vergleich Blöcke = eingefrorener Plan, C Konflikt, D Bestandsfall, E Blockzuordnung/Erreichbarkeit); Feature-Suite 946/946. Nicht auf dem Testsystem geprüft, nicht gepusht.
|
||||||
|
|
||||||
|
## Nachtrag (05.11.2026): Anfrage-Basisprozess und Schablonen für alle Vorfälle
|
||||||
|
|
||||||
|
**Branch `feature/anfrage-basisprozess`** – [SCHABLONENKATALOG.md](Prozessarchitektur/SCHABLONENKATALOG.md) §9–10.
|
||||||
|
|
||||||
|
- Basisprozess `inquiry.request@1` für Webseite und Portalanfragen mit Schablonen für Antwort (Auskunft/verbindliches Angebot), Vertragsdokumentation, Finanz und Gastkommunikation; A1/A2 bleiben Voreinstellungen und Altfassungen. Altfälle lesen ihr eingefrorenes Profil unverändert (neue Einstellungen werden abgeleitet).
|
||||||
|
- Antwortart und Reservierungsstrategie sind entkoppelt (`inquiry_answer` / `pre_reservation`); Gastkommunikation wird je Anlass zugewiesen (`arrival_info_sender`, `review_request_sender`). Schablonen liefern Standardwerte unterhalb aller einstellbaren Ebenen.
|
||||||
|
- Kanalkonfigurator für Webseite, Portalanfrage und feste Buchung einheitlich: Eingang und Nachrichtenregeln, Entscheidungen, „Ablauf im Zusammenhang“ aus dem Plan, Auswirkungen, Einzelschritte (eingeklappt), Tester.
|
||||||
|
- Keine Migration. Betroffen sind neue Vorgänge; laufende behalten Profil und Plan.
|
||||||
|
|
||||||
|
## Nachtrag (05.11.2026): Schablonenkomposition für extern verbindliche Buchungen
|
||||||
|
|
||||||
|
**Branch `feature/schablonenkomposition`** – Details, Zuordnung und Grenzen: [SCHABLONEN.md](Prozessarchitektur/SCHABLONEN.md).
|
||||||
|
|
||||||
|
- Basisprozess `external.booking@1` mit Plätzen für **Finanzabwicklung** (`collection.own` / `collection.portal`) und **Vertragsdokumentation** (`contract_docs.own` / `contract_docs.external`). Alle vier Kombinationen laufen im Prozesskern und im Prozess-Tester; die vierte (eigenes Inkasso + externe Unterlagen) war mit A3–A5 nicht darstellbar.
|
||||||
|
- A3–A5 bleiben als Voreinstellungen/Altfassungen erhalten (Äquivalenz mit den Archetypen ist getestet); `CaseType` ist nur noch Klassifikation, kein A7.
|
||||||
|
- Der Plan friert die Schablonenversionen ein; laufende Vorgänge und Altpläne bleiben unverändert. Keine Migration.
|
||||||
|
- Kanalkonfigurator: Geschäftsentscheidungen zuerst, Einzelschritte eingeklappt, Auswirkungsanalyse beim Schablonenwechsel, Konflikte (A4→A3-Fall) bleiben bestätigungspflichtig. Tester-Bericht nennt Schablonen, unabhängig laufende Schritte, fehlende Nachweise und nicht bestätigte Portal-Fähigkeiten.
|
||||||
|
- Offen: Bereitstellung auf `develop`/stommer.info (siehe Abschnitt unten, sobald erfolgt).
|
||||||
|
|
||||||
|
## Nachtrag (05.11.2026): Konfigurierbarkeit der Fachmodule
|
||||||
|
|
||||||
|
- **Speicherkonflikt behoben:** Ein bestätigter Wechsel A4 → A3 (Destination Solutions mit `payments = portal`) scheiterte an „Inkasso … nicht zulässig“, weil der Entwurf den Altwert vor der bestätigten Entfernung gegen das neue Modell prüfte; nicht mehr erlaubte variable Verantwortlichkeiten zählten zudem nicht als Konflikt. Jetzt: `ChannelProcessConfiguration::conflicts()` + `withoutOverriddenSettings()`, Regressionstests in `ChannelCapabilityTest`.
|
||||||
|
- **Modul-Konfigurationsmatrix:** [MODUL_KONFIGURATIONSMATRIX.md](Prozessarchitektur/MODUL_KONFIGURATIONSMATRIX.md) – je Modul Varianten, Parameter, Abhängigkeiten, Zustand, fehlende Fähigkeiten (priorisiert). Wichtigste Lücke im Referenzfall: Zahlungsplan/-erinnerung/Mahnung nicht konfigurierbar.
|
||||||
|
- **Auswirkungs-Abgleich:** `App\Process\ConfigurationImpact` + Abschnitt „Was die Abschaltung bedeutet“ im Kanalkonfigurator (nur Hinweise, ändert nichts).
|
||||||
|
|
||||||
## Aktueller Stand (05.11.2026): V2.1 – fachliche Konfigurierbarkeit
|
## Aktueller Stand (05.11.2026): V2.1 – fachliche Konfigurierbarkeit
|
||||||
|
|
||||||
**Umgesetzt auf `feature/prozessarchitektur-v2-1`:** Kanalfähigkeiten steuern die Modellwahl (mit erklärten Einschränkungen und Abgleich alter Werte), Ausführungsvarianten je Modul, Dokumentenerstellung/-ablage/-versand und Buchungsinformation entkoppelt, Warten auf die Bestätigungsmail des Portals (Belegung sofort gesichert, Eskalation, Wiederaufnahme), Kommunikation nach Medium × Absicht × Wirkung (WhatsApp/Chat nur als Testfälle der Architektur, kein Provider), nichtlineare Prozessansicht im Kanalkonfigurator, neue Tester-Szenarien, Erweiterungspunkt-Nachweis (Anschriftsprüfung).
|
**Umgesetzt auf `feature/prozessarchitektur-v2-1`:** Kanalfähigkeiten steuern die Modellwahl (mit erklärten Einschränkungen und Abgleich alter Werte), Ausführungsvarianten je Modul, Dokumentenerstellung/-ablage/-versand und Buchungsinformation entkoppelt, Warten auf die Bestätigungsmail des Portals (Belegung sofort gesichert, Eskalation, Wiederaufnahme), Kommunikation nach Medium × Absicht × Wirkung (WhatsApp/Chat nur als Testfälle der Architektur, kein Provider), nichtlineare Prozessansicht im Kanalkonfigurator, neue Tester-Szenarien, Erweiterungspunkt-Nachweis (Anschriftsprüfung).
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
@php
|
||||||
|
$muted = 'color:#6b7280;font-size:.8rem';
|
||||||
|
$card = 'border:1px solid rgba(128,128,128,.3);border-radius:.5rem;padding:.75rem 1rem;margin-bottom:.6rem';
|
||||||
|
$decision = collect($this->decisions())->first(fn (array $candidate): bool => $block['area'] !== null && $candidate['area'] === $block['area']);
|
||||||
|
$areaImpacts = $block['area'] === null ? [] : array_values(array_filter($this->templateImpacts(), fn (array $impact): bool => $impact['area'] === $block['area']->label()));
|
||||||
|
@endphp
|
||||||
|
<x-filament::section :heading="'Einstellungen: '.$block['label']" :description="'Phase '.$block['phase'].' · Änderungen bleiben ein Entwurf, bis Sie speichern.'" wire:key="block-detail-{{ $this->intake }}-{{ $block['key'] }}">
|
||||||
|
@foreach ($block['problems'] as $problem)
|
||||||
|
<p style="color:#b91c1c;font-size:.85rem;margin-bottom:.4rem">{{ $problem }}</p>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
@if ($decision)
|
||||||
|
<h3 style="font-weight:600;margin:.2rem 0 .3rem">{{ $decision['area']->label() }} <span style="{{ $muted }}">– {{ $decision['area']->question() }}</span></h3>
|
||||||
|
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(16rem,1fr));gap:.6rem" role="radiogroup" aria-label="{{ $decision['area']->label() }}">
|
||||||
|
@foreach ($decision['options'] as $option)
|
||||||
|
@php($template = $option['template'])
|
||||||
|
<div style="{{ $card }};{{ $option['selected'] ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }};{{ $option['admissible'] ? '' : 'opacity:.85;background:rgba(128,128,128,.07)' }}" wire:key="template-{{ $this->intake }}-{{ $option['key'] }}">
|
||||||
|
<button type="button" role="radio" aria-checked="{{ $option['selected'] ? 'true' : 'false' }}" @disabled(! $option['admissible']) wire:click="chooseTemplate('{{ $decision['area']->value }}', '{{ $option['key'] }}')" style="text-align:left;width:100%">
|
||||||
|
<strong>{{ $template::label() }}</strong>
|
||||||
|
<div style="font-size:.85rem;margin-top:.3rem">{{ $template::purpose() }}</div>
|
||||||
|
</button>
|
||||||
|
<ul style="{{ $muted }};margin-top:.4rem;list-style:disc;padding-left:1.1rem">
|
||||||
|
@foreach ($template::dimensions() as $dimension => $statement)<li><strong>{{ $dimension }}:</strong> {{ $statement }}</li>@endforeach
|
||||||
|
</ul>
|
||||||
|
@foreach ($option['restrictions'] as $restriction)
|
||||||
|
<p style="color:#b45309;font-size:.8rem;margin-top:.4rem"><strong>Passt gerade nicht ({{ $restriction->kind }}):</strong> {{ $restriction->reason }}@if ($restriction->alternative) <br>Zulässig ist stattdessen: {{ $restriction->alternative }}.@endif @if ($restriction->change) <br>{{ $restriction->change }}.@endif</p>
|
||||||
|
@endforeach
|
||||||
|
@foreach ($option['hints'] as $hint)<p style="{{ $muted }};margin-top:.3rem">{{ $hint }}</p>@endforeach
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@foreach ($areaImpacts as $impact)
|
||||||
|
<div style="font-size:.85rem;margin:.4rem 0 .8rem" data-impact="{{ $impact['area'] }}">
|
||||||
|
<strong>Was der Wechsel bedeutet:</strong> {{ $impact['from'] ?? 'bisher keine Schablone' }} → <strong>{{ $impact['to'] }}</strong>
|
||||||
|
@if ($impact['responsibility'])<div>Verantwortung: {{ $impact['responsibility']['from'] }} → {{ $impact['responsibility']['to'] }}</div>@endif
|
||||||
|
@if ($impact['removed'] !== [])<div>Entfällt: {{ implode(', ', $impact['removed']) }}</div>@endif
|
||||||
|
@if ($impact['added'] !== [])<div>Kommt hinzu: {{ implode(', ', $impact['added']) }}</div>@endif
|
||||||
|
@if ($impact['kept'] !== [])<div style="{{ $muted }}">Bleibt mit allen Einstellungen: {{ implode(', ', $impact['kept']) }}</div>@endif
|
||||||
|
@foreach ($impact['switches_lost'] as $lost)<div style="color:#b45309">Ihr gespeicherter Schalter für „{{ $lost }}“ hat dann keinen Bezug mehr.</div>@endforeach
|
||||||
|
@foreach ($impact['settings_replaced'] as $text)<div style="color:#b45309">{{ $text }}</div>@endforeach
|
||||||
|
@foreach ($impact['needs'] as $need)<div style="{{ $muted }}">{{ $need }}</div>@endforeach
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($block['extensions'] !== [])
|
||||||
|
<p style="{{ $muted }};margin:.4rem 0">Noch nicht vorhanden (hier gibt es dafür keine Einstellung): {{ implode('; ', $block['extensions']) }}.</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<h3 style="font-weight:600;margin:.8rem 0 .2rem">Verbindungen</h3>
|
||||||
|
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">
|
||||||
|
@forelse ($block['waits_for'] as $dependency)
|
||||||
|
<li>Wartet auf <strong>{{ $dependency['label'] }}</strong> ({{ implode(', ', array_unique($dependency['steps'])) }}) – harte Abhängigkeit</li>
|
||||||
|
@empty
|
||||||
|
<li>Wartet auf keinen anderen Block – läuft unabhängig.</li>
|
||||||
|
@endforelse
|
||||||
|
@foreach ($block['after'] as $dependency)<li>Soll nach <strong>{{ $dependency['label'] }}</strong> ({{ implode(', ', array_unique($dependency['steps'])) }}) – weiche Abhängigkeit, blockiert nicht</li>@endforeach
|
||||||
|
@if ($block['may_wait'] !== [])<li>Kann warten auf: {{ implode(', ', $block['may_wait']) }}</li>@endif
|
||||||
|
@if ($block['events'] !== [])<li>Reagiert auf Ereignisse: {{ implode(', ', $block['events']) }}</li>@endif
|
||||||
|
@if ($block['scheduled'] !== [])<li>Zeitgesteuert: {{ implode(', ', $block['scheduled']) }}</li>@endif
|
||||||
|
@foreach ($block['conditional'] as $conditional)<li>Bedingt: {{ $conditional['label'] }}@if ($conditional['reason']) – nur wenn {{ $conditional['reason'] }}@endif</li>@endforeach
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
@if ($block['configurable'] !== [])
|
||||||
|
<h3 style="font-weight:600;margin:.8rem 0 0">Einstellbare Schritte</h3>
|
||||||
|
@foreach ($block['configurable'] as $step)
|
||||||
|
@include('filament.resources.channels.channel-process-step', ['step' => $step])
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($block['fixed'] !== [])
|
||||||
|
<p style="{{ $muted }};margin-top:.6rem">Feste Schritte ohne eigene Einstellung: {{ implode(', ', array_column($block['fixed'], 'label')) }}.</p>
|
||||||
|
@endif
|
||||||
|
@if ($block['off'] !== [])
|
||||||
|
<p style="{{ $muted }};margin-top:.3rem">Entfällt hier: {{ implode('; ', array_map(fn (array $step): string => $step['label'].($step['reason'] ? ' ('.$step['reason'].')' : ''), $block['off'])) }}.</p>
|
||||||
|
@endif
|
||||||
|
@if ($block['configurable'] === [] && $block['facts'] === [] && $decision === null)
|
||||||
|
<p style="{{ $muted }}">Dieser Block hat keine eigenen Einstellungen.</p>
|
||||||
|
@endif
|
||||||
|
</x-filament::section>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
@php
|
||||||
|
$muted = 'color:#6b7280;font-size:.8rem';
|
||||||
|
$input = 'border:1px solid rgba(128,128,128,.4);border-radius:.375rem;padding:.3rem .45rem;background:transparent';
|
||||||
|
$performers = ['system' => 'System', 'landlord' => 'Sie', 'guest' => 'Gast', 'portal' => 'Portal', 'service_provider' => 'Dienstleister', 'none' => 'niemand'];
|
||||||
|
$waitLabels = ['guest' => 'Gast', 'portal' => 'Portal', 'landlord' => 'Sie', 'time' => 'Frist'];
|
||||||
|
@endphp
|
||||||
|
<div style="border-top:1px solid rgba(128,128,128,.25);padding:.6rem 0;{{ $step['on'] ? '' : 'opacity:.65' }}" wire:key="step-{{ $this->intake }}-{{ $step['module'] }}">
|
||||||
|
<div style="display:flex;justify-content:space-between;gap:.5rem;align-items:center">
|
||||||
|
<strong style="font-size:.9rem">{{ $step['label'] }}
|
||||||
|
@if ($step['tester_only'])<span style="color:#b45309;font-size:.75rem"> · nur im Prozess-Tester</span>@endif
|
||||||
|
@if ($step['inserted'])<span style="{{ $muted }}"> · Zusatzschritt der Variante</span>@endif
|
||||||
|
</strong>
|
||||||
|
@if ($step['optional'])
|
||||||
|
<x-filament::button size="xs" :color="($this->drafts[$this->intake]['steps'][$step['module']]['on'] ?? true) === false ? 'gray' : 'success'" wire:click="toggleStep('{{ $step['module'] }}')">
|
||||||
|
{{ ($this->drafts[$this->intake]['steps'][$step['module']]['on'] ?? true) === false ? 'aus' : 'an' }}
|
||||||
|
</x-filament::button>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<div style="font-size:.85rem;margin-top:.2rem">{{ $step['purpose'] }}</div>
|
||||||
|
<div style="{{ $muted }};margin-top:.2rem">
|
||||||
|
@if ($step['needs'] !== []) wartet auf: {{ implode(', ', $step['needs']) }} · @elseif ($step['on']) läuft unabhängig · @endif
|
||||||
|
@if ($step['after'] !== []) soll nach: {{ implode(', ', $step['after']) }} · @endif
|
||||||
|
@if ($step['condition']) nur wenn: {{ $step['condition'] }} · @endif
|
||||||
|
Wer: {{ $performers[$step['performer']] ?? $step['performer'] ?? '–' }}
|
||||||
|
@if ($step['waits'] !== []) · kann warten auf: {{ implode(', ', array_map(fn ($wait) => $waitLabels[$wait] ?? $wait, $step['waits'])) }}@endif
|
||||||
|
@if ($step['triggers'] !== [] && $this->expert()) · Auslöser: {{ implode(', ', $step['triggers']) }}@endif
|
||||||
|
@if (! $step['on'] && $step['reason']) · <em>übersprungen: {{ $step['reason'] }}</em>@endif
|
||||||
|
@if ($this->expert()) · <code>{{ $step['module'] }}</code> v{{ $step['version'] }}@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if ($step['mode_setting'] && $step['mode_options'] !== [])
|
||||||
|
<label style="display:block;font-size:.85rem;margin-top:.4rem">Ausführung
|
||||||
|
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $step['mode_setting']->value }}" style="{{ $input }};margin-left:.4rem">
|
||||||
|
<option value="">wie Standard</option>
|
||||||
|
@foreach ($step['mode_options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
|
||||||
|
</select>
|
||||||
|
<span style="{{ $muted }}">wirksam: {{ $this->setting($step['mode_setting'], $this->profile())['value'] }} ({{ $this->setting($step['mode_setting'], $this->profile())['source'] }})</span>
|
||||||
|
</label>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if ($step['performer_setting'] && count($step['performer_options']) > 1)
|
||||||
|
<label style="display:block;font-size:.85rem;margin-top:.4rem">Wer sendet
|
||||||
|
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $step['performer_setting']->value }}" style="{{ $input }};margin-left:.4rem">
|
||||||
|
<option value="">wie Standard</option>
|
||||||
|
@foreach ($step['performer_options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
|
||||||
|
</select>
|
||||||
|
<span style="{{ $muted }}">wirksam: {{ $this->setting($step['performer_setting'], $this->profile())['value'] }} ({{ $this->setting($step['performer_setting'], $this->profile())['source'] }})</span>
|
||||||
|
</label>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@foreach ($step['parameters'] as $parameter)
|
||||||
|
<label style="display:block;font-size:.85rem;margin-top:.4rem">{{ $parameter['question'] }}
|
||||||
|
@if ($parameter['options'])
|
||||||
|
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" style="{{ $input }};margin-left:.4rem">
|
||||||
|
<option value="">wie geerbt</option>
|
||||||
|
@foreach ($parameter['options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
|
||||||
|
</select>
|
||||||
|
@else
|
||||||
|
<input type="text" wire:model.live.debounce.600ms="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" placeholder="{{ $parameter['value'] }}" style="{{ $input }};width:8rem;margin-left:.4rem">
|
||||||
|
@endif
|
||||||
|
<span style="{{ $muted }}">wirksam: {{ $parameter['value'] }} ({{ $parameter['source'] }})</span>
|
||||||
|
@if ($parameter['set'])
|
||||||
|
<button type="button" wire:click="inherit('{{ $parameter['key'] }}')" style="{{ $muted }};text-decoration:underline">auf geerbten Wert zurücksetzen</button>
|
||||||
|
@endif
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
@@ -65,6 +65,20 @@
|
|||||||
@endif
|
@endif
|
||||||
@if ($plan = $report['plan'] ?? null)
|
@if ($plan = $report['plan'] ?? null)
|
||||||
<p style="font-size:.9rem"><strong>{{ $plan['label'] }}</strong> ({{ $plan['model'] }} Version {{ $plan['version'] }}{{ $plan['variant'] !== 'standard' ? ', Variante '.$plan['variant'] : '' }}) · Vorgangsart {{ $plan['case_type'] }}</p>
|
<p style="font-size:.9rem"><strong>{{ $plan['label'] }}</strong> ({{ $plan['model'] }} Version {{ $plan['version'] }}{{ $plan['variant'] !== 'standard' ? ', Variante '.$plan['variant'] : '' }}) · Vorgangsart {{ $plan['case_type'] }}</p>
|
||||||
|
@if (($plan['templates'] ?? []) !== [])
|
||||||
|
<div style="font-size:.85rem;margin:.4rem 0">
|
||||||
|
<strong>Verwendete Funktionsschablonen</strong>
|
||||||
|
<ul style="padding-left:1.2rem;list-style:disc">
|
||||||
|
@foreach ($plan['templates'] as $template)
|
||||||
|
<li>{{ $template['area'] }}: <strong>{{ $template['label'] }}</strong> <span style="{{ $muted }}">({{ $template['reference'] }}, Verantwortung: {{ $template['responsibility'] }}; Schritte: {{ implode(', ', $template['modules']) }})</span>
|
||||||
|
@foreach ($template['capabilities'] as $capability)
|
||||||
|
<div style="{{ $capability['confirmed'] ? $muted : 'color:#b45309;font-size:.8rem' }}">Voraussetzung „{{ $capability['label'] }}“ = {{ $capability['required'] }} – {{ $capability['confirmed'] ? 'bestätigt' : 'NICHT bestätigt, wird nicht als nachgewiesen behandelt' }} ({{ $capability['source'] }})</div>
|
||||||
|
@endforeach
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
<details style="font-size:.85rem;margin:.4rem 0"><summary>Wirksame Einstellungen</summary>
|
<details style="font-size:.85rem;margin:.4rem 0"><summary>Wirksame Einstellungen</summary>
|
||||||
<ul style="padding-left:1.2rem;list-style:disc">
|
<ul style="padding-left:1.2rem;list-style:disc">
|
||||||
@foreach ($plan['configuration'] as $row)<li>{{ $row['question'] }}: <strong>{{ $row['value'] }}</strong> <span style="{{ $muted }}">({{ $row['source'] }})</span></li>@endforeach
|
@foreach ($plan['configuration'] as $row)<li>{{ $row['question'] }}: <strong>{{ $row['value'] }}</strong> <span style="{{ $muted }}">({{ $row['source'] }})</span></li>@endforeach
|
||||||
@@ -77,6 +91,12 @@
|
|||||||
<div style="display:flex;justify-content:space-between"><strong>{{ $index + 1 }}. {{ $event['label'] }}</strong><span style="{{ $muted }}">{{ $event['at'] }} (simuliert)</span></div>
|
<div style="display:flex;justify-content:space-between"><strong>{{ $index + 1 }}. {{ $event['label'] }}</strong><span style="{{ $muted }}">{{ $event['at'] }} (simuliert)</span></div>
|
||||||
@if ($event['error'])<p style="color:#b91c1c;font-size:.85rem">Fehler: {{ $event['error'] }}</p>@endif
|
@if ($event['error'])<p style="color:#b91c1c;font-size:.85rem">Fehler: {{ $event['error'] }}</p>@endif
|
||||||
@isset($event['situation'])<p style="font-size:.85rem;margin:.3rem 0">{{ $event['status'] }} · {{ $event['situation'] }}</p>@endisset
|
@isset($event['situation'])<p style="font-size:.85rem;margin:.3rem 0">{{ $event['status'] }} · {{ $event['situation'] }}</p>@endisset
|
||||||
|
@if (($event['independent'] ?? []) !== [])
|
||||||
|
<p style="font-size:.85rem;color:#15803d">Läuft unabhängig weiter, obwohl anderes wartet: {{ implode(', ', $event['independent']) }}</p>
|
||||||
|
@endif
|
||||||
|
@if (($event['waiting'] ?? []) !== [])
|
||||||
|
<p style="font-size:.85rem;color:#6d28d9">Wartet / Nachweis fehlt: {{ implode(', ', $event['waiting']) }}</p>
|
||||||
|
@endif
|
||||||
<ul style="font-size:.85rem;list-style:none;padding:0">
|
<ul style="font-size:.85rem;list-style:none;padding:0">
|
||||||
@foreach ($event['activities'] as $activity)
|
@foreach ($event['activities'] as $activity)
|
||||||
<li><span style="color:{{ $stateColor[$activity['state_key']] ?? '#6b7280' }};font-weight:600">{{ $activity['state'] }}</span> – {{ $activity['label'] }}@if ($activity['detail'])<span style="{{ $muted }}"> · {{ $activity['detail'] }}</span>@endif</li>
|
<li><span style="color:{{ $stateColor[$activity['state_key']] ?? '#6b7280' }};font-weight:600">{{ $activity['state'] }}</span> – {{ $activity['label'] }}@if ($activity['detail'])<span style="{{ $muted }}"> · {{ $activity['detail'] }}</span>@endif</li>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
$model = $this->model();
|
$model = $this->model();
|
||||||
$steps = $this->steps();
|
$steps = $this->steps();
|
||||||
$problems = $this->problems();
|
$problems = $this->problems();
|
||||||
|
$composable = $this->composable();
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@if (count($this->tabs()) > 1)
|
@if (count($this->tabs()) > 1)
|
||||||
@@ -20,6 +21,20 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@php($entry = $this->entry())
|
||||||
|
<x-filament::section heading="1 · So kommt es an" :description="$entry['event']">
|
||||||
|
<p style="font-size:.9rem">{{ $entry['binding'] }}</p>
|
||||||
|
<p style="{{ $muted }}">Eingangswege, die hier angeschaltet sind: {{ implode(', ', $entry['media']) }}. Das Medium bestimmt nur, wie etwas ankommt – nicht den Ablauf.</p>
|
||||||
|
<details style="margin-top:.5rem"><summary style="cursor:pointer;font-size:.9rem">Was eine Nachricht auslöst (Nachrichtenregeln)</summary>
|
||||||
|
<table style="font-size:.85rem;margin-top:.4rem;border-collapse:collapse">
|
||||||
|
@foreach ($this->messageRules() as $rule)
|
||||||
|
<tr><td style="padding:.15rem .8rem .15rem 0"><strong>{{ $rule['intent'] }}</strong></td><td>{{ implode(' · ', $rule['effects']) }}</td></tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
<p style="{{ $muted }};margin-top:.3rem">Eine allgemeine Frage legt keinen Vorgang an. Nachrichten zu einem Vorgang werden nur über einen sicheren Bezug zugeordnet. Die Regeln gelten für den ganzen Betrieb und lassen sich nur einschränken (System › Betrieb).</p>
|
||||||
|
</details>
|
||||||
|
</x-filament::section>
|
||||||
|
|
||||||
@if (! $this->record->isWebsite())
|
@if (! $this->record->isWebsite())
|
||||||
@php($capabilities = $this->capabilities())
|
@php($capabilities = $this->capabilities())
|
||||||
<x-filament::section heading="Was kann dieses Portal für Ihr Konto?" description="Davon hängt ab, welche Abläufe passen. Mit dem Speichern bestätigen Sie die hier gezeigten Angaben. Geben Sie nur an, was Sie wissen – „unbekannt“ sperrt nichts.">
|
<x-filament::section heading="Was kann dieses Portal für Ihr Konto?" description="Davon hängt ab, welche Abläufe passen. Mit dem Speichern bestätigen Sie die hier gezeigten Angaben. Geben Sie nur an, was Sie wissen – „unbekannt“ sperrt nichts.">
|
||||||
@@ -37,12 +52,21 @@
|
|||||||
</x-filament::section>
|
</x-filament::section>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if ($conflicts = $this->conflicts())
|
||||||
|
<div style="{{ $card }};margin-bottom:.8rem;border-color:#b45309">
|
||||||
|
<strong>Bisherige Einstellungen widersprechen dem gewählten Ablauf</strong>
|
||||||
|
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">@foreach ($conflicts as $conflict)<li>{{ $conflict['text'] }}</li>@endforeach</ul>
|
||||||
|
<label style="font-size:.85rem"><input type="checkbox" wire:model.live="acknowledge"> Ich bestätige: Diese bisherigen Einstellungen werden beim Speichern entfernt und im Verlauf des Kanals festgehalten.</label>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<details @if (! $composable || $draft['derived']) open @endif style="margin-bottom:1rem"><summary style="cursor:pointer;font-weight:600">Basisprozess: {{ $model::label() }}</summary>
|
||||||
<x-filament::section :heading="$this->question()" :description="$draft['derived'] ? 'Noch nicht gewählt: abgeleitet aus Ihren bisherigen Einstellungen. Gespeichert wird erst, wenn Sie speichern.' : null">
|
<x-filament::section :heading="$this->question()" :description="$draft['derived'] ? 'Noch nicht gewählt: abgeleitet aus Ihren bisherigen Einstellungen. Gespeichert wird erst, wenn Sie speichern.' : null">
|
||||||
@if ($models === [])
|
@if ($models === [])
|
||||||
<p>Für diese Eingangsart gibt es keine Ablaufmodelle.</p>
|
<p>Für diese Eingangsart gibt es keine Ablaufmodelle.</p>
|
||||||
@endif
|
@endif
|
||||||
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(18rem,1fr));gap:.6rem" role="radiogroup" aria-label="Ablaufmodell">
|
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(18rem,1fr));gap:.6rem" role="radiogroup" aria-label="Ablaufmodell">
|
||||||
@foreach ($models as $key => $option)
|
@foreach ($this->visibleModels($models) as $key => $option)
|
||||||
@php($candidate = $option['model'])
|
@php($candidate = $option['model'])
|
||||||
<div style="{{ $card }};{{ $draft['model'] === $key ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }};{{ $option['admissible'] ? '' : 'opacity:.85;background:rgba(128,128,128,.07)' }}">
|
<div style="{{ $card }};{{ $draft['model'] === $key ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }};{{ $option['admissible'] ? '' : 'opacity:.85;background:rgba(128,128,128,.07)' }}">
|
||||||
<button type="button" role="radio" aria-checked="{{ $draft['model'] === $key ? 'true' : 'false' }}" @disabled(! $option['admissible']) wire:click="chooseModel('{{ $key }}')" style="text-align:left;width:100%">
|
<button type="button" role="radio" aria-checked="{{ $draft['model'] === $key ? 'true' : 'false' }}" @disabled(! $option['admissible']) wire:click="chooseModel('{{ $key }}')" style="text-align:left;width:100%">
|
||||||
@@ -55,15 +79,20 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
@foreach ($option['hints'] as $hint)<p style="{{ $muted }};margin-top:.3rem">{{ $hint }}</p>@endforeach
|
@foreach ($option['hints'] as $hint)<p style="{{ $muted }};margin-top:.3rem">{{ $hint }}</p>@endforeach
|
||||||
@if ($draft['model'] === $key && ! $option['admissible'])<p style="color:#b91c1c;font-size:.8rem;margin-top:.3rem">Dies ist Ihr bisheriger Ablauf. Er bleibt wirksam, bis Sie ein passendes Modell wählen oder die Fähigkeit oben ändern.</p>@endif
|
@if ($draft['model'] === $key && ! $option['admissible'])<p style="color:#b91c1c;font-size:.8rem;margin-top:.3rem">Dies ist Ihr bisheriger Ablauf. Er bleibt wirksam, bis Sie ein passendes Modell wählen oder die Fähigkeit oben ändern.</p>@endif
|
||||||
|
@if ($candidate::isLegacy() && $draft['model'] === $key)
|
||||||
|
<p style="{{ $muted }};margin-top:.4rem">Festes Modell (bisherige Vorgangsart). Sie können es in die frei kombinierbaren Schablonen übernehmen – die Kombination bleibt dabei gleich.</p>
|
||||||
|
<x-filament::button size="xs" color="gray" wire:click="applyPreset('{{ $key }}')" style="margin-top:.3rem">Auf Schablonen umstellen</x-filament::button>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if ($conflicts = $this->conflicts())
|
|
||||||
<div style="{{ $card }};margin-top:.8rem;border-color:#b45309">
|
@if ($composable && ($presets = $this->presets()) !== [])
|
||||||
<strong>Bisherige Einstellungen widersprechen diesem Modell</strong>
|
<div style="color:#6b7280;font-size:.8rem;margin-top:.6rem">Bekannte Kombinationen als Ausgangspunkt:
|
||||||
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">@foreach ($conflicts as $conflict)<li>{{ $conflict['text'] }}</li>@endforeach</ul>
|
@foreach ($presets as $archetype => $preset)
|
||||||
<label style="font-size:.85rem"><input type="checkbox" wire:model.live="acknowledge"> Ich bestätige: Diese bisherigen Einstellungen werden beim Speichern entfernt und im Verlauf des Kanals festgehalten.</label>
|
<button type="button" wire:click="applyPreset('{{ $archetype }}')" style="text-decoration:underline;margin-left:.4rem">{{ $preset['label'] }}</button>
|
||||||
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@@ -82,89 +111,83 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</x-filament::section>
|
</x-filament::section>
|
||||||
|
</details>
|
||||||
|
|
||||||
@if ($problems !== [])
|
@if ($this->dirty())
|
||||||
|
<div style="{{ $card }};border-color:#b45309;display:flex;justify-content:space-between;align-items:center;gap:.6rem" role="status">
|
||||||
|
<span style="font-size:.9rem"><strong>Ungespeicherte Änderungen.</strong> Der Prozess unten zeigt Ihren Entwurf; der Tester verwendet ihn ebenfalls. Gespeichert wird erst mit „Speichern“.</span>
|
||||||
|
<x-filament::button size="xs" color="gray" wire:click="discard">Änderungen verwerfen</x-filament::button>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@if (($loose = $this->problemsOutsideBlocks()) !== [])
|
||||||
<x-filament::section heading="Nicht zulässig">
|
<x-filament::section heading="Nicht zulässig">
|
||||||
<ul style="color:#b91c1c;font-size:.9rem;list-style:disc;padding-left:1.2rem">
|
<ul style="color:#b91c1c;font-size:.9rem;list-style:disc;padding-left:1.2rem">
|
||||||
@foreach ($problems as $problem)<li>{{ $problem }}</li>@endforeach
|
@foreach ($loose as $problem)<li>{{ $problem }}</li>@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
</x-filament::section>
|
</x-filament::section>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div style="display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:1rem;align-items:start">
|
@php($blocks = $this->blocks())
|
||||||
<div>
|
<x-filament::section heading="Der Geschäftsprozess" description="Fachliche Blöcke – keine feste Reihenfolge. Was wartet, ergibt sich aus den Abhängigkeiten dieses Ablaufs. Klicken Sie einen Block an, um ihn einzustellen.">
|
||||||
@foreach (collect($steps)->groupBy('phase') as $phase => $group)
|
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(17rem,1fr));gap:.7rem">
|
||||||
<h3 style="font-weight:600;margin:.6rem 0 .3rem">{{ $phases[$phase] ?? $phase }}</h3>
|
@foreach ($blocks as $key => $block)
|
||||||
@foreach ($group as $index => $step)
|
<div style="{{ $card }};margin:0;{{ $this->block === $key ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }};{{ $block['active'] ? '' : 'opacity:.6' }}" wire:key="block-{{ $this->intake }}-{{ $key }}">
|
||||||
<div style="{{ $card }};{{ $step['on'] ? '' : 'opacity:.6' }}" wire:key="step-{{ $this->intake }}-{{ $step['module'] }}">
|
<button type="button" wire:click="selectBlock('{{ $key }}')" aria-expanded="{{ $this->block === $key ? 'true' : 'false' }}" aria-controls="block-detail" style="text-align:left;width:100%">
|
||||||
<div style="display:flex;justify-content:space-between;gap:.5rem;align-items:center">
|
<div style="{{ $muted }}">{{ $block['phase'] }}</div>
|
||||||
<strong>{{ $step['label'] }}
|
<strong>{{ $block['label'] }}</strong>
|
||||||
@if ($step['tester_only'])<span style="color:#b45309;font-size:.75rem"> · nur im Prozess-Tester</span>@endif
|
@if ($block['template'])<div style="font-size:.85rem">{{ $block['template']::label() }}</div>@endif
|
||||||
@if ($step['inserted'])<span style="{{ $muted }}"> · Zusatzschritt der Variante</span>@endif
|
<ul style="font-size:.82rem;margin-top:.35rem;list-style:none;padding:0">
|
||||||
</strong>
|
@foreach ($block['facts'] as $fact)
|
||||||
@if ($step['optional'])
|
<li><span style="{{ $muted }}">{{ $fact['question'] }}</span> <strong>{{ $fact['value'] }}</strong> <span style="{{ $muted }}">({{ $fact['source'] }})</span></li>
|
||||||
<x-filament::button size="xs" :color="($draft['steps'][$step['module']]['on'] ?? true) === false ? 'gray' : 'success'" wire:click="toggleStep('{{ $step['module'] }}')">
|
@endforeach
|
||||||
{{ ($draft['steps'][$step['module']]['on'] ?? true) === false ? 'aus' : 'an' }}
|
</ul>
|
||||||
</x-filament::button>
|
<div style="font-size:.8rem;margin-top:.4rem">
|
||||||
|
@if (! $block['active'])
|
||||||
|
<span style="{{ $muted }}">Entfällt in diesem Ablauf.</span>
|
||||||
@else
|
@else
|
||||||
<span style="{{ $muted }}" title="Pflichtschritt – nicht abschaltbar">🔒 Pflicht</span>
|
@forelse ($block['waits_for'] as $dependency)
|
||||||
|
<div style="color:#b45309">⏳ wartet auf {{ $dependency['label'] }}</div>
|
||||||
|
@empty
|
||||||
|
<div style="color:#15803d">⇉ läuft unabhängig</div>
|
||||||
|
@endforelse
|
||||||
|
@foreach ($block['after'] as $dependency)<div style="{{ $muted }}">↳ soll nach {{ $dependency['label'] }}</div>@endforeach
|
||||||
|
@if ($block['events'] !== [])<div style="{{ $muted }}">⚡ ereignisgesteuert: {{ implode(', ', $block['events']) }}</div>@endif
|
||||||
|
@if ($block['scheduled'] !== [])<div style="{{ $muted }}">⏱ zeitgesteuert: {{ implode(', ', $block['scheduled']) }}</div>@endif
|
||||||
|
@foreach ($block['conditional'] as $conditional)<div style="{{ $muted }}">? bedingt: {{ $conditional['label'] }}</div>@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
@if ($block['problems'] !== [] || $block['attention'] > 0)<div style="color:#b91c1c">⚠ Klärung nötig</div>@endif
|
||||||
</div>
|
</div>
|
||||||
<div style="font-size:.85rem;margin-top:.25rem">{{ $step['purpose'] }}</div>
|
</button>
|
||||||
<div style="{{ $muted }};margin-top:.25rem">
|
|
||||||
@if ($step['needs'] !== []) braucht zuerst: {{ implode(', ', $step['needs']) }} · @elseif ($step['on']) läuft unabhängig · @endif
|
|
||||||
@if ($step['after'] !== []) soll nach: {{ implode(', ', $step['after']) }} · @endif
|
|
||||||
@if ($step['condition']) nur wenn: {{ $step['condition'] }} · @endif
|
|
||||||
@if ($step['executions'] !== [] && ! $step['optional']) So darf das erfüllt werden: {{ implode(', ', $step['executions']) }}@if ($step['why']) – {{ $step['why'] }}@endif · @endif
|
|
||||||
Wer: {{ $performers[$step['performer']] ?? $step['performer'] ?? '–' }}
|
|
||||||
@if ($step['waits'] !== []) · kann warten auf: {{ implode(', ', array_map(fn ($wait) => ['guest' => 'Gast', 'portal' => 'Portal', 'landlord' => 'Sie', 'time' => 'Frist'][$wait] ?? $wait, $step['waits'])) }}@endif
|
|
||||||
@if (! $step['on'] && $step['reason']) · <em>übersprungen: {{ $step['reason'] }}</em>@endif
|
|
||||||
@if ($this->expert()) · <code>{{ $step['module'] }}</code> v{{ $step['version'] }}@endif
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if ($step['mode_setting'] && $step['mode_options'] !== [])
|
|
||||||
<label style="display:block;font-size:.85rem;margin-top:.4rem">Ausführung
|
|
||||||
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $step['mode_setting']->value }}" style="{{ $input }};margin-left:.4rem">
|
|
||||||
<option value="">wie Standard</option>
|
|
||||||
@foreach ($step['mode_options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
|
|
||||||
</select>
|
|
||||||
<span style="{{ $muted }}">{{ $this->setting($step['mode_setting'], $this->profile())['source'] }}</span>
|
|
||||||
</label>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($step['performer_setting'] && count($step['performer_options']) > 1)
|
|
||||||
<label style="display:block;font-size:.85rem;margin-top:.4rem">Wer sendet
|
|
||||||
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $step['performer_setting']->value }}" style="{{ $input }};margin-left:.4rem">
|
|
||||||
<option value="">wie Standard</option>
|
|
||||||
@foreach ($step['performer_options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
|
|
||||||
</select>
|
|
||||||
<span style="{{ $muted }}">im Rahmen des Modells wählbar, ohne Modellwechsel</span>
|
|
||||||
</label>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@foreach ($step['parameters'] as $parameter)
|
|
||||||
<label style="display:block;font-size:.85rem;margin-top:.4rem">{{ $parameter['question'] }}
|
|
||||||
@if ($parameter['options'])
|
|
||||||
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" style="{{ $input }};margin-left:.4rem">
|
|
||||||
<option value="">wie geerbt</option>
|
|
||||||
@foreach ($parameter['options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
|
|
||||||
</select>
|
|
||||||
@else
|
|
||||||
<input type="text" wire:model.live.debounce.600ms="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" placeholder="{{ $parameter['value'] }}" style="{{ $input }};width:8rem;margin-left:.4rem">
|
|
||||||
@endif
|
|
||||||
<span style="{{ $muted }}">wirksam: {{ $parameter['value'] }} ({{ $parameter['source'] }})</span>
|
|
||||||
@if ($parameter['set'])
|
|
||||||
<button type="button" wire:click="inherit('{{ $parameter['key'] }}')" style="{{ $muted }};text-decoration:underline">auf geerbten Wert zurücksetzen</button>
|
|
||||||
@endif
|
|
||||||
</label>
|
|
||||||
@endforeach
|
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endforeach
|
</div>
|
||||||
|
<p style="{{ $muted }};margin-top:.5rem">Gilt für neue Vorgänge. Laufende Vorgänge dieses Kanals ({{ $this->runningCases() }}) behalten ihren bisherigen Ablauf.</p>
|
||||||
|
</x-filament::section>
|
||||||
|
|
||||||
|
<div id="block-detail">
|
||||||
|
@if ($this->block !== '' && isset($blocks[$this->block]))
|
||||||
|
@include('filament.resources.channels.channel-process-block', ['block' => $blocks[$this->block]])
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<x-filament::section heading="Vorschau: ein neuer Vorgang" description="Mit den aktuellen, auch ungespeicherten Einstellungen. Es wird nichts gespeichert und nichts ausgeführt.">
|
@if ($impacts = $this->impacts())
|
||||||
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">
|
<x-filament::section heading="Was die Abschaltung bedeutet">
|
||||||
|
@foreach ($impacts as $impact)
|
||||||
|
<div style="font-size:.9rem;margin-bottom:.6rem">
|
||||||
|
<strong>{{ $impact['label'] }}</strong>: {{ $impact['suggestion'] }}
|
||||||
|
@foreach ($impact['remains'] as $text)<div style="color:#b45309">{{ $text }}</div>@endforeach
|
||||||
|
@if ($impact['affected'] !== [])<div>Betrifft: {{ implode(', ', $impact['affected']) }}</div>@endif
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</x-filament::section>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<x-filament::section heading="Ablauf prüfen" description="Spielt einen ausgedachten Vorgang mit genau diesem – auch ungespeicherten – Entwurf durch, ohne Wirkung auf echte Daten.">
|
||||||
|
<x-filament::button color="gray" wire:click="test">Ablauf testen</x-filament::button>
|
||||||
|
@if ($this->expert())
|
||||||
|
<details style="margin-top:.8rem"><summary style="cursor:pointer;font-size:.9rem">Alle Schritte dieses Ablaufs ({{ count($steps) }})</summary>
|
||||||
|
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem;margin-top:.4rem">
|
||||||
@foreach ($steps as $step)
|
@foreach ($steps as $step)
|
||||||
<li style="{{ $step['on'] ? '' : 'color:#9ca3af;text-decoration:line-through' }}">
|
<li style="{{ $step['on'] ? '' : 'color:#9ca3af;text-decoration:line-through' }}">
|
||||||
{{ $step['label'] }}
|
{{ $step['label'] }}
|
||||||
@@ -172,9 +195,7 @@
|
|||||||
</li>
|
</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
<p style="{{ $muted }};margin-top:.6rem">Gilt für neue Vorgänge. Laufende Vorgänge dieses Kanals ({{ $this->runningCases() }}) behalten ihren bisherigen Ablauf.</p>
|
</details>
|
||||||
<x-filament::button color="gray" wire:click="test" style="margin-top:.6rem">Ablauf testen</x-filament::button>
|
@endif
|
||||||
<p style="{{ $muted }}">Spielt einen ausgedachten Vorgang mit genau dieser Einstellung durch – ohne Wirkung auf echte Daten.</p>
|
|
||||||
</x-filament::section>
|
</x-filament::section>
|
||||||
</div>
|
|
||||||
</x-filament-panels::page>
|
</x-filament-panels::page>
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
use App\Process\Capability;
|
use App\Process\Capability;
|
||||||
use App\Process\ChannelCapabilities;
|
use App\Process\ChannelCapabilities;
|
||||||
use App\Process\ChannelProcessConfiguration;
|
use App\Process\ChannelProcessConfiguration;
|
||||||
|
use App\Process\ConfigurationImpact;
|
||||||
use App\Process\ProcessProfile;
|
use App\Process\ProcessProfile;
|
||||||
use Carbon\CarbonImmutable;
|
use Carbon\CarbonImmutable;
|
||||||
use Database\Seeders\PropertySeeder;
|
use Database\Seeders\PropertySeeder;
|
||||||
@@ -129,7 +130,7 @@ public function test_saving_a_model_that_overrides_a_stored_setting_needs_the_co
|
|||||||
$configuration = app(ChannelProcessConfiguration::class);
|
$configuration = app(ChannelProcessConfiguration::class);
|
||||||
|
|
||||||
$conflicts = $configuration->conflicts($channel->refresh(), IntakeKind::Booking, 'a3.portal_booking');
|
$conflicts = $configuration->conflicts($channel->refresh(), IntakeKind::Booking, 'a3.portal_booking');
|
||||||
$this->assertSame([ProcessSetting::Payments], array_column($conflicts, 'setting'));
|
$this->assertSame([ProcessSetting::Payments, ProcessSetting::GuestMessages], array_column($conflicts, 'setting'), 'fixed and no longer allowed responsibilities are both listed');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
app(ConfigureChannelProcess::class)->handle($channel, IntakeKind::Booking, ['model' => 'a3.portal_booking'], by: 'Lars');
|
app(ConfigureChannelProcess::class)->handle($channel, IntakeKind::Booking, ['model' => 'a3.portal_booking'], by: 'Lars');
|
||||||
@@ -144,17 +145,106 @@ public function test_saving_a_model_that_overrides_a_stored_setting_needs_the_co
|
|||||||
|
|
||||||
$channel->refresh();
|
$channel->refresh();
|
||||||
$this->assertArrayNotHasKey('payments', $channel->process_overrides['booking']);
|
$this->assertArrayNotHasKey('payments', $channel->process_overrides['booking']);
|
||||||
$this->assertSame('portal', $channel->process_overrides['booking']['guest_messages'], 'what the model does not fix stays');
|
$this->assertArrayNotHasKey('guest_messages', $channel->process_overrides['booking'], 'a responsibility the model does not allow is removed with it');
|
||||||
$this->assertStringContainsString('Bisher eingestellt', $channel->settings['process_history'][0]['removed_settings'][0]);
|
$this->assertStringContainsString('Bisher eingestellt', $channel->settings['process_history'][0]['removed_settings'][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regression: Destination Solutions with the old `payments = portal`, switched to A3 in the configurator with the
|
||||||
|
* confirmation. The page carries the stale value in its draft; saving used to fail with "Inkasso … nicht zulässig".
|
||||||
|
*/
|
||||||
|
public function test_confirmed_switch_from_old_portal_collection_to_a3_saves_through_the_page(): void
|
||||||
|
{
|
||||||
|
$ds = $this->channel('Destination Solution', ['booking' => ['payments' => 'portal', 'guest_messages' => 'portal', 'contract_delivery' => 'manual']]);
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])->set('intake', 'booking');
|
||||||
|
$this->assertSame('portal', $page->get('drafts')['booking']['settings']['payments'], 'the page carries the stale value');
|
||||||
|
$page->set('capabilityDraft.collects_payment', '0')->call('chooseModel', 'a3.portal_booking');
|
||||||
|
$this->assertSame([], $page->instance()->problems(), 'a stored value the confirmed switch removes is not an error');
|
||||||
|
|
||||||
|
$page->call('save')->assertNotified('Nicht gespeichert');
|
||||||
|
$this->assertSame('portal', $ds->fresh()->process_overrides['booking']['payments'], 'without the confirmation nothing changes');
|
||||||
|
|
||||||
|
$page->set('acknowledge', true)->call('save')->assertNotified('Ablauf gespeichert');
|
||||||
|
|
||||||
|
$ds->refresh();
|
||||||
|
$this->assertSame('a3.portal_booking', $ds->process_overrides['booking']['model']);
|
||||||
|
$this->assertArrayNotHasKey('payments', $ds->process_overrides['booking']);
|
||||||
|
$this->assertArrayNotHasKey('guest_messages', $ds->process_overrides['booking'], 'a responsibility the model does not allow goes with it');
|
||||||
|
$this->assertSame('manual', $ds->process_overrides['booking']['contract_delivery'], 'unrelated stored settings stay');
|
||||||
|
$this->assertSame([], $page->instance()->conflicts(), 'the stale setting does not return as an error or conflict');
|
||||||
|
$this->assertSame([], $page->instance()->problems());
|
||||||
|
$this->assertArrayNotHasKey('payments', $page->get('drafts')['booking']['settings']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A3 → A4 → A3 keeps the stored values consistent; stored values the target model accepts are untouched. */
|
||||||
|
public function test_switching_between_a3_and_a4_keeps_settings_consistent(): void
|
||||||
|
{
|
||||||
|
$ds = $this->channel('Destination Solution', []);
|
||||||
|
$configuration = app(ChannelProcessConfiguration::class);
|
||||||
|
$save = app(ConfigureChannelProcess::class);
|
||||||
|
|
||||||
|
$save->handle($ds, IntakeKind::Booking, ['model' => 'a3.portal_booking', 'capabilities' => ['collects_payment' => '0'], 'settings' => ['guest_messages' => 'landlord']], by: 'Lars');
|
||||||
|
$this->assertSame('landlord', $ds->fresh()->process_overrides['booking']['guest_messages']);
|
||||||
|
|
||||||
|
$save->handle($ds->fresh(), IntakeKind::Booking, ['model' => 'a4.portal_booking', 'capabilities' => ['collects_payment' => '1']], by: 'Lars');
|
||||||
|
$this->assertSame('a4.portal_booking', $ds->fresh()->process_overrides['booking']['model']);
|
||||||
|
$this->assertSame([], $configuration->conflicts($ds->fresh(), IntakeKind::Booking, 'a4.portal_booking'));
|
||||||
|
|
||||||
|
$save->handle($ds->fresh(), IntakeKind::Booking, ['model' => 'a3.portal_booking', 'capabilities' => ['collects_payment' => '0']], by: 'Lars');
|
||||||
|
$this->assertSame('a3.portal_booking', $ds->fresh()->process_overrides['booking']['model']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A running case keeps its frozen plan when the channel model changes; other channels and intake kinds stay untouched. */
|
||||||
|
public function test_a_confirmed_switch_does_not_touch_running_cases_or_other_channels(): void
|
||||||
|
{
|
||||||
|
$ds = $this->channel('Destination Solution', ['booking' => ['payments' => 'portal']]);
|
||||||
|
$other = $this->channel('Sonstiges Portal', ['booking' => ['payments' => 'portal'], 'inquiry' => ['hold_hours' => 12]]);
|
||||||
|
$ds->update(['process_overrides' => [...$ds->process_overrides, 'inquiry' => ['hold_hours' => 24]]]);
|
||||||
|
$booking = app(TakeOverExternalBooking::class)->handle($this->property, $ds->fresh(), CarbonImmutable::parse('2026-12-05'), CarbonImmutable::parse('2026-12-09'), ['portal_reference' => 'DS-ALT']);
|
||||||
|
$frozen = $booking->fresh()->profile;
|
||||||
|
|
||||||
|
app(ConfigureChannelProcess::class)->handle($ds->fresh(), IntakeKind::Booking, ['model' => 'a3.portal_booking', 'capabilities' => ['collects_payment' => '0'], 'settings' => ['payments' => 'portal']], by: 'Lars', acknowledgeConflicts: true);
|
||||||
|
|
||||||
|
$this->assertSame($frozen, $booking->fresh()->profile, 'the running case keeps its frozen plan');
|
||||||
|
$this->assertSame('portal', $other->fresh()->process_overrides['booking']['payments'], 'another channel is untouched');
|
||||||
|
$this->assertSame(['hold_hours' => 24], array_intersect_key($ds->fresh()->process_overrides['inquiry'], ['hold_hours' => 1]), 'the other intake kind is untouched');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Switching a step off never drops the duty it served: the impact names dependants, what stays and the admissible ways. */
|
||||||
|
public function test_switching_off_the_data_request_shows_what_stays_and_the_alternatives_without_changing_anything(): void
|
||||||
|
{
|
||||||
|
$ds = $this->channel('Destination Solution', []);
|
||||||
|
$impact = app(ConfigurationImpact::class);
|
||||||
|
|
||||||
|
$this->assertSame([], $impact->of($ds, IntakeKind::Booking, ['model' => 'a3.portal_booking']), 'nothing switched off, nothing to report');
|
||||||
|
|
||||||
|
$draft = ['model' => 'a3.portal_booking', 'steps' => ['guest.data_request' => ['on' => false]]];
|
||||||
|
$result = collect($impact->of($ds, IntakeKind::Booking, $draft))->firstWhere('module', 'guest.data_request');
|
||||||
|
|
||||||
|
$this->assertTrue($result['valid']);
|
||||||
|
$this->assertSame([], $result['affected'], 'no step of this model waits for the data request: they carry on');
|
||||||
|
$this->assertContains('von Ihnen von Hand', $result['alternatives'], 'the admissible ways to obtain the data remain offered');
|
||||||
|
$this->assertStringContainsString('Es wird nichts anderes automatisch geändert', $result['suggestion']);
|
||||||
|
$this->assertSame([], app(ChannelProcessConfiguration::class)->problems($ds, IntakeKind::Booking, $draft), 'the combination is valid');
|
||||||
|
|
||||||
|
$mandatory = collect($impact->of($ds, IntakeKind::Booking, ['model' => 'a3.portal_booking', 'steps' => ['documents.send' => ['on' => false]]]))->firstWhere('module', 'documents.send');
|
||||||
|
$this->assertFalse($mandatory['valid']);
|
||||||
|
$this->assertStringContainsString('Pflicht', $mandatory['suggestion']);
|
||||||
|
|
||||||
|
$dependants = collect($impact->of($ds, IntakeKind::Booking, ['model' => 'a3.portal_booking', 'steps' => ['portal.confirmation' => ['on' => false]]]))->firstWhere('module', 'portal.confirmation');
|
||||||
|
$this->assertContains('Buchungsunterlagen (Vertragsdokumentation)', $dependants['affected'], 'the documents depend hard on the confirmation step');
|
||||||
|
$this->assertNotEmpty($dependants['remains']);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_unknown_capabilities_block_nothing_but_ask_for_confirmation(): void
|
public function test_unknown_capabilities_block_nothing_but_ask_for_confirmation(): void
|
||||||
{
|
{
|
||||||
$generic = $this->channel('Irgendein Portal', []);
|
$generic = $this->channel('Irgendein Portal', []);
|
||||||
|
|
||||||
$options = app(ChannelProcessConfiguration::class)->modelOptions($generic, IntakeKind::Booking);
|
$options = app(ChannelProcessConfiguration::class)->modelOptions($generic, IntakeKind::Booking);
|
||||||
|
|
||||||
$this->assertSame(['a3.portal_booking', 'a4.portal_booking', 'a5.portal_booking'], array_keys(array_filter($options, fn (array $option): bool => $option['admissible'])));
|
$this->assertSame(['a3.portal_booking', 'a4.portal_booking', 'a5.portal_booking', 'external.booking'], array_keys(array_filter($options, fn (array $option): bool => $option['admissible'])));
|
||||||
$this->assertNotSame([], $options['a4.portal_booking']['hints']);
|
$this->assertNotSame([], $options['a4.portal_booking']['hints']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,16 +71,16 @@ public function test_only_admissible_models_per_channel_and_intake_are_offered()
|
|||||||
$listing = $this->channel('Ostseeklar', 'inquiry');
|
$listing = $this->channel('Ostseeklar', 'inquiry');
|
||||||
$website = Channel::websiteOf($this->property);
|
$website = Channel::websiteOf($this->property);
|
||||||
|
|
||||||
$this->assertSame(['a2.offer', 'a2.information'], array_keys($configuration->admissibleModels($fewo, IntakeKind::Inquiry)));
|
$this->assertSame(['a2.offer', 'a2.information', 'inquiry.request'], array_keys($configuration->admissibleModels($fewo, IntakeKind::Inquiry)));
|
||||||
$this->assertSame(['a4.portal_booking'], array_keys($configuration->admissibleModels($fewo, IntakeKind::Booking)), 'O2: FeWo-direkt bookings only A4 for now');
|
$this->assertSame(['a4.portal_booking', 'external.booking'], array_keys($configuration->admissibleModels($fewo, IntakeKind::Booking)), 'O2: of the archetypes only A4 fits FeWo-direkt; the base process is open and restricts per template');
|
||||||
$this->assertSame(['a3.portal_booking'], array_keys($configuration->admissibleModels($ds, IntakeKind::Booking)));
|
$this->assertSame(['a3.portal_booking', 'external.booking'], array_keys($configuration->admissibleModels($ds, IntakeKind::Booking)));
|
||||||
$this->assertSame([IntakeKind::Booking], $configuration->intakes($ds));
|
$this->assertSame([IntakeKind::Booking], $configuration->intakes($ds));
|
||||||
$this->assertSame(['a2.offer', 'a2.information'], array_keys($configuration->admissibleModels($listing, IntakeKind::Inquiry)));
|
$this->assertSame(['a2.offer', 'a2.information', 'inquiry.request'], array_keys($configuration->admissibleModels($listing, IntakeKind::Inquiry)));
|
||||||
$this->assertSame(['a1.offer', 'a1.information'], array_keys($configuration->admissibleModels($website, IntakeKind::Inquiry)));
|
$this->assertSame(['a1.offer', 'a1.information', 'inquiry.request'], array_keys($configuration->admissibleModels($website, IntakeKind::Inquiry)));
|
||||||
|
|
||||||
// The restriction lives in the channel profile, not in the process core: a changed profile releases more models.
|
// The restriction lives in the channel profile, not in the process core: a changed profile releases more models.
|
||||||
$fewo->update(['settings' => [...(array) $fewo->settings, 'portal_profile' => 'generic']]);
|
$fewo->update(['settings' => [...(array) $fewo->settings, 'portal_profile' => 'generic']]);
|
||||||
$this->assertSame(['a3.portal_booking', 'a4.portal_booking', 'a5.portal_booking'], array_keys($configuration->admissibleModels($fewo->fresh(), IntakeKind::Booking)));
|
$this->assertSame(['a3.portal_booking', 'a4.portal_booking', 'a5.portal_booking', 'external.booking'], array_keys($configuration->admissibleModels($fewo->fresh(), IntakeKind::Booking)));
|
||||||
|
|
||||||
$this->expectException(ValidationException::class);
|
$this->expectException(ValidationException::class);
|
||||||
app(ConfigureChannelProcess::class)->handle($ds, IntakeKind::Booking, ['model' => 'a4.portal_booking']);
|
app(ConfigureChannelProcess::class)->handle($ds, IntakeKind::Booking, ['model' => 'a4.portal_booking']);
|
||||||
@@ -193,9 +193,9 @@ public function test_the_page_shows_the_steps_with_their_settings_and_saves(): v
|
|||||||
Livewire::test(ChannelProcess::class, ['record' => $website->getRouteKey()])
|
Livewire::test(ChannelProcess::class, ['record' => $website->getRouteKey()])
|
||||||
->assertSee('Wie wird eine Anfrage über')
|
->assertSee('Wie wird eine Anfrage über')
|
||||||
->assertSee('Angebot mit Vorreservierung')
|
->assertSee('Angebot mit Vorreservierung')
|
||||||
|
->assertSee('Der Geschäftsprozess')
|
||||||
|
->call('selectBlock', 'intake')
|
||||||
->assertSee('Fehlende Angaben beim Gast anfragen')
|
->assertSee('Fehlende Angaben beim Gast anfragen')
|
||||||
->assertSee('Pflicht')
|
|
||||||
->assertSee('Vorschau: ein neuer Vorgang')
|
|
||||||
->set('drafts.inquiry.settings.hold_hours', '24')
|
->set('drafts.inquiry.settings.hold_hours', '24')
|
||||||
->assertSee('hier gesetzt')
|
->assertSee('hier gesetzt')
|
||||||
->call('save')
|
->call('save')
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public function test_case_h_an_optional_address_check_is_added_at_an_extension_p
|
|||||||
$catalogue = app(ProcessCatalogue::class);
|
$catalogue = app(ProcessCatalogue::class);
|
||||||
$using = array_keys(array_filter($catalogue->models(), fn ($model): bool => collect($model->variants())->contains(fn ($variant): bool => in_array('guest.address_check', $model->modules($variant->key), true))));
|
$using = array_keys(array_filter($catalogue->models(), fn ($model): bool => collect($model->variants())->contains(fn ($variant): bool => in_array('guest.address_check', $model->modules($variant->key), true))));
|
||||||
|
|
||||||
$this->assertSame(['a1.offer'], $using);
|
$this->assertSame(['a1.offer', 'inquiry.request'], $using, 'the former offer model and the request base process that replaces it');
|
||||||
$this->assertSame([], $catalogue->problems());
|
$this->assertSame([], $catalogue->problems());
|
||||||
foreach ($catalogue->models() as $key => $model) {
|
foreach ($catalogue->models() as $key => $model) {
|
||||||
$this->assertNotContains('guest.address_check', $model->modules('standard'), "{$key}: standard course unchanged");
|
$this->assertNotContains('guest.address_check', $model->modules('standard'), "{$key}: standard course unchanged");
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Process;
|
||||||
|
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Models\Booking;
|
||||||
|
use App\Models\Channel;
|
||||||
|
use App\Models\Property;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Process\Tester\ProcessSandbox;
|
||||||
|
use App\Support\Content;
|
||||||
|
use App\Support\Settings;
|
||||||
|
use Carbon\CarbonImmutable;
|
||||||
|
use Database\Seeders\PropertySeeder;
|
||||||
|
use Database\Seeders\SiteSeeder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\Group;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relevant request variants played through the isolated tester: general question without a case, information,
|
||||||
|
* binding offer with acceptance, request with independent data collection and reservation (with and without early
|
||||||
|
* reservation), portal request with the portal as standard sender. The report shows the templates and what waits.
|
||||||
|
*/
|
||||||
|
#[Group('sandbox')]
|
||||||
|
class InquiryProcessTesterTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private Property $property;
|
||||||
|
|
||||||
|
private User $user;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->travelTo(CarbonImmutable::parse('2026-10-23 10:00'));
|
||||||
|
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||||
|
$this->property = Property::sole();
|
||||||
|
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||||
|
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'vermieter@example.org', 'process_defaults' => ['processing' => 'automatic', 'clarification_hold_auto_minutes' => 120, 'data_request_mode' => 'automatic']]);
|
||||||
|
$this->user = User::factory()->create();
|
||||||
|
ProcessTesterTest::template();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_general_question_creates_no_booking_case(): void
|
||||||
|
{
|
||||||
|
$report = $this->play(Channel::websiteOf($this->property), 'general_question_message', ['model' => 'inquiry.request'], 1);
|
||||||
|
|
||||||
|
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||||
|
$this->assertNull($report['plan'], 'no case, so no plan');
|
||||||
|
$this->assertSame([], $report['violations']);
|
||||||
|
$this->assertSame(0, Booking::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_binding_offer_is_sent_and_accepted(): void
|
||||||
|
{
|
||||||
|
$report = $this->play(Channel::websiteOf($this->property), 'complete_request', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']], 3);
|
||||||
|
|
||||||
|
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||||
|
$this->assertContains('inquiry.binding_offer@1', array_column($report['plan']['templates'], 'reference'));
|
||||||
|
[$sent, , $accepted] = $report['timeline'];
|
||||||
|
$this->assertSame('Angebot gesendet', $sent['status']);
|
||||||
|
$this->assertTrue($sent['calendar']['occupying'], 'the offer holds the dates');
|
||||||
|
$this->assertSame('Bestätigt', $accepted['status']);
|
||||||
|
$this->assertContains('Gast nimmt das Angebot an', $sent['waiting']);
|
||||||
|
$this->assertSame(0, Booking::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_information_reserves_nothing(): void
|
||||||
|
{
|
||||||
|
$report = $this->play(Channel::websiteOf($this->property), 'complete_request', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.information']], 2);
|
||||||
|
|
||||||
|
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||||
|
$this->assertContains('inquiry.information@1', array_column($report['plan']['templates'], 'reference'));
|
||||||
|
$first = $report['timeline'][0];
|
||||||
|
$this->assertFalse($first['calendar']['occupying']);
|
||||||
|
$this->assertNull($first['calendar']['hold_until']);
|
||||||
|
$this->assertContains('Unverbindliche Auskunft senden (automatisch)', array_column($first['activities'], 'label'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_data_collection_and_reservation_run_independently_and_the_strategy_is_free(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
|
||||||
|
$reserving = $this->play($website, 'missing_address', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']], 3);
|
||||||
|
$early = $reserving['timeline'][0];
|
||||||
|
$this->assertTrue($early['calendar']['occupying'], 'suggested strategy: the dates are held at once');
|
||||||
|
$this->assertNotNull($early['calendar']['hold_until']);
|
||||||
|
$this->assertContains('Angaben für das Angebot vervollständigen', $early['waiting'], 'the details are missing – evidence is open');
|
||||||
|
$this->assertStringContainsString('Bitte ergänzen Sie Ihre Angaben', implode(' ', array_column($early['mails'], 'subject')), 'the data request goes out although the offer waits');
|
||||||
|
$this->assertSame('Angebot gesendet', $reserving['timeline'][2]['status']);
|
||||||
|
|
||||||
|
$free = $this->play($website, 'missing_address', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer'], 'settings' => ['pre_reservation' => '0']], 3);
|
||||||
|
$this->assertFalse($free['timeline'][0]['calendar']['occupying'], 'same answer, other strategy: nothing held at the request');
|
||||||
|
$this->assertStringContainsString('Bitte ergänzen Sie Ihre Angaben', implode(' ', array_column($free['timeline'][0]['mails'], 'subject')), 'the data collection does not depend on the reservation');
|
||||||
|
$this->assertSame('Angebot gesendet', $free['timeline'][2]['status'], 'and the offer still goes out once the details are there');
|
||||||
|
$this->assertTrue($free['timeline'][2]['calendar']['occupying'], 'the offer itself holds the dates');
|
||||||
|
$this->assertSame(0, Booking::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_portal_request_with_the_portal_as_standard_sender_shows_the_unconfirmed_capability(): void
|
||||||
|
{
|
||||||
|
$portal = Channel::factory()->for($this->property)->create(['name' => 'Anfrageportal', 'booking_model' => 'inquiry', 'status' => 'setup', 'is_active' => false, 'import_enabled' => false, 'settings' => ['import_url' => 'https://anfrage.example/a.ics', 'portal_profile' => 'generic']]);
|
||||||
|
|
||||||
|
$report = $this->play($portal, 'portal_inquiry', ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer', 'guest_communication' => 'guest_comm.portal']], 3);
|
||||||
|
|
||||||
|
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||||
|
$communication = collect($report['plan']['templates'])->firstWhere('reference', 'guest_comm.portal@1');
|
||||||
|
$this->assertNotNull($communication);
|
||||||
|
$this->assertFalse($communication['capabilities'][0]['confirmed'], 'the portal writing to guests is not shown as proven');
|
||||||
|
$sender = collect($report['plan']['configuration'])->firstWhere('question', 'Wer schickt dem Gast die Anreise-Informationen?');
|
||||||
|
$this->assertSame(['Das Portal', 'Vorschlag der gewählten Funktionsschablone'], [$sender['value'], $sender['source']]);
|
||||||
|
$this->assertSame(0, Booking::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $draft
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function play(Channel $channel, string $scenario, array $draft, int $steps): array
|
||||||
|
{
|
||||||
|
return app(ProcessSandbox::class)->run($channel, IntakeKind::Inquiry, $draft, $scenario, ['arrival' => '2026-11-07', 'nights' => 3, 'guests' => 2, 'text' => 'question'], $steps, $this->user)->report;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,306 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Process;
|
||||||
|
|
||||||
|
use App\Actions\ConfigureChannelProcess;
|
||||||
|
use App\Actions\CreateReservation;
|
||||||
|
use App\Actions\TakeOverExternalBooking;
|
||||||
|
use App\Actions\TakeOverPortalInquiry;
|
||||||
|
use App\Enums\ActivityState;
|
||||||
|
use App\Enums\InquiryAnswer;
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Enums\ProcessSetting;
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
use App\Models\Booking;
|
||||||
|
use App\Models\Channel;
|
||||||
|
use App\Models\Property;
|
||||||
|
use App\Pricing\StayRequest;
|
||||||
|
use App\Process\CaseActivities;
|
||||||
|
use App\Process\CaseContext;
|
||||||
|
use App\Process\ChannelProcessConfiguration;
|
||||||
|
use App\Process\ProcessCatalogue;
|
||||||
|
use App\Process\ProcessLanes;
|
||||||
|
use App\Process\ProcessPlan;
|
||||||
|
use App\Process\ProcessProfile;
|
||||||
|
use App\Process\ProcessRunner;
|
||||||
|
use App\Process\Templates\TemplateComposer;
|
||||||
|
use App\Support\Content;
|
||||||
|
use App\Support\Settings;
|
||||||
|
use Carbon\CarbonImmutable;
|
||||||
|
use Database\Seeders\PropertySeeder;
|
||||||
|
use Database\Seeders\SiteSeeder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Mail\MailManager;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use PHPUnit\Framework\Attributes\Group;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The request base process (`inquiry.request`): the same principle as the externally binding booking – base process,
|
||||||
|
* combinable function templates, individually configurable modules – for the own website and portal requests. Covers
|
||||||
|
* the equivalence with A1/A2, the decoupling of the answer from the reservation, guest communication per occasion and
|
||||||
|
* that the displayed dependencies are the executed ones.
|
||||||
|
*/
|
||||||
|
#[Group('configurator')]
|
||||||
|
class InquiryTemplateTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private Property $property;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->travelTo(CarbonImmutable::parse('2026-10-23 10:00'));
|
||||||
|
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||||
|
$this->property = Property::sole();
|
||||||
|
Storage::fake('local');
|
||||||
|
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||||
|
config(['mail.default' => 'array']);
|
||||||
|
Mail::swap(new MailManager($this->app));
|
||||||
|
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'test@example.org']);
|
||||||
|
Http::preventStrayRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_catalogue_with_the_request_base_process_is_consistent(): void
|
||||||
|
{
|
||||||
|
$this->assertSame([], app(ProcessCatalogue::class)->problems());
|
||||||
|
$model = app(ProcessCatalogue::class)->model('inquiry.request');
|
||||||
|
$this->assertEqualsCanonicalizing(['inquiry_answer', 'contract_documents', 'collection', 'guest_communication'], array_map(fn ($area): string => $area->value, $model->slots()));
|
||||||
|
foreach (['a1.offer', 'a1.information', 'a2.offer', 'a2.information'] as $legacy) {
|
||||||
|
$archetype = app(ProcessCatalogue::class)->model($legacy);
|
||||||
|
$this->assertTrue($archetype::isLegacy());
|
||||||
|
$this->assertSame([], app(TemplateComposer::class)->problems($model, $archetype::presetTemplates()), $legacy.' is a valid combination of the base process');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array{0: string, 1: string, 2: bool}> archetype, answer template, whether the portal sends the request
|
||||||
|
*/
|
||||||
|
public static function archetypes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A1 offer' => ['a1.offer', 'inquiry.binding_offer', false],
|
||||||
|
'A1 information' => ['a1.information', 'inquiry.information', false],
|
||||||
|
'A2 offer' => ['a2.offer', 'inquiry.binding_offer', true],
|
||||||
|
'A2 information' => ['a2.information', 'inquiry.information', true],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DataProvider('archetypes')]
|
||||||
|
public function test_the_base_process_behaves_like_the_archetype_it_replaces(string $legacy, string $answer, bool $viaPortal): void
|
||||||
|
{
|
||||||
|
$channel = $viaPortal ? $this->portal() : Channel::websiteOf($this->property);
|
||||||
|
|
||||||
|
$this->configure($channel, ['model' => $legacy]);
|
||||||
|
$old = $this->request($channel->fresh(), $viaPortal, '2026-11-07');
|
||||||
|
$this->configure($channel->fresh(), ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => $answer]]);
|
||||||
|
$new = $this->request($channel->fresh(), $viaPortal, '2026-12-07');
|
||||||
|
|
||||||
|
$oldValues = $old->process()->values;
|
||||||
|
$newValues = $new->process()->values;
|
||||||
|
unset($oldValues['contract_template_id'], $newValues['contract_template_id']);
|
||||||
|
$this->assertEquals($oldValues, $newValues, 'identical effective configuration');
|
||||||
|
$this->assertSame($old->case_type, $new->case_type);
|
||||||
|
$this->assertSame($old->hold_purpose, $new->hold_purpose);
|
||||||
|
$this->assertSame($old->hold_expires_at === null, $new->hold_expires_at === null, 'the same reservation behaviour');
|
||||||
|
|
||||||
|
$summarise = fn (Booking $booking): array => collect(CaseActivities::for($booking->fresh()))->map(fn ($activity): array => [$activity->key, $activity->label, $activity->state->value])->all();
|
||||||
|
$this->assertSame($summarise($old), $summarise($new), 'identical activities and states');
|
||||||
|
$this->assertSame('inquiry.request', ProcessPlan::of($new)->model);
|
||||||
|
$this->assertArrayHasKey('guest_communication', ProcessPlan::of($new)->templates);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_answer_template_does_not_force_a_reservation_strategy(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
$configuration = app(ChannelProcessConfiguration::class);
|
||||||
|
|
||||||
|
// Binding offer: reservation at the request is a suggestion – both strategies are admissible.
|
||||||
|
foreach ([null, '1', '0'] as $reservation) {
|
||||||
|
$draft = ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer'], 'settings' => $reservation === null ? [] : ['pre_reservation' => $reservation]];
|
||||||
|
$this->assertSame([], $configuration->problems($website, IntakeKind::Inquiry, $draft), 'binding offer with reservation setting '.var_export($reservation, true));
|
||||||
|
}
|
||||||
|
$this->assertTrue($configuration->profileWith($website, IntakeKind::Inquiry, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']])->preReservation());
|
||||||
|
$this->assertSame(ProcessProfile::TEMPLATE_DEFAULT, $configuration->profileWith($website, IntakeKind::Inquiry, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']])->source(ProcessSetting::PreReservation));
|
||||||
|
|
||||||
|
// Information: by definition nothing is reserved – the documented rule, with its reason.
|
||||||
|
$problems = $configuration->problems($website, IntakeKind::Inquiry, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.information'], 'settings' => ['pre_reservation' => '1']]);
|
||||||
|
$this->assertStringContainsString('widerspricht der Schablone', implode(' ', $problems));
|
||||||
|
|
||||||
|
// Offer without early reservation: no hold at an incomplete request, the offer itself holds later.
|
||||||
|
$this->configure($website, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer'], 'settings' => ['pre_reservation' => '0']]);
|
||||||
|
$incomplete = $this->request($website->fresh(), false, '2026-11-07', street: '');
|
||||||
|
$this->assertNull($incomplete->hold_expires_at, 'no reservation at the request');
|
||||||
|
$this->assertSame(InquiryAnswer::Offer, $incomplete->process()->inquiryAnswer());
|
||||||
|
$this->assertFalse(Booking::query()->occupying()->whereKey($incomplete->id)->exists());
|
||||||
|
|
||||||
|
$this->configure($website->fresh(), ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer'], 'settings' => ['pre_reservation' => null]]);
|
||||||
|
$held = $this->request($website->fresh(), false, '2026-12-07', street: '');
|
||||||
|
$this->assertNotNull($held->hold_expires_at, 'the suggested strategy: clarification hold at the request');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_switching_the_answer_keeps_explicit_module_parameters_and_asks_before_dropping_a_contradicting_one(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
$this->configure($website, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer'], 'settings' => ['hold_hours' => '24', 'processing' => 'automatic', 'guest_link_valid_days' => '7']]);
|
||||||
|
|
||||||
|
$this->configure($website->fresh(), ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.information'], 'settings' => ['hold_hours' => '24', 'processing' => 'automatic', 'guest_link_valid_days' => '7']]);
|
||||||
|
$saved = $website->fresh()->process_overrides['inquiry'];
|
||||||
|
$this->assertEquals(['24', 'automatic'], [(string) $saved['hold_hours'], $saved['processing']], 'explicit parameters survive the switch');
|
||||||
|
$this->assertSame('inquiry.information', $saved['templates']['inquiry_answer']);
|
||||||
|
|
||||||
|
// An explicitly stored reservation contradicts the information: it must be confirmed before it goes.
|
||||||
|
$website->fresh()->update(['process_overrides' => ['inquiry' => [...$saved, 'pre_reservation' => true]]]);
|
||||||
|
$conflicts = app(ChannelProcessConfiguration::class)->conflicts($website->fresh(), IntakeKind::Inquiry, 'inquiry.request', ['inquiry_answer' => 'inquiry.information']);
|
||||||
|
$this->assertSame([ProcessSetting::PreReservation], array_column($conflicts, 'setting'));
|
||||||
|
$this->expectException(ValidationException::class);
|
||||||
|
app(ConfigureChannelProcess::class)->handle($website->fresh(), IntakeKind::Inquiry, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.information']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_requests_take_no_portal_collection_and_no_external_documents(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
$configuration = app(ChannelProcessConfiguration::class);
|
||||||
|
$options = $configuration->templateOptions($website, app(ProcessCatalogue::class)->model('inquiry.request'));
|
||||||
|
|
||||||
|
$this->assertFalse($options['collection']['collection.portal']['admissible']);
|
||||||
|
$this->assertStringContainsString('Annahme des Angebots', $options['collection']['collection.portal']['restrictions'][0]->reason);
|
||||||
|
$this->assertFalse($options['contract_documents']['contract_docs.external']['admissible']);
|
||||||
|
$this->assertFalse($options['guest_communication']['guest_comm.portal']['admissible'], 'the own website has no portal');
|
||||||
|
$this->assertNotSame([], $configuration->problems($website, IntakeKind::Inquiry, ['model' => 'inquiry.request', 'templates' => ['collection' => 'collection.portal']]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_guest_communication_is_assigned_per_occasion_without_touching_other_tasks(): void
|
||||||
|
{
|
||||||
|
$channel = $this->bookingPortal();
|
||||||
|
$this->configure($channel, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own']], IntakeKind::Booking);
|
||||||
|
$baseline = $this->takeOver($channel->fresh(), 'KOM-1', '2027-07-10');
|
||||||
|
|
||||||
|
$this->configure($channel->fresh(), ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own'], 'settings' => ['arrival_info_sender' => 'portal']], IntakeKind::Booking);
|
||||||
|
$changed = $this->takeOver($channel->fresh(), 'KOM-2', '2027-08-10');
|
||||||
|
|
||||||
|
$activities = fn (Booking $booking): array => collect(CaseActivities::for($booking->fresh()))->keyBy('key')->all();
|
||||||
|
[$before, $after] = [$activities($baseline), $activities($changed)];
|
||||||
|
$this->assertSame(ActivityState::External, $after['arrival_info']->state, 'the arrival information is now the portal’s');
|
||||||
|
$this->assertNotSame(ActivityState::External, $before['arrival_info']->state);
|
||||||
|
$this->assertArrayHasKey('review', $after, 'the review request stays with us');
|
||||||
|
$this->assertSame(array_keys($before), array_keys($after), 'no other task appears or disappears');
|
||||||
|
foreach (array_diff(array_keys($before), ['arrival_info']) as $key) {
|
||||||
|
$this->assertSame($before[$key]->state, $after[$key]->state, $key.' is unchanged');
|
||||||
|
}
|
||||||
|
$profile = $changed->process();
|
||||||
|
$this->assertSame([Responsibility::Portal, Responsibility::Landlord, Responsibility::Landlord], [$profile->arrivalInfoSender(), $profile->reviewRequestSender(), $profile->payments()]);
|
||||||
|
$this->assertSame(Responsibility::Landlord, $profile->guestMessages(), 'the umbrella setting is untouched');
|
||||||
|
|
||||||
|
// And the other way round: the review request goes to the portal, the arrival information stays ours.
|
||||||
|
$this->configure($channel->fresh(), ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own'], 'settings' => ['arrival_info_sender' => null, 'review_request_sender' => 'portal']], IntakeKind::Booking);
|
||||||
|
$other = $this->takeOver($channel->fresh(), 'KOM-3', '2027-09-10');
|
||||||
|
$this->assertArrayNotHasKey('review', $activities($other));
|
||||||
|
$this->assertNotSame(ActivityState::External, $activities($other)['arrival_info']->state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_portal_inquiry_gets_the_portal_as_standard_sender_that_each_occasion_can_take_back(): void
|
||||||
|
{
|
||||||
|
$portal = $this->portal();
|
||||||
|
$this->configure($portal, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer', 'guest_communication' => 'guest_comm.portal']]);
|
||||||
|
$case = $this->request($portal->fresh(), true, '2027-01-12');
|
||||||
|
$this->assertEquals(['guest_communication' => 'guest_comm.portal@1'], array_intersect_key(ProcessPlan::of($case)->templates, ['guest_communication' => 1]));
|
||||||
|
$this->assertSame([Responsibility::Portal, Responsibility::Portal], [$case->process()->arrivalInfoSender(), $case->process()->reviewRequestSender()]);
|
||||||
|
$this->assertSame(ProcessProfile::TEMPLATE_DEFAULT, $case->process()->source(ProcessSetting::ArrivalInfoSender));
|
||||||
|
|
||||||
|
$this->configure($portal->fresh(), ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer', 'guest_communication' => 'guest_comm.portal'], 'settings' => ['review_request_sender' => 'landlord']]);
|
||||||
|
$mixed = $this->request($portal->fresh(), true, '2027-02-12');
|
||||||
|
$this->assertSame([Responsibility::Portal, Responsibility::Landlord], [$mixed->process()->arrivalInfoSender(), $mixed->process()->reviewRequestSender()], 'the explicit value wins over the template suggestion');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_cases_frozen_before_the_new_settings_read_exactly_as_before(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
$this->configure($website, ['model' => 'a1.information']);
|
||||||
|
$case = $this->request($website->fresh(), false, '2026-11-07');
|
||||||
|
$profile = $case->profile;
|
||||||
|
foreach (['inquiry_answer', 'arrival_info_sender', 'review_request_sender'] as $key) {
|
||||||
|
unset($profile['values'][$key], $profile['sources'][$key]);
|
||||||
|
}
|
||||||
|
$case->forceFill(['profile' => $profile])->saveQuietly();
|
||||||
|
|
||||||
|
$old = $case->fresh()->process();
|
||||||
|
$this->assertSame(InquiryAnswer::Information, $old->inquiryAnswer(), 'derived from the reservation, as before');
|
||||||
|
$this->assertSame([$old->guestMessages(), $old->guestMessages()], [$old->arrivalInfoSender(), $old->reviewRequestSender()]);
|
||||||
|
$this->assertSame('a1.information', ProcessPlan::of($case->fresh())->model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_displayed_dependencies_are_the_executed_ones(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
$this->configure($website, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']]);
|
||||||
|
$draft = ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']];
|
||||||
|
|
||||||
|
$lanes = app(ProcessLanes::class)->of(app(ChannelProcessConfiguration::class)->preview($website->fresh(), IntakeKind::Inquiry, $draft));
|
||||||
|
$labels = fn (string $lane): array => array_column($lanes[$lane], 'module');
|
||||||
|
$this->assertContains('hold', $labels('parallel'), 'the reservation runs at once');
|
||||||
|
$this->assertContains('guest.data_request', $labels('parallel'), 'so does the data collection – independent of each other');
|
||||||
|
$this->assertContains('offer.binding', $labels('waiting'));
|
||||||
|
$this->assertContains('documents.send', $labels('waiting'));
|
||||||
|
$this->assertContains('case.tasks', $labels('event'));
|
||||||
|
$this->assertContains('arrival.info', $labels('later'));
|
||||||
|
$this->assertNotContains('offer.information', array_merge(...array_values(array_map(fn (array $lane): array => array_column($lane, 'module'), $lanes))), 'an offer needs no information step: it is not in the plan at all');
|
||||||
|
|
||||||
|
// The runner agrees: with missing details the offer is held back, the hold and the data request are not.
|
||||||
|
$case = $this->request($website->fresh(), false, '2026-11-07', street: '');
|
||||||
|
$context = CaseContext::of($case);
|
||||||
|
$runner = app(ProcessRunner::class);
|
||||||
|
$catalogue = app(ProcessCatalogue::class);
|
||||||
|
foreach (array_column($lanes['waiting'], 'module') as $module) {
|
||||||
|
if (in_array($module, ['offer.binding', 'offer.acceptance'], true) && $context->plan->enabled($module)) {
|
||||||
|
$this->assertNotSame([], $runner->unmetHardDependencies($catalogue->module($module), $context), $module.' waits in the plan as shown');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (['hold', 'guest.data_request'] as $module) {
|
||||||
|
$this->assertSame([], $runner->unmetHardDependencies($catalogue->module($module), $context), $module.' does not wait');
|
||||||
|
}
|
||||||
|
$waitingFor = collect($lanes['waiting'])->firstWhere('module', 'offer.binding')['after'];
|
||||||
|
$this->assertContains('Angaben des Gastes', $waitingFor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $draft
|
||||||
|
*/
|
||||||
|
private function configure(Channel $channel, array $draft, IntakeKind $intake = IntakeKind::Inquiry): void
|
||||||
|
{
|
||||||
|
app(ConfigureChannelProcess::class)->handle($channel, $intake, $draft, acknowledgeConflicts: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function request(Channel $channel, bool $viaPortal, string $arrival, string $street = 'Weg 1'): Booking
|
||||||
|
{
|
||||||
|
$arrival = CarbonImmutable::parse($arrival);
|
||||||
|
if ($viaPortal) {
|
||||||
|
return app(TakeOverPortalInquiry::class)->handle($channel, $arrival, $arrival->addDays(3), 'ANF-'.$arrival->format('md'))->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
return app(CreateReservation::class)->handle($this->property->fresh(), new StayRequest($arrival, $arrival->addDays(3), 2), ['first_name' => 'Gesa', 'last_name' => 'Gast', 'email' => 'gesa@example.org', 'street' => $street, 'postal_code' => '10115', 'city' => 'Berlin', 'country' => 'DE'])->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function takeOver(Channel $channel, string $reference, string $arrival): Booking
|
||||||
|
{
|
||||||
|
$arrival = CarbonImmutable::parse($arrival);
|
||||||
|
|
||||||
|
return app(TakeOverExternalBooking::class)->handle($this->property, $channel, $arrival, $arrival->addDays(7), ['portal_reference' => $reference]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function portal(): Channel
|
||||||
|
{
|
||||||
|
return Channel::factory()->for($this->property)->create(['name' => 'Anfrageportal', 'booking_model' => 'inquiry', 'import_enabled' => false, 'settings' => ['import_url' => 'https://anfrage.example/a.ics', 'portal_profile' => 'generic']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function bookingPortal(): Channel
|
||||||
|
{
|
||||||
|
return Channel::factory()->for($this->property)->create(['name' => 'Buchungsportal', 'booking_model' => 'portal_booking', 'import_enabled' => false, 'settings' => ['import_url' => 'https://buchung.example/a.ics', 'portal_profile' => 'generic']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -119,7 +119,7 @@ public function test_loyalty_cannot_reach_a_real_case_and_leaves_the_other_model
|
|||||||
$catalogue = app(ProcessCatalogue::class);
|
$catalogue = app(ProcessCatalogue::class);
|
||||||
$using = array_keys(array_filter($catalogue->models(), fn ($model): bool => collect($model->variants())->contains(fn ($variant): bool => in_array('pricing.loyalty_discount', $model->modules($variant->key), true))));
|
$using = array_keys(array_filter($catalogue->models(), fn ($model): bool => collect($model->variants())->contains(fn ($variant): bool => in_array('pricing.loyalty_discount', $model->modules($variant->key), true))));
|
||||||
|
|
||||||
$this->assertSame(['a1.offer'], $using, 'only the A1 offer model has the variant');
|
$this->assertSame(['a1.offer', 'inquiry.request'], $using, 'only the A1 offer model and the request base process have the variant');
|
||||||
$this->assertSame([], $catalogue->problems());
|
$this->assertSame([], $catalogue->problems());
|
||||||
foreach ($catalogue->models() as $key => $model) {
|
foreach ($catalogue->models() as $key => $model) {
|
||||||
$this->assertNotContains('guest.loyalty_status', $model->modules('standard'), "{$key}: standard course unchanged");
|
$this->assertNotContains('guest.loyalty_status', $model->modules('standard'), "{$key}: standard course unchanged");
|
||||||
|
|||||||
@@ -0,0 +1,540 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Process;
|
||||||
|
|
||||||
|
use App\Actions\ConfigureChannelProcess;
|
||||||
|
use App\Actions\SendBookingReminders;
|
||||||
|
use App\Actions\TakeOverExternalBooking;
|
||||||
|
use App\Enums\ActivityState;
|
||||||
|
use App\Enums\CaseType;
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Enums\ProcessSetting;
|
||||||
|
use App\Enums\Responsibility;
|
||||||
|
use App\Models\Booking;
|
||||||
|
use App\Models\BookingTask;
|
||||||
|
use App\Models\Channel;
|
||||||
|
use App\Models\Property;
|
||||||
|
use App\Process\CaseActivities;
|
||||||
|
use App\Process\ChannelProcessConfiguration;
|
||||||
|
use App\Process\Models\ExternalBookingModel;
|
||||||
|
use App\Process\Models\ProcessModel;
|
||||||
|
use App\Process\Models\Responsibilities;
|
||||||
|
use App\Process\Models\Step;
|
||||||
|
use App\Process\ProcessCatalogue;
|
||||||
|
use App\Process\ProcessPlan;
|
||||||
|
use App\Process\ProcessProfile;
|
||||||
|
use App\Process\Templates\FunctionTemplate;
|
||||||
|
use App\Process\Templates\OwnCollection;
|
||||||
|
use App\Process\Templates\TemplateArea;
|
||||||
|
use App\Process\Templates\TemplateComposer;
|
||||||
|
use App\Support\Content;
|
||||||
|
use App\Support\Settings;
|
||||||
|
use Carbon\CarbonImmutable;
|
||||||
|
use Database\Seeders\PropertySeeder;
|
||||||
|
use Database\Seeders\SiteSeeder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Mail\MailManager;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use PHPUnit\Framework\Attributes\Group;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Composition of function templates on the base process of externally binding bookings (docs/Prozessarchitektur/
|
||||||
|
* SCHABLONEN.md): the four combinations of collection and contract documentation, equivalence with the archetypes
|
||||||
|
* A3–A5, refusal of invalid combinations and versioning.
|
||||||
|
*/
|
||||||
|
#[Group('configurator')]
|
||||||
|
class TemplateCompositionTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private Property $property;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->travelTo(CarbonImmutable::parse('2026-10-23 18:00'));
|
||||||
|
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||||
|
$this->property = Property::sole();
|
||||||
|
Storage::fake('local');
|
||||||
|
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||||
|
config(['mail.default' => 'array']);
|
||||||
|
Mail::swap(new MailManager($this->app));
|
||||||
|
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'test@example.org']);
|
||||||
|
Http::preventStrayRequests();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array{0: string, 1: string, 2: CaseType, 3: bool}> collection, documents, classification, whether the payout check is part of the course
|
||||||
|
*/
|
||||||
|
public static function combinations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'own collection + own documents (A3)' => ['collection.own', 'contract_docs.own', CaseType::A3, false],
|
||||||
|
'portal collection + own documents (A4)' => ['collection.portal', 'contract_docs.own', CaseType::A4, true],
|
||||||
|
'portal collection + external documents (A5)' => ['collection.portal', 'contract_docs.external', CaseType::A5, true],
|
||||||
|
'own collection + external documents (no archetype)' => ['collection.own', 'contract_docs.external', CaseType::A3, false],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_catalogue_with_templates_is_consistent(): void
|
||||||
|
{
|
||||||
|
$this->assertSame([], app(ProcessCatalogue::class)->problems());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DataProvider('combinations')]
|
||||||
|
public function test_every_combination_is_composed_into_a_valid_versioned_plan(string $collection, string $documents, CaseType $type, bool $payout): void
|
||||||
|
{
|
||||||
|
$model = app(ProcessCatalogue::class)->model('external.booking');
|
||||||
|
$chosen = ['collection' => $collection, 'contract_documents' => $documents];
|
||||||
|
|
||||||
|
$this->assertSame([], app(TemplateComposer::class)->problems($model, $chosen));
|
||||||
|
|
||||||
|
$channel = $this->configured($chosen);
|
||||||
|
$booking = $this->takeOver($channel, 'COMBO');
|
||||||
|
$plan = ProcessPlan::of($booking);
|
||||||
|
|
||||||
|
$this->assertSame(['external.booking', 1], [$plan->model, $plan->modelVersion]);
|
||||||
|
$this->assertEquals(['collection' => $collection.'@1', 'contract_documents' => $documents.'@1', 'guest_communication' => 'guest_comm.own@1'], $plan->templates);
|
||||||
|
$this->assertSame($payout, array_key_exists('portal.payout', $plan->modules));
|
||||||
|
$this->assertArrayHasKey('payments.monitor', $plan->modules);
|
||||||
|
$this->assertArrayHasKey('documents.send', $plan->modules);
|
||||||
|
$this->assertSame($type, $booking->case_type, 'the case type is only a classification');
|
||||||
|
$this->assertNull($plan->notice);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_fourth_combination_collects_ourselves_while_the_portal_provides_the_documents(): void
|
||||||
|
{
|
||||||
|
$booking = $this->takeOver($this->configured(['collection' => 'collection.own', 'contract_documents' => 'contract_docs.external']), 'VIER');
|
||||||
|
$profile = $booking->process();
|
||||||
|
|
||||||
|
$this->assertSame([Responsibility::Landlord, Responsibility::Portal], [$profile->payments(), $profile->documents()]);
|
||||||
|
$this->assertSame(ProcessProfile::TEMPLATE, $profile->source(ProcessSetting::Payments));
|
||||||
|
$this->assertSame(ProcessProfile::TEMPLATE, $profile->source(ProcessSetting::Documents));
|
||||||
|
|
||||||
|
$activities = collect(CaseActivities::for($booking))->keyBy('key');
|
||||||
|
$this->assertNotSame(ActivityState::External, $activities['payment']->state, 'we monitor the guest payments ourselves');
|
||||||
|
$this->assertStringNotContainsString('Portal', $activities['payment']->label, 'no portal collection shown');
|
||||||
|
$this->assertNull($activities['payout'] ?? null, 'no payout check without portal collection');
|
||||||
|
$this->assertNull($booking->fresh()->confirmation_sent_at, 'the portal provides the contract documents: we send none');
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DataProvider('archetypes')]
|
||||||
|
public function test_a_combination_behaves_like_the_archetype_it_reproduces(string $legacy, string $collection, string $documents): void
|
||||||
|
{
|
||||||
|
$old = $this->takeOver($this->legacyChannel($legacy), 'ALT', '2027-07-10');
|
||||||
|
$new = $this->takeOver($this->configured(['collection' => $collection, 'contract_documents' => $documents]), 'NEU', '2027-08-10');
|
||||||
|
|
||||||
|
$oldValues = $old->process()->values;
|
||||||
|
$newValues = $new->process()->values;
|
||||||
|
unset($oldValues['contract_template_id'], $newValues['contract_template_id']);
|
||||||
|
$this->assertEquals($oldValues, $newValues, 'identical effective configuration');
|
||||||
|
$this->assertSame($old->case_type, $new->case_type);
|
||||||
|
|
||||||
|
$summarise = fn (Booking $booking): array => collect(CaseActivities::for($booking))->map(fn ($activity): array => [$activity->key, $activity->label, $activity->state->value])->all();
|
||||||
|
$this->assertSame($summarise($old), $summarise($new), 'identical activities and states');
|
||||||
|
|
||||||
|
$oldModules = array_keys(ProcessPlan::of($old)->modules);
|
||||||
|
$newModules = array_keys(ProcessPlan::of($new)->modules);
|
||||||
|
$this->assertSame(array_values(array_diff($oldModules, $legacy === 'a3.portal_booking' ? ['portal.payout'] : [])), $newModules, 'the course is the archetype course (the payout check only where the portal collects)');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array{0: string, 1: string, 2: string}>
|
||||||
|
*/
|
||||||
|
public static function archetypes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'A3' => ['a3.portal_booking', 'collection.own', 'contract_docs.own'],
|
||||||
|
'A4' => ['a4.portal_booking', 'collection.portal', 'contract_docs.own'],
|
||||||
|
'A5' => ['a5.portal_booking', 'collection.portal', 'contract_docs.external'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DataProvider('combinations')]
|
||||||
|
public function test_payment_requests_arise_from_own_collection_only_and_never_twice(string $collection, string $documents, CaseType $type, bool $payout): void
|
||||||
|
{
|
||||||
|
$channel = $this->configured(['collection' => $collection, 'contract_documents' => $documents]);
|
||||||
|
$booking = app(TakeOverExternalBooking::class)->handle($this->property, $channel, CarbonImmutable::parse('2027-07-10'), CarbonImmutable::parse('2027-07-17'), [
|
||||||
|
'portal_reference' => 'ZAHL', 'portal_total' => 98000, 'guests' => 2,
|
||||||
|
'guest' => ['first_name' => 'Pia', 'last_name' => 'Portal', 'email' => 'pia@example.org', 'street' => 'Weg 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'],
|
||||||
|
]);
|
||||||
|
$this->travelTo(CarbonImmutable::parse('2027-06-25 10:00'));
|
||||||
|
|
||||||
|
app(SendBookingReminders::class)->handle();
|
||||||
|
$first = BookingTask::query()->where('booking_id', $booking->id)->count();
|
||||||
|
app(SendBookingReminders::class)->handle();
|
||||||
|
$second = BookingTask::query()->where('booking_id', $booking->id)->count();
|
||||||
|
|
||||||
|
$this->assertSame($first, $second, 'repeated runs create no second request');
|
||||||
|
$collection === 'collection.own' ? $this->assertGreaterThan(0, $first, 'we collect: payment tasks exist') : $this->assertSame(0, $first, 'the portal collects: no own payment request towards the guest');
|
||||||
|
$this->assertNull($booking->fresh()->confirmation_sent_at, 'a portal event or reminder never creates or changes our contract');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_archetypes_are_presets_of_the_base_process(): void
|
||||||
|
{
|
||||||
|
$catalogue = app(ProcessCatalogue::class);
|
||||||
|
foreach (['a3.portal_booking', 'a4.portal_booking', 'a5.portal_booking'] as $key) {
|
||||||
|
$model = $catalogue->model($key);
|
||||||
|
$this->assertTrue($model::isLegacy());
|
||||||
|
$this->assertSame([], app(TemplateComposer::class)->problems($catalogue->model('external.booking'), $model::presetTemplates()));
|
||||||
|
}
|
||||||
|
$this->assertFalse(ExternalBookingModel::isLegacy());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_unsuitable_combinations_are_refused_with_a_reason(): void
|
||||||
|
{
|
||||||
|
$composer = app(TemplateComposer::class);
|
||||||
|
$model = app(ProcessCatalogue::class)->model('external.booking');
|
||||||
|
|
||||||
|
$this->assertStringContainsString('gehört zu', implode(' ', $composer->problems($model, ['collection' => 'contract_docs.own'])), 'a template only fits the slot of its area');
|
||||||
|
$this->assertStringContainsString('gibt es nicht', implode(' ', $composer->problems($model, ['collection' => 'collection.gibt-es-nicht'])));
|
||||||
|
$this->assertStringContainsString('keinen Platz', implode(' ', $composer->problems($model, ['gastronomie' => 'collection.own'])));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_double_effects_missing_prerequisites_contradictions_and_exclusions_are_detected(): void
|
||||||
|
{
|
||||||
|
$this->register(DoubleCollectionTemplate::class, NeedyDocumentsTemplate::class, ContradictingDocumentsTemplate::class, ExcludingDocumentsTemplate::class, DuplicateModuleTemplate::class);
|
||||||
|
$composer = app(TemplateComposer::class);
|
||||||
|
$model = app(ProcessCatalogue::class)->model('external.booking');
|
||||||
|
$problems = fn (array $chosen): string => implode(' | ', $composer->problems($model, $chosen));
|
||||||
|
|
||||||
|
$this->assertStringContainsString('doppelt erzeugt', $problems(['contract_documents' => DoubleCollectionTemplate::key()]), 'the collection result may come from one template only');
|
||||||
|
$this->assertStringContainsString('voraus', $problems(['contract_documents' => NeedyDocumentsTemplate::key()]));
|
||||||
|
$this->assertStringContainsString('Widersprüchliche Verantwortlichkeit', $problems(['contract_documents' => ContradictingDocumentsTemplate::key()]));
|
||||||
|
$this->assertStringContainsString('nicht kombinieren', $problems(['collection' => 'collection.portal', 'contract_documents' => ExcludingDocumentsTemplate::key()]));
|
||||||
|
$this->assertSame('', $problems(['collection' => 'collection.own', 'contract_documents' => ExcludingDocumentsTemplate::key()]), 'the exclusion only concerns portal collection');
|
||||||
|
$this->assertStringContainsString('mehrfach', $problems(['collection' => DuplicateModuleTemplate::key()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_hard_dependency_on_a_module_the_templates_would_have_supplied_is_unmet(): void
|
||||||
|
{
|
||||||
|
config(['process.models' => [...config('process.models'), 'test.model' => [1 => ModelWithDependentStep::class]]]);
|
||||||
|
$this->register(SuppliesStayTemplate::class);
|
||||||
|
$model = app(ProcessCatalogue::class)->model('test.model');
|
||||||
|
|
||||||
|
$this->assertStringContainsString('braucht zwingend', implode(' ', app(TemplateComposer::class)->problems($model, ['collection' => 'collection.own'])));
|
||||||
|
$this->assertSame([], app(TemplateComposer::class)->problems($model, ['collection' => SuppliesStayTemplate::key()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_new_template_version_applies_to_new_cases_only_and_old_plans_stay_readable(): void
|
||||||
|
{
|
||||||
|
$channel = $this->configured(['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own']);
|
||||||
|
$first = $this->takeOver($channel, 'V1');
|
||||||
|
|
||||||
|
config(['process.templates' => [...config('process.templates'), 'collection.own' => [1 => OwnCollection::class, 2 => OwnCollectionVersion2::class]]]);
|
||||||
|
$second = $this->takeOver($channel->fresh(), 'V2', '2027-08-10');
|
||||||
|
|
||||||
|
$this->assertSame('collection.own@1', ProcessPlan::of($first->fresh())->templates['collection']);
|
||||||
|
$this->assertSame('collection.own@2', ProcessPlan::of($second)->templates['collection']);
|
||||||
|
$this->assertSame($first->profile['plan'], $first->fresh()->profile['plan'], 'the running case keeps its frozen plan');
|
||||||
|
|
||||||
|
$legacy = ProcessPlan::fromArray(['model' => 'a3.portal_booking', 'model_version' => 2, 'modules' => ['intake.record' => 1]]);
|
||||||
|
$this->assertSame([], $legacy->templates, 'plans frozen before the composition have no templates');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_unsaved_choice_shows_in_the_preview_with_the_template_of_each_step(): void
|
||||||
|
{
|
||||||
|
$channel = $this->channel('Test Portal');
|
||||||
|
$rows = collect(app(ChannelProcessConfiguration::class)->preview($channel, IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.external']]));
|
||||||
|
|
||||||
|
$this->assertSame('Portal-Inkasso', $rows->firstWhere('module', 'portal.payout')['template']);
|
||||||
|
$this->assertSame('Externe Vertragsunterlagen', $rows->firstWhere('module', 'documents.send')['template']);
|
||||||
|
$this->assertNull($rows->firstWhere('module', 'stay')['template']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_base_process_cannot_be_saved_with_templates_the_portal_cannot_support(): void
|
||||||
|
{
|
||||||
|
$channel = $this->channel('FeWo-direkt Test');
|
||||||
|
$configure = app(ConfigureChannelProcess::class);
|
||||||
|
$draft = ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own'], 'capabilities' => ['collects_payment' => '1', 'provides_contract_documents' => '0']];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$configure->handle($channel, IntakeKind::Booking, $draft);
|
||||||
|
$this->fail('own collection although the portal collects');
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
$this->assertStringContainsString('Zieht das Portal das Geld', implode(' ', $exception->errors()['process']));
|
||||||
|
}
|
||||||
|
$this->assertNull(($channel->fresh()->process_overrides ?? [])['booking'] ?? null, 'nothing saved');
|
||||||
|
|
||||||
|
$configure->handle($channel, IntakeKind::Booking, [...$draft, 'templates' => ['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.own']]);
|
||||||
|
$this->assertEquals(['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.own', 'guest_communication' => 'guest_comm.own'], $channel->fresh()->process_overrides['booking']['templates']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $templates
|
||||||
|
*/
|
||||||
|
private function configured(array $templates): Channel
|
||||||
|
{
|
||||||
|
$channel = $this->channel('Vergleichsportal', suffix: md5(json_encode($templates)));
|
||||||
|
app(ConfigureChannelProcess::class)->handle($channel, IntakeKind::Booking, ['model' => 'external.booking', 'templates' => $templates]);
|
||||||
|
|
||||||
|
return $channel->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param class-string<FunctionTemplate> ...$classes
|
||||||
|
*/
|
||||||
|
private function register(string ...$classes): void
|
||||||
|
{
|
||||||
|
$templates = config('process.templates');
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
$templates[$class::key()] = [1 => $class];
|
||||||
|
}
|
||||||
|
config(['process.templates' => $templates]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function legacyChannel(string $model): Channel
|
||||||
|
{
|
||||||
|
$channel = $this->channel('Vergleichsportal', suffix: 'alt');
|
||||||
|
app(ConfigureChannelProcess::class)->handle($channel, IntakeKind::Booking, ['model' => $model]);
|
||||||
|
|
||||||
|
return $channel->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function takeOver(Channel $channel, string $reference, string $arrival = '2027-07-10'): Booking
|
||||||
|
{
|
||||||
|
$arrival = CarbonImmutable::parse($arrival);
|
||||||
|
|
||||||
|
return app(TakeOverExternalBooking::class)->handle($this->property, $channel, $arrival, $arrival->addDays(7), ['portal_reference' => $reference]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function channel(string $name, string $suffix = ''): Channel
|
||||||
|
{
|
||||||
|
return Channel::factory()->for($this->property)->create(['name' => $name, 'booking_model' => 'portal_booking', 'import_enabled' => false, 'settings' => ['import_url' => 'https://portal.example/'.md5($name.$suffix).'.ics', 'portal_profile' => 'generic']]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test doubles: templates and a model that exist only to provoke the composition checks. */
|
||||||
|
abstract class TestTemplate extends FunctionTemplate
|
||||||
|
{
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'test.'.strtolower(substr(strrchr(static::class, '\\'), 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function purpose(): string
|
||||||
|
{
|
||||||
|
return 'Testschablone';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return static::key();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class DoubleCollectionTemplate extends TestTemplate
|
||||||
|
{
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::ContractDocuments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['documents.send'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function provides(): array
|
||||||
|
{
|
||||||
|
return [TemplateArea::ContractDocuments->result(), TemplateArea::Collection->result()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class NeedyDocumentsTemplate extends TestTemplate
|
||||||
|
{
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::ContractDocuments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['documents.send'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function requires(): array
|
||||||
|
{
|
||||||
|
return ['signature.qualified'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class ContradictingDocumentsTemplate extends TestTemplate
|
||||||
|
{
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::ContractDocuments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['documents.send'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fixes(): array
|
||||||
|
{
|
||||||
|
return ['documents' => 'landlord', 'payments' => 'portal'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class ExcludingDocumentsTemplate extends TestTemplate
|
||||||
|
{
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::ContractDocuments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['documents.send'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function incompatibleWith(): array
|
||||||
|
{
|
||||||
|
return ['collection.portal' => 'Beide würden die Auszahlung dokumentieren.'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class DuplicateModuleTemplate extends TestTemplate
|
||||||
|
{
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::Collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['payments.monitor', 'documents.send'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class SuppliesStayTemplate extends TestTemplate
|
||||||
|
{
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::Collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['stay'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class OwnCollectionVersion2 extends TestTemplate
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'collection.own';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function area(): TemplateArea
|
||||||
|
{
|
||||||
|
return TemplateArea::Collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function modules(): array
|
||||||
|
{
|
||||||
|
return ['payments.monitor'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibility(): Responsibility
|
||||||
|
{
|
||||||
|
return Responsibility::Landlord;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A model whose review step needs the stay, which a collection template may supply. */
|
||||||
|
final class ModelWithDependentStep extends ProcessModel
|
||||||
|
{
|
||||||
|
public static function key(): string
|
||||||
|
{
|
||||||
|
return 'test.model';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function version(): int
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return 'Testmodell';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function description(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function caseTypes(): array
|
||||||
|
{
|
||||||
|
return [CaseType::A3];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function intakes(): array
|
||||||
|
{
|
||||||
|
return [IntakeKind::Booking];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function responsibilities(): Responsibilities
|
||||||
|
{
|
||||||
|
return Responsibilities::of(fixed: []);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function defaultTemplates(): array
|
||||||
|
{
|
||||||
|
return ['collection' => 'collection.own'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function steps(): array
|
||||||
|
{
|
||||||
|
return [Step::module('intake.record'), Step::slot(TemplateArea::Collection), Step::module('review.request')];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,237 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Process;
|
||||||
|
|
||||||
|
use App\Actions\ConfigureChannelProcess;
|
||||||
|
use App\Actions\TakeOverExternalBooking;
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Enums\ProcessSetting;
|
||||||
|
use App\Filament\Resources\Channels\Pages\ChannelProcess;
|
||||||
|
use App\Models\Booking;
|
||||||
|
use App\Models\Channel;
|
||||||
|
use App\Models\Property;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Process\ChannelProcessConfiguration;
|
||||||
|
use App\Process\ConfigurationImpact;
|
||||||
|
use App\Process\ProcessCatalogue;
|
||||||
|
use App\Process\ProcessPlan;
|
||||||
|
use App\Process\ProcessProfile;
|
||||||
|
use App\Process\ProcessSettings;
|
||||||
|
use App\Support\Content;
|
||||||
|
use App\Support\Settings;
|
||||||
|
use Carbon\CarbonImmutable;
|
||||||
|
use Database\Seeders\PropertySeeder;
|
||||||
|
use Database\Seeders\SiteSeeder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Mail\MailManager;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use PHPUnit\Framework\Attributes\Group;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The channel configurator on the composition: the business decisions come first, the single steps stay reachable and
|
||||||
|
* configurable, nothing changes silently, running cases keep their plan.
|
||||||
|
*/
|
||||||
|
#[Group('configurator')]
|
||||||
|
class TemplateConfiguratorTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private Property $property;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->travelTo(CarbonImmutable::parse('2026-10-23 18:00'));
|
||||||
|
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||||
|
$this->property = Property::sole();
|
||||||
|
Storage::fake('local');
|
||||||
|
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||||
|
config(['mail.default' => 'array']);
|
||||||
|
Mail::swap(new MailManager($this->app));
|
||||||
|
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'test@example.org']);
|
||||||
|
Http::preventStrayRequests();
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_page_shows_the_business_decisions_first_and_keeps_the_steps_reachable(): void
|
||||||
|
{
|
||||||
|
$ds = $this->channel('Destination Solution', []);
|
||||||
|
|
||||||
|
Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])
|
||||||
|
->call('chooseModel', 'external.booking')
|
||||||
|
->assertSee('Der Geschäftsprozess')
|
||||||
|
->call('selectBlock', 'finance')
|
||||||
|
->assertSee('Wer zieht das Geld des Gastes ein?')
|
||||||
|
->assertSee('Eigenes Inkasso')
|
||||||
|
->assertSee('Portal-Inkasso')
|
||||||
|
->assertSee('Mehrstufige Mahnungen', escape: false)
|
||||||
|
->assertSee('Zahlungen des Gastes')
|
||||||
|
->call('selectBlock', 'documents')
|
||||||
|
->assertSee('Eigene Vertragsdokumentation')
|
||||||
|
->assertSee('Externe Vertragsunterlagen');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_archetype_moves_to_the_base_process_with_the_same_combination_and_saves(): void
|
||||||
|
{
|
||||||
|
$fewo = $this->channel('FeWo-direkt', [], 'mixed');
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $fewo->getRouteKey()])->set('intake', 'booking');
|
||||||
|
|
||||||
|
$page->assertSee('Auf Schablonen umstellen')->call('applyPreset', 'a4.portal_booking');
|
||||||
|
$this->assertSame(['external.booking', ['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.own']], [$page->get('drafts')['booking']['model'], $page->get('drafts')['booking']['templates']]);
|
||||||
|
$this->assertSame([], $page->instance()->problems());
|
||||||
|
|
||||||
|
$page->call('save')->assertNotified('Ablauf gespeichert');
|
||||||
|
$this->assertSame('external.booking', $fewo->fresh()->process_overrides['booking']['model']);
|
||||||
|
$this->assertEquals(['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.own', 'guest_communication' => 'guest_comm.own'], $fewo->fresh()->process_overrides['booking']['templates']);
|
||||||
|
|
||||||
|
$booking = $this->takeOver($fewo->fresh(), 'FD-1');
|
||||||
|
$this->assertEquals(['collection' => 'collection.portal@1', 'contract_documents' => 'contract_docs.own@1', 'guest_communication' => 'guest_comm.own@1'], ProcessPlan::of($booking)->templates);
|
||||||
|
$this->assertSame('A4', strtoupper($booking->case_type->value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_template_the_portal_cannot_support_cannot_be_chosen_and_says_why(): void
|
||||||
|
{
|
||||||
|
$fewo = $this->channel('FeWo-direkt', [], 'mixed');
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $fewo->getRouteKey()])->set('intake', 'booking')->call('applyPreset', 'a4.portal_booking');
|
||||||
|
|
||||||
|
$page->call('chooseTemplate', 'collection', 'collection.own');
|
||||||
|
$this->assertSame('collection.portal', $page->get('drafts')['booking']['templates']['collection'], 'refused: FeWo-direkt collects the money');
|
||||||
|
$page->call('selectBlock', 'finance')->assertSee('Passt gerade nicht')->assertSee('Zieht das Portal das Geld des Gastes ein?');
|
||||||
|
|
||||||
|
// The landlord corrects the capability first: now the template fits.
|
||||||
|
$page->set('capabilityDraft.collects_payment', '0')->call('chooseTemplate', 'collection', 'collection.own');
|
||||||
|
$this->assertSame('collection.own', $page->get('drafts')['booking']['templates']['collection']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_unconfirmed_capabilities_are_flagged_and_never_taken_as_proven(): void
|
||||||
|
{
|
||||||
|
$generic = $this->channel('Irgendein Portal', [], 'portal_booking');
|
||||||
|
$options = app(ChannelProcessConfiguration::class)->templateOptions($generic, app(ProcessCatalogue::class)->model('external.booking'));
|
||||||
|
|
||||||
|
$this->assertTrue($options['collection']['collection.own']['admissible'], 'unknown blocks nothing');
|
||||||
|
$this->assertSame(['collects_payment'], $options['collection']['collection.own']['unconfirmed']);
|
||||||
|
$this->assertNotSame([], $options['contract_documents']['contract_docs.external']['hints']);
|
||||||
|
|
||||||
|
$fewo = $this->channel('FeWo-direkt Profil', [], 'mixed');
|
||||||
|
$suggested = app(ChannelProcessConfiguration::class)->templateOptions($fewo, app(ProcessCatalogue::class)->model('external.booking'));
|
||||||
|
$this->assertContains('collects_payment', $suggested['collection']['collection.portal']['unconfirmed'], 'a suggestion of the channel profile is not a confirmation');
|
||||||
|
$this->assertStringContainsString('nicht als bestätigt', implode(' ', $suggested['collection']['collection.portal']['hints']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The A4 → A3 regression of the archetypes, now as a switch of the collection template */
|
||||||
|
public function test_switching_the_collection_template_shows_every_consequence_and_needs_the_confirmation(): void
|
||||||
|
{
|
||||||
|
$ds = $this->channel('Destination Solution', ['booking' => ['payments' => 'portal', 'guest_messages' => 'portal', 'contract_delivery' => 'manual', 'steps' => ['review.request' => ['on' => false]]]]);
|
||||||
|
$ds->update(['settings' => [...(array) $ds->settings, 'capabilities' => ['messages_guest' => ['value' => false, 'at' => now()->toIso8601String(), 'by' => 'Lars']]]]);
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])->set('intake', 'booking');
|
||||||
|
|
||||||
|
$page->set('capabilityDraft.collects_payment', '0')->call('chooseModel', 'external.booking')->call('chooseTemplate', 'collection', 'collection.own');
|
||||||
|
$conflicts = collect($page->instance()->conflicts())->map(fn (array $conflict): string => $conflict['setting']->value)->all();
|
||||||
|
$this->assertEqualsCanonicalizing(['payments', 'guest_messages'], $conflicts, 'the stale collection and the stale portal communication are conflicts, not silent changes');
|
||||||
|
$page->assertSee('Bisherige Einstellungen widersprechen');
|
||||||
|
|
||||||
|
$page->call('save')->assertNotified('Nicht gespeichert');
|
||||||
|
$this->assertSame('portal', $ds->fresh()->process_overrides['booking']['payments'], 'nothing changed without the confirmation');
|
||||||
|
|
||||||
|
$page->set('acknowledge', true)->call('save')->assertNotified('Ablauf gespeichert');
|
||||||
|
$saved = $ds->fresh()->process_overrides['booking'];
|
||||||
|
$this->assertSame('external.booking', $saved['model']);
|
||||||
|
$this->assertArrayNotHasKey('payments', $saved);
|
||||||
|
$this->assertArrayNotHasKey('guest_messages', $saved);
|
||||||
|
$this->assertSame('manual', $saved['contract_delivery'], 'parameters of the kept modules survive');
|
||||||
|
$this->assertSame(['review.request' => ['on' => false]], $saved['steps'], 'so does a switched-off optional step');
|
||||||
|
$this->assertStringContainsString('Bisher eingestellt', $ds->fresh()->settings['process_history'][0]['removed_settings'][0]);
|
||||||
|
$this->assertEquals(['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own', 'guest_communication' => 'guest_comm.own'], $saved['templates']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_impact_of_a_template_change_names_modules_responsibility_and_open_ends(): void
|
||||||
|
{
|
||||||
|
$fewo = $this->channel('FeWo-direkt', ['booking' => ['steps' => []]], 'mixed');
|
||||||
|
app(ConfigureChannelProcess::class)->handle($fewo, IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.own']]);
|
||||||
|
|
||||||
|
$impact = app(ConfigurationImpact::class)->ofTemplates($fewo->fresh(), IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.external']]);
|
||||||
|
|
||||||
|
$impact = collect($impact)->keyBy('area');
|
||||||
|
$this->assertEqualsCanonicalizing(['Finanzabwicklung (Inkasso)', 'Vertragsdokumentation'], $impact->keys()->all());
|
||||||
|
$finance = $impact['Finanzabwicklung (Inkasso)'];
|
||||||
|
$documents = $impact['Vertragsdokumentation'];
|
||||||
|
$this->assertSame(['Portal-Inkasso', 'Eigenes Inkasso'], [$finance['from'], $finance['to']]);
|
||||||
|
$this->assertSame(['Auszahlung des Portals'], $finance['removed']);
|
||||||
|
$this->assertSame(['Zahlungen des Gastes'], $finance['kept']);
|
||||||
|
$this->assertSame(['from' => 'Das Portal', 'to' => 'Wir'], $finance['responsibility']);
|
||||||
|
$this->assertContains('Mehrstufige Mahnungen (rechtliche Ausgestaltung offen)', $finance['extensions']);
|
||||||
|
$this->assertSame(['from' => 'Wir', 'to' => 'Das Portal'], $documents['responsibility']);
|
||||||
|
$this->assertSame([], app(ConfigurationImpact::class)->ofTemplates($fewo->fresh(), IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.own']]), 'no change, no impact');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_modules_of_a_template_stay_individually_configurable_and_the_inheritance_holds(): void
|
||||||
|
{
|
||||||
|
Settings::tenant()->update(['process_defaults' => ['contract_delivery' => 'manual']]);
|
||||||
|
$ds = $this->channel('Destination Solution', []);
|
||||||
|
app(ConfigureChannelProcess::class)->handle($ds, IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own']]);
|
||||||
|
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $ds->fresh()->getRouteKey()])->set('intake', 'booking');
|
||||||
|
$documents = collect($page->instance()->steps())->firstWhere('module', 'documents.send');
|
||||||
|
$this->assertSame('Eigene Vertragsdokumentation', $documents['template']);
|
||||||
|
$this->assertContains('contract_delivery', array_column($documents['parameters'], 'key'), 'the module of the template has its own parameters');
|
||||||
|
$this->assertNotNull($documents['mode_setting'], 'and its own mode');
|
||||||
|
$this->assertSame('manual', app(ProcessSettings::class)->resolve($this->property, $ds->fresh(), IntakeKind::Booking)->value(ProcessSetting::ContractDelivery));
|
||||||
|
$this->assertSame(ProcessProfile::TENANT, app(ProcessSettings::class)->resolve($this->property, $ds->fresh(), IntakeKind::Booking)->source(ProcessSetting::ContractDelivery));
|
||||||
|
|
||||||
|
$page->set('drafts.booking.settings.contract_delivery', 'automatic')->set('drafts.booking.settings.processing', 'approval')->call('save')->assertNotified('Ablauf gespeichert');
|
||||||
|
$profile = app(ProcessSettings::class)->resolve($this->property, $ds->fresh(), IntakeKind::Booking);
|
||||||
|
$this->assertSame(['automatic', ProcessProfile::CHANNEL], [$profile->value(ProcessSetting::ContractDelivery), $profile->source(ProcessSetting::ContractDelivery)]);
|
||||||
|
$this->assertSame(ProcessProfile::TEMPLATE, $profile->source(ProcessSetting::Payments));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_template_does_not_override_a_parameter_set_by_hand_and_a_contradicting_responsibility_is_refused(): void
|
||||||
|
{
|
||||||
|
$ds = $this->channel('Destination Solution', []);
|
||||||
|
$configuration = app(ChannelProcessConfiguration::class);
|
||||||
|
|
||||||
|
$problems = $configuration->problems($ds, IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own'], 'settings' => ['payments' => 'portal']]);
|
||||||
|
$this->assertNotSame([], $problems, 'a responsibility set by hand may not contradict the template');
|
||||||
|
$this->assertStringContainsString('widerspricht der Schablone', implode(' ', $problems));
|
||||||
|
$this->assertSame([], $configuration->problems($ds, IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own'], 'settings' => ['payments' => 'landlord', 'contract_delivery' => 'manual']]));
|
||||||
|
|
||||||
|
$this->expectException(ValidationException::class);
|
||||||
|
app(ConfigureChannelProcess::class)->handle($ds, IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own'], 'settings' => ['payments' => 'portal']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_changing_the_templates_leaves_running_cases_and_their_plans_untouched(): void
|
||||||
|
{
|
||||||
|
$ds = $this->channel('Destination Solution', []);
|
||||||
|
app(ConfigureChannelProcess::class)->handle($ds, IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.own']]);
|
||||||
|
$running = $this->takeOver($ds->fresh(), 'DS-ALT');
|
||||||
|
$frozen = $running->fresh()->profile;
|
||||||
|
|
||||||
|
app(ConfigureChannelProcess::class)->handle($ds->fresh(), IntakeKind::Booking, ['model' => 'external.booking', 'templates' => ['collection' => 'collection.portal', 'contract_documents' => 'contract_docs.external'], 'capabilities' => ['collects_payment' => '1', 'provides_contract_documents' => '1']]);
|
||||||
|
$new = $this->takeOver($ds->fresh(), 'DS-NEU', '2027-09-10');
|
||||||
|
|
||||||
|
$this->assertSame($frozen, $running->fresh()->profile, 'the running case keeps profile and plan');
|
||||||
|
$this->assertSame('collection.own@1', ProcessPlan::of($running->fresh())->templates['collection']);
|
||||||
|
$this->assertSame('collection.portal@1', ProcessPlan::of($new)->templates['collection']);
|
||||||
|
$this->assertSame(['landlord', 'portal'], [$running->fresh()->process()->payments()->value, $new->process()->payments()->value]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $overrides
|
||||||
|
*/
|
||||||
|
private function channel(string $name, array $overrides, string $model = 'portal_booking'): Channel
|
||||||
|
{
|
||||||
|
return Channel::factory()->for($this->property)->create(['name' => $name, 'booking_model' => $model, 'process_overrides' => $overrides, 'import_enabled' => false, 'settings' => ['import_url' => 'https://portal.example/'.md5($name).'.ics']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function takeOver(Channel $channel, string $reference, string $arrival = '2027-07-10'): Booking
|
||||||
|
{
|
||||||
|
$arrival = CarbonImmutable::parse($arrival);
|
||||||
|
|
||||||
|
return app(TakeOverExternalBooking::class)->handle($this->property, $channel, $arrival, $arrival->addDays(7), ['portal_reference' => $reference]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Process;
|
||||||
|
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Models\Booking;
|
||||||
|
use App\Models\BookingTask;
|
||||||
|
use App\Models\Channel;
|
||||||
|
use App\Models\Property;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Process\Tester\ProcessSandbox;
|
||||||
|
use App\Support\Content;
|
||||||
|
use App\Support\Settings;
|
||||||
|
use Carbon\CarbonImmutable;
|
||||||
|
use Database\Seeders\PropertySeeder;
|
||||||
|
use Database\Seeders\SiteSeeder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use PHPUnit\Framework\Attributes\Group;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acceptance of the template composition: the four combinations of collection and contract documentation are played
|
||||||
|
* through the isolated process tester with a synthetic externally binding booking. The report must show the templates
|
||||||
|
* used, which steps run independently of waiting ones and which evidence is missing – and the combinations must differ in
|
||||||
|
* exactly the way their templates promise.
|
||||||
|
*/
|
||||||
|
#[Group('sandbox')]
|
||||||
|
class TemplateProcessTesterTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private Property $property;
|
||||||
|
|
||||||
|
private User $user;
|
||||||
|
|
||||||
|
private Channel $portal;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->travelTo(CarbonImmutable::parse('2026-10-23 10:00'));
|
||||||
|
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||||
|
$this->property = Property::sole();
|
||||||
|
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||||
|
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'vermieter@example.org', 'process_defaults' => ['processing' => 'automatic']]);
|
||||||
|
$this->user = User::factory()->create();
|
||||||
|
ProcessTesterTest::template();
|
||||||
|
$this->portal = Channel::factory()->for($this->property)->create(['name' => 'Destination Solution', 'booking_model' => 'portal_booking', 'status' => 'setup', 'is_active' => false, 'import_enabled' => false, 'settings' => ['import_url' => 'https://ds.example/a.ics', 'email_senders' => 'ds.example', 'portal_profile' => 'generic']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array{0: string, 1: string}>
|
||||||
|
*/
|
||||||
|
public static function combinations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'eigenes Inkasso + eigene Vertragsdokumentation' => ['collection.own', 'contract_docs.own'],
|
||||||
|
'Portal-Inkasso + eigene Vertragsdokumentation' => ['collection.portal', 'contract_docs.own'],
|
||||||
|
'Portal-Inkasso + externe Vertragsunterlagen' => ['collection.portal', 'contract_docs.external'],
|
||||||
|
'eigenes Inkasso + externe Vertragsunterlagen' => ['collection.own', 'contract_docs.external'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DataProvider('combinations')]
|
||||||
|
public function test_every_combination_runs_in_the_tester_and_differs_as_its_templates_promise(string $collection, string $documents): void
|
||||||
|
{
|
||||||
|
$report = $this->play($collection, $documents);
|
||||||
|
|
||||||
|
$this->assertNull($report['aborted'] ?? null, json_encode($report));
|
||||||
|
$this->assertSame([], $report['violations']);
|
||||||
|
$this->assertSame(['external.booking', 1], [$report['plan']['model'], $report['plan']['version']]);
|
||||||
|
$this->assertEqualsCanonicalizing([$collection.'@1', $documents.'@1', 'guest_comm.own@1'], array_column($report['plan']['templates'], 'reference'), 'the report names the templates used');
|
||||||
|
foreach ($report['plan']['templates'] as $template) {
|
||||||
|
$this->assertNotEmpty($template['modules']);
|
||||||
|
foreach ($template['capabilities'] as $capability) {
|
||||||
|
$this->assertFalse($capability['confirmed'], 'a capability nobody confirmed is not shown as proven');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[$known, , $confirmed] = $report['timeline'];
|
||||||
|
$labels = fn (array $event): array => array_column($event['activities'], 'label');
|
||||||
|
$states = fn (array $event): array => array_column($event['activities'], 'state_key', 'label');
|
||||||
|
|
||||||
|
// Finance: exactly one of the two collections shows up.
|
||||||
|
if ($collection === 'collection.own') {
|
||||||
|
$this->assertContains('Anzahlung erhalten', $labels($known));
|
||||||
|
$this->assertNotContains('Auszahlung von Destination Solution auf unser Konto', $labels($known));
|
||||||
|
$this->assertEmpty(array_filter($labels($known), fn (string $label): bool => str_starts_with($label, 'Zahlung des Gastes an')), 'no portal collection');
|
||||||
|
$this->assertContains('Anzahlung erhalten', $known['waiting'], 'we wait for the guest payments: evidence is missing');
|
||||||
|
} else {
|
||||||
|
$this->assertNotContains('Anzahlung erhalten', $labels($known), 'no own payment request towards the guest');
|
||||||
|
$this->assertSame('external', $states($known)['Zahlung des Gastes an Destination Solution']);
|
||||||
|
$this->assertContains('Auszahlung von Destination Solution auf unser Konto', $known['waiting'], 'the payout evidence is missing');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Contract documentation: ours has to be checked and sent, the portal's is external. Only ours ever goes out as a contract.
|
||||||
|
if ($documents === 'contract_docs.own') {
|
||||||
|
$this->assertSame('waiting', $states($known)['Buchungsunterlagen prüfen und senden'], 'our documents wait for the portal confirmation');
|
||||||
|
$this->assertSame('open', $states($confirmed)['Buchungsunterlagen prüfen und senden'], 'then the landlord sends them (approval, not automatic)');
|
||||||
|
} else {
|
||||||
|
$this->assertSame('external', $states($known)['Buchungsunterlagen an den Gast']);
|
||||||
|
$this->assertNotContains('Buchungsunterlagen prüfen und senden', $labels($confirmed));
|
||||||
|
$this->assertEmpty(array_filter(array_column($confirmed['mails'], 'subject'), fn (string $subject): bool => str_contains($subject, 'Buchungsbestätigung') || str_contains($subject, 'Mietvertrag')), 'no contract from us');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Independent steps keep running while the confirmation, the documents and the payments wait.
|
||||||
|
$this->assertContains('Kontaktdaten des Gastes', $known['independent']);
|
||||||
|
$this->assertContains('Anreisedaten', $known['independent']);
|
||||||
|
$this->assertContains('Bestätigung des Portals abwarten', $confirmed['independent'], 'the confirmation ends while the payments still wait');
|
||||||
|
$this->assertContains('Buchungsinformation an den Gast (automatisch)', $confirmed['independent']);
|
||||||
|
|
||||||
|
$this->assertSame(0, Booking::query()->count(), 'nothing reached the real data');
|
||||||
|
$this->assertSame(0, BookingTask::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_tester_runs_the_fourth_combination_and_marks_it_as_such(): void
|
||||||
|
{
|
||||||
|
$report = $this->play('collection.own', 'contract_docs.external');
|
||||||
|
|
||||||
|
$this->assertSame('A3', $report['plan']['case_type'], 'classified by who collects – no archetype of its own');
|
||||||
|
$values = collect($report['plan']['configuration'])->keyBy('question');
|
||||||
|
$this->assertSame(['Wir', 'festgelegt durch die gewählte Funktionsschablone'], [$values['Wer kümmert sich um die Zahlungen des Gastes?']['value'] ?? null, $values['Wer kümmert sich um die Zahlungen des Gastes?']['source'] ?? null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function play(string $collection, string $documents): array
|
||||||
|
{
|
||||||
|
$draft = ['model' => 'external.booking', 'templates' => ['collection' => $collection, 'contract_documents' => $documents], 'settings' => ['await_portal_confirmation' => '1', 'booking_notice' => 'automatic']];
|
||||||
|
|
||||||
|
return app(ProcessSandbox::class)->run($this->portal, IntakeKind::Booking, $draft, 'portal_confirmation_wait', ['arrival' => '2026-11-14', 'nights' => 4, 'guests' => 2, 'confirmation' => 'late'], 6, $this->user)->report;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Process;
|
||||||
|
|
||||||
|
use App\Actions\ConfigureChannelProcess;
|
||||||
|
use App\Actions\TakeOverExternalBooking;
|
||||||
|
use App\Enums\IntakeKind;
|
||||||
|
use App\Enums\ProcessSetting;
|
||||||
|
use App\Filament\Resources\Channels\Pages\ChannelProcess;
|
||||||
|
use App\Models\Booking;
|
||||||
|
use App\Models\Channel;
|
||||||
|
use App\Models\Property;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Process\ProcessBlocks;
|
||||||
|
use App\Process\ProcessCatalogue;
|
||||||
|
use App\Process\ProcessPlan;
|
||||||
|
use App\Process\ProcessSettings;
|
||||||
|
use App\Support\Content;
|
||||||
|
use App\Support\Settings;
|
||||||
|
use Carbon\CarbonImmutable;
|
||||||
|
use Database\Seeders\PropertySeeder;
|
||||||
|
use Database\Seeders\SiteSeeder;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Mail\MailManager;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use PHPUnit\Framework\Attributes\Group;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The visual configurator: business blocks derived from the resolved plan, configuration inside the block, drafts that
|
||||||
|
* stay drafts, one authoritative process definition for new cases.
|
||||||
|
*/
|
||||||
|
#[Group('configurator')]
|
||||||
|
class VisualProcessConfiguratorTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private Property $property;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->travelTo(CarbonImmutable::parse('2026-10-23 18:00'));
|
||||||
|
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||||
|
$this->property = Property::sole();
|
||||||
|
Storage::fake('local');
|
||||||
|
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||||
|
config(['mail.default' => 'array']);
|
||||||
|
Mail::swap(new MailManager($this->app));
|
||||||
|
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'test@example.org']);
|
||||||
|
Http::preventStrayRequests();
|
||||||
|
$this->actingAs(User::factory()->create());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test A: own website – answer and reservation changed in the blocks, overview follows, draft is tested, then saved */
|
||||||
|
public function test_a_website_request_is_configured_in_the_blocks_and_the_overview_follows(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $website->getRouteKey()])
|
||||||
|
->call('chooseModel', 'inquiry.request')
|
||||||
|
->call('selectBlock', 'answer')
|
||||||
|
->assertSee('Verbindliches Angebot')
|
||||||
|
->call('chooseTemplate', 'inquiry_answer', 'inquiry.binding_offer');
|
||||||
|
|
||||||
|
$blocks = $page->instance()->blocks();
|
||||||
|
$this->assertSame('Verbindliches Angebot', $blocks['answer']['template']::label());
|
||||||
|
$this->assertTrue($page->instance()->dirty(), 'a changed draft is shown as unsaved');
|
||||||
|
$this->assertNull($website->fresh()->process_overrides['inquiry']['model'] ?? null, 'nothing is saved by choosing');
|
||||||
|
|
||||||
|
// The offer waits for exactly what it needs; data collection and availability do not wait for it.
|
||||||
|
$this->assertContains('Eingang und Gastdaten', array_column($blocks['answer']['waits_for'], 'label'));
|
||||||
|
$this->assertContains('Verfügbarkeit und Reservierung', array_column($blocks['answer']['waits_for'], 'label'));
|
||||||
|
$this->assertTrue($blocks['intake']['independent']);
|
||||||
|
$this->assertTrue($blocks['availability']['independent']);
|
||||||
|
$this->assertSame([], $blocks['availability']['waits_for']);
|
||||||
|
|
||||||
|
$reserving = collect($blocks['availability']['facts'])->firstWhere('key', 'pre_reservation');
|
||||||
|
$this->assertSame('ja', mb_strtolower(substr($reserving['value'], 0, 2)), 'the offer suggests holding the dates at the request');
|
||||||
|
|
||||||
|
$page->call('selectBlock', 'availability')->set('drafts.inquiry.settings.pre_reservation', '0')->set('drafts.inquiry.settings.data_request_mode', 'manual');
|
||||||
|
$blocks = $page->instance()->blocks();
|
||||||
|
$this->assertContains('Reservierung des Zeitraums', array_column($blocks['availability']['off'], 'label'), 'the hold step drops out of the overview at once');
|
||||||
|
$this->assertSame('hier gesetzt', collect($blocks['availability']['facts'])->firstWhere('key', 'pre_reservation')['source']);
|
||||||
|
$this->assertStringContainsString('selbst nach', mb_strtolower(collect($blocks['intake']['facts'])->firstWhere('key', 'data_request_mode')['value']), 'the data request mode is shown in its block');
|
||||||
|
|
||||||
|
// The tester gets the very same unsaved draft.
|
||||||
|
$page->call('test');
|
||||||
|
$draft = session('process-tester.draft.'.$website->id.'.inquiry');
|
||||||
|
$this->assertSame('inquiry.request', $draft['model']);
|
||||||
|
$this->assertSame('inquiry.binding_offer', $draft['templates']['inquiry_answer']);
|
||||||
|
$this->assertSame('0', $draft['settings']['pre_reservation']);
|
||||||
|
|
||||||
|
$page->call('save')->assertNotified('Ablauf gespeichert');
|
||||||
|
$saved = $website->fresh()->process_overrides['inquiry'];
|
||||||
|
$this->assertSame(['inquiry.request', 'inquiry.binding_offer'], [$saved['model'], $saved['templates']['inquiry_answer']]);
|
||||||
|
$this->assertFalse($saved['pre_reservation']);
|
||||||
|
$this->assertFalse($page->instance()->dirty(), 'after saving the stored configuration is shown');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_selecting_never_saves_and_changes_can_be_discarded(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $website->getRouteKey()])->call('selectBlock', 'availability');
|
||||||
|
$this->assertFalse($page->instance()->dirty(), 'opening a block changes nothing');
|
||||||
|
|
||||||
|
$page->set('drafts.inquiry.settings.hold_hours', '12');
|
||||||
|
$this->assertTrue($page->instance()->dirty());
|
||||||
|
$this->assertNull(($website->fresh()->process_overrides['inquiry'] ?? [])['hold_hours'] ?? null);
|
||||||
|
|
||||||
|
$page->call('discard');
|
||||||
|
$this->assertFalse($page->instance()->dirty());
|
||||||
|
$this->assertArrayNotHasKey('hold_hours', $page->get('drafts')['inquiry']['settings']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test B: Destination Solutions – own collection, external contract documents, own booking notice, waiting for the portal */
|
||||||
|
public function test_destination_solutions_blocks_templates_modules_and_the_frozen_plan_agree(): void
|
||||||
|
{
|
||||||
|
$ds = $this->portal('Destination Solution');
|
||||||
|
app(ConfigureChannelProcess::class)->handle($ds, IntakeKind::Booking, [
|
||||||
|
'model' => 'external.booking',
|
||||||
|
'templates' => ['collection' => 'collection.own', 'contract_documents' => 'contract_docs.external'],
|
||||||
|
'settings' => ['await_portal_confirmation' => '1', 'booking_notice' => 'automatic'],
|
||||||
|
'capabilities' => ['collects_payment' => '0', 'provides_contract_documents' => '1'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $ds->fresh()->getRouteKey()])->set('intake', 'booking');
|
||||||
|
$blocks = $page->instance()->blocks();
|
||||||
|
|
||||||
|
$this->assertSame('Eigenes Inkasso', $blocks['finance']['template']::label());
|
||||||
|
$this->assertSame('Externe Vertragsunterlagen', $blocks['documents']['template']::label());
|
||||||
|
$this->assertContains('Bestätigung des Portals', array_column($blocks['documents']['waits_for'], 'label'), 'the documents wait for the portal confirmation');
|
||||||
|
$this->assertTrue($blocks['finance']['independent'], 'collecting the money does not wait for it');
|
||||||
|
$this->assertTrue($blocks['communication']['independent'], 'neither does the guest communication');
|
||||||
|
$this->assertContains('Zahlungen des Gastes', array_column($blocks['finance']['fixed'], 'label'));
|
||||||
|
$this->assertContains('Mehrstufige Mahnungen (rechtliche Ausgestaltung offen)', $blocks['finance']['extensions']);
|
||||||
|
$this->assertSame('automatic', collect($blocks['documents']['facts'])->firstWhere('key', 'booking_notice') ? 'automatic' : null);
|
||||||
|
|
||||||
|
// What the overview shows is what a new case gets.
|
||||||
|
$booking = $this->takeOver($ds->fresh(), 'DS-1');
|
||||||
|
$plan = ProcessPlan::of($booking);
|
||||||
|
$shown = collect($blocks)->flatMap(fn (array $block): array => collect($block['modules'])->where('on', true)->pluck('module')->all())->sort()->values()->all();
|
||||||
|
$this->assertSame(collect(array_keys($plan->modules))->sort()->values()->all(), $shown);
|
||||||
|
$this->assertEqualsCanonicalizing(['collection' => 'collection.own@1', 'contract_documents' => 'contract_docs.external@1'], array_intersect_key($plan->templates, ['collection' => 1, 'contract_documents' => 1]));
|
||||||
|
$this->assertSame('landlord', $booking->process()->payments()->value);
|
||||||
|
$this->assertSame('portal', $booking->process()->documents()->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test C: a stored legacy setting contradicts the chosen template – one definition, controlled adoption */
|
||||||
|
public function test_a_contradicting_legacy_setting_becomes_a_conflict_and_never_a_second_definition(): void
|
||||||
|
{
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
$website->update(['process_overrides' => ['inquiry' => ['model' => 'a1.offer', 'pre_reservation' => true]]]);
|
||||||
|
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $website->fresh()->getRouteKey()])
|
||||||
|
->call('chooseModel', 'inquiry.request')
|
||||||
|
->call('chooseTemplate', 'inquiry_answer', 'inquiry.information');
|
||||||
|
|
||||||
|
$conflicts = collect($page->instance()->conflicts())->map(fn (array $conflict): string => $conflict['setting']->value)->all();
|
||||||
|
$this->assertContains('pre_reservation', $conflicts);
|
||||||
|
$this->assertGreaterThan(0, $page->instance()->blocks()['availability']['attention'], 'the block that is affected is marked');
|
||||||
|
$page->assertSee('Bisherige Einstellungen widersprechen');
|
||||||
|
|
||||||
|
$page->call('save')->assertNotified('Nicht gespeichert');
|
||||||
|
$this->assertSame('a1.offer', $website->fresh()->process_overrides['inquiry']['model'], 'refused: still exactly the old definition');
|
||||||
|
|
||||||
|
$page->set('acknowledge', true)->call('save')->assertNotified('Ablauf gespeichert');
|
||||||
|
$saved = $website->fresh()->process_overrides['inquiry'];
|
||||||
|
$this->assertSame('inquiry.request', $saved['model']);
|
||||||
|
$this->assertArrayNotHasKey('pre_reservation', $saved, 'the stale legacy value is gone, not hidden behind the template');
|
||||||
|
|
||||||
|
$plan = ProcessPlan::freeze(app(ProcessSettings::class)->forWebsite($this->property), ProcessPlan::configurationOf($website->fresh(), IntakeKind::Inquiry));
|
||||||
|
$this->assertSame([ProcessPlan::CONFIGURED, 'inquiry.request', 'inquiry.information@1'], [$plan->source, $plan->model, $plan->templates['inquiry_answer']]);
|
||||||
|
$this->assertFalse(app(ProcessSettings::class)->forWebsite($this->property)->preReservation());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test D: cases of the historical models keep their frozen plan when the channel is reconfigured */
|
||||||
|
public function test_historical_cases_keep_their_frozen_plan(): void
|
||||||
|
{
|
||||||
|
$fewo = $this->portal('FeWo-direkt', 'mixed');
|
||||||
|
app(ConfigureChannelProcess::class)->handle($fewo, IntakeKind::Booking, ['model' => 'a4.portal_booking', 'capabilities' => ['collects_payment' => '1']]);
|
||||||
|
$old = $this->takeOver($fewo->fresh(), 'FD-ALT');
|
||||||
|
$frozen = $old->fresh()->profile;
|
||||||
|
$this->assertSame('a4.portal_booking', ProcessPlan::of($old)->model);
|
||||||
|
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $fewo->fresh()->getRouteKey()])->set('intake', 'booking')->call('applyPreset', 'a4.portal_booking');
|
||||||
|
$page->call('save')->assertNotified('Ablauf gespeichert');
|
||||||
|
|
||||||
|
$this->assertSame($frozen, $old->fresh()->profile);
|
||||||
|
$this->assertSame('a4.portal_booking', ProcessPlan::of($old->fresh())->model);
|
||||||
|
$this->assertSame('external.booking', ProcessPlan::of($this->takeOver($fewo->fresh(), 'FD-NEU', '2027-09-10'))->model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test E: the main view has few blocks, every module sits in exactly one of them, every control is reachable */
|
||||||
|
public function test_every_module_is_in_a_block_and_every_control_is_reachable_there(): void
|
||||||
|
{
|
||||||
|
$catalogue = app(ProcessCatalogue::class);
|
||||||
|
$grouped = collect(ProcessBlocks::BLOCKS)->flatMap(fn (array $block): array => $block['modules'])->all();
|
||||||
|
$this->assertSame([], array_values(array_diff(array_keys($catalogue->modules()), $grouped)), 'a new module needs a block');
|
||||||
|
$this->assertSame($grouped, array_values(array_unique($grouped)), 'no module is in two blocks');
|
||||||
|
|
||||||
|
$ds = $this->portal('Destination Solution');
|
||||||
|
$page = Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])->set('intake', 'booking')->call('chooseModel', 'external.booking');
|
||||||
|
$blocks = $page->instance()->blocks();
|
||||||
|
$this->assertLessThanOrEqual(8, count($blocks), 'a handful of blocks, not 28 modules');
|
||||||
|
$this->assertNotContains(ProcessBlocks::OTHER, array_keys($blocks));
|
||||||
|
|
||||||
|
$reachable = [];
|
||||||
|
foreach ($blocks as $block) {
|
||||||
|
foreach ($block['configurable'] as $step) {
|
||||||
|
foreach ([$step['mode_setting'], $step['performer_setting'], ...array_map(fn (array $parameter) => ProcessSetting::from($parameter['key']), $step['parameters'])] as $setting) {
|
||||||
|
if ($setting !== null) {
|
||||||
|
$reachable[$step['module']][$setting->value] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Whatever the configurator can save for a step is offered inside the block of that step.
|
||||||
|
foreach ($page->instance()->steps() as $step) {
|
||||||
|
if (! $step['on']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$offered = array_filter([$step['mode_setting']?->value, ...(count($step['performer_options']) > 1 ? [$step['performer_setting']?->value] : []), ...array_column($step['parameters'], 'key')]);
|
||||||
|
foreach ($offered as $setting) {
|
||||||
|
$this->assertArrayHasKey($setting, $reachable[$step['module']] ?? [], $step['module'].' / '.$setting.' is not reachable in its block');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One authoritative definition: the derived legacy model is only an adapter for channels without a chosen model */
|
||||||
|
public function test_the_derived_legacy_model_is_only_used_where_nothing_is_chosen(): void
|
||||||
|
{
|
||||||
|
$users = collect(['app/Process', 'app/Actions', 'app/Filament', 'app/Console'])
|
||||||
|
->flatMap(fn (string $directory): array => collect(app('files')->allFiles(base_path($directory)))->map(fn ($file) => $file->getPathname())->all())
|
||||||
|
->filter(fn (string $path): bool => str_contains(file_get_contents($path), 'derivedModel('))
|
||||||
|
->map(fn (string $path): string => basename($path))->sort()->values()->all();
|
||||||
|
|
||||||
|
$this->assertSame(['ChannelProcessConfiguration.php', 'ProcessCatalogue.php', 'ProcessPlan.php'], $users, 'only plan resolution and the configurator show the adapter');
|
||||||
|
|
||||||
|
$website = Channel::websiteOf($this->property);
|
||||||
|
app(ConfigureChannelProcess::class)->handle($website, IntakeKind::Inquiry, ['model' => 'inquiry.request', 'templates' => ['inquiry_answer' => 'inquiry.binding_offer']]);
|
||||||
|
$profile = app(ProcessSettings::class)->forWebsite($this->property);
|
||||||
|
$plan = ProcessPlan::freeze($profile, ProcessPlan::configurationOf($website->fresh(), IntakeKind::Inquiry));
|
||||||
|
$this->assertSame([ProcessPlan::CONFIGURED, 'inquiry.request'], [$plan->source, $plan->model], 'a chosen model is never replaced by the derived one');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function portal(string $name, string $model = 'portal_booking'): Channel
|
||||||
|
{
|
||||||
|
return Channel::factory()->for($this->property)->create(['name' => $name, 'booking_model' => $model, 'import_enabled' => false, 'settings' => ['import_url' => 'https://portal.example/'.md5($name).'.ics']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function takeOver(Channel $channel, string $reference, string $arrival = '2027-07-10'): Booking
|
||||||
|
{
|
||||||
|
$arrival = CarbonImmutable::parse($arrival);
|
||||||
|
|
||||||
|
return app(TakeOverExternalBooking::class)->handle($this->property, $channel, $arrival, $arrival->addDays(7), ['portal_reference' => $reference]);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user