From d695566a7a558e2adc624fff603ac88b88377990 Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 4 Nov 2026 14:53:08 +0100 Subject: [PATCH] =?UTF-8?q?U-A:=20process:check/impact/fingerprint,=20Modu?= =?UTF-8?q?lmatrix,=20Modul-Vertragstest,=20O4-Aussetzung=20der=20Au=C3=9F?= =?UTF-8?q?enwirkungen=20(I-002),=20Bewertungsbitte=20je=20Kanal=20abschal?= =?UTF-8?q?tbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- app/Actions/RequestReviews.php | 7 +- app/Actions/SendBookingReminders.php | 5 +- app/Console/Commands/ProcessCheck.php | 104 ++++++++++++++++ app/Console/Commands/ProcessFingerprint.php | 34 ++++++ app/Console/Commands/ProcessImpact.php | 62 ++++++++++ .../Architektur/MODULMATRIX.md | 31 +++++ pipeline.toml | 5 +- tests/Feature/Process/ModuleContractTest.php | 109 +++++++++++++++++ .../PortalReportSuspendsAutomationTest.php | 112 ++++++++++++++++++ 9 files changed, 466 insertions(+), 3 deletions(-) create mode 100644 app/Console/Commands/ProcessCheck.php create mode 100644 app/Console/Commands/ProcessFingerprint.php create mode 100644 app/Console/Commands/ProcessImpact.php create mode 100644 docs/Prozessarchitektur/Architektur/MODULMATRIX.md create mode 100644 tests/Feature/Process/ModuleContractTest.php create mode 100644 tests/Feature/Process/PortalReportSuspendsAutomationTest.php diff --git a/app/Actions/RequestReviews.php b/app/Actions/RequestReviews.php index 399d200..77b4f0c 100644 --- a/app/Actions/RequestReviews.php +++ b/app/Actions/RequestReviews.php @@ -6,6 +6,8 @@ use App\Enums\Responsibility; use App\Mail\ReviewRequest; use App\Models\Booking; +use App\Process\OutwardSuspension; +use App\Process\ProcessPlan; use Illuminate\Support\Facades\Mail; /** @@ -27,7 +29,10 @@ public function handle(): int ->whereHas('guest', fn ($query) => $query->whereNull('anonymized_at')->whereNotNull('email')->where('email', '!=', '')) ->with('guest') ->get() - ->filter(fn (Booking $booking): bool => $booking->process()->guestMessages() === Responsibility::Landlord); + ->filter(fn (Booking $booking): bool => $booking->process()->guestMessages() === Responsibility::Landlord + // The step can be switched off per channel (Kanal › Ablauf); an open portal report holds it back (O4). + && ProcessPlan::of($booking)->enabled('review.request') + && OutwardSuspension::reason($booking) === null); foreach ($bookings as $booking) { Mail::to($booking->guest->email, $booking->guest->full_name)->send(new ReviewRequest($booking)); diff --git a/app/Actions/SendBookingReminders.php b/app/Actions/SendBookingReminders.php index e5a717d..a6ca912 100644 --- a/app/Actions/SendBookingReminders.php +++ b/app/Actions/SendBookingReminders.php @@ -9,6 +9,7 @@ use App\Mail\ArrivalInformation; use App\Models\Booking; use App\Models\BookingTask; +use App\Process\OutwardSuspension; use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Mail; @@ -63,7 +64,9 @@ public function handle(): array ->whereDate('arrival', '>=', $today) ->whereDate('arrival', '<=', $today->copy()->addDays(self::ARRIVAL_INFO_MAX_DAYS_BEFORE))) ->filter(fn (Booking $booking): bool => $booking->process()->guestMessages() === Responsibility::Landlord - && $booking->arrival->lessThanOrEqualTo($today->copy()->addDays($booking->process()->arrivalInfoDaysBefore()))); + && $booking->arrival->lessThanOrEqualTo($today->copy()->addDays($booking->process()->arrivalInfoDaysBefore())) + // Decision O4: an open portal report of a cancellation or change holds the message back until clarified. + && OutwardSuspension::reason($booking) === null); foreach ($arrivals as $booking) { Mail::to($booking->guest->email, $booking->guest->full_name)->send(new ArrivalInformation($booking)); $booking->update(['arrival_info_sent_at' => now()]); diff --git a/app/Console/Commands/ProcessCheck.php b/app/Console/Commands/ProcessCheck.php new file mode 100644 index 0000000..0d1fb3e --- /dev/null +++ b/app/Console/Commands/ProcessCheck.php @@ -0,0 +1,104 @@ +problems(); + + if ($this->option('cases')) { + $problems = [...$problems, ...$this->cases($catalogue)]; + } + + if ($this->option('matrix')) { + $path = base_path('docs/Prozessarchitektur/Architektur/MODULMATRIX.md'); + file_put_contents($path, $this->matrix($catalogue)); + $this->info('Modulmatrix geschrieben: '.$path); + } + + foreach ($problems as $problem) { + $this->error($problem); + } + if ($problems === []) { + $this->info(count($catalogue->modules()).' Module, '.count($catalogue->modelVersions()).' Modelle: ohne Befund.'); + } + + return $problems === [] ? self::SUCCESS : self::FAILURE; + } + + /** + * @return list + */ + private function cases(ProcessCatalogue $catalogue): array + { + $problems = []; + Booking::withoutGlobalScopes()->select(['id', 'reference', 'profile', 'status'])->whereNotNull('profile')->lazyById()->each(function (Booking $booking) use ($catalogue, &$problems): void { + $plan = (array) (($booking->profile ?? [])['plan'] ?? []); + if ($plan === []) { + return; + } + $frozen = ProcessPlan::fromArray($plan); + if (! $catalogue->hasModel($frozen->model)) { + $problems[] = "Vorgang {$booking->reference}: Modell {$frozen->model} ist nicht mehr registriert."; + } elseif (! $catalogue->hasModel($frozen->model, $frozen->modelVersion)) { + $problems[] = "Vorgang {$booking->reference}: Modellversion {$frozen->reference()} fehlt im Register (T3: Versionen nicht entfernen, solange Vorgänge sie tragen)."; + } + foreach ($frozen->modules as $key => $version) { + if (! $catalogue->serves($key, $version) && ! in_array($booking->status, [BookingStatus::Cancelled, BookingStatus::Declined, BookingStatus::Expired, BookingStatus::Completed], true)) { + $problems[] = "Offener Vorgang {$booking->reference}: Modul {$key}@{$version} wird nicht mehr bedient."; + } + } + }); + + return $problems; + } + + private function matrix(ProcessCatalogue $catalogue): string + { + $models = $catalogue->models(); + $lines = [ + '# Modulmatrix (erzeugt)', + '', + 'Erzeugt von `php artisan process:check --matrix` aus `config/process.php` – nicht von Hand ändern. Spalten: Modelle (Standardablauf; `V` = nur in einer Variante).', + '', + '| Modul | Version | Phase | Aktivierung | Verfügbarkeit | hart abhängig von | '.implode(' | ', array_keys($models)).' | Testgruppe |', + '|'.str_repeat('---|', 7 + count($models)), + ]; + foreach ($catalogue->modules() as $key => $class) { + $definition = $class::definition(); + $cells = array_map(function ($model) use ($key): string { + if (in_array($key, $model->modules('standard'), true)) { + return '●'; + } + foreach ($model->variants() as $variant) { + if (in_array($key, $model->modules($variant->key), true)) { + return 'V'; + } + } + + return ''; + }, $models); + $hard = implode(', ', array_map(fn ($dependency): string => $dependency->module, array_filter($definition->requires, fn ($dependency): bool => $dependency->hard))); + $lines[] = "| `{$key}` | {$class::version()} | {$definition->phase} | {$definition->toggle} | {$definition->availability} | {$hard} | ".implode(' | ', $cells)." | `module:{$key}` |"; + } + + return implode("\n", $lines)."\n"; + } +} diff --git a/app/Console/Commands/ProcessFingerprint.php b/app/Console/Commands/ProcessFingerprint.php new file mode 100644 index 0000000..7b4cc93 --- /dev/null +++ b/app/Console/Commands/ProcessFingerprint.php @@ -0,0 +1,34 @@ + md5($query->get()->map(fn (object $row): string => (string) json_encode($row))->implode("\n")); + + $this->line((string) json_encode([ + 'bookings' => DB::table('bookings')->count(), + 'channels' => DB::table('channels')->count(), + 'blocked_periods' => DB::table('blocked_periods')->count(), + 'h_bookings' => $hash(DB::table('bookings')->orderBy('id')->select('id', 'status', 'profile', 'total', 'quote', 'offer_terms', 'acceptance', 'arrival', 'departure', 'hold_expires_at', 'deposit_due_on', 'balance_due_on')), + 'h_overrides' => $hash(DB::table('channels')->orderBy('id')->select('id', 'process_overrides', 'booking_model', 'case_intake')), + 'h_blocks' => $hash(DB::table('blocked_periods')->orderBy('id')->select('id', 'starts_on', 'ends_on', 'source', 'channel_id', 'linked_booking_id', 'deleted_at')), + ], JSON_PRETTY_PRINT)); + + return self::SUCCESS; + } +} diff --git a/app/Console/Commands/ProcessImpact.php b/app/Console/Commands/ProcessImpact.php new file mode 100644 index 0000000..eff6797 --- /dev/null +++ b/app/Console/Commands/ProcessImpact.php @@ -0,0 +1,62 @@ +argument('module'); + if (! $catalogue->hasModule($key)) { + $this->error("Unbekanntes Modul {$key}. Registriert: ".implode(', ', array_keys($catalogue->modules()))); + + return self::FAILURE; + } + + $class = $catalogue->modules()[$key]; + $definition = $class::definition(); + $uses = []; + foreach ($catalogue->models() as $modelKey => $model) { + foreach ($model->variants() as $variant) { + if (in_array($key, $model->modules($variant->key), true)) { + $uses[] = $modelKey.($variant->key === 'standard' ? '' : ':'.$variant->key).' ('.implode('/', array_map(fn ($type): string => strtoupper($type->value), $model::caseTypes())).')'; + } + } + } + $dependents = array_keys(array_filter($catalogue->modules(), fn (string $other): bool => collect($other::definition()->requires)->contains(fn ($dependency): bool => $dependency->module === $key))); + $modelKeys = array_map(fn (string $use): string => explode(' ', explode(':', $use)[0])[0], $uses); + $channels = Channel::withoutGlobalScopes()->get(['process_overrides'])->filter(fn (Channel $channel): bool => collect((array) $channel->process_overrides)->contains(fn ($config): bool => in_array($config['model'] ?? null, $modelKeys, true)))->count(); + + $this->table(['', $key.' v'.$class::version()], [ + ['Aufgabe', $definition->purpose], + ['Phase / Aktivierung', $definition->phase.' / '.$definition->toggle.' / '.$definition->availability], + ['Modelle', implode(', ', $uses) ?: '–'], + ['Erweiterungspunkte', implode(', ', $definition->points) ?: 'fester Platz im Modell'], + ['Benötigt', implode(', ', array_map(fn ($dependency): string => $dependency->module.($dependency->hard ? ' (hart)' : ' (weich)'), $definition->requires)) ?: '–'], + ['Benötigt von', implode(', ', $dependents) ?: '–'], + ['Läuft automatisch', is_subclass_of($class, RunsAutomatically::class) ? 'ja, Auslöser: '.implode(', ', $definition->triggers) : 'nein'], + ['Preisbeitrag', is_subclass_of($class, ContributesToPrice::class) ? 'ja (CasePricing, nur vor Verbindlichkeit)' : 'nein'], + ['Wertet Vertragsdaten aus', $definition->readsContractData ? 'ja – Bestandsfall-Test Pflicht (--group=ongoing)' : 'nein'], + ['Parameter', implode(', ', array_map(fn ($parameter): string => is_string($parameter) ? $parameter : $parameter->value, $definition->parameters)) ?: '–'], + ['Kanäle mit gewähltem Modell', (string) $channels], + ['Tests', "--group=module:{$key} --group=golden --group=ongoing --group=runner"], + ]); + + return self::SUCCESS; + } +} diff --git a/docs/Prozessarchitektur/Architektur/MODULMATRIX.md b/docs/Prozessarchitektur/Architektur/MODULMATRIX.md new file mode 100644 index 0000000..c243b02 --- /dev/null +++ b/docs/Prozessarchitektur/Architektur/MODULMATRIX.md @@ -0,0 +1,31 @@ +# Modulmatrix (erzeugt) + +Erzeugt von `php artisan process:check --matrix` aus `config/process.php` – nicht von Hand ändern. Spalten: Modelle (Standardablauf; `V` = nur in einer Variante). + +| Modul | Version | Phase | Aktivierung | Verfügbarkeit | hart abhängig von | a1.offer | a1.information | a2.offer | a2.information | a3.portal_booking | a4.portal_booking | a5.portal_booking | a6.internal | Testgruppe | +|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---| +| `intake.record` | 1 | P01 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:intake.record` | +| `guest.details` | 1 | P01 | mandatory | production | intake.record | ● | ● | ● | ● | ● | ● | ● | | `module:guest.details` | +| `guest.data_request` | 1 | P01 | optional | production | intake.record | ● | ● | ● | ● | ● | ● | ● | | `module:guest.data_request` | +| `hold` | 1 | P01 | conditional | production | intake.record | ● | ● | ● | ● | | | | | `module:hold` | +| `availability.check` | 1 | P01 | mandatory | production | | ● | ● | ● | ● | | | | | `module:availability.check` | +| `binding.portal` | 1 | P02 | mandatory | production | intake.record | | | | | ● | ● | ● | | `module:binding.portal` | +| `channels.block` | 1 | P02 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:channels.block` | +| `offer.information` | 1 | P02 | mandatory | production | intake.record | ● | ● | ● | ● | | | | | `module:offer.information` | +| `offer.binding` | 2 | P02 | mandatory | production | guest.details, availability.check | ● | ● | ● | ● | | | | | `module:offer.binding` | +| `offer.acceptance` | 1 | P02 | mandatory | production | offer.binding | ● | ● | ● | ● | | | | | `module:offer.acceptance` | +| `documents.send` | 1 | P03 | mandatory | production | guest.details | ● | ● | ● | ● | ● | ● | ● | | `module:documents.send` | +| `documents.stay_confirmation` | 1 | P03 | optional | production | | | | | | | | | ● | `module:documents.stay_confirmation` | +| `case.tasks` | 1 | P03 | event_driven | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.tasks` | +| `change.proposal` | 1 | P03 | event_driven | production | | ● | ● | ● | ● | ● | ● | ● | | `module:change.proposal` | +| `case.closure` | 1 | P05 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.closure` | +| `case.settlement` | 1 | P05 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:case.settlement` | +| `payments.monitor` | 1 | P03 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | `module:payments.monitor` | +| `portal.payout` | 1 | P03 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | `module:portal.payout` | +| `payments.internal` | 1 | P03 | conditional | production | | | | | | | | | ● | `module:payments.internal` | +| `arrival.details` | 1 | P04 | optional | production | | ● | ● | ● | ● | ● | ● | ● | | `module:arrival.details` | +| `arrival.info` | 1 | P04 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | | `module:arrival.info` | +| `stay` | 1 | P04 | mandatory | production | | ● | ● | ● | ● | ● | ● | ● | ● | `module:stay` | +| `review.request` | 1 | P05 | optional | production | stay | ● | ● | ● | ● | ● | ● | ● | | `module:review.request` | +| `guest.loyalty_status` | 1 | P01 | optional | tester_only | guest.details | V | | | | | | | | `module:guest.loyalty_status` | +| `pricing.loyalty_discount` | 1 | P02 | optional | tester_only | guest.loyalty_status | V | | | | | | | | `module:pricing.loyalty_discount` | diff --git a/pipeline.toml b/pipeline.toml index 1a44a3c..60dfe37 100644 --- a/pipeline.toml +++ b/pipeline.toml @@ -10,7 +10,10 @@ prepare = [ ["php", "-r", "copy('.env.example', '.env');"], ["php", "artisan", "key:generate", "--no-interaction"], ] -test = [["php", "-d", "memory_limit=512M", "vendor/bin/phpunit", "--testsuite=Feature", "--no-progress"]] +test = [ + ["php", "artisan", "process:check", "--no-interaction"], + ["php", "-d", "memory_limit=512M", "vendor/bin/phpunit", "--testsuite=Feature", "--no-progress"], +] finalize = [ ["composer", "install", "--no-dev", "--prefer-dist", "--optimize-autoloader", "--no-interaction", "--no-progress"], ["php", "artisan", "optimize:clear", "--no-interaction"], diff --git a/tests/Feature/Process/ModuleContractTest.php b/tests/Feature/Process/ModuleContractTest.php new file mode 100644 index 0000000..e81454e --- /dev/null +++ b/tests/Feature/Process/ModuleContractTest.php @@ -0,0 +1,109 @@ +modules() as $key => $class) { + $definition = $class::definition(); + $this->assertMatchesRegularExpression('/^[a-z0-9_]+(\.[a-z0-9_]+)*$/', $key); + $this->assertNotSame('', trim($definition->label), "{$key}: label"); + $this->assertNotSame('', trim($definition->purpose), "{$key}: purpose"); + $this->assertContains($definition->phase, $phases, "{$key}: phase"); + $this->assertContains($definition->toggle, $toggles, "{$key}: toggle"); + $this->assertSame([], array_diff($definition->effects, $effects), "{$key}: unknown effect kinds"); + $this->assertGreaterThanOrEqual(1, $class::version()); + foreach ($definition->parameters as $parameter) { + $this->assertTrue($parameter instanceof ProcessSetting || (is_string($parameter) && $parameter !== ''), "{$key}: parameter"); + } + if (is_subclass_of($class, RunsAutomatically::class)) { + $this->assertNotSame([], $definition->modes, "{$key}: an automatic module names its modes"); + $this->assertNotSame([], $definition->triggers, "{$key}: an automatic module names its triggers"); + } + if ($definition->isTesterOnly()) { + $this->assertNotSame([], $definition->points, "{$key}: a tester-only module sits at an extension point"); + } + } + } + + public function test_reading_methods_never_write(): void + { + $this->travelTo(CarbonImmutable::parse('2026-10-23 10:00')); + $this->seed(PropertySeeder::class); + $property = Property::sole(); + $portal = Channel::factory()->for($property)->create(['booking_model' => 'portal_booking', 'process_overrides' => ['booking' => ['payments' => 'portal']]]); + $cases = []; + foreach ([BookingStatus::Reserved, BookingStatus::OfferSent, BookingStatus::Confirmed, BookingStatus::Completed, BookingStatus::Cancelled] as $index => $status) { + $cases[] = Booking::factory()->for($property)->create(['status' => $status, 'intake' => 'inquiry', 'arrival' => now()->addDays(40 + $index * 10)->toDateString(), 'departure' => now()->addDays(44 + $index * 10)->toDateString(), 'hold_expires_at' => now()->addDay()]); + $cases[] = Booking::factory()->for($property)->create(['status' => $status === BookingStatus::Reserved ? BookingStatus::Confirmed : $status, 'intake' => 'booking', 'import_channel_id' => $portal->id, 'origin_channel_id' => $portal->id, 'arrival' => now()->addDays(100 + $index * 10)->toDateString(), 'departure' => now()->addDays(104 + $index * 10)->toDateString()]); + } + $catalogue = app(ProcessCatalogue::class); + + $writes = []; + DB::listen(function (QueryExecuted $query) use (&$writes): void { + if (preg_match('/^\s*(insert|update|delete|replace)\b/i', $query->sql) === 1) { + $writes[] = $query->sql; + } + }); + + foreach ($cases as $booking) { + $booking = $booking->fresh(); + // Every module against every case: also modules of other models must read without side effects. + $plan = new ProcessPlan('a1.offer', 1, 'loyalty', array_map(fn (string $class): int => $class::version(), $catalogue->modules()), [], ProcessPlan::TESTER); + $context = new CaseContext($booking, $plan); + foreach (array_keys($catalogue->modules()) as $key) { + $module = $catalogue->module($key); + $module->applies($context); + $module->activities($context); + $module->state($context); + if ($module instanceof RunsAutomatically) { + $module->due($context); + $module->blockers($context); + $module->isOutward(); + } + if ($module instanceof ContributesToPrice && $booking->arrival->lessThan(now()->addDays(55))) { + $module->priceLines($context, app(PriceCalculator::class)->calculate($property, new StayRequest($booking->arrival, $booking->departure, 2))); + } + } + } + + $this->assertSame([], $writes, 'reading methods of modules must not write'); + } +} diff --git a/tests/Feature/Process/PortalReportSuspendsAutomationTest.php b/tests/Feature/Process/PortalReportSuspendsAutomationTest.php new file mode 100644 index 0000000..ade5b6f --- /dev/null +++ b/tests/Feature/Process/PortalReportSuspendsAutomationTest.php @@ -0,0 +1,112 @@ +travelTo(CarbonImmutable::parse('2026-10-23 18:00')); + $this->seed([PropertySeeder::class, SiteSeeder::class]); + $this->property = Property::sole(); + Storage::fake('local'); + Content::save(['contract.terms' => '

Echte Bedingungen

', 'stay.cancellation' => '

Echtes Storno

']); + config(['mail.default' => 'array']); + Mail::swap(new MailManager($this->app)); + Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051', 'test_recipient' => 'test@example.org', 'process_defaults' => ['processing' => 'automatic']]); + Http::preventStrayRequests(); + $this->portal = Channel::factory()->for($this->property)->create(['name' => 'Destination Solutions', 'booking_model' => 'portal_booking', 'import_enabled' => false, 'settings' => ['import_url' => 'https://ds.example/a.ics', 'email_senders' => 'ds.example']]); + } + + public function test_documents_wait_while_a_cancellation_report_is_open_and_go_after_clarification(): void + { + $booking = app(TakeOverExternalBooking::class)->handle($this->property, $this->portal, CarbonImmutable::parse('2026-12-05'), CarbonImmutable::parse('2026-12-12'), ['portal_reference' => 'DS-9', 'portal_total' => 98000, 'guests' => 2]); + $task = $this->report($booking); + + app(ContributeCaseFacts::class)->handle($booking->fresh(), ['guest.first_name' => 'Dora', 'guest.last_name' => 'Gast', 'guest.email' => 'dora@example.org'], FactSource::PortalMail); + + $booking->refresh(); + $this->assertNull($booking->confirmation_sent_at, 'no documents while the report is open'); + $this->assertSame(BookingStatus::Confirmed, $booking->status, 'the report never changes the booking'); + $held = app(CaseAutomation::class)->advance($booking->fresh()); + $this->assertSame([OutwardSuspension::reason($booking)], $held, 'the documents wait only for the clarification'); + + $task->update(['status' => BookingTaskStatus::Done, 'completed_at' => now(), 'note' => 'Portal bestätigt: keine Stornierung']); + $held = app(CaseAutomation::class)->advance($booking->fresh()); + + // After clarification the step is evaluated from the case's current state again: here the documents' own + // release rules (portal template, released texts) decide, no longer the report. + $this->assertNotContains(OutwardSuspension::reason($booking), $held); + $this->assertStringContainsString('Arbeitsfassung', implode(' ', $held)); + } + + public function test_arrival_information_waits_but_internal_tasks_go_on(): void + { + $booking = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => now()->addDays(2)->toDateString(), 'departure' => now()->addDays(6)->toDateString(), 'deposit_due_on' => now()->subDay()->toDateString(), 'confirmed_at' => now()]); + $this->report($booking); + + app(SendBookingReminders::class)->handle(); + + $this->assertNull($booking->fresh()->arrival_info_sent_at); + $this->assertTrue(BookingTask::query()->where('booking_id', $booking->id)->where('kind', BookingTaskKind::DepositReminder)->exists(), 'internal tasks are not blocked'); + } + + public function test_an_unassigned_portal_mail_suspends_nothing(): void + { + $booking = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => now()->addDays(2)->toDateString(), 'departure' => now()->addDays(6)->toDateString(), 'confirmed_at' => now()]); + + app(ProcessPortalMail::class)->handle(new PortalMail('', 'noreply@ds.example', 'Buchung storniert: UNBEKANNT-1', 'Die Buchung vom 01.03.2027 bis 05.03.2027 wurde storniert.', CarbonImmutable::now())); + app(SendBookingReminders::class)->handle(); + + $this->assertNull(OutwardSuspension::reason($booking)); + $this->assertNotNull($booking->fresh()->arrival_info_sent_at); + } + + private function report(Booking $booking): BookingTask + { + return BookingTask::query()->create(['booking_id' => $booking->id, 'kind' => BookingTaskKind::PortalCancellationReported, 'status' => BookingTaskStatus::Open, 'title' => 'Portal meldet Stornierung']); + } +}