Buchungsakte: Vorgang, naechster Schritt, Vertrag, Mailverlauf, Storno mit Mail, Archiv
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s

- Buchungsseite zeigt Art des Vorgangs, Verlaufsleiste und den naechsten Schritt in Klartext
- Vertragsabschnitt (Vorlage, Dokumente mit Pruefsumme, Zustellung) und Vertragstext-Ansicht
- Reiter Aufgaben und Mailverlauf (jede Mail zur Buchung wird protokolliert)
- Stornieren in der Verwaltung informiert Gast und Vermieter und legt eine Aufgabe fuer Stornokosten an
- Stornierte/abgelehnte/abgelaufene Buchungen aus der Hauptliste, Filter Archiv anzeigen

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-10-30 16:16:42 +01:00
1 parent 89d569b6c8
commit 5baf39441f
15 files changed
+684 -7

No files matched your search

@@ -8,7 +8,9 @@
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\RelationManagers\MessagesRelationManager;
use App\Filament\Resources\Bookings\RelationManagers\PaymentsRelationManager;
use App\Filament\Resources\Bookings\RelationManagers\TasksRelationManager;
use App\Filament\Resources\Bookings\Schemas\BookingForm;
use App\Filament\Resources\Bookings\Schemas\BookingInfolist;
use App\Filament\Resources\Bookings\Tables\BookingsTable;
@@ -72,6 +74,8 @@ public static function getRelations(): array
{
return [
PaymentsRelationManager::class,
TasksRelationManager::class,
MessagesRelationManager::class,
];
}
@@ -2,6 +2,7 @@
namespace App\Filament\Resources\Bookings\Pages;
use App\Actions\CancelBooking;
use App\Actions\ConfirmBooking;
use App\Actions\DeclineBooking;
use App\Actions\SendOffer;
@@ -189,6 +190,16 @@ protected function getHeaderActions(): array
$notification = Notification::make()->title($sent ? 'Bestätigung gesendet' : 'Versand fehlgeschlagen');
($sent ? $notification->success() : $notification->danger()->body('Details im Postfach.'))->send();
}),
Action::make('contractText')
->label('Vertragstext ansehen')
->icon(Heroicon::OutlinedDocumentMagnifyingGlass)
->color('gray')
->visible(fn (): bool => $this->record->offer_terms !== null)
->modalHeading(fn (): string => 'Vertrag '.$this->record->reference)
->modalContent(fn () => view('filament.booking-contract', ['booking' => $this->record]))
->modalSubmitAction(false)
->modalCancelActionLabel('Schließen')
->modalWidth('4xl'),
Action::make('contract')
->label('Mietvertrag')
->icon(Heroicon::OutlinedDocumentText)
@@ -209,12 +220,23 @@ protected function getHeaderActions(): array
->icon(Heroicon::OutlinedNoSymbol)
->color('danger')
->visible(fn (): bool => in_array($this->record->status, BookingStatus::occupying(), true))
->requiresConfirmation()
->modalDescription('Der Zeitraum wird wieder freigegeben. Der Gast wird nicht automatisch benachrichtigt.')
->action(function (): void {
$this->record->update(['status' => BookingStatus::Cancelled, 'cancelled_at' => now()]);
->modalHeading('Buchung stornieren')
->modalDescription('Der Zeitraum wird wieder freigegeben. Gast und Vermieter erhalten eine Stornierungs-E-Mail; die Stornokosten bleiben als Aufgabe offen.')
->schema([
Toggle::make('notify_guest')->label('Gast per E-Mail informieren')->default(true),
Toggle::make('costs_task')->label('Aufgabe „Stornokosten prüfen“ anlegen')->default(true),
])
->action(function (array $data, CancelBooking $cancel): void {
try {
$informed = $cancel->handle($this->record, (bool) $data['notify_guest'], (bool) $data['costs_task'], auth()->user()->name);
} catch (ReservationException $exception) {
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
Notification::make()->title('Buchung storniert')->success()->send();
return;
}
$notification = Notification::make()->title('Buchung storniert');
($informed ? $notification->success() : $notification->warning()->body('Die Mail an den Gast konnte nicht gesendet werden – bitte den Gast selbst informieren.'))->send();
}),
]),
];
@@ -0,0 +1,40 @@
<?php
namespace App\Filament\Resources\Bookings\RelationManagers;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
/**
* Communication log: every e-mail that went out for this booking.
*/
class MessagesRelationManager extends RelationManager
{
protected static string $relationship = 'messages';
protected static ?string $title = 'Mailverlauf';
public function isReadOnly(): bool
{
return true;
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('subject')
->defaultSort('sent_at', 'desc')
->emptyStateHeading('Noch keine E-Mails zu dieser Buchung')
->description('Betreff und Empfängerart jeder E-Mail zu dieser Buchung. Im Testbetrieb gehen alle Mails an die Testadresse.')
->columns([
TextColumn::make('sent_at')->label('Gesendet')->dateTime('d.m.Y, H:i'),
TextColumn::make('audience')->label('An')->badge()->formatStateUsing(fn (string $state): string => match ($state) {
'guest' => 'Gast',
'landlord' => 'Vermieter',
default => 'Testadresse',
}),
TextColumn::make('subject')->label('Betreff')->wrap(),
]);
}
}
@@ -0,0 +1,48 @@
<?php
namespace App\Filament\Resources\Bookings\RelationManagers;
use App\Enums\BookingTaskStatus;
use App\Models\BookingTask;
use Filament\Actions\Action;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
/**
* Tasks of this booking (payment reminders, cancellation requests and costs).
*/
class TasksRelationManager extends RelationManager
{
protected static string $relationship = 'tasks';
protected static ?string $title = 'Aufgaben';
public function isReadOnly(): bool
{
return false;
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('kind')
->defaultSort('created_at', 'desc')
->emptyStateHeading('Keine Aufgaben zu dieser Buchung')
->columns([
TextColumn::make('kind')->label('Aufgabe')->badge(),
TextColumn::make('status')->label('Status')->badge(),
TextColumn::make('due_on')->label('Seit / fällig')->date('d.m.Y')->placeholder('–'),
TextColumn::make('note')->label('Hinweis')->wrap()->placeholder('–'),
])
->recordActions([
Action::make('done')
->label('Erledigt')
->icon(Heroicon::OutlinedCheck)
->color('success')
->visible(fn (BookingTask $record): bool => $record->status === BookingTaskStatus::Open)
->action(fn (BookingTask $record) => $record->complete(auth()->user()->name)),
]);
}
}
@@ -3,24 +3,68 @@
namespace App\Filament\Resources\Bookings\Schemas;
use App\Models\Booking;
use App\Support\BookingProgress;
use App\Support\Money;
use Carbon\CarbonImmutable;
use Filament\Infolists\Components\RepeatableEntry;
use Filament\Infolists\Components\RepeatableEntry\TableColumn;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Support\HtmlString;
class BookingInfolist
{
/**
* The steps of the process as a row of chips.
*/
private static function timeline(Booking $booking): HtmlString
{
$style = [
'done' => 'background:#dcfce7;color:#14532d',
'current' => 'background:#fef3c7;color:#78350f;font-weight:700',
'todo' => 'background:#f3f4f6;color:#4b5563',
'skipped' => 'background:#f3f4f6;color:#9ca3af;text-decoration:line-through',
];
$icon = ['done' => '✓ ', 'current' => '● ', 'todo' => '', 'skipped' => ''];
return new HtmlString('<div style="display:flex;flex-wrap:wrap;gap:.4rem">'.collect(BookingProgress::steps($booking))->map(fn (array $step): string => '<span style="padding:.25rem .6rem;border-radius:999px;font-size:.8rem;'.$style[$step['state']].'">'.$icon[$step['state']].e($step['label']).($step['detail'] ? ' · '.e($step['detail']) : '').'</span>')->implode('').'</div>');
}
public static function configure(Schema $schema): Schema
{
return $schema
->columns(3)
->components([
Section::make('Vorgang')
->columnSpanFull()
->schema([
TextEntry::make('process')->label('Art des Vorgangs')->state(fn (Booking $record): string => BookingProgress::kindLabel($record)),
TextEntry::make('next')
->label(fn (Booking $record): string => 'Nächster Schritt: '.BookingProgress::next($record)['title'])
->state(fn (Booking $record): string => BookingProgress::next($record)['text'])
->color(fn (Booking $record): string => BookingProgress::next($record)['color'])
->weight('bold'),
TextEntry::make('steps')
->label('Verlauf')
->state(fn (Booking $record): HtmlString => self::timeline($record))
->html()
->columnSpanFull(),
]),
Grid::make(1)
->columnSpan(2)
->schema([
Section::make('Vertrag')
->columns(2)
->schema([
TextEntry::make('contract_template')->label('Vorlage')->state(fn (Booking $record): string => isset($record->offer_terms['template']) ? $record->offer_terms['template']['name'].' (Version '.$record->offer_terms['template']['version'].')' : ($record->offer_terms ? 'Texte der Webseite (Stand '.CarbonImmutable::parse($record->offer_terms['captured_at'])->format('d.m.Y').')' : 'Noch kein Angebot / Vertrag')),
TextEntry::make('contract_state')->label('Dokumente')->state(fn (Booking $record): string => collect([
$record->offer_path ? 'Angebot (PDF) Version '.$record->offer_version : null,
$record->contract_path ? 'Mietvertrag (PDF, unveränderlich, Prüfsumme '.substr((string) $record->contract_pdf_sha256, 0, 10).')' : null,
])->filter()->implode(' · ') ?: 'Noch kein Dokument – der Vertrag entsteht mit dem Angebot bzw. der Bestätigung'),
TextEntry::make('contract_mail')->label('Zustellung')->state(fn (Booking $record): string => $record->confirmation_sent_at ? 'Bestätigung mit Vertrag gesendet am '.$record->confirmation_sent_at->format('d.m.Y, H:i') : ($record->confirmation_failed_at ? 'Versand fehlgeschlagen' : 'Noch nicht gesendet'))->columnSpanFull(),
]),
Section::make('Aufenthalt')
->columns(3)
->schema([
@@ -37,6 +37,9 @@ public static function configure(Table $table, ?int $guestId = null): Table
}
if (filled($filters['status']['values'] ?? [])) {
$records = $records->whereIn('status_key', $filters['status']['values']);
} elseif (! ($filters['show_closed']['isActive'] ?? false)) {
// Cancelled, declined and expired requests leave the main list (they stay available as archive).
$records = $records->reject(fn (array $record): bool => in_array($record['status_key'], ['cancelled', 'declined', 'expired'], true));
}
$column = in_array($sortColumn, ['arrival', 'departure', 'reference', 'guest', 'source', 'total'], true) ? $sortColumn : 'arrival';
$records = $records->sortBy($column, SORT_REGULAR, $sortDirection === 'desc');
@@ -69,6 +72,7 @@ public static function configure(Table $table, ?int $guestId = null): Table
'imported' => 'Im Portalkalender geführt', 'archived' => 'Nicht mehr im Kalenderfeed',
]),
Filter::make('upcoming')->label('Nur kommende Aufenthalte'),
Filter::make('show_closed')->label('Archiv anzeigen (storniert, abgelehnt, abgelaufen)'),
Filter::make('without_guest')->label('Gastzuordnung offen'),
])
->recordUrl(fn (array $record): string => $record['url'])