Vorgangskern und geführte Vorgangsbearbeitung (Pakete 1 und 2, Prozessarchitektur v0.10)
- Buchung ist der einheitliche Vorgang: Eingangsart, Vorgangsart A1–A6, eingefrorenes Abwicklungsprofil, gespeicherter Verlauf (booking_events); Gast, Personen und Beträge dürfen unbekannt sein, Platzhalter-Gäste werden migriert und nicht mehr angelegt - Einstellungen in Ebenen: Vermieterstandard (So arbeite ich), Abweichung der Wohnung (Experte), Abweichung je Portal und Eingangsart; ersetzt booking_model als Steuergröße - Ein Weg für extern verbindliche Buchungen (TakeOverExternalBooking) statt RecordPortalBooking und "Akte anlegen"; Portalpreis als belegte Gesamtposition - Startseite "Zu erledigen", neue Vorgangsseite mit nächstem Schritt, Automatik-Schalter, "Beenden" mit Storno statt Statusumschaltung; Status von Hand nur im Expertenmodus - Migration übernimmt bisheriges Verhalten unverändert (abweichende Wohnungswerte bleiben als Abweichung), Bericht: php artisan process:settings-report Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9005c12164
commit
3a728c3255
78 files changed
+4296
-1180
No files matched your search
@@ -36,9 +36,10 @@ public function test_rentals_staff_starts_in_the_simple_mode_with_the_daily_menu
|
||||
$this->assertSame(AdminMode::Simple, $user->adminMode());
|
||||
$this->get(Dashboard::getUrl())
|
||||
->assertOk()
|
||||
->assertSee('Anfragen & Buchungen', false)
|
||||
->assertSee('Vorgänge')
|
||||
->assertSee('Sperrzeiten')
|
||||
->assertSee('Portal-Aufgaben')
|
||||
->assertSee('Zu erledigen')
|
||||
->assertDontSee('Portal-Aufgaben')
|
||||
->assertSee('Verwaltung')
|
||||
->assertDontSee('Kalenderabgleich')
|
||||
->assertDontSee('Vertragsvorlagen')
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Actions\SendOffer;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\OfferMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Mail\NewReservation;
|
||||
use App\Mail\OfferMade;
|
||||
@@ -86,7 +85,7 @@ public function test_automatic_offer_can_be_accepted_end_to_end(): void
|
||||
|
||||
public function test_without_pre_reservation_a_request_blocks_nothing(): void
|
||||
{
|
||||
$this->property->update(['pre_reservation_enabled' => false]);
|
||||
Settings::tenant()->update(['process_defaults' => ['pre_reservation' => false]]);
|
||||
|
||||
$first = $this->request();
|
||||
$second = $this->request('other@example.org');
|
||||
@@ -100,7 +99,7 @@ public function test_without_pre_reservation_a_request_blocks_nothing(): void
|
||||
|
||||
public function test_automatic_mode_without_pre_reservation_falls_back_to_manual_and_says_why(): void
|
||||
{
|
||||
$this->property->update(['offer_mode' => OfferMode::Automatic, 'pre_reservation_enabled' => false]);
|
||||
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic', 'pre_reservation' => false]]);
|
||||
|
||||
$booking = $this->request();
|
||||
|
||||
@@ -205,7 +204,7 @@ public function test_live_operation_needs_released_contract_texts_for_automatic_
|
||||
|
||||
private function automatic(): void
|
||||
{
|
||||
$this->property->update(['offer_mode' => OfferMode::Automatic]);
|
||||
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic']]);
|
||||
}
|
||||
|
||||
private function request(string $email = 'gast@example.org', string $arrival = '2026-11-07', string $departure = '2026-11-10'): Booking
|
||||
|
||||
@@ -70,7 +70,7 @@ public function test_landlord_declines_without_notifying_the_guest(): void
|
||||
$booking = Booking::factory()->for($this->property)->reserved()->create();
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->callAction('decline', ['notify' => false]);
|
||||
->callAction('end', ['reason' => 'Zeitraum passt nicht', 'notify' => false]);
|
||||
|
||||
$this->assertSame(BookingStatus::Declined, $booking->fresh()->status);
|
||||
Mail::assertNotSent(BookingDeclined::class);
|
||||
@@ -123,7 +123,7 @@ public function test_phone_booking_for_occupied_dates_is_refused(): void
|
||||
'email' => 'peter@example.com',
|
||||
])
|
||||
->call('create')
|
||||
->assertNotified('Buchung nicht möglich');
|
||||
->assertNotified('Nicht möglich');
|
||||
|
||||
$this->assertSame(1, Booking::count());
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
use App\Actions\CancelBooking;
|
||||
use App\Actions\SendOffer;
|
||||
use App\Enums\ActivityState;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\CaseType;
|
||||
use App\Filament\Resources\Bookings\Pages\ListBookings;
|
||||
use App\Filament\Resources\Bookings\Pages\ViewBooking;
|
||||
use App\Filament\Resources\Bookings\RelationManagers\MessagesRelationManager;
|
||||
@@ -18,12 +20,11 @@
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Support\BookingProgress;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -53,31 +54,33 @@ protected function setUp(): void
|
||||
public function test_next_step_follows_the_state_of_the_booking(): void
|
||||
{
|
||||
$request = Booking::factory()->for($this->property)->reserved(now()->addHours(48))->create(['arrival' => '2026-11-07', 'departure' => '2026-11-10']);
|
||||
$this->assertSame('Anfrage prüfen', BookingProgress::next($request)['title']);
|
||||
$this->assertSame('sendOffer', CaseActivities::next($request)?->action);
|
||||
|
||||
Mail::fake();
|
||||
$offer = app(SendOffer::class)->handle($request);
|
||||
$this->assertSame('Wartet auf den Gast', BookingProgress::next($offer)['title']);
|
||||
$this->assertNull(CaseActivities::next($offer));
|
||||
$this->assertStringContainsString('Angebot liegt beim Gast', CaseActivities::situation($offer));
|
||||
|
||||
$confirmed = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => '2026-12-01', 'departure' => '2026-12-05', 'deposit_due_on' => '2026-10-25', 'balance_due_on' => '2026-11-20', 'total' => 100000, 'deposit' => 30000]);
|
||||
$this->assertSame('Anzahlung offen', BookingProgress::next($confirmed)['title']);
|
||||
$this->assertSame('resendConfirmation', CaseActivities::next($confirmed)?->action);
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-12-02 12:00'));
|
||||
$confirmed->update(['status' => BookingStatus::Paid, 'total' => 0, 'deposit' => 0]);
|
||||
$this->assertSame('Gast ist vor Ort', BookingProgress::next($confirmed->fresh())['title']);
|
||||
$this->assertContains('current', array_column(BookingProgress::steps($confirmed->fresh()), 'state'));
|
||||
$this->assertStringContainsString('Gast ist vor Ort', CaseActivities::situation($confirmed->fresh()));
|
||||
$this->assertSame(ActivityState::Waiting, collect(CaseActivities::for($confirmed->fresh()))->firstWhere('key', 'stay')->state);
|
||||
}
|
||||
|
||||
public function test_portal_booking_is_recognised_without_payment_steps_and_asks_to_send_the_contract(): void
|
||||
{
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'FeWo-direkt', 'booking_model' => 'portal_booking']);
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'FeWo-direkt', 'booking_model' => 'portal_booking', 'process_overrides' => ['booking' => ['payments' => 'portal']]]);
|
||||
$booking = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'import_channel_id' => $portal->id, 'source' => 'portal', 'arrival' => '2026-12-01', 'departure' => '2026-12-05']);
|
||||
|
||||
$this->assertSame(BookingProgress::PORTAL_BOOKING, BookingProgress::kind($booking));
|
||||
$this->assertStringContainsString('FeWo-direkt', BookingProgress::kindLabel($booking));
|
||||
$this->assertSame('Vertrag senden', BookingProgress::next($booking)['title']);
|
||||
$this->assertContains('Zahlung', array_column(BookingProgress::steps($booking), 'label'));
|
||||
$this->assertNotContains('Anzahlung', array_column(BookingProgress::steps($booking), 'label'));
|
||||
$this->assertSame(CaseType::A4, $booking->caseType());
|
||||
$this->assertStringContainsString('Gebucht über FeWo-direkt', CaseActivities::situation($booking));
|
||||
$this->assertSame('resendConfirmation', CaseActivities::next($booking)?->action);
|
||||
$keys = array_map(fn ($activity) => $activity->key, CaseActivities::for($booking));
|
||||
$this->assertContains('payment', $keys);
|
||||
$this->assertNotContains('deposit', $keys);
|
||||
}
|
||||
|
||||
public function test_every_booking_mail_lands_in_the_communication_log_with_its_audience(): void
|
||||
@@ -121,7 +124,7 @@ public function test_cancellation_without_guest_mail_and_the_admin_action_offer_
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->callAction(TestAction::make('cancel')->arguments([]), ['notify_guest' => false, 'costs_task' => false])
|
||||
->callAction('end', ['initiated_by' => 'landlord', 'reason' => 'Wasserschaden', 'notify' => false, 'costs_task' => false])
|
||||
->assertNotified('Buchung storniert');
|
||||
|
||||
Mail::assertNotSent(BookingCancelled::class);
|
||||
@@ -149,9 +152,9 @@ public function test_the_booking_page_shows_process_contract_tasks_and_mail_log(
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->assertSee('Nächster Schritt: Wartet auf den Gast')
|
||||
->assertSee('Vertrag')
|
||||
->assertSee('Angebot (PDF) Version 1');
|
||||
->assertSee('Angebot liegt beim Gast')
|
||||
->assertSee('Gast nimmt das Angebot an')
|
||||
->assertSee('Angebot Version 1');
|
||||
|
||||
Livewire::test(MessagesRelationManager::class, ['ownerRecord' => $booking, 'pageClass' => ViewBooking::class])->assertSuccessful();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use App\Models\ContractTemplate;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Support\BookingProgress;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Support\CancellationCost;
|
||||
use App\Support\SelfServiceLinks;
|
||||
use Carbon\CarbonImmutable;
|
||||
@@ -109,7 +109,7 @@ public function test_cancelling_records_the_cancellation_with_the_proposed_cost_
|
||||
$this->assertSame(CancellationCost::rent($booking), $record->base_amount);
|
||||
$this->assertSame($record->calculated_fee, $record->fee());
|
||||
$this->assertStringContainsString('Vorschlag nach Stornoregel', BookingTask::query()->where('kind', BookingTaskKind::CancellationFee)->sole()->note);
|
||||
$this->assertStringContainsString('Stornokosten', BookingProgress::next($booking->fresh())['text']);
|
||||
$this->assertStringContainsString('Stornokosten', CaseActivities::next($booking->fresh())?->label);
|
||||
}
|
||||
|
||||
public function test_guest_link_is_instant_only_while_the_rule_makes_it_free_and_shows_the_cost(): void
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Actions\SendOffer;
|
||||
use App\Actions\TakeOverExternalBooking;
|
||||
use App\Documents\OfferTerms;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Enums\ProcessSetting;
|
||||
use App\Enums\Responsibility;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingEvent;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ContractTemplate;
|
||||
use App\Models\Guest;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Process\ProcessSettings;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Package 1 of UMSETZUNGSPLAN_v0.10: one case for every occasion, unknown stays unknown, settings in levels
|
||||
* (landlord → property → channel per intake kind → case), the profile frozen per case and a stored history.
|
||||
*/
|
||||
class CaseCoreTest 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, SiteSeeder::class]);
|
||||
$this->property = Property::sole();
|
||||
Mail::fake();
|
||||
Storage::fake('local');
|
||||
}
|
||||
|
||||
/** 1.2 */
|
||||
public function test_a_portal_booking_without_guest_data_stays_unknown_instead_of_getting_a_placeholder(): void
|
||||
{
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'FeWo-direkt', 'booking_model' => 'portal_booking']);
|
||||
$guestsBefore = Guest::query()->count();
|
||||
|
||||
$booking = app(TakeOverExternalBooking::class)->handle($this->property, $portal, CarbonImmutable::parse('2026-12-01'), CarbonImmutable::parse('2026-12-05'), ['portal_reference' => 'HA-1']);
|
||||
|
||||
$this->assertSame(BookingStatus::Confirmed, $booking->status);
|
||||
$this->assertNull($booking->guest_id);
|
||||
$this->assertNull($booking->guests);
|
||||
$this->assertNull($booking->total);
|
||||
$this->assertNull($booking->quote);
|
||||
$this->assertSame('Gast noch nicht bekannt', $booking->guestName());
|
||||
$this->assertSame($guestsBefore, Guest::query()->count());
|
||||
$this->assertSame(IntakeKind::Booking, $booking->intake);
|
||||
$this->assertSame(CaseType::A3, $booking->case_type);
|
||||
$this->assertSame(0, $booking->openAmount());
|
||||
$this->assertFalse($booking->wantsPaymentTasks());
|
||||
}
|
||||
|
||||
public function test_a_known_portal_price_is_taken_over_as_one_line_and_never_split(): void
|
||||
{
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'FeWo-direkt', 'booking_model' => 'portal_booking']);
|
||||
|
||||
$booking = app(TakeOverExternalBooking::class)->handle($this->property, $portal, CarbonImmutable::parse('2026-12-01'), CarbonImmutable::parse('2026-12-05'), ['portal_total' => 97951, 'guests' => 2]);
|
||||
|
||||
$this->assertSame(97951, $booking->total);
|
||||
$this->assertCount(1, $booking->quote['lines']);
|
||||
$this->assertSame(97951, $booking->quote['lines'][0]['amount']);
|
||||
$this->assertStringContainsString('laut Portal', $booking->quote['lines'][0]['label']);
|
||||
}
|
||||
|
||||
/** 1.3 */
|
||||
public function test_landlord_defaults_apply_to_a_new_request(): void
|
||||
{
|
||||
Settings::tenant()->update(['process_defaults' => ['hold_hours' => 24, 'processing' => 'manual']]);
|
||||
|
||||
$booking = $this->request();
|
||||
|
||||
$this->assertSame(BookingStatus::Reserved, $booking->status);
|
||||
$this->assertTrue($booking->hold_expires_at->equalTo(now()->addHours(24)));
|
||||
$this->assertSame(ProcessingMode::Manual, $booking->processingMode());
|
||||
$this->assertSame(CaseType::A1, $booking->case_type);
|
||||
}
|
||||
|
||||
/** 1.4 */
|
||||
public function test_a_channel_value_that_is_not_set_inherits_and_a_set_value_wins_even_when_it_is_no(): void
|
||||
{
|
||||
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic', 'pre_reservation' => true]]);
|
||||
$inherits = Channel::factory()->for($this->property)->create(['booking_model' => 'inquiry', 'process_overrides' => ['inquiry' => ['processing' => null]]]);
|
||||
$deviates = Channel::factory()->for($this->property)->create(['booking_model' => 'inquiry', 'process_overrides' => ['inquiry' => ['processing' => 'manual', 'pre_reservation' => '0']]]);
|
||||
$settings = app(ProcessSettings::class);
|
||||
|
||||
$inherited = $settings->resolve($this->property, $inherits, IntakeKind::Inquiry);
|
||||
$deviated = $settings->resolve($this->property, $deviates, IntakeKind::Inquiry);
|
||||
|
||||
$this->assertSame(ProcessingMode::Automatic, $inherited->processing());
|
||||
$this->assertTrue($inherited->preReservation());
|
||||
$this->assertSame('tenant', $inherited->source(ProcessSetting::Processing));
|
||||
$this->assertSame(ProcessingMode::Manual, $deviated->processing());
|
||||
$this->assertFalse($deviated->preReservation());
|
||||
$this->assertSame('channel', $deviated->source(ProcessSetting::PreReservation));
|
||||
}
|
||||
|
||||
public function test_a_property_deviation_sits_between_landlord_default_and_channel(): void
|
||||
{
|
||||
Settings::tenant()->update(['process_defaults' => ['hold_hours' => 48]]);
|
||||
$this->property->update(['process_overrides' => ['hold_hours' => 12]]);
|
||||
|
||||
$this->assertSame(12, app(ProcessSettings::class)->resolve($this->property->fresh(), null, IntakeKind::Inquiry)->holdHours());
|
||||
}
|
||||
|
||||
/** 1.5 */
|
||||
public function test_one_mixed_portal_handles_requests_and_bindings_differently(): void
|
||||
{
|
||||
$inquiryTemplate = ContractTemplate::query()->create(['name' => 'Anfrage', 'terms' => '<p>A</p>']);
|
||||
$bookingTemplate = ContractTemplate::query()->create(['name' => 'Portalbuchung', 'terms' => '<p>B</p>']);
|
||||
$portal = Channel::factory()->for($this->property)->create(['booking_model' => 'mixed', 'process_overrides' => [
|
||||
'inquiry' => ['contract_template_id' => $inquiryTemplate->id],
|
||||
'booking' => ['contract_template_id' => $bookingTemplate->id, 'payments' => 'portal'],
|
||||
]]);
|
||||
|
||||
$request = $this->request(channel: $portal);
|
||||
$binding = app(TakeOverExternalBooking::class)->handle($this->property, $portal, CarbonImmutable::parse('2026-12-10'), CarbonImmutable::parse('2026-12-14'));
|
||||
|
||||
$this->assertSame(CaseType::A2, $request->case_type);
|
||||
$this->assertSame(CaseType::A4, $binding->case_type);
|
||||
$this->assertSame('Anfrage', OfferTerms::templateFor($request)?->name);
|
||||
$this->assertSame('Portalbuchung', OfferTerms::templateFor($binding)?->name);
|
||||
$this->assertSame(Responsibility::Landlord, $request->process()->payments());
|
||||
$this->assertSame(Responsibility::Portal, $binding->process()->payments());
|
||||
}
|
||||
|
||||
/** 1.6 */
|
||||
public function test_the_profile_is_frozen_with_the_case(): void
|
||||
{
|
||||
$before = $this->request();
|
||||
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic', 'hold_hours' => 72]]);
|
||||
$after = $this->request('zweite@example.org', '2026-12-01', '2026-12-04');
|
||||
|
||||
$this->assertSame(ProcessingMode::Manual, $before->fresh()->processingMode());
|
||||
$this->assertSame(48, $before->fresh()->process()->holdHours());
|
||||
$this->assertSame(72, $after->process()->holdHours());
|
||||
|
||||
$before->fresh()->update(['processing_mode' => ProcessingMode::Automatic]);
|
||||
$this->assertSame(ProcessingMode::Automatic, $before->fresh()->processingMode());
|
||||
$this->assertTrue(BookingEvent::query()->where('booking_id', $before->id)->where('type', 'mode')->exists());
|
||||
}
|
||||
|
||||
/** 1.7 */
|
||||
public function test_the_history_is_stored_and_does_not_change_with_the_case(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
$this->actingAs(User::factory()->create(['name' => 'Ingrid']));
|
||||
app(SendOffer::class)->handle($booking);
|
||||
|
||||
$summaries = $booking->events()->pluck('summary')->all();
|
||||
$this->assertStringStartsWith('Vorgang angelegt', $summaries[0]);
|
||||
$this->assertContains('Angebot Version 1 gesendet, gültig bis 24.10.2026, 10:00 Uhr', $summaries);
|
||||
$this->assertSame('Ingrid', $booking->events()->where('type', 'offer')->value('actor'));
|
||||
|
||||
$booking->fresh()->update(['offer_version' => 0, 'offer_sent_at' => null]);
|
||||
$this->assertContains('Angebot Version 1 gesendet, gültig bis 24.10.2026, 10:00 Uhr', $booking->events()->pluck('summary')->all());
|
||||
}
|
||||
|
||||
/** 1.1 */
|
||||
public function test_the_migration_keeps_behaviour_of_existing_cases_and_differing_properties(): void
|
||||
{
|
||||
$second = Property::factory()->create(['tenant_id' => $this->property->tenant_id, 'hold_hours' => 24, 'offer_mode' => 'manual']);
|
||||
$this->property->update(['hold_hours' => 48, 'offer_mode' => 'manual']);
|
||||
$portal = Channel::factory()->for($this->property)->create(['booking_model' => 'portal_booking', 'payment_tasks_reservation' => false]);
|
||||
$placeholder = Guest::query()->create(['first_name' => 'Gast', 'last_name' => '(FeWo-direkt)', 'email' => '']);
|
||||
$legacy = Booking::factory()->for($this->property)->create(['import_channel_id' => $portal->id, 'source' => 'portal', 'guest_id' => $placeholder->id, 'offer_hash' => 'abc', 'offer_version' => 2]);
|
||||
DB::table('bookings')->update(['intake' => null, 'case_type' => null, 'profile' => null]);
|
||||
DB::table('booking_events')->delete();
|
||||
DB::table('tenants')->update(['process_defaults' => null]);
|
||||
|
||||
(require database_path('migrations/2026_11_01_090100_move_process_settings_and_backfill_cases.php'))->up();
|
||||
|
||||
$tenant = Settings::tenant()->fresh();
|
||||
$this->assertSame('manual', $tenant->process_defaults['processing']);
|
||||
$this->assertArrayNotHasKey('hold_hours', $tenant->process_defaults);
|
||||
$this->assertSame(48, $this->property->fresh()->process_overrides['hold_hours']);
|
||||
$this->assertSame(24, $second->fresh()->process_overrides['hold_hours']);
|
||||
$this->assertSame(24, app(ProcessSettings::class)->resolve($second->fresh(), null, IntakeKind::Inquiry)->holdHours());
|
||||
|
||||
$legacy = $legacy->fresh();
|
||||
$this->assertSame(CaseType::A4, $legacy->case_type);
|
||||
$this->assertSame('migration', $legacy->process()->origin);
|
||||
$this->assertFalse($legacy->wantsPaymentTasks());
|
||||
$this->assertSame('abc', $legacy->offer_hash);
|
||||
$this->assertSame(2, $legacy->offer_version);
|
||||
$this->assertNull($legacy->guest_id);
|
||||
$this->assertNull(Guest::query()->find($placeholder->id));
|
||||
$this->assertTrue($legacy->events()->exists());
|
||||
}
|
||||
|
||||
private function request(string $email = 'gast@example.org', string $arrival = '2026-11-07', string $departure = '2026-11-10', ?Channel $channel = null): Booking
|
||||
{
|
||||
return app(CreateReservation::class)->handle(
|
||||
$this->property->fresh(),
|
||||
new StayRequest(CarbonImmutable::parse($arrival), CarbonImmutable::parse($departure), 2),
|
||||
['first_name' => 'Gesa', 'last_name' => 'Gast', 'email' => $email],
|
||||
sendMails: false,
|
||||
originChannel: $channel,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -95,8 +95,7 @@ public function test_portal_reservation_uses_the_reservation_template_and_a_conf
|
||||
$reservation = $this->template('FeWo-direkt', '<p>PORTAL-VERTRAG {{ mieter }}</p>', null, null);
|
||||
$portal = Channel::factory()->for($this->property)->create([
|
||||
'booking_model' => 'portal_booking',
|
||||
'contract_template_id' => $inquiry->id,
|
||||
'contract_template_reservation_id' => $reservation->id,
|
||||
'process_overrides' => ['inquiry' => ['contract_template_id' => $inquiry->id], 'booking' => ['contract_template_id' => $reservation->id, 'payments' => 'portal']],
|
||||
]);
|
||||
$booking = $this->booking(['import_channel_id' => $portal->id, 'source' => 'portal']);
|
||||
|
||||
@@ -109,7 +108,7 @@ public function test_portal_reservation_uses_the_reservation_template_and_a_conf
|
||||
Storage::disk('local')->assertExists($booking->contract_path);
|
||||
Mail::assertSent(BookingConfirmed::class, fn (BookingConfirmed $mail): bool => ! str_contains($mail->render(), 'überweisen'));
|
||||
|
||||
$inquiryPortal = Channel::factory()->for($this->property)->create(['booking_model' => 'inquiry', 'contract_template_id' => $inquiry->id, 'contract_template_reservation_id' => $reservation->id]);
|
||||
$inquiryPortal = Channel::factory()->for($this->property)->create(['booking_model' => 'inquiry', 'process_overrides' => ['inquiry' => ['contract_template_id' => $inquiry->id], 'booking' => ['contract_template_id' => $reservation->id]]]);
|
||||
$this->assertSame($inquiry->id, OfferTerms::templateFor($this->booking(['import_channel_id' => $inquiryPortal->id, 'source' => 'portal', 'arrival' => '2026-12-01', 'departure' => '2026-12-03']))->id);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public function test_default_order_is_explicit_choice_then_portal_then_property(
|
||||
$propertyDefault = $this->template('Direkt', ['terms' => '<p>DIREKT</p>']);
|
||||
$portalDefault = $this->template('Portal', ['terms' => '<p>PORTAL</p>']);
|
||||
$this->property->update(['contract_template_id' => $propertyDefault->id]);
|
||||
$channel = Channel::factory()->for($this->property)->create(['contract_template_id' => $portalDefault->id]);
|
||||
$channel = Channel::factory()->for($this->property)->create(['process_overrides' => ['booking' => ['contract_template_id' => $portalDefault->id]]]);
|
||||
|
||||
$direct = $this->offer();
|
||||
$viaPortal = $this->offer([], ['import_channel_id' => $channel->id, 'arrival' => '2026-12-01', 'departure' => '2026-12-04']);
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Actions\ProvideGuestContact;
|
||||
use App\Enums\AdminMode;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Filament\Pages\HandlingSettings;
|
||||
use App\Filament\Resources\Bookings\Pages\CreateBooking;
|
||||
use App\Filament\Resources\Bookings\Pages\ViewBooking;
|
||||
use App\Filament\Resources\Bookings\Schemas\BookingForm;
|
||||
use App\Filament\Widgets\WorkListWidget;
|
||||
use App\Mail\OfferMade;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ChannelTask;
|
||||
use App\Models\InboxMessage;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Process\CaseActivities;
|
||||
use App\Process\WorkList;
|
||||
use App\Support\Content;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Package 2 of UMSETZUNGSPLAN_v0.10: the work list, the guided case page, automatic or manual handling, continuing
|
||||
* after a stop and ending a case without bypassing obligations.
|
||||
*/
|
||||
class GuidedCaseHandlingTest 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, SiteSeeder::class]);
|
||||
$this->property = Property::sole();
|
||||
Mail::fake();
|
||||
Storage::fake('local');
|
||||
Http::fake(['*' => Http::response('', 500)]);
|
||||
$this->withoutVite();
|
||||
$this->actingAs(User::factory()->create(['name' => 'Ingrid', 'admin_mode' => AdminMode::Simple]));
|
||||
}
|
||||
|
||||
/** 2.1 */
|
||||
public function test_an_automatic_request_gets_its_offer_without_a_click_and_leaves_nothing_to_do(): void
|
||||
{
|
||||
$this->releaseContractTexts();
|
||||
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic']]);
|
||||
|
||||
$booking = $this->request(sendMails: true);
|
||||
|
||||
$this->assertSame(BookingStatus::OfferSent, $booking->status);
|
||||
Mail::assertSent(OfferMade::class);
|
||||
$this->assertNull(CaseActivities::next($booking));
|
||||
$this->assertSame([], WorkList::items());
|
||||
}
|
||||
|
||||
/** 2.2 */
|
||||
public function test_a_manual_request_is_prepared_and_waits_for_release_in_the_work_list(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
$this->assertSame(BookingStatus::Reserved, $booking->status);
|
||||
$items = WorkList::items();
|
||||
$this->assertCount(1, $items);
|
||||
$this->assertSame('Angebot prüfen und senden', $items[0]['title']);
|
||||
$this->assertStringContainsString('Gesa Gast', $items[0]['detail']);
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->assertSee('Angebot prüfen und senden')
|
||||
->assertSee('Sie geben jeden Schritt selbst frei')
|
||||
->callAction(TestAction::make('sendOffer')->arguments([]))
|
||||
->assertNotified('Angebot gesendet');
|
||||
|
||||
$this->assertSame(BookingStatus::OfferSent, $booking->fresh()->status);
|
||||
$this->assertSame('Ingrid', $booking->events()->where('type', 'offer')->value('actor'));
|
||||
}
|
||||
|
||||
/** 2.3 */
|
||||
public function test_missing_data_stops_the_case_with_a_task_and_it_continues_automatically_afterwards(): void
|
||||
{
|
||||
$this->releaseContractTexts();
|
||||
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic']]);
|
||||
|
||||
Livewire::test(CreateBooking::class)
|
||||
->fillForm([
|
||||
'kind' => BookingForm::INQUIRY, 'property_id' => $this->property->id, 'guests' => 2,
|
||||
'arrival' => '2026-11-07', 'departure' => '2026-11-10', 'first_name' => 'Paul', 'last_name' => 'Telefon', 'send_mails' => true,
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
$booking = Booking::query()->sole();
|
||||
|
||||
$this->assertSame(BookingStatus::Reserved, $booking->status);
|
||||
$this->assertSame('provideContact', CaseActivities::next($booking)?->action);
|
||||
$this->assertSame('E-Mail-Adresse des Gastes eintragen', WorkList::items()[0]['title']);
|
||||
Mail::assertNotSent(OfferMade::class);
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->callAction(TestAction::make('provideContact')->arguments([]), ['guest' => ['first_name' => 'Paul', 'last_name' => 'Telefon', 'email' => 'paul@example.org'], 'process' => ProvideGuestContact::AUTOMATIC, 'guest_confirmed' => false])
|
||||
->assertNotified('Kontaktdaten gespeichert, Angebot gesendet');
|
||||
|
||||
$this->assertSame(BookingStatus::OfferSent, $booking->fresh()->status);
|
||||
Mail::assertSent(OfferMade::class, 1);
|
||||
}
|
||||
|
||||
public function test_after_completing_a_task_the_landlord_may_keep_releasing_by_hand(): void
|
||||
{
|
||||
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic']]);
|
||||
$booking = $this->request(email: '');
|
||||
|
||||
app(ProvideGuestContact::class)->handle($booking, ['email' => 'gesa@example.org'], ProvideGuestContact::MANUAL);
|
||||
|
||||
$this->assertSame(BookingStatus::Reserved, $booking->fresh()->status);
|
||||
$this->assertSame('sendOffer', CaseActivities::next($booking->fresh())?->action);
|
||||
Mail::assertNotSent(OfferMade::class);
|
||||
}
|
||||
|
||||
public function test_the_handling_of_one_case_can_be_switched_and_is_recorded(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->callAction('automation', ['mode' => ProcessingMode::Automatic->value]);
|
||||
|
||||
$this->assertSame(ProcessingMode::Automatic, $booking->fresh()->processing_mode);
|
||||
$this->assertStringContainsString('Automatisch', $booking->events()->where('type', 'mode')->value('summary'));
|
||||
}
|
||||
|
||||
/** 2.5 / 2.6 */
|
||||
public function test_the_work_list_brings_everything_to_do_into_one_list(): void
|
||||
{
|
||||
$this->request();
|
||||
$portal = Channel::factory()->for($this->property)->create(['name' => 'Ostsee-Portal']);
|
||||
ChannelTask::factory()->for($portal)->create(['starts_on' => '2026-12-01', 'ends_on' => '2026-12-05']);
|
||||
BlockedPeriod::factory()->for($this->property)->create(['channel_id' => $portal->id, 'source' => 'channel', 'external_uid' => 'x1', 'starts_on' => '2026-12-20', 'ends_on' => '2026-12-22', 'needs_review' => true]);
|
||||
InboxMessage::factory()->create(['subject' => 'Angebot nicht zugestellt']);
|
||||
|
||||
$titles = array_column(WorkList::items(), 'title');
|
||||
|
||||
$this->assertContains('Angebot prüfen und senden', $titles);
|
||||
$this->assertContains('In Ostsee-Portal sperren', $titles);
|
||||
$this->assertContains('Unbekannte Belegung von Ostsee-Portal – was ist das?', $titles);
|
||||
$this->assertContains('Angebot nicht zugestellt', $titles);
|
||||
Livewire::test(WorkListWidget::class)->assertSee('In Ostsee-Portal sperren')->assertSee('Vorgang öffnen');
|
||||
}
|
||||
|
||||
/** 2.5 */
|
||||
public function test_the_case_page_shows_the_state_the_next_step_and_only_fitting_buttons(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->assertSee('Anfrage über die Webseite')
|
||||
->assertSee('Zeitraum reserviert bis')
|
||||
->assertSee('Als Nächstes')
|
||||
->assertActionVisible('sendOffer')
|
||||
->assertActionVisible('end')
|
||||
->assertActionHidden('resendConfirmation')
|
||||
->assertActionHidden('portalPrice')
|
||||
->assertDontSee('Technische Angaben')
|
||||
->assertDontSee('Status von Hand ändern');
|
||||
}
|
||||
|
||||
/** 2.7 */
|
||||
public function test_the_expert_view_shows_technical_details_on_the_same_page(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
$this->actingAs(User::factory()->create(['admin_mode' => AdminMode::Expert]));
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->assertSee('Technische Angaben')
|
||||
->assertSee('Abwicklungsprofil (eingefroren)')
|
||||
->assertSee('Grundeinstellung');
|
||||
}
|
||||
|
||||
/** 2.8 */
|
||||
public function test_nationality_is_never_a_reason_to_stop(): void
|
||||
{
|
||||
$this->releaseContractTexts();
|
||||
Settings::tenant()->update(['process_defaults' => ['processing' => 'automatic']]);
|
||||
|
||||
$foreign = app(CreateReservation::class)->handle(
|
||||
$this->property->fresh(),
|
||||
new StayRequest(CarbonImmutable::parse('2026-11-07'), CarbonImmutable::parse('2026-11-10'), 2),
|
||||
['first_name' => 'Ayşe', 'last_name' => 'Yılmaz', 'email' => 'ayse@example.com.tr', 'country' => 'TR', 'city' => 'İzmir'],
|
||||
);
|
||||
|
||||
$this->assertSame(BookingStatus::OfferSent, $foreign->status);
|
||||
}
|
||||
|
||||
public function test_ending_a_request_needs_a_reason_and_ends_it_without_booking(): void
|
||||
{
|
||||
$booking = $this->request();
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->callAction('end', ['reason' => '', 'notify' => false])
|
||||
->assertHasFormErrors(['reason' => 'required']);
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->callAction('end', ['reason' => 'Hund nicht erlaubt', 'notify' => false])
|
||||
->assertNotified('Vorgang beendet');
|
||||
|
||||
$this->assertSame(BookingStatus::Declined, $booking->fresh()->status);
|
||||
$this->assertSame(0, Booking::query()->occupying()->count());
|
||||
$this->assertSame('Hund nicht erlaubt', $booking->events()->where('type', 'status')->value('reason'));
|
||||
}
|
||||
|
||||
public function test_the_landlord_sets_defaults_on_one_page_and_a_portal_deviates_per_intake(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create(['admin_mode' => AdminMode::Expert]));
|
||||
|
||||
Livewire::test(HandlingSettings::class)
|
||||
->fillForm(['processing' => 'automatic', 'hold_hours' => 24, 'pre_reservation' => null])
|
||||
->call('save')
|
||||
->assertNotified('Gespeichert');
|
||||
|
||||
$this->assertSame(['processing' => 'automatic', 'hold_hours' => 24], Settings::tenant()->fresh()->process_defaults);
|
||||
}
|
||||
|
||||
private function request(string $email = 'gesa@example.org', bool $sendMails = false): 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' => $email],
|
||||
sendMails: $sendMails,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatic offers wait for released contract texts in live mode; tests run in test mode, but the texts are set as
|
||||
* a real landlord would have them.
|
||||
*/
|
||||
private function releaseContractTexts(): void
|
||||
{
|
||||
Content::save(['contract.terms' => '<p>Echte Bedingungen</p>', 'stay.cancellation' => '<p>Echtes Storno</p>']);
|
||||
Settings::tenant()->update(['bank_iban' => 'DE02120300000000202051']);
|
||||
}
|
||||
}
|
||||
@@ -4,26 +4,31 @@
|
||||
|
||||
use App\Actions\OpenPortalFile;
|
||||
use App\Actions\ProvideGuestContact;
|
||||
use App\Actions\RecordPortalBooking;
|
||||
use App\Actions\ResolveChannelOccupation;
|
||||
use App\Actions\SetBookingStatus;
|
||||
use App\Actions\TakeOverExternalBooking;
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\AdminMode;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\CaseType;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Enums\ProcessingMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Filament\Resources\Bookings\Pages\CreateBooking;
|
||||
use App\Filament\Resources\Bookings\Pages\ListBookings;
|
||||
use App\Filament\Resources\Bookings\Pages\ViewBooking;
|
||||
use App\Filament\Resources\Bookings\Schemas\BookingForm;
|
||||
use App\Filament\Resources\PortalOccupations\Pages\ViewPortalOccupation;
|
||||
use App\Mail\BookingConfirmed;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Support\BookingProgress;
|
||||
use App\Process\CaseActivities;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
@@ -35,8 +40,9 @@
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Portal bookings entered without contact data, the contract process that follows (automatic or by hand),
|
||||
* manual status changes, the archive and the clarification of portal occupations.
|
||||
* Bookings already binding on a portal (A3–A5): one way to take them over – entered by hand or found in the portal
|
||||
* calendar –, the documents that follow (automatic or released by hand), manual status corrections, ending, the
|
||||
* archive and the clarification of portal occupations.
|
||||
*/
|
||||
class PortalBookingTest extends TestCase
|
||||
{
|
||||
@@ -59,97 +65,107 @@ protected function setUp(): void
|
||||
$this->withoutVite();
|
||||
}
|
||||
|
||||
public function test_a_portal_booking_without_contact_data_occupies_the_dates_but_creates_no_contract(): void
|
||||
public function test_a_binding_portal_booking_is_taken_over_without_offer_acceptance_or_contract(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM, total: 123400, reference: 'HA-123');
|
||||
$booking = $this->takeOver(total: 123400, reference: 'HA-123', guest: ['first_name' => 'Erika', 'last_name' => 'Muster']);
|
||||
|
||||
$this->assertSame(BookingStatus::Confirmed, $booking->status);
|
||||
$this->assertSame(CaseType::A3, $booking->case_type);
|
||||
$this->assertSame($this->portal->id, $booking->origin_channel_id);
|
||||
$this->assertSame('HA-123', $booking->portal_reference);
|
||||
$this->assertSame(123400, $booking->total);
|
||||
$this->assertSame(0, $booking->offer_version);
|
||||
$this->assertSame('', $booking->guest->email);
|
||||
$this->assertNull($booking->contract_path);
|
||||
$this->assertSame(BookingProgress::PORTAL_BOOKING, BookingProgress::kind($booking));
|
||||
$this->assertSame('Kontaktdaten fehlen', BookingProgress::next($booking)['title']);
|
||||
$this->assertSame('provideContact', CaseActivities::next($booking)?->action);
|
||||
Mail::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_an_immediate_contract_needs_the_email_address(): void
|
||||
public function test_entering_the_contact_data_can_send_the_documents_automatically(): void
|
||||
{
|
||||
$this->expectException(ReservationException::class);
|
||||
$booking = $this->takeOver(total: 50000);
|
||||
|
||||
$this->record(RecordPortalBooking::CONTRACT);
|
||||
}
|
||||
|
||||
public function test_entering_the_contact_data_can_start_the_contract_automatically(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM);
|
||||
|
||||
$message = app(ProvideGuestContact::class)->handle($booking, ['email' => 'Gast@Example.test', 'street' => 'Hauptstr. 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn'], ProvideGuestContact::AUTOMATIC, guestConfirmed: true);
|
||||
$message = app(ProvideGuestContact::class)->handle($booking, ['first_name' => 'Erika', 'last_name' => 'Muster', 'email' => 'Gast@Example.test', 'street' => 'Hauptstr. 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn'], ProvideGuestContact::AUTOMATIC, guestConfirmed: true);
|
||||
|
||||
$booking->refresh();
|
||||
$this->assertSame('Kontaktdaten gespeichert, Vertrag gesendet', $message);
|
||||
$this->assertSame('gast@example.test', $booking->guest->email);
|
||||
$this->assertNotNull($booking->contract_path);
|
||||
$this->assertNotNull($booking->guest_confirmed_at);
|
||||
$this->assertSame(ProcessingMode::Automatic, $booking->processing_mode);
|
||||
Mail::assertSent(BookingConfirmed::class, 1);
|
||||
}
|
||||
|
||||
public function test_entering_the_contact_data_by_hand_sends_nothing(): void
|
||||
public function test_automatic_documents_wait_for_the_portal_price(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM);
|
||||
$booking = $this->takeOver();
|
||||
|
||||
app(ProvideGuestContact::class)->handle($booking, ['email' => 'gast@example.test'], ProvideGuestContact::MANUAL);
|
||||
$this->expectException(ReservationException::class);
|
||||
$this->expectExceptionMessage('Gesamtpreis');
|
||||
app(ProvideGuestContact::class)->handle($booking, ['first_name' => 'Erika', 'last_name' => 'Muster', 'email' => 'gast@example.test'], ProvideGuestContact::AUTOMATIC);
|
||||
}
|
||||
|
||||
public function test_entering_the_contact_data_by_hand_sends_nothing_and_the_documents_become_the_next_step(): void
|
||||
{
|
||||
$booking = $this->takeOver(total: 50000);
|
||||
|
||||
app(ProvideGuestContact::class)->handle($booking, ['first_name' => 'Erika', 'last_name' => 'Muster', 'email' => 'gast@example.test'], ProvideGuestContact::MANUAL);
|
||||
|
||||
$this->assertNull($booking->fresh()->contract_path);
|
||||
$this->assertSame('Vertrag senden', BookingProgress::next($booking->fresh())['title']);
|
||||
$this->assertSame('resendConfirmation', CaseActivities::next($booking->fresh())?->action);
|
||||
Mail::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_a_recorded_request_stays_open_and_automatic_continuation_needs_an_email(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::RECORD);
|
||||
$this->assertSame(BookingStatus::Reserved, $booking->status);
|
||||
|
||||
$this->expectException(ReservationException::class);
|
||||
app(ProvideGuestContact::class)->handle($booking, ['phone' => '0123'], ProvideGuestContact::AUTOMATIC);
|
||||
}
|
||||
|
||||
public function test_the_booking_form_records_a_portal_booking_and_the_page_offers_the_contact_actions(): void
|
||||
public function test_the_new_dialog_takes_over_a_portal_booking_and_the_page_leads_to_the_contact_data(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(CreateBooking::class)
|
||||
->fillForm([
|
||||
'property_id' => $this->property->id, 'guests' => 2, 'arrival' => '2026-11-07', 'departure' => '2026-11-10',
|
||||
'channel_id' => $this->portal->id, 'portal_reference' => 'HA-9', 'portal_process' => RecordPortalBooking::CONFIRM,
|
||||
'first_name' => 'Erika', 'last_name' => 'Muster',
|
||||
'kind' => BookingForm::EXTERNAL,
|
||||
'property_id' => $this->property->id, 'arrival' => '2026-11-07', 'departure' => '2026-11-10',
|
||||
'channel_id' => $this->portal->id, 'portal_reference' => 'HA-9',
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$booking = Booking::query()->sole();
|
||||
$this->assertSame('HA-9', $booking->portal_reference);
|
||||
$this->assertNull($booking->guest_id);
|
||||
$this->assertNull($booking->guests);
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->assertActionVisible('requestContact')
|
||||
->callAction('requestContact')
|
||||
->assertSee('Name und Kontaktdaten des Gastes eintragen')
|
||||
->assertSee('Gesamtpreis laut Portal eintragen')
|
||||
->callAction(TestAction::make('requestContact')->arguments([]))
|
||||
->assertNotified('Als angefragt vermerkt')
|
||||
->callAction('provideContact', ['guest' => ['first_name' => 'Erika', 'last_name' => 'Muster', 'email' => 'erika@example.test'], 'process' => ProvideGuestContact::MANUAL, 'guest_confirmed' => false])
|
||||
->assertNotified('Kontaktdaten gespeichert');
|
||||
->callAction(TestAction::make('provideContact')->arguments([]), ['guest' => ['first_name' => 'Erika', 'last_name' => 'Muster', 'email' => 'erika@example.test'], 'process' => ProvideGuestContact::MANUAL, 'guest_confirmed' => false])
|
||||
->assertNotified('Kontaktdaten gespeichert')
|
||||
->callAction(TestAction::make('portalPrice')->arguments([]), ['portal_total' => '979.51', 'guests' => 2])
|
||||
->assertNotified('Preis gespeichert');
|
||||
|
||||
$this->assertNotNull($booking->fresh()->contact_requested_at);
|
||||
$this->assertSame('erika@example.test', $booking->fresh()->guest->email);
|
||||
$booking->refresh();
|
||||
$this->assertNotNull($booking->contact_requested_at);
|
||||
$this->assertSame('erika@example.test', $booking->guest->email);
|
||||
$this->assertSame(97951, $booking->total);
|
||||
$this->assertSame(2, $booking->guests);
|
||||
}
|
||||
|
||||
public function test_status_can_be_changed_by_hand_with_a_reason_and_the_calendar_is_checked(): void
|
||||
public function test_status_can_be_corrected_by_hand_but_a_binding_booking_never_falls_back_to_a_request(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM);
|
||||
$booking = $this->takeOver();
|
||||
$set = app(SetBookingStatus::class);
|
||||
|
||||
$set->handle($booking, BookingStatus::Paid, 'Zahlung über das Portal erhalten', 'Test');
|
||||
$this->assertSame(BookingStatus::Paid, $booking->fresh()->status);
|
||||
$this->assertStringContainsString('Zahlung über das Portal erhalten', $booking->fresh()->internal_notes);
|
||||
$this->assertSame('Von Hand gesetzt: Zahlung über das Portal erhalten', $booking->events()->where('type', 'status')->reorder()->latest('id')->value('reason'));
|
||||
|
||||
try {
|
||||
$set->handle($booking->fresh(), BookingStatus::Reserved, 'zurück');
|
||||
$this->fail('A binding booking must not become a request again.');
|
||||
} catch (ReservationException) {
|
||||
$this->assertSame(BookingStatus::Paid, $booking->fresh()->status);
|
||||
}
|
||||
|
||||
$booking->update(['status' => BookingStatus::Expired]);
|
||||
$other = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => '2026-11-08', 'departure' => '2026-11-09']);
|
||||
@@ -168,12 +184,15 @@ public function test_status_can_be_changed_by_hand_with_a_reason_and_the_calenda
|
||||
$set->handle($booking->fresh(), BookingStatus::Cancelled, 'nicht erlaubt');
|
||||
}
|
||||
|
||||
public function test_the_manual_status_action_is_not_offered_for_the_own_website_process(): void
|
||||
public function test_the_manual_status_action_is_an_expert_function_and_not_offered_for_the_website_process(): void
|
||||
{
|
||||
$own = Booking::factory()->for($this->property)->reserved(now()->addHours(48))->create(['source' => 'website', 'arrival' => '2026-11-07', 'departure' => '2026-11-10']);
|
||||
$portal = $this->record(RecordPortalBooking::CONFIRM, arrival: '2026-12-01', departure: '2026-12-04');
|
||||
$this->actingAs(User::factory()->create());
|
||||
$portal = $this->takeOver(arrival: '2026-12-01', departure: '2026-12-04');
|
||||
|
||||
$this->actingAs(User::factory()->create(['admin_mode' => AdminMode::Simple]));
|
||||
Livewire::test(ViewBooking::class, ['record' => $portal->getRouteKey()])->assertDontSee('Status von Hand ändern');
|
||||
|
||||
$this->actingAs(User::factory()->create(['admin_mode' => AdminMode::Expert]));
|
||||
Livewire::test(ViewBooking::class, ['record' => $own->getRouteKey()])->assertDontSee('Status von Hand ändern');
|
||||
Livewire::test(ViewBooking::class, ['record' => $portal->getRouteKey()])->assertSee('Status von Hand ändern')
|
||||
->callAction(TestAction::make('setStatus')->arguments([]), ['status' => BookingStatus::Paid->value, 'reason' => 'Portal zahlt aus'])
|
||||
@@ -181,6 +200,21 @@ public function test_the_manual_status_action_is_not_offered_for_the_own_website
|
||||
$this->assertSame(BookingStatus::Paid, $portal->fresh()->status);
|
||||
}
|
||||
|
||||
public function test_ending_a_portal_booking_cancels_it_and_asks_to_cancel_on_the_portal_too(): void
|
||||
{
|
||||
$booking = $this->takeOver(total: 50000);
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->callAction('end', ['initiated_by' => 'guest', 'reason' => 'Gast storniert im Portal', 'costs_task' => true])
|
||||
->assertNotified('Buchung storniert');
|
||||
|
||||
$this->assertSame(BookingStatus::Cancelled, $booking->fresh()->status);
|
||||
$this->assertTrue(BookingTask::query()->where('booking_id', $booking->id)->where('kind', BookingTaskKind::PortalCancellation)->exists());
|
||||
$this->assertSame('Gast storniert im Portal', $booking->events()->where('type', 'status')->reorder()->latest('id')->value('reason'));
|
||||
$this->assertSame('Stornierung im Portal veranlassen bzw. prüfen', CaseActivities::next($booking->fresh())?->label);
|
||||
}
|
||||
|
||||
public function test_archived_bookings_leave_the_list_but_keep_everything(): void
|
||||
{
|
||||
$past = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Completed, 'arrival' => '2026-09-01', 'departure' => '2026-09-05']);
|
||||
@@ -195,7 +229,7 @@ public function test_archived_bookings_leave_the_list_but_keep_everything(): voi
|
||||
|
||||
public function test_the_list_filters_by_channel_period_and_missing_contact_data(): void
|
||||
{
|
||||
$portalBooking = $this->record(RecordPortalBooking::CONFIRM, arrival: '2026-12-01', departure: '2026-12-04');
|
||||
$portalBooking = $this->takeOver(arrival: '2026-12-01', departure: '2026-12-04');
|
||||
$own = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => '2026-11-07', 'departure' => '2026-11-10']);
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
@@ -218,9 +252,9 @@ public function test_an_independent_occupation_with_a_booking_channel_is_no_long
|
||||
$this->assertSame(OccupationKind::Reservation, $block->fresh()->occupation_kind);
|
||||
}
|
||||
|
||||
public function test_a_portal_reservation_from_the_calendar_gets_a_booking_file_and_stays_occupied(): void
|
||||
public function test_a_portal_reservation_from_the_calendar_becomes_one_case_and_stays_occupied(): void
|
||||
{
|
||||
$block = BlockedPeriod::factory()->for($this->property)->create(['channel_id' => $this->portal->id, 'source' => 'channel', 'external_uid' => 'u2', 'starts_on' => '2026-12-10', 'ends_on' => '2026-12-14', 'occupation_kind' => OccupationKind::Reservation]);
|
||||
$block = BlockedPeriod::factory()->for($this->property)->create(['channel_id' => $this->portal->id, 'source' => 'channel', 'external_uid' => 'u2', 'starts_on' => '2026-12-10', 'ends_on' => '2026-12-14', 'occupation_kind' => OccupationKind::Reservation, 'ical_interpretation' => ['fields' => ['guest_first_name' => 'Mia']]]);
|
||||
$checker = app(AvailabilityChecker::class);
|
||||
$this->assertFalse($checker->isAvailable($this->property, CarbonImmutable::parse('2026-12-10'), CarbonImmutable::parse('2026-12-14')));
|
||||
|
||||
@@ -228,8 +262,10 @@ public function test_a_portal_reservation_from_the_calendar_gets_a_booking_file_
|
||||
|
||||
$this->assertSame(BookingStatus::Confirmed, $booking->status);
|
||||
$this->assertSame($this->portal->id, $booking->origin_channel_id);
|
||||
$this->assertSame(BookingProgress::PORTAL_BOOKING, BookingProgress::kind($booking));
|
||||
$this->assertSame('', $booking->guest->email);
|
||||
$this->assertSame(CaseType::A3, $booking->case_type);
|
||||
$this->assertNull($booking->guest_id);
|
||||
$this->assertNull($booking->total);
|
||||
$this->assertStringContainsString('Name laut Kalender: Mia', $booking->internal_notes);
|
||||
$this->assertTrue($block->fresh()->is_representation);
|
||||
$this->assertSame($booking->id, $block->fresh()->linked_booking_id);
|
||||
$this->assertFalse($checker->isAvailable($this->property, CarbonImmutable::parse('2026-12-10'), CarbonImmutable::parse('2026-12-14')));
|
||||
@@ -237,7 +273,7 @@ public function test_a_portal_reservation_from_the_calendar_gets_a_booking_file_
|
||||
$this->assertSame(1, Booking::query()->count());
|
||||
}
|
||||
|
||||
public function test_a_blocked_period_gets_no_booking_file(): void
|
||||
public function test_a_blocked_period_does_not_become_a_booking(): void
|
||||
{
|
||||
$block = BlockedPeriod::factory()->for($this->property)->create(['channel_id' => $this->portal->id, 'source' => 'channel', 'external_uid' => 'u3', 'starts_on' => '2026-12-10', 'ends_on' => '2026-12-14', 'occupation_kind' => OccupationKind::Block]);
|
||||
|
||||
@@ -245,7 +281,7 @@ public function test_a_blocked_period_gets_no_booking_file(): void
|
||||
app(OpenPortalFile::class)->handle($block);
|
||||
}
|
||||
|
||||
public function test_the_occupation_page_offers_the_file_and_leads_to_the_booking(): void
|
||||
public function test_the_occupation_page_takes_the_reservation_over_and_leads_to_the_case(): void
|
||||
{
|
||||
$block = BlockedPeriod::factory()->for($this->property)->create(['channel_id' => $this->portal->id, 'source' => 'channel', 'external_uid' => 'u4', 'starts_on' => '2026-12-10', 'ends_on' => '2026-12-14', 'occupation_kind' => OccupationKind::Reservation]);
|
||||
$this->actingAs(User::factory()->create());
|
||||
@@ -254,32 +290,31 @@ public function test_the_occupation_page_offers_the_file_and_leads_to_the_bookin
|
||||
|
||||
$booking = Booking::query()->sole();
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->assertSee('Ablauf: Meilensteine und Aktivitäten')
|
||||
->assertSee('Bisheriger Verlauf')
|
||||
->assertSee('Standardprozess')
|
||||
->assertSee('Kontaktdaten eintragen');
|
||||
->assertSee('Als Nächstes')
|
||||
->assertSee('Ablauf')
|
||||
->assertSee('Verlauf')
|
||||
->assertSee('Gebucht über FeWo-direkt')
|
||||
->assertSee('Gast noch nicht bekannt');
|
||||
}
|
||||
|
||||
public function test_every_milestone_lists_its_activities_and_the_history_records_what_happened(): void
|
||||
public function test_the_history_records_what_happened_with_its_actor(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM);
|
||||
$booking = $this->takeOver();
|
||||
|
||||
$steps = collect(BookingProgress::steps($booking))->keyBy('label');
|
||||
$this->assertFalse($steps['Gast & Kontaktdaten']['activities'][1]['done']);
|
||||
$this->assertSame('Kontaktdaten eintragen', $steps['Gast & Kontaktdaten']['activities'][1]['action']);
|
||||
$this->assertSame(['Vorgang angelegt (FeWo-direkt)', 'Buchung verbindlich bestätigt'], array_column(BookingProgress::history($booking), 'label'));
|
||||
$this->assertSame(['Vorgang angelegt: Portalbuchung, Abwicklung bei uns (FeWo-direkt)', 'Beim Portal verbindlich gebucht – übernommen'], $booking->events()->pluck('summary')->all());
|
||||
}
|
||||
|
||||
private function record(string $process, ?int $total = null, ?string $reference = null, string $arrival = '2026-11-07', string $departure = '2026-11-10'): Booking
|
||||
/**
|
||||
* @param array<string, ?string>|null $guest
|
||||
*/
|
||||
private function takeOver(?int $total = null, ?string $reference = null, string $arrival = '2026-11-07', string $departure = '2026-11-10', ?array $guest = null): Booking
|
||||
{
|
||||
return app(RecordPortalBooking::class)->handle(
|
||||
return app(TakeOverExternalBooking::class)->handle(
|
||||
$this->property,
|
||||
$this->portal,
|
||||
new StayRequest(CarbonImmutable::parse($arrival), CarbonImmutable::parse($departure), 2),
|
||||
['first_name' => 'Erika', 'last_name' => 'Muster'],
|
||||
$process,
|
||||
$reference,
|
||||
$total,
|
||||
CarbonImmutable::parse($arrival),
|
||||
CarbonImmutable::parse($departure),
|
||||
['portal_total' => $total, 'portal_reference' => $reference, 'guest' => $guest],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -137,8 +137,8 @@ public function test_free_cancellation_window_switches_between_instant_and_reque
|
||||
public function test_payment_tasks_follow_the_channel_policy(): void
|
||||
{
|
||||
$own = $this->confirmed();
|
||||
$reservationPortal = Channel::factory()->for($this->property)->create(['booking_model' => 'portal_booking', 'payment_tasks_reservation' => false]);
|
||||
$inquiryPortal = Channel::factory()->for($this->property)->create(['booking_model' => 'inquiry', 'payment_tasks_inquiry' => true]);
|
||||
$reservationPortal = Channel::factory()->for($this->property)->create(['booking_model' => 'portal_booking', 'process_overrides' => ['booking' => ['payments' => 'portal']]]);
|
||||
$inquiryPortal = Channel::factory()->for($this->property)->create(['booking_model' => 'inquiry', 'process_overrides' => ['inquiry' => ['payments' => 'landlord']]]);
|
||||
$portalReservation = $this->confirmed('2026-12-10', '2026-12-14', ['import_channel_id' => $reservationPortal->id, 'source' => 'portal']);
|
||||
$portalInquiry = $this->confirmed('2026-12-16', '2026-12-18', ['import_channel_id' => $inquiryPortal->id, 'source' => 'portal']);
|
||||
|
||||
|
||||
Reference in new issue
Block a user