Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86965d6d45 | ||
|
|
3cbca35fcb | ||
|
|
664f00e510 | ||
|
|
4554af8056 | ||
|
|
f2b6626f6a | ||
|
|
b1b09a6db4 | ||
|
|
221ce8ca81 | ||
|
|
e40f8639b3 | ||
|
|
eba1a4d094 | ||
|
|
e1d0f6b023 | ||
|
|
6f14437855 | ||
|
|
c46f4a032b | ||
|
|
e95ba4f986 | ||
|
|
381720763c | ||
|
|
a3ab1b6657 | ||
|
|
8ad71c54d2 | ||
|
|
e5cbc6faca | ||
|
|
0d51c673eb | ||
|
|
fdf226535b | ||
|
|
f8561fe0e5 | ||
|
|
8026eceab4 | ||
|
|
8442d0a3d8 | ||
|
|
ef1635e59a | ||
|
|
4410fb3ee0 |
No files matched your search
@@ -8,6 +8,7 @@
|
||||
use App\Documents\DocumentFinding;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\DocumentKind;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\Booking;
|
||||
@@ -49,14 +50,16 @@ public function blockers(Booking $booking): array
|
||||
{
|
||||
$property = $booking->property;
|
||||
$reasons = [];
|
||||
$information = ! $booking->process()->preReservation();
|
||||
$information = $booking->process()->inquiryAnswer() === InquiryAnswer::Information;
|
||||
|
||||
if ($information && ($booking->status !== BookingStatus::Reserved || $booking->information_version > 0)) {
|
||||
$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.
|
||||
$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).';
|
||||
}
|
||||
if (blank($booking->guest?->email)) {
|
||||
@@ -87,7 +90,7 @@ public function handle(Booking $booking): array
|
||||
{
|
||||
$booking->loadMissing(['property', 'guest']);
|
||||
|
||||
if ($booking->process()->preReservation()) {
|
||||
if ($booking->process()->inquiryAnswer() === InquiryAnswer::Offer) {
|
||||
$this->clearance->refresh($booking->property);
|
||||
}
|
||||
|
||||
@@ -97,7 +100,7 @@ public function handle(Booking $booking): array
|
||||
}
|
||||
|
||||
try {
|
||||
if (! $booking->process()->preReservation()) {
|
||||
if ($booking->process()->inquiryAnswer() === InquiryAnswer::Information) {
|
||||
$this->sendInformation->handle($booking->fresh(), ['expected_version' => 0, 'acknowledged' => true]);
|
||||
} else {
|
||||
$this->sendOffer->handle($booking->fresh(), ['expected_version' => 0]);
|
||||
|
||||
@@ -5,40 +5,60 @@
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Models\Channel;
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\ChannelProcessConfiguration;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Saves the process of a channel for one intake kind (Kanal › Ablauf, docs/Prozessarchitektur/Architektur/03): the
|
||||
* chosen model and variant, the step switches and the step settings – in channels.process_overrides[intake], next to
|
||||
* the existing settings, so their inheritance stays as it is. Refuses everything the configuration does not admit
|
||||
* (mandatory steps off, responsibilities the model does not allow, tester-only variants). Changes apply to new cases
|
||||
* only (decision E3): running cases keep their frozen plan.
|
||||
* Saves the process of a channel for one intake kind (Kanal › Ablauf, docs/Prozessarchitektur/Architektur/03 and V2.1/02):
|
||||
* the confirmed capabilities of the portal, the chosen model and variant, the step switches and the step settings – in
|
||||
* channels.settings and channels.process_overrides[intake], next to the existing settings, so their inheritance stays
|
||||
* as it is. Refuses everything the configuration does not admit (mandatory steps off, responsibilities the model does not
|
||||
* allow, a model the capabilities do not fit, tester-only variants). Stored settings that the chosen model overrides are
|
||||
* removed only after the landlord confirmed that, and the change is kept in the channel's history. Changes apply to new
|
||||
* cases only (decision E3): running cases keep their frozen plan.
|
||||
*/
|
||||
class ConfigureChannelProcess
|
||||
{
|
||||
public function __construct(private ChannelProcessConfiguration $configuration) {}
|
||||
public const HISTORY_LIMIT = 20;
|
||||
|
||||
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>} $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
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function handle(Channel $channel, IntakeKind $intake, array $draft, ?string $by = null): Channel
|
||||
public function handle(Channel $channel, IntakeKind $intake, array $draft, ?string $by = null, bool $acknowledgeConflicts = false): Channel
|
||||
{
|
||||
$problems = $this->configuration->problems($channel, $intake, $draft);
|
||||
if ($problems !== []) {
|
||||
throw ValidationException::withMessages(['process' => $problems]);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($channel, $intake, $draft, $by): Channel {
|
||||
$conflicts = $this->configuration->conflicts($channel, $intake, (string) $draft['model'], (array) ($draft['templates'] ?? []));
|
||||
if ($conflicts !== [] && ! $acknowledgeConflicts) {
|
||||
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:',
|
||||
...array_column($conflicts, 'text'),
|
||||
]]);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($channel, $intake, $draft, $by, $conflicts): Channel {
|
||||
$channel = Channel::query()->lockForUpdate()->findOrFail($channel->id);
|
||||
$by ??= auth()->user()?->name;
|
||||
$overrides = (array) ($channel->process_overrides ?? []);
|
||||
$current = (array) ($overrides[$intake->value] ?? []);
|
||||
$removed = array_map(fn (array $conflict): string => $conflict['setting']->value, $conflicts);
|
||||
|
||||
$settings = [];
|
||||
foreach (ProcessSetting::cases() as $setting) {
|
||||
if (in_array($setting->value, $removed, true)) {
|
||||
continue;
|
||||
}
|
||||
$value = array_key_exists($setting->value, (array) ($draft['settings'] ?? [])) ? $setting->normalize($draft['settings'][$setting->value]) : $setting->normalize($current[$setting->value] ?? null);
|
||||
if ($value !== null && in_array($intake, $setting->channelIntakes(), true)) {
|
||||
$settings[$setting->value] = $value;
|
||||
@@ -52,15 +72,36 @@ 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] = [
|
||||
...$settings,
|
||||
'model' => $draft['model'],
|
||||
'variant' => $draft['variant'] ?? 'standard',
|
||||
'steps' => $steps,
|
||||
'templates' => $templates,
|
||||
'configured_at' => now()->toIso8601String(),
|
||||
'configured_by' => $by ?? auth()->user()?->name,
|
||||
'configured_by' => $by,
|
||||
];
|
||||
$channel->update(['process_overrides' => $overrides]);
|
||||
|
||||
$channelSettings = (array) ($channel->settings ?? []);
|
||||
$changes = [];
|
||||
if (! $channel->isWebsite() && filled($draft['capabilities'] ?? null)) {
|
||||
$confirmed = $this->capabilities->confirm($channel, (array) $draft['capabilities'], $by);
|
||||
$channelSettings['capabilities'] = $confirmed['capabilities'];
|
||||
$changes = $confirmed['changes'];
|
||||
}
|
||||
$channelSettings['process_history'] = array_slice([...(array) ($channelSettings['process_history'] ?? []), [
|
||||
'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),
|
||||
]], -self::HISTORY_LIMIT);
|
||||
|
||||
$channel->update(['process_overrides' => $overrides, 'settings' => $channelSettings]);
|
||||
|
||||
return $channel;
|
||||
});
|
||||
|
||||
@@ -12,9 +12,11 @@
|
||||
use App\Enums\TenantServiceKey;
|
||||
use App\Mail\PortalMailNotification;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\IntakeObservation;
|
||||
use App\Models\PortalEmail;
|
||||
use App\Process\ProcessRunner;
|
||||
use App\Support\Settings;
|
||||
use App\Tenancy\TenantFeatures;
|
||||
use Carbon\CarbonInterface;
|
||||
@@ -79,6 +81,7 @@ public function handle(PortalMail $mail): ?PortalEmail
|
||||
|
||||
// One intake for all channels (package 4): bookings, requests and cancellations reach their case.
|
||||
rescue(fn () => $this->intake($channel, $parsed, $record));
|
||||
rescue(fn () => $this->resume($channel, $parsed, $record));
|
||||
|
||||
if (in_array($record->status, [PortalEmailStatus::Blocked, PortalEmailStatus::Released, PortalEmailStatus::NeedsReview], true)) {
|
||||
rescue(fn () => Mail::to(Settings::notificationRecipients())->send(new PortalMailNotification($record)));
|
||||
@@ -91,6 +94,22 @@ public function handle(PortalMail $mail): ?PortalEmail
|
||||
return $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* A booking mail of the portal can be the confirmation a case waits for (V2.1, docs/Prozessarchitektur/V2.1/02 §5): the
|
||||
* case is evaluated again. Only cases whose channel makes them wait are touched – everything else stays as it was.
|
||||
*/
|
||||
private function resume(Channel $channel, ParsedPortalMail $parsed, PortalEmail $record): void
|
||||
{
|
||||
if ($parsed->type !== PortalEmailType::Booking) {
|
||||
return;
|
||||
}
|
||||
$case = $record->blocked_period_id !== null ? Booking::query()->find(BlockedPeriod::withTrashed()->whereKey($record->blocked_period_id)->value('linked_booking_id')) : null;
|
||||
$case ??= $parsed->reference !== null ? app(PortalIntake::class)->caseByReference($channel, $parsed->reference) : null;
|
||||
if ($case !== null && $case->isBinding() && $case->process()->awaitsPortalConfirmation()) {
|
||||
app(ProcessRunner::class)->advance($case, 'portal.mail');
|
||||
}
|
||||
}
|
||||
|
||||
private function intake(Channel $channel, ParsedPortalMail $parsed, PortalEmail $record): void
|
||||
{
|
||||
$intake = app(PortalIntake::class);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
use App\Enums\DataRequestMode;
|
||||
use App\Enums\DocumentKind;
|
||||
use App\Enums\FactSource;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Mail\DataRequested;
|
||||
use App\Models\Booking;
|
||||
@@ -70,7 +71,7 @@ public static function needs(Booking $booking): ?array
|
||||
}
|
||||
|
||||
$purpose = match (true) {
|
||||
$booking->process()->preReservation() => self::FOR_OFFER,
|
||||
$booking->process()->inquiryAnswer() === InquiryAnswer::Offer => self::FOR_OFFER,
|
||||
$booking->wish_at !== null => self::FOR_WISH,
|
||||
default => null,
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ public function handle(): int
|
||||
->whereHas('guest', fn ($query) => $query->whereNull('anonymized_at')->whereNotNull('email')->where('email', '!=', ''))
|
||||
->with('guest')
|
||||
->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).
|
||||
&& ProcessPlan::of($booking)->enabled('review.request')
|
||||
&& OutwardSuspension::reason($booking) === null);
|
||||
|
||||
@@ -49,6 +49,41 @@ public function automatically(Booking $booking): array
|
||||
return $this->send($booking, $composition, acknowledged: false, automatic: true) ? [] : ['Die Unterlagen konnten nicht versendet werden (siehe Postfach).'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the contract document and files it internally – without sending anything to the guest (delivery „internal“,
|
||||
* docs/Prozessarchitektur/V2.1/02 §4). Same gate as the automatic dispatch: the composition must be clean.
|
||||
*
|
||||
* @return list<string> reasons why it was not created (empty: filed or already there)
|
||||
*/
|
||||
public function storeInternally(Booking $booking): array
|
||||
{
|
||||
if ($booking->contract_path !== null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$composition = $this->compose($booking);
|
||||
if (! $composition->canSendAutomatically()) {
|
||||
return [...$composition->blockers(), ...array_map(fn (string $point): string => 'Bitte prüfen: '.$point, $composition->toConfirm())];
|
||||
}
|
||||
|
||||
$lock = Cache::lock('booking-documents-'.$booking->id, 120);
|
||||
if (! $lock->get()) {
|
||||
return ['Die Unterlagen werden gerade bearbeitet.'];
|
||||
}
|
||||
|
||||
try {
|
||||
$booking->refresh();
|
||||
if (! $composition->termsFrozen && $composition->terms !== null) {
|
||||
$booking->update(['offer_terms' => $composition->terms]);
|
||||
}
|
||||
|
||||
return CaseLog::context(fn (): bool => $this->confirm->deliver($booking, notifyGuest: false, kind: $composition->kind), actor: CaseLog::SYSTEM.' (automatisch)')
|
||||
? [] : ['Das Vertragsdokument konnte nicht erstellt werden (siehe Postfach).'];
|
||||
} finally {
|
||||
$lock->release();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sending by hand after the landlord saw the composition.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Mail\BookingNotice;
|
||||
use App\Models\Booking;
|
||||
use App\Process\CaseLog;
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\PortalConfirmation;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Sends the guest of a binding booking a short booking information (V2.1, docs/Prozessarchitektur/V2.1/02 §4) – separate
|
||||
* from the contract documentation, which has its own step. Once only (the history entry `booking_notice` is the record).
|
||||
* Where the landlord chose „unless the portal confirmed“, it is not sent when the portal informs the guest itself (confirmed
|
||||
* capability of the channel) and its booking confirmation for this case is on record; the reason is kept in the history.
|
||||
*/
|
||||
class SendBookingNotice
|
||||
{
|
||||
public const EVENT = 'booking_notice';
|
||||
|
||||
public static function sent(Booking $booking): bool
|
||||
{
|
||||
return $booking->events()->where('type', self::EVENT)->where('summary', 'not like', 'Keine eigene%')->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Why no own notice is needed, or null when it is.
|
||||
*/
|
||||
public static function suppression(Booking $booking): ?string
|
||||
{
|
||||
if ($booking->process()->bookingNotice() !== BookingNoticeMode::AutomaticUnlessPortalConfirmed) {
|
||||
return null;
|
||||
}
|
||||
$channel = $booking->processChannel();
|
||||
if ($channel === null || app(ChannelCapabilities::class)->value($channel, ChannelCapabilities::MESSAGES_GUEST) !== true) {
|
||||
return null;
|
||||
}
|
||||
$evidence = PortalConfirmation::evidence($booking);
|
||||
|
||||
return $evidence === null ? null : 'Das Portal informiert den Gast selbst und hat die Buchung bestätigt ('.$evidence['label'].').';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Booking $booking, bool $automatic = false): bool
|
||||
{
|
||||
$booking->loadMissing(['guest', 'property']);
|
||||
if (! $booking->isBinding()) {
|
||||
throw ReservationException::invalidTransition($booking->status->getLabel(), 'mit einer Buchungsinformation bedacht');
|
||||
}
|
||||
if (self::sent($booking)) {
|
||||
return true;
|
||||
}
|
||||
if (blank($booking->guest?->email)) {
|
||||
throw new ReservationException('Vor dem Versand bitte die E-Mail-Adresse des Gastes ergänzen.');
|
||||
}
|
||||
if ($automatic && ($reason = self::suppression($booking)) !== null) {
|
||||
if (! $booking->events()->where('type', self::EVENT)->exists()) {
|
||||
CaseLog::record($booking, self::EVENT, 'Keine eigene Buchungsinformation nötig', reason: $reason, data: ['level' => 'stated_by_portal']);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new BookingNotice($booking));
|
||||
CaseLog::record($booking, self::EVENT, 'Buchungsinformation an den Gast gesendet', actor: $automatic ? CaseLog::SYSTEM.' (automatisch)' : null);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public function handle(): array
|
||||
->whereNull('arrival_info_sent_at')
|
||||
->whereDate('arrival', '>=', $today)
|
||||
->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()))
|
||||
// Decision O4: an open portal report of a cancellation or change holds the message back until clarified.
|
||||
&& OutwardSuspension::reason($booking) === null);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\Medium;
|
||||
use App\Enums\MessageEffect;
|
||||
use App\Enums\MessageIntent;
|
||||
use App\Support\Settings;
|
||||
|
||||
/**
|
||||
* The medium × intent policy (V2.1): `config/communication.php` is the ceiling, the landlord's `communication_rules`
|
||||
* (tenants) may only narrow it: switch a medium off, withdraw effects. Widening is ignored.
|
||||
*/
|
||||
class CommunicationRules
|
||||
{
|
||||
public function mediumActive(Medium $medium): bool
|
||||
{
|
||||
$ceiling = (bool) config("communication.media.{$medium->value}.active", false);
|
||||
|
||||
return $ceiling && ($this->narrowing()['media'][$medium->value]['active'] ?? true) !== false;
|
||||
}
|
||||
|
||||
public function consentRequired(Medium $medium): bool
|
||||
{
|
||||
return (bool) config("communication.media.{$medium->value}.consent_required", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<MessageEffect> the effects the rules allow for the intent on the medium (never empty: review at least)
|
||||
*/
|
||||
public function effects(Medium $medium, MessageIntent $intent): array
|
||||
{
|
||||
/** @var list<MessageEffect> $ceiling */
|
||||
$ceiling = config('communication.effects.'.$intent->value, [MessageEffect::Review]);
|
||||
$withdrawn = (array) ($this->narrowing()['effects'][$medium->value][$intent->value] ?? []);
|
||||
$allowed = array_values(array_filter($ceiling, fn (MessageEffect $effect): bool => ! in_array($effect->value, $withdrawn, true)));
|
||||
|
||||
return $allowed === [] ? [MessageEffect::Review] : $allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function narrowing(): array
|
||||
{
|
||||
return (array) (Settings::tenant()?->communication_rules ?? []);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\Medium;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* A message as the medium adapters hand it over (V2.1): raw data only. {@see $verifiedBookingId} is set by the adapter
|
||||
* itself from a reference it issued and can verify (signed token, reply to one of our mails) – a claim in the text is
|
||||
* never enough. {@see $consentGiven} is likewise the adapter's statement.
|
||||
*/
|
||||
final readonly class IncomingMessage
|
||||
{
|
||||
public function __construct(
|
||||
public Medium $medium,
|
||||
public string $sender,
|
||||
public string $text,
|
||||
public CarbonImmutable $receivedAt,
|
||||
public string $externalId,
|
||||
public ?int $verifiedBookingId = null,
|
||||
public bool $consentGiven = false,
|
||||
public ?string $senderName = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\MessageIntent;
|
||||
|
||||
/**
|
||||
* Rule-based intent of a message (V2.1). Deterministic and medium-independent; an AI classifier can later implement the
|
||||
* same interface of work (E-035). Whatever the rules do not clearly recognise is {@see MessageIntent::Unclear}.
|
||||
*/
|
||||
class IntentClassifier
|
||||
{
|
||||
public function classify(string $text, bool $assignedToCase): MessageIntent
|
||||
{
|
||||
$text = mb_strtolower($text);
|
||||
$has = fn (array $words): bool => (bool) preg_match('/('.implode('|', $words).')/u', $text);
|
||||
|
||||
if ($assignedToCase && $has(['umbuchen', 'verschieb', 'stornieren', 'stornierung', 'später anreisen', 'früher anreisen', 'ändern'])) {
|
||||
return MessageIntent::ChangeRequest;
|
||||
}
|
||||
if ($assignedToCase && $has(['ankunft', 'uhr', 'personen', 'kennzeichen', 'adresse', 'telefon', 'handynummer'])) {
|
||||
return MessageIntent::ProvideData;
|
||||
}
|
||||
if ($assignedToCase) {
|
||||
return MessageIntent::CaseReply;
|
||||
}
|
||||
if ($has(['frei', 'verfügbar', 'buchen', 'reservieren', 'anreise', 'zeitraum', 'vom \d'])) {
|
||||
return MessageIntent::StayInquiry;
|
||||
}
|
||||
if ($has(['\?', 'hund', 'haustier', 'parkplatz', 'wlan', 'preis', 'kosten', 'wie weit', 'strand', 'ausstattung'])) {
|
||||
return MessageIntent::GeneralQuestion;
|
||||
}
|
||||
|
||||
return MessageIntent::Unclear;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\Medium;
|
||||
use App\Enums\MessageEffect;
|
||||
use App\Enums\MessageIntent;
|
||||
use App\Models\Booking;
|
||||
|
||||
/**
|
||||
* What the process core decided about a message (V2.1): intent, case (only if verified), the effects that apply and why.
|
||||
*/
|
||||
final readonly class MessageDecision
|
||||
{
|
||||
/**
|
||||
* @param list<MessageEffect> $effects applied effects, in order
|
||||
* @param list<string> $reasons plain-language explanation
|
||||
*/
|
||||
public function __construct(
|
||||
public Medium $medium,
|
||||
public MessageIntent $intent,
|
||||
public ?Booking $booking,
|
||||
public array $effects,
|
||||
public array $reasons,
|
||||
) {}
|
||||
|
||||
public function has(MessageEffect $effect): bool
|
||||
{
|
||||
return in_array($effect, $this->effects, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{medium: string, intent: string, booking_id: ?int, effects: list<string>, reasons: list<string>}
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return ['medium' => $this->medium->value, 'intent' => $this->intent->value, 'booking_id' => $this->booking?->id,
|
||||
'effects' => array_map(fn (MessageEffect $effect): string => $effect->value, $this->effects), 'reasons' => $this->reasons];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Actions\ReceiveInboundMessage;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\MessageEffect;
|
||||
use App\Enums\MessageIntent;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\InboundMessage;
|
||||
use App\Process\CaseLog;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Database\UniqueConstraintViolationException;
|
||||
|
||||
/**
|
||||
* Entry of messages from every medium except the e-mail inbox, which keeps its own path (V2.1, docs/…/02 §6):
|
||||
* store once → assign deterministically (only a reference verified by the adapter, and not contradicted by the text) →
|
||||
* classify → apply the effects the rules allow. A message never creates a case, reservation, offer or booking; what is
|
||||
* unclear or contradictory goes to review. No answer is sent here.
|
||||
*/
|
||||
class MessageIntake
|
||||
{
|
||||
public function __construct(private CommunicationRules $rules, private IntentClassifier $classifier) {}
|
||||
|
||||
public function handle(IncomingMessage $incoming): MessageDecision
|
||||
{
|
||||
$key = $incoming->medium->value.':'.$incoming->externalId;
|
||||
$existing = InboundMessage::query()->where('message_id', $key)->first();
|
||||
if ($existing !== null) {
|
||||
return $this->fromStored($existing, $incoming);
|
||||
}
|
||||
|
||||
$reasons = [];
|
||||
$booking = $this->assignedCase($incoming, $reasons);
|
||||
$intent = $this->classifier->classify($incoming->text, $booking !== null);
|
||||
$effects = $this->effectsFor($incoming, $intent, $booking, $reasons);
|
||||
$decision = new MessageDecision($incoming->medium, $intent, $booking, $effects, $reasons);
|
||||
|
||||
try {
|
||||
$message = InboundMessage::query()->create([
|
||||
'message_id' => $key,
|
||||
'medium' => $incoming->medium->value,
|
||||
'from_address' => mb_substr($incoming->sender, 0, 255),
|
||||
'from_name' => $incoming->senderName,
|
||||
'subject' => mb_substr(strtok($incoming->text, "\n") ?: '', 0, 120),
|
||||
'body' => $incoming->text,
|
||||
'received_at' => $incoming->receivedAt,
|
||||
'test_mode' => ! Settings::isLive(),
|
||||
'status' => $booking !== null && ! $decision->has(MessageEffect::Review) ? InboundMessage::ASSIGNED : InboundMessage::NEEDS_REVIEW,
|
||||
'booking_id' => $booking?->id,
|
||||
'match_reason' => $booking !== null ? 'verified_reference' : null,
|
||||
'intent' => $intent->value,
|
||||
'decision' => $decision->toArray(),
|
||||
]);
|
||||
} catch (UniqueConstraintViolationException) {
|
||||
return $this->fromStored(InboundMessage::query()->where('message_id', $key)->firstOrFail(), $incoming);
|
||||
}
|
||||
|
||||
$this->apply($message, $decision);
|
||||
|
||||
return $decision;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $reasons
|
||||
*/
|
||||
private function assignedCase(IncomingMessage $incoming, array &$reasons): ?Booking
|
||||
{
|
||||
if ($incoming->verifiedBookingId === null) {
|
||||
$reasons[] = 'Kein überprüfter Bezug zu einem Vorgang – Absender, Rufnummer, Name oder Zeitraum allein ordnen nicht zu.';
|
||||
|
||||
return null;
|
||||
}
|
||||
$booking = Booking::query()->find($incoming->verifiedBookingId);
|
||||
if ($booking === null) {
|
||||
$reasons[] = 'Der überprüfte Bezug verweist auf keinen Vorgang dieses Vermieters.';
|
||||
|
||||
return null;
|
||||
}
|
||||
if (preg_match_all('/\b(20\d{2}-\d{4})\b/', $incoming->text, $numbers) && array_diff($numbers[1], [$booking->reference]) !== []) {
|
||||
$reasons[] = 'Die Nachricht nennt eine andere Vorgangsnummer als der überprüfte Bezug – widersprüchlich.';
|
||||
|
||||
return null;
|
||||
}
|
||||
$reasons[] = 'Dem Vorgang '.$booking->reference.' zugeordnet (überprüfter Bezug).';
|
||||
|
||||
return $booking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $reasons
|
||||
* @return list<MessageEffect>
|
||||
*/
|
||||
private function effectsFor(IncomingMessage $incoming, MessageIntent $intent, ?Booking $booking, array &$reasons): array
|
||||
{
|
||||
if (! $this->rules->mediumActive($incoming->medium)) {
|
||||
$reasons[] = $incoming->medium->getLabel().' ist für diesen Vermieter nicht eingeschaltet – die Nachricht liegt zur Klärung vor.';
|
||||
|
||||
return [MessageEffect::Review];
|
||||
}
|
||||
if ($this->rules->consentRequired($incoming->medium) && ! $incoming->consentGiven) {
|
||||
$reasons[] = 'Für '.$incoming->medium->getLabel().' liegt keine Einwilligung vor – nur Klärung durch den Vermieter.';
|
||||
|
||||
return [MessageEffect::Review];
|
||||
}
|
||||
|
||||
$effects = array_values(array_filter(
|
||||
$this->rules->effects($incoming->medium, $intent),
|
||||
fn (MessageEffect $effect): bool => ! $effect->needsCase() || $booking !== null,
|
||||
));
|
||||
// The review fallback only stands alone: where a real effect applies it is not added.
|
||||
$real = array_values(array_filter($effects, fn (MessageEffect $effect): bool => $effect !== MessageEffect::Review));
|
||||
if ($real === [] || $intent === MessageIntent::Unclear) {
|
||||
$reasons[] = 'Nicht eindeutig oder nicht zulässig – zur Klärung vorgelegt, nichts wird übernommen.';
|
||||
|
||||
return [MessageEffect::Review];
|
||||
}
|
||||
|
||||
return $real;
|
||||
}
|
||||
|
||||
private function apply(InboundMessage $message, MessageDecision $decision): void
|
||||
{
|
||||
$booking = $decision->booking;
|
||||
if ($booking === null || $decision->has(MessageEffect::Review)) {
|
||||
return;
|
||||
}
|
||||
CaseLog::record($booking, 'message_in', $decision->medium->getLabel().'-Nachricht eingegangen ('.$decision->intent->getLabel().')', actor: CaseLog::GUEST, at: $message->received_at);
|
||||
if ($decision->has(MessageEffect::ReportToCase) || $decision->has(MessageEffect::ContributeFacts)) {
|
||||
BookingTask::openOnce($booking, BookingTaskKind::InboundReview, 'm'.$message->id, ['due_on' => today(), 'note' => $decision->medium->getLabel().'-Nachricht („'.mb_substr((string) $message->subject, 0, 100).'“) – im Posteingang ansehen; es wird nichts automatisch übernommen.']);
|
||||
}
|
||||
if ($decision->has(MessageEffect::ContributeFacts)) {
|
||||
app(ReceiveInboundMessage::class)->evaluate($message);
|
||||
}
|
||||
}
|
||||
|
||||
private function fromStored(InboundMessage $stored, IncomingMessage $incoming): MessageDecision
|
||||
{
|
||||
$data = (array) $stored->decision;
|
||||
|
||||
return new MessageDecision(
|
||||
$incoming->medium,
|
||||
MessageIntent::tryFrom((string) $stored->intent) ?? MessageIntent::Unclear,
|
||||
$stored->booking,
|
||||
array_values(array_filter(array_map(fn (string $effect): ?MessageEffect => MessageEffect::tryFrom($effect), (array) ($data['effects'] ?? [])))),
|
||||
(array) ($data['reasons'] ?? []),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Tenant;
|
||||
use App\Process\ProcessRunner;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Evaluates binding bookings that wait for an event again (V2.1, docs/Prozessarchitektur/V2.1/02 §5): the portal's
|
||||
* confirmation mail did not come in time (escalate once), came meanwhile (close the escalation, go on) – without this nothing
|
||||
* would resume or time out, because no scheduler looks at binding cases. Only cases whose channel makes them wait are
|
||||
* touched; once per landlord.
|
||||
*/
|
||||
#[Signature('bookings:advance-waiting')]
|
||||
#[Description('Re-evaluate binding bookings that wait for a portal confirmation (deadline, escalation, resume) – once per landlord')]
|
||||
class AdvanceWaitingCases extends Command
|
||||
{
|
||||
public function handle(TenantRunner $tenants, ProcessRunner $runner): int
|
||||
{
|
||||
$tenants->each(function (Tenant $tenant) use ($runner): void {
|
||||
$evaluated = 0;
|
||||
Booking::query()->occupying()->where('intake', 'booking')->where('created_at', '>', now()->subDays(90))
|
||||
->with(['property', 'guest', 'importChannel', 'originChannel'])
|
||||
->each(function (Booking $booking) use ($runner, &$evaluated): void {
|
||||
if (! $booking->process()->awaitsPortalConfirmation()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$runner->advance($booking, 'schedule:waiting');
|
||||
$evaluated++;
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
}
|
||||
});
|
||||
|
||||
$this->info("{$tenant->name}: {$evaluated} wartende Vorgang/Vorgänge bewertet.");
|
||||
});
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\DocumentKind;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
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,
|
||||
]);
|
||||
|
||||
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);
|
||||
}
|
||||
if ($booking->offer_version > 0) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* Whether the guest of a binding booking gets a short booking information (without contract) from us (docs/
|
||||
* Prozessarchitektur/V2.1/02 §4) – independent of the contract documentation, which stays with its own step.
|
||||
*/
|
||||
enum BookingNoticeMode: string implements HasLabel
|
||||
{
|
||||
case Off = 'off';
|
||||
case Automatic = 'automatic';
|
||||
case AutomaticUnlessPortalConfirmed = 'automatic_unless_portal_confirmed';
|
||||
case Manual = 'manual';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Off => 'keine eigene Buchungsinformation',
|
||||
self::Automatic => 'automatisch senden',
|
||||
self::AutomaticUnlessPortalConfirmed => 'automatisch senden – außer das Portal hat nachweislich bestätigt',
|
||||
self::Manual => 'von Hand senden',
|
||||
};
|
||||
}
|
||||
|
||||
public function isAutomatic(): bool
|
||||
{
|
||||
return in_array($this, [self::Automatic, self::AutomaticUnlessPortalConfirmed], true);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ enum BookingTaskKind: string implements HasLabel
|
||||
case PortalCancellation = 'portal_cancellation';
|
||||
case PortalCancellationReported = 'portal_cancel_reported';
|
||||
case PortalChangeReported = 'portal_change_reported';
|
||||
case PortalConfirmationMissing = 'portal_confirmation_missing';
|
||||
case RefundCheck = 'refund_check';
|
||||
case BookingWish = 'booking_wish';
|
||||
case ArrivalDetails = 'arrival_details';
|
||||
@@ -47,6 +48,7 @@ public function getLabel(): string
|
||||
self::PortalCancellation => 'Stornierung im Portal veranlassen bzw. prüfen',
|
||||
self::PortalCancellationReported => 'Das Portal meldet eine Stornierung – bitte prüfen',
|
||||
self::PortalChangeReported => 'Das Portal meldet eine Änderung – bitte prüfen',
|
||||
self::PortalConfirmationMissing => 'Bestätigungsmail des Portals fehlt – bitte beim Portal prüfen',
|
||||
self::RefundCheck => 'Erstattung an den Gast prüfen',
|
||||
self::BookingWish => 'Buchungswunsch bestätigen?',
|
||||
self::ArrivalDetails => 'Anreisedaten beim Gast erfragen',
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What happens with the contract document of a booking that is binding (docs/Prozessarchitektur/V2.1/02 §4): creating
|
||||
* and filing it is separate from sending it to the guest. `Follow` keeps the behaviour of V2: it goes out the way the case
|
||||
* is processed (automatically or by the landlord's hand).
|
||||
*/
|
||||
enum ContractDelivery: string implements HasLabel
|
||||
{
|
||||
case Follow = 'follow';
|
||||
case Automatic = 'automatic';
|
||||
case Manual = 'manual';
|
||||
case Internal = 'internal';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Follow => 'wie die übrige Bearbeitung',
|
||||
self::Automatic => 'automatisch erstellen und an den Gast senden',
|
||||
self::Manual => 'von Hand prüfen und senden',
|
||||
self::Internal => 'erstellen und nur intern ablegen (nicht senden)',
|
||||
};
|
||||
}
|
||||
|
||||
/** The mode as the document step sees it: automatic when the case is processed automatically or the delivery says so. */
|
||||
public function sendsAutomatically(ProcessingMode $processing): bool
|
||||
{
|
||||
return match ($this) {
|
||||
self::Follow => $processing === ProcessingMode::Automatic,
|
||||
self::Automatic => true,
|
||||
self::Manual, self::Internal => false,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public static function forCase(Booking $booking): ?self
|
||||
$booking->intake === IntakeKind::Internal => $booking->guest_id !== null ? self::StayConfirmation : self::Internal,
|
||||
$booking->caseType()->isExternallyBinding() => $profile->documents() === Responsibility::Portal ? null : self::ExternalRecord,
|
||||
$booking->isBinding() => $profile->documents() === Responsibility::Portal ? null : self::Confirmation,
|
||||
! $profile->preReservation() => self::Information,
|
||||
$profile->inquiryAnswer() === InquiryAnswer::Information => self::Information,
|
||||
default => self::Offer,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* The ways a task of the process may be fulfilled (docs/Prozessarchitektur/V2.1/02 §2). What is business-mandatory stays
|
||||
* mandatory; the question is not „can I switch it off?“ but „which admissible ways do I have?“. A module names its ways,
|
||||
* the process model narrows them for its archetype.
|
||||
*/
|
||||
enum Execution: string implements HasLabel
|
||||
{
|
||||
case Automatic = 'automatic';
|
||||
case Approval = 'approval';
|
||||
case Manual = 'manual';
|
||||
case Portal = 'portal';
|
||||
case ServiceProvider = 'service_provider';
|
||||
case External = 'external';
|
||||
case NotRequired = 'not_required';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Automatic => 'automatisch durch FewoPortal',
|
||||
self::Approval => 'vorbereitet, nach Ihrer Freigabe',
|
||||
self::Manual => 'von Ihnen von Hand',
|
||||
self::Portal => 'durch das Portal',
|
||||
self::ServiceProvider => 'durch einen Dienstleister',
|
||||
self::External => 'bereits extern erledigt (mit Nachweis)',
|
||||
self::NotRequired => 'nicht erforderlich',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* The communication medium a message came through (V2.1). It says nothing about bindingness or business meaning.
|
||||
* WhatsApp and Chat exist as test cases of the architecture; no provider is connected.
|
||||
*/
|
||||
enum Medium: string implements HasLabel
|
||||
{
|
||||
case Email = 'email';
|
||||
case Form = 'form';
|
||||
case WhatsApp = 'whatsapp';
|
||||
case Chat = 'chat';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Email => 'E-Mail',
|
||||
self::Form => 'Formular',
|
||||
self::WhatsApp => 'WhatsApp',
|
||||
self::Chat => 'Chat',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What a message may cause (V2.1). No effect creates a case, a reservation, an offer or a booking.
|
||||
*/
|
||||
enum MessageEffect: string implements HasLabel
|
||||
{
|
||||
case AnswerInformation = 'answer_information';
|
||||
case ContributeFacts = 'contribute_facts';
|
||||
case ReportToCase = 'report_to_case';
|
||||
case HandoffInquiry = 'handoff_inquiry';
|
||||
case Review = 'review';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::AnswerInformation => 'allgemeine Auskunft geben',
|
||||
self::ContributeFacts => 'Angaben für den Vorgang vorschlagen',
|
||||
self::ReportToCase => 'Aufgabe am Vorgang anlegen',
|
||||
self::HandoffInquiry => 'auf den Anfrageweg verweisen',
|
||||
self::Review => 'zur Klärung vorlegen',
|
||||
};
|
||||
}
|
||||
|
||||
/** Effects that act on an existing case and therefore need a verified assignment. */
|
||||
public function needsCase(): bool
|
||||
{
|
||||
return $this === self::ContributeFacts || $this === self::ReportToCase;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Communication\IntentClassifier;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What a message wants (V2.1) – decided by the rules of {@see IntentClassifier}, independent of the medium.
|
||||
*/
|
||||
enum MessageIntent: string implements HasLabel
|
||||
{
|
||||
case GeneralQuestion = 'general_question';
|
||||
case StayInquiry = 'stay_inquiry';
|
||||
case CaseReply = 'case_reply';
|
||||
case ProvideData = 'provide_data';
|
||||
case ChangeRequest = 'change_request';
|
||||
case Unclear = 'unclear';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::GeneralQuestion => 'allgemeine Frage',
|
||||
self::StayInquiry => 'Anfrage zu einem Aufenthalt',
|
||||
self::CaseReply => 'Antwort in einem Vorgang',
|
||||
self::ProvideData => 'Angaben zu einem Vorgang',
|
||||
self::ChangeRequest => 'Änderungswunsch',
|
||||
self::Unclear => 'unklar',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,13 @@ enum ProcessSetting: string
|
||||
case DataRequestReminderHours = 'data_request_reminder_hours';
|
||||
case GuestLinkValidDays = 'guest_link_valid_days';
|
||||
case FormRequiresAddress = 'form_requires_address';
|
||||
case ContractDelivery = 'contract_delivery';
|
||||
case BookingNotice = 'booking_notice';
|
||||
case AwaitPortalConfirmation = 'await_portal_confirmation';
|
||||
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).
|
||||
@@ -46,6 +53,12 @@ public function default(): string|int|bool|null
|
||||
self::DataRequestReminderHours => 24,
|
||||
self::GuestLinkValidDays => 14,
|
||||
self::FormRequiresAddress => false,
|
||||
self::ContractDelivery => ContractDelivery::Follow->value,
|
||||
self::BookingNotice => BookingNoticeMode::Off->value,
|
||||
self::AwaitPortalConfirmation => false,
|
||||
self::PortalConfirmationWaitHours => 48,
|
||||
// Not set: derived (ProcessSettings) – the answer from the reservation, the senders from guest_messages.
|
||||
self::InquiryAnswer, self::ArrivalInfoSender, self::ReviewRequestSender => null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -71,6 +84,13 @@ public function question(): string
|
||||
self::DataRequestReminderHours => 'Nach wie vielen Stunden ohne Antwort wird erinnert?',
|
||||
self::GuestLinkValidDays => 'Wie lange gilt der Link, über den der Gast Angaben ergänzt?',
|
||||
self::FormRequiresAddress => 'Muss die vollständige Anschrift schon im Anfrageformular der Webseite angegeben werden?',
|
||||
self::ContractDelivery => 'Was geschieht mit dem Vertragsdokument einer verbindlichen Buchung?',
|
||||
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::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?',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,9 +102,10 @@ public function question(): string
|
||||
public function channelIntakes(): array
|
||||
{
|
||||
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::Documents => [IntakeKind::Booking],
|
||||
self::Documents, self::ContractDelivery, self::BookingNotice, self::AwaitPortalConfirmation, self::PortalConfirmationWaitHours => [IntakeKind::Booking],
|
||||
self::ArrivalInfoDaysBefore, self::GuestLinkValidDays => [],
|
||||
self::ClarificationHoldAutoMinutes, self::ClarificationHoldManualMinutes, self::FormRequiresAddress => [IntakeKind::Inquiry],
|
||||
self::DataRequest, self::DataRequestRemindersMax, self::DataRequestFollowupsMax, self::DataRequestReminderHours => [IntakeKind::Inquiry, IntakeKind::Booking],
|
||||
@@ -96,7 +117,7 @@ public function channelIntakes(): array
|
||||
*/
|
||||
public function isLandlordSetting(): bool
|
||||
{
|
||||
return $this !== self::ContractTemplate;
|
||||
return ! in_array($this, [self::ContractTemplate, self::InquiryAnswer], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,13 +131,16 @@ public function normalize(mixed $value): string|int|bool|null
|
||||
|
||||
return match ($this) {
|
||||
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::PreReservation, self::FormRequiresAddress => is_bool($value) ? $value : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE),
|
||||
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::HoldHours, self::ArrivalInfoDaysBefore, self::ContractTemplate => is_numeric($value) ? (int) $value : null,
|
||||
self::DataRequest => ($value instanceof DataRequestMode ? $value : DataRequestMode::tryFrom((string) $value))?->value,
|
||||
self::ContractDelivery => ($value instanceof ContractDelivery ? $value : ContractDelivery::tryFrom((string) $value))?->value,
|
||||
self::BookingNotice => ($value instanceof BookingNoticeMode ? $value : BookingNoticeMode::tryFrom((string) $value))?->value,
|
||||
// 0 is a value of its own: no clarification hold, no reminder, no follow-up question.
|
||||
self::ClarificationHoldAutoMinutes, self::ClarificationHoldManualMinutes, self::DataRequestRemindersMax, self::DataRequestFollowupsMax => is_numeric($value) ? max(0, (int) $value) : null,
|
||||
self::DataRequestReminderHours, self::GuestLinkValidDays => is_numeric($value) ? max(1, (int) $value) : null,
|
||||
self::DataRequestReminderHours, self::GuestLinkValidDays, self::PortalConfirmationWaitHours => is_numeric($value) ? max(1, (int) $value) : null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -127,7 +151,8 @@ public function describe(string|int|bool|null $value): string
|
||||
{
|
||||
return match ($this) {
|
||||
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::HoldHours => $value.' Stunden',
|
||||
self::ArrivalInfoDaysBefore => $value.' Tage vor Anreise',
|
||||
@@ -139,6 +164,10 @@ public function describe(string|int|bool|null $value): string
|
||||
self::DataRequestReminderHours => 'nach '.$value.' Stunden',
|
||||
self::GuestLinkValidDays => $value.' Tage',
|
||||
self::FormRequiresAddress => $value ? 'ja, Pflichtangabe' : 'nein, kann nachgefragt werden',
|
||||
self::ContractDelivery => ContractDelivery::tryFrom((string) $value)?->getLabel() ?? '–',
|
||||
self::BookingNotice => BookingNoticeMode::tryFrom((string) $value)?->getLabel() ?? '–',
|
||||
self::AwaitPortalConfirmation => $value ? 'ja, erst nach der Bestätigungsmail' : 'nein',
|
||||
self::PortalConfirmationWaitHours => $value.' Stunden',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
namespace App\Filament\Forms;
|
||||
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Enums\ContractDelivery;
|
||||
use App\Enums\DataRequestMode;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
@@ -37,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.'),
|
||||
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::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::ContractTemplate => Select::make($name)
|
||||
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
|
||||
@@ -49,6 +53,13 @@ public static function field(string $name, ProcessSetting $setting, string $inhe
|
||||
ProcessSetting::DataRequestRemindersMax, ProcessSetting::DataRequestFollowupsMax => TextInput::make($name)->integer()->minValue(0)->maxValue(5)->placeholder($placeholder),
|
||||
ProcessSetting::DataRequestReminderHours => TextInput::make($name)->integer()->minValue(1)->maxValue(336)->suffix('Stunden')->placeholder($placeholder),
|
||||
ProcessSetting::GuestLinkValidDays => TextInput::make($name)->integer()->minValue(1)->maxValue(60)->suffix('Tage')->placeholder($placeholder),
|
||||
ProcessSetting::ContractDelivery => Select::make($name)->options(ContractDelivery::class)->placeholder($placeholder)
|
||||
->helperText('Erstellen und Ablegen sind vom Versand getrennt. Ein nur intern abgelegter Vertrag gilt nicht als gesendet. Gilt für extern verbindliche Buchungen, bei denen wir die Vertragsunterlagen übernehmen.'),
|
||||
ProcessSetting::BookingNotice => Select::make($name)->options(BookingNoticeMode::class)->placeholder($placeholder)
|
||||
->helperText('Eine kurze Information über die Buchung – unabhängig vom Vertrag. Das Portal bleibt für seine eigenen Nachrichten zuständig.'),
|
||||
ProcessSetting::AwaitPortalConfirmation => Select::make($name)->options(['1' => 'Ja – Unterlagen und Nachrichten warten auf die Bestätigungsmail des Portals', '0' => 'Nein – sofort bearbeiten'])->placeholder($placeholder)
|
||||
->helperText('Die Belegung ist von Anfang an gesichert; es wartet nur, was Sie hier einstellen. Bleibt die Mail aus, erhalten Sie eine Aufgabe.'),
|
||||
ProcessSetting::PortalConfirmationWaitHours => TextInput::make($name)->integer()->minValue(1)->maxValue(720)->suffix('Stunden')->placeholder($placeholder),
|
||||
ProcessSetting::FormRequiresAddress => Select::make($name)->options(['1' => 'Ja – ohne vollständige Anschrift kann nicht angefragt werden', '0' => 'Nein – fehlt sie, wird beim Gast nachgefragt'])->placeholder($placeholder),
|
||||
})->label($setting->question());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\UserRole;
|
||||
@@ -112,7 +113,9 @@ public static function where(ProcessSetting $setting): string
|
||||
public static function answer(ProcessProfile $profile): string
|
||||
{
|
||||
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::Internal => 'keine – eigene Belegung',
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\DocumentKind;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\Responsibility;
|
||||
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')
|
||||
->icon(Heroicon::OutlinedPaperAirplane)
|
||||
->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')
|
||||
->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')
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Actions\RecordPortalAmounts;
|
||||
use App\Actions\RequestCaseData;
|
||||
use App\Actions\SendBookingDocuments;
|
||||
use App\Actions\SendBookingNotice;
|
||||
use App\Actions\SendOffer;
|
||||
use App\Actions\SetBookingStatus;
|
||||
use App\Documents\OfferTerms;
|
||||
@@ -18,12 +19,14 @@
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\AdminMode;
|
||||
use App\Enums\AmountKind;
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\ChangeBasis;
|
||||
use App\Enums\ChangeStatus;
|
||||
use App\Enums\DocumentKind;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\InternalKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
@@ -50,6 +53,8 @@
|
||||
use App\Process\CaseAutomation;
|
||||
use App\Process\CaseLog;
|
||||
use App\Process\CaseRequirements;
|
||||
use App\Process\PortalConfirmation;
|
||||
use App\Process\ProcessRunner;
|
||||
use App\Support\Countries;
|
||||
use App\Support\Money;
|
||||
use Carbon\CarbonImmutable;
|
||||
@@ -141,6 +146,8 @@ protected function getHeaderActions(): array
|
||||
$this->confirmAction(),
|
||||
$this->sendDocumentsAction(),
|
||||
$this->resendConfirmationAction(),
|
||||
$this->confirmPortalAction(),
|
||||
$this->sendBookingNoticeAction(),
|
||||
$this->portalPriceAction(),
|
||||
$this->changeAction(),
|
||||
$this->confirmPortalCancellationAction(),
|
||||
@@ -184,7 +191,7 @@ private function sendOfferAction(): Action
|
||||
return Action::make('sendOffer')
|
||||
->label(fn (): string => match (true) {
|
||||
$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',
|
||||
})
|
||||
->icon(Heroicon::OutlinedPaperAirplane)
|
||||
@@ -492,6 +499,50 @@ private function confirmAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* V2.1: the landlord states that the portal confirmed the booking (e.g. seen in the portal's own interface). The steps that
|
||||
* wait for it go on; the booking itself was binding from the start.
|
||||
*/
|
||||
private function confirmPortalAction(): Action
|
||||
{
|
||||
return Action::make('confirmPortal')
|
||||
->label('Bestätigung des Portals festhalten')
|
||||
->icon(Heroicon::OutlinedCheckBadge)
|
||||
->visible(fn (): bool => $this->record->isBinding() && $this->record->process()->awaitsPortalConfirmation() && PortalConfirmation::evidence($this->record) === null)
|
||||
->modalDescription('Das Portal hat die Buchung bestätigt (z. B. in seiner Oberfläche gesehen). Unterlagen und Nachrichten, die darauf warten, gehen dann weiter. Die Buchung bleibt wie sie ist.')
|
||||
->schema([Textarea::make('note')->label('Woran haben Sie das gesehen?')->rows(2)->maxLength(500)])
|
||||
->action(function (array $data): void {
|
||||
PortalConfirmation::confirm($this->record, CaseLog::actor(), $data['note'] ?? null);
|
||||
app(ProcessRunner::class)->advance($this->record->fresh(), 'portal.mail');
|
||||
$this->record->refresh();
|
||||
Notification::make()->title('Bestätigung festgehalten')->success()->send();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* V2.1: the short booking information to the guest, sent by hand (also where the automatic dispatch is off).
|
||||
*/
|
||||
private function sendBookingNoticeAction(): Action
|
||||
{
|
||||
return Action::make('sendBookingNotice')
|
||||
->label('Buchungsinformation an den Gast senden')
|
||||
->icon(Heroicon::OutlinedEnvelope)
|
||||
->visible(fn (): bool => $this->record->isBinding() && $this->record->process()->bookingNotice() !== BookingNoticeMode::Off && ! SendBookingNotice::sent($this->record) && filled($this->record->guest?->email))
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Der Gast erhält eine kurze Information über seine Buchung – ohne Vertrag.')
|
||||
->action(function (SendBookingNotice $notice): void {
|
||||
try {
|
||||
$notice->handle($this->record->fresh());
|
||||
} catch (ReservationException $exception) {
|
||||
Notification::make()->title('Nicht gesendet')->body($exception->getMessage())->danger()->send();
|
||||
|
||||
return;
|
||||
}
|
||||
$this->record->refresh();
|
||||
Notification::make()->title('Buchungsinformation gesendet')->success()->send();
|
||||
});
|
||||
}
|
||||
|
||||
private function resendConfirmationAction(): Action
|
||||
{
|
||||
return Action::make('resendConfirmation')
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
use App\Pricing\CaseMoney;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Process\CaseAutomation;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use App\Process\ProcessPlan;
|
||||
use App\Process\ProcessProfile;
|
||||
use App\Support\Money;
|
||||
use Carbon\CarbonImmutable;
|
||||
@@ -121,6 +123,7 @@ public static function configure(Schema $schema): Schema
|
||||
->schema([
|
||||
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('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('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(),
|
||||
@@ -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>');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$profile = $booking->process();
|
||||
|
||||
@@ -3,18 +3,32 @@
|
||||
namespace App\Filament\Resources\Channels\Pages;
|
||||
|
||||
use App\Actions\ConfigureChannelProcess;
|
||||
use App\Communication\CommunicationRules;
|
||||
use App\Enums\AdminMode;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\Medium;
|
||||
use App\Enums\MessageEffect;
|
||||
use App\Enums\MessageIntent;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Filament\Resources\Channels\ChannelResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\User;
|
||||
use App\Process\Capability;
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\ChannelProcessConfiguration;
|
||||
use App\Process\ConfigurationImpact;
|
||||
use App\Process\Models\ProcessModel;
|
||||
use App\Process\ProcessBlocks;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use App\Process\ProcessLanes;
|
||||
use App\Process\ProcessProfile;
|
||||
use App\Process\ProcessSettings;
|
||||
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\Notifications\Notification;
|
||||
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
||||
@@ -41,27 +55,115 @@ class ChannelProcess extends Page
|
||||
|
||||
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 = [];
|
||||
|
||||
/** @var array<string, string> capability key => '1' | '0' | '' (unknown); saving confirms what is shown */
|
||||
public array $capabilityDraft = [];
|
||||
|
||||
/** The landlord confirmed that stored settings the chosen model overrides are removed. */
|
||||
public bool $acknowledge = false;
|
||||
|
||||
/** The business block opened in the detail panel ('' = none). */
|
||||
public string $block = '';
|
||||
|
||||
public function mount(int|string $record): void
|
||||
{
|
||||
$this->record = $this->resolveRecord($record);
|
||||
$configuration = app(ChannelProcessConfiguration::class);
|
||||
foreach ($configuration->intakes($this->record) as $intake) {
|
||||
$current = $configuration->current($this->record, $intake);
|
||||
$stored = (array) (($this->record->process_overrides ?? [])[$intake->value] ?? []);
|
||||
$models = $configuration->admissibleModels($this->record, $intake);
|
||||
$model = array_key_exists($current['model'], $models) || $models === [] ? $current['model'] : (string) array_key_first($models);
|
||||
$this->drafts[$intake->value] = [
|
||||
'model' => $model,
|
||||
'variant' => $current['variant'],
|
||||
'steps' => (array) ($stored['steps'] ?? []),
|
||||
'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'],
|
||||
];
|
||||
$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] ?? []);
|
||||
|
||||
return [
|
||||
'model' => $current['model'],
|
||||
'variant' => $current['variant'],
|
||||
'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())))),
|
||||
'derived' => $current['derived'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function draft(): array
|
||||
{
|
||||
return [...$this->drafts[$this->intake], 'capabilities' => $this->capabilityDraft];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, Capability>
|
||||
*/
|
||||
public function capabilities(): array
|
||||
{
|
||||
return app(ChannelCapabilities::class)->resolve($this->record, $this->capabilityDraft);
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
@@ -92,18 +194,200 @@ public function question(): string
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, ProcessModel>
|
||||
* Every model of this intake kind with whether the channel fits it and why not.
|
||||
*
|
||||
* @return array<string, array{model: ProcessModel, admissible: bool, restrictions: list<Restriction>, hints: list<string>}>
|
||||
*/
|
||||
public function models(): array
|
||||
{
|
||||
return app(ChannelProcessConfiguration::class)->admissibleModels($this->record, IntakeKind::from($this->intake));
|
||||
return app(ChannelProcessConfiguration::class)->modelOptions($this->record, IntakeKind::from($this->intake), $this->capabilityDraft);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stored settings the chosen model would silently override.
|
||||
*
|
||||
* @return list<array{setting: ProcessSetting, stored: string, fixed: string, text: string}>
|
||||
*/
|
||||
public function conflicts(): array
|
||||
{
|
||||
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
|
||||
{
|
||||
if (! ($this->models()[$model]['admissible'] ?? false)) {
|
||||
return;
|
||||
}
|
||||
$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]['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
|
||||
@@ -113,7 +397,75 @@ public function model(): ProcessModel
|
||||
|
||||
public function profile(): ProcessProfile
|
||||
{
|
||||
return app(ChannelProcessConfiguration::class)->profileWith($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]);
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,13 +481,26 @@ public function steps(): array
|
||||
$profile = $this->profile();
|
||||
$draft = $this->drafts[$this->intake];
|
||||
|
||||
return array_map(function (array $row) use ($configuration, $catalogue, $model, $profile): array {
|
||||
$rows = $configuration->preview($this->record, IntakeKind::from($this->intake), $this->draft());
|
||||
$labels = collect($rows)->mapWithKeys(fn (array $row): array => [$row['module'] => $row['label']]);
|
||||
$active = collect($rows)->where('on', true)->pluck('module')->all();
|
||||
|
||||
return array_map(function (array $row) use ($configuration, $catalogue, $model, $profile, $labels, $active): array {
|
||||
$definition = $catalogue->modules()[$row['module']]::definition();
|
||||
// The view of the order is derived from the same definitions the runner uses: only dependencies present in the plan count.
|
||||
$needs = collect($definition->requires)->filter(fn ($dependency): bool => $dependency->hard && in_array($dependency->module, $active, true))->map(fn ($dependency): string => $labels[$dependency->module])->values()->all();
|
||||
$after = collect($definition->requires)->filter(fn ($dependency): bool => ! $dependency->hard && in_array($dependency->module, $active, true))->map(fn ($dependency): string => $labels[$dependency->module])->values()->all();
|
||||
$controls = ChannelProcessConfiguration::STEP_CONTROLS[$row['module']] ?? [];
|
||||
$parameters = array_values(array_filter($controls['parameters'] ?? [], fn (ProcessSetting $setting): bool => in_array(IntakeKind::from($this->intake), $setting->channelIntakes(), true) && ! $model::fixesSetting($setting) && ($this->expert() || in_array($setting, [ProcessSetting::HoldHours, ProcessSetting::DataRequestReminderHours, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ClarificationHoldAutoMinutes], true))));
|
||||
$parameters = array_values(array_filter($controls['parameters'] ?? [], fn (ProcessSetting $setting): bool => in_array(IntakeKind::from($this->intake), $setting->channelIntakes(), true) && ! $model::fixesSetting($setting) && ($this->expert() || in_array($setting, [ProcessSetting::HoldHours, ProcessSetting::DataRequestReminderHours, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ClarificationHoldAutoMinutes, ProcessSetting::ContractDelivery, ProcessSetting::BookingNotice, ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours], true))));
|
||||
|
||||
return [...$row,
|
||||
'purpose' => $definition->purpose,
|
||||
'needs' => $needs,
|
||||
'after' => $after,
|
||||
'condition' => $definition->condition,
|
||||
'why' => $definition->why,
|
||||
'executions' => array_map(fn (Execution $execution): string => $execution->getLabel(), $definition->executions),
|
||||
'triggers' => $definition->triggers,
|
||||
'waits' => $definition->waits,
|
||||
'optional' => $definition->isOptional(),
|
||||
'version' => $catalogue->modules()[$row['module']]::version(),
|
||||
@@ -143,9 +508,9 @@ public function steps(): array
|
||||
'mode_options' => $configuration->modeOptions($row['module']),
|
||||
'performer_setting' => isset($controls['performer']) ? $controls['performer']['setting'] : null,
|
||||
'performer_options' => $configuration->performerOptions($model, $row['module']),
|
||||
'parameters' => array_map(fn (ProcessSetting $setting): array => $this->setting($setting, $profile), $parameters),
|
||||
'parameters' => array_map(fn (ProcessSetting $setting): array => [...$this->setting($setting, $profile), 'options' => $configuration->settingOptions($setting)], $parameters),
|
||||
];
|
||||
}, $configuration->preview($this->record, IntakeKind::from($this->intake), $draft));
|
||||
}, $rows);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +547,17 @@ public function toggleStep(string $module): void
|
||||
*/
|
||||
public function problems(): array
|
||||
{
|
||||
return app(ChannelProcessConfiguration::class)->problems($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]);
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,13 +575,17 @@ public function runningCases(): int
|
||||
public function save(): void
|
||||
{
|
||||
try {
|
||||
$this->record = app(ConfigureChannelProcess::class)->handle($this->record, IntakeKind::from($this->intake), $this->drafts[$this->intake]);
|
||||
$this->record = app(ConfigureChannelProcess::class)->handle($this->record, IntakeKind::from($this->intake), $this->draft(), acknowledgeConflicts: $this->acknowledge);
|
||||
} catch (ValidationException $exception) {
|
||||
Notification::make()->title('Nicht gespeichert')->body(collect($exception->errors())->flatten()->implode(' '))->danger()->persistent()->send();
|
||||
|
||||
return;
|
||||
}
|
||||
$this->drafts[$this->intake]['derived'] = false;
|
||||
$this->acknowledge = false;
|
||||
$intake = $this->intake;
|
||||
$this->mount($this->record->getKey());
|
||||
$this->intake = $intake;
|
||||
$running = $this->runningCases();
|
||||
Notification::make()->title('Ablauf gespeichert')->body('Gilt für neue Vorgänge.'.($running > 0 ? ' '.$running.' laufende Vorgänge behalten ihren bisherigen Ablauf.' : ''))->success()->send();
|
||||
}
|
||||
@@ -216,7 +595,7 @@ public function save(): void
|
||||
*/
|
||||
public function test(): void
|
||||
{
|
||||
session()->put('process-tester.draft.'.$this->record->id.'.'.$this->intake, $this->drafts[$this->intake]);
|
||||
session()->put('process-tester.draft.'.$this->record->id.'.'.$this->intake, $this->draft());
|
||||
$this->redirect(ChannelResource::getUrl('test', ['record' => $this->record, 'intake' => $this->intake]));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public function mount(int|string $record): void
|
||||
if ($this->draft === []) {
|
||||
$current = app(ChannelProcessConfiguration::class)->current($this->record, IntakeKind::from($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->resetInputs();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Booking;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Address;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* A short booking information for the guest of a binding booking – without contract and without attachment
|
||||
* (V2.1 „Buchungsinformation“, independent of the contract documentation). Working draft like the other guest texts:
|
||||
* it only goes out automatically where the landlord chose that for the channel.
|
||||
*/
|
||||
class BookingNotice extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public function __construct(public Booking $booking) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Ihre Buchung '.($this->booking->portal_reference ?? $this->booking->reference),
|
||||
replyTo: [new Address(config('fewo.owner.email'), config('fewo.owner.name'))],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(markdown: 'mail.booking-notice');
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
* to a case only by a reliable reference (CH-13); otherwise it waits in the inbox for the landlord. Being assigned is
|
||||
* not yet permission to take anything over.
|
||||
*/
|
||||
#[Fillable(['mailbox_id', 'message_id', 'in_reply_to', 'references', 'from_address', 'from_name', 'to_addresses', 'subject', 'body', 'received_at', 'test_mode', 'status', 'booking_id', 'match_reason', 'hints', 'portal_email_id', 'extraction_status', 'extraction', 'processed_at'])]
|
||||
#[Fillable(['mailbox_id', 'message_id', 'medium', 'intent', 'decision', 'in_reply_to', 'references', 'from_address', 'from_name', 'to_addresses', 'subject', 'body', 'received_at', 'test_mode', 'status', 'booking_id', 'match_reason', 'hints', 'portal_email_id', 'extraction_status', 'extraction', 'processed_at'])]
|
||||
class InboundMessage extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
@@ -44,6 +44,7 @@ protected function casts(): array
|
||||
'to_addresses' => 'array',
|
||||
'hints' => 'array',
|
||||
'extraction' => 'array',
|
||||
'decision' => 'array',
|
||||
'test_mode' => 'boolean',
|
||||
'received_at' => 'immutable_datetime',
|
||||
'processed_at' => 'immutable_datetime',
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
'channel_stale_after_minutes', 'channel_task_reminder_after_minutes',
|
||||
'reminder_interval_days', 'digest_daily', 'digest_weekly', 'digest_weekday', 'digest_hour', 'digest_sections',
|
||||
'digest_when_empty', 'digest_daily_sent_on', 'digest_weekly_sent_on',
|
||||
'process_defaults', 'document_releases',
|
||||
'process_defaults', 'document_releases', 'communication_rules',
|
||||
])]
|
||||
class Tenant extends Model
|
||||
{
|
||||
@@ -77,6 +77,7 @@ protected function casts(): array
|
||||
'digest_sections' => 'array',
|
||||
'process_defaults' => 'array',
|
||||
'document_releases' => 'array',
|
||||
'communication_rules' => 'array',
|
||||
'digest_when_empty' => 'boolean',
|
||||
'digest_daily_sent_on' => 'immutable_date',
|
||||
'digest_weekly_sent_on' => 'immutable_date',
|
||||
|
||||
@@ -28,6 +28,8 @@ final class ActivityDetails
|
||||
'binding' => ['status', 'portal_signal'],
|
||||
'price' => ['price', 'amount'],
|
||||
'documents' => ['document', 'mail'],
|
||||
'booking_notice' => ['booking_notice', 'mail'],
|
||||
'portal_confirmation' => ['portal_confirmation', 'evidence', 'task', 'mail'],
|
||||
'arrival_info' => ['document', 'mail'],
|
||||
'review' => ['mail'],
|
||||
'payment' => ['payment', 'amount'],
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
/**
|
||||
* One capability of a channel with the value in force and where it comes from (docs/Prozessarchitektur/V2.1/02 §3.1).
|
||||
*/
|
||||
final readonly class Capability
|
||||
{
|
||||
public const CONFIRMED = 'confirmed';
|
||||
|
||||
public const DERIVED = 'derived';
|
||||
|
||||
public const SUGGESTED = 'suggested';
|
||||
|
||||
public const UNKNOWN = 'unknown';
|
||||
|
||||
public function __construct(
|
||||
public string $key,
|
||||
public ?bool $value,
|
||||
public string $source,
|
||||
public ?string $note = null,
|
||||
public ?string $confirmedAt = null,
|
||||
public ?string $confirmedBy = null,
|
||||
) {}
|
||||
|
||||
public function isKnown(): bool
|
||||
{
|
||||
return $this->value !== null;
|
||||
}
|
||||
|
||||
public function sourceLabel(): string
|
||||
{
|
||||
return match ($this->source) {
|
||||
self::CONFIRMED => 'bestätigt'.($this->confirmedBy ? ' von '.$this->confirmedBy : '').($this->confirmedAt ? ' am '.substr($this->confirmedAt, 8, 2).'.'.substr($this->confirmedAt, 5, 2).'.'.substr($this->confirmedAt, 0, 4) : ''),
|
||||
self::DERIVED => 'abgeleitet aus Ihrer bisherigen Einstellung'.($this->note ? ' („'.$this->note.'“)' : '').' – bitte bestätigen oder korrigieren',
|
||||
self::SUGGESTED => 'Vorschlag des Kanalprofils – bitte bestätigen',
|
||||
default => 'noch nicht bekannt – bitte bestätigen',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Models\Channel;
|
||||
|
||||
/**
|
||||
* What a portal actually does for the landlord's account (K00 „Kanal-Fähigkeit“, docs/Prozessarchitektur/V2.1/02 §3). The
|
||||
* admissible process models follow from it; the profile of the portal only suggests values. The value in force is, in
|
||||
* this order: confirmed by an administrator · derived from an explicitly stored setting of the channel · suggested by the
|
||||
* channel profile · unknown (blocks nothing, is shown as „please confirm“).
|
||||
*/
|
||||
final class ChannelCapabilities
|
||||
{
|
||||
public const COLLECTS_PAYMENT = 'collects_payment';
|
||||
|
||||
public const PROVIDES_CONTRACT_DOCUMENTS = 'provides_contract_documents';
|
||||
|
||||
public const MESSAGES_GUEST = 'messages_guest';
|
||||
|
||||
public const SENDS_CONFIRMATION_MAIL = 'sends_confirmation_mail';
|
||||
|
||||
/** Older stored settings that imply a capability: capability => [setting, value that means yes, value that means no]. */
|
||||
private const LEGACY = [
|
||||
self::COLLECTS_PAYMENT => ['payments', 'portal', 'landlord'],
|
||||
self::PROVIDES_CONTRACT_DOCUMENTS => ['documents', 'portal', 'landlord'],
|
||||
self::MESSAGES_GUEST => ['guest_messages', 'portal', 'landlord'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<string, array{label: string, question: string}>
|
||||
*/
|
||||
public static function definitions(): array
|
||||
{
|
||||
return [
|
||||
self::COLLECTS_PAYMENT => ['label' => 'Inkasso', 'question' => 'Zieht das Portal das Geld des Gastes ein?'],
|
||||
self::PROVIDES_CONTRACT_DOCUMENTS => ['label' => 'Vertragsunterlagen', 'question' => 'Stellt das Portal dem Gast die verbindlichen Vertragsunterlagen bereit?'],
|
||||
self::MESSAGES_GUEST => ['label' => 'Gastkommunikation', 'question' => 'Schreibt das Portal den Gast an (Anreise-Information, Erinnerungen)?'],
|
||||
self::SENDS_CONFIRMATION_MAIL => ['label' => 'Bestätigungsmail', 'question' => 'Schickt das Portal Ihnen eine Buchungsbestätigung per E-Mail?'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The capabilities of a channel; a draft (key => bool|null) overrides what is stored, to show what a change would do.
|
||||
*
|
||||
* @param array<string, bool|null>|null $draft
|
||||
* @return array<string, Capability>
|
||||
*/
|
||||
public function resolve(Channel $channel, ?array $draft = null): array
|
||||
{
|
||||
$stored = (array) (($channel->settings ?? [])['capabilities'] ?? []);
|
||||
$legacy = (array) (($channel->process_overrides ?? [])['booking'] ?? []);
|
||||
$suggested = (array) (config('channels.portal_profiles.'.app(ChannelProcessConfiguration::class)->profileKey($channel).'.capabilities') ?? []);
|
||||
$result = [];
|
||||
|
||||
foreach (array_keys(self::definitions()) as $key) {
|
||||
if ($draft !== null && array_key_exists($key, $draft) && $draft[$key] !== null && $draft[$key] !== '') {
|
||||
// A value the landlord only left as shown keeps its origin; a changed one is a pending confirmation.
|
||||
$value = filter_var($draft[$key], FILTER_VALIDATE_BOOLEAN);
|
||||
$base = $this->resolve($channel)[$key];
|
||||
if ($base->value !== $value) {
|
||||
$result[$key] = new Capability($key, $value, Capability::CONFIRMED, null, now()->toIso8601String(), auth()->user()?->name);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isset($stored[$key]['value'])) {
|
||||
$result[$key] = new Capability($key, (bool) $stored[$key]['value'], Capability::CONFIRMED, null, $stored[$key]['at'] ?? null, $stored[$key]['by'] ?? null);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (isset(self::LEGACY[$key]) && filled($legacy[self::LEGACY[$key][0]] ?? null)) {
|
||||
[$setting, $yes, $no] = self::LEGACY[$key];
|
||||
$value = (string) $legacy[$setting];
|
||||
if (in_array($value, [$yes, $no], true)) {
|
||||
$result[$key] = new Capability($key, $value === $yes, Capability::DERIVED, $value === $yes ? 'Portal' : 'wir');
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$result[$key] = array_key_exists($key, $suggested) && $suggested[$key] !== null
|
||||
? new Capability($key, (bool) $suggested[$key], Capability::SUGGESTED)
|
||||
: new Capability($key, null, Capability::UNKNOWN);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function value(Channel $channel, string $key): ?bool
|
||||
{
|
||||
return $this->resolve($channel)[$key]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* What is stored to confirm the capabilities of a draft, and the readable list of what changed.
|
||||
*
|
||||
* @param array<string, bool|string|null> $draft
|
||||
* @return array{capabilities: array<string, array{value: bool, at: string, by: ?string}>, changes: list<string>}
|
||||
*/
|
||||
public function confirm(Channel $channel, array $draft, ?string $by): array
|
||||
{
|
||||
$stored = (array) (($channel->settings ?? [])['capabilities'] ?? []);
|
||||
$changes = [];
|
||||
foreach (self::definitions() as $key => $definition) {
|
||||
if (! array_key_exists($key, $draft) || $draft[$key] === null || $draft[$key] === '') {
|
||||
continue;
|
||||
}
|
||||
$value = filter_var($draft[$key], FILTER_VALIDATE_BOOLEAN);
|
||||
if (isset($stored[$key]['value']) && (bool) $stored[$key]['value'] === $value) {
|
||||
continue;
|
||||
}
|
||||
$changes[] = $definition['label'].': '.(isset($stored[$key]['value']) ? ($stored[$key]['value'] ? 'ja' : 'nein').' → ' : '').($value ? 'ja' : 'nein');
|
||||
$stored[$key] = ['value' => $value, 'at' => now()->toIso8601String(), 'by' => $by];
|
||||
}
|
||||
|
||||
return ['capabilities' => $stored, 'changes' => $changes];
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\ContractDelivery;
|
||||
use App\Enums\DataRequestMode;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
@@ -11,6 +14,8 @@
|
||||
use App\Models\Channel;
|
||||
use App\Process\Models\ProcessModel;
|
||||
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
|
||||
@@ -28,14 +33,17 @@ final class ChannelProcessConfiguration
|
||||
public const STEP_CONTROLS = [
|
||||
'guest.details' => ['parameters' => [ProcessSetting::FormRequiresAddress]],
|
||||
'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.information' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::GuestLinkValidDays]],
|
||||
'documents.send' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::ContractTemplate]],
|
||||
'arrival.info' => ['performer' => ['field' => 'guest_messages', 'setting' => ProcessSetting::GuestMessages], 'parameters' => [ProcessSetting::ArrivalInfoDaysBefore]],
|
||||
'documents.send' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::ContractDelivery, ProcessSetting::ContractTemplate]],
|
||||
'documents.booking_notice' => ['parameters' => [ProcessSetting::BookingNotice]],
|
||||
'portal.confirmation' => ['parameters' => [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours]],
|
||||
'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.
|
||||
@@ -79,34 +87,237 @@ public function profileKey(Channel $channel): string
|
||||
}
|
||||
|
||||
/**
|
||||
* The models the landlord may choose for this channel and intake kind.
|
||||
* Every model of the intake kind with whether this channel fits it and – if not – why and what to do (decision
|
||||
* E2/O2 and V2.1 §3.2: the capabilities of the channel decide, not a fixed list of portals).
|
||||
*
|
||||
* @param array<string, bool|string|null>|null $capabilityDraft unsaved capability values of the configurator
|
||||
* @return array<string, array{model: ProcessModel, admissible: bool, restrictions: list<Restriction>, hints: list<string>}>
|
||||
*/
|
||||
public function modelOptions(Channel $channel, IntakeKind $intake, ?array $capabilityDraft = null): array
|
||||
{
|
||||
$capabilities = app(ChannelCapabilities::class)->resolve($channel, $capabilityDraft);
|
||||
$options = [];
|
||||
foreach ($this->catalogue->admissible($intake) as $key => $model) {
|
||||
// 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;
|
||||
}
|
||||
$restrictions = [];
|
||||
$hints = [];
|
||||
foreach ($model::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.';
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($actual->value !== $required) {
|
||||
$fits = collect($this->catalogue->admissible($intake))->first(fn (ProcessModel $other): bool => $other::key() !== $key && collect($other::capabilityRequirements())->every(fn (bool $value, string $name): bool => ($capabilities[$name] ?? null)?->value === $value));
|
||||
$restrictions[] = new Restriction(
|
||||
Restriction::CAPABILITY,
|
||||
$model::label().' setzt voraus: „'.$definition['question'].'“ – '.($required ? 'ja' : 'nein').'. Für diesen Kanal gilt aber '.($actual->value ? 'ja' : 'nein').' ('.$actual->sourceLabel().').',
|
||||
$fits ? $fits::label() : null,
|
||||
'Wenn das nicht stimmt: oben bei „Was kann dieses Portal?“ „'.$definition['label'].'“ auf '.($required ? 'ja' : 'nein').' stellen und bestätigen.',
|
||||
);
|
||||
}
|
||||
}
|
||||
$options[$key] = ['model' => $model, 'admissible' => $restrictions === [], 'restrictions' => $restrictions, 'hints' => $hints];
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* The models the landlord may choose now.
|
||||
*
|
||||
* @param array<string, bool|string|null>|null $capabilityDraft
|
||||
* @return array<string, ProcessModel>
|
||||
*/
|
||||
public function admissibleModels(Channel $channel, IntakeKind $intake): array
|
||||
public function admissibleModels(Channel $channel, IntakeKind $intake, ?array $capabilityDraft = null): array
|
||||
{
|
||||
$allowed = (array) (config('channels.portal_profiles.'.$this->profileKey($channel))[$intake->value] ?? []);
|
||||
return array_map(fn (array $option): ProcessModel => $option['model'], array_filter($this->modelOptions($channel, $intake, $capabilityDraft), fn (array $option): bool => $option['admissible']));
|
||||
}
|
||||
|
||||
return array_filter($this->catalogue->admissible($intake), fn (ProcessModel $model): bool => in_array($model::key(), $allowed, true));
|
||||
/**
|
||||
* 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
|
||||
* 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}>
|
||||
*/
|
||||
public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey, array $templates = []): array
|
||||
{
|
||||
if (! $this->catalogue->hasModel($modelKey)) {
|
||||
return [];
|
||||
}
|
||||
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
|
||||
$conflicts = [];
|
||||
$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);
|
||||
$value = $setting?->normalize($stored[$key] ?? null);
|
||||
$fixedValue = $setting?->normalize($fixed) ?? $fixed;
|
||||
if ($setting === null || $value === null || (string) $value === (string) $fixedValue) {
|
||||
continue;
|
||||
}
|
||||
$conflicts[] = ['setting' => $setting, 'stored' => $setting->describe($value), 'fixed' => $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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
{
|
||||
$config = ProcessPlan::configurationOf($channel, $intake);
|
||||
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;
|
||||
$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' => []];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +337,21 @@ public function performerOptions(ProcessModel $model, string $module): array
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* The fixed choices of a setting that is not free text (null: free input).
|
||||
*
|
||||
* @return array<string, string>|null
|
||||
*/
|
||||
public function settingOptions(ProcessSetting $setting): ?array
|
||||
{
|
||||
return match ($setting) {
|
||||
ProcessSetting::ContractDelivery => collect(ContractDelivery::cases())->mapWithKeys(fn (ContractDelivery $case): array => [$case->value => $case->getLabel()])->all(),
|
||||
ProcessSetting::BookingNotice => collect(BookingNoticeMode::cases())->mapWithKeys(fn (BookingNoticeMode $case): array => [$case->value => $case->getLabel()])->all(),
|
||||
ProcessSetting::AwaitPortalConfirmation => ['1' => 'ja, erst nach der Bestätigungsmail', '0' => 'nein, sofort'],
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed modes of a step (as values of its setting).
|
||||
*
|
||||
@@ -145,26 +371,33 @@ public function modeOptions(string $module): array
|
||||
* 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]
|
||||
* @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
|
||||
{
|
||||
$model = $this->catalogue->model((string) ($draft['model'] ?? $this->current($channel, $intake)['model']));
|
||||
$variant = (string) ($draft['variant'] ?? 'standard');
|
||||
$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 = [];
|
||||
foreach ($model->modules($variant) as $key) {
|
||||
foreach ($model->modules($variant, $templates) as $key) {
|
||||
$class = $this->catalogue->modules()[$key];
|
||||
$definition = $class::definition();
|
||||
$on = ($draft['steps'][$key]['on'] ?? true) !== false || ! $definition->isOptional();
|
||||
$reason = match (true) {
|
||||
! $on => 'im Kanal abgeschaltet',
|
||||
$key === 'hold' && ! $profile->preReservation() => 'keine Vorreservierung in diesem Modell',
|
||||
$key === 'offer.information' && $profile->preReservation() => 'nicht in diesem Modell (verbindliches Angebot)',
|
||||
$key === 'offer.binding' && ! $profile->preReservation() => 'erst, wenn ein Angebot von Hand gesendet wird',
|
||||
$key === 'hold' && ! $profile->preReservation() => 'keine Reservierung bei der Anfrage',
|
||||
$key === 'offer.information' && $profile->inquiryAnswer() === InquiryAnswer::Offer => 'nicht bei verbindlichem Angebot',
|
||||
$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 === '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',
|
||||
default => null,
|
||||
};
|
||||
@@ -172,11 +405,12 @@ public function preview(Channel $channel, IntakeKind $intake, array $draft): arr
|
||||
$performer = match ($key) {
|
||||
'documents.send' => $profile->documents()->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,
|
||||
};
|
||||
$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;
|
||||
@@ -190,16 +424,20 @@ public function preview(Channel $channel, IntakeKind $intake, array $draft): arr
|
||||
*/
|
||||
public function problems(Channel $channel, IntakeKind $intake, array $draft, bool $sandbox = false): array
|
||||
{
|
||||
$draft = $this->withoutOverriddenSettings($channel, $intake, $draft);
|
||||
$problems = [];
|
||||
if (! in_array($intake, $this->intakes($channel), true)) {
|
||||
$problems[] = 'Dieser Kanal liefert keine '.($intake === IntakeKind::Booking ? 'festen Buchungen' : 'Anfragen').'.';
|
||||
}
|
||||
$key = (string) ($draft['model'] ?? '');
|
||||
$models = $this->admissibleModels($channel, $intake);
|
||||
if ($key === '' || ! array_key_exists($key, $models)) {
|
||||
return [...$problems, 'Das Ablaufmodell „'.$key.'“ ist für diesen Kanal nicht zulässig. Zulässig: '.(implode(', ', array_map(fn (ProcessModel $model): string => $model::label(), $models)) ?: 'keines').'.'];
|
||||
$options = $this->modelOptions($channel, $intake, (array) ($draft['capabilities'] ?? []) ?: null);
|
||||
if ($key === '' || ! array_key_exists($key, $options)) {
|
||||
return [...$problems, 'Das Ablaufmodell „'.$key.'“ gibt es für diese Eingangsart dieses Kanals nicht.'];
|
||||
}
|
||||
$model = $models[$key];
|
||||
if (! $options[$key]['admissible']) {
|
||||
return [...$problems, ...array_map(fn (Restriction $restriction): string => $restriction->text(), $options[$key]['restrictions'])];
|
||||
}
|
||||
$model = $options[$key]['model'];
|
||||
$variant = $model->variant((string) ($draft['variant'] ?? 'standard'));
|
||||
if ($variant === null) {
|
||||
return [...$problems, 'Das Modell hat diese Variante nicht.'];
|
||||
@@ -208,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.';
|
||||
}
|
||||
|
||||
$templates = $this->templatesOf($model, $draft);
|
||||
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.";
|
||||
|
||||
continue;
|
||||
@@ -236,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,9 +524,10 @@ public function problems(Channel $channel, IntakeKind $intake, array $draft, boo
|
||||
*/
|
||||
public function profileWith(Channel $channel, IntakeKind $intake, array $draft): ProcessProfile
|
||||
{
|
||||
$draft = $this->withoutOverriddenSettings($channel, $intake, $draft);
|
||||
$preview = clone $channel;
|
||||
$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);
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
return ['pre_reservation' => false];
|
||||
|
||||
@@ -34,6 +34,21 @@ public static function caseTypes(): array
|
||||
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
|
||||
{
|
||||
return ['pre_reservation' => true];
|
||||
@@ -47,6 +62,9 @@ public function variants(): array
|
||||
->testerOnly()
|
||||
->insert(Point::AfterGuestIdentified, 'guest.loyalty_status')
|
||||
->insert(Point::BeforePriceFixing, 'pricing.loyalty_discount'),
|
||||
Variant::make('address_check', 'Angebot mit Anschriftsprüfung (Zusatzschritt, nur im Prozess-Tester)')
|
||||
->testerOnly()
|
||||
->insert(Point::AfterGuestIdentified, 'guest.address_check'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,21 @@ public static function caseTypes(): array
|
||||
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
|
||||
{
|
||||
return ['pre_reservation' => false];
|
||||
|
||||
@@ -35,6 +35,21 @@ public static function caseTypes(): array
|
||||
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
|
||||
{
|
||||
return ['pre_reservation' => true];
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/**
|
||||
* A3 – binding portal booking with our own handling (e.g. Destination Solutions, R08).
|
||||
*/
|
||||
final class A3PortalBookingModel extends PortalBookingModel
|
||||
class A3PortalBookingModel extends PortalBookingModel
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
@@ -17,7 +17,7 @@ public static function key(): string
|
||||
|
||||
public static function version(): int
|
||||
{
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
@@ -35,6 +35,11 @@ public static function caseTypes(): array
|
||||
return [CaseType::A3];
|
||||
}
|
||||
|
||||
public static function capabilityRequirements(): array
|
||||
{
|
||||
return ['collects_payment' => false, 'provides_contract_documents' => false];
|
||||
}
|
||||
|
||||
public static function responsibilities(): Responsibilities
|
||||
{
|
||||
return Responsibilities::of(
|
||||
@@ -43,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
|
||||
{
|
||||
return ['payments' => 'landlord', 'documents' => 'landlord'];
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Models;
|
||||
|
||||
/**
|
||||
* Version 1 (A3, V2) – the course the cases froze before V2.1; stays registered while any case carries it (requirement T3).
|
||||
*/
|
||||
final class A3PortalBookingModelV1 extends A3PortalBookingModel
|
||||
{
|
||||
public static function version(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function steps(): array
|
||||
{
|
||||
return $this->stepsOfVersion1();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
/**
|
||||
* A4 – binding portal booking with shared handling: portal collection, our contract documentation (e.g. FeWo-direkt, R09).
|
||||
*/
|
||||
final class A4PortalBookingModel extends PortalBookingModel
|
||||
class A4PortalBookingModel extends PortalBookingModel
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
@@ -17,7 +17,7 @@ public static function key(): string
|
||||
|
||||
public static function version(): int
|
||||
{
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
@@ -35,6 +35,11 @@ public static function caseTypes(): array
|
||||
return [CaseType::A4];
|
||||
}
|
||||
|
||||
public static function capabilityRequirements(): array
|
||||
{
|
||||
return ['collects_payment' => true, 'provides_contract_documents' => false];
|
||||
}
|
||||
|
||||
public static function responsibilities(): Responsibilities
|
||||
{
|
||||
return Responsibilities::of(
|
||||
@@ -43,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
|
||||
{
|
||||
return ['payments' => 'portal', 'documents' => 'landlord'];
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Models;
|
||||
|
||||
/**
|
||||
* Version 1 (A4, V2) – the course the cases froze before V2.1; stays registered while any case carries it (requirement T3).
|
||||
*/
|
||||
final class A4PortalBookingModelV1 extends A4PortalBookingModel
|
||||
{
|
||||
public static function version(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function steps(): array
|
||||
{
|
||||
return $this->stepsOfVersion1();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
/**
|
||||
* A5 – binding portal booking handled largely by the portal: collection and contract documentation at the portal.
|
||||
*/
|
||||
final class A5PortalBookingModel extends PortalBookingModel
|
||||
class A5PortalBookingModel extends PortalBookingModel
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
@@ -17,7 +17,7 @@ public static function key(): string
|
||||
|
||||
public static function version(): int
|
||||
{
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
@@ -35,6 +35,11 @@ public static function caseTypes(): array
|
||||
return [CaseType::A5];
|
||||
}
|
||||
|
||||
public static function capabilityRequirements(): array
|
||||
{
|
||||
return ['collects_payment' => true, 'provides_contract_documents' => true];
|
||||
}
|
||||
|
||||
public static function responsibilities(): Responsibilities
|
||||
{
|
||||
return Responsibilities::of(
|
||||
@@ -43,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
|
||||
{
|
||||
return ['payments' => 'portal', 'documents' => 'portal'];
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Models;
|
||||
|
||||
/**
|
||||
* Version 1 (A5, V2) – the course the cases froze before V2.1; stays registered while any case carries it (requirement T3).
|
||||
*/
|
||||
final class A5PortalBookingModelV1 extends A5PortalBookingModel
|
||||
{
|
||||
public static function version(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function steps(): array
|
||||
{
|
||||
return $this->stepsOfVersion1();
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,37 @@ public static function intakes(): array
|
||||
return [IntakeKind::Booking];
|
||||
}
|
||||
|
||||
/**
|
||||
* Version 2 (V2.1): waits for the portal's confirmation where the channel says so (before the guest-facing steps; the
|
||||
* occupation does not depend on it) and offers the booking information as a step of its own after the documents.
|
||||
*/
|
||||
public function steps(): array
|
||||
{
|
||||
$course = [];
|
||||
foreach (InquiryModel::bindingCourse() as $step) {
|
||||
$course[] = $step;
|
||||
if ($step->module === 'documents.send') {
|
||||
$course[] = Step::module('documents.booking_notice');
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
...$course,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The course of version 1 (V2), kept for the cases that froze it.
|
||||
*
|
||||
* @return list<Step>
|
||||
*/
|
||||
protected function stepsOfVersion1(): array
|
||||
{
|
||||
return [
|
||||
Step::module('intake.record'),
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\IntakeKind;
|
||||
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
|
||||
@@ -33,6 +35,17 @@ abstract public static function responsibilities(): Responsibilities;
|
||||
/** @return list<Step> */
|
||||
abstract public function steps(): array;
|
||||
|
||||
/**
|
||||
* What a channel must be able to do (and not do) for this model to fit: capability key => required value. Empty:
|
||||
* the model fits every channel that delivers its intake kind (docs/Prozessarchitektur/V2.1/02 §3.2).
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*/
|
||||
public static function capabilityRequirements(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings the model fixes for its cases (e.g. the pre-reservation of the offer model).
|
||||
*
|
||||
@@ -63,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>
|
||||
*/
|
||||
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');
|
||||
$catalogue = app(ProcessCatalogue::class);
|
||||
$modules = [];
|
||||
foreach ($this->steps() as $step) {
|
||||
if ($step->isPoint()) {
|
||||
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 {
|
||||
$modules[] = $step->module;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
@@ -19,8 +22,18 @@ public static function point(Point $point): self
|
||||
return new self(null, $point);
|
||||
}
|
||||
|
||||
public static function slot(TemplateArea $area): self
|
||||
{
|
||||
return new self(null, null, $area);
|
||||
}
|
||||
|
||||
public function isPoint(): bool
|
||||
{
|
||||
return $this->point !== null;
|
||||
}
|
||||
|
||||
public function isSlot(): bool
|
||||
{
|
||||
return $this->slot !== null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Guest;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Dependency;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Modules\StepState;
|
||||
|
||||
/**
|
||||
* V2.1 case H (docs/Prozessarchitektur/V2.1/ABNAHME_V2_1.md): an optional plausibility check of the guest's address, added
|
||||
* at the extension point „after the guest is identified“ without touching any other model. It only informs – the result
|
||||
* never holds back an offer or a booking (the address gate of v0.11 stays the only rule). Tester only until released.
|
||||
*/
|
||||
final class AddressCheck extends Module
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'guest.address_check';
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Anschrift auf Plausibilität prüfen',
|
||||
purpose: 'Prüft, ob die Anschrift des Gastes plausibel aussieht (Postleitzahl, Ort). Es ist ein Hinweis; nichts wird dadurch aufgehalten.',
|
||||
phase: 'P01',
|
||||
requires: [Dependency::hard('guest.details')],
|
||||
triggers: ['facts.applied'],
|
||||
toggle: ModuleDefinition::TOGGLE_OPTIONAL,
|
||||
events: ['facts'],
|
||||
points: ['after_guest_identified'],
|
||||
availability: ModuleDefinition::AVAILABILITY_TESTER_ONLY,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string> what looks implausible (empty: plausible)
|
||||
*/
|
||||
public function findings(CaseContext $case): array
|
||||
{
|
||||
$guest = $case->booking->guest;
|
||||
$findings = [];
|
||||
if (blank($guest?->street)) {
|
||||
$findings[] = 'Straße fehlt';
|
||||
}
|
||||
if (blank($guest?->city)) {
|
||||
$findings[] = 'Ort fehlt';
|
||||
}
|
||||
if (in_array(mb_strtoupper((string) $guest?->country), ['', 'DE', 'DEUTSCHLAND'], true) && ! preg_match('/^\d{5}$/', trim((string) $guest?->postal_code))) {
|
||||
$findings[] = 'Postleitzahl hat nicht fünf Ziffern';
|
||||
}
|
||||
|
||||
return $findings;
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$findings = $this->findings($case);
|
||||
|
||||
return [new Activity('address_check', 'Anschrift auf Plausibilität prüfen', ActivityState::Done, $findings === [] ? 'Anschrift wirkt plausibel' : 'Hinweis: '.implode(', ', $findings))];
|
||||
}
|
||||
|
||||
public function state(CaseContext $case): ?StepState
|
||||
{
|
||||
return StepState::Done;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\Execution;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
@@ -25,6 +26,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Verfügbarkeit',
|
||||
purpose: 'Prüft, ob der Zeitraum frei ist und die Kalender der Portale aktuell sind.',
|
||||
phase: 'P01',
|
||||
executions: [Execution::Automatic],
|
||||
condition: 'bei jeder Anfrage vor Angebot oder Bestätigung',
|
||||
why: 'Doppelbuchungen sind nicht zu verantworten (E-027); die Verfügbarkeit wird immer geprüft.',
|
||||
effects: ['network'],
|
||||
triggers: ['intake', 'facts.applied'],
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\ChannelTaskStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
|
||||
use App\Models\ChannelTask;
|
||||
use App\Process\Activity;
|
||||
@@ -29,6 +30,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Andere Kanäle sperren',
|
||||
purpose: 'Sperrt den Zeitraum in Portalen, die nicht automatisch abgleichen, und gibt ihn bei Ende wieder frei – mit Nachweis je Portal.',
|
||||
phase: 'P02',
|
||||
executions: [Execution::Automatic, Execution::Manual],
|
||||
condition: 'sobald ein Vorgang den Zeitraum belegt',
|
||||
why: 'Die Belegung muss in anderen Portalen nachgezogen werden, sonst droht eine Doppelbuchung.',
|
||||
effects: ['channel_task', 'landlord_mail', 'network'],
|
||||
waits: ['landlord', 'portal'],
|
||||
triggers: ['booking.occupies', 'booking.released'],
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Actions\RequestCaseData;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Models\DataRequest;
|
||||
use App\Process\Activity;
|
||||
@@ -34,6 +35,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Fehlende Angaben beim Gast anfragen',
|
||||
purpose: 'Fragt fehlende Pflichtangaben per Link beim Gast an, erinnert und übergibt an Sie, wenn der Gast nicht antwortet.',
|
||||
phase: 'P01',
|
||||
executions: [Execution::Automatic, Execution::Approval, Execution::Manual, Execution::NotRequired],
|
||||
condition: 'wenn Angaben für den nächsten Schritt fehlen und eine E-Mail-Adresse bekannt ist',
|
||||
requires: [Dependency::hard('intake.record')],
|
||||
effects: ['case_write', 'guest_mail'],
|
||||
waits: ['guest', 'landlord', 'time'],
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Models\DataRequest;
|
||||
@@ -30,6 +32,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Angaben des Gastes',
|
||||
purpose: 'Identifiziert den Gast, führt seine Angaben aus allen Quellen zusammen und prüft, ob alles für den nächsten Schritt da ist.',
|
||||
phase: 'P01',
|
||||
executions: [Execution::Automatic, Execution::Manual],
|
||||
condition: 'wenn wir selbst mit dem Gast schreiben (Anfrage, eigene Unterlagen, Nachrichten oder Zahlung)',
|
||||
why: 'Ohne die Angaben des Gastes entsteht kein eigenes Angebot und keine Unterlage (G2a).',
|
||||
requires: [Dependency::hard('intake.record')],
|
||||
effects: ['case_write'],
|
||||
waits: ['guest', 'landlord'],
|
||||
@@ -45,7 +50,7 @@ public function applies(CaseContext $case): bool
|
||||
{
|
||||
$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
|
||||
@@ -54,7 +59,7 @@ public function activities(CaseContext $case): array
|
||||
$profile = $case->profile;
|
||||
$hasEmail = filled($booking->guest?->email);
|
||||
// v0.11 (G2a): before the own binding offer – or the binding confirmation of a wish – every required detail.
|
||||
$action = $profile->preReservation() || $booking->offer_version > 0 ? CaseRequirements::OFFER : CaseRequirements::WISH_CONFIRMATION;
|
||||
$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);
|
||||
$missing = $hasEmail && $needsDetails ? CaseRequirements::missing($booking, $action) : [];
|
||||
$request = $booking->openDataRequest();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Models\Booking;
|
||||
use App\Process\CaseContext;
|
||||
@@ -29,6 +30,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Reservierung des Zeitraums',
|
||||
purpose: 'Hält den Zeitraum während der Klärung bzw. der Angebotsfrist frei und gibt ihn nach Ablauf wieder frei.',
|
||||
phase: 'P01',
|
||||
executions: [Execution::Automatic],
|
||||
condition: 'bei einer Anfrage, die den Zeitraum reservieren soll',
|
||||
requires: [Dependency::hard('intake.record')],
|
||||
effects: ['calendar_hold'],
|
||||
waits: ['time'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Module;
|
||||
@@ -25,6 +26,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Eingang',
|
||||
purpose: 'Hält den Eingang der Anfrage, Buchung oder Eigenbelegung fest und friert den Ablauf ein.',
|
||||
phase: 'P01',
|
||||
executions: [Execution::Automatic],
|
||||
condition: 'immer, sobald ein Vorgang entsteht',
|
||||
why: 'Ohne Eingang gibt es keinen Vorgang.',
|
||||
effects: ['case_write', 'calendar_hold'],
|
||||
triggers: ['intake'],
|
||||
events: ['created', 'intake', 'profile', 'hold', 'mode'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Dependency;
|
||||
@@ -27,6 +28,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Verbindlichkeit beim Portal',
|
||||
purpose: 'Stellt fest, dass die Buchung beim Portal verbindlich ist, und übernimmt den Gesamtpreis laut Portal.',
|
||||
phase: 'P02',
|
||||
executions: [Execution::Portal, Execution::Manual],
|
||||
condition: 'bei einer Buchung, die beim Portal schon verbindlich ist',
|
||||
why: 'Die Buchung ist beim Portal verbindlich und bleibt es (E-036); der Gesamtpreis laut Portal wird übernommen.',
|
||||
requires: [Dependency::hard('intake.record')],
|
||||
effects: ['case_write'],
|
||||
waits: ['portal', 'landlord'],
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Models\BookingTask;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\CaseLog;
|
||||
use App\Process\Modules\Dependency;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Modules\RunsAutomatically;
|
||||
use App\Process\Modules\StepState;
|
||||
use App\Process\PortalConfirmation;
|
||||
use App\Process\StepResult;
|
||||
|
||||
/**
|
||||
* P02 for extern binding bookings (V2.1, docs/Prozessarchitektur/V2.1/02 §5): waits for the portal's booking confirmation
|
||||
* mail, assigned to the case deterministically, before the steps that depend on it hard (contract documents, booking notice)
|
||||
* go on. The occupation does not wait: the booking is binding from the start and its calendar entries are protected
|
||||
* (binding.portal, channels.block do not depend on this step). Without the mail within the configured time the landlord gets
|
||||
* one task; nothing is sent or released automatically. The landlord can confirm in the case, or send by hand.
|
||||
*/
|
||||
final class PortalConfirmationStep extends Module implements RunsAutomatically
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'portal.confirmation';
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Bestätigung des Portals abwarten',
|
||||
purpose: 'Wartet auf die Bestätigungsmail des Portals, bevor Unterlagen und Nachrichten an den Gast gehen. Die Belegung ist von Anfang an gesichert.',
|
||||
phase: 'P02',
|
||||
why: 'Solange das Portal die Buchung nicht bestätigt hat, sollen keine Unterlagen an den Gast gehen; die Belegung ist trotzdem gesichert.',
|
||||
executions: [Execution::Automatic, Execution::Manual, Execution::NotRequired],
|
||||
condition: 'nur bei extern verbindlicher Buchung und nur, wenn für den Kanal „Bestätigungsmail abwarten“ eingestellt ist',
|
||||
requires: [Dependency::hard('intake.record')],
|
||||
effects: ['case_write'],
|
||||
waits: ['portal', 'time', 'landlord'],
|
||||
triggers: ['portal.mail', 'schedule:waiting', 'booking.taken_over'],
|
||||
parameters: [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours],
|
||||
toggle: ModuleDefinition::TOGGLE_CONDITIONAL,
|
||||
performers: ['portal', 'landlord'],
|
||||
modes: ['automatic'],
|
||||
events: ['portal_confirmation', 'evidence', 'task'],
|
||||
);
|
||||
}
|
||||
|
||||
public function applies(CaseContext $case): bool
|
||||
{
|
||||
return ! $case->inquiry && ! $case->closed && $case->profile->awaitsPortalConfirmation();
|
||||
}
|
||||
|
||||
public function state(CaseContext $case): ?StepState
|
||||
{
|
||||
if (PortalConfirmation::evidence($case->booking) !== null) {
|
||||
return StepState::Done;
|
||||
}
|
||||
|
||||
return PortalConfirmation::isOverdue($case->booking) ? StepState::Problem : StepState::Waiting;
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$evidence = PortalConfirmation::evidence($case->booking);
|
||||
$deadline = PortalConfirmation::deadline($case->booking);
|
||||
|
||||
return [new Activity('portal_confirmation', 'Bestätigung des Portals abwarten', match (true) {
|
||||
$evidence !== null => ActivityState::Done,
|
||||
PortalConfirmation::isOverdue($case->booking) => ActivityState::Problem,
|
||||
default => ActivityState::Waiting,
|
||||
}, match (true) {
|
||||
$evidence !== null => $evidence['label'],
|
||||
PortalConfirmation::isOverdue($case->booking) => 'ausgeblieben seit '.$deadline->format('d.m.Y, H:i').' Uhr – bitte beim Portal prüfen; Unterlagen und Nachrichten warten weiter, bis Sie bestätigen oder von Hand senden',
|
||||
default => 'erwartet bis '.$deadline->format('d.m.Y, H:i').' Uhr – Unterlagen und Nachrichten warten; die Belegung ist gesichert',
|
||||
}, $evidence === null ? 'confirmPortal' : null)];
|
||||
}
|
||||
|
||||
/** Due when the time ran out without the mail: escalate once; or when the mail arrived and the escalation is still open. */
|
||||
public function due(CaseContext $case): bool
|
||||
{
|
||||
$open = $this->openTask($case) !== null;
|
||||
$evidence = PortalConfirmation::evidence($case->booking) !== null;
|
||||
|
||||
return ($evidence && $open) || (! $evidence && ! $open && PortalConfirmation::isOverdue($case->booking));
|
||||
}
|
||||
|
||||
public function blockers(CaseContext $case): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function run(CaseContext $case): StepResult
|
||||
{
|
||||
$task = $this->openTask($case);
|
||||
if (PortalConfirmation::evidence($case->booking) !== null) {
|
||||
$task?->complete(CaseLog::SYSTEM, 'Die Bestätigung des Portals liegt jetzt vor.');
|
||||
|
||||
return StepResult::ran();
|
||||
}
|
||||
|
||||
BookingTask::openOnce($case->booking, BookingTaskKind::PortalConfirmationMissing, 'portal-confirmation', [
|
||||
'due_on' => today(),
|
||||
'note' => 'Die Bestätigungsmail des Portals ist bis '.PortalConfirmation::deadline($case->booking)->format('d.m.Y, H:i').' Uhr nicht eingegangen. Die Belegung ist gesichert. Bitte beim Portal prüfen und im Vorgang bestätigen – oder die Unterlagen von Hand senden.',
|
||||
]);
|
||||
CaseLog::record($case->booking, 'task', 'Bestätigungsmail des Portals fehlt – Aufgabe angelegt', actor: CaseLog::SYSTEM);
|
||||
|
||||
return StepResult::ran();
|
||||
}
|
||||
|
||||
public function isOutward(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private function openTask(CaseContext $case): ?BookingTask
|
||||
{
|
||||
return BookingTask::query()->where('booking_id', $case->booking->id)->where('kind', BookingTaskKind::PortalConfirmationMissing)->where('status', BookingTaskStatus::Open)->first();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Process\Modules;
|
||||
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,9 @@
|
||||
* @param list<string> $events history types that belong to the step (shown behind the step)
|
||||
* @param list<string> $points extension points the module may be inserted at (checked; empty = fixed place in a model)
|
||||
* @param bool $readsContractData evaluates frozen contract data – needs an ongoing-case test (checked)
|
||||
* @param list<Execution> $executions the admissible ways to fulfil the task (V2.1; the model may narrow them)
|
||||
* @param string|null $condition when the step applies, in plain words (DESCRIBES – the logic is `applies()`, never read from here)
|
||||
* @param string|null $why why the task is mandatory, shown instead of a lock
|
||||
*/
|
||||
public function __construct(
|
||||
public string $label,
|
||||
@@ -58,6 +62,9 @@ public function __construct(
|
||||
public array $points = [],
|
||||
public bool $readsContractData = false,
|
||||
public string $availability = self::AVAILABILITY_PRODUCTION,
|
||||
public array $executions = [],
|
||||
public ?string $condition = null,
|
||||
public ?string $why = null,
|
||||
) {}
|
||||
|
||||
public function isOptional(): bool
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Money;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Module;
|
||||
@@ -25,6 +26,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Zahlung (ohne Erinnerungen)',
|
||||
purpose: 'Hält fest, was bei einer Eigenbelegung oder privaten Überlassung bezahlt wurde – ohne Erinnerungen.',
|
||||
phase: 'P03',
|
||||
executions: [Execution::Manual],
|
||||
condition: 'bei einer Eigenbelegung mit Preis',
|
||||
effects: ['case_write'],
|
||||
toggle: ModuleDefinition::TOGGLE_CONDITIONAL,
|
||||
performers: ['landlord'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Money;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Process\Activity;
|
||||
@@ -28,6 +29,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Zahlungen des Gastes',
|
||||
purpose: 'Überwacht Anzahlung und Restzahlung und erinnert rechtzeitig – oder zeigt, was das Portal laut eigener Angabe eingezogen hat.',
|
||||
phase: 'P03',
|
||||
executions: [Execution::Manual, Execution::Portal],
|
||||
condition: 'bei jeder verbindlichen Buchung',
|
||||
why: 'Zahlungen werden überwacht – von uns oder durch das Portal (nur „laut Portal“).',
|
||||
effects: ['case_write', 'guest_mail'],
|
||||
waits: ['guest', 'portal', 'time'],
|
||||
triggers: ['payment.recorded', 'portal.amounts', 'schedule:reminders'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Money;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Pricing\CaseMoney;
|
||||
use App\Process\Activity;
|
||||
@@ -28,6 +29,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Auszahlung des Portals',
|
||||
purpose: 'Prüft, ob die Auszahlung des Portals tatsächlich auf unserem Konto eingegangen ist und zu den Angaben passt.',
|
||||
phase: 'P03',
|
||||
executions: [Execution::Manual],
|
||||
condition: 'wenn das Portal das Geld einzieht',
|
||||
why: 'Die Auszahlung muss tatsächlich auf unserem Konto eingehen (O5).',
|
||||
effects: ['case_write'],
|
||||
waits: ['portal', 'landlord', 'time'],
|
||||
triggers: ['portal.amounts', 'payment.recorded'],
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Process\Activity;
|
||||
@@ -41,6 +43,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Verbindliches Angebot',
|
||||
purpose: 'Erstellt das verbindliche Angebot mit Vertragsentwurf und sendet es dem Gast; der Zeitraum ist für die Haltefrist reserviert.',
|
||||
phase: 'P02',
|
||||
executions: [Execution::Automatic, Execution::Manual],
|
||||
condition: 'bei einer Anfrage mit Reservierung',
|
||||
why: 'Ohne verbindliches Angebot gibt es auf eigenem Weg keinen Vertrag (E-003).',
|
||||
requires: [Dependency::hard('guest.details'), Dependency::hard('availability.check'), Dependency::soft('guest.data_request')],
|
||||
effects: ['case_write', 'guest_mail', 'landlord_mail', 'document', 'calendar_hold', 'network'],
|
||||
waits: ['guest', 'landlord'],
|
||||
@@ -55,7 +60,7 @@ public static function definition(): ModuleDefinition
|
||||
/** The binding way: the request reserves (pre-reservation) or an offer was made anyway. */
|
||||
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
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Process\Activity;
|
||||
@@ -32,6 +34,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Unverbindliche Auskunft und Buchungswunsch',
|
||||
purpose: 'Beantwortet die Anfrage mit einer unverbindlichen Auskunft ohne Reservierung; fragt der Gast die Buchung an, wird erneut geprüft und verbindlich bestätigt.',
|
||||
phase: 'P02',
|
||||
why: 'Der Gast braucht eine Antwort auf seine Anfrage; ob sie automatisch oder von Hand kommt, bestimmen Sie.',
|
||||
executions: [Execution::Automatic, Execution::Manual],
|
||||
condition: 'bei einer Anfrage ohne Reservierung',
|
||||
requires: [Dependency::hard('intake.record'), Dependency::soft('guest.data_request')],
|
||||
effects: ['case_write', 'guest_mail', 'landlord_mail', 'document'],
|
||||
waits: ['guest', 'landlord'],
|
||||
@@ -45,7 +50,7 @@ public static function definition(): ModuleDefinition
|
||||
|
||||
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
|
||||
|
||||
@@ -27,6 +27,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Annahme durch den Gast',
|
||||
purpose: 'Der Gast nimmt das Angebot an oder lehnt es ab; mit der Annahme wird die Buchung verbindlich.',
|
||||
phase: 'P02',
|
||||
executions: [],
|
||||
condition: 'nach einem verbindlichen Angebot',
|
||||
why: 'Der Gast nimmt an – ohne Annahme kommt kein Vertrag zustande (E-003). Eine zweite Freigabe ist nicht nötig.',
|
||||
requires: [Dependency::hard('offer.binding')],
|
||||
effects: ['case_write', 'guest_mail', 'landlord_mail', 'document'],
|
||||
waits: ['guest', 'time'],
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
|
||||
use App\Actions\SendBookingDocuments;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ContractDelivery;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Process\Activity;
|
||||
@@ -14,6 +15,7 @@
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Modules\RunsAutomatically;
|
||||
use App\Process\PortalConfirmation;
|
||||
use App\Process\StepResult;
|
||||
|
||||
/**
|
||||
@@ -28,17 +30,27 @@ public static function key(): string
|
||||
return 'documents.send';
|
||||
}
|
||||
|
||||
public static function version(): int
|
||||
{
|
||||
// 2: the contract document is created and filed separately from sending it (contract_delivery); waits for the portal's
|
||||
// confirmation where the channel says so. Default behaviour is the one of version 1.
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Buchungsunterlagen (Vertragsdokumentation)',
|
||||
purpose: 'Sendet dem Gast die verbindliche Buchungsbestätigung mit Vertrag bzw. die Unterlagen der Portalbuchung.',
|
||||
phase: 'P03',
|
||||
requires: [Dependency::hard('guest.details')],
|
||||
executions: [Execution::Automatic, Execution::Approval, Execution::Manual, Execution::Portal],
|
||||
condition: 'bei jeder verbindlichen Buchung, für die wir die Unterlagen verantworten',
|
||||
why: 'Die verbindliche Vertragsdokumentation muss den Gast erreichen – von uns oder vom Portal (O1). Wie, ist einstellbar.',
|
||||
requires: [Dependency::hard('guest.details'), Dependency::hard('portal.confirmation')],
|
||||
effects: ['case_write', 'guest_mail', 'document'],
|
||||
waits: ['landlord', 'portal'],
|
||||
triggers: ['automation', 'booking.taken_over'],
|
||||
parameters: [ProcessSetting::Documents, ProcessSetting::Processing, ProcessSetting::ContractTemplate],
|
||||
triggers: ['automation', 'booking.taken_over', 'portal.mail', 'schedule:waiting'],
|
||||
parameters: [ProcessSetting::Documents, ProcessSetting::Processing, ProcessSetting::ContractDelivery, ProcessSetting::ContractTemplate],
|
||||
performers: ['system', 'landlord', 'portal'],
|
||||
modes: ['automatic', 'manual'],
|
||||
events: ['document', 'mail'],
|
||||
@@ -59,8 +71,14 @@ public function activities(CaseContext $case): array
|
||||
}
|
||||
|
||||
$binding = $case->binding;
|
||||
$delivery = $case->profile->contractDelivery();
|
||||
$internal = $delivery === ContractDelivery::Internal;
|
||||
$stored = $booking->contract_path !== null;
|
||||
$awaiting = $binding && ! $case->inquiry && $case->profile->awaitsPortalConfirmation() && PortalConfirmation::evidence($booking) === null;
|
||||
$state = match (true) {
|
||||
$booking->confirmation_sent_at !== null => ActivityState::Done,
|
||||
// Created and filed internally is how the landlord chose to fulfil the step; sending stays possible by hand.
|
||||
$internal && $stored => ActivityState::Done,
|
||||
! $binding => ActivityState::Later,
|
||||
$booking->confirmation_failed_at !== null => ActivityState::Problem,
|
||||
default => ActivityState::Open,
|
||||
@@ -68,33 +86,42 @@ public function activities(CaseContext $case): array
|
||||
$missing = $binding && $state === ActivityState::Open ? app(CaseAutomation::class)->documentBlockers($booking) : [];
|
||||
// What the landlord still has to confirm (unreleased texts, terms not shown to be agreed on the portal).
|
||||
$toConfirm = $binding && $state === ActivityState::Open && $missing === [] ? app(SendBookingDocuments::class)->compose($booking)->toConfirm() : [];
|
||||
$waiting = $missing !== [] || ($awaiting && $state === ActivityState::Open);
|
||||
|
||||
return [new Activity('documents', match (true) {
|
||||
$internal && $state === ActivityState::Done && $booking->confirmation_sent_at === null => 'Vertrag intern abgelegt',
|
||||
$internal && $state === ActivityState::Open => 'Vertrag erstellen und intern ablegen',
|
||||
$state !== ActivityState::Open => $case->inquiry ? 'Buchungsbestätigung mit Vertrag senden' : 'Buchungsunterlagen an den Gast senden',
|
||||
$case->inquiry => 'Buchungsbestätigung mit Vertrag prüfen und senden',
|
||||
default => 'Buchungsunterlagen prüfen und senden',
|
||||
}, $case->later($missing !== [] ? ActivityState::Waiting : $state),
|
||||
}, $case->later($waiting ? ActivityState::Waiting : $state),
|
||||
match (true) {
|
||||
$booking->confirmation_sent_at !== null => 'gesendet am '.$booking->confirmation_sent_at->format('d.m.Y'),
|
||||
$internal && $state === ActivityState::Done => 'erstellt und intern abgelegt – nicht an den Gast gesendet (Einstellung des Kanals); Senden von Hand bleibt möglich',
|
||||
$state === ActivityState::Problem => 'Versand fehlgeschlagen',
|
||||
$missing !== [] => 'wartet: '.implode(' ', $missing),
|
||||
$awaiting => 'wartet auf die Bestätigungsmail des Portals (die Belegung ist gesichert)',
|
||||
$toConfirm !== [] => 'vor dem Versand zu prüfen: '.implode(' ', $toConfirm),
|
||||
default => null,
|
||||
}, match (true) {
|
||||
$state === ActivityState::Problem => 'resendConfirmation',
|
||||
$binding && $missing === [] && $booking->confirmation_sent_at === null => 'sendDocuments',
|
||||
$binding && $missing === [] && $booking->confirmation_sent_at === null && ! ($internal && $stored) => 'sendDocuments',
|
||||
default => null,
|
||||
})];
|
||||
}
|
||||
|
||||
/** The guest's e-mail and the price are what the documents need – not every detail of a request. */
|
||||
/**
|
||||
* The guest's e-mail and the price are what the documents need – not every detail of a request. Due when they are
|
||||
* to go out automatically (as the case is processed or as chosen for the delivery), or – delivery „internal“ – when the
|
||||
* contract is still to be created and filed.
|
||||
*/
|
||||
public function due(CaseContext $case): bool
|
||||
{
|
||||
$booking = $case->booking;
|
||||
$delivery = $case->profile->contractDelivery();
|
||||
$mine = $case->binding && $booking->confirmation_sent_at === null && $case->profile->documents() === Responsibility::Landlord && $case->profile->origin !== 'migration';
|
||||
|
||||
return $booking->processingMode() === ProcessingMode::Automatic
|
||||
&& $case->binding && $booking->confirmation_sent_at === null
|
||||
&& $case->profile->documents() === Responsibility::Landlord && $case->profile->origin !== 'migration';
|
||||
return $mine && ($delivery === ContractDelivery::Internal ? $booking->contract_path === null : $delivery->sendsAutomatically($booking->processingMode()));
|
||||
}
|
||||
|
||||
public function blockers(CaseContext $case): array
|
||||
@@ -104,7 +131,8 @@ public function blockers(CaseContext $case): array
|
||||
|
||||
public function run(CaseContext $case): StepResult
|
||||
{
|
||||
$reasons = app(SendBookingDocuments::class)->automatically($case->booking);
|
||||
$documents = app(SendBookingDocuments::class);
|
||||
$reasons = $case->profile->contractDelivery() === ContractDelivery::Internal ? $documents->storeInternally($case->booking) : $documents->automatically($case->booking);
|
||||
|
||||
return $reasons === [] ? StepResult::ran() : StepResult::blocked($reasons);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Settlement;
|
||||
|
||||
use App\Actions\SendBookingNotice;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Dependency;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Modules\RunsAutomatically;
|
||||
use App\Process\Modules\StepState;
|
||||
use App\Process\PortalConfirmation;
|
||||
use App\Process\StepResult;
|
||||
|
||||
/**
|
||||
* P03 (V2.1, docs/Prozessarchitektur/V2.1/02 §4): a short booking information for the guest of a binding booking – without
|
||||
* contract, independent of the contract documentation. Off by default. It waits for the portal's confirmation where the
|
||||
* channel is set up that way, and is not needed where the portal informs the guest itself and confirmed (evidence on record).
|
||||
*/
|
||||
final class BookingNoticeStep extends Module implements RunsAutomatically
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'documents.booking_notice';
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Buchungsinformation an den Gast',
|
||||
purpose: 'Sendet dem Gast eine kurze Information über seine Buchung – ohne Vertrag, unabhängig von den Vertragsunterlagen.',
|
||||
phase: 'P03',
|
||||
executions: [Execution::Automatic, Execution::Manual, Execution::Portal, Execution::NotRequired],
|
||||
condition: 'nur bei extern verbindlicher Buchung und nur, wenn für den Kanal eine Buchungsinformation eingestellt ist',
|
||||
requires: [Dependency::hard('portal.confirmation'), Dependency::hard('guest.details'), Dependency::soft('documents.send')],
|
||||
effects: ['case_write', 'guest_mail'],
|
||||
waits: ['portal', 'guest', 'landlord'],
|
||||
triggers: ['automation', 'booking.taken_over', 'portal.mail', 'schedule:waiting'],
|
||||
parameters: [ProcessSetting::BookingNotice],
|
||||
toggle: ModuleDefinition::TOGGLE_CONDITIONAL,
|
||||
performers: ['system', 'landlord', 'portal'],
|
||||
modes: ['automatic', 'manual'],
|
||||
events: ['booking_notice', 'mail'],
|
||||
);
|
||||
}
|
||||
|
||||
public function applies(CaseContext $case): bool
|
||||
{
|
||||
return ! $case->inquiry && $case->profile->bookingNotice() !== BookingNoticeMode::Off;
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$booking = $case->booking;
|
||||
$suppression = SendBookingNotice::suppression($booking);
|
||||
$sent = SendBookingNotice::sent($booking);
|
||||
$waitsForPortal = $case->profile->awaitsPortalConfirmation() && PortalConfirmation::evidence($booking) === null;
|
||||
$label = 'Buchungsinformation an den Gast'.($case->profile->bookingNotice()->isAutomatic() ? ' (automatisch)' : '');
|
||||
|
||||
return [new Activity('booking_notice', $label, $case->later(match (true) {
|
||||
$sent => ActivityState::Done,
|
||||
$suppression !== null => ActivityState::NotApplicable,
|
||||
! $case->binding => ActivityState::Later,
|
||||
$waitsForPortal => ActivityState::Waiting,
|
||||
blank($booking->guest?->email) => ActivityState::Waiting,
|
||||
default => ActivityState::Open,
|
||||
}), match (true) {
|
||||
$sent => 'gesendet',
|
||||
$suppression !== null => 'nicht nötig: '.$suppression,
|
||||
$waitsForPortal => 'wartet auf die Bestätigungsmail des Portals',
|
||||
blank($booking->guest?->email) => 'wartet: Die E-Mail-Adresse des Gastes fehlt.',
|
||||
default => null,
|
||||
}, ! $sent && $suppression === null && $case->binding && filled($booking->guest?->email) ? 'sendBookingNotice' : null)];
|
||||
}
|
||||
|
||||
public function state(CaseContext $case): ?StepState
|
||||
{
|
||||
$booking = $case->booking;
|
||||
|
||||
return match (true) {
|
||||
SendBookingNotice::sent($booking) => StepState::Done,
|
||||
SendBookingNotice::suppression($booking) !== null => StepState::NotApplicable,
|
||||
! $case->binding => StepState::Later,
|
||||
default => StepState::Open,
|
||||
};
|
||||
}
|
||||
|
||||
public function due(CaseContext $case): bool
|
||||
{
|
||||
return $case->profile->bookingNotice()->isAutomatic() && $case->binding && ! $case->closed
|
||||
&& ! SendBookingNotice::sent($case->booking) && SendBookingNotice::suppression($case->booking) === null && $case->profile->origin !== 'migration';
|
||||
}
|
||||
|
||||
public function blockers(CaseContext $case): array
|
||||
{
|
||||
return filled($case->booking->guest?->email) ? [] : ['Die E-Mail-Adresse des Gastes fehlt.'];
|
||||
}
|
||||
|
||||
public function run(CaseContext $case): StepResult
|
||||
{
|
||||
return app(SendBookingNotice::class)->handle($case->booking, automatic: true) ? StepResult::ran() : StepResult::blocked([SendBookingNotice::suppression($case->booking) ?? 'Nicht gesendet.']);
|
||||
}
|
||||
|
||||
public function isOutward(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Aufgaben und Meldungen',
|
||||
purpose: 'Zeigt offene Aufgaben des Vorgangs – Meldungen der Portale, Entscheidungen, Zahlungs- und Leistungsaufgaben.',
|
||||
phase: 'P03',
|
||||
executions: [],
|
||||
condition: 'wenn eine Aufgabe oder Meldung vorliegt',
|
||||
effects: ['case_write'],
|
||||
waits: ['landlord'],
|
||||
triggers: ['task.created', 'portal.report'],
|
||||
|
||||
@@ -26,6 +26,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Änderungsvorschlag',
|
||||
purpose: 'Zeigt einen Änderungsvorschlag, der beim Gast liegt.',
|
||||
phase: 'P03',
|
||||
executions: [],
|
||||
condition: 'wenn ein Änderungsvorschlag beim Gast liegt',
|
||||
effects: ['case_write', 'guest_mail'],
|
||||
waits: ['guest', 'time'],
|
||||
triggers: ['change.proposed'],
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseClosure;
|
||||
use App\Process\CaseContext;
|
||||
@@ -28,6 +29,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Kaufmännisch abschließen',
|
||||
purpose: 'Schließt den Vorgang kaufmännisch ab, wenn Zahlungen, Erstattungen und Auszahlungen geklärt sind.',
|
||||
phase: 'P05',
|
||||
executions: [Execution::Manual],
|
||||
condition: 'nach dem Aufenthalt',
|
||||
why: 'Zahlungen, Erstattungen und Auszahlungen müssen geklärt sein; eine Portalmeldung ersetzt den Nachweis nicht (O5).',
|
||||
requires: [Dependency::soft('case.closure')],
|
||||
effects: ['case_write'],
|
||||
waits: ['landlord', 'portal'],
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\InternalKind;
|
||||
use App\Models\BookingTask;
|
||||
use App\Process\Activity;
|
||||
@@ -28,6 +29,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Aufenthalt abschließen',
|
||||
purpose: 'Schließt den Aufenthalt ab, sobald nach der Abreise nichts mehr für ihn offen ist.',
|
||||
phase: 'P05',
|
||||
executions: [Execution::Automatic, Execution::Manual],
|
||||
condition: 'nach der Abreise',
|
||||
why: 'Ein Aufenthalt wird immer abgeschlossen, damit nichts offen bleibt (E-010).',
|
||||
effects: ['case_write'],
|
||||
waits: ['time', 'landlord'],
|
||||
triggers: ['schedule:daily'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Settlement;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\InternalKind;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
@@ -25,6 +26,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Aufenthaltsbestätigung',
|
||||
purpose: 'Bestätigt den Gästen einer Eigenbelegung oder privaten Überlassung den Aufenthalt – nur bei Bedarf.',
|
||||
phase: 'P03',
|
||||
executions: [Execution::Manual, Execution::NotRequired],
|
||||
condition: 'bei einer privaten Überlassung mit Gästen',
|
||||
effects: ['guest_mail', 'document'],
|
||||
toggle: ModuleDefinition::TOGGLE_OPTIONAL,
|
||||
performers: ['landlord'],
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Models\BookingTask;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
@@ -28,6 +29,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Anreisedaten',
|
||||
purpose: 'Sammelt Telefon und Anreisezeit für die Übergabe und meldet rechtzeitig, was fehlt.',
|
||||
phase: 'P04',
|
||||
executions: [Execution::Manual, Execution::ServiceProvider, Execution::NotRequired],
|
||||
condition: 'bei verbindlichen Buchungen',
|
||||
effects: ['case_write'],
|
||||
waits: ['guest', 'landlord', 'time'],
|
||||
triggers: ['schedule:prepare-stays'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Stay;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Process\Activity;
|
||||
@@ -27,10 +28,13 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Anreise-Informationen',
|
||||
purpose: 'Wegbeschreibung, Schlüssel und Kontakt vor Ort rechtzeitig vor der Anreise.',
|
||||
phase: 'P04',
|
||||
why: 'Ohne Anreise-Informationen finden Gäste Schlüssel und Wohnung nicht; wer sie sendet, ist einstellbar.',
|
||||
executions: [Execution::Automatic, Execution::Portal, Execution::ServiceProvider, Execution::NotRequired],
|
||||
condition: 'bei verbindlichen Buchungen',
|
||||
effects: ['guest_mail'],
|
||||
waits: ['time', 'portal'],
|
||||
triggers: ['schedule:reminders'],
|
||||
parameters: [ProcessSetting::GuestMessages, ProcessSetting::ArrivalInfoDaysBefore],
|
||||
parameters: [ProcessSetting::ArrivalInfoSender, ProcessSetting::ArrivalInfoDaysBefore],
|
||||
performers: ['system', 'portal', 'service_provider'],
|
||||
events: ['document', 'mail'],
|
||||
);
|
||||
@@ -41,7 +45,7 @@ public function activities(CaseContext $case): array
|
||||
$booking = $case->booking;
|
||||
$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 (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')];
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace App\Process\Modules\Stay;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
@@ -27,11 +29,14 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Bitte um eine Bewertung',
|
||||
purpose: 'Bittet den Gast nach dem Aufenthalt um eine Bewertung.',
|
||||
phase: 'P05',
|
||||
executions: [Execution::Automatic, Execution::Portal, Execution::NotRequired],
|
||||
condition: 'nach dem Aufenthalt, wenn wir dem Gast schreiben',
|
||||
requires: [Dependency::hard('stay')],
|
||||
effects: ['guest_mail'],
|
||||
waits: ['time'],
|
||||
triggers: ['schedule:reviews'],
|
||||
toggle: ModuleDefinition::TOGGLE_OPTIONAL,
|
||||
parameters: [ProcessSetting::ReviewRequestSender],
|
||||
performers: ['system'],
|
||||
events: ['mail'],
|
||||
);
|
||||
@@ -39,7 +44,7 @@ public static function definition(): ModuleDefinition
|
||||
|
||||
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
|
||||
|
||||
@@ -25,6 +25,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Aufenthalt',
|
||||
purpose: 'Der Aufenthalt vom Anreise- bis zum Abreisetag.',
|
||||
phase: 'P04',
|
||||
executions: [],
|
||||
condition: 'immer',
|
||||
waits: ['time'],
|
||||
triggers: ['schedule:daily'],
|
||||
performers: ['guest', 'landlord'],
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Enums\PortalEmailType;
|
||||
use App\Models\Booking;
|
||||
use App\Models\PortalEmail;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* The evidence that a portal confirmed a binding booking (docs/Prozessarchitektur/V2.1/02 §5): a booking mail of the portal
|
||||
* that is assigned to the case deterministically – by the portal's booking reference or by the calendar entry that belongs
|
||||
* to the case, both of the same channel (CH-13) – or the landlord's explicit confirmation in the case. The evidence level is
|
||||
* „laut Portal“ (mail) or „nachgewiesen durch den Vermieter“; it never creates or changes a binding, the booking was
|
||||
* binding from the start (E-036). Pure reading; `confirm` records the landlord's confirmation.
|
||||
*/
|
||||
final class PortalConfirmation
|
||||
{
|
||||
public const EVENT = 'portal_confirmation';
|
||||
|
||||
/**
|
||||
* @return array{source: 'mail'|'landlord', at: CarbonImmutable, label: string}|null
|
||||
*/
|
||||
public static function evidence(Booking $booking): ?array
|
||||
{
|
||||
$landlord = $booking->events()->where('type', self::EVENT)->orderBy('occurred_at')->first();
|
||||
if ($landlord !== null) {
|
||||
return ['source' => 'landlord', 'at' => CarbonImmutable::parse($landlord->occurred_at), 'label' => 'vom Vermieter bestätigt ('.$landlord->actor.')'];
|
||||
}
|
||||
|
||||
$channelId = $booking->processChannel()?->id;
|
||||
if ($channelId === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$mail = PortalEmail::query()->where('channel_id', $channelId)->where('type', PortalEmailType::Booking)
|
||||
->where(fn ($query) => $query
|
||||
->when(filled($booking->portal_reference), fn ($by) => $by->orWhere('reference', $booking->portal_reference))
|
||||
->orWhereHas('blockedPeriod', fn ($block) => $block->withTrashed()->where('linked_booking_id', $booking->id)))
|
||||
->orderBy('received_at')->first();
|
||||
|
||||
return $mail === null ? null : ['source' => 'mail', 'at' => CarbonImmutable::parse($mail->received_at), 'label' => 'Bestätigungsmail des Portals vom '.CarbonImmutable::parse($mail->received_at)->format('d.m.Y, H:i').' Uhr (laut Portal)'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Until when the confirmation is awaited (counted from the case's arrival in the system).
|
||||
*/
|
||||
public static function deadline(Booking $booking): CarbonImmutable
|
||||
{
|
||||
return CarbonImmutable::parse($booking->created_at)->addHours($booking->process()->portalConfirmationWaitHours());
|
||||
}
|
||||
|
||||
public static function isOverdue(Booking $booking): bool
|
||||
{
|
||||
return self::deadline($booking)->isPast();
|
||||
}
|
||||
|
||||
/**
|
||||
* The landlord states that the portal confirmed (e.g. checked in the portal's own interface). Recorded once.
|
||||
*/
|
||||
public static function confirm(Booking $booking, string $by, ?string $note = null): void
|
||||
{
|
||||
if ($booking->events()->where('type', self::EVENT)->exists()) {
|
||||
return;
|
||||
}
|
||||
CaseLog::record($booking, self::EVENT, 'Bestätigung des Portals vom Vermieter festgehalten', reason: $note, data: ['module' => 'portal.confirmation', 'level' => 'confirmed_by_landlord'], actor: $by);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Process\Models\ProcessModel;
|
||||
use App\Process\Modules\ProcessModule;
|
||||
use App\Process\Modules\RunsAutomatically;
|
||||
use App\Process\Templates\FunctionTemplate;
|
||||
use App\Process\Templates\TemplateArea;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
@@ -97,6 +100,53 @@ public function models(): array
|
||||
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
|
||||
* branched (legacy mapping, docs/Prozessarchitektur/Architektur/06 §4).
|
||||
@@ -105,7 +155,7 @@ public function derivedModel(ProcessProfile $profile): string
|
||||
{
|
||||
return match ($profile->intake) {
|
||||
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) {
|
||||
CaseType::A5 => 'a5.portal_booking',
|
||||
CaseType::A4 => 'a4.portal_booking',
|
||||
@@ -151,12 +201,48 @@ public function problems(): array
|
||||
$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 ($versions as $version => $class) {
|
||||
if ($class::key() !== $key || $class::version() !== $version) {
|
||||
$problems[] = "Modell {$key}@{$version}: Klasse {$class} meldet ".$class::key().'@'.$class::version().'.';
|
||||
}
|
||||
$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->modules($variant->key) as $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\Channel;
|
||||
use App\Process\Models\ProcessModel;
|
||||
use App\Process\Templates\TemplateComposer;
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
@@ -27,6 +28,7 @@ final class ProcessPlan
|
||||
* @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, 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 readonly string $model,
|
||||
@@ -37,6 +39,7 @@ public function __construct(
|
||||
public readonly string $source = self::DERIVED,
|
||||
public readonly array $labels = [],
|
||||
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
|
||||
* 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
|
||||
{
|
||||
@@ -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 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, 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);
|
||||
$modules = [];
|
||||
$labels = [];
|
||||
foreach ($model->modules($variant) as $key) {
|
||||
foreach ($model->modules($variant, $templates) as $key) {
|
||||
$class = $catalogue->modules()[$key];
|
||||
$modules[$key] = $class::version();
|
||||
$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
|
||||
{
|
||||
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
|
||||
@@ -204,6 +217,7 @@ public function toArray(): array
|
||||
'source' => $this->source,
|
||||
'labels' => $this->labels,
|
||||
'notice' => $this->notice,
|
||||
'templates' => $this->templates === [] ? null : $this->templates,
|
||||
], fn (mixed $value): bool => $value !== null);
|
||||
}
|
||||
|
||||
@@ -221,6 +235,7 @@ public static function fromArray(array $data): self
|
||||
(string) ($data['source'] ?? self::DERIVED),
|
||||
(array) ($data['labels'] ?? []),
|
||||
isset($data['notice']) ? (string) $data['notice'] : null,
|
||||
array_map('strval', (array) ($data['templates'] ?? [])),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\ContractDelivery;
|
||||
use App\Enums\DataRequestMode;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
@@ -30,6 +33,15 @@ final class ProcessProfile
|
||||
/** Fixed by the process model chosen for the channel (Architektur V2). */
|
||||
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. */
|
||||
public const CASE_TYPE = 'case_type';
|
||||
|
||||
@@ -51,7 +63,9 @@ public function __construct(
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
@@ -59,7 +73,7 @@ public static function caseTypeFor(IntakeKind $intake, bool $viaChannel, Respons
|
||||
IntakeKind::Internal => CaseType::A6,
|
||||
IntakeKind::Inquiry => $viaChannel ? CaseType::A2 : CaseType::A1,
|
||||
IntakeKind::Booking => match (true) {
|
||||
$documents === Responsibility::Portal => CaseType::A5,
|
||||
$documents === Responsibility::Portal && $payments === Responsibility::Portal => CaseType::A5,
|
||||
$payments === Responsibility::Portal => CaseType::A4,
|
||||
default => CaseType::A3,
|
||||
},
|
||||
@@ -101,6 +115,27 @@ public function payments(): Responsibility
|
||||
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
|
||||
{
|
||||
return Responsibility::tryFrom((string) $this->value(ProcessSetting::GuestMessages)) ?? Responsibility::Landlord;
|
||||
@@ -147,6 +182,26 @@ public function guestLinkValidDays(): int
|
||||
return max(1, (int) $this->value(ProcessSetting::GuestLinkValidDays));
|
||||
}
|
||||
|
||||
public function contractDelivery(): ContractDelivery
|
||||
{
|
||||
return ContractDelivery::tryFrom((string) $this->value(ProcessSetting::ContractDelivery)) ?? ContractDelivery::Follow;
|
||||
}
|
||||
|
||||
public function bookingNotice(): BookingNoticeMode
|
||||
{
|
||||
return BookingNoticeMode::tryFrom((string) $this->value(ProcessSetting::BookingNotice)) ?? BookingNoticeMode::Off;
|
||||
}
|
||||
|
||||
public function awaitsPortalConfirmation(): bool
|
||||
{
|
||||
return (bool) $this->value(ProcessSetting::AwaitPortalConfirmation);
|
||||
}
|
||||
|
||||
public function portalConfirmationWaitHours(): int
|
||||
{
|
||||
return max(1, (int) $this->value(ProcessSetting::PortalConfirmationWaitHours));
|
||||
}
|
||||
|
||||
public function formRequiresAddress(): bool
|
||||
{
|
||||
return (bool) $this->value(ProcessSetting::FormRequiresAddress);
|
||||
@@ -171,6 +226,9 @@ public static function sourceLabel(string $source): string
|
||||
self::WEBSITE => 'Einstellung der eigenen Webseite',
|
||||
self::CASE_TYPE => 'fest für diese Vorgangsart',
|
||||
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',
|
||||
default => 'Grundeinstellung',
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process;
|
||||
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\InquiryAnswer;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
@@ -11,6 +12,8 @@
|
||||
use App\Models\Property;
|
||||
use App\Models\Tenant;
|
||||
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
|
||||
@@ -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] ?? []),
|
||||
];
|
||||
|
||||
$model = $this->chosenModel($channel, $intake);
|
||||
$templates = $this->chosenTemplates($channel, $intake, $model);
|
||||
$suggested = [];
|
||||
foreach ($templates as $class) {
|
||||
$suggested = [...$suggested, ...$class::defaults()];
|
||||
}
|
||||
|
||||
$values = [];
|
||||
$sources = [];
|
||||
foreach (ProcessSetting::cases() as $setting) {
|
||||
$values[$setting->value] = $setting->default();
|
||||
$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) {
|
||||
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
|
||||
// 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) {
|
||||
$setting = ProcessSetting::tryFrom($key);
|
||||
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) {
|
||||
// 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.
|
||||
@@ -74,12 +96,39 @@ public function resolve(Property $property, ?Channel $channel, IntakeKind $intak
|
||||
$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]);
|
||||
$payments = Responsibility::from((string) $values[ProcessSetting::Payments->value]);
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
/**
|
||||
* Why something cannot be chosen or switched off – in a form the landlord can act on (docs/Prozessarchitektur/V2.1/02
|
||||
* §3.2): what stands in the way and of what kind it is, which other way is allowed, what exactly to change.
|
||||
*/
|
||||
final readonly class Restriction
|
||||
{
|
||||
public const BUSINESS = 'fachlich';
|
||||
|
||||
public const CAPABILITY = 'Kanalfähigkeit';
|
||||
|
||||
public const SECURITY = 'Schutzregel';
|
||||
|
||||
public function __construct(
|
||||
public string $kind,
|
||||
public string $reason,
|
||||
public ?string $alternative = null,
|
||||
public ?string $change = null,
|
||||
) {}
|
||||
|
||||
public function text(): string
|
||||
{
|
||||
return trim($this->reason.($this->alternative ? ' Zulässig ist stattdessen: '.$this->alternative.'.' : '').($this->change ? ' Änderung: '.$this->change.'.' : ''));
|
||||
}
|
||||
}
|
||||
@@ -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],
|
||||
};
|
||||
}
|
||||
}
|
||||
Loaded 100 of 143 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user