profile; return $case->inquiry || $profile->documents() === Responsibility::Landlord || $profile->guestMessages() === Responsibility::Landlord || $profile->payments() === Responsibility::Landlord; } public function activities(CaseContext $case): array { $booking = $case->booking; $profile = $case->profile; $hasEmail = filled($booking->guest?->email); // v0.11 (G2a): before the own binding offer – or the binding confirmation of a wish – every required detail. $action = $profile->preReservation() || $booking->offer_version > 0 ? CaseRequirements::OFFER : CaseRequirements::WISH_CONFIRMATION; $needsDetails = $case->inquiry && ! $case->binding && $booking->offer_version === 0 && ($action === CaseRequirements::OFFER || $booking->wish_at !== null); $missing = $hasEmail && $needsDetails ? CaseRequirements::missing($booking, $action) : []; $request = $booking->openDataRequest(); $asked = $booking->contact_requested_at !== null || $request?->status === DataRequest::OPEN; $state = match (true) { $hasEmail && $missing === [] => ActivityState::Done, $asked => ActivityState::Waiting, default => ActivityState::Open, }; $title = match (true) { $booking->guest === null => 'Name und Kontaktdaten des Gastes eintragen', ! $hasEmail => 'E-Mail-Adresse des Gastes eintragen', $missing !== [] => $action === CaseRequirements::OFFER ? 'Angaben für das Angebot vervollständigen' : 'Angaben für die Bestätigung vervollständigen', default => 'Kontaktdaten des Gastes', }; $detail = match (true) { $state === ActivityState::Done => $booking->guestName(), $missing !== [] => 'fehlt: '.implode(', ', CaseRequirements::labels($missing)).($request !== null ? ' · '.$request->statusLabel() : ($asked ? ' · beim Gast angefragt' : '')), $booking->contact_requested_at !== null => 'beim Gast erfragt am '.$booking->contact_requested_at->format('d.m.Y'), default => 'fehlt noch', }; // A prepared data request waits for the landlord's release: that is the next step, otherwise entering the details. $draft = $needsDetails && $request?->status === DataRequest::DRAFT; return [new Activity('contact', $title, $case->later($draft ? ActivityState::Open : $state), $detail, $state === ActivityState::Done ? null : ($draft ? 'approveDataRequest' : 'provideContact'))]; } }