Ein Eingang fuer alle Kanaele (Paket 4, Prozessarchitektur v0.10)

Portalbuchungen und -anfragen aus Kalender und Mail werden ueber PortalIntake
zum Vorgang (nur bei sicherer Erkennung), Dubletten ueber Buchungsnummer,
gleiches Portal mit gleichen Naechten und Spiegelung; Unsicheres wird geklaert.
Portalstorno und -aenderung als Aufgabe am Vorgang ohne stille Stornierung.
Schalter je Kanal (Aus als Standard, Beobachten, Anlegen, Anlegen + weiter),
Eingangsprotokoll, Bestandsuebernahme mit Vorschau/Bericht/Ruecknahme,
Sperrnachweis in drei Stufen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-01 20:53:35 +01:00
1 parent cf11c8a474
commit ac9d20b812
29 files changed
+1952 -16

No files matched your search

@@ -4,6 +4,7 @@
use App\Actions\ClassifyPortalOccupation;
use App\Actions\OpenPortalFile;
use App\Actions\ResolveChannelOccupation;
use App\Enums\OccupationKind;
use App\Exceptions\ReservationException;
use App\Filament\Actions\AssignGuestAction;
@@ -15,11 +16,13 @@
use App\Filament\Resources\PortalOccupations\Pages\ManagePortalOccupations;
use App\Filament\Resources\PortalOccupations\Pages\ViewPortalOccupation;
use App\Models\BlockedPeriod;
use App\Models\Booking;
use App\Models\Channel;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Actions\ViewAction;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\Select;
use Filament\Infolists\Components\TextEntry;
use Filament\Notifications\Notification;
@@ -80,19 +83,85 @@ public static function table(Table $table): Table
TextColumn::make('channel.name')->label('Importkanal'),
TextColumn::make('property.name')->label('Wohnung')->toggleable(),
TextColumn::make('needs_review')->label('Prüffall')->formatStateUsing(fn (bool $state): string => $state ? 'Bitte prüfen' : '–')->description(fn (BlockedPeriod $record): ?string => $record->review_note),
])->recordActions([Action::make('fileLink')->label('Als Buchung übernehmen')->icon(Heroicon::OutlinedFolderPlus)->button()->color('primary')->visible(fn (BlockedPeriod $record): bool => static::canOpenFile($record))->url(fn (BlockedPeriod $record): string => static::getUrl('view', ['record' => $record])), static::showFileAction()->button(), ViewAction::make(), ActionGroup::make(static::occupationActions(withFile: false))->label('Weitere Aktionen')]);
])->recordActions([Action::make('clarifyLink')->label('Klären')->icon(Heroicon::OutlinedQuestionMarkCircle)->button()->color('warning')->visible(fn (BlockedPeriod $record): bool => static::isUnclear($record))->url(fn (BlockedPeriod $record): string => static::getUrl('view', ['record' => $record])), Action::make('fileLink')->label('Als Buchung übernehmen')->icon(Heroicon::OutlinedFolderPlus)->button()->color('primary')->visible(fn (BlockedPeriod $record): bool => static::canOpenFile($record))->url(fn (BlockedPeriod $record): string => static::getUrl('view', ['record' => $record])), static::showFileAction()->button(), ViewAction::make(), ActionGroup::make(static::occupationActions(withFile: false))->label('Weitere Aktionen')]);
}
public static function occupationActions(bool $withFile = true): array
{
return [
...($withFile ? [static::openFileAction(), static::showFileAction()] : []),
...($withFile ? [static::clarifyAction(), static::openFileAction(), static::showFileAction()] : []),
AssignGuestAction::make(),
static::classificationAction(),
...BlockedPeriodResource::portalActions(),
];
}
/**
* Whether the entry still waits for the landlord's answer (it is listed under "Zu erledigen").
*/
public static function isUnclear(BlockedPeriod $record): bool
{
return ! $record->trashed() && BlockedPeriod::query()->unclear()->whereKey($record->id)->exists();
}
/**
* The one question for an unclear portal entry, in plain words: is it a booking (then it becomes a case), does it
* belong to a case that already exists, or is it no booking at all? The detailed tools stay under "Weitere".
*/
public static function clarifyAction(): Action
{
return Action::make('clarify')->label('Klären: Was ist das?')->icon(Heroicon::OutlinedQuestionMarkCircle)->color('primary')
->visible(fn (BlockedPeriod $record): bool => static::isUnclear($record) && ! $record->is_representation)
->authorize(fn (BlockedPeriod $record): bool => auth()->user()?->can('update', $record) ?? false)
->modalHeading(fn (BlockedPeriod $record): string => 'Belegung von '.($record->channel?->name ?? 'einem Portal').' am '.$record->starts_on->format('d.m.').'–'.$record->ends_on->format('d.m.Y'))
->modalDescription(fn (BlockedPeriod $record): string => 'Für diesen Zeitraum wurde eine Belegung gemeldet. Bitte wählen Sie, was es ist.'.($record->review_note ? ' Hinweis: '.$record->review_note : ''))
->modalSubmitActionLabel('Übernehmen')
->schema(fn (BlockedPeriod $record): array => [
Radio::make('answer')->hiddenLabel()->required()->live()->options(array_filter([
'booking' => static::canOpenFile($record) ? 'Eine Buchung über '.($record->channel?->name ?? 'das Portal').' – als Vorgang übernehmen' : null,
'case' => static::sameNightCases($record) !== [] ? 'Gehört zu einem Vorgang, der schon da ist' : null,
'block' => 'Keine Buchung: Sperre, eigene Nutzung oder Spiegelung eines anderen Portals',
])),
Select::make('booking_id')->label('Vorgang')->options(fn (): array => static::sameNightCases($record))
->visible(fn (Get $get): bool => $get('answer') === 'case')->required(fn (Get $get): bool => $get('answer') === 'case'),
])
->action(function (BlockedPeriod $record, array $data, OpenPortalFile $open, ResolveChannelOccupation $resolve, ClassifyPortalOccupation $classify) {
try {
if ($data['answer'] === 'booking') {
$booking = $open->handle($record);
Notification::make()->title('Als Buchung übernommen')->success()->send();
return redirect(BookingResource::getUrl('view', ['record' => $booking]));
}
if ($data['answer'] === 'case') {
$resolve->handle($record, 'booking', (int) $data['booking_id']);
Notification::make()->title('Dem Vorgang zugeordnet')->success()->send();
return null;
}
$classify->handle($record, OccupationKind::Block);
$record->refresh()->forceFill(['needs_review' => false, 'reviewed_at' => now(), 'review_note' => 'Persönlich als Sperre eingeordnet.'])->save();
Notification::make()->title('Als Sperre eingeordnet')->success()->send();
} catch (ReservationException $exception) {
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
}
return null;
});
}
/**
* Cases of the same property with exactly these nights (the only ones the entry may belong to).
*
* @return array<int, string>
*/
public static function sameNightCases(BlockedPeriod $record): array
{
return Booking::query()->occupying()->with('guest')->where('property_id', $record->property_id)
->whereDate('arrival', $record->starts_on)->whereDate('departure', $record->ends_on)->get()
->mapWithKeys(fn (Booking $booking): array => [$booking->id => $booking->reference.' · '.$booking->guestName().' · '.$booking->bookingChannelLabel()])->all();
}
/**
* Takes a reservation from a portal calendar over as a case (no second, manual "file").
*/