Akte auch fuer Portal-Reservierungen aus dem Kalender, Ablauf mit Aktivitaeten, Verlauf, Standardprozess je Portal
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m34s

- Akte anlegen aus einer importierten Portal-Reservierung (Belegung bleibt durchgehend belegt, Kalendereintrag wird Spiegelung)
- Akte: Standardprozess (Portal/Vorlage/Storno/Anlagen), Meilensteine mit Aktivitaeten und Aktionshinweis, chronologischer Verlauf
- Kanalformular: Abschnitt Standardprozess je Buchungstyp mit Anzeige, was die Vorlage mitbringt
- Portalpreis als gemeinsame Logik (PortalPrice)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-10-30 18:56:32 +01:00
1 parent 5ba9ae08ab
commit 81c025f1ee
10 files changed
+450 -75

No files matched your search

@@ -2,6 +2,7 @@
namespace App\Filament\Resources\Bookings\Schemas;
use App\Documents\OfferTerms;
use App\Models\Booking;
use App\Support\BookingProgress;
use App\Support\Money;
@@ -17,19 +18,59 @@
class BookingInfolist
{
/**
* The steps of the process as a row of chips.
* The process as a checklist: every milestone with its state and the activities that belong to it. Open
* activities name the action on this page that does them.
*/
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',
$badge = [
'done' => ['✓', '#16a34a', 'erledigt'],
'current' => ['●', '#d97706', 'jetzt'],
'todo' => ['○', '#9ca3af', 'später'],
'skipped' => ['–', '#9ca3af', 'entfällt'],
];
$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>');
$rows = collect(BookingProgress::steps($booking))->map(function (array $step) use ($badge): string {
[$icon, $color, $word] = $badge[$step['state']];
$activities = collect($step['activities'])->map(fn (array $activity): string => '<li style="margin:.15rem 0;'.($activity['done'] ? 'color:#15803d' : '').'">'.($activity['done'] ? '✓ ' : '○ ').e($activity['label']).($activity['action'] && $step['state'] !== 'skipped' ? ' <span style="color:#b45309">→ Aktion „'.e($activity['action']).'“</span>' : '').'</li>')->implode('');
return '<div style="display:flex;gap:.75rem;padding:.55rem 0;border-bottom:1px solid rgba(128,128,128,.25)">'
.'<div style="width:1.6rem;text-align:center;font-weight:700;color:'.$color.'" title="'.$word.'">'.$icon.'</div>'
.'<div style="flex:1"><div style="'.($step['state'] === 'current' ? 'font-weight:700' : '').($step['state'] === 'skipped' ? ';color:#9ca3af' : '').'">'.e($step['label']).($step['detail'] ? ' <span style="font-weight:400;color:#6b7280">· '.e($step['detail']).'</span>' : '').'</div>'
.($activities !== '' ? '<ul style="list-style:none;padding:0;margin:.2rem 0 0;font-size:.85rem">'.$activities.'</ul>' : '').'</div></div>';
})->implode('');
return new HtmlString('<div>'.$rows.'</div>');
}
/**
* What has happened so far, oldest first.
*/
private static function chronicle(Booking $booking): HtmlString
{
$rows = collect(BookingProgress::history($booking))->map(fn (array $event): string => '<li style="margin:.2rem 0"><span style="color:#6b7280">'.$event['at']->format('d.m.Y H:i').'</span> · '.e($event['label']).'</li>')->implode('');
return new HtmlString('<ul style="list-style:none;padding:0;margin:0;font-size:.9rem">'.$rows.'</ul>');
}
/**
* The standard process that applies to this booking: which template (with cancellation rule and annexes) comes from
* the portal and booking type, and whether payments become tasks.
*/
private static function setup(Booking $booking): string
{
$channel = $booking->importChannel ?? $booking->originChannel;
$template = OfferTerms::templateFor($booking);
$policy = $template?->cancellationPolicy;
$annexes = $template?->annexesFor($booking)->map(fn ($annex) => $annex->name)->implode(', ');
return collect([
$channel ? 'Portal: '.$channel->name : 'Eigene Buchung (Webseite / manuell)',
'Vertragsvorlage: '.($template ? $template->label() : 'Texte der Webseite'),
'Stornoregel: '.($policy ? $policy->name : 'keine hinterlegt'),
'Anlagen: '.($annexes ?: 'keine'),
'Zahlungsaufgaben: '.($booking->wantsPaymentTasks() ? 'ja' : 'nein (läuft über das Portal)'),
])->implode(' · ');
}
public static function configure(Schema $schema): Schema
@@ -46,11 +87,20 @@ public static function configure(Schema $schema): Schema
->state(fn (Booking $record): string => BookingProgress::next($record)['text'])
->color(fn (Booking $record): string => BookingProgress::next($record)['color'])
->weight('bold'),
TextEntry::make('setup')
->label('Standardprozess (aus Portal und Buchungstyp)')
->state(fn (Booking $record): string => self::setup($record))
->columnSpanFull(),
TextEntry::make('steps')
->label('Verlauf')
->label('Ablauf: Meilensteine und Aktivitäten')
->state(fn (Booking $record): HtmlString => self::timeline($record))
->html()
->columnSpanFull(),
TextEntry::make('chronicle')
->label('Bisheriger Verlauf')
->state(fn (Booking $record): HtmlString => self::chronicle($record))
->html()
->columnSpanFull(),
]),
Grid::make(1)
->columnSpan(2)
@@ -102,6 +102,6 @@ public static function configure(Table $table, ?int $guestId = null): Table
Filter::make('without_guest')->label('Gastzuordnung offen'),
])
->recordUrl(fn (array $record): string => $record['url'])
->recordActions([Action::make('view')->label(fn (array $record): string => $record['record_type'] === 'booking' ? 'Akte öffnen' : 'Details')->icon('heroicon-o-folder-open')->button()->color('primary')->url(fn (array $record): string => $record['url'])]);
->recordActions([Action::make('view')->label(fn (array $record): string => $record['record_type'] === 'booking' ? 'Akte öffnen' : ($record['kind'] === 'block' ? 'Details' : 'Akte anlegen'))->icon('heroicon-o-folder-open')->button()->color('primary')->url(fn (array $record): string => $record['url'])]);
}
}
@@ -8,6 +8,7 @@
use App\Enums\ChannelExportMode;
use App\Enums\ChannelStatus;
use App\Models\Channel;
use App\Models\ContractAnnex;
use App\Models\ContractTemplate;
use App\Models\Property;
use App\Support\CurrentProperty;
@@ -18,6 +19,7 @@
use Filament\Forms\Components\Toggle;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Group;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
@@ -51,24 +53,32 @@ public static function configure(Schema $schema, bool $selectProperty = false):
Select::make('status')->label('Kanalstatus')->options(ChannelStatus::class)->default(ChannelStatus::Setup)->required(),
Select::make('booking_model')->label('Buchungsmodell')->options(ChannelBookingModel::class)->default(ChannelBookingModel::Mixed)->required()
->helperText('„Portalbuchung“ und „Gemischt“ gelten als Sofortbuchung: automatische Angebote für diese Wohnung warten, bis das Portal unseren Kalender abgerufen hat. „Vermittlung / Anfrage“: keine Sofortbuchung.'),
Select::make('contract_template_id')
->label('Vertragsvorlage für Anfragen / Angebote über dieses Portal')
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
->placeholder('Standard der Wohnung')
->helperText('Für Angebote zu Buchungen, die über dieses Portal kommen und dessen Vorgaben (z. B. Stornofristen) entsprechen müssen.'),
Select::make('contract_template_reservation_id')
->label('Vertragsvorlage für Buchungen, die beim Portal verbindlich sind')
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
->placeholder('wie bei Anfragen')
->helperText('Z. B. der FeWo-direkt-Vertrag für Direktbuchungen (Zahlung läuft über das Portal).'),
Toggle::make('payment_tasks_inquiry')
->label('Zahlungsaufgaben bei Anfragen über dieses Portal')
->helperText('Fällige Anzahlungen/Restzahlungen erscheinen als Aufgabe (Mails an Gäste gehen nie automatisch).')
->default(true),
Toggle::make('payment_tasks_reservation')
->label('Zahlungsaufgaben bei Reservierungen über dieses Portal')
->helperText('Aus, wenn das Portal das Geld einzieht und mahnt (z. B. FeWo-direkt Online-Buchung).')
->default(false),
Section::make('Standardprozess für Buchungen über dieses Portal')
->description('Hier legen Sie fest, was bei einer Buchung über dieses Portal gilt – getrennt nach Buchungstyp. Die Vertragsvorlage bringt Vertragstext, Stornoregel und Vertragsanlagen mit (Menü Einrichtung › Vertragsvorlagen). Der Ablauf selbst (Kontaktdaten, Vertrag, Zahlung, Anreise) steht in der Akte jeder Buchung.')
->columns(2)
->columnSpanFull()
->schema([
Select::make('contract_template_id')
->label('Anfrage über dieses Portal: Vertragsvorlage')
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
->placeholder('Standard der Wohnung')
->live()
->helperText(fn (Get $get): string => self::templateSummary($get('contract_template_id'), 'Wir antworten persönlich, Angebot und Vertrag kommen von uns. ')),
Select::make('contract_template_reservation_id')
->label('Buchung beim Portal verbindlich: Vertragsvorlage')
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
->placeholder('wie bei Anfragen')
->live()
->helperText(fn (Get $get): string => self::templateSummary($get('contract_template_reservation_id') ?? $get('contract_template_id'), 'Das Portal hat die Buchung schon verbindlich gemacht, wir senden den Vertrag. ')),
Toggle::make('payment_tasks_inquiry')
->label('Anfrage über dieses Portal: Zahlungsaufgaben anlegen')
->helperText('Fällige Anzahlungen/Restzahlungen erscheinen als Aufgabe (Mails an Gäste gehen nie automatisch).')
->default(true),
Toggle::make('payment_tasks_reservation')
->label('Buchung beim Portal verbindlich: Zahlungsaufgaben anlegen')
->helperText('Aus, wenn das Portal das Geld einzieht und mahnt (z. B. FeWo-direkt Online-Buchung).')
->default(false),
]),
Select::make('connector')
->label('Kalenderanbindung')
->helperText('Diese Verbindung gleicht Belegungszeiträume über iCal ab. Weitere Portalfunktionen benötigen eine eigene Anbindung.')
@@ -114,4 +124,19 @@ public static function configure(Schema $schema, bool $selectProperty = false):
->columnSpanFull(),
]);
}
/**
* What a contract template brings along, shown under the template choice.
*/
private static function templateSummary(mixed $templateId, string $intro): string
{
$template = filled($templateId) ? ContractTemplate::query()->with('cancellationPolicy')->find($templateId) : null;
if ($template === null) {
return $intro.'Ohne Auswahl gilt die Vorlage der Wohnung bzw. die Texte der Webseite.';
}
$annexes = ContractAnnex::query()->whereIn('id', (array) ($template->annex_ids ?? []))->orderBy('name')->pluck('name')->implode(', ');
return $intro.'Die Vorlage bringt mit: Stornoregel '.($template->cancellationPolicy?->name ?? '– keine –').' · Anlagen: '.($annexes ?: 'keine').'.';
}
}
@@ -3,7 +3,9 @@
namespace App\Filament\Resources\PortalOccupations;
use App\Actions\ClassifyPortalOccupation;
use App\Actions\OpenPortalFile;
use App\Enums\OccupationKind;
use App\Exceptions\ReservationException;
use App\Filament\Actions\AssignGuestAction;
use App\Filament\Concerns\FollowsAdminMode;
use App\Filament\Concerns\SelectsRecordProperty;
@@ -78,18 +80,61 @@ 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([ViewAction::make(), ActionGroup::make(static::occupationActions())->label('Weitere Aktionen')]);
])->recordActions([Action::make('fileLink')->label('Akte anlegen')->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(): array
public static function occupationActions(bool $withFile = true): array
{
return [
...($withFile ? [static::openFileAction(), static::showFileAction()] : []),
AssignGuestAction::make(),
static::classificationAction(),
...BlockedPeriodResource::portalActions(),
];
}
/**
* Opens the booking file (workflow, contract, payments, tasks) for a reservation from a portal calendar.
*/
public static function openFileAction(): Action
{
return Action::make('openFile')->label('Akte anlegen')->icon(Heroicon::OutlinedFolderPlus)->color('primary')
->visible(fn (BlockedPeriod $record): bool => static::canOpenFile($record))
->authorize(fn (BlockedPeriod $record): bool => auth()->user()?->can('update', $record) ?? false)
->requiresConfirmation()
->modalHeading('Akte für diese Reservierung anlegen')
->modalDescription('Aus der Kalenderbelegung wird eine Buchung mit Ablauf: Kontaktdaten, Vertrag, Zahlungen, Anreise, Storno. Der Zeitraum bleibt durchgehend belegt. Gast, Personenzahl und Preis sind noch unbekannt und werden in der Akte ergänzt.')
->action(function (BlockedPeriod $record, OpenPortalFile $open) {
try {
$booking = $open->handle($record);
} catch (ReservationException $exception) {
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
return null;
}
Notification::make()->title('Akte angelegt')->success()->send();
return redirect(BookingResource::getUrl('view', ['record' => $booking]));
});
}
public static function showFileAction(): Action
{
return Action::make('showFile')->label('Akte öffnen')->icon(Heroicon::OutlinedFolderOpen)->color('primary')
->visible(fn (BlockedPeriod $record): bool => $record->linked_booking_id !== null)
->url(fn (BlockedPeriod $record): ?string => $record->linked_booking_id ? BookingResource::getUrl('view', ['record' => $record->linked_booking_id]) : null);
}
/**
* Whether the calendar entry is a reservation that can still get its own booking file.
*/
public static function canOpenFile(BlockedPeriod $record): bool
{
return in_array($record->source, ['channel', 'email'], true) && ! $record->trashed() && ! $record->is_representation
&& $record->channel_id !== null && $record->occupationKind() !== OccupationKind::Block;
}
public static function classificationAction(): Action
{
return Action::make('classify')->label('Einordnen: Reservierung, Sperrzeit oder unbekannt')