inquiry && $case->profile->bookingNotice() !== BookingNoticeMode::Off; } public function activities(CaseContext $case): array { $booking = $case->booking; $suppression = SendBookingNotice::suppression($booking); $sent = SendBookingNotice::sent($booking); $waitsForPortal = $case->profile->awaitsPortalConfirmation() && PortalConfirmation::evidence($booking) === null; $label = 'Buchungsinformation an den Gast'.($case->profile->bookingNotice()->isAutomatic() ? ' (automatisch)' : ''); return [new Activity('booking_notice', $label, $case->later(match (true) { $sent => ActivityState::Done, $suppression !== null => ActivityState::NotApplicable, ! $case->binding => ActivityState::Later, $waitsForPortal => ActivityState::Waiting, blank($booking->guest?->email) => ActivityState::Waiting, default => ActivityState::Open, }), match (true) { $sent => 'gesendet', $suppression !== null => 'nicht nötig: '.$suppression, $waitsForPortal => 'wartet auf die Bestätigungsmail des Portals', blank($booking->guest?->email) => 'wartet: Die E-Mail-Adresse des Gastes fehlt.', default => null, }, ! $sent && $suppression === null && $case->binding && filled($booking->guest?->email) ? 'sendBookingNotice' : null)]; } public function state(CaseContext $case): ?StepState { $booking = $case->booking; return match (true) { SendBookingNotice::sent($booking) => StepState::Done, SendBookingNotice::suppression($booking) !== null => StepState::NotApplicable, ! $case->binding => StepState::Later, default => StepState::Open, }; } public function due(CaseContext $case): bool { return $case->profile->bookingNotice()->isAutomatic() && $case->binding && ! $case->closed && ! SendBookingNotice::sent($case->booking) && SendBookingNotice::suppression($case->booking) === null && $case->profile->origin !== 'migration'; } public function blockers(CaseContext $case): array { return filled($case->booking->guest?->email) ? [] : ['Die E-Mail-Adresse des Gastes fehlt.']; } public function run(CaseContext $case): StepResult { return app(SendBookingNotice::class)->handle($case->booking, automatic: true) ? StepResult::ran() : StepResult::blocked([SendBookingNotice::suppression($case->booking) ?? 'Nicht gesendet.']); } public function isOutward(): bool { return true; } }