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,9 +4,12 @@
|
||||
|
||||
use App\Actions\ConfirmBooking;
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Actions\RecordPortalBooking;
|
||||
use App\Actions\TakeOverExternalBooking;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Filament\Resources\BlockedPeriods\BlockedPeriodResource;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Filament\Resources\Bookings\Schemas\BookingForm;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Pricing\QuoteException;
|
||||
@@ -17,61 +20,68 @@
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* Entry of a new case that did not come through the website: a request (A1/A2) goes the same way as a website request,
|
||||
* a booking already binding on a portal (A3–A5) is taken over as it is.
|
||||
*/
|
||||
class CreateBooking extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BookingResource::class;
|
||||
|
||||
protected static ?string $title = 'Buchung erfassen';
|
||||
protected static ?string $title = 'Neu eintragen';
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
try {
|
||||
$property = Property::findOrFail($data['property_id']);
|
||||
$stay = new StayRequest(
|
||||
CarbonImmutable::parse($data['arrival']),
|
||||
CarbonImmutable::parse($data['departure']),
|
||||
(int) $data['guests'],
|
||||
promoCode: $data['promo_code'] ?: null,
|
||||
);
|
||||
$guest = Arr::only($data, ['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city']);
|
||||
|
||||
if (filled($data['channel_id'] ?? null)) {
|
||||
$booking = app(RecordPortalBooking::class)->handle(
|
||||
$property,
|
||||
Channel::query()->findOrFail($data['channel_id']),
|
||||
$stay,
|
||||
$guest,
|
||||
$data['portal_process'] ?? RecordPortalBooking::CONFIRM,
|
||||
$data['portal_reference'] ?? null,
|
||||
filled($data['portal_total'] ?? null) ? (int) $data['portal_total'] : null,
|
||||
$data['internal_notes'] ?: null,
|
||||
(bool) ($data['guest_confirmed'] ?? false),
|
||||
);
|
||||
|
||||
return $booking;
|
||||
}
|
||||
|
||||
$booking = app(CreateReservation::class)->handle($property, $stay, $guest, source: 'manual', sendMails: $data['send_mails']);
|
||||
|
||||
if ($data['confirm_immediately']) {
|
||||
app(ConfirmBooking::class)->handle($booking, notifyGuest: $data['send_mails']);
|
||||
}
|
||||
} catch (QuoteException|ReservationException $exception) {
|
||||
Notification::make()->title('Buchung nicht möglich')->body($exception->getMessage())->danger()->send();
|
||||
|
||||
if (($data['kind'] ?? null) === BookingForm::OWN_USE) {
|
||||
$this->redirect(BlockedPeriodResource::getUrl());
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
$booking->update(['internal_notes' => $data['internal_notes'] ?: null]);
|
||||
try {
|
||||
$property = Property::query()->findOrFail($data['property_id']);
|
||||
$channel = filled($data['channel_id'] ?? null) ? Channel::query()->findOrFail($data['channel_id']) : null;
|
||||
$arrival = CarbonImmutable::parse($data['arrival']);
|
||||
$departure = CarbonImmutable::parse($data['departure']);
|
||||
$guest = Arr::only($data, ['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city']);
|
||||
|
||||
if ($data['kind'] === BookingForm::EXTERNAL) {
|
||||
return app(TakeOverExternalBooking::class)->handle($property, $channel, $arrival, $departure, [
|
||||
'guest' => $guest,
|
||||
'guests' => filled($data['guests'] ?? null) ? (int) $data['guests'] : null,
|
||||
'portal_reference' => $data['portal_reference'] ?? null,
|
||||
'portal_total' => filled($data['portal_total'] ?? null) ? (int) $data['portal_total'] : null,
|
||||
'notes' => $data['internal_notes'] ?? null,
|
||||
'guest_confirmed' => (bool) ($data['guest_confirmed'] ?? false),
|
||||
]);
|
||||
}
|
||||
|
||||
$stay = new StayRequest($arrival, $departure, (int) $data['guests'], promoCode: filled($data['promo_code'] ?? null) ? $data['promo_code'] : null);
|
||||
$sendMails = (bool) ($data['send_mails'] ?? false);
|
||||
$booking = app(CreateReservation::class)->handle($property, $stay, $guest, source: 'manual', sendMails: $sendMails && ! ($data['confirm_immediately'] ?? false), originChannel: $channel);
|
||||
|
||||
if ($data['confirm_immediately'] ?? false) {
|
||||
app(ConfirmBooking::class)->handle($booking, notifyGuest: $sendMails && filled($booking->guest?->email));
|
||||
}
|
||||
} catch (QuoteException|ReservationException $exception) {
|
||||
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
if (filled($data['internal_notes'] ?? null)) {
|
||||
$booking->update(['internal_notes' => trim(($booking->internal_notes ? $booking->internal_notes."\n\n" : '').$data['internal_notes'])]);
|
||||
}
|
||||
|
||||
return $booking;
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return BookingResource::getUrl('view', ['record' => $this->getRecord()]);
|
||||
/** @var Booking $record */
|
||||
$record = $this->getRecord();
|
||||
|
||||
return BookingResource::getUrl('view', ['record' => $record]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user