Vorgang: Schritte im Ablauf anklickbar – was geschah, Herkunft der Angaben, korrigieren
Deploy FeWo mit PipelineManager / deploy (push) Successful in 5m13s

- Ein Klick auf einen Schritt im „Ablauf“ öffnet seine Einzelheiten: die
  Verlaufseinträge dieses Schritts und bei den Gastangaben jede Angabe mit
  Wert, Herkunft (Webseite, Link, E-Mail, KI, Sie), Zeitpunkt, Belegstelle,
  Sicherheit und offenen Abweichungen.
- „Angaben korrigieren“ öffnet den Eintragsdialog: Ihre Eingabe gilt, der
  vorherige Wert bleibt im Nachweis; „Diesen Schritt ausführen“ führt
  direkt zur Aktion des Schritts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-03 18:03:36 +01:00
1 parent ad63db78f3
commit 7e4e208d18
5 files changed
+219 -2

No files matched your search

@@ -15,6 +15,7 @@
use App\Actions\SetBookingStatus;
use App\Documents\OfferTerms;
use App\Documents\RentalContract;
use App\Enums\ActivityState;
use App\Enums\AdminMode;
use App\Enums\AmountKind;
use App\Enums\BookingStatus;
@@ -43,6 +44,8 @@
use App\Models\User;
use App\Pricing\PrivateStayPrice;
use App\Pricing\QuoteException;
use App\Process\Activity;
use App\Process\ActivityDetails;
use App\Process\CaseActivities;
use App\Process\CaseAutomation;
use App\Process\CaseLog;
@@ -354,6 +357,37 @@ private function openFactConflicts(): string
return $notes === [] ? '' : ' Abweichende Angaben des Gastes – bitte den richtigen Wert eintragen: '.implode(' · ', $notes);
}
/**
* What lies behind one step of the progress list (clicked in "Ablauf"): its history entries and – for the guest's
* details – each detail with source, time, evidence and certainty, with the way to correct it or to do the step.
*/
public function activityDetailsAction(): Action
{
return Action::make('activityDetails')
->modalHeading(fn (array $arguments): string => ActivityDetails::activity($this->record, (string) ($arguments['key'] ?? ''))?->label ?? 'Schritt')
->modalWidth('4xl')
->modalSubmitAction(false)
->modalCancelActionLabel('Schließen')
->modalContent(function (array $arguments): \Illuminate\Contracts\View\View {
$key = (string) ($arguments['key'] ?? '');
$activity = ActivityDetails::activity($this->record, $key);
return view('filament.activity-details', [
'activity' => $activity ?? new Activity($key, 'Schritt', ActivityState::NotApplicable),
'events' => ActivityDetails::events($this->record, $key),
'facts' => ActivityDetails::showsFacts($key) ? ActivityDetails::facts($this->record->loadMissing('guest')) : null,
]);
})
->extraModalFooterActions(fn (array $arguments): array => array_values(array_filter([
ActivityDetails::showsFacts((string) ($arguments['key'] ?? '')) && $this->record->internal_kind !== InternalKind::Block
? Action::make('correctFacts')->label('Angaben korrigieren')->color('primary')->action(fn () => $this->replaceMountedAction('provideContact'))
: null,
($step = ActivityDetails::activity($this->record, (string) ($arguments['key'] ?? ''))?->action) !== null && $step !== 'provideContact'
? Action::make('doStep')->label('Diesen Schritt ausführen')->action(fn () => $this->replaceMountedAction($step))
: null,
])));
}
/**
* v0.11 data request: send the prepared question (or ask now although the case is set to asking by hand).
*/
@@ -50,7 +50,7 @@ public static function configure(Schema $schema): Schema
->columnSpan(2)
->schema([
Section::make('Ablauf')
->description('Was erledigt ist, was wartet und was noch kommt.')
->description('Was erledigt ist, was wartet und was noch kommt. Ein Klick auf einen Schritt zeigt, was dort geschah und woher die Angaben stammen.')
->schema([TextEntry::make('activities')->hiddenLabel()->state(fn (Booking $record): HtmlString => self::activities($record))->html()]),
Section::make('Preis und Zahlungen')
->schema([
@@ -217,7 +217,8 @@ private static function activities(Booking $booking): HtmlString
$color = $colors[$activity->state->getColor()];
$strong = $activity->state->needsAction() ? 'font-weight:700' : '';
return '<li style="display:flex;gap:.75rem;padding:.45rem 0;border-bottom:1px solid rgba(128,128,128,.2)">'
// A click opens what lies behind the step (ViewBooking::activityDetailsAction).
return '<li style="display:flex;gap:.75rem;padding:.45rem 0;border-bottom:1px solid rgba(128,128,128,.2);cursor:pointer" title="Einzelheiten ansehen" wire:click="mountAction(&#039;activityDetails&#039;, { key: &#039;'.e($activity->key).'&#039; })">'
.'<span style="width:1.4rem;text-align:center;font-weight:700;color:'.$color.'">'.$activity->state->icon().'</span>'
.'<span style="flex:1;'.$strong.'">'.e($activity->label)
.($activity->detail ? ' <span style="font-weight:400;color:#6b7280">· '.e($activity->detail).'</span>' : '')
+102
View File
@@ -0,0 +1,102 @@
<?php
namespace App\Process;
use App\Enums\FactSource;
use App\Models\Booking;
use App\Models\BookingEvent;
use App\Models\CaseFact;
use Illuminate\Support\Collection;
/**
* What lies behind one step of the case's progress list: the history entries that belong to it and – for the guest's
* details – every detail with its source, time, evidence and certainty (v0.11, S5), so the landlord can see where a
* value came from and correct it.
*/
final class ActivityDetails
{
/** History types per step (the step's own key or its prefix). */
private const EVENT_TYPES = [
'intake' => ['created', 'intake', 'profile', 'hold', 'mode'],
'contact' => ['facts', 'fact', 'guest', 'data_request', 'mail_in'],
'data_request' => ['data_request', 'mail_in', 'facts', 'fact'],
'information' => ['information', 'mail', 'hold'],
'wish' => ['wish'],
'wish_check' => ['wish', 'status'],
'offer' => ['offer', 'hold', 'mail', 'status'],
'acceptance' => ['offer', 'status'],
'binding' => ['status', 'portal_signal'],
'price' => ['price', 'amount'],
'documents' => ['document', 'mail'],
'arrival_info' => ['document', 'mail'],
'review' => ['mail'],
'payment' => ['payment', 'amount'],
'deposit' => ['payment'],
'balance' => ['payment'],
'payout' => ['payment', 'amount'],
'change_proposed' => ['change'],
'arrival_details' => ['task', 'services'],
'stay' => ['task', 'services', 'status'],
'closure' => ['task', 'status', 'settled'],
'settlement' => ['settled'],
'task_' => ['task'],
];
public static function activity(Booking $booking, string $key): ?Activity
{
return collect(CaseActivities::for($booking))->first(fn (Activity $activity): bool => $activity->key === $key);
}
/**
* @return Collection<int, BookingEvent>
*/
public static function events(Booking $booking, string $key): Collection
{
$types = self::EVENT_TYPES[$key] ?? (str_starts_with($key, 'task_') ? self::EVENT_TYPES['task_'] : []);
return $types === [] ? collect() : $booking->events()->whereIn('type', $types)->reorder()->latest('occurred_at')->latest('id')->limit(50)->get();
}
public static function showsFacts(string $key): bool
{
return in_array($key, ['contact', 'data_request', 'intake'], true);
}
/**
* Every detail of the guest and the stay with its current value and where it came from (latest decisive fact).
*
* @return list<array{field: string, label: string, value: ?string, source: ?string, actor: ?string, at: ?string, evidence: ?string, confidence: ?float, open: list<string>}>
*/
public static function facts(Booking $booking): array
{
$facts = CaseFact::query()->where('booking_id', $booking->id)->orderBy('id')->get()->groupBy('field');
$rows = [];
foreach ([...CaseRequirements::FIELDS, ...CaseRequirements::OPTIONAL_FIELDS] as $field => $label) {
$value = CaseRequirements::value($booking, $field);
/** @var Collection<int, CaseFact> $history */
$history = $facts->get($field, collect());
$decisive = $history->reverse()->first(fn (CaseFact $fact): bool => in_array($fact->outcome, [CaseFact::APPLIED, CaseFact::CONFIRMED], true));
$open = $history->filter(fn (CaseFact $fact): bool => in_array($fact->outcome, [CaseFact::CONFLICT, CaseFact::CHANGE_REQUEST], true) && $fact->created_at->greaterThanOrEqualTo($decisive?->created_at ?? $fact->created_at))
->map(fn (CaseFact $fact): string => '„'.$fact->value.'“ laut '.$fact->source->getLabel().' – '.$fact->outcomeLabel())->values()->all();
if (blank($value) && $history->isEmpty()) {
continue;
}
$rows[] = [
'field' => $field,
'label' => $label,
'value' => filled($value) ? (string) $value : null,
'source' => $decisive?->source instanceof FactSource ? $decisive->source->getLabel() : (filled($value) ? 'vor der Herkunftsaufzeichnung erfasst' : null),
'actor' => $decisive?->actor,
'at' => $decisive?->created_at?->format('d.m.Y, H:i'),
'evidence' => $decisive?->evidence,
'confidence' => $decisive?->confidence,
'open' => $open,
];
}
return $rows;
}
}