Vorgangskern und geführte Vorgangsbearbeitung (Pakete 1 und 2, Prozessarchitektur v0.10)
- Buchung ist der einheitliche Vorgang: Eingangsart, Vorgangsart A1–A6, eingefrorenes Abwicklungsprofil, gespeicherter Verlauf (booking_events); Gast, Personen und Beträge dürfen unbekannt sein, Platzhalter-Gäste werden migriert und nicht mehr angelegt - Einstellungen in Ebenen: Vermieterstandard (So arbeite ich), Abweichung der Wohnung (Experte), Abweichung je Portal und Eingangsart; ersetzt booking_model als Steuergröße - Ein Weg für extern verbindliche Buchungen (TakeOverExternalBooking) statt RecordPortalBooking und "Akte anlegen"; Portalpreis als belegte Gesamtposition - Startseite "Zu erledigen", neue Vorgangsseite mit nächstem Schritt, Automatik-Schalter, "Beenden" mit Storno statt Statusumschaltung; Status von Hand nur im Expertenmodus - Migration übernimmt bisheriges Verhalten unverändert (abweichende Wohnungswerte bleiben als Abweichung), Bericht: php artisan process:settings-report Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9005c12164
commit
3a728c3255
78 files changed
+4296
-1180
No files matched your search
@@ -4,15 +4,18 @@
|
||||
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\IntakeKind;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Mail\NewReservation;
|
||||
use App\Mail\ReservationReceived;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Guest;
|
||||
use App\Models\Property;
|
||||
use App\Pricing\PriceCalculator;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Process\ProcessSettings;
|
||||
use App\Support\Settings;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Tenancy\TenantContextMissing;
|
||||
@@ -23,7 +26,7 @@
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Turns a guest request into a reservation that holds the dates for the property's hold time,
|
||||
* Turns a guest request into a case (intake "request") that holds the dates for the hold time of the process settings,
|
||||
* and sends the quote to the guest and a notification to the landlord.
|
||||
*/
|
||||
class CreateReservation
|
||||
@@ -40,7 +43,7 @@ public function __construct(
|
||||
* @throws QuoteException
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Property $property, StayRequest $stay, array $guestData, ?string $message = null, string $source = 'website', bool $sendMails = true, array $attribution = []): Booking
|
||||
public function handle(Property $property, StayRequest $stay, array $guestData, ?string $message = null, string $source = 'website', bool $sendMails = true, array $attribution = [], ?Channel $originChannel = null): Booking
|
||||
{
|
||||
$tenant = $property->tenant;
|
||||
|
||||
@@ -50,7 +53,7 @@ public function handle(Property $property, StayRequest $stay, array $guestData,
|
||||
|
||||
return app(TenantContext::class)->run(
|
||||
$tenant,
|
||||
fn (): Booking => $this->create($property, $stay, $guestData, $message, $source, $sendMails, $attribution),
|
||||
fn (): Booking => $this->create($property, $stay, $guestData, $message, $source, $sendMails, $attribution, $originChannel),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -58,9 +61,13 @@ public function handle(Property $property, StayRequest $stay, array $guestData,
|
||||
* @param array{first_name: string, last_name: string, email: string, phone?: ?string, street?: ?string, postal_code?: ?string, city?: ?string, country?: ?string} $guestData
|
||||
* @param array{referral_source?: ?string, utm_source?: ?string, utm_medium?: ?string, utm_campaign?: ?string} $attribution
|
||||
*/
|
||||
private function create(Property $property, StayRequest $stay, array $guestData, ?string $message, string $source, bool $sendMails, array $attribution): Booking
|
||||
private function create(Property $property, StayRequest $stay, array $guestData, ?string $message, string $source, bool $sendMails, array $attribution, ?Channel $originChannel): Booking
|
||||
{
|
||||
$booking = DB::transaction(function () use ($property, $stay, $guestData, $message, $source, $attribution): Booking {
|
||||
if ($originChannel !== null && $originChannel->property_id !== $property->id) {
|
||||
throw new ReservationException('Der Kanal gehört nicht zu dieser Wohnung.');
|
||||
}
|
||||
|
||||
$booking = DB::transaction(function () use ($property, $stay, $guestData, $message, $source, $attribution, $originChannel): Booking {
|
||||
Property::whereKey($property->getKey())->lockForUpdate()->first();
|
||||
|
||||
if (! $this->availability->isAvailable($property, $stay->arrival, $stay->departure)) {
|
||||
@@ -70,11 +77,14 @@ private function create(Property $property, StayRequest $stay, array $guestData,
|
||||
$quote = $this->calculator->calculate($property, $stay);
|
||||
|
||||
[$guest, $differences] = $this->guestFor($guestData);
|
||||
$profile = app(ProcessSettings::class)->resolve($property, $originChannel, IntakeKind::Inquiry);
|
||||
|
||||
return $property->bookings()->create([
|
||||
'guest_id' => $guest->id,
|
||||
'status' => BookingStatus::Reserved,
|
||||
'source' => $source,
|
||||
'intake' => IntakeKind::Inquiry,
|
||||
'origin_channel_id' => $originChannel?->id,
|
||||
...Arr::only(array_filter($attribution), ['referral_source', 'utm_source', 'utm_medium', 'utm_campaign']),
|
||||
'arrival' => $stay->arrival->toDateString(),
|
||||
'departure' => $stay->departure->toDateString(),
|
||||
@@ -85,7 +95,7 @@ private function create(Property $property, StayRequest $stay, array $guestData,
|
||||
'total' => $quote->total(),
|
||||
'deposit' => $quote->deposit(),
|
||||
'balance_due_on' => $quote->balanceDueOn->toDateString(),
|
||||
'hold_expires_at' => $property->pre_reservation_enabled ? now()->addHours($property->hold_hours) : null,
|
||||
'hold_expires_at' => $profile->preReservation() ? now()->addHours($profile->holdHours()) : null,
|
||||
'message' => $message,
|
||||
'internal_notes' => $differences !== [] ? "Abweichende Angaben in dieser Anfrage (Gästekartei nicht geändert):\n".implode("\n", $differences) : null,
|
||||
]);
|
||||
@@ -165,7 +175,7 @@ private function sendMails(Booking $booking): void
|
||||
}
|
||||
|
||||
try {
|
||||
if (! $offerSent) {
|
||||
if (! $offerSent && filled($booking->guest?->email)) {
|
||||
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new ReservationReceived($booking));
|
||||
}
|
||||
Mail::to(Settings::notificationRecipients())->send(new NewReservation($booking, $offerSent, $blockers));
|
||||
|
||||
Reference in new issue
Block a user