Files
fewo-stommer/app/Actions/ReleaseReservation.php
LarsandClaude Sonnet 5.5 a73b164ea1
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m36s
Zahlungsaufgaben, Freigabe-/Storno-Link, Vertragsvorlagen, Anreise-Mail
- Zahlungen werden nicht mehr automatisch angemahnt: faellige Anzahlung/Restzahlung werden Aufgaben
  (Zahlungen & Wuensche, Tages-/Wochenuebersicht); Mail nur per Klick; je Portal und Buchungstyp abschaltbar
- Freigabe-Link in der Eingangsbestaetigung, Storno-Link in der Buchungsbestaetigung; je Wohnung
  Wunsch / sofort / sofort bis Frist; Stornowuensche und Kosten bleiben Aufgabe des Gastgebers
- Vertragsvorlagen mit Versionen (je Angebot, Portal oder Wohnung waehlbar), benutzte Versionen gesperrt;
  Angebot und finaler Vertrag als unveraenderliche PDF mit SHA-256, Vertrag wird nie neu geschrieben
- Anreise-Mail je Wohnung einstellbar (Standard 3 Tage), neue Textfelder Schluessel/Parken/Ankunftstag

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 12:46:29 +01:00

54 lines
1.8 KiB
PHP
Raw Permalink 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\Actions;
use App\Enums\BookingStatus;
use App\Exceptions\ReservationException;
use App\Mail\OfferAnswered;
use App\Models\Booking;
use App\Support\Settings;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Throwable;
/**
* The guest releases a held request or offer through the link in the mail – the dates are free again at once.
* Repeating it is harmless. The link only reaches requests that are still held; a binding booking is never touched.
*/
class ReleaseReservation
{
/**
* @return bool true when this call released the dates, false when they had been released before
*
* @throws ReservationException
*/
public function handle(Booking $booking): bool
{
$released = DB::transaction(function () use ($booking): bool {
$booking->lockForTransition();
if ($booking->status === BookingStatus::Declined && $booking->declined_by === 'guest') {
return false;
}
if (! in_array($booking->status, BookingStatus::holding(), true)) {
throw ReservationException::invalidTransition($booking->status->getLabel(), 'freigegeben');
}
$booking->update(['status' => BookingStatus::Declined, 'declined_by' => 'guest', 'hold_expires_at' => null]);
return true;
});
if ($released) {
try {
Mail::to(Settings::notificationRecipients())->send(new OfferAnswered($booking, accepted: false));
} catch (Throwable $exception) {
Log::warning('Meldung über Freigabe nicht zugestellt', ['booking' => $booking->id, 'exception' => $exception::class]);
}
}
return $released;
}
}