Merge feature/prozessarchitektur-v2-1: V2.1 fachliche Konfigurierbarkeit
Deploy FeWo mit PipelineManager / deploy (push) Successful in 6m22s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 6m22s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
8ad71c54d2
89 files changed
+3186
-81
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,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\Medium;
|
||||
use App\Enums\MessageEffect;
|
||||
use App\Enums\MessageIntent;
|
||||
use App\Support\Settings;
|
||||
|
||||
/**
|
||||
* The medium × intent policy (V2.1): `config/communication.php` is the ceiling, the landlord's `communication_rules`
|
||||
* (tenants) may only narrow it: switch a medium off, withdraw effects. Widening is ignored.
|
||||
*/
|
||||
class CommunicationRules
|
||||
{
|
||||
public function mediumActive(Medium $medium): bool
|
||||
{
|
||||
$ceiling = (bool) config("communication.media.{$medium->value}.active", false);
|
||||
|
||||
return $ceiling && ($this->narrowing()['media'][$medium->value]['active'] ?? true) !== false;
|
||||
}
|
||||
|
||||
public function consentRequired(Medium $medium): bool
|
||||
{
|
||||
return (bool) config("communication.media.{$medium->value}.consent_required", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<MessageEffect> the effects the rules allow for the intent on the medium (never empty: review at least)
|
||||
*/
|
||||
public function effects(Medium $medium, MessageIntent $intent): array
|
||||
{
|
||||
/** @var list<MessageEffect> $ceiling */
|
||||
$ceiling = config('communication.effects.'.$intent->value, [MessageEffect::Review]);
|
||||
$withdrawn = (array) ($this->narrowing()['effects'][$medium->value][$intent->value] ?? []);
|
||||
$allowed = array_values(array_filter($ceiling, fn (MessageEffect $effect): bool => ! in_array($effect->value, $withdrawn, true)));
|
||||
|
||||
return $allowed === [] ? [MessageEffect::Review] : $allowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function narrowing(): array
|
||||
{
|
||||
return (array) (Settings::tenant()?->communication_rules ?? []);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\Medium;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* A message as the medium adapters hand it over (V2.1): raw data only. {@see $verifiedBookingId} is set by the adapter
|
||||
* itself from a reference it issued and can verify (signed token, reply to one of our mails) – a claim in the text is
|
||||
* never enough. {@see $consentGiven} is likewise the adapter's statement.
|
||||
*/
|
||||
final readonly class IncomingMessage
|
||||
{
|
||||
public function __construct(
|
||||
public Medium $medium,
|
||||
public string $sender,
|
||||
public string $text,
|
||||
public CarbonImmutable $receivedAt,
|
||||
public string $externalId,
|
||||
public ?int $verifiedBookingId = null,
|
||||
public bool $consentGiven = false,
|
||||
public ?string $senderName = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\MessageIntent;
|
||||
|
||||
/**
|
||||
* Rule-based intent of a message (V2.1). Deterministic and medium-independent; an AI classifier can later implement the
|
||||
* same interface of work (E-035). Whatever the rules do not clearly recognise is {@see MessageIntent::Unclear}.
|
||||
*/
|
||||
class IntentClassifier
|
||||
{
|
||||
public function classify(string $text, bool $assignedToCase): MessageIntent
|
||||
{
|
||||
$text = mb_strtolower($text);
|
||||
$has = fn (array $words): bool => (bool) preg_match('/('.implode('|', $words).')/u', $text);
|
||||
|
||||
if ($assignedToCase && $has(['umbuchen', 'verschieb', 'stornieren', 'stornierung', 'später anreisen', 'früher anreisen', 'ändern'])) {
|
||||
return MessageIntent::ChangeRequest;
|
||||
}
|
||||
if ($assignedToCase && $has(['ankunft', 'uhr', 'personen', 'kennzeichen', 'adresse', 'telefon', 'handynummer'])) {
|
||||
return MessageIntent::ProvideData;
|
||||
}
|
||||
if ($assignedToCase) {
|
||||
return MessageIntent::CaseReply;
|
||||
}
|
||||
if ($has(['frei', 'verfügbar', 'buchen', 'reservieren', 'anreise', 'zeitraum', 'vom \d'])) {
|
||||
return MessageIntent::StayInquiry;
|
||||
}
|
||||
if ($has(['\?', 'hund', 'haustier', 'parkplatz', 'wlan', 'preis', 'kosten', 'wie weit', 'strand', 'ausstattung'])) {
|
||||
return MessageIntent::GeneralQuestion;
|
||||
}
|
||||
|
||||
return MessageIntent::Unclear;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Enums\Medium;
|
||||
use App\Enums\MessageEffect;
|
||||
use App\Enums\MessageIntent;
|
||||
use App\Models\Booking;
|
||||
|
||||
/**
|
||||
* What the process core decided about a message (V2.1): intent, case (only if verified), the effects that apply and why.
|
||||
*/
|
||||
final readonly class MessageDecision
|
||||
{
|
||||
/**
|
||||
* @param list<MessageEffect> $effects applied effects, in order
|
||||
* @param list<string> $reasons plain-language explanation
|
||||
*/
|
||||
public function __construct(
|
||||
public Medium $medium,
|
||||
public MessageIntent $intent,
|
||||
public ?Booking $booking,
|
||||
public array $effects,
|
||||
public array $reasons,
|
||||
) {}
|
||||
|
||||
public function has(MessageEffect $effect): bool
|
||||
{
|
||||
return in_array($effect, $this->effects, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{medium: string, intent: string, booking_id: ?int, effects: list<string>, reasons: list<string>}
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return ['medium' => $this->medium->value, 'intent' => $this->intent->value, 'booking_id' => $this->booking?->id,
|
||||
'effects' => array_map(fn (MessageEffect $effect): string => $effect->value, $this->effects), 'reasons' => $this->reasons];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Communication;
|
||||
|
||||
use App\Actions\ReceiveInboundMessage;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\MessageEffect;
|
||||
use App\Enums\MessageIntent;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\InboundMessage;
|
||||
use App\Process\CaseLog;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Database\UniqueConstraintViolationException;
|
||||
|
||||
/**
|
||||
* Entry of messages from every medium except the e-mail inbox, which keeps its own path (V2.1, docs/…/02 §6):
|
||||
* store once → assign deterministically (only a reference verified by the adapter, and not contradicted by the text) →
|
||||
* classify → apply the effects the rules allow. A message never creates a case, reservation, offer or booking; what is
|
||||
* unclear or contradictory goes to review. No answer is sent here.
|
||||
*/
|
||||
class MessageIntake
|
||||
{
|
||||
public function __construct(private CommunicationRules $rules, private IntentClassifier $classifier) {}
|
||||
|
||||
public function handle(IncomingMessage $incoming): MessageDecision
|
||||
{
|
||||
$key = $incoming->medium->value.':'.$incoming->externalId;
|
||||
$existing = InboundMessage::query()->where('message_id', $key)->first();
|
||||
if ($existing !== null) {
|
||||
return $this->fromStored($existing, $incoming);
|
||||
}
|
||||
|
||||
$reasons = [];
|
||||
$booking = $this->assignedCase($incoming, $reasons);
|
||||
$intent = $this->classifier->classify($incoming->text, $booking !== null);
|
||||
$effects = $this->effectsFor($incoming, $intent, $booking, $reasons);
|
||||
$decision = new MessageDecision($incoming->medium, $intent, $booking, $effects, $reasons);
|
||||
|
||||
try {
|
||||
$message = InboundMessage::query()->create([
|
||||
'message_id' => $key,
|
||||
'medium' => $incoming->medium->value,
|
||||
'from_address' => mb_substr($incoming->sender, 0, 255),
|
||||
'from_name' => $incoming->senderName,
|
||||
'subject' => mb_substr(strtok($incoming->text, "\n") ?: '', 0, 120),
|
||||
'body' => $incoming->text,
|
||||
'received_at' => $incoming->receivedAt,
|
||||
'test_mode' => ! Settings::isLive(),
|
||||
'status' => $booking !== null && ! $decision->has(MessageEffect::Review) ? InboundMessage::ASSIGNED : InboundMessage::NEEDS_REVIEW,
|
||||
'booking_id' => $booking?->id,
|
||||
'match_reason' => $booking !== null ? 'verified_reference' : null,
|
||||
'intent' => $intent->value,
|
||||
'decision' => $decision->toArray(),
|
||||
]);
|
||||
} catch (UniqueConstraintViolationException) {
|
||||
return $this->fromStored(InboundMessage::query()->where('message_id', $key)->firstOrFail(), $incoming);
|
||||
}
|
||||
|
||||
$this->apply($message, $decision);
|
||||
|
||||
return $decision;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $reasons
|
||||
*/
|
||||
private function assignedCase(IncomingMessage $incoming, array &$reasons): ?Booking
|
||||
{
|
||||
if ($incoming->verifiedBookingId === null) {
|
||||
$reasons[] = 'Kein überprüfter Bezug zu einem Vorgang – Absender, Rufnummer, Name oder Zeitraum allein ordnen nicht zu.';
|
||||
|
||||
return null;
|
||||
}
|
||||
$booking = Booking::query()->find($incoming->verifiedBookingId);
|
||||
if ($booking === null) {
|
||||
$reasons[] = 'Der überprüfte Bezug verweist auf keinen Vorgang dieses Vermieters.';
|
||||
|
||||
return null;
|
||||
}
|
||||
if (preg_match_all('/\b(20\d{2}-\d{4})\b/', $incoming->text, $numbers) && array_diff($numbers[1], [$booking->reference]) !== []) {
|
||||
$reasons[] = 'Die Nachricht nennt eine andere Vorgangsnummer als der überprüfte Bezug – widersprüchlich.';
|
||||
|
||||
return null;
|
||||
}
|
||||
$reasons[] = 'Dem Vorgang '.$booking->reference.' zugeordnet (überprüfter Bezug).';
|
||||
|
||||
return $booking;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $reasons
|
||||
* @return list<MessageEffect>
|
||||
*/
|
||||
private function effectsFor(IncomingMessage $incoming, MessageIntent $intent, ?Booking $booking, array &$reasons): array
|
||||
{
|
||||
if (! $this->rules->mediumActive($incoming->medium)) {
|
||||
$reasons[] = $incoming->medium->getLabel().' ist für diesen Vermieter nicht eingeschaltet – die Nachricht liegt zur Klärung vor.';
|
||||
|
||||
return [MessageEffect::Review];
|
||||
}
|
||||
if ($this->rules->consentRequired($incoming->medium) && ! $incoming->consentGiven) {
|
||||
$reasons[] = 'Für '.$incoming->medium->getLabel().' liegt keine Einwilligung vor – nur Klärung durch den Vermieter.';
|
||||
|
||||
return [MessageEffect::Review];
|
||||
}
|
||||
|
||||
$effects = array_values(array_filter(
|
||||
$this->rules->effects($incoming->medium, $intent),
|
||||
fn (MessageEffect $effect): bool => ! $effect->needsCase() || $booking !== null,
|
||||
));
|
||||
// The review fallback only stands alone: where a real effect applies it is not added.
|
||||
$real = array_values(array_filter($effects, fn (MessageEffect $effect): bool => $effect !== MessageEffect::Review));
|
||||
if ($real === [] || $intent === MessageIntent::Unclear) {
|
||||
$reasons[] = 'Nicht eindeutig oder nicht zulässig – zur Klärung vorgelegt, nichts wird übernommen.';
|
||||
|
||||
return [MessageEffect::Review];
|
||||
}
|
||||
|
||||
return $real;
|
||||
}
|
||||
|
||||
private function apply(InboundMessage $message, MessageDecision $decision): void
|
||||
{
|
||||
$booking = $decision->booking;
|
||||
if ($booking === null || $decision->has(MessageEffect::Review)) {
|
||||
return;
|
||||
}
|
||||
CaseLog::record($booking, 'message_in', $decision->medium->getLabel().'-Nachricht eingegangen ('.$decision->intent->getLabel().')', actor: CaseLog::GUEST, at: $message->received_at);
|
||||
if ($decision->has(MessageEffect::ReportToCase) || $decision->has(MessageEffect::ContributeFacts)) {
|
||||
BookingTask::openOnce($booking, BookingTaskKind::InboundReview, 'm'.$message->id, ['due_on' => today(), 'note' => $decision->medium->getLabel().'-Nachricht („'.mb_substr((string) $message->subject, 0, 100).'“) – im Posteingang ansehen; es wird nichts automatisch übernommen.']);
|
||||
}
|
||||
if ($decision->has(MessageEffect::ContributeFacts)) {
|
||||
app(ReceiveInboundMessage::class)->evaluate($message);
|
||||
}
|
||||
}
|
||||
|
||||
private function fromStored(InboundMessage $stored, IncomingMessage $incoming): MessageDecision
|
||||
{
|
||||
$data = (array) $stored->decision;
|
||||
|
||||
return new MessageDecision(
|
||||
$incoming->medium,
|
||||
MessageIntent::tryFrom((string) $stored->intent) ?? MessageIntent::Unclear,
|
||||
$stored->booking,
|
||||
array_values(array_filter(array_map(fn (string $effect): ?MessageEffect => MessageEffect::tryFrom($effect), (array) ($data['effects'] ?? [])))),
|
||||
(array) ($data['reasons'] ?? []),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Tenant;
|
||||
use App\Process\ProcessRunner;
|
||||
use App\Tenancy\TenantRunner;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Evaluates binding bookings that wait for an event again (V2.1, docs/Prozessarchitektur/V2.1/02 §5): the portal's
|
||||
* confirmation mail did not come in time (escalate once), came meanwhile (close the escalation, go on) – without this nothing
|
||||
* would resume or time out, because no scheduler looks at binding cases. Only cases whose channel makes them wait are
|
||||
* touched; once per landlord.
|
||||
*/
|
||||
#[Signature('bookings:advance-waiting')]
|
||||
#[Description('Re-evaluate binding bookings that wait for a portal confirmation (deadline, escalation, resume) – once per landlord')]
|
||||
class AdvanceWaitingCases extends Command
|
||||
{
|
||||
public function handle(TenantRunner $tenants, ProcessRunner $runner): int
|
||||
{
|
||||
$tenants->each(function (Tenant $tenant) use ($runner): void {
|
||||
$evaluated = 0;
|
||||
Booking::query()->occupying()->where('intake', 'booking')->where('created_at', '>', now()->subDays(90))
|
||||
->with(['property', 'guest', 'importChannel', 'originChannel'])
|
||||
->each(function (Booking $booking) use ($runner, &$evaluated): void {
|
||||
if (! $booking->process()->awaitsPortalConfirmation()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
$runner->advance($booking, 'schedule:waiting');
|
||||
$evaluated++;
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
}
|
||||
});
|
||||
|
||||
$this->info("{$tenant->name}: {$evaluated} wartende Vorgang/Vorgänge bewertet.");
|
||||
});
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* The communication medium a message came through (V2.1). It says nothing about bindingness or business meaning.
|
||||
* WhatsApp and Chat exist as test cases of the architecture; no provider is connected.
|
||||
*/
|
||||
enum Medium: string implements HasLabel
|
||||
{
|
||||
case Email = 'email';
|
||||
case Form = 'form';
|
||||
case WhatsApp = 'whatsapp';
|
||||
case Chat = 'chat';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Email => 'E-Mail',
|
||||
self::Form => 'Formular',
|
||||
self::WhatsApp => 'WhatsApp',
|
||||
self::Chat => 'Chat',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What a message may cause (V2.1). No effect creates a case, a reservation, an offer or a booking.
|
||||
*/
|
||||
enum MessageEffect: string implements HasLabel
|
||||
{
|
||||
case AnswerInformation = 'answer_information';
|
||||
case ContributeFacts = 'contribute_facts';
|
||||
case ReportToCase = 'report_to_case';
|
||||
case HandoffInquiry = 'handoff_inquiry';
|
||||
case Review = 'review';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::AnswerInformation => 'allgemeine Auskunft geben',
|
||||
self::ContributeFacts => 'Angaben für den Vorgang vorschlagen',
|
||||
self::ReportToCase => 'Aufgabe am Vorgang anlegen',
|
||||
self::HandoffInquiry => 'auf den Anfrageweg verweisen',
|
||||
self::Review => 'zur Klärung vorlegen',
|
||||
};
|
||||
}
|
||||
|
||||
/** Effects that act on an existing case and therefore need a verified assignment. */
|
||||
public function needsCase(): bool
|
||||
{
|
||||
return $this === self::ContributeFacts || $this === self::ReportToCase;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Communication\IntentClassifier;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What a message wants (V2.1) – decided by the rules of {@see IntentClassifier}, independent of the medium.
|
||||
*/
|
||||
enum MessageIntent: string implements HasLabel
|
||||
{
|
||||
case GeneralQuestion = 'general_question';
|
||||
case StayInquiry = 'stay_inquiry';
|
||||
case CaseReply = 'case_reply';
|
||||
case ProvideData = 'provide_data';
|
||||
case ChangeRequest = 'change_request';
|
||||
case Unclear = 'unclear';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::GeneralQuestion => 'allgemeine Frage',
|
||||
self::StayInquiry => 'Anfrage zu einem Aufenthalt',
|
||||
self::CaseReply => 'Antwort in einem Vorgang',
|
||||
self::ProvideData => 'Angaben zu einem Vorgang',
|
||||
self::ChangeRequest => 'Änderungswunsch',
|
||||
self::Unclear => 'unklar',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,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')
|
||||
|
||||
@@ -4,17 +4,21 @@
|
||||
|
||||
use App\Actions\ConfigureChannelProcess;
|
||||
use App\Enums\AdminMode;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Filament\Resources\Channels\ChannelResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\User;
|
||||
use App\Process\Capability;
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\ChannelProcessConfiguration;
|
||||
use App\Process\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 +48,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 +61,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 +73,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 +123,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 +160,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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,13 +176,26 @@ public function steps(): array
|
||||
$profile = $this->profile();
|
||||
$draft = $this->drafts[$this->intake];
|
||||
|
||||
return array_map(function (array $row) use ($configuration, $catalogue, $model, $profile): array {
|
||||
$rows = $configuration->preview($this->record, IntakeKind::from($this->intake), $this->draft());
|
||||
$labels = collect($rows)->mapWithKeys(fn (array $row): array => [$row['module'] => $row['label']]);
|
||||
$active = collect($rows)->where('on', true)->pluck('module')->all();
|
||||
|
||||
return array_map(function (array $row) use ($configuration, $catalogue, $model, $profile, $labels, $active): array {
|
||||
$definition = $catalogue->modules()[$row['module']]::definition();
|
||||
// The view of the order is derived from the same definitions the runner uses: only dependencies present in the plan count.
|
||||
$needs = collect($definition->requires)->filter(fn ($dependency): bool => $dependency->hard && in_array($dependency->module, $active, true))->map(fn ($dependency): string => $labels[$dependency->module])->values()->all();
|
||||
$after = collect($definition->requires)->filter(fn ($dependency): bool => ! $dependency->hard && in_array($dependency->module, $active, true))->map(fn ($dependency): string => $labels[$dependency->module])->values()->all();
|
||||
$controls = ChannelProcessConfiguration::STEP_CONTROLS[$row['module']] ?? [];
|
||||
$parameters = array_values(array_filter($controls['parameters'] ?? [], fn (ProcessSetting $setting): bool => in_array(IntakeKind::from($this->intake), $setting->channelIntakes(), true) && ! $model::fixesSetting($setting) && ($this->expert() || in_array($setting, [ProcessSetting::HoldHours, ProcessSetting::DataRequestReminderHours, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ClarificationHoldAutoMinutes], true))));
|
||||
$parameters = array_values(array_filter($controls['parameters'] ?? [], fn (ProcessSetting $setting): bool => in_array(IntakeKind::from($this->intake), $setting->channelIntakes(), true) && ! $model::fixesSetting($setting) && ($this->expert() || in_array($setting, [ProcessSetting::HoldHours, ProcessSetting::DataRequestReminderHours, ProcessSetting::ArrivalInfoDaysBefore, ProcessSetting::ClarificationHoldAutoMinutes, ProcessSetting::ContractDelivery, ProcessSetting::BookingNotice, ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours], true))));
|
||||
|
||||
return [...$row,
|
||||
'purpose' => $definition->purpose,
|
||||
'needs' => $needs,
|
||||
'after' => $after,
|
||||
'condition' => $definition->condition,
|
||||
'why' => $definition->why,
|
||||
'executions' => array_map(fn (Execution $execution): string => $execution->getLabel(), $definition->executions),
|
||||
'triggers' => $definition->triggers,
|
||||
'waits' => $definition->waits,
|
||||
'optional' => $definition->isOptional(),
|
||||
'version' => $catalogue->modules()[$row['module']]::version(),
|
||||
@@ -143,9 +203,9 @@ public function steps(): array
|
||||
'mode_options' => $configuration->modeOptions($row['module']),
|
||||
'performer_setting' => isset($controls['performer']) ? $controls['performer']['setting'] : null,
|
||||
'performer_options' => $configuration->performerOptions($model, $row['module']),
|
||||
'parameters' => array_map(fn (ProcessSetting $setting): array => $this->setting($setting, $profile), $parameters),
|
||||
'parameters' => array_map(fn (ProcessSetting $setting): array => [...$this->setting($setting, $profile), 'options' => $configuration->settingOptions($setting)], $parameters),
|
||||
];
|
||||
}, $configuration->preview($this->record, IntakeKind::from($this->intake), $draft));
|
||||
}, $rows);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,7 +242,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 +260,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 +280,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');
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
* to a case only by a reliable reference (CH-13); otherwise it waits in the inbox for the landlord. Being assigned is
|
||||
* not yet permission to take anything over.
|
||||
*/
|
||||
#[Fillable(['mailbox_id', 'message_id', 'in_reply_to', 'references', 'from_address', 'from_name', 'to_addresses', 'subject', 'body', 'received_at', 'test_mode', 'status', 'booking_id', 'match_reason', 'hints', 'portal_email_id', 'extraction_status', 'extraction', 'processed_at'])]
|
||||
#[Fillable(['mailbox_id', 'message_id', 'medium', 'intent', 'decision', 'in_reply_to', 'references', 'from_address', 'from_name', 'to_addresses', 'subject', 'body', 'received_at', 'test_mode', 'status', 'booking_id', 'match_reason', 'hints', 'portal_email_id', 'extraction_status', 'extraction', 'processed_at'])]
|
||||
class InboundMessage extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
@@ -44,6 +44,7 @@ protected function casts(): array
|
||||
'to_addresses' => 'array',
|
||||
'hints' => 'array',
|
||||
'extraction' => 'array',
|
||||
'decision' => 'array',
|
||||
'test_mode' => 'boolean',
|
||||
'received_at' => 'immutable_datetime',
|
||||
'processed_at' => 'immutable_datetime',
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
'channel_stale_after_minutes', 'channel_task_reminder_after_minutes',
|
||||
'reminder_interval_days', 'digest_daily', 'digest_weekly', 'digest_weekday', 'digest_hour', 'digest_sections',
|
||||
'digest_when_empty', 'digest_daily_sent_on', 'digest_weekly_sent_on',
|
||||
'process_defaults', 'document_releases',
|
||||
'process_defaults', 'document_releases', 'communication_rules',
|
||||
])]
|
||||
class Tenant extends Model
|
||||
{
|
||||
@@ -77,6 +77,7 @@ protected function casts(): array
|
||||
'digest_sections' => 'array',
|
||||
'process_defaults' => 'array',
|
||||
'document_releases' => 'array',
|
||||
'communication_rules' => 'array',
|
||||
'digest_when_empty' => 'boolean',
|
||||
'digest_daily_sent_on' => 'immutable_date',
|
||||
'digest_weekly_sent_on' => 'immutable_date',
|
||||
|
||||
@@ -28,6 +28,8 @@ final class ActivityDetails
|
||||
'binding' => ['status', 'portal_signal'],
|
||||
'price' => ['price', 'amount'],
|
||||
'documents' => ['document', 'mail'],
|
||||
'booking_notice' => ['booking_notice', 'mail'],
|
||||
'portal_confirmation' => ['portal_confirmation', 'evidence', 'task', 'mail'],
|
||||
'arrival_info' => ['document', 'mail'],
|
||||
'review' => ['mail'],
|
||||
'payment' => ['payment', 'amount'],
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
/**
|
||||
* One capability of a channel with the value in force and where it comes from (docs/Prozessarchitektur/V2.1/02 §3.1).
|
||||
*/
|
||||
final readonly class Capability
|
||||
{
|
||||
public const CONFIRMED = 'confirmed';
|
||||
|
||||
public const DERIVED = 'derived';
|
||||
|
||||
public const SUGGESTED = 'suggested';
|
||||
|
||||
public const UNKNOWN = 'unknown';
|
||||
|
||||
public function __construct(
|
||||
public string $key,
|
||||
public ?bool $value,
|
||||
public string $source,
|
||||
public ?string $note = null,
|
||||
public ?string $confirmedAt = null,
|
||||
public ?string $confirmedBy = null,
|
||||
) {}
|
||||
|
||||
public function isKnown(): bool
|
||||
{
|
||||
return $this->value !== null;
|
||||
}
|
||||
|
||||
public function sourceLabel(): string
|
||||
{
|
||||
return match ($this->source) {
|
||||
self::CONFIRMED => 'bestätigt'.($this->confirmedBy ? ' von '.$this->confirmedBy : '').($this->confirmedAt ? ' am '.substr($this->confirmedAt, 8, 2).'.'.substr($this->confirmedAt, 5, 2).'.'.substr($this->confirmedAt, 0, 4) : ''),
|
||||
self::DERIVED => 'abgeleitet aus Ihrer bisherigen Einstellung'.($this->note ? ' („'.$this->note.'“)' : '').' – bitte bestätigen oder korrigieren',
|
||||
self::SUGGESTED => 'Vorschlag des Kanalprofils – bitte bestätigen',
|
||||
default => 'noch nicht bekannt – bitte bestätigen',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Models\Channel;
|
||||
|
||||
/**
|
||||
* What a portal actually does for the landlord's account (K00 „Kanal-Fähigkeit“, docs/Prozessarchitektur/V2.1/02 §3). The
|
||||
* admissible process models follow from it; the profile of the portal only suggests values. The value in force is, in
|
||||
* this order: confirmed by an administrator · derived from an explicitly stored setting of the channel · suggested by the
|
||||
* channel profile · unknown (blocks nothing, is shown as „please confirm“).
|
||||
*/
|
||||
final class ChannelCapabilities
|
||||
{
|
||||
public const COLLECTS_PAYMENT = 'collects_payment';
|
||||
|
||||
public const PROVIDES_CONTRACT_DOCUMENTS = 'provides_contract_documents';
|
||||
|
||||
public const MESSAGES_GUEST = 'messages_guest';
|
||||
|
||||
public const SENDS_CONFIRMATION_MAIL = 'sends_confirmation_mail';
|
||||
|
||||
/** Older stored settings that imply a capability: capability => [setting, value that means yes, value that means no]. */
|
||||
private const LEGACY = [
|
||||
self::COLLECTS_PAYMENT => ['payments', 'portal', 'landlord'],
|
||||
self::PROVIDES_CONTRACT_DOCUMENTS => ['documents', 'portal', 'landlord'],
|
||||
self::MESSAGES_GUEST => ['guest_messages', 'portal', 'landlord'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<string, array{label: string, question: string}>
|
||||
*/
|
||||
public static function definitions(): array
|
||||
{
|
||||
return [
|
||||
self::COLLECTS_PAYMENT => ['label' => 'Inkasso', 'question' => 'Zieht das Portal das Geld des Gastes ein?'],
|
||||
self::PROVIDES_CONTRACT_DOCUMENTS => ['label' => 'Vertragsunterlagen', 'question' => 'Stellt das Portal dem Gast die verbindlichen Vertragsunterlagen bereit?'],
|
||||
self::MESSAGES_GUEST => ['label' => 'Gastkommunikation', 'question' => 'Schreibt das Portal den Gast an (Anreise-Information, Erinnerungen)?'],
|
||||
self::SENDS_CONFIRMATION_MAIL => ['label' => 'Bestätigungsmail', 'question' => 'Schickt das Portal Ihnen eine Buchungsbestätigung per E-Mail?'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The capabilities of a channel; a draft (key => bool|null) overrides what is stored, to show what a change would do.
|
||||
*
|
||||
* @param array<string, bool|null>|null $draft
|
||||
* @return array<string, Capability>
|
||||
*/
|
||||
public function resolve(Channel $channel, ?array $draft = null): array
|
||||
{
|
||||
$stored = (array) (($channel->settings ?? [])['capabilities'] ?? []);
|
||||
$legacy = (array) (($channel->process_overrides ?? [])['booking'] ?? []);
|
||||
$suggested = (array) (config('channels.portal_profiles.'.app(ChannelProcessConfiguration::class)->profileKey($channel).'.capabilities') ?? []);
|
||||
$result = [];
|
||||
|
||||
foreach (array_keys(self::definitions()) as $key) {
|
||||
if ($draft !== null && array_key_exists($key, $draft) && $draft[$key] !== null && $draft[$key] !== '') {
|
||||
// A value the landlord only left as shown keeps its origin; a changed one is a pending confirmation.
|
||||
$value = filter_var($draft[$key], FILTER_VALIDATE_BOOLEAN);
|
||||
$base = $this->resolve($channel)[$key];
|
||||
if ($base->value !== $value) {
|
||||
$result[$key] = new Capability($key, $value, Capability::CONFIRMED, null, now()->toIso8601String(), auth()->user()?->name);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isset($stored[$key]['value'])) {
|
||||
$result[$key] = new Capability($key, (bool) $stored[$key]['value'], Capability::CONFIRMED, null, $stored[$key]['at'] ?? null, $stored[$key]['by'] ?? null);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (isset(self::LEGACY[$key]) && filled($legacy[self::LEGACY[$key][0]] ?? null)) {
|
||||
[$setting, $yes, $no] = self::LEGACY[$key];
|
||||
$value = (string) $legacy[$setting];
|
||||
if (in_array($value, [$yes, $no], true)) {
|
||||
$result[$key] = new Capability($key, $value === $yes, Capability::DERIVED, $value === $yes ? 'Portal' : 'wir');
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$result[$key] = array_key_exists($key, $suggested) && $suggested[$key] !== null
|
||||
? new Capability($key, (bool) $suggested[$key], Capability::SUGGESTED)
|
||||
: new Capability($key, null, Capability::UNKNOWN);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function value(Channel $channel, string $key): ?bool
|
||||
{
|
||||
return $this->resolve($channel)[$key]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* What is stored to confirm the capabilities of a draft, and the readable list of what changed.
|
||||
*
|
||||
* @param array<string, bool|string|null> $draft
|
||||
* @return array{capabilities: array<string, array{value: bool, at: string, by: ?string}>, changes: list<string>}
|
||||
*/
|
||||
public function confirm(Channel $channel, array $draft, ?string $by): array
|
||||
{
|
||||
$stored = (array) (($channel->settings ?? [])['capabilities'] ?? []);
|
||||
$changes = [];
|
||||
foreach (self::definitions() as $key => $definition) {
|
||||
if (! array_key_exists($key, $draft) || $draft[$key] === null || $draft[$key] === '') {
|
||||
continue;
|
||||
}
|
||||
$value = filter_var($draft[$key], FILTER_VALIDATE_BOOLEAN);
|
||||
if (isset($stored[$key]['value']) && (bool) $stored[$key]['value'] === $value) {
|
||||
continue;
|
||||
}
|
||||
$changes[] = $definition['label'].': '.(isset($stored[$key]['value']) ? ($stored[$key]['value'] ? 'ja' : 'nein').' → ' : '').($value ? 'ja' : 'nein');
|
||||
$stored[$key] = ['value' => $value, 'at' => now()->toIso8601String(), 'by' => $by];
|
||||
}
|
||||
|
||||
return ['capabilities' => $stored, 'changes' => $changes];
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Process;
|
||||
|
||||
use App\Enums\BookingNoticeMode;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\ContractDelivery;
|
||||
use App\Enums\DataRequestMode;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
@@ -31,7 +33,9 @@ final class ChannelProcessConfiguration
|
||||
'hold' => ['parameters' => [ProcessSetting::ClarificationHoldAutoMinutes, ProcessSetting::ClarificationHoldManualMinutes]],
|
||||
'offer.binding' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::HoldHours, ProcessSetting::ContractTemplate]],
|
||||
'offer.information' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::GuestLinkValidDays]],
|
||||
'documents.send' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::ContractTemplate]],
|
||||
'documents.send' => ['mode' => ProcessSetting::Processing, 'parameters' => [ProcessSetting::ContractDelivery, ProcessSetting::ContractTemplate]],
|
||||
'documents.booking_notice' => ['parameters' => [ProcessSetting::BookingNotice]],
|
||||
'portal.confirmation' => ['parameters' => [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours]],
|
||||
'arrival.info' => ['performer' => ['field' => 'guest_messages', 'setting' => ProcessSetting::GuestMessages], 'parameters' => [ProcessSetting::ArrivalInfoDaysBefore]],
|
||||
];
|
||||
|
||||
@@ -79,15 +83,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +197,21 @@ public function performerOptions(ProcessModel $model, string $module): array
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* The fixed choices of a setting that is not free text (null: free input).
|
||||
*
|
||||
* @return array<string, string>|null
|
||||
*/
|
||||
public function settingOptions(ProcessSetting $setting): ?array
|
||||
{
|
||||
return match ($setting) {
|
||||
ProcessSetting::ContractDelivery => collect(ContractDelivery::cases())->mapWithKeys(fn (ContractDelivery $case): array => [$case->value => $case->getLabel()])->all(),
|
||||
ProcessSetting::BookingNotice => collect(BookingNoticeMode::cases())->mapWithKeys(fn (BookingNoticeMode $case): array => [$case->value => $case->getLabel()])->all(),
|
||||
ProcessSetting::AwaitPortalConfirmation => ['1' => 'ja, erst nach der Bestätigungsmail', '0' => 'nein, sofort'],
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Allowed modes of a step (as values of its setting).
|
||||
*
|
||||
@@ -195,11 +281,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.'];
|
||||
|
||||
@@ -47,6 +47,9 @@ public function variants(): array
|
||||
->testerOnly()
|
||||
->insert(Point::AfterGuestIdentified, 'guest.loyalty_status')
|
||||
->insert(Point::BeforePriceFixing, 'pricing.loyalty_discount'),
|
||||
Variant::make('address_check', 'Angebot mit Anschriftsprüfung (Zusatzschritt, nur im Prozess-Tester)')
|
||||
->testerOnly()
|
||||
->insert(Point::AfterGuestIdentified, 'guest.address_check'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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).
|
||||
*
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Guest;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Dependency;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Modules\StepState;
|
||||
|
||||
/**
|
||||
* V2.1 case H (docs/Prozessarchitektur/V2.1/ABNAHME_V2_1.md): an optional plausibility check of the guest's address, added
|
||||
* at the extension point „after the guest is identified“ without touching any other model. It only informs – the result
|
||||
* never holds back an offer or a booking (the address gate of v0.11 stays the only rule). Tester only until released.
|
||||
*/
|
||||
final class AddressCheck extends Module
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'guest.address_check';
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Anschrift auf Plausibilität prüfen',
|
||||
purpose: 'Prüft, ob die Anschrift des Gastes plausibel aussieht (Postleitzahl, Ort). Es ist ein Hinweis; nichts wird dadurch aufgehalten.',
|
||||
phase: 'P01',
|
||||
requires: [Dependency::hard('guest.details')],
|
||||
triggers: ['facts.applied'],
|
||||
toggle: ModuleDefinition::TOGGLE_OPTIONAL,
|
||||
events: ['facts'],
|
||||
points: ['after_guest_identified'],
|
||||
availability: ModuleDefinition::AVAILABILITY_TESTER_ONLY,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string> what looks implausible (empty: plausible)
|
||||
*/
|
||||
public function findings(CaseContext $case): array
|
||||
{
|
||||
$guest = $case->booking->guest;
|
||||
$findings = [];
|
||||
if (blank($guest?->street)) {
|
||||
$findings[] = 'Straße fehlt';
|
||||
}
|
||||
if (blank($guest?->city)) {
|
||||
$findings[] = 'Ort fehlt';
|
||||
}
|
||||
if (in_array(mb_strtoupper((string) $guest?->country), ['', 'DE', 'DEUTSCHLAND'], true) && ! preg_match('/^\d{5}$/', trim((string) $guest?->postal_code))) {
|
||||
$findings[] = 'Postleitzahl hat nicht fünf Ziffern';
|
||||
}
|
||||
|
||||
return $findings;
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$findings = $this->findings($case);
|
||||
|
||||
return [new Activity('address_check', 'Anschrift auf Plausibilität prüfen', ActivityState::Done, $findings === [] ? 'Anschrift wirkt plausibel' : 'Hinweis: '.implode(', ', $findings))];
|
||||
}
|
||||
|
||||
public function state(CaseContext $case): ?StepState
|
||||
{
|
||||
return StepState::Done;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\Execution;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
@@ -25,6 +26,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Verfügbarkeit',
|
||||
purpose: 'Prüft, ob der Zeitraum frei ist und die Kalender der Portale aktuell sind.',
|
||||
phase: 'P01',
|
||||
executions: [Execution::Automatic],
|
||||
condition: 'bei jeder Anfrage vor Angebot oder Bestätigung',
|
||||
why: 'Doppelbuchungen sind nicht zu verantworten (E-027); die Verfügbarkeit wird immer geprüft.',
|
||||
effects: ['network'],
|
||||
triggers: ['intake', 'facts.applied'],
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\ChannelTaskStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
|
||||
use App\Models\ChannelTask;
|
||||
use App\Process\Activity;
|
||||
@@ -29,6 +30,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Andere Kanäle sperren',
|
||||
purpose: 'Sperrt den Zeitraum in Portalen, die nicht automatisch abgleichen, und gibt ihn bei Ende wieder frei – mit Nachweis je Portal.',
|
||||
phase: 'P02',
|
||||
executions: [Execution::Automatic, Execution::Manual],
|
||||
condition: 'sobald ein Vorgang den Zeitraum belegt',
|
||||
why: 'Die Belegung muss in anderen Portalen nachgezogen werden, sonst droht eine Doppelbuchung.',
|
||||
effects: ['channel_task', 'landlord_mail', 'network'],
|
||||
waits: ['landlord', 'portal'],
|
||||
triggers: ['booking.occupies', 'booking.released'],
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Actions\RequestCaseData;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Models\DataRequest;
|
||||
use App\Process\Activity;
|
||||
@@ -34,6 +35,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Fehlende Angaben beim Gast anfragen',
|
||||
purpose: 'Fragt fehlende Pflichtangaben per Link beim Gast an, erinnert und übergibt an Sie, wenn der Gast nicht antwortet.',
|
||||
phase: 'P01',
|
||||
executions: [Execution::Automatic, Execution::Approval, Execution::Manual, Execution::NotRequired],
|
||||
condition: 'wenn Angaben für den nächsten Schritt fehlen und eine E-Mail-Adresse bekannt ist',
|
||||
requires: [Dependency::hard('intake.record')],
|
||||
effects: ['case_write', 'guest_mail'],
|
||||
waits: ['guest', 'landlord', 'time'],
|
||||
|
||||
@@ -3,6 +3,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,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Modules\Intake;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Models\BookingTask;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\CaseLog;
|
||||
use App\Process\Modules\Dependency;
|
||||
use App\Process\Modules\Module;
|
||||
use App\Process\Modules\ModuleDefinition;
|
||||
use App\Process\Modules\RunsAutomatically;
|
||||
use App\Process\Modules\StepState;
|
||||
use App\Process\PortalConfirmation;
|
||||
use App\Process\StepResult;
|
||||
|
||||
/**
|
||||
* P02 for extern binding bookings (V2.1, docs/Prozessarchitektur/V2.1/02 §5): waits for the portal's booking confirmation
|
||||
* mail, assigned to the case deterministically, before the steps that depend on it hard (contract documents, booking notice)
|
||||
* go on. The occupation does not wait: the booking is binding from the start and its calendar entries are protected
|
||||
* (binding.portal, channels.block do not depend on this step). Without the mail within the configured time the landlord gets
|
||||
* one task; nothing is sent or released automatically. The landlord can confirm in the case, or send by hand.
|
||||
*/
|
||||
final class PortalConfirmationStep extends Module implements RunsAutomatically
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'portal.confirmation';
|
||||
}
|
||||
|
||||
public static function definition(): ModuleDefinition
|
||||
{
|
||||
return new ModuleDefinition(
|
||||
label: 'Bestätigung des Portals abwarten',
|
||||
purpose: 'Wartet auf die Bestätigungsmail des Portals, bevor Unterlagen und Nachrichten an den Gast gehen. Die Belegung ist von Anfang an gesichert.',
|
||||
phase: 'P02',
|
||||
why: 'Solange das Portal die Buchung nicht bestätigt hat, sollen keine Unterlagen an den Gast gehen; die Belegung ist trotzdem gesichert.',
|
||||
executions: [Execution::Automatic, Execution::Manual, Execution::NotRequired],
|
||||
condition: 'nur bei extern verbindlicher Buchung und nur, wenn für den Kanal „Bestätigungsmail abwarten“ eingestellt ist',
|
||||
requires: [Dependency::hard('intake.record')],
|
||||
effects: ['case_write'],
|
||||
waits: ['portal', 'time', 'landlord'],
|
||||
triggers: ['portal.mail', 'schedule:waiting', 'booking.taken_over'],
|
||||
parameters: [ProcessSetting::AwaitPortalConfirmation, ProcessSetting::PortalConfirmationWaitHours],
|
||||
toggle: ModuleDefinition::TOGGLE_CONDITIONAL,
|
||||
performers: ['portal', 'landlord'],
|
||||
modes: ['automatic'],
|
||||
events: ['portal_confirmation', 'evidence', 'task'],
|
||||
);
|
||||
}
|
||||
|
||||
public function applies(CaseContext $case): bool
|
||||
{
|
||||
return ! $case->inquiry && ! $case->closed && $case->profile->awaitsPortalConfirmation();
|
||||
}
|
||||
|
||||
public function state(CaseContext $case): ?StepState
|
||||
{
|
||||
if (PortalConfirmation::evidence($case->booking) !== null) {
|
||||
return StepState::Done;
|
||||
}
|
||||
|
||||
return PortalConfirmation::isOverdue($case->booking) ? StepState::Problem : StepState::Waiting;
|
||||
}
|
||||
|
||||
public function activities(CaseContext $case): array
|
||||
{
|
||||
$evidence = PortalConfirmation::evidence($case->booking);
|
||||
$deadline = PortalConfirmation::deadline($case->booking);
|
||||
|
||||
return [new Activity('portal_confirmation', 'Bestätigung des Portals abwarten', match (true) {
|
||||
$evidence !== null => ActivityState::Done,
|
||||
PortalConfirmation::isOverdue($case->booking) => ActivityState::Problem,
|
||||
default => ActivityState::Waiting,
|
||||
}, match (true) {
|
||||
$evidence !== null => $evidence['label'],
|
||||
PortalConfirmation::isOverdue($case->booking) => 'ausgeblieben seit '.$deadline->format('d.m.Y, H:i').' Uhr – bitte beim Portal prüfen; Unterlagen und Nachrichten warten weiter, bis Sie bestätigen oder von Hand senden',
|
||||
default => 'erwartet bis '.$deadline->format('d.m.Y, H:i').' Uhr – Unterlagen und Nachrichten warten; die Belegung ist gesichert',
|
||||
}, $evidence === null ? 'confirmPortal' : null)];
|
||||
}
|
||||
|
||||
/** Due when the time ran out without the mail: escalate once; or when the mail arrived and the escalation is still open. */
|
||||
public function due(CaseContext $case): bool
|
||||
{
|
||||
$open = $this->openTask($case) !== null;
|
||||
$evidence = PortalConfirmation::evidence($case->booking) !== null;
|
||||
|
||||
return ($evidence && $open) || (! $evidence && ! $open && PortalConfirmation::isOverdue($case->booking));
|
||||
}
|
||||
|
||||
public function blockers(CaseContext $case): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function run(CaseContext $case): StepResult
|
||||
{
|
||||
$task = $this->openTask($case);
|
||||
if (PortalConfirmation::evidence($case->booking) !== null) {
|
||||
$task?->complete(CaseLog::SYSTEM, 'Die Bestätigung des Portals liegt jetzt vor.');
|
||||
|
||||
return StepResult::ran();
|
||||
}
|
||||
|
||||
BookingTask::openOnce($case->booking, BookingTaskKind::PortalConfirmationMissing, 'portal-confirmation', [
|
||||
'due_on' => today(),
|
||||
'note' => 'Die Bestätigungsmail des Portals ist bis '.PortalConfirmation::deadline($case->booking)->format('d.m.Y, H:i').' Uhr nicht eingegangen. Die Belegung ist gesichert. Bitte beim Portal prüfen und im Vorgang bestätigen – oder die Unterlagen von Hand senden.',
|
||||
]);
|
||||
CaseLog::record($case->booking, 'task', 'Bestätigungsmail des Portals fehlt – Aufgabe angelegt', actor: CaseLog::SYSTEM);
|
||||
|
||||
return StepResult::ran();
|
||||
}
|
||||
|
||||
public function isOutward(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private function openTask(CaseContext $case): ?BookingTask
|
||||
{
|
||||
return BookingTask::query()->where('booking_id', $case->booking->id)->where('kind', BookingTaskKind::PortalConfirmationMissing)->where('status', BookingTaskStatus::Open)->first();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Process\Modules;
|
||||
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
|
||||
/**
|
||||
@@ -41,6 +42,9 @@
|
||||
* @param list<string> $events history types that belong to the step (shown behind the step)
|
||||
* @param list<string> $points extension points the module may be inserted at (checked; empty = fixed place in a model)
|
||||
* @param bool $readsContractData evaluates frozen contract data – needs an ongoing-case test (checked)
|
||||
* @param list<Execution> $executions the admissible ways to fulfil the task (V2.1; the model may narrow them)
|
||||
* @param string|null $condition when the step applies, in plain words (DESCRIBES – the logic is `applies()`, never read from here)
|
||||
* @param string|null $why why the task is mandatory, shown instead of a lock
|
||||
*/
|
||||
public function __construct(
|
||||
public string $label,
|
||||
@@ -58,6 +62,9 @@ public function __construct(
|
||||
public array $points = [],
|
||||
public bool $readsContractData = false,
|
||||
public string $availability = self::AVAILABILITY_PRODUCTION,
|
||||
public array $executions = [],
|
||||
public ?string $condition = null,
|
||||
public ?string $why = null,
|
||||
) {}
|
||||
|
||||
public function isOptional(): bool
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Money;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Process\Activity;
|
||||
use App\Process\CaseContext;
|
||||
use App\Process\Modules\Module;
|
||||
@@ -25,6 +26,8 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Zahlung (ohne Erinnerungen)',
|
||||
purpose: 'Hält fest, was bei einer Eigenbelegung oder privaten Überlassung bezahlt wurde – ohne Erinnerungen.',
|
||||
phase: 'P03',
|
||||
executions: [Execution::Manual],
|
||||
condition: 'bei einer Eigenbelegung mit Preis',
|
||||
effects: ['case_write'],
|
||||
toggle: ModuleDefinition::TOGGLE_CONDITIONAL,
|
||||
performers: ['landlord'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Money;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Process\Activity;
|
||||
@@ -28,6 +29,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Zahlungen des Gastes',
|
||||
purpose: 'Überwacht Anzahlung und Restzahlung und erinnert rechtzeitig – oder zeigt, was das Portal laut eigener Angabe eingezogen hat.',
|
||||
phase: 'P03',
|
||||
executions: [Execution::Manual, Execution::Portal],
|
||||
condition: 'bei jeder verbindlichen Buchung',
|
||||
why: 'Zahlungen werden überwacht – von uns oder durch das Portal (nur „laut Portal“).',
|
||||
effects: ['case_write', 'guest_mail'],
|
||||
waits: ['guest', 'portal', 'time'],
|
||||
triggers: ['payment.recorded', 'portal.amounts', 'schedule:reminders'],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Process\Modules\Money;
|
||||
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\Execution;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Pricing\CaseMoney;
|
||||
use App\Process\Activity;
|
||||
@@ -28,6 +29,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Auszahlung des Portals',
|
||||
purpose: 'Prüft, ob die Auszahlung des Portals tatsächlich auf unserem Konto eingegangen ist und zu den Angaben passt.',
|
||||
phase: 'P03',
|
||||
executions: [Execution::Manual],
|
||||
condition: 'wenn das Portal das Geld einzieht',
|
||||
why: 'Die Auszahlung muss tatsächlich auf unserem Konto eingehen (O5).',
|
||||
effects: ['case_write'],
|
||||
waits: ['portal', 'landlord', 'time'],
|
||||
triggers: ['portal.amounts', 'payment.recorded'],
|
||||
|
||||
@@ -5,6 +5,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,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Unverbindliche Auskunft und Buchungswunsch',
|
||||
purpose: 'Beantwortet die Anfrage mit einer unverbindlichen Auskunft ohne Reservierung; fragt der Gast die Buchung an, wird erneut geprüft und verbindlich bestätigt.',
|
||||
phase: 'P02',
|
||||
why: 'Der Gast braucht eine Antwort auf seine Anfrage; ob sie automatisch oder von Hand kommt, bestimmen Sie.',
|
||||
executions: [Execution::Automatic, Execution::Manual],
|
||||
condition: 'bei einer Anfrage ohne Reservierung',
|
||||
requires: [Dependency::hard('intake.record'), Dependency::soft('guest.data_request')],
|
||||
effects: ['case_write', 'guest_mail', 'landlord_mail', 'document'],
|
||||
waits: ['guest', 'landlord'],
|
||||
|
||||
@@ -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,9 @@ public static function definition(): ModuleDefinition
|
||||
label: 'Anreise-Informationen',
|
||||
purpose: 'Wegbeschreibung, Schlüssel und Kontakt vor Ort rechtzeitig vor der Anreise.',
|
||||
phase: 'P04',
|
||||
why: 'Ohne Anreise-Informationen finden Gäste Schlüssel und Wohnung nicht; wer sie sendet, ist einstellbar.',
|
||||
executions: [Execution::Automatic, Execution::Portal, Execution::ServiceProvider, Execution::NotRequired],
|
||||
condition: 'bei verbindlichen Buchungen',
|
||||
effects: ['guest_mail'],
|
||||
waits: ['time', 'portal'],
|
||||
triggers: ['schedule:reminders'],
|
||||
|
||||
@@ -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.'.' : ''));
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public function request(array $guest): Booking
|
||||
public function travel(int $minutes): void
|
||||
{
|
||||
Date::setTestNow(now()->addMinutes($minutes));
|
||||
foreach (['bookings:expire-holds', 'bookings:auto-offers', 'cases:data-requests'] as $command) {
|
||||
foreach (['bookings:advance-waiting', 'bookings:expire-holds', 'bookings:auto-offers', 'cases:data-requests'] as $command) {
|
||||
Artisan::call($command);
|
||||
}
|
||||
app(SendBookingReminders::class)->handle();
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Process\Tester\Scenarios\CommunicationFailure;
|
||||
use App\Process\Tester\Scenarios\CompleteRequest;
|
||||
use App\Process\Tester\Scenarios\GeneralQuestionMessage;
|
||||
use App\Process\Tester\Scenarios\MessageOtherMedium;
|
||||
use App\Process\Tester\Scenarios\MissingAddress;
|
||||
use App\Process\Tester\Scenarios\PortalBooking;
|
||||
use App\Process\Tester\Scenarios\PortalConfirmationWait;
|
||||
use App\Process\Tester\Scenarios\PortalInquiry;
|
||||
use App\Process\Tester\Scenarios\ReturningGuest;
|
||||
use App\Process\Tester\Scenarios\Scenario;
|
||||
@@ -17,7 +20,7 @@
|
||||
final class ScenarioCatalogue
|
||||
{
|
||||
/** @var list<class-string<Scenario>> */
|
||||
public const SCENARIOS = [CompleteRequest::class, MissingAddress::class, PortalInquiry::class, ReturningGuest::class, CommunicationFailure::class, PortalBooking::class];
|
||||
public const SCENARIOS = [CompleteRequest::class, MissingAddress::class, PortalInquiry::class, ReturningGuest::class, CommunicationFailure::class, PortalBooking::class, PortalConfirmationWait::class, MessageOtherMedium::class, GeneralQuestionMessage::class];
|
||||
|
||||
/**
|
||||
* @return array<string, class-string<Scenario>>
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Tester\Scenarios;
|
||||
|
||||
use App\Communication\IncomingMessage;
|
||||
use App\Communication\MessageIntake;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\Medium;
|
||||
use App\Process\Tester\SandboxContext;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* V2.1: a general question or a stay inquiry arrives by chat without any case. Shows that it is only answered or referred
|
||||
* to the inquiry path and creates no case, reservation or booking.
|
||||
*/
|
||||
final class GeneralQuestionMessage extends Scenario
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'general_question_message';
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Allgemeine Frage im Chat (ohne Vorgang)';
|
||||
}
|
||||
|
||||
public static function description(): string
|
||||
{
|
||||
return 'Eine Frage oder Terminanfrage kommt ohne Vorgang im Chat an. Es entsteht kein Vorgang; die Nachricht wird nur beantwortet, auf den Anfrageweg verwiesen oder geklärt.';
|
||||
}
|
||||
|
||||
public static function intakes(): array
|
||||
{
|
||||
return [IntakeKind::Inquiry];
|
||||
}
|
||||
|
||||
public static function inputs(): array
|
||||
{
|
||||
return [
|
||||
'text' => ['label' => 'Nachricht', 'default' => 'question', 'type' => 'select', 'options' => ['question' => 'Sind Hunde erlaubt?', 'stay' => 'Ist die Wohnung im Dezember frei?', 'unclear' => 'ok danke']],
|
||||
];
|
||||
}
|
||||
|
||||
public function events(array $inputs): array
|
||||
{
|
||||
$text = match ((string) ($inputs['text'] ?? 'question')) {
|
||||
'stay' => 'Ist die Wohnung vom 12.12. bis 19.12. frei? Wir würden gern buchen.',
|
||||
'unclear' => 'ok danke',
|
||||
default => 'Sind Hunde erlaubt und gibt es einen Parkplatz?',
|
||||
};
|
||||
|
||||
return [new ScenarioEvent('Nachricht im Chat ohne Vorgang', fn (SandboxContext $context) => app(MessageIntake::class)->handle(
|
||||
new IncomingMessage(Medium::Chat, 'chat-visitor-1', $text, CarbonImmutable::now(), 'tester-'.md5($text)),
|
||||
))];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Tester\Scenarios;
|
||||
|
||||
use App\Communication\IncomingMessage;
|
||||
use App\Communication\MessageIntake;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\Medium;
|
||||
use App\Process\Tester\SandboxContext;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* V2.1: a message of a guest arrives through another medium (WhatsApp or chat; no provider, only the entry). Shows how
|
||||
* medium, reference and rules decide – assigned reply, unassignable message, contradictory reference – and that nothing
|
||||
* is taken over or created by itself.
|
||||
*/
|
||||
final class MessageOtherMedium extends Scenario
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'message_other_medium';
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Nachricht über WhatsApp oder Chat';
|
||||
}
|
||||
|
||||
public static function description(): string
|
||||
{
|
||||
return 'Der Gast antwortet in einem anderen Medium – mit überprüftem Bezug, ohne Bezug oder mit widersprüchlicher Vorgangsnummer. Zeigt Zuordnung, Absicht und erlaubte Wirkung.';
|
||||
}
|
||||
|
||||
public static function intakes(): array
|
||||
{
|
||||
return [IntakeKind::Inquiry, IntakeKind::Booking];
|
||||
}
|
||||
|
||||
public static function inputs(): array
|
||||
{
|
||||
return [
|
||||
...parent::inputs(),
|
||||
'medium' => ['label' => 'Medium', 'default' => 'whatsapp', 'type' => 'select', 'options' => ['whatsapp' => 'WhatsApp', 'chat' => 'Chat']],
|
||||
'reference' => ['label' => 'Bezug', 'default' => 'verified', 'type' => 'select', 'options' => ['verified' => 'überprüfter Bezug zum Vorgang', 'none' => 'kein Bezug (nur Absender)', 'contradicting' => 'überprüfter Bezug, Text nennt andere Nummer']],
|
||||
'consent' => ['label' => 'Einwilligung des Gastes liegt vor', 'default' => true, 'type' => 'bool'],
|
||||
];
|
||||
}
|
||||
|
||||
public function events(array $inputs): array
|
||||
{
|
||||
return [
|
||||
new ScenarioEvent('Anfrage des Gastes liegt vor', fn (SandboxContext $context) => $context->request([])),
|
||||
new ScenarioEvent('Nachricht des Gastes im anderen Medium', function (SandboxContext $context) use ($inputs): void {
|
||||
$reference = (string) ($inputs['reference'] ?? 'verified');
|
||||
$text = 'Wir kommen am Anreisetag gegen 16 Uhr an.'.($reference === 'contradicting' ? ' Vorgang 2099-0001' : '');
|
||||
app(MessageIntake::class)->handle(new IncomingMessage(
|
||||
Medium::tryFrom((string) ($inputs['medium'] ?? 'whatsapp')) ?? Medium::WhatsApp, '+49170000000', $text, CarbonImmutable::now(), 'tester-'.md5($text),
|
||||
$reference === 'none' ? null : $context->booking?->id, (bool) ($inputs['consent'] ?? true),
|
||||
));
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Process\Tester\Scenarios;
|
||||
|
||||
use App\Actions\ProcessPortalMail;
|
||||
use App\Actions\TakeOverExternalBooking;
|
||||
use App\Channels\Mail\PortalMail;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Process\Tester\SandboxContext;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* V2.1: a booking binding at the portal is known without the portal's confirmation mail, e.g. from a calendar or a manual entry; the
|
||||
* mail comes at once, late or never. Shows what waits (documents, booking information), that the occupation does not,
|
||||
* and the escalation when the mail stays away.
|
||||
*/
|
||||
final class PortalConfirmationWait extends Scenario
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'portal_confirmation_wait';
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Bestätigungsmail des Portals: sofort, verspätet oder ausbleibend';
|
||||
}
|
||||
|
||||
public static function description(): string
|
||||
{
|
||||
return 'Die Buchung ist bekannt, die Bestätigungsmail des Portals kommt sofort, nach einigen Stunden oder gar nicht. Zeigt, was wartet, was nicht, und wann Sie eine Aufgabe erhalten.';
|
||||
}
|
||||
|
||||
public static function intakes(): array
|
||||
{
|
||||
return [IntakeKind::Booking];
|
||||
}
|
||||
|
||||
public static function inputs(): array
|
||||
{
|
||||
return [
|
||||
...parent::inputs(),
|
||||
'confirmation' => ['label' => 'Bestätigungsmail', 'default' => 'late', 'type' => 'select', 'options' => ['immediate' => 'sofort', 'late' => 'nach 5 Stunden', 'missing' => 'bleibt aus']],
|
||||
];
|
||||
}
|
||||
|
||||
public function events(array $inputs): array
|
||||
{
|
||||
$known = new ScenarioEvent('Buchung ist bekannt (ohne Bestätigungsmail des Portals)', function (SandboxContext $context): void {
|
||||
$context->booking = app(TakeOverExternalBooking::class)->handle($context->property, $context->channel, $context->arrival(), $context->departure(), [
|
||||
'portal_reference' => $this->reference($context), 'portal_total' => 98000, 'guests' => $context->guests(),
|
||||
'guest' => ['first_name' => 'Testgast', 'last_name' => 'Portal', 'email' => 'portalgast@tester.invalid', 'street' => 'Teststraße 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn', 'country' => 'DE'],
|
||||
]);
|
||||
});
|
||||
|
||||
return [$known, ...match ((string) ($inputs['confirmation'] ?? 'late')) {
|
||||
'immediate' => [$this->mailEvent()],
|
||||
'missing' => [new ScenarioEvent('60 Stunden vergehen – die Mail bleibt aus', fn (SandboxContext $context) => $context->travel(60 * 60))],
|
||||
default => [new ScenarioEvent('5 Stunden vergehen', fn (SandboxContext $context) => $context->travel(5 * 60)), $this->mailEvent()],
|
||||
}];
|
||||
}
|
||||
|
||||
private function mailEvent(): ScenarioEvent
|
||||
{
|
||||
return new ScenarioEvent('Bestätigungsmail des Portals kommt an', function (SandboxContext $context): void {
|
||||
$senders = array_values(array_filter(array_map('trim', explode(',', (string) ($context->channel->setting('email_senders') ?? '')))));
|
||||
$text = "Gast: Testgast Portal\nAnreise: ".$context->arrival()->format('d.m.Y')."\nAbreise: ".$context->departure()->format('d.m.Y')."\nBuchungsnummer: ".$this->reference($context);
|
||||
app(ProcessPortalMail::class)->handle(new PortalMail('<'.md5($text).'@tester.invalid>', 'buchung@'.($senders[0] ?? 'portal.invalid'), 'Neue Buchung', $text, CarbonImmutable::now()));
|
||||
});
|
||||
}
|
||||
|
||||
private function reference(SandboxContext $context): string
|
||||
{
|
||||
return 'TEST-'.$context->arrival()->format('md');
|
||||
}
|
||||
}
|
||||
+11
-9
@@ -26,17 +26,19 @@
|
||||
'uid_suffix' => '@fewo-stommer',
|
||||
|
||||
/*
|
||||
| Business and integration capabilities per kind of channel (decision E2/O2): which process models may be chosen for
|
||||
| requests and for bookings that are binding at the portal. A channel names its profile in settings.portal_profile
|
||||
| (Kanal › Ablauf); without one it is recognised by its name, else "generic". Further models are released here after
|
||||
| a business review – never as a special rule in the process core.
|
||||
| Channel profiles (decision E2/O2, V2.1): a profile only SUGGESTS what a portal does for the landlord's account – it is
|
||||
| recognised by name or named in settings.portal_profile. The suggested capabilities are no gate: the administrator
|
||||
| confirms or corrects them per channel (Kanal › Ablauf), and the admissible process models follow from the confirmed
|
||||
| values (App\Process\ChannelCapabilities). null = unknown (blocks nothing, shown as "please confirm").
|
||||
| FeWo-direkt: R09 (the portal collects, our own contract documents). Destination Solutions: E-016 / R08 – "für den
|
||||
| beschriebenen Vermieterzugang": we collect and document; the account may change.
|
||||
*/
|
||||
'portal_profiles' => [
|
||||
'website' => ['label' => 'Eigene Webseite', 'inquiry' => ['a1.offer', 'a1.information'], 'booking' => []],
|
||||
'fewo_direkt' => ['label' => 'FeWo-direkt (Vrbo)', 'match' => ['fewo-direkt', 'fewo direkt', 'vrbo'], 'inquiry' => ['a2.offer', 'a2.information'], 'booking' => ['a4.portal_booking']],
|
||||
'destination_solutions' => ['label' => 'Destination Solutions', 'match' => ['destination solution'], 'inquiry' => [], 'booking' => ['a3.portal_booking']],
|
||||
'inquiry_listing' => ['label' => 'Inserat mit Anfragen (z. B. ferienundwohnen.de, Ostseeklar)', 'match' => ['ferienundwohnen', 'ostseeklar', 'strandurlaub', 'ferienunterkunft'], 'inquiry' => ['a2.offer', 'a2.information'], 'booking' => []],
|
||||
'generic' => ['label' => 'Sonstiges Portal', 'inquiry' => ['a2.offer', 'a2.information'], 'booking' => ['a3.portal_booking', 'a4.portal_booking', 'a5.portal_booking']],
|
||||
'website' => ['label' => 'Eigene Webseite', 'capabilities' => []],
|
||||
'fewo_direkt' => ['label' => 'FeWo-direkt (Vrbo)', 'match' => ['fewo-direkt', 'fewo direkt', 'vrbo'], 'capabilities' => ['collects_payment' => true, 'provides_contract_documents' => false, 'messages_guest' => true, 'sends_confirmation_mail' => null]],
|
||||
'destination_solutions' => ['label' => 'Destination Solutions', 'match' => ['destination solution'], 'capabilities' => ['collects_payment' => false, 'provides_contract_documents' => false, 'messages_guest' => false, 'sends_confirmation_mail' => null]],
|
||||
'inquiry_listing' => ['label' => 'Inserat mit Anfragen (z. B. ferienundwohnen.de, Ostseeklar)', 'match' => ['ferienundwohnen', 'ostseeklar', 'strandurlaub', 'ferienunterkunft'], 'capabilities' => []],
|
||||
'generic' => ['label' => 'Sonstiges Portal', 'capabilities' => []],
|
||||
],
|
||||
|
||||
'removal_confirmation_runs' => 2,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\Medium;
|
||||
use App\Enums\MessageEffect as E;
|
||||
use App\Enums\MessageIntent as I;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Medium × intent rules (V2.1, docs/Prozessarchitektur/V2.1/02 §6)
|
||||
|--------------------------------------------------------------------------
|
||||
| The ceiling. A landlord may only narrow it (tenants.communication_rules), never widen it. A message never creates a
|
||||
| case, reservation, offer or booking – no effect does. Without a verified assignment, effects that act on a case are dropped.
|
||||
*/
|
||||
return [
|
||||
'media' => [
|
||||
Medium::Email->value => ['active' => true, 'consent_required' => false],
|
||||
Medium::Form->value => ['active' => true, 'consent_required' => false],
|
||||
Medium::WhatsApp->value => ['active' => false, 'consent_required' => true],
|
||||
Medium::Chat->value => ['active' => false, 'consent_required' => false],
|
||||
],
|
||||
|
||||
/** Effects per intent. Anything not listed means: review. */
|
||||
'effects' => [
|
||||
I::GeneralQuestion->value => [E::AnswerInformation, E::Review],
|
||||
I::StayInquiry->value => [E::HandoffInquiry, E::Review],
|
||||
I::CaseReply->value => [E::ReportToCase, E::Review],
|
||||
I::ProvideData->value => [E::ContributeFacts, E::ReportToCase, E::Review],
|
||||
I::ChangeRequest->value => [E::ReportToCase, E::Review],
|
||||
I::Unclear->value => [E::Review],
|
||||
],
|
||||
];
|
||||
+9
-3
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Process\Models;
|
||||
use App\Process\Modules\Guest;
|
||||
use App\Process\Modules\Intake;
|
||||
use App\Process\Modules\Loyalty;
|
||||
use App\Process\Modules\Money;
|
||||
@@ -28,10 +29,12 @@
|
||||
Intake\AvailabilityCheck::class,
|
||||
Intake\PortalBinding::class,
|
||||
Intake\ChannelBlocks::class,
|
||||
Intake\PortalConfirmationStep::class,
|
||||
Offer\Information::class,
|
||||
Offer\BindingOffer::class,
|
||||
Offer\OfferAcceptance::class,
|
||||
Settlement\BookingDocuments::class,
|
||||
Settlement\BookingNoticeStep::class,
|
||||
Settlement\StayConfirmation::class,
|
||||
Settlement\CaseTasks::class,
|
||||
Settlement\ChangeProposal::class,
|
||||
@@ -45,6 +48,7 @@
|
||||
Stay\Stay::class,
|
||||
Stay\ReviewRequest::class,
|
||||
// Architecture proof, tester only (decision E7).
|
||||
Guest\AddressCheck::class,
|
||||
Loyalty\LoyaltyStatusCheck::class,
|
||||
Loyalty\LoyaltyDiscount::class,
|
||||
],
|
||||
@@ -55,6 +59,8 @@
|
||||
*/
|
||||
'compatible' => [
|
||||
'offer.binding' => [1],
|
||||
// V2.1: contract_delivery / portal confirmation were added; with the defaults the step behaves as in version 1.
|
||||
'documents.send' => [1],
|
||||
],
|
||||
|
||||
'models' => [
|
||||
@@ -62,9 +68,9 @@
|
||||
'a1.information' => [1 => Models\A1InformationModel::class],
|
||||
'a2.offer' => [1 => Models\A2OfferModel::class],
|
||||
'a2.information' => [1 => Models\A2InformationModel::class],
|
||||
'a3.portal_booking' => [1 => Models\A3PortalBookingModel::class],
|
||||
'a4.portal_booking' => [1 => Models\A4PortalBookingModel::class],
|
||||
'a5.portal_booking' => [1 => Models\A5PortalBookingModel::class],
|
||||
'a3.portal_booking' => [1 => Models\A3PortalBookingModelV1::class, 2 => Models\A3PortalBookingModel::class],
|
||||
'a4.portal_booking' => [1 => Models\A4PortalBookingModelV1::class, 2 => Models\A4PortalBookingModel::class],
|
||||
'a5.portal_booking' => [1 => Models\A5PortalBookingModelV1::class, 2 => Models\A5PortalBookingModel::class],
|
||||
'a6.internal' => [1 => Models\A6InternalModel::class],
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* V2.1 (docs/Prozessarchitektur/V2.1/02 §6): medium, intent and the decision of a message are kept next to it; existing
|
||||
* rows are e-mails. The landlord's narrowing of the communication rules is a column of the tenant.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('inbound_messages', function (Blueprint $table) {
|
||||
$table->string('medium', 20)->default('email')->after('message_id');
|
||||
$table->string('intent', 30)->nullable();
|
||||
$table->json('decision')->nullable();
|
||||
});
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->json('communication_rules')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('tenants', function (Blueprint $table) {
|
||||
$table->dropColumn('communication_rules');
|
||||
});
|
||||
Schema::table('inbound_messages', function (Blueprint $table) {
|
||||
$table->dropColumn(['medium', 'intent', 'decision']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
# V2.1 – Konfigurationslücken: bisherige Anforderung gegen V2
|
||||
|
||||
Stand: 05.11.2026 · Grundlage: Entscheidungen E-001 bis E-038, Archetypen (`01`), Abwicklungsprofile (`02` / K00), Szenarien R01–R09, Querschnitt „Communication Handler“ (CH-01 bis CH-18), Querschnitt „Gates und Nachweise“, `KONFIGURATION_UND_WIRKSAMKEIT`, `Vorschläge/KANALKONFIGURATOR`, Entscheidungspapier „Eingang und Gastlink“, die V2-Dokumente 00–06 mit Abschlussbericht, der Code (Stand `develop` `4410fb3`) und die Tests. Zusätzlich gelesen: der Live-Stand der Kanalkonfiguration auf stommer.info (nur lesend).
|
||||
|
||||
Kennzeichnung: **[Beschluss]** dokumentierte Entscheidung · **[Bestand]** im Code · **[Neu]** neue Anforderung dieses Auftrags (V2.1) · **[Offen]** fachlich nicht geklärt, nicht entschieden.
|
||||
|
||||
---
|
||||
|
||||
## 1. Was die Prüfung der ursprünglichen Entscheidungen ergibt
|
||||
|
||||
1. **Archetyp = Konstellation aus tatsächlicher Abwicklungsverantwortung, nicht der Name des Kanals** [Beschluss `01_Buchungsarchetypen`: „Maßgeblich sind die tatsächliche Eingangsart und Abwicklungsverantwortung, nicht nur der Name des Kanals“; K00: „kein automatisches ‚alle FeWo-direkt-Buchungen sind gleich‘“]. V2 hat das mit einer festen Liste je Portal (`config/channels.php › portal_profiles`) ins Gegenteil verkehrt.
|
||||
2. **E-016 gilt „für den beschriebenen Vermieterzugang“** [Beschluss]: Destination Solutions = A3 ist die Beschreibung eines Kontos, keine Eigenschaft des Portals. R08 sagt dasselbe („Betreiberangaben zum konkret genutzten Zugang“). Die V2-Einschränkung „Destination Solutions nur A3“ war eine Planungsfestlegung (O2), kein Beschluss.
|
||||
3. **Kanal-Fähigkeit ist ein vorgesehener Konfigurationsbereich** [Beschluss K00: „iCal/API/E-Mail/Portaloberfläche/manuell; Nachweis, Verzögerung, Vollständigkeit und erforderliche manuelle Schritte“]. V2 hat ihn nicht gebaut.
|
||||
4. **Verantwortung ist mehrdimensional** [Beschluss K00: Vertrags-/Dokumentenversand, Gastkommunikation, Zahlung, Mahnung, Storno/Erstattung, lokale Leistungen, Kalender-/Sperrpflege]. V2 bildet Dokumente, Zahlung und Gastkommunikation nur grob ab.
|
||||
5. **Phasen sind keine Reihenfolge** [Beschluss E-006, Prozesslandkarte: „Schritte können entfallen, parallel oder zu einem späteren Zeitpunkt ausgeführt werden“]. Der Runner kann das; die Oberfläche zeigt eine nummerierte Liste.
|
||||
6. **Ein universeller Eingang; Chat und API sind Quellen** [Beschluss Entscheidungspapier E1: „Webseite, iCal, Portal-Mail, Gast-Mail, Chat, API, persönlicher Link, Eingabe von Hand“]. Messenger sind für den CH-MVP ausdrücklich ausgeklammert [Beschluss v0.11], aber als Quelle vorgesehen.
|
||||
7. **Extern verbindlich bleibt verbindlich; ein Transportweg legt die Verbindlichkeit nicht fest** [Beschluss E-036, CH-09, A3–A5-Regel]. Gilt unverändert und bindet V2.1.
|
||||
|
||||
Keine der obigen Festlegungen wurde durch V2.1 geändert. V2.1 ersetzt keinen Beschluss; Abweichungen von V2-Planungsfestlegungen (O2, Pflichtschloss) sind unten einzeln begründet.
|
||||
|
||||
## 2. Matrix: Anforderung → V2 → Lücke → Ursache → Änderung
|
||||
|
||||
| # | Anforderung (Quelle) | V2 heute | Lücke | Ursache | Änderung in V2.1 |
|
||||
|---|---|---|---|---|---|
|
||||
| L01 | Modell folgt der tatsächlichen Verantwortung (Archetypen, K00) [Beschluss] | `portal_profiles`: Destination Solutions nur A3, FeWo-direkt nur A4 | Wechsel DS → A4 unmöglich, obwohl **auf stommer.info für DS bereits `booking.payments = portal` gespeichert ist** (Live-Stand 05.11.2026) | O2 als feste Liste statt Fähigkeit [V2-Planung] | Zulässigkeit aus bestätigten **Kanalfähigkeiten**; Profil nur Vorschlag (`02` §3) |
|
||||
| L02 | Kanal-Fähigkeit pflegen und bestätigen (K00) [Beschluss] | nicht vorhanden | keine Pflege, keine Bestätigung, keine Historie | V2 hat K00-Zeile nicht umgesetzt | `ChannelCapabilities` im Kanal, bestätigt durch Administratoren, mit Historie |
|
||||
| L03 | Geerbte Altwerte und Entwurf unterscheiden; Herkunft sichtbar (KONFIGURATION §1, E-029) [Beschluss] | `ChannelProcess::mount` wählt bei unzulässigem abgeleitetem Modell **still** das erste zulässige; `ConfigureChannelProcess` übernimmt Altwerte, das Modell überstimmt sie danach still (`ProcessSettings::resolve`, Herkunft „Modell“) | Altwert `payments=portal` + Modell A3 ⇒ gespeichert `portal`, wirksam `landlord`, niemand erfährt es | Fehler in V2-Umsetzung [Bestand] | Abgleich vor dem Speichern: Konflikte listen, bestätigen lassen, protokollieren; kein stilles Umschalten |
|
||||
| L04 | Fachlich Zwingendes ≠ operative Ausführung (Auftrag §5) [Neu] | `toggle` Pflicht/Optional; Pflicht = Schloss | Frage „abschalten?“ statt „wie darf es erfüllt werden?“ | Modul kennt nur an/aus und Modus | `ModuleDefinition::executions` je Modul, Modell schränkt ein; Schritt zeigt zulässige Ausführungen |
|
||||
| L05 | Dokumentenprofil, Nachweis, A5-Ergänzung (E-005, E-013, E-025, K00) [Beschluss] | `documents.send` koppelt Erzeugen, Ablegen, Versand | Vertrag nur intern, nur Buchungsinformation, Versand nach Freigabe als getrennte Entscheidungen nicht darstellbar | ein Modul, eine Einstellung (`Processing`) | Einstellungen `contract_delivery`, `booking_notice`; neues Modul `documents.booking_notice`; Erzeugen/Ablegen/Versand getrennt abgeleitet (`02` §4) |
|
||||
| L06 | Nachweisstufen und Mindestnachweis je Schritt/Kanal (Vorschlag §5, D3) [Vorschlag, nicht beschlossen] | nur Verlaufseintrag `evidence` im Ereignis-Handler; **keine** Stufe je Schritt, **kein** `AcceptedFieldsTest` (in `03` §6 erwähnt, nicht gebaut) | Dokumentation und Code weichen ab | V2-Dokument beschrieb mehr, als umgesetzt wurde | Nachweis für Portalbestätigung und Portalunterlagen als Verlaufseintrag mit Stufe; Rest bleibt [Offen] (D3/D4 nicht beschlossen) |
|
||||
| L07 | Portal-Bestätigung abwarten (Auftrag §7) [Neu] | nicht vorhanden. `PortalIntake`/`ProcessPortalMail` rufen **nie** `advance`; kein Zeitgeber wertet wartende verbindliche Vorgänge neu aus | Warten wäre nie fortgesetzt und nie eskaliert worden | Automatik hängt nur an Eingang, Fakten, Beträgen und Anfrage-Zeitgebern | Modul `portal.confirmation`, Wiederaufnahme nach Portalmail, Zeitgeber für wartende Vorgänge (`02` §5) |
|
||||
| L08 | Universeller Eingang; Chat/Messenger als Quelle (Entscheidungspapier E1) [Beschluss] | Eingang ist E-Mail-förmig (`ReceiveInboundMessage(PortalMail)`) | Medium und Absicht nicht unterscheidbar | nur das Medium E-Mail gebaut | `IncomingMessage` + Regeln Medium × Absicht (`02` §6); WhatsApp/Chat nur als Testfälle |
|
||||
| L09 | Nichtlinear darstellen (E-006) [Beschluss] | Runner nichtlinear; Oberfläche nummeriert 1–n | Reihenfolge suggeriert Abhängigkeit | Darstellung | Phasenansicht aus `requires`/`waits`/`triggers` derselben Definition (`02` §7) |
|
||||
| L10 | Einschränkungen verständlich erklären (Auftrag §10 E) [Neu] | Schloss, Meldung „nicht zulässig“ | keine Handlungserklärung | Meldungen ohne Ursache/Alternative | strukturierte `Restriction` (Ursache, Alternative, konkrete Änderung) |
|
||||
| L11 | Konfiguration der Schritte über die Hierarchie (V2-Plan `06` §1: `steps.*` auf allen Ebenen) [V2-Planung] | `steps[…].on` nur am Kanal; Ausführungseinstellungen laufen über `ProcessSettings` (alle Ebenen) | Ein/Aus eines optionalen Schritts nicht als Vermieter-/Wohnungsstandard | V2 hat nur Kanalebene umgesetzt | **Bleibt Kanalebene** (Begründung `02` §3.4); Ausführungsarten gelten über alle Ebenen |
|
||||
| L12 | Mahnung, Storno/Erstattung, Kalender-/Sperrpflege als Verantwortung (K00) [Beschluss] | Mahnung folgt `payments`; Sperrpflege je Kanal (`requires_manual_blocking`); Storno/Erstattung nicht einstellbar | Storno/Erstattung je Modell nicht einstellbar | nicht im V2-Umfang | **Nicht Teil V2.1**; [Offen] DS-06/FW-05 (Portalverfahren ungeklärt) |
|
||||
| L13 | D4 „akzeptierte Angaben je Kanal“ (Vorschlag) [Vorschlag] | nicht umgesetzt | – | in `03` als „entschieden“ geführt, nie gebaut | geht in die Medium-/Absichtsregeln ein (zulässige Informationsquelle); eigene Feldauswahl [Offen] |
|
||||
| L14 | Datenbeschaffung unabhängig von Angebotsautomatik (K00, E-032–E-034) [Beschluss] | umgesetzt (`DataRequest`, getrennte Zähler) | keine | – | unverändert |
|
||||
| L15 | Zwei getrennte Reservierungszwecke mit eigenen Fristen (E-033) [Beschluss] | umgesetzt (`hold`, `RequestHold`) | in der Oberfläche nur eine Zeile | Darstellung | in der Phasenansicht als unabhängige Aktivität mit eigener Frist |
|
||||
| L16 | Verbindlichkeit externer Buchungen geschützt (E-036, CH-09) [Beschluss] | umgesetzt (`binding.portal`, `PortalIntake`) | keine | – | bleibt Voraussetzung jeder V2.1-Änderung (Belegung hängt nie an `portal.confirmation`) |
|
||||
|
||||
## 3. Widersprüche und offene Fragen (nicht stillschweigend entschieden)
|
||||
|
||||
| # | Frage | Stand | Behandlung in V2.1 |
|
||||
|---|---|---|---|
|
||||
| F1 | **O1 gegen „Portal stellt Vertragsunterlagen bereit“.** O1 (Betreiber, 04.11.) macht die Vertragsdokumentation archetypbestimmend: Portal ⇒ A5. | Auftrag §6 nennt „Vertragsunterlagen durch das Portal bereitstellen lassen“ als zu unterstützende Variante. | Das ist **A5**, kein Zusatz zu A3/A4. „Vertrag intern erzeugen, Gast bekommt nur eine Buchungsinformation“ bleibt innerhalb A3/A4, weil die Dokumentation bei uns bleibt. O1 bleibt unverändert. |
|
||||
| F2 | Mindestnachweis (D3) und akzeptierte Angaben (D4) | im Vorschlag, nie beschlossen | [Offen]; V2.1 setzt nur den Nachweis der Portalbestätigung um |
|
||||
| F3 | Frist und Rückfallverhalten, wenn eine Portalbestätigung ausbleibt | nicht beschlossen | Parameter `portal_confirmation_wait_hours` (Vorgabe 48 Stunden, als **Vorschlag** gekennzeichnet); danach Aufgabe an den Vermieter, **kein** automatisches Aufheben oder Senden |
|
||||
| F4 | Darf WhatsApp einen Vorgang über ein Kennzeichen (Vorgangsnummer) zuordnen? | [Offen]; CH-07: „Buchungsnummer allein ist kein Identitätsnachweis“ | Nein: Nachrichten ohne verifizierten Antwortbezug gehen zur Klärung. Keine Zuordnung nach Rufnummer, Name oder Zeitraum |
|
||||
| F5 | Einwilligungs-/Datenschutzanforderungen für Messenger | nicht geklärt | je Medium als Pflichtfeld der Regel („Einwilligung nötig“), Stand [Offen]; kein Messenger-Echtbetrieb |
|
||||
| F6 | DS-01 bis DS-06, FW-01 bis FW-07 | offen (Portalnachweise) | unverändert [Offen]; V2.1 ersetzt keine Prüfung |
|
||||
| F7 | Ob für Destination Solutions tatsächlich Portal-Inkasso gilt | Live-Stand: `payments = portal` gespeichert; E-016/R08: Vermieter kassiert | wird **nicht entschieden**. Die gespeicherte Einstellung wird als Fähigkeit „abgeleitet“ gezeigt und muss vom Administrator bestätigt oder korrigiert werden (L01/L03) |
|
||||
|
||||
## 4. Wiederverwendung
|
||||
|
||||
Kein Bestandteil wird ersetzt: `ProcessRunner`, `ProcessSettings`-Hierarchie, `ConfirmBooking::deliver(notifyGuest: false)` (erzeugt und legt ab, ohne zu senden), `RentalContract::generate` (idempotent über `contract_path`), `PortalIntake`/`ProcessPortalMail`, `MessageMatcher`, `ContributeCaseFacts`, `ChannelEventHandler`, der Prozess-Tester samt Sandbox, `CaseLog` (Nachweise als Verlaufseinträge).
|
||||
@@ -0,0 +1,124 @@
|
||||
# V2.1 – Fachliches Zielbild: konfigurierbarer Geschäftsprozess auf V2
|
||||
|
||||
Stand: 05.11.2026 · setzt `01_KONFIGURATIONSLUECKEN.md` um. Die technische Basis von V2 (Fachmodule, Modelle, `ProcessRunner`, Konfigurator, isolierter Tester) bleibt; es kommen Fähigkeiten und Einstellungen hinzu, keine zweite Engine und keine zweite Konfigurationsquelle.
|
||||
|
||||
Leitsatz: **Die Grenze der Konfigurierbarkeit begründet die fachliche Notwendigkeit, nicht die Struktur der heutigen Implementierung.** Vor jedem neuen Mechanismus wurde geprüft, ob Modulvertrag, Parameter, Abhängigkeiten oder Erweiterungspunkte reichen. Neu gebaut wird nur, was dort nicht darstellbar war.
|
||||
|
||||
## 1. Vier getrennte Dimensionen
|
||||
|
||||
| Dimension | Beispiele | Wo es steht |
|
||||
|---|---|---|
|
||||
| Geschäftskanal (Herkunft) | Eigene Webseite, Destination Solutions, FeWo-direkt | `channels`, bleibt am Vorgang (`origin_channel_id`) |
|
||||
| Kommunikationsmedium | E-Mail, Formular, WhatsApp, Chat | `Medium` (neu); Eingang je Nachricht |
|
||||
| Nachrichtenabsicht | Auskunft, Nachfrage, Datenlieferung, Buchungsanfrage, Stornohinweis, unklar | `Intent` (neu); vom Prozesskern bestimmt |
|
||||
| Verbindlichkeit/Ereignisart | unverbindlich, extern verbindlich, Information | unverändert (`IntakeKind`, `Booking::isBinding`) |
|
||||
|
||||
Kein Medium und keine Absicht legt eine Verbindlichkeit fest. Eine eingehende Nachricht erzeugt **nie** selbst einen Vorgang, eine Reservierung, ein Angebot oder eine Buchung (strukturell: kein Wirkungstyp der Regeln legt einen Vorgang an).
|
||||
|
||||
## 2. Archetyp = Rahmen (Ausführungsvarianten statt Schlösser)
|
||||
|
||||
- Das Modell legt fest, **wer wofür verantwortlich ist**, wenn das die Vorgangsart bestimmt (Vertragsabschluss, Inkasso, Vertragsdokumentation; O1 unverändert).
|
||||
- Jedes Modul nennt, **auf welche Weisen** seine Aufgabe erfüllt werden darf (`executions`): automatisch · mit Freigabe · von Hand · durch das Portal · durch einen Dienstleister · bereits extern erledigt und nachgewiesen · nicht erforderlich. Das Modell schränkt die Menge je Archetyp ein.
|
||||
- Die Oberfläche zeigt an jedem Schritt **„So darf das erfüllt werden“** statt eines Schlosses. Eine zwingende Aufgabe bleibt zwingend; abschaltbar ist sie nicht, wohl aber ausführbar auf den zugelassenen Wegen.
|
||||
- Die Auswahl landet in vorhandenen Einstellungen (`Processing`, `DataRequest`, `Documents`, `GuestMessages`) oder in den neuen unten. Dieselbe Hierarchie Vorgang ← Kanal × Eingangsart ← Wohnung ← Vermieter ← Systemstandard; eingefroren beim Eingang.
|
||||
|
||||
## 3. Kanalfähigkeiten und Modellzulässigkeit
|
||||
|
||||
### 3.1 Fähigkeiten
|
||||
|
||||
Gespeichert im Kanal (`channels.settings.capabilities`), je Fähigkeit: Wert, bestätigt am/von, Historie (letzte 20 Änderungen).
|
||||
|
||||
| Fähigkeit | Bedeutung | Wirkt auf |
|
||||
|---|---|---|
|
||||
| `collects_payment` | Das Portal zieht das Geld des Gastes ein | Modell A4/A5 verlangen „ja“, A3 verlangt „nein“ |
|
||||
| `provides_contract_documents` | Das Portal stellt die verbindlichen Vertragsunterlagen bereit | A5 verlangt „ja“, A3/A4 „nein“ (O1) |
|
||||
| `messages_guest` | Das Portal schreibt den Gast an (Anreise-Information, Erinnerungen) | Auswahl „Portal“ bei Gastkommunikation |
|
||||
| `sends_confirmation_mail` | Das Portal schickt uns eine Buchungsbestätigung per E-Mail | Warten auf Portalbestätigung |
|
||||
|
||||
**Wert ermitteln (in dieser Reihenfolge, die Quelle wird angezeigt):**
|
||||
1. *bestätigt* – vom Administrator bestätigt;
|
||||
2. *abgeleitet* – aus einer ausdrücklich gespeicherten Altstellung (`payments`, `documents`, `guest_messages` am Kanal); der Administrator muss sie bestätigen oder korrigieren;
|
||||
3. *Vorschlag* – aus dem Kanalprofil (`config/channels.php`, z. B. R09 für FeWo-direkt, E-016 für Destination Solutions);
|
||||
4. *unbekannt* – blockiert nichts, wird als „bitte bestätigen“ gezeigt.
|
||||
|
||||
### 3.2 Zulässigkeit
|
||||
|
||||
Ein Modell ist zulässig, wenn die Eingangsart passt und jede verlangte Fähigkeit den verlangten Wert hat (unbekannt = zulässig mit Hinweis). Die feste Portalliste entfällt; sie wird zum Vorschlagsprofil. O2 bleibt als Vorgabe für FeWo-direkt erhalten (Profil: zieht Geld ein, keine Vertragsunterlagen ⇒ A4), ist aber nicht mehr dauerhaft gesperrt.
|
||||
|
||||
**Ein nicht zulässiges Modell bleibt sichtbar** mit Begründung: *Ursache* (fehlende Fähigkeit mit Quelle des aktuellen Werts), *Alternative* (welches Modell passt), *konkrete Änderung* (welche Fähigkeit bestätigen). Änderungen der Fähigkeiten im Entwurf wirken sofort auf die Auswahl.
|
||||
|
||||
### 3.3 Abgleich mit Altwerten
|
||||
|
||||
Beim Speichern prüft `ConfigureChannelProcess`, ob am Kanal Einstellungen stehen, die das gewählte Modell festlegt (z. B. `payments = portal` bei A3). Konflikte werden **aufgelistet** (Wert alt/Wert Modell/Folge), müssen ausdrücklich bestätigt werden und werden danach entfernt und im Verlauf des Kanals festgehalten. Ohne Bestätigung wird nicht gespeichert. Der Konfigurator wählt nie still ein anderes Modell.
|
||||
|
||||
### 3.4 Was auf Kanalebene bleibt
|
||||
|
||||
Ein/Aus optionaler Schritte (`steps[…].on`) gilt weiter nur je Kanal und Eingangsart. Grund: Ob ein Schritt für ein Portal entfällt, hängt an dessen Fähigkeiten; ein Vermieter- oder Wohnungsstandard würde Kanäle mit anderen Fähigkeiten falsch treffen. Ausführungsarten (Einstellungen) vererben dagegen über alle Ebenen.
|
||||
|
||||
## 4. Dokumente: Erzeugen, Ablegen, Versenden, Informieren
|
||||
|
||||
| Fähigkeit | Wo | Einstellung |
|
||||
|---|---|---|
|
||||
| Vertragsgrundlage prüfen | `documents.send` (`DocumentComposer`, Konditionsstand, Freigaben) | unverändert, nicht abschaltbar |
|
||||
| Vertragsdokument erzeugen und intern ablegen | `ConfirmBooking::deliver(notifyGuest: false)` | `contract_delivery = internal` |
|
||||
| Vertragsdokument an den Gast senden | `documents.send` | `contract_delivery = automatic / manual`, Vorgabe `follow` = wie `processing` |
|
||||
| Buchungsinformation (ohne Vertrag) | neues Modul `documents.booking_notice` | `booking_notice = off / automatic / automatic_unless_portal_confirmed / manual` |
|
||||
| Vom Portal bereitgestellte Unterlagen | Modell A5 (`Documents = Portal`) | Modellwahl (O1) |
|
||||
| Ergänzende Informationen | `arrival.info` (Zeitpunkt, Ausführender) | unverändert, unabhängig von der Vertragsdokumentation |
|
||||
|
||||
Darstellbare Fälle: Vertrag automatisch erstellen und senden · erstellen und nur intern ablegen · nach Freigabe/von Hand senden · nur Buchungsinformation · Portal stellt Unterlagen bereit (A5) · keine eigene Nachricht, wenn das Portal die Bestätigung nachweislich geschickt hat · ergänzende Informationen unabhängig.
|
||||
|
||||
**Grenzen:** Der Gast bekommt nie neue, nicht vereinbarte Pflichten (Konditionsprüfung bleibt). Bei extern verbindlicher Buchung ändert keine Dokumenteinstellung die Verbindlichkeit. Ein Vertrag, der nur intern liegt, ist **nicht** „versendet“: der Schritt bleibt offen, bis er gesendet wird oder der Vermieter ihn bewusst als erledigt markiert.
|
||||
|
||||
## 5. Warten auf ein Ereignis: Portalbestätigung
|
||||
|
||||
Modul `portal.confirmation` (optional, nur für extern verbindliche Buchungen; Einstellungen `await_portal_confirmation` ja/nein, `portal_confirmation_wait_hours`, Vorschlag 48).
|
||||
|
||||
- **Erwartet:** eine Buchungsmail des Portals (`PortalEmailType::Booking`), die dem Vorgang **deterministisch** zugeordnet ist (CH-13: belastbare Portalreferenz oder verknüpfte Belegung desselben Kanals). Keine Zuordnung nach Name, Adresse oder Zeitraum allein.
|
||||
- **Nachweis:** die Mail (Stufe „laut Portal erledigt“) oder eine ausdrückliche Bestätigung des Vermieters im Vorgang (Verlaufseintrag `portal_confirmation`). Eine Mail allein schafft keine Verbindlichkeit.
|
||||
- **Wer wartet (harte Abhängigkeit):** `documents.send`, `documents.booking_notice`. **Wer nicht:** Belegung und Kalendersperren (`binding.portal`, `channels.block`), Datenbeschaffung, Zahlungsüberwachung, Aufenthalt, interne Aufgaben.
|
||||
- **Wiederaufnahme:** nach Verarbeitung einer Portalmail für diesen Vorgang (Auslöser `portal.mail`) und durch einen Zeitgeber für wartende Vorgänge (`bookings:advance-waiting`, alle 5 Minuten).
|
||||
- **Ausbleiben:** nach Ablauf der Frist wird der Schritt zum Problem, es entsteht **eine** Aufgabe „Portalbestätigung fehlt“; die Folgeschritte bleiben angehalten, bis der Vermieter bestätigt oder von Hand sendet. Nichts wird automatisch gesendet oder aufgehoben.
|
||||
- Ist der Vorgang selbst durch diese Mail entstanden, ist der Nachweis sofort erbracht.
|
||||
|
||||
## 6. Kommunikation: Medium × Absicht
|
||||
|
||||
`IncomingMessage` (Medium, Absender, Text, Zeit, externe Kennung, überprüfter Antwortbezug) → `MessageIntake` → `MessageDecision`.
|
||||
|
||||
- **Absicht** bestimmt der Prozesskern regelbasiert (`IntentClassifier`, später KI über dieselbe Schnittstelle, E-035). Der Adapter liefert nur Rohdaten und einen **vom Adapter überprüften** Antwortbezug (signiertes Kennzeichen); eine Behauptung des Absenders zählt nicht.
|
||||
- **Regeln** (`config/communication.php`, Vermieter dürfen nur einschränken, nie erweitern): je Medium aktiv/inaktiv, Einwilligung nötig, je Absicht erlaubte Wirkungen:
|
||||
|
||||
| Wirkung | Bedeutung | Voraussetzung |
|
||||
|---|---|---|
|
||||
| `answer_information` | allgemeine Auskunft beantworten, kein Vorgang | – |
|
||||
| `contribute_facts` | Angaben an einen **zugeordneten** Vorgang über `ContributeCaseFacts` | verifizierter Antwortbezug |
|
||||
| `report_to_case` | Aufgabe am zugeordneten Vorgang | verifizierter Antwortbezug |
|
||||
| `handoff_inquiry` | Verweis auf den Anfrageprozess (Formular); kein Vorgang | – |
|
||||
| `review` | manuelle Klärung im Posteingang | – |
|
||||
|
||||
- **Zuordnung:** nur deterministisch (verifizierter Antwortbezug, bestehender `MessageMatcher` bei E-Mail). Gleiche Absenderadresse, Rufnummer, Name oder Zeitraum genügen **nicht**. Unklar ⇒ `review`.
|
||||
- **Widerspruch/Mehrdeutigkeit** ⇒ `review`, keine Übernahme.
|
||||
- **Antwort:** die Entscheidung nennt die zulässigen Antwortmedien; ein Versand durch Messenger/Chat-Adapter ist nicht Teil von V2.1.
|
||||
- WhatsApp und Chat sind **Testfälle der Architektur**: Regeln, Eingang und Tester vorhanden, kein Provideranschluss. Der bestehende E-Mail-Weg (`ReceiveInboundMessage`) bleibt unverändert.
|
||||
|
||||
## 7. Darstellung des nichtlinearen Ablaufs
|
||||
|
||||
Die Prozessansicht entsteht aus **derselben** Moduldefinition wie die Ausführung (`requires`, `waits`, `triggers`, `applies`, `executions`); es gibt keine zweite Pflege. Je Phase (P01–P05) eine Spur; je Schritt:
|
||||
|
||||
- „braucht zuerst: …“ (harte Abhängigkeit, nur wenn im Plan)
|
||||
- „soll nach: …“ (weiche Abhängigkeit)
|
||||
- „läuft unabhängig“ (keine harte Abhängigkeit im Plan)
|
||||
- „wartet auf: Gast / Portal / Frist / Vermieter“
|
||||
- „nur wenn: …“ (bedingt; Beschreibungstext der Definition, **keine** Logik)
|
||||
- „löst aus / endet durch: …“ (Auslöser)
|
||||
- Ausführung: Wer und wie (automatisch · Freigabe · von Hand · extern/Portal), abgeschaltet.
|
||||
|
||||
Die Nummerierung 1–n entfällt.
|
||||
|
||||
## 8. Prozess-Tester und Nachweisfälle
|
||||
|
||||
Die Szenarien laufen weiter im isolierten Prozess. Neu: Portalbestätigung (sofort/verspätet/ausbleibend), Dokumentvarianten (über den Entwurf), Nachrichten über andere Medien, Auskunft ohne Vorgang, Stammdaten-Abgleich, eingefrorene Konfiguration, unabhängige Aktivitäten. Fälle A–H: Abschnitt 2 der Abnahme `ABNAHME_V2_1.md`.
|
||||
|
||||
## 9. Grenzen (bewusst)
|
||||
|
||||
Keine Skripte oder Bedingungen im Konfigurator · keine Umordnung sicherheitsrelevanter Schritte · keine Umgehung von Verbindlichkeits-, Verfügbarkeits-, Preis- oder Datenschutzprüfungen · keine zweite Engine · keine zweite Wahrheitsquelle · kein Provideranschluss für Messenger/Chat · Storno/Erstattung je Modell nicht einstellbar (offen, DS-06/FW-05).
|
||||
@@ -0,0 +1,73 @@
|
||||
# V2.1 – Abnahme: Fälle A–H und kritische Selbstprüfung
|
||||
|
||||
Stand: 05.11.2026, Branch `feature/prozessarchitektur-v2-1`. Grundlage: [01 Lücken](01_KONFIGURATIONSLUECKEN.md), [02 Zielbild](02_FACHLICHES_ZIELBILD.md). Alle Nachweise sind automatisierte Tests; „Tester“ meint den isolierten Prozess-Tester (Kanal › Ablauf › Ablauf testen).
|
||||
|
||||
## 1. Was V2.1 ergänzt
|
||||
|
||||
| Bereich | Umsetzung |
|
||||
|---|---|
|
||||
| Kanalfähigkeiten | `Capability`, `ChannelCapabilities`: bestätigt / abgeleitet / vorgeschlagen / unbekannt. Sie entscheiden, welche Modelle zulässig sind. |
|
||||
| Erklärte Einschränkungen | `Restriction`: was fehlt, welche Variante erlaubt ist, was zu ändern ist, Grund (fachlich / technisch / Fähigkeit). |
|
||||
| Abgleich alter Werte | Gespeicherte Einstellungen gegen `fixes()` des Modells: ausdrückliche Bestätigung, Eintrag in `settings.process_history`. |
|
||||
| Ausführungsvarianten | `Execution` (automatisch, Freigabe, von Hand, Portal, Dienstleister, extern, nicht nötig), je Modul mit `why` (Begründung der Pflicht) und `condition`. |
|
||||
| Dokumente entkoppelt | `contract_delivery` (wie bisher / automatisch / von Hand / nur intern ablegen), `booking_notice` (aus / automatisch / automatisch, außer das Portal bestätigt) als eigener Schritt. |
|
||||
| Portalbestätigung | Modul `portal.confirmation`: Belegung sofort gesichert, gästebezogene Schritte warten, Frist, genau eine Aufgabe bei Ausbleiben, Wiederaufnahme per Portalmail oder Bestätigung im Vorgang. |
|
||||
| Kommunikation | `config/communication.php`, `CommunicationRules`, `IntentClassifier`, `MessageIntake`: Medium × Absicht × Wirkung; Vermieter dürfen nur einschränken. |
|
||||
| Nichtlineare Ansicht | Konfigurator zeigt je Schritt „braucht zuerst“, „soll nach“, „läuft unabhängig“, „nur wenn“, „So darf das erfüllt werden“; keine Nummerierung. Quelle: dieselben Moduldefinitionen wie der `ProcessRunner`. |
|
||||
| Tester | Neue Szenarien: Portalbestätigung (sofort / verspätet / ausbleibend), Nachricht über WhatsApp/Chat, allgemeine Frage ohne Vorgang. |
|
||||
| Erweiterungspunkt | `guest.address_check` (nur Tester) als Variante `address_check` des A1-Angebotsmodells. |
|
||||
|
||||
Modellversionen: a3/a4/a5 Version 1 bleiben für laufende Vorgänge erhalten, Version 2 enthält die neuen Module (`config/process.php`, `compatible`). Die Standardwerte der neuen Einstellungen reproduzieren das V2-Verhalten (Golden-Master- und Laufende-Vorgänge-Tests unverändert grün).
|
||||
|
||||
## 2. Nachweisfälle
|
||||
|
||||
| Fall | Konfiguration | Module / Regeln | Ausführung | Vorschau & Tester | Wirkung auf andere Archetypen | Tests |
|
||||
|---|---|---|---|---|---|---|
|
||||
| **A** Destination Solutions heute | Kanal mit Fähigkeit „Portal kassiert nicht“ (bestätigt) → Modell A3, Zahlungen eigen | A3 v2, `documents.send`, `payments.internal` | Eigene Zahlungsabwicklung und Dokumentation wie bisher | Vorschau zeigt A3-Schritte; Tester `portal_booking` | keine | `ChannelCapabilityTest`, `BehaviourComparisonTest` |
|
||||
| **B** Destination Solutions künftig | Fähigkeit „Portal kassiert“ bestätigen (mit Bestätigung des Abgleichs) → A4 | A4 v2, `money.portal_payout` statt interner Zahlung | Neue Vorgänge laufen als A4; laufende behalten ihren eingefrorenen Plan; **keine neue A4-Logik** | Vorschau und Tester zeigen A4; nicht erfüllte Modelle bleiben sichtbar mit Erklärung | A3/A5 unverändert | `ChannelCapabilityTest` (Wechsel, Abgleich `payments = portal`, Historie) |
|
||||
| **C** Portalbestätigung als Voraussetzung | `await_portal_confirmation = ja`, Wartezeit, `booking_notice` | `portal.confirmation`, harte Abhängigkeit von `documents.send` und `documents.booking_notice` | Belegung sofort gesichert; Unterlagen/Information warten; nach Frist **eine** Aufgabe, nichts wird automatisch gesendet; Mail oder Bestätigung im Vorgang setzt fort | Szenario „Bestätigungsmail: sofort / verspätet / ausbleibend“ | nur Modelle, die das Modul enthalten (A3–A5 v2) | `DocumentsAndPortalConfirmationTest`, `ProcessTesterTest` |
|
||||
| **D** Alternative Dokumentenverarbeitung | `contract_delivery = intern`, `booking_notice = automatisch` | `documents.send` (v2), `documents.booking_notice` | Vertrag erstellt und abgelegt, nicht gesendet; Gast erhält nur die Buchungsinformation; spätere Versendung von Hand möglich; Unterdrückung, wenn das Portal selbst informiert und bestätigt hat | Tester über Entwurf der Einstellungen | wie C | `DocumentsAndPortalConfirmationTest` |
|
||||
| **E** Kommunikation über verschiedene Medien | Medium in `config/communication.php` aktiv, Vermieter kann einschränken | `MessageIntake`, `IntentClassifier`, `MessageMatcher` (E-Mail unverändert) | Antwort mit überprüftem Bezug wird dem Vorgang zugeordnet, Herkunft (`medium`, Kanal der Buchung) bleibt, Aufgabe „Posteingang prüfen“, nichts wird automatisch übernommen | Szenario „Nachricht über WhatsApp oder Chat“ | keine | `MessageMediumIntentTest`, `ProcessTesterTest` |
|
||||
| **F** Auskunft ohne Buchungsanfrage | wie E | Wirkungen `answer_information`, `handoff_inquiry`, sonst `review` | Es entsteht weder Vorgang noch Reservierung, Angebot oder Buchung (strukturell: kein Wirkungstyp legt einen Vorgang an) | Szenario „Allgemeine Frage im Chat“ | keine | `MessageMediumIntentTest`, `ProcessTesterTest` |
|
||||
| **G** Nichtlineare Datenbeschaffung | A1-Standard | `hold`, `guest.details`, `guest.data_request` unabhängig; `offer.binding` hart von den Angaben abhängig | Klärungsreservierung steht sofort, Datenbeschaffung läuft; das Angebot wartet („erst wenn alle Angaben da sind“) | Ansicht „braucht zuerst / läuft unabhängig“ | keine | `ExtensionAndIndependentStepsTest`, `ProcessRunnerTest` |
|
||||
| **H** Neuer Zusatzschritt | Variante `address_check` (nur Tester) am Erweiterungspunkt `after_guest_identified` | `guest.address_check` | Nur Hinweis, hält nichts auf; echte Vorgänge können die Variante nicht erhalten | Tester-Entwurf | nur A1-Angebot hat die Variante; Standardabläufe aller Modelle unverändert (Test) | `ExtensionAndIndependentStepsTest` |
|
||||
|
||||
## 3. Regression (Phase 3)
|
||||
|
||||
Bestehende Suites unverändert grün: Prozesskern, Golden Master, laufende Vorgänge, Sandbox-Sicherheit (`ProcessTesterSecurityTest`, `SideEffectPathsTest`), Posteingang (`GuestMailInboxTest`), Dokumente (`DocumentCompositionTest`). Schwerpunkte:
|
||||
|
||||
| Thema | Absicherung |
|
||||
|---|---|
|
||||
| Vertragsverbindlichkeit, Angebotsversionen, Preisfestlegung | unveränderte Module; Loyalty-Nachweis und Angebots-Tests grün |
|
||||
| Reservierungsfristen | Halte-Logik unverändert; Portalbestätigung berührt `occupying()` nicht (Test: Belegung bleibt während des Wartens) |
|
||||
| Portalbestätigungen, Idempotenz | Mail zweimal → ein Vorgang; Aufgabe „Portalbestätigung fehlt“ nur einmal; zweiter Lauf von `bookings:advance-waiting` ohne Wirkung |
|
||||
| Nachrichten: Zuordnung, Dubletten, Widersprüche | gleiche externe Kennung → einmal gespeichert; Absender/Name/Zeitraum allein ordnen nie zu; abweichende Vorgangsnummer → `review` |
|
||||
| Bestehende Buchungen | Einstellungen mit V2-Standardwerten; eingefrorene Pläne (Version 1 bleibt) |
|
||||
| Versand | Mail-Gate `EnforceMailTestMode` unverändert; keine neuen Versandwege; Medien-Antworten werden nicht gesendet |
|
||||
| Mandantentrennung | `communication_rules` je Mandant, `InboundMessage` mandantengebunden (`BelongsToTenant`) |
|
||||
| Sandbox | Szenarien nutzen nur die Sandbox-Datenbank; Sicherheitstests grün |
|
||||
|
||||
## 4. Offene Fachfragen (bewusst nicht entschieden)
|
||||
|
||||
Siehe `01_KONFIGURATIONSLUECKEN.md` F1–F7: Einwilligung für WhatsApp je Absender, Ausbleiben-Frist (48 h ist ein Vorschlag, einstellbar), Inkasso bei Destination Solutions, Storno/Erstattung je Modell, DS-/FW-Prüfungen. Kein Provideranschluss für WhatsApp/Chat; sie sind Testfälle der Architektur und standardmäßig **ausgeschaltet** (`config/communication.php`).
|
||||
|
||||
## 5. Kritische Selbstprüfung
|
||||
|
||||
1. **Konfigurierbarkeit wiederhergestellt oder nur weitere starre Modelle?** Wiederhergestellt, soweit fachlich zulässig: Innerhalb eines Archetyps stellt der Betreiber Ausführungsvariante, Dokumentenbehandlung, Wartebedingung, Zuständigkeit und Kommunikationswege ein; das Modell folgt aus den Kanalfähigkeiten. Neue Modelle (a3–a5 v2) enthalten nur zusätzliche Module, keine neuen Sonderabläufe.
|
||||
2. **DS auf anderes Modell?** Ja (Fall B): Fähigkeit bestätigen → A4, mit erklärtem Abgleich alter Werte. Ohne neue A4-Logik.
|
||||
3. **Dokumente unabhängig?** Ja: Vertrag erstellen/ablegen/senden, Buchungsinformation und Ergänzungsunterlagen getrennt; Pflichtgrenzen (Vertragsinhalt, Freigabe der Dokumentarten) bleiben.
|
||||
4. **Auf Portal-Mail oder überprüften Eingang warten?** Ja (Fall C): Portal-Mail, die dem Vorgang deterministisch zugeordnet ist, oder Bestätigung des Vermieters.
|
||||
5. **Medien mit unterschiedlichen Befugnissen je Absicht?** Ja: Wirkungen je Medium × Absicht; Vermieter dürfen nur einschränken.
|
||||
6. **WhatsApp löst Auskunft aus, ohne Buchungskanal zu sein?** Ja (Fall F): `answer_information` / `handoff_inquiry`; kein Wirkungstyp erzeugt Vorgang oder Buchung.
|
||||
7. **Künftiger KI-Chat?** Ja, als Adapter: Er liefert `IncomingMessage` mit überprüftem Bezug; Klassifikation und Regeln liegen im Kern. Der Chat-Anschluss ist nicht gebaut; die Absichtserkennung kann später hinter derselben Schnittstelle (`IntentClassifier`) durch ein Modell ersetzt werden.
|
||||
8. **Unabhängige Schritte schreiten fort?** Ja (Fall G, `ProcessRunner`: harte Abhängigkeit hält nur den abhängigen Schritt).
|
||||
9. **Tatsächliches Verhalten oder starre Liste?** Ansicht aus denselben Definitionen wie die Ausführung; Phasen gruppiert, Abhängigkeiten, Unabhängigkeit, Bedingungen und Ausführungsvarianten sichtbar. Einschränkung: keine grafische Darstellung (bewusst, kein BPMN-Editor).
|
||||
10. **Im Tester durchspielbar?** Ja, drei neue Szenarien; Entwurfseinstellungen werden ohne Speichern getestet. Die geforderte Szenarienliste ist damit nicht vollständig als einzelne Szenarien abgebildet: Dokumentvarianten und eingefrorene Konfiguration laufen über den Entwurf bestehender Szenarien (siehe Abschnitt 6).
|
||||
11. **Änderungen beeinflussen andere Archetypen?** Nein: Version 1 der Modelle bleibt, neue Module bedingt/aus als Standard, Standardabläufe unverändert (Test), `process:impact` zeigt die betroffenen Modelle.
|
||||
12. **Verständlich und wirtschaftlich?** Die neuen Einstellungen sind Auswahlfelder an dem Schritt, den sie betreffen, mit Standard „wie bisher“; Einschränkungen werden in Klartext erklärt. Für Vermieter mit nur einer Website ändert sich nichts. Aufwand der Konfiguration lohnt sich vor allem für Portalkanäle; das ist so gewollt.
|
||||
|
||||
## 6. Bekannte Grenzen und Restpunkte
|
||||
|
||||
- Dokumentvarianten, Stammdaten-Abgleich, eingefrorene Konfiguration und unabhängige Aktivitäten sind als Tests, nicht als eigene Tester-Szenarien abgebildet (der Tester spielt die Szenarien mit beliebigen Entwurfseinstellungen durch).
|
||||
- Eingehende Nachrichten anderer Medien werden gespeichert und entschieden; ein Posteingangs-Bildschirm zeigt `medium`, `intent` und `decision` nicht gesondert an.
|
||||
- Keine Antwort wird über WhatsApp/Chat gesendet.
|
||||
+7
-1
@@ -1,6 +1,12 @@
|
||||
# Projektstand
|
||||
|
||||
## Aktueller Stand (04.11.2026): Modulare Prozessarchitektur V2
|
||||
## Aktueller Stand (05.11.2026): V2.1 – fachliche Konfigurierbarkeit
|
||||
|
||||
**Umgesetzt auf `feature/prozessarchitektur-v2-1`:** Kanalfähigkeiten steuern die Modellwahl (mit erklärten Einschränkungen und Abgleich alter Werte), Ausführungsvarianten je Modul, Dokumentenerstellung/-ablage/-versand und Buchungsinformation entkoppelt, Warten auf die Bestätigungsmail des Portals (Belegung sofort gesichert, Eskalation, Wiederaufnahme), Kommunikation nach Medium × Absicht × Wirkung (WhatsApp/Chat nur als Testfälle der Architektur, kein Provider), nichtlineare Prozessansicht im Kanalkonfigurator, neue Tester-Szenarien, Erweiterungspunkt-Nachweis (Anschriftsprüfung).
|
||||
|
||||
Dokumente: [Lücken](Prozessarchitektur/V2.1/01_KONFIGURATIONSLUECKEN.md), [Zielbild](Prozessarchitektur/V2.1/02_FACHLICHES_ZIELBILD.md), [Abnahme Fälle A–H und Selbstprüfung](Prozessarchitektur/V2.1/ABNAHME_V2_1.md).
|
||||
|
||||
## Stand (04.11.2026): Modulare Prozessarchitektur V2
|
||||
|
||||
**Umgesetzt auf `feature/prozessarchitektur-v2` (Pakete U-0 bis U-E, Entscheidungen O1–O5, Anforderungen T1–T3):**
|
||||
|
||||
|
||||
@@ -20,21 +20,53 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if (! $this->record->isWebsite())
|
||||
@php($capabilities = $this->capabilities())
|
||||
<x-filament::section heading="Was kann dieses Portal für Ihr Konto?" description="Davon hängt ab, welche Abläufe passen. Mit dem Speichern bestätigen Sie die hier gezeigten Angaben. Geben Sie nur an, was Sie wissen – „unbekannt“ sperrt nichts.">
|
||||
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(18rem,1fr));gap:.6rem">
|
||||
@foreach ($capabilities as $key => $capability)
|
||||
<label style="{{ $card }};font-size:.85rem">
|
||||
{{ \App\Process\ChannelCapabilities::definitions()[$key]['question'] }}
|
||||
<select wire:model.live="capabilityDraft.{{ $key }}" style="{{ $input }};display:block;margin-top:.3rem">
|
||||
<option value="1">ja</option><option value="0">nein</option><option value="">unbekannt</option>
|
||||
</select>
|
||||
<span style="{{ $muted }}">{{ $capability->sourceLabel() }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</x-filament::section>
|
||||
@endif
|
||||
|
||||
<x-filament::section :heading="$this->question()" :description="$draft['derived'] ? 'Noch nicht gewählt: abgeleitet aus Ihren bisherigen Einstellungen. Gespeichert wird erst, wenn Sie speichern.' : null">
|
||||
@if ($models === [])
|
||||
<p>Für diesen Kanal ist für diese Eingangsart kein Ablaufmodell freigegeben (Kanalprofil). Vorgänge folgen weiter dem aus den Einstellungen abgeleiteten Ablauf.</p>
|
||||
<p>Für diese Eingangsart gibt es keine Ablaufmodelle.</p>
|
||||
@endif
|
||||
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(16rem,1fr));gap:.6rem" role="radiogroup" aria-label="Ablaufmodell">
|
||||
@foreach ($models as $key => $candidate)
|
||||
<button type="button" role="radio" aria-checked="{{ $draft['model'] === $key ? 'true' : 'false' }}" wire:click="chooseModel('{{ $key }}')"
|
||||
style="{{ $card }};text-align:left;{{ $draft['model'] === $key ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }}">
|
||||
<strong>{{ $candidate::label() }}</strong>
|
||||
<span style="{{ $muted }}"> · {{ implode('/', array_map(fn ($type) => strtoupper($type->value), $candidate::caseTypes())) }}</span>
|
||||
<div style="font-size:.85rem;margin-top:.3rem">{{ $candidate::description() }}</div>
|
||||
</button>
|
||||
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(18rem,1fr));gap:.6rem" role="radiogroup" aria-label="Ablaufmodell">
|
||||
@foreach ($models as $key => $option)
|
||||
@php($candidate = $option['model'])
|
||||
<div style="{{ $card }};{{ $draft['model'] === $key ? 'border-color:rgb(var(--primary-600));box-shadow:0 0 0 1px rgb(var(--primary-600))' : '' }};{{ $option['admissible'] ? '' : 'opacity:.85;background:rgba(128,128,128,.07)' }}">
|
||||
<button type="button" role="radio" aria-checked="{{ $draft['model'] === $key ? 'true' : 'false' }}" @disabled(! $option['admissible']) wire:click="chooseModel('{{ $key }}')" style="text-align:left;width:100%">
|
||||
<strong>{{ $candidate::label() }}</strong>
|
||||
<span style="{{ $muted }}"> · {{ implode('/', array_map(fn ($type) => strtoupper($type->value), $candidate::caseTypes())) }}</span>
|
||||
<div style="font-size:.85rem;margin-top:.3rem">{{ $candidate::description() }}</div>
|
||||
</button>
|
||||
@foreach ($option['restrictions'] as $restriction)
|
||||
<p style="color:#b45309;font-size:.8rem;margin-top:.4rem"><strong>Passt gerade nicht ({{ $restriction->kind }}):</strong> {{ $restriction->reason }}@if ($restriction->alternative) <br>Zulässig ist stattdessen: {{ $restriction->alternative }}.@endif @if ($restriction->change) <br>{{ $restriction->change }}.@endif</p>
|
||||
@endforeach
|
||||
@foreach ($option['hints'] as $hint)<p style="{{ $muted }};margin-top:.3rem">{{ $hint }}</p>@endforeach
|
||||
@if ($draft['model'] === $key && ! $option['admissible'])<p style="color:#b91c1c;font-size:.8rem;margin-top:.3rem">Dies ist Ihr bisheriger Ablauf. Er bleibt wirksam, bis Sie ein passendes Modell wählen oder die Fähigkeit oben ändern.</p>@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
@if ($conflicts = $this->conflicts())
|
||||
<div style="{{ $card }};margin-top:.8rem;border-color:#b45309">
|
||||
<strong>Bisherige Einstellungen widersprechen diesem Modell</strong>
|
||||
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">@foreach ($conflicts as $conflict)<li>{{ $conflict['text'] }}</li>@endforeach</ul>
|
||||
<label style="font-size:.85rem"><input type="checkbox" wire:model.live="acknowledge"> Ich bestätige: Diese bisherigen Einstellungen werden beim Speichern entfernt und im Verlauf des Kanals festgehalten.</label>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if (count($model->variants()) > 1)
|
||||
<div style="margin-top:.8rem">
|
||||
<label style="font-size:.9rem">Variante
|
||||
@@ -80,6 +112,10 @@
|
||||
</div>
|
||||
<div style="font-size:.85rem;margin-top:.25rem">{{ $step['purpose'] }}</div>
|
||||
<div style="{{ $muted }};margin-top:.25rem">
|
||||
@if ($step['needs'] !== []) braucht zuerst: {{ implode(', ', $step['needs']) }} · @elseif ($step['on']) läuft unabhängig · @endif
|
||||
@if ($step['after'] !== []) soll nach: {{ implode(', ', $step['after']) }} · @endif
|
||||
@if ($step['condition']) nur wenn: {{ $step['condition'] }} · @endif
|
||||
@if ($step['executions'] !== [] && ! $step['optional']) So darf das erfüllt werden: {{ implode(', ', $step['executions']) }}@if ($step['why']) – {{ $step['why'] }}@endif · @endif
|
||||
Wer: {{ $performers[$step['performer']] ?? $step['performer'] ?? '–' }}
|
||||
@if ($step['waits'] !== []) · kann warten auf: {{ implode(', ', array_map(fn ($wait) => ['guest' => 'Gast', 'portal' => 'Portal', 'landlord' => 'Sie', 'time' => 'Frist'][$wait] ?? $wait, $step['waits'])) }}@endif
|
||||
@if (! $step['on'] && $step['reason']) · <em>übersprungen: {{ $step['reason'] }}</em>@endif
|
||||
@@ -108,7 +144,14 @@
|
||||
|
||||
@foreach ($step['parameters'] as $parameter)
|
||||
<label style="display:block;font-size:.85rem;margin-top:.4rem">{{ $parameter['question'] }}
|
||||
<input type="text" wire:model.live.debounce.600ms="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" placeholder="{{ $parameter['value'] }}" style="{{ $input }};width:8rem;margin-left:.4rem">
|
||||
@if ($parameter['options'])
|
||||
<select wire:model.live="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" style="{{ $input }};margin-left:.4rem">
|
||||
<option value="">wie geerbt</option>
|
||||
@foreach ($parameter['options'] as $value => $label)<option value="{{ $value }}">{{ $label }}</option>@endforeach
|
||||
</select>
|
||||
@else
|
||||
<input type="text" wire:model.live.debounce.600ms="drafts.{{ $this->intake }}.settings.{{ $parameter['key'] }}" placeholder="{{ $parameter['value'] }}" style="{{ $input }};width:8rem;margin-left:.4rem">
|
||||
@endif
|
||||
<span style="{{ $muted }}">wirksam: {{ $parameter['value'] }} ({{ $parameter['source'] }})</span>
|
||||
@if ($parameter['set'])
|
||||
<button type="button" wire:click="inherit('{{ $parameter['key'] }}')" style="{{ $muted }};text-decoration:underline">auf geerbten Wert zurücksetzen</button>
|
||||
@@ -121,14 +164,14 @@
|
||||
</div>
|
||||
|
||||
<x-filament::section heading="Vorschau: ein neuer Vorgang" description="Mit den aktuellen, auch ungespeicherten Einstellungen. Es wird nichts gespeichert und nichts ausgeführt.">
|
||||
<ol style="font-size:.85rem;list-style:decimal;padding-left:1.2rem">
|
||||
<ul style="font-size:.85rem;list-style:disc;padding-left:1.2rem">
|
||||
@foreach ($steps as $step)
|
||||
<li style="{{ $step['on'] ? '' : 'color:#9ca3af;text-decoration:line-through' }}">
|
||||
{{ $step['label'] }}
|
||||
<span style="{{ $muted }}">– {{ $step['on'] ? ($performers[$step['performer']] ?? $step['performer'] ?? '').($step['mode'] ? ', '.(\App\Enums\ProcessingMode::tryFrom($step['mode'])?->getLabel() ?? \App\Enums\DataRequestMode::tryFrom($step['mode'])?->getLabel() ?? $step['mode']) : '') : 'übersprungen: '.$step['reason'] }}</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ol>
|
||||
</ul>
|
||||
<p style="{{ $muted }};margin-top:.6rem">Gilt für neue Vorgänge. Laufende Vorgänge dieses Kanals ({{ $this->runningCases() }}) behalten ihren bisherigen Ablauf.</p>
|
||||
<x-filament::button color="gray" wire:click="test" style="margin-top:.6rem">Ablauf testen</x-filament::button>
|
||||
<p style="{{ $muted }}">Spielt einen ausgedachten Vorgang mit genau dieser Einstellung durch – ohne Wirkung auf echte Daten.</p>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{{-- Working draft (V2.1): short booking information, no contract, no payment instructions. --}}
|
||||
@php($portal = $booking->processChannel()?->name ?? 'dem Portal')
|
||||
<x-mail::message :site="$booking->website()" :message="$message ?? null">
|
||||
# Ihre Buchung der {{ $booking->property->name }}
|
||||
|
||||
Guten Tag {{ $booking->guest->full_name }},
|
||||
|
||||
wir haben Ihre Buchung über {{ $portal }} erhalten und freuen uns auf Ihren Besuch.
|
||||
|
||||
**Anreise:** {{ $booking->arrival->translatedFormat('l, d.m.Y') }}@if ($booking->property->check_in_time) ab {{ substr($booking->property->check_in_time, 0, 5) }} Uhr @endif<br>
|
||||
**Abreise:** {{ $booking->departure->translatedFormat('l, d.m.Y') }}@if ($booking->property->check_out_time) bis {{ substr($booking->property->check_out_time, 0, 5) }} Uhr @endif<br>
|
||||
@if ($booking->guests)
|
||||
**Personen:** {{ $booking->guests }}<br>
|
||||
@endif
|
||||
@if ($booking->portal_reference)
|
||||
**Buchungsnummer bei {{ $portal }}:** {{ $booking->portal_reference }}<br>
|
||||
@endif
|
||||
**Unsere Nummer:** {{ $booking->reference }}
|
||||
|
||||
Bei Fragen antworten Sie einfach auf diese E-Mail.
|
||||
|
||||
Herzliche Grüße<br>
|
||||
{{ config('fewo.owner.name') }}
|
||||
</x-mail::message>
|
||||
@@ -17,6 +17,8 @@
|
||||
Schedule::command('bookings:expire-holds')->everyFiveMinutes()->withoutOverlapping();
|
||||
|
||||
Schedule::command('bookings:auto-offers')->everyFiveMinutes()->withoutOverlapping();
|
||||
// Binding bookings waiting for a portal confirmation: deadline, escalation, resume (V2.1).
|
||||
Schedule::command('bookings:advance-waiting')->everyFiveMinutes()->withoutOverlapping();
|
||||
|
||||
// v0.11: reminders of data requests (never extends a hold or a deadline of the case).
|
||||
Schedule::command('cases:data-requests')->everyFiveMinutes()->withoutOverlapping();
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Process;
|
||||
|
||||
use App\Actions\ConfigureChannelProcess;
|
||||
use App\Actions\TakeOverExternalBooking;
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Filament\Resources\Channels\Pages\ChannelProcess;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Process\Capability;
|
||||
use App\Process\ChannelCapabilities;
|
||||
use App\Process\ChannelProcessConfiguration;
|
||||
use App\Process\ProcessProfile;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Livewire\Livewire;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* V2.1 cases A and B (docs/Prozessarchitektur/V2.1/02 §3): the admissible models follow from the confirmed capabilities of
|
||||
* the channel, not from a fixed list of portals; old stored settings and the draft are told apart; a model fixing a
|
||||
* stored setting differently is never switched silently.
|
||||
*/
|
||||
#[Group('configurator')]
|
||||
class ChannelCapabilityTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-10-23 10:00'));
|
||||
$this->seed(PropertySeeder::class);
|
||||
$this->property = Property::sole();
|
||||
Mail::fake();
|
||||
}
|
||||
|
||||
/** Case A: Destination Solutions today – we collect, we document (E-016 for the described account). */
|
||||
public function test_case_a_destination_solutions_today_is_a3(): void
|
||||
{
|
||||
$ds = $this->channel('Destination Solution', []);
|
||||
|
||||
$options = app(ChannelProcessConfiguration::class)->modelOptions($ds, IntakeKind::Booking);
|
||||
|
||||
$this->assertSame(Capability::SUGGESTED, app(ChannelCapabilities::class)->resolve($ds)['collects_payment']->source);
|
||||
$this->assertTrue($options['a3.portal_booking']['admissible']);
|
||||
$this->assertFalse($options['a4.portal_booking']['admissible']);
|
||||
$restriction = $options['a4.portal_booking']['restrictions'][0];
|
||||
$this->assertSame('Kanalfähigkeit', $restriction->kind);
|
||||
$this->assertStringContainsString('Zieht das Portal das Geld des Gastes ein?', $restriction->reason);
|
||||
$this->assertSame('Portalbuchung, eigene Abwicklung', $restriction->alternative, 'the allowed alternative is named');
|
||||
$this->assertStringContainsString('Inkasso', (string) $restriction->change);
|
||||
}
|
||||
|
||||
/** Case B: the account changes – the portal collects. The existing A4 model fits; no new logic. */
|
||||
public function test_case_b_destination_solutions_with_portal_collection_switches_to_the_existing_a4_model(): void
|
||||
{
|
||||
$ds = $this->channel('Destination Solution', []);
|
||||
$configuration = app(ChannelProcessConfiguration::class);
|
||||
$before = $configuration->modelOptions($ds, IntakeKind::Booking);
|
||||
$this->assertFalse($before['a4.portal_booking']['admissible']);
|
||||
|
||||
// The unsaved draft already changes what fits.
|
||||
$draft = ['collects_payment' => '1'];
|
||||
$this->assertTrue($configuration->modelOptions($ds, IntakeKind::Booking, $draft)['a4.portal_booking']['admissible']);
|
||||
$this->assertFalse($configuration->modelOptions($ds, IntakeKind::Booking, $draft)['a3.portal_booking']['admissible']);
|
||||
|
||||
app(ConfigureChannelProcess::class)->handle($ds, IntakeKind::Booking, ['model' => 'a4.portal_booking', 'capabilities' => $draft], by: 'Lars');
|
||||
|
||||
$ds->refresh();
|
||||
$capability = app(ChannelCapabilities::class)->resolve($ds)['collects_payment'];
|
||||
$this->assertSame([true, Capability::CONFIRMED, 'Lars'], [$capability->value, $capability->source, $capability->confirmedBy]);
|
||||
$this->assertSame('Inkasso: ja', $ds->settings['process_history'][0]['capabilities'][0]);
|
||||
|
||||
$booking = app(TakeOverExternalBooking::class)->handle($this->property, $ds, CarbonImmutable::parse('2026-12-05'), CarbonImmutable::parse('2026-12-09'), ['portal_reference' => 'DS-NEU']);
|
||||
$this->assertSame([CaseType::A4, 'a4.portal_booking'], [$booking->case_type, $booking->profile['plan']['model']]);
|
||||
$this->assertSame(ProcessProfile::MODEL, $booking->process()->source(ProcessSetting::Payments));
|
||||
}
|
||||
|
||||
/** The old stored value `payments = portal` is a derived capability and is shown as such – not overwritten unnoticed. */
|
||||
public function test_a_stored_old_setting_becomes_a_derived_capability_and_is_not_silently_overridden(): void
|
||||
{
|
||||
$ds = $this->channel('Destination Solution', ['booking' => ['payments' => 'portal']]);
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
$capability = app(ChannelCapabilities::class)->resolve($ds)['collects_payment'];
|
||||
$this->assertSame([true, Capability::DERIVED], [$capability->value, $capability->source], 'the stored setting wins over the profile suggestion');
|
||||
|
||||
// The derived model of this channel is A4 – the page keeps it instead of switching to A3.
|
||||
$page = Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])->set('intake', 'booking');
|
||||
$this->assertSame('a4.portal_booking', $page->get('drafts')['booking']['model']);
|
||||
$page->assertSee('abgeleitet aus Ihrer bisherigen Einstellung');
|
||||
}
|
||||
|
||||
/** The order is shown from the module definitions: dependencies, independence, conditions and how a duty may be fulfilled. */
|
||||
public function test_the_configurator_shows_dependencies_independence_and_allowed_fulfilment(): void
|
||||
{
|
||||
$ds = $this->channel('Destination Solution', []);
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
$steps = collect(Livewire::test(ChannelProcess::class, ['record' => $ds->getRouteKey()])->set('intake', 'booking')->instance()->steps())->keyBy('module');
|
||||
|
||||
$this->assertNotEmpty($steps['documents.send']['needs'], 'the contract documents need something first');
|
||||
$this->assertSame([], $steps['intake.record']['needs'], 'the intake depends on nothing');
|
||||
$this->assertNotNull($steps['documents.booking_notice']['condition']);
|
||||
foreach ($steps as $step) {
|
||||
if ($step['toggle'] === 'mandatory' && $step['executions'] !== []) {
|
||||
$this->assertNotNull($step['why'], $step['module'].': the restriction is explained');
|
||||
}
|
||||
}
|
||||
$this->assertNotEmpty(collect($steps['documents.send']['parameters'])->firstWhere('key', 'contract_delivery')['options']);
|
||||
}
|
||||
|
||||
public function test_saving_a_model_that_overrides_a_stored_setting_needs_the_confirmation_and_is_recorded(): void
|
||||
{
|
||||
$channel = $this->channel('Sonstiges Portal', ['booking' => ['payments' => 'portal', 'guest_messages' => 'portal']]);
|
||||
$channel->update(['settings' => [...(array) $channel->settings, 'capabilities' => ['collects_payment' => ['value' => false, 'at' => now()->toIso8601String(), 'by' => 'Lars']]]]);
|
||||
$configuration = app(ChannelProcessConfiguration::class);
|
||||
|
||||
$conflicts = $configuration->conflicts($channel->refresh(), IntakeKind::Booking, 'a3.portal_booking');
|
||||
$this->assertSame([ProcessSetting::Payments], array_column($conflicts, 'setting'));
|
||||
|
||||
try {
|
||||
app(ConfigureChannelProcess::class)->handle($channel, IntakeKind::Booking, ['model' => 'a3.portal_booking'], by: 'Lars');
|
||||
$this->fail('saving without the confirmation must be refused');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertStringContainsString('ausdrücklich bestätigen', $exception->errors()['process'][0]);
|
||||
$this->assertStringContainsString('Bisher eingestellt: „Das Portal“', $exception->errors()['process'][1]);
|
||||
}
|
||||
$this->assertSame('portal', $channel->fresh()->process_overrides['booking']['payments'], 'nothing was changed');
|
||||
|
||||
app(ConfigureChannelProcess::class)->handle($channel, IntakeKind::Booking, ['model' => 'a3.portal_booking'], by: 'Lars', acknowledgeConflicts: true);
|
||||
|
||||
$channel->refresh();
|
||||
$this->assertArrayNotHasKey('payments', $channel->process_overrides['booking']);
|
||||
$this->assertSame('portal', $channel->process_overrides['booking']['guest_messages'], 'what the model does not fix stays');
|
||||
$this->assertStringContainsString('Bisher eingestellt', $channel->settings['process_history'][0]['removed_settings'][0]);
|
||||
}
|
||||
|
||||
public function test_unknown_capabilities_block_nothing_but_ask_for_confirmation(): void
|
||||
{
|
||||
$generic = $this->channel('Irgendein Portal', []);
|
||||
|
||||
$options = app(ChannelProcessConfiguration::class)->modelOptions($generic, IntakeKind::Booking);
|
||||
|
||||
$this->assertSame(['a3.portal_booking', 'a4.portal_booking', 'a5.portal_booking'], array_keys(array_filter($options, fn (array $option): bool => $option['admissible'])));
|
||||
$this->assertNotSame([], $options['a4.portal_booking']['hints']);
|
||||
}
|
||||
|
||||
public function test_a5_needs_both_capabilities_and_says_which_is_missing(): void
|
||||
{
|
||||
$fewo = $this->channel('FeWo-direkt', []);
|
||||
|
||||
$a5 = app(ChannelProcessConfiguration::class)->modelOptions($fewo, IntakeKind::Booking)['a5.portal_booking'];
|
||||
|
||||
$this->assertFalse($a5['admissible']);
|
||||
$this->assertStringContainsString('Vertragsunterlagen', $a5['restrictions'][0]->change);
|
||||
$this->assertTrue(app(ChannelProcessConfiguration::class)->modelOptions($fewo, IntakeKind::Booking, ['provides_contract_documents' => '1'])['a5.portal_booking']['admissible'], 'O2 is a suggestion: with a confirmed capability A5 becomes available');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $overrides
|
||||
*/
|
||||
private function channel(string $name, array $overrides): Channel
|
||||
{
|
||||
return Channel::factory()->for($this->property)->create(['name' => $name, 'booking_model' => 'portal_booking', 'process_overrides' => $overrides, 'import_enabled' => false, 'settings' => ['import_url' => 'https://portal.example/'.md5($name).'.ics']]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Process;
|
||||
|
||||
use App\Actions\ConfigureChannelProcess;
|
||||
use App\Actions\ContributeCaseFacts;
|
||||
use App\Actions\ProcessPortalMail;
|
||||
use App\Actions\RecordPortalAmounts;
|
||||
use App\Actions\SendBookingDocuments;
|
||||
use App\Actions\SendBookingNotice;
|
||||
use App\Actions\TakeOverExternalBooking;
|
||||
use App\Channels\Mail\PortalMail;
|
||||
use App\Documents\DocumentReleases;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\DocumentKind;
|
||||
use App\Enums\FactSource;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Mail\BookingConfirmed;
|
||||
use App\Mail\BookingDocumentation;
|
||||
use App\Mail\BookingNotice;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ContractTemplate;
|
||||
use App\Models\Property;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Process\PortalConfirmation;
|
||||
use App\Process\ProcessRunner;
|
||||
use App\Support\Content;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* V2.1 cases C and D (docs/Prozessarchitektur/V2.1/02 §4–5): the contract document is created, filed and sent
|
||||
* independently; a short booking information stands on its own; guest-facing steps wait for the portal's confirmation mail
|
||||
* while the occupation is protected from the start; a missing mail escalates once; the landlord can confirm or send by hand.
|
||||
*/
|
||||
#[Group('module:portal.confirmation')]
|
||||
#[Group('module:documents.booking_notice')]
|
||||
class DocumentsAndPortalConfirmationTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
private Channel $portal;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-10-23 10:00'));
|
||||
$this->seed(PropertySeeder::class);
|
||||
$this->property = Property::sole();
|
||||
Storage::fake('local');
|
||||
Mail::fake();
|
||||
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'process_defaults' => ['processing' => 'automatic']]);
|
||||
DocumentReleases::set(DocumentKind::ExternalRecord, true, 'Test');
|
||||
$template = ContractTemplate::query()->create(['name' => 'Portalunterlagen', 'version' => 1, 'body' => '<p>Mietvertrag {{ mieter }}</p>', 'released_at' => now(), 'portal_terms_confirmed_at' => now()]);
|
||||
$this->portal = Channel::factory()->for($this->property)->create(['name' => 'Destination Solution', 'booking_model' => 'portal_booking', 'import_enabled' => false, 'case_intake' => 'create',
|
||||
'process_overrides' => ['booking' => ['contract_template_id' => $template->id]],
|
||||
'settings' => ['import_url' => 'https://ds.example/a.ics', 'email_senders' => 'ds.example']]);
|
||||
}
|
||||
|
||||
/** Case D: the contract is filed internally; the guest gets only a booking information. */
|
||||
public function test_case_d_contract_only_internal_and_the_guest_gets_only_a_booking_information(): void
|
||||
{
|
||||
$this->configure(['contract_delivery' => 'internal', 'booking_notice' => 'automatic']);
|
||||
|
||||
$booking = $this->booking();
|
||||
|
||||
$booking->refresh();
|
||||
$this->assertNotNull($booking->contract_path, 'the contract was created and filed');
|
||||
$this->assertNull($booking->confirmation_sent_at, 'but not sent');
|
||||
Mail::assertNotSent(BookingDocumentation::class);
|
||||
Mail::assertNotSent(BookingConfirmed::class);
|
||||
Mail::assertSent(BookingNotice::class, 1);
|
||||
$activities = collect(CaseActivities::for($booking))->keyBy('key');
|
||||
$this->assertSame([ActivityState::Done, 'Vertrag intern abgelegt'], [$activities['documents']->state, $activities['documents']->label]);
|
||||
$this->assertSame(ActivityState::Done, $activities['booking_notice']->state);
|
||||
|
||||
// Sending the contract later by hand stays possible and fills the usual record.
|
||||
$this->assertTrue(app(SendBookingDocuments::class)->handle($booking->fresh()));
|
||||
$this->assertNotNull($booking->fresh()->confirmation_sent_at);
|
||||
Mail::assertSent(BookingDocumentation::class, 1);
|
||||
}
|
||||
|
||||
public function test_the_default_setting_sends_the_contract_documents_as_before_and_no_notice(): void
|
||||
{
|
||||
$this->configure([]);
|
||||
|
||||
$booking = $this->booking();
|
||||
|
||||
Mail::assertSent(BookingDocumentation::class, 1);
|
||||
Mail::assertNotSent(BookingNotice::class);
|
||||
$this->assertNotNull($booking->fresh()->confirmation_sent_at);
|
||||
$this->assertNull(collect(CaseActivities::for($booking->fresh()))->firstWhere('key', 'booking_notice'));
|
||||
}
|
||||
|
||||
public function test_the_contract_after_release_by_hand_is_prepared_but_not_sent(): void
|
||||
{
|
||||
$this->configure(['contract_delivery' => 'manual']);
|
||||
|
||||
$booking = $this->booking();
|
||||
|
||||
Mail::assertNothingSent();
|
||||
$this->assertNull($booking->fresh()->contract_path);
|
||||
$this->assertSame('sendDocuments', collect(CaseActivities::for($booking->fresh()))->firstWhere('key', 'documents')->action);
|
||||
}
|
||||
|
||||
public function test_the_portal_confirmation_is_not_needed_when_the_portal_provides_everything_so_no_own_notice_goes_out(): void
|
||||
{
|
||||
$this->configure(['booking_notice' => 'automatic_unless_portal_confirmed', 'contract_delivery' => 'internal'], capabilities: ['messages_guest' => '1']);
|
||||
|
||||
$booking = $this->bookingFromMail();
|
||||
|
||||
Mail::assertNotSent(BookingNotice::class);
|
||||
$notice = collect(CaseActivities::for($booking->fresh()))->firstWhere('key', 'booking_notice');
|
||||
$this->assertSame(ActivityState::NotApplicable, $notice->state);
|
||||
$this->assertStringContainsString('Das Portal informiert den Gast selbst und hat die Buchung bestätigt', $notice->detail);
|
||||
$this->assertFalse(SendBookingNotice::sent($booking->fresh()));
|
||||
}
|
||||
|
||||
/** Case C: the occupation is protected at once; the guest-facing steps wait for the portal's mail. */
|
||||
public function test_case_c_guest_facing_steps_wait_for_the_portal_confirmation_and_the_occupation_does_not(): void
|
||||
{
|
||||
$this->configure(['await_portal_confirmation' => '1', 'booking_notice' => 'automatic'], capabilities: ['sends_confirmation_mail' => '1']);
|
||||
|
||||
// The booking is recognised without the portal's mail (e.g. a calendar entry or a manual entry).
|
||||
$booking = $this->booking(withGuest: true);
|
||||
|
||||
$booking->refresh();
|
||||
$this->assertTrue(Booking::query()->occupying()->whereKey($booking->id)->exists(), 'the booking is binding and occupies from the start');
|
||||
$this->assertNull($booking->confirmation_sent_at);
|
||||
Mail::assertNothingSent();
|
||||
$activities = collect(CaseActivities::for($booking))->keyBy('key');
|
||||
$this->assertSame(ActivityState::Waiting, $activities['portal_confirmation']->state);
|
||||
$this->assertSame(ActivityState::Waiting, $activities['documents']->state);
|
||||
$this->assertStringContainsString('wartet auf die Bestätigungsmail des Portals', $activities['documents']->detail);
|
||||
$this->assertSame(ActivityState::Waiting, $activities['booking_notice']->state);
|
||||
$this->assertNotSame(ActivityState::Waiting, $activities['stay']->state === ActivityState::Waiting ? ActivityState::Open : ActivityState::Done, 'independent steps are not held up');
|
||||
|
||||
// The portal's mail arrives late and is assigned to the case by its reference: everything goes on.
|
||||
$this->travel(5)->hours();
|
||||
$this->portalMail('Neue Buchung', $this->bookingText('DS-WAIT'));
|
||||
|
||||
$booking->refresh();
|
||||
$this->assertNotNull(PortalConfirmation::evidence($booking));
|
||||
$this->assertNotNull($booking->confirmation_sent_at, 'the contract documents went out after the confirmation');
|
||||
Mail::assertSent(BookingNotice::class, 1);
|
||||
}
|
||||
|
||||
public function test_a_missing_confirmation_escalates_once_and_sends_nothing(): void
|
||||
{
|
||||
$this->configure(['await_portal_confirmation' => '1', 'portal_confirmation_wait_hours' => '24', 'booking_notice' => 'automatic']);
|
||||
$booking = $this->booking(withGuest: true);
|
||||
|
||||
$this->artisan('bookings:advance-waiting')->assertSuccessful();
|
||||
$this->assertSame(0, BookingTask::query()->where('booking_id', $booking->id)->where('kind', BookingTaskKind::PortalConfirmationMissing)->count(), 'within the time: nothing');
|
||||
|
||||
$this->travel(25)->hours();
|
||||
$this->artisan('bookings:advance-waiting')->assertSuccessful();
|
||||
$this->artisan('bookings:advance-waiting')->assertSuccessful();
|
||||
|
||||
$task = BookingTask::query()->where('booking_id', $booking->id)->where('kind', BookingTaskKind::PortalConfirmationMissing)->sole();
|
||||
$this->assertSame(BookingTaskStatus::Open, $task->status);
|
||||
Mail::assertNothingSent();
|
||||
$this->assertTrue(Booking::query()->occupying()->whereKey($booking->id)->exists());
|
||||
$this->assertSame(ActivityState::Problem, collect(CaseActivities::for($booking->fresh()))->firstWhere('key', 'portal_confirmation')->state);
|
||||
|
||||
// The mail comes after all: the task closes and the waiting steps go on.
|
||||
$this->portalMail('Neue Buchung', $this->bookingText('DS-WAIT'));
|
||||
$this->artisan('bookings:advance-waiting')->assertSuccessful();
|
||||
|
||||
$this->assertSame(BookingTaskStatus::Done, $task->fresh()->status);
|
||||
$this->assertNotNull($booking->fresh()->confirmation_sent_at);
|
||||
}
|
||||
|
||||
public function test_the_landlord_confirms_in_the_case_and_the_waiting_steps_continue(): void
|
||||
{
|
||||
$this->configure(['await_portal_confirmation' => '1', 'booking_notice' => 'automatic']);
|
||||
$booking = $this->booking(withGuest: true);
|
||||
$this->assertNull($booking->fresh()->confirmation_sent_at);
|
||||
|
||||
PortalConfirmation::confirm($booking->fresh(), 'Ingrid', 'im Portal gesehen');
|
||||
app(ProcessRunner::class)->advance($booking->fresh(), 'portal.mail');
|
||||
|
||||
$this->assertSame('landlord', PortalConfirmation::evidence($booking->fresh())['source']);
|
||||
$this->assertNotNull($booking->fresh()->confirmation_sent_at);
|
||||
Mail::assertSent(BookingNotice::class, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $settings
|
||||
* @param array<string, string> $capabilities
|
||||
*/
|
||||
private function configure(array $settings, array $capabilities = []): void
|
||||
{
|
||||
app(ConfigureChannelProcess::class)->handle($this->portal, IntakeKind::Booking, ['model' => 'a3.portal_booking', 'settings' => $settings, 'capabilities' => $capabilities], by: 'Test');
|
||||
$this->portal->refresh();
|
||||
}
|
||||
|
||||
private function booking(bool $withGuest = true): Booking
|
||||
{
|
||||
return app(TakeOverExternalBooking::class)->handle($this->property, $this->portal, CarbonImmutable::parse('2026-12-05'), CarbonImmutable::parse('2026-12-09'), [
|
||||
'portal_reference' => 'DS-WAIT', 'portal_total' => 98000, 'guests' => 2,
|
||||
...($withGuest ? ['guest' => ['first_name' => 'Dora', 'last_name' => 'Gast', 'email' => 'dora@example.org', 'street' => 'Weg 1', 'postal_code' => '10115', 'city' => 'Berlin', 'country' => 'DE']] : []),
|
||||
]);
|
||||
}
|
||||
|
||||
private function bookingFromMail(): Booking
|
||||
{
|
||||
$this->portalMail('Neue Buchung', $this->bookingText('DS-MAIL'));
|
||||
$booking = Booking::query()->where('portal_reference', 'DS-MAIL')->sole();
|
||||
app(ContributeCaseFacts::class)->handle($booking, ['guest.first_name' => 'Dora', 'guest.last_name' => 'Gast', 'guest.email' => 'dora@example.org'], FactSource::PortalMail);
|
||||
app(RecordPortalAmounts::class)->handle($booking->fresh(), 98000, [], [], 'Destination Solution');
|
||||
|
||||
return $booking->fresh();
|
||||
}
|
||||
|
||||
private function bookingText(string $reference): string
|
||||
{
|
||||
return "Gast: Dora Gast\nAnreise: 05.12.2026\nAbreise: 09.12.2026\nBuchungsnummer: {$reference}";
|
||||
}
|
||||
|
||||
private function portalMail(string $subject, string $text): void
|
||||
{
|
||||
app(ProcessPortalMail::class)->handle(new PortalMail('<'.md5($text.now()).'@ds.example>', 'buchung@ds.example', $subject, $text, CarbonImmutable::now()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Process;
|
||||
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Property;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Process\ProcessCatalogue;
|
||||
use App\Process\ProcessPlan;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* V2.1 cases G and H: independent steps proceed while others wait (G); a new optional step is added at an existing
|
||||
* extension point without touching any other model (H).
|
||||
*/
|
||||
#[Group('module:guest.address_check')]
|
||||
class ExtensionAndIndependentStepsTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-10-23 10:00'));
|
||||
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||
$this->property = Property::sole();
|
||||
Mail::fake();
|
||||
}
|
||||
|
||||
/** Case H: the optional address check sits at an extension point; only the A1 offer model offers the variant. */
|
||||
public function test_case_h_an_optional_address_check_is_added_at_an_extension_point_without_changing_other_models(): void
|
||||
{
|
||||
$catalogue = app(ProcessCatalogue::class);
|
||||
$using = array_keys(array_filter($catalogue->models(), fn ($model): bool => collect($model->variants())->contains(fn ($variant): bool => in_array('guest.address_check', $model->modules($variant->key), true))));
|
||||
|
||||
$this->assertSame(['a1.offer'], $using);
|
||||
$this->assertSame([], $catalogue->problems());
|
||||
foreach ($catalogue->models() as $key => $model) {
|
||||
$this->assertNotContains('guest.address_check', $model->modules('standard'), "{$key}: standard course unchanged");
|
||||
}
|
||||
|
||||
$booking = $this->request(postalCode: '1011');
|
||||
$plan = ProcessPlan::freeze($booking->process(), ['model' => 'a1.offer', 'variant' => 'address_check'], sandbox: true);
|
||||
$booking->forceFill(['profile' => [...$booking->profile, 'plan' => $plan->toArray()]])->saveQuietly();
|
||||
|
||||
$check = collect(CaseActivities::for($booking->fresh()))->firstWhere('key', 'address_check');
|
||||
$this->assertSame(ActivityState::Done, $check->state, 'the check only informs and holds nothing back');
|
||||
$this->assertStringContainsString('Postleitzahl hat nicht fünf Ziffern', $check->detail);
|
||||
}
|
||||
|
||||
public function test_case_h_the_address_check_cannot_reach_a_real_case(): void
|
||||
{
|
||||
$this->expectExceptionMessage('nur im Prozess-Tester');
|
||||
|
||||
ProcessPlan::freeze($this->request()->process(), ['model' => 'a1.offer', 'variant' => 'address_check']);
|
||||
}
|
||||
|
||||
/** Case G: the clarification hold stands while the missing details are collected; the offer waits for them, not for the hold. */
|
||||
public function test_case_g_hold_and_data_collection_run_independently_and_the_offer_waits_for_the_details(): void
|
||||
{
|
||||
$booking = $this->request(street: '');
|
||||
|
||||
$activities = collect(CaseActivities::for($booking->fresh()))->keyBy('key');
|
||||
|
||||
$this->assertTrue(Booking::query()->occupying()->whereKey($booking->id)->exists(), 'the dates are held at once, independent of the missing details');
|
||||
$this->assertSame(ActivityState::Open, $activities['contact']->state);
|
||||
$this->assertStringContainsString('fehlt: Straße und Hausnummer', $activities['contact']->detail);
|
||||
$this->assertSame(ActivityState::Later, $activities['offer']->state, 'no binding offer before the required details');
|
||||
$this->assertSame('erst wenn alle Angaben da sind', $activities['offer']->detail);
|
||||
}
|
||||
|
||||
private function request(string $street = 'Weg 1', string $postalCode = '10115'): Booking
|
||||
{
|
||||
return app(CreateReservation::class)->handle($this->property->fresh(), new StayRequest(CarbonImmutable::parse('2026-11-07'), CarbonImmutable::parse('2026-11-10'), 2), ['first_name' => 'Gesa', 'last_name' => 'Gast', 'email' => 'gesa@example.org', 'street' => $street, 'postal_code' => $postalCode, 'city' => 'Berlin', 'country' => 'DE'])->fresh();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Process;
|
||||
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Communication\CommunicationRules;
|
||||
use App\Communication\IncomingMessage;
|
||||
use App\Communication\MessageDecision;
|
||||
use App\Communication\MessageIntake;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\Medium;
|
||||
use App\Enums\MessageEffect;
|
||||
use App\Enums\MessageIntent;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\InboundMessage;
|
||||
use App\Models\Property;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* V2.1 cases E and F (docs/Prozessarchitektur/V2.1/02 §6): medium, intent and effect are separate. WhatsApp and chat are
|
||||
* test cases of the architecture (no provider): an assigned reply keeps its origin, a question without a case causes no
|
||||
* case, everything unclear or contradictory goes to review.
|
||||
*/
|
||||
#[Group('module:communication.medium')]
|
||||
class MessageMediumIntentTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-10-22 10:00'));
|
||||
$this->seed(PropertySeeder::class);
|
||||
$this->property = Property::sole();
|
||||
Mail::fake();
|
||||
config(['communication.media.whatsapp.active' => true, 'communication.media.chat.active' => true]);
|
||||
}
|
||||
|
||||
/** Case E: a reply by WhatsApp with a verified reference reaches the case, origin preserved, nothing taken over by itself. */
|
||||
public function test_case_e_a_whatsapp_reply_with_verified_reference_reports_to_the_case_and_keeps_its_origin(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
$decision = $this->receive(Medium::WhatsApp, 'Wir kommen gegen 16 Uhr an, Kennzeichen HRO-AB 123', verified: $booking->id, consent: true);
|
||||
|
||||
$this->assertSame(MessageIntent::ProvideData, $decision->intent);
|
||||
$this->assertTrue($decision->booking->is($booking));
|
||||
$this->assertTrue($decision->has(MessageEffect::ContributeFacts));
|
||||
$this->assertTrue($decision->has(MessageEffect::ReportToCase));
|
||||
$message = InboundMessage::query()->sole();
|
||||
$this->assertSame('whatsapp', $message->medium);
|
||||
$this->assertSame($booking->id, $message->booking_id);
|
||||
$this->assertSame(1, BookingTask::query()->where('booking_id', $booking->id)->where('kind', BookingTaskKind::InboundReview)->count());
|
||||
$this->assertSame($booking->status, $booking->fresh()->status, 'the message changes no booking status');
|
||||
$this->assertSame(1, Booking::query()->count());
|
||||
}
|
||||
|
||||
public function test_the_same_message_twice_is_stored_and_decided_once(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
$this->receive(Medium::Chat, 'Ankunft 15 Uhr', verified: $booking->id, id: 'c-1');
|
||||
$again = $this->receive(Medium::Chat, 'Ankunft 15 Uhr', verified: $booking->id, id: 'c-1');
|
||||
|
||||
$this->assertSame(1, InboundMessage::query()->count());
|
||||
$this->assertSame(1, BookingTask::query()->where('kind', BookingTaskKind::InboundReview)->count());
|
||||
$this->assertTrue($again->booking->is($booking));
|
||||
}
|
||||
|
||||
/** Case F: an inquiry without a case via chat answers or hands off – and never creates a case. */
|
||||
public function test_case_f_a_general_question_creates_no_case_and_only_allows_information(): void
|
||||
{
|
||||
$decision = $this->receive(Medium::Chat, 'Sind Hunde erlaubt und gibt es einen Parkplatz?');
|
||||
|
||||
$this->assertSame(MessageIntent::GeneralQuestion, $decision->intent);
|
||||
$this->assertSame([MessageEffect::AnswerInformation], $decision->effects);
|
||||
$this->assertNull($decision->booking);
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
$this->assertSame(0, BookingTask::query()->count());
|
||||
}
|
||||
|
||||
public function test_a_stay_inquiry_via_whatsapp_refers_to_the_inquiry_path_and_books_nothing(): void
|
||||
{
|
||||
$decision = $this->receive(Medium::WhatsApp, 'Ist die Wohnung vom 12.12. bis 19.12. frei? Wir würden gern buchen.', consent: true);
|
||||
|
||||
$this->assertSame(MessageIntent::StayInquiry, $decision->intent);
|
||||
$this->assertSame([MessageEffect::HandoffInquiry], $decision->effects);
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
}
|
||||
|
||||
public function test_same_sender_or_name_alone_never_assigns_a_case(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
$decision = $this->receive(Medium::WhatsApp, 'Hier Gesa Gast, wir kommen um 16 Uhr an.', sender: 'gesa@example.org', consent: true);
|
||||
|
||||
$this->assertNull($decision->booking);
|
||||
$this->assertSame([MessageEffect::Review], $decision->effects);
|
||||
$this->assertSame(InboundMessage::NEEDS_REVIEW, InboundMessage::query()->sole()->status);
|
||||
$this->assertSame(0, BookingTask::query()->where('booking_id', $booking->id)->count());
|
||||
}
|
||||
|
||||
public function test_a_contradicting_case_number_in_the_text_sends_the_message_to_review(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
$decision = $this->receive(Medium::Chat, 'Zu Vorgang 2099-0001: Ankunft 17 Uhr', verified: $booking->id);
|
||||
|
||||
$this->assertNull($decision->booking);
|
||||
$this->assertSame([MessageEffect::Review], $decision->effects);
|
||||
$this->assertStringContainsString('widersprüchlich', implode(' ', $decision->reasons));
|
||||
}
|
||||
|
||||
public function test_an_unclear_message_goes_to_review(): void
|
||||
{
|
||||
$decision = $this->receive(Medium::Chat, 'ok danke');
|
||||
|
||||
$this->assertSame(MessageIntent::Unclear, $decision->intent);
|
||||
$this->assertSame([MessageEffect::Review], $decision->effects);
|
||||
}
|
||||
|
||||
public function test_a_medium_without_consent_or_switched_off_only_reaches_review(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
$noConsent = $this->receive(Medium::WhatsApp, 'Ankunft 16 Uhr', verified: $booking->id, consent: false, id: 'w-1');
|
||||
config(['communication.media.chat.active' => false]);
|
||||
$off = $this->receive(Medium::Chat, 'Ankunft 16 Uhr', verified: $booking->id, id: 'c-9');
|
||||
|
||||
$this->assertSame([MessageEffect::Review], $noConsent->effects);
|
||||
$this->assertSame([MessageEffect::Review], $off->effects);
|
||||
$this->assertSame(0, BookingTask::query()->where('booking_id', $booking->id)->count());
|
||||
}
|
||||
|
||||
public function test_the_landlord_may_only_narrow_never_widen_the_rules(): void
|
||||
{
|
||||
$rules = app(CommunicationRules::class);
|
||||
Settings::tenant()->update(['communication_rules' => [
|
||||
'media' => ['chat' => ['active' => false], 'email' => ['active' => true]],
|
||||
'effects' => ['whatsapp' => ['provide_data' => ['contribute_facts']]],
|
||||
]]);
|
||||
|
||||
$this->assertFalse($rules->mediumActive(Medium::Chat));
|
||||
$this->assertTrue($rules->mediumActive(Medium::WhatsApp));
|
||||
$this->assertSame([MessageEffect::ReportToCase, MessageEffect::Review], $rules->effects(Medium::WhatsApp, MessageIntent::ProvideData));
|
||||
|
||||
// Widening is ignored: the ceiling keeps WhatsApp off even when the tenant says "active".
|
||||
config(['communication.media.whatsapp.active' => false]);
|
||||
Settings::tenant()->update(['communication_rules' => ['media' => ['whatsapp' => ['active' => true]]]]);
|
||||
$this->assertFalse($rules->mediumActive(Medium::WhatsApp));
|
||||
}
|
||||
|
||||
private function request(): Booking
|
||||
{
|
||||
return app(CreateReservation::class)->handle($this->property->fresh(), new StayRequest(CarbonImmutable::parse('2026-11-07'), CarbonImmutable::parse('2026-11-10'), 2), ['first_name' => 'Gesa', 'last_name' => 'Gast', 'email' => 'gesa@example.org'])->fresh();
|
||||
}
|
||||
|
||||
private function receive(Medium $medium, string $text, ?int $verified = null, bool $consent = false, string $sender = '+491701234567', string $id = 'm-1'): MessageDecision
|
||||
{
|
||||
return app(MessageIntake::class)->handle(new IncomingMessage($medium, $sender, $text, CarbonImmutable::now(), $id, $verified, $consent));
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,9 @@ public function test_every_module_has_a_complete_definition(): void
|
||||
$this->assertNotSame([], $definition->modes, "{$key}: an automatic module names its modes");
|
||||
$this->assertNotSame([], $definition->triggers, "{$key}: an automatic module names its triggers");
|
||||
}
|
||||
if ($definition->toggle === ModuleDefinition::TOGGLE_MANDATORY && $definition->executions !== []) {
|
||||
$this->assertNotNull($definition->why, "{$key}: a mandatory duty states why (shown instead of a lock)");
|
||||
}
|
||||
if ($definition->isTesterOnly()) {
|
||||
$this->assertNotSame([], $definition->points, "{$key}: a tester-only module sits at an extension point");
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Filament\Resources\Channels\Pages\ChannelProcess;
|
||||
use App\Filament\Resources\Channels\Pages\ChannelProcessTest;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ProcessTestRun;
|
||||
use App\Models\Property;
|
||||
@@ -132,6 +133,39 @@ public function test_a_portal_booking_scenario_with_cancellation_report(): void
|
||||
$this->assertFalse((bool) $fewo->fresh()->is_active, 'the real channel is unchanged');
|
||||
}
|
||||
|
||||
/** V2.1: waiting for the portal's confirmation – shows the wait, the protected occupation and the escalation in the tester */
|
||||
public function test_the_portal_confirmation_scenarios_show_waiting_arrival_and_escalation(): void
|
||||
{
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'Destination Solution', 'booking_model' => 'portal_booking', 'status' => 'setup', 'is_active' => false, 'import_enabled' => false, 'settings' => ['import_url' => 'https://ds.example/a.ics', 'email_senders' => 'ds.example']]);
|
||||
$draft = ['model' => 'a3.portal_booking', 'settings' => ['await_portal_confirmation' => '1', 'booking_notice' => 'automatic']];
|
||||
|
||||
$late = app(ProcessSandbox::class)->run($portal, IntakeKind::Booking, $draft, 'portal_confirmation_wait', ['arrival' => '2026-11-14', 'nights' => 4, 'guests' => 2, 'confirmation' => 'late'], 6, $this->user)->report;
|
||||
$missing = app(ProcessSandbox::class)->run($portal, IntakeKind::Booking, $draft, 'portal_confirmation_wait', ['arrival' => '2026-11-14', 'nights' => 4, 'guests' => 2, 'confirmation' => 'missing'], 6, $this->user)->report;
|
||||
|
||||
$this->assertNull($late['aborted'] ?? null, json_encode($late));
|
||||
$known = $late['timeline'][0];
|
||||
$this->assertStringContainsString('wartet', json_encode($known['activities'], JSON_UNESCAPED_UNICODE));
|
||||
$this->assertSame([], $known['mails'], 'nothing goes out while the confirmation is missing');
|
||||
$this->assertNotEmpty(end($late['timeline'])['mails'], 'after the confirmation the booking information goes out (sandbox only)');
|
||||
$this->assertStringContainsString('ausgeblieben', json_encode(end($missing['timeline'])['activities'], JSON_UNESCAPED_UNICODE));
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
$this->assertSame(0, BookingTask::query()->count(), 'the escalation task exists only inside the sandbox');
|
||||
}
|
||||
|
||||
/** V2.1 E/F: other media and questions without a case, through the isolated tester */
|
||||
public function test_the_message_scenarios_show_assignment_and_never_create_a_case(): void
|
||||
{
|
||||
config(['communication.media.chat.active' => true, 'communication.media.whatsapp.active' => true]);
|
||||
$website = Channel::websiteOf($this->property);
|
||||
|
||||
$question = app(ProcessSandbox::class)->run($website, IntakeKind::Inquiry, ['model' => 'a1.offer'], 'general_question_message', ['text' => 'question'], 1, $this->user)->report;
|
||||
$reply = app(ProcessSandbox::class)->run($website, IntakeKind::Inquiry, ['model' => 'a1.offer'], 'message_other_medium', ['arrival' => '2026-11-07', 'nights' => 3, 'guests' => 2, 'medium' => 'whatsapp', 'reference' => 'none', 'consent' => true], 2, $this->user)->report;
|
||||
|
||||
$this->assertNull($question['aborted'] ?? null, json_encode($question));
|
||||
$this->assertNull($reply['aborted'] ?? null, json_encode($reply));
|
||||
$this->assertSame(0, Booking::query()->count());
|
||||
}
|
||||
|
||||
/** S12/T06: a failing mail server leaves the case in a defined state */
|
||||
public function test_a_mail_failure_keeps_the_case(): void
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user