Doppelbuchungen nur einmal melden und im Postfach der Verwaltung zeigen

Der Kalenderabgleich alle 5 Minuten hat jede fortbestehende Ueberschneidung
erneut gemailt. ReportChannelConflicts legt jede Ueberschneidung einmal im
neuen Postfach (InboxMessage, Fingerabdruck je Mandant) ab und mailt nur neue.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-10-30 09:52:35 +01:00
1 parent 876a0a20f3
commit b9225f5fb8
17 files changed
+593 -15

No files matched your search

+29
View File
@@ -10,6 +10,7 @@
use App\Enums\BookingStatus;
use App\Enums\ChannelTaskAction;
use App\Enums\ChannelTaskStatus;
use App\Enums\InboxMessageKind;
use App\Filament\Resources\ChannelTasks\Pages\ListChannelTasks;
use App\Filament\Resources\Properties\Pages\EditProperty;
use App\Filament\Resources\Properties\RelationManagers\ChannelsRelationManager;
@@ -21,6 +22,7 @@
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 Carbon\CarbonImmutable;
@@ -118,6 +120,33 @@ public function test_overlap_with_an_existing_booking_is_reported_as_possible_do
$this->assertSame(1, $log->conflicts);
Mail::assertSent(ChannelConflict::class);
$message = InboxMessage::sole();
$this->assertSame(InboxMessageKind::ChannelConflict, $message->kind);
$this->assertSame($this->property->id, $message->property_id);
$this->assertStringContainsString('überschneidet sich mit Buchung', $message->body);
$this->assertStringContainsString('monat=2026-11', $message->action_url);
}
public function test_a_lasting_double_booking_is_reported_once_however_often_the_calendar_is_synced(): void
{
$booking = Booking::factory()->for($this->property)->create(['arrival' => '2026-11-08', 'departure' => '2026-11-12', 'status' => BookingStatus::Confirmed]);
$channel = $this->channel('FeWo-direkt');
$this->fakeFeed([['x1', '20261107', '20261110']]);
foreach (range(1, 3) as $run) {
$this->travel(5)->minutes();
$log = (new SyncChannel)->handle($channel);
$this->assertSame(1, $log->conflicts, 'the sync log keeps counting the open conflict');
}
Mail::assertSentCount(1);
$this->assertSame(1, InboxMessage::count());
$booking->update(['departure' => '2026-11-13']);
(new SyncChannel)->handle($channel);
Mail::assertSent(ChannelConflict::class, 2);
$this->assertSame(2, InboxMessage::count());
}
public function test_failed_import_is_logged_and_alerted_once_until_it_works_again(): void