Files
Lars StommerandClaude Opus 5.5 4f69b426a4 Booking path 1 (offer + guest acceptance), 2FA for all, privacy hardening, brand graphics in theme
- Offer workflow: "Angebot senden" in the admin (dates, guests, promo code, manual price adjustment,
  validity from the property's hold time, message, guest data for the contract) with live price;
  contract draft PDF; signed, versioned offer page for the guest to accept (acceptance record without
  IP) or decline; expiry job, landlord notifications, editable offer texts, wording on the website.
- 2FA is mandatory for every admin account.
- Privacy: complete anonymisation (notes, attribution, review names, offer messages), shorter
  periods for unbinding requests, portal mail excerpts and attribution (configurable proposals),
  iCal summary not stored, known e-mail no longer overwrites guest data, security headers, bearer
  tokens for automations, metadata stripped from photo originals, review link throttled.
- Daily database backup (backup:database) and scripts/backup-pull.sh for the NAS.
- Theme: brand mark in header/footer, favicon/touch icon, wave divider, icons, illustration as
  image placeholder; navy follows the text colour for dark appearances.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 21:38:22 +02:00

55 lines
1.9 KiB
PHP

<?php
namespace App\Actions;
use App\Availability\AvailabilityChecker;
use App\Documents\RentalContract;
use App\Enums\BookingStatus;
use App\Exceptions\ReservationException;
use App\Mail\BookingConfirmed;
use App\Models\Booking;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
/**
* Makes a booking binding: payment due dates are fixed, the rental contract is generated and sent with the
* confirmation. Used when the guest accepts an offer (AcceptOffer) and when the landlord confirms directly
* (e.g. a booking agreed on the phone). Expired requests/offers can still be confirmed while the dates are free.
*/
class ConfirmBooking
{
public function __construct(
private AvailabilityChecker $availability,
private RentalContract $contract,
) {}
/**
* @throws ReservationException
*/
public function handle(Booking $booking, bool $notifyGuest = true): void
{
if (! in_array($booking->status, [BookingStatus::Reserved, BookingStatus::OfferSent, BookingStatus::Expired], true)) {
throw ReservationException::invalidTransition($booking->status->getLabel(), 'bestätigt');
}
DB::transaction(function () use ($booking): void {
if (! $this->availability->isAvailable($booking->property, $booking->arrival, $booking->departure, ignore: $booking)) {
throw ReservationException::notAvailable();
}
$booking->update([
'status' => BookingStatus::Confirmed,
'hold_expires_at' => null,
'confirmed_at' => now(),
'deposit_due_on' => today()->addDays(config('fewo.deposit_due_days'))->toDateString(),
]);
});
$this->contract->generate($booking);
if ($notifyGuest) {
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new BookingConfirmed($booking));
}
}
}