From 0d51c673eb11c762e8800d2ac22a9d74273f20c4 Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 5 Nov 2026 08:17:51 +0100 Subject: [PATCH] =?UTF-8?q?V2.1:=20Erweiterungspunkt-Nachweis,=20F=C3=A4ll?= =?UTF-8?q?e=20G/H,=20Abnahmeprotokoll,=20Status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- app/Process/Models/A1OfferModel.php | 3 + app/Process/Modules/Guest/AddressCheck.php | 71 +++++++++++++++ .../Modules/Intake/PortalConfirmationStep.php | 2 +- .../Scenarios/PortalConfirmationWait.php | 2 +- config/process.php | 2 + docs/Prozessarchitektur/V2.1/ABNAHME_V2_1.md | 73 +++++++++++++++ .../ExtensionAndIndependentStepsTest.php | 88 +++++++++++++++++++ 7 files changed, 239 insertions(+), 2 deletions(-) create mode 100644 app/Process/Modules/Guest/AddressCheck.php create mode 100644 docs/Prozessarchitektur/V2.1/ABNAHME_V2_1.md create mode 100644 tests/Feature/Process/ExtensionAndIndependentStepsTest.php diff --git a/app/Process/Models/A1OfferModel.php b/app/Process/Models/A1OfferModel.php index c67a786..18c3acf 100644 --- a/app/Process/Models/A1OfferModel.php +++ b/app/Process/Models/A1OfferModel.php @@ -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'), ]; } } diff --git a/app/Process/Modules/Guest/AddressCheck.php b/app/Process/Modules/Guest/AddressCheck.php new file mode 100644 index 0000000..bca5f5e --- /dev/null +++ b/app/Process/Modules/Guest/AddressCheck.php @@ -0,0 +1,71 @@ + 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; + } +} diff --git a/app/Process/Modules/Intake/PortalConfirmationStep.php b/app/Process/Modules/Intake/PortalConfirmationStep.php index 5d17494..7e698f3 100644 --- a/app/Process/Modules/Intake/PortalConfirmationStep.php +++ b/app/Process/Modules/Intake/PortalConfirmationStep.php @@ -84,7 +84,7 @@ public function activities(CaseContext $case): array }, $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. */ + /** 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; diff --git a/app/Process/Tester/Scenarios/PortalConfirmationWait.php b/app/Process/Tester/Scenarios/PortalConfirmationWait.php index d0164a3..87e6b29 100644 --- a/app/Process/Tester/Scenarios/PortalConfirmationWait.php +++ b/app/Process/Tester/Scenarios/PortalConfirmationWait.php @@ -10,7 +10,7 @@ use Carbon\CarbonImmutable; /** - * V2.1: a booking binding at the portal is known without the portal's confirmation mail (calendar or manual entry); the + * 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. */ diff --git a/config/process.php b/config/process.php index 6685d56..f775e5f 100644 --- a/config/process.php +++ b/config/process.php @@ -1,6 +1,7 @@ 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(); + } +}