Files
fewo-stommer/app/Process/WorkList.php
T
LarsandClaude Opus 5.5 3a728c3255 Vorgangskern und geführte Vorgangsbearbeitung (Pakete 1 und 2, Prozessarchitektur v0.10)
- Buchung ist der einheitliche Vorgang: Eingangsart, Vorgangsart A1–A6, eingefrorenes
  Abwicklungsprofil, gespeicherter Verlauf (booking_events); Gast, Personen und Beträge
  dürfen unbekannt sein, Platzhalter-Gäste werden migriert und nicht mehr angelegt
- Einstellungen in Ebenen: Vermieterstandard (So arbeite ich), Abweichung der Wohnung
  (Experte), Abweichung je Portal und Eingangsart; ersetzt booking_model als Steuergröße
- Ein Weg für extern verbindliche Buchungen (TakeOverExternalBooking) statt
  RecordPortalBooking und "Akte anlegen"; Portalpreis als belegte Gesamtposition
- Startseite "Zu erledigen", neue Vorgangsseite mit nächstem Schritt, Automatik-Schalter,
  "Beenden" mit Storno statt Statusumschaltung; Status von Hand nur im Expertenmodus
- Migration übernimmt bisheriges Verhalten unverändert (abweichende Wohnungswerte bleiben
  als Abweichung), Bericht: php artisan process:settings-report

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 16:25:46 +01:00

90 lines
4.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Process;
use App\Enums\ActivityState;
use App\Enums\BookingStatus;
use App\Enums\ChannelTaskAction;
use App\Filament\Resources\Bookings\BookingResource;
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
use App\Filament\Resources\InboxMessages\InboxMessageResource;
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
use App\Models\BlockedPeriod;
use App\Models\Booking;
use App\Models\ChannelTask;
use App\Models\InboxMessage;
/**
* "Zu erledigen": everything the landlord has to do, in one list – the next step of every open case, portals to block
* or release, calendar entries nobody knows yet and system notices that need a decision. Each entry names the thing in
* plain words and leads to the one place where it is done.
*/
class WorkList
{
/**
* @return list<array{title: string, detail: ?string, url: string, button: string, tone: string, sort: string}>
*/
public static function items(): array
{
$items = [];
$cases = Booking::query()
->with(['guest', 'property', 'payments', 'importChannel', 'originChannel'])
->whereNull('archived_at')
->whereNotIn('status', [BookingStatus::Declined, BookingStatus::Expired, BookingStatus::Completed])
->where(fn ($query) => $query->whereNot('status', BookingStatus::Cancelled)->orWhereHas('tasks', fn ($tasks) => $tasks->where('status', 'open')))
->get();
foreach ($cases as $case) {
$next = CaseActivities::next($case);
if ($next === null) {
continue;
}
$items[] = [
'title' => $next->label,
'detail' => $case->guestName().' · '.$case->arrival->format('d.m.').'–'.$case->departure->format('d.m.Y').' · '.$case->property->name.($next->detail ? ' · '.$next->detail : ''),
'url' => BookingResource::getUrl('view', ['record' => $case]),
'button' => 'Vorgang öffnen',
'tone' => $next->state === ActivityState::Problem ? 'danger' : 'warning',
'sort' => ($next->state === ActivityState::Problem ? '0' : '1').$case->arrival->format('Ymd'),
];
}
foreach (ChannelTask::query()->open()->with('channel.property')->orderBy('starts_on')->get() as $task) {
$items[] = [
'title' => ($task->action === ChannelTaskAction::Block ? 'In '.$task->channel?->name.' sperren' : 'In '.$task->channel?->name.' wieder freigeben'),
'detail' => $task->period().' · '.$task->channel?->property?->name.' · '.$task->reason,
'url' => ChannelTaskResource::getUrl(),
'button' => 'Erledigen',
'tone' => 'danger',
'sort' => '0'.$task->starts_on->format('Ymd'),
];
}
foreach (BlockedPeriod::query()->unclear()->with(['channel', 'property'])->whereDate('ends_on', '>=', today())->orderBy('starts_on')->get() as $occupation) {
$items[] = [
'title' => 'Unbekannte Belegung von '.($occupation->channel?->name ?? 'einem Portal').' – was ist das?',
'detail' => $occupation->starts_on->format('d.m.').'–'.$occupation->ends_on->format('d.m.Y').' · '.$occupation->property?->name,
'url' => PortalOccupationResource::getUrl('view', ['record' => $occupation]),
'button' => 'Klären',
'tone' => 'warning',
'sort' => '1'.$occupation->starts_on->format('Ymd'),
];
}
foreach (InboxMessage::query()->whereNull('read_at')->latest()->get() as $message) {
$items[] = [
'title' => $message->subject,
'detail' => str($message->body)->limit(160)->toString(),
'url' => $message->action_url ?: InboxMessageResource::getUrl(),
'button' => 'Ansehen',
'tone' => 'info',
'sort' => '2'.$message->created_at?->format('YmdHis'),
];
}
usort($items, fn (array $a, array $b): int => strcmp($a['sort'], $b['sort']));
return $items;
}
}