Sperrzeiten um Eigenbelegung und privaten Buchungskanal erweitern
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m49s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m49s
This commit is contained in:
1 parent
2b2e732612
commit
4389894959
12 files changed
+305
-28
No files matched your search
@@ -8,11 +8,13 @@
|
||||
use App\Actions\ClassifyPortalOccupation;
|
||||
use App\Actions\ConfirmBooking;
|
||||
use App\Actions\DeclineBooking;
|
||||
use App\Actions\ResolveChannelOccupation;
|
||||
use App\Actions\SendOffer;
|
||||
use App\Actions\SyncChannel;
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Availability\OccupancyOverview;
|
||||
use App\Channels\ICal\ICalFeed;
|
||||
use App\Enums\BlockedPeriodPurpose;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Enums\UserRole;
|
||||
@@ -125,6 +127,148 @@ public function test_manual_classification_preserves_calendar_identity_and_survi
|
||||
Livewire::test(ManageBlockedPeriods::class)->assertCanSeeTableRecords([$block]);
|
||||
}
|
||||
|
||||
public function test_imported_block_can_be_classified_as_private_own_use_without_exporting_it_back_to_its_source(): void
|
||||
{
|
||||
$property = $this->property();
|
||||
$block = $this->import($property, ['needs_review' => true]);
|
||||
$identity = $block->only(['channel_id', 'external_uid', 'starts_on', 'ends_on', 'export_approved']);
|
||||
$target = Channel::factory()->for($property)->create();
|
||||
|
||||
Livewire::test(ViewPortalOccupation::class, ['record' => $block->id])->callAction('classify', [
|
||||
'occupation_kind' => 'block', 'block_purpose' => 'own_use', 'block_note' => 'Familienaufenthalt', 'origin_channel_id' => 'private',
|
||||
])->assertHasNoActionErrors()->assertNotified('Belegungsart gespeichert');
|
||||
|
||||
$block->refresh();
|
||||
$this->assertSame(BlockedPeriodPurpose::OwnUse, $block->block_purpose);
|
||||
$this->assertTrue($block->is_private);
|
||||
$this->assertNull($block->origin_channel_id);
|
||||
$this->assertTrue($block->needs_review);
|
||||
$this->assertEquals($identity, $block->only(array_keys($identity)));
|
||||
$this->assertStringNotContainsString('UID:block-'.$block->id, app(ICalFeed::class)->build($block->channel));
|
||||
$this->assertStringContainsString('UID:block-'.$block->id, app(ICalFeed::class)->build($target));
|
||||
Livewire::test(ViewPortalOccupation::class, ['record' => $block->id])->assertSee('Eigenbelegung')->assertSee('Familienaufenthalt')->assertSee('Privat')->assertSee($block->channel->name);
|
||||
$row = app(OccupancyOverview::class)->records(includeBlocks: true)['portal-'.$block->id];
|
||||
$this->assertSame('Privat', $row['source']);
|
||||
$this->assertSame('Eigenbelegung · Familienaufenthalt', $row['reason']);
|
||||
}
|
||||
|
||||
public function test_private_purpose_and_note_survive_a_changed_calendar_import_and_rule_evaluation(): void
|
||||
{
|
||||
$property = $this->property();
|
||||
$block = $this->import($property, ['external_uid' => 'private-stay']);
|
||||
app(ClassifyPortalOccupation::class)->handle($block, OccupationKind::Block, details: [
|
||||
'block_purpose' => 'own_use', 'block_note' => 'Persönlich bestätigt', 'is_private' => true,
|
||||
]);
|
||||
Http::preventStrayRequests();
|
||||
Http::fake(['https://portal.example/calendar.ics' => Http::response($this->feed('private-stay', '20261120', '20261125'))]);
|
||||
|
||||
$result = app(SyncChannel::class)->handle($block->channel);
|
||||
|
||||
$this->assertTrue($result->successful, $result->message ?? 'Import failed');
|
||||
$block->refresh();
|
||||
$this->assertSame('2026-11-20', $block->starts_on->toDateString());
|
||||
$this->assertSame(OccupationKind::Block, $block->occupationKind());
|
||||
$this->assertTrue($block->is_private);
|
||||
$this->assertNull($block->origin_channel_id);
|
||||
$this->assertSame('Eigenbelegung · Persönlich bestätigt', $block->blockDescription());
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
public function test_manual_block_can_be_created_and_edited_with_own_use_and_private_channel(): void
|
||||
{
|
||||
$property = $this->property();
|
||||
|
||||
Livewire::test(ManageBlockedPeriods::class)->callAction('create', [
|
||||
'property_id' => $property->id, 'starts_on' => '2026-11-10', 'ends_on' => '2026-11-12',
|
||||
'block_purpose' => 'own_use', 'block_note' => 'Eigener Aufenthalt', 'is_private' => true,
|
||||
])->assertHasNoActionErrors();
|
||||
|
||||
$block = BlockedPeriod::sole();
|
||||
$this->assertSame('manual', $block->source);
|
||||
$this->assertTrue($block->is_private);
|
||||
$this->assertSame(BlockedPeriodPurpose::OwnUse, $block->block_purpose);
|
||||
Livewire::test(ManageBlockedPeriods::class)->callTableAction('edit', $block, [
|
||||
'block_purpose' => 'maintenance', 'block_note' => 'Bad renovieren', 'is_private' => false,
|
||||
])->assertHasNoActionErrors();
|
||||
$block->refresh();
|
||||
$this->assertFalse($block->is_private);
|
||||
$this->assertSame('Wartung / Renovierung · Bad renovieren', $block->blockDescription());
|
||||
}
|
||||
|
||||
public function test_imported_block_purpose_can_be_changed_directly_in_blocked_periods_and_cleared(): void
|
||||
{
|
||||
$property = $this->property();
|
||||
$block = $this->import($property, ['occupation_kind' => OccupationKind::Block, 'block_purpose' => 'own_use', 'block_note' => 'Alter Hinweis', 'is_private' => true]);
|
||||
|
||||
Livewire::test(ManageBlockedPeriods::class)->callTableAction('classify', $block, [
|
||||
'occupation_kind' => 'block', 'block_purpose' => 'other', 'block_note' => null, 'origin_channel_id' => null,
|
||||
])->assertHasNoActionErrors();
|
||||
|
||||
$block->refresh();
|
||||
$this->assertSame(BlockedPeriodPurpose::Other, $block->block_purpose);
|
||||
$this->assertNull($block->block_note);
|
||||
$this->assertFalse($block->is_private);
|
||||
Livewire::test(ViewPortalOccupation::class, ['record' => $block->id])->callAction('classify', [
|
||||
'occupation_kind' => 'reservation', 'origin_channel_id' => $block->channel_id,
|
||||
])->assertHasNoActionErrors();
|
||||
$this->assertNull($block->fresh()->block_purpose);
|
||||
$this->assertSame($block->channel_id, $block->fresh()->origin_channel_id);
|
||||
}
|
||||
|
||||
public function test_invalid_block_note_is_rejected_without_changing_the_classification(): void
|
||||
{
|
||||
$block = $this->import($this->property());
|
||||
|
||||
Livewire::test(ViewPortalOccupation::class, ['record' => $block->id])->callAction('classify', [
|
||||
'occupation_kind' => 'block', 'block_purpose' => 'own_use', 'block_note' => str_repeat('x', 256), 'origin_channel_id' => 'private',
|
||||
])->assertHasActionErrors(['block_note' => 'max']);
|
||||
|
||||
$this->assertNull($block->fresh()->occupation_kind);
|
||||
$this->assertFalse($block->fresh()->is_private);
|
||||
}
|
||||
|
||||
public function test_private_and_external_origin_cannot_be_saved_together(): void
|
||||
{
|
||||
$block = $this->import($this->property());
|
||||
|
||||
try {
|
||||
app(ClassifyPortalOccupation::class)->handle($block, OccupationKind::Block, $block->channel_id, ['is_private' => true]);
|
||||
$this->fail('Contradicting booking channels must be rejected.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertSame('Privat und ein externer Buchungskanal können nicht gleichzeitig gewählt werden.', $exception->errors()['origin_channel_id'][0]);
|
||||
}
|
||||
|
||||
$this->assertNull($block->fresh()->occupation_kind);
|
||||
$this->assertFalse($block->fresh()->is_private);
|
||||
}
|
||||
|
||||
public function test_identity_resolution_preserves_private_origin_until_an_external_origin_is_explicitly_selected(): void
|
||||
{
|
||||
$block = $this->import($this->property(), ['occupation_kind' => OccupationKind::Block, 'is_private' => true]);
|
||||
|
||||
app(ResolveChannelOccupation::class)->handle($block, 'independent');
|
||||
$this->assertTrue($block->fresh()->is_private);
|
||||
$this->assertNull($block->fresh()->origin_channel_id);
|
||||
|
||||
app(ResolveChannelOccupation::class)->handle($block, 'independent', originId: $block->channel_id);
|
||||
$this->assertFalse($block->fresh()->is_private);
|
||||
$this->assertSame($block->channel_id, $block->fresh()->origin_channel_id);
|
||||
}
|
||||
|
||||
public function test_invalid_business_purpose_is_rejected_by_the_action(): void
|
||||
{
|
||||
$block = $this->import($this->property());
|
||||
|
||||
try {
|
||||
app(ClassifyPortalOccupation::class)->handle($block, OccupationKind::Block, details: ['block_purpose' => 'invented-purpose']);
|
||||
$this->fail('Unknown purposes must be rejected.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertArrayHasKey('block_purpose', $exception->errors());
|
||||
}
|
||||
|
||||
$this->assertNull($block->fresh()->occupation_kind);
|
||||
}
|
||||
|
||||
public function test_a_guest_with_only_known_information_can_be_created_and_assigned_from_portal_details(): void
|
||||
{
|
||||
$property = $this->property();
|
||||
|
||||
Reference in new issue
Block a user