V2.1: Kanalfähigkeiten, Ausführungsvarianten, Dokumentenentkopplung, Portalbestätigung
Modellwahl über Kanalfähigkeiten mit erklärten Einschränkungen, Abgleich alter Werte, Ausführungsvarianten je Modul, getrennte Vertrags-/Buchungsinformation, Warten auf die Portalbestätigung mit Eskalation und Wiederaufnahme (Fälle C und D getestet). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ef1635e59a
commit
8442d0a3d8
62 files changed
+1818
-69
No files matched your search
@@ -5,40 +5,59 @@
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Models\Channel;
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\ChannelProcessConfiguration;
|
||||
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) {}
|
||||
|
||||
/**
|
||||
* @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>, 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']);
|
||||
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;
|
||||
@@ -58,9 +77,22 @@ public function handle(Channel $channel, IntakeKind $intake, array $draft, ?stri
|
||||
'variant' => $draft['variant'] ?? 'standard',
|
||||
'steps' => $steps,
|
||||
'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',
|
||||
'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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,10 @@ 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';
|
||||
|
||||
/**
|
||||
* Built-in default (the behaviour before any landlord setting existed).
|
||||
@@ -46,6 +50,10 @@ 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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -71,6 +79,10 @@ 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?',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,7 +96,7 @@ public function channelIntakes(): array
|
||||
return match ($this) {
|
||||
self::Processing, self::Payments, self::GuestMessages, self::ContractTemplate => [IntakeKind::Inquiry, IntakeKind::Booking],
|
||||
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],
|
||||
@@ -111,12 +123,14 @@ 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::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,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -139,6 +153,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,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Forms;
|
||||
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Enums\ContractDelivery;
|
||||
use App\Enums\DataRequestMode;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
@@ -49,6 +51,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());
|
||||
}
|
||||
|
||||
@@ -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,6 +19,7 @@
|
||||
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;
|
||||
@@ -50,6 +52,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 +145,8 @@ protected function getHeaderActions(): array
|
||||
$this->confirmAction(),
|
||||
$this->sendDocumentsAction(),
|
||||
$this->resendConfirmationAction(),
|
||||
$this->confirmPortalAction(),
|
||||
$this->sendBookingNoticeAction(),
|
||||
$this->portalPriceAction(),
|
||||
$this->changeAction(),
|
||||
$this->confirmPortalCancellationAction(),
|
||||
@@ -492,6 +498,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')
|
||||
|
||||
@@ -10,11 +10,14 @@
|
||||
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\Models\ProcessModel;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use App\Process\ProcessProfile;
|
||||
use App\Process\ProcessSettings;
|
||||
use App\Process\Restriction;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
||||
@@ -44,6 +47,12 @@ class ChannelProcess extends Page
|
||||
/** @var array<string, array{model: string, variant: string, steps: array<string, array{on?: bool}>, settings: array<string, mixed>}> */
|
||||
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;
|
||||
|
||||
public function mount(int|string $record): void
|
||||
{
|
||||
$this->record = $this->resolveRecord($record);
|
||||
@@ -51,8 +60,9 @@ public function mount(int|string $record): void
|
||||
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);
|
||||
// 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.
|
||||
$model = $current['model'];
|
||||
$this->drafts[$intake->value] = [
|
||||
'model' => $model,
|
||||
'variant' => $current['variant'],
|
||||
@@ -62,6 +72,26 @@ public function mount(int|string $record): void
|
||||
];
|
||||
}
|
||||
$this->intake = (string) array_key_first($this->drafts);
|
||||
$this->capabilityDraft = $this->record->isWebsite() ? [] : collect(app(ChannelCapabilities::class)->resolve($this->record))
|
||||
->map(fn (Capability $capability): string => $capability->value === null ? '' : ($capability->value ? '1' : '0'))->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,15 +122,31 @@ 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']);
|
||||
}
|
||||
|
||||
public function chooseModel(string $model): void
|
||||
{
|
||||
if (! ($this->models()[$model]['admissible'] ?? false)) {
|
||||
return;
|
||||
}
|
||||
$this->acknowledge = false;
|
||||
$this->drafts[$this->intake]['model'] = $model;
|
||||
$this->drafts[$this->intake]['variant'] = 'standard';
|
||||
$this->drafts[$this->intake]['steps'] = [];
|
||||
@@ -113,7 +159,7 @@ 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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +191,7 @@ public function steps(): array
|
||||
'performer_options' => $configuration->performerOptions($model, $row['module']),
|
||||
'parameters' => array_map(fn (ProcessSetting $setting): array => $this->setting($setting, $profile), $parameters),
|
||||
];
|
||||
}, $configuration->preview($this->record, IntakeKind::from($this->intake), $draft));
|
||||
}, $configuration->preview($this->record, IntakeKind::from($this->intake), $this->draft()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +228,7 @@ 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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,13 +246,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 +266,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]));
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
@@ -79,15 +79,82 @@ 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) {
|
||||
if ($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));
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return list<array{setting: ProcessSetting, stored: string, fixed: string, text: string}>
|
||||
*/
|
||||
public function conflicts(Channel $channel, IntakeKind $intake, string $modelKey): array
|
||||
{
|
||||
if (! $this->catalogue->hasModel($modelKey)) {
|
||||
return [];
|
||||
}
|
||||
$stored = (array) (($channel->process_overrides ?? [])[$intake->value] ?? []);
|
||||
$conflicts = [];
|
||||
foreach ($this->catalogue->model($modelKey)::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).'“. Das Modell „'.$modelKey.'“ legt fest: „'.$setting->describe($fixedValue).'“.'];
|
||||
}
|
||||
|
||||
return $conflicts;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,11 +262,14 @@ public function problems(Channel $channel, IntakeKind $intake, array $draft, boo
|
||||
$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.'];
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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'),
|
||||
|
||||
@@ -33,6 +33,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).
|
||||
*
|
||||
|
||||
@@ -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,7 @@
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Models\DataRequest;
|
||||
@@ -30,6 +31,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'],
|
||||
|
||||
@@ -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,127 @@
|
||||
<?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',
|
||||
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,7 @@
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Process\Activity;
|
||||
@@ -41,6 +42,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'],
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Process\Activity;
|
||||
@@ -32,6 +33,8 @@ 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',
|
||||
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'],
|
||||
|
||||
@@ -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,6 +28,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Anreise-Informationen',
|
||||
purpose: 'Wegbeschreibung, Schlüssel und Kontakt vor Ort rechtzeitig vor der Anreise.',
|
||||
phase: 'P04',
|
||||
executions: [Execution::Automatic, Execution::Portal, Execution::ServiceProvider, Execution::NotRequired],
|
||||
condition: 'bei verbindlichen Buchungen',
|
||||
effects: ['guest_mail'],
|
||||
waits: ['time', 'portal'],
|
||||
triggers: ['schedule:reminders'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Stay;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
@@ -27,6 +28,8 @@ 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'],
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\ContractDelivery;
|
||||
use App\Enums\DataRequestMode;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
@@ -147,6 +149,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);
|
||||
|
||||
@@ -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.'.' : ''));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user