what keeps the case from going on automatically (empty: nothing to do or done) */ public function advance(Booking $booking): array { $booking->loadMissing(['guest', 'property']); if ($booking->processingMode() !== ProcessingMode::Automatic) { return []; } try { return CaseLog::context(fn (): array => $this->step($booking), actor: CaseLog::SYSTEM.' (automatisch)'); } catch (Throwable $exception) { report($exception); return ['Technischer Fehler beim automatischen Weiterbearbeiten – bitte von Hand fortsetzen.']; } } /** * @return list */ private function step(Booking $booking): array { if ($booking->status === BookingStatus::Reserved && $booking->offer_version === 0 && $booking->intake !== IntakeKind::Booking) { return $this->autoOffer->handle($booking); } if ($booking->isBinding() && $booking->confirmation_sent_at === null && $booking->process()->documents() === Responsibility::Landlord && $booking->process()->origin !== 'migration') { $missing = $this->documentBlockers($booking); if ($missing !== []) { return $missing; } return $this->confirm->deliver($booking) ? [] : ['Die Unterlagen konnten nicht versendet werden (siehe Postfach).']; } return []; } /** * What is missing before the documents of a binding case can go to the guest. * * @return list */ public function documentBlockers(Booking $booking): array { return array_values(array_filter([ $booking->guest === null ? 'Name und Kontaktdaten des Gastes fehlen.' : null, $booking->guest !== null && blank($booking->guest->email) ? 'Die E-Mail-Adresse des Gastes fehlt.' : null, $booking->total === null ? 'Der Gesamtpreis (laut Portal) fehlt.' : null, ])); } }