Portal-Direktbuchung erfassen, Kontaktdaten-Prozess, manueller Statuswechsel, Archiv, Filter, Menue Verwaltung/Einrichtung
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m38s
- Buchung erfassen: Buchungsweg Portal (Referenz, Portalpreis, ohne Kontaktdaten), Prozess bestaetigen/Vertrag sofort/nur erfassen - Buchungsakte: Kontaktdaten eintragen (automatisch oder manuell weiter), Gast um Kontaktdaten bitten, Status von Hand aendern, Archivieren - Liste: Filter Kanal, Anreisezeitraum, Kontaktdaten fehlen; Spalten ausblendbar; Archiv - Klaerung: verstaendlichere Texte, eigenstaendige Belegung mit Kanal gilt als geklaert (Gitea #4) - Akte per Button aus Liste und Belegungsplan erreichbar - Menue: Gruppen Verwaltung (Tagesgeschaeft) und Einrichtung (Konfiguration), einfache Ansicht auf 8 Punkte Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c4187edaf
commit
5ba9ae08ab
37 files changed
+786
-82
No files matched your search
@@ -108,8 +108,8 @@ private function create(Property $property, StayRequest $stay, array $guestData,
|
||||
*/
|
||||
private function guestFor(array $guestData): array
|
||||
{
|
||||
$email = mb_strtolower($guestData['email']);
|
||||
$guest = Guest::query()->where('email', $email)->first();
|
||||
$email = mb_strtolower(trim((string) ($guestData['email'] ?? '')));
|
||||
$guest = $email === '' ? null : Guest::query()->where('email', $email)->first();
|
||||
|
||||
if ($guest === null) {
|
||||
return [Guest::create([
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\Booking;
|
||||
use App\Support\BookingProgress;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
/**
|
||||
* The guest's contact data arrived (portal message, e-mail, phone) and is entered on the booking. The landlord chooses
|
||||
* whether the process continues automatically – a binding portal booking gets its contract, a request gets the
|
||||
* offer – or by hand (data only). An already existing e-mail confirmation of the guest can be recorded as well.
|
||||
*/
|
||||
class ProvideGuestContact
|
||||
{
|
||||
public const AUTOMATIC = 'automatic';
|
||||
|
||||
public const MANUAL = 'manual';
|
||||
|
||||
public function __construct(private ConfirmBooking $confirm, private SendOffer $offer) {}
|
||||
|
||||
/**
|
||||
* @param array<string, ?string> $contact first_name, last_name, email, phone, street, postal_code, city, country
|
||||
* @return string what was done, for the notification
|
||||
*
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Booking $booking, array $contact, string $process = self::MANUAL, bool $guestConfirmed = false): string
|
||||
{
|
||||
$contact = array_map(fn ($value) => filled($value) ? trim((string) $value) : null, Arr::only($contact, ['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city', 'country']));
|
||||
if (isset($contact['email'])) {
|
||||
$contact['email'] = mb_strtolower($contact['email']);
|
||||
}
|
||||
|
||||
if ($process === self::AUTOMATIC && blank($contact['email'] ?? $booking->guest?->email)) {
|
||||
throw new ReservationException('Für den automatischen Ablauf wird die E-Mail-Adresse des Gastes benötigt.');
|
||||
}
|
||||
|
||||
$booking->guest->update(array_filter($contact, fn ($value) => $value !== null));
|
||||
if ($guestConfirmed) {
|
||||
$booking->forceFill(['guest_confirmed_at' => $booking->guest_confirmed_at ?? now()])->saveQuietly();
|
||||
}
|
||||
$booking->refresh()->load('guest');
|
||||
|
||||
if ($process !== self::AUTOMATIC) {
|
||||
return 'Kontaktdaten gespeichert';
|
||||
}
|
||||
|
||||
if (in_array($booking->status, BookingStatus::occupying(), true)) {
|
||||
$this->confirm->deliver($booking);
|
||||
|
||||
return 'Kontaktdaten gespeichert, Vertrag gesendet';
|
||||
}
|
||||
|
||||
if (BookingProgress::kind($booking) === BookingProgress::PORTAL_BOOKING) {
|
||||
$this->confirm->handle($booking);
|
||||
|
||||
return 'Kontaktdaten gespeichert, Buchung bestätigt und Vertrag gesendet';
|
||||
}
|
||||
|
||||
$this->offer->handle($booking);
|
||||
|
||||
return 'Kontaktdaten gespeichert, Angebot gesendet';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\QuoteLineType;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Pricing\PriceCalculator;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\QuoteLine;
|
||||
use App\Pricing\StayRequest;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Records a booking that a portal already made binding (e.g. a direct booking on FeWo-direkt) – usually without
|
||||
* the guest's contact data. The booking keeps the portal as its origin channel and may carry the portal's price and
|
||||
* reference. The landlord decides how the contract process continues:
|
||||
*
|
||||
* - {@see self::CONFIRM}: the booking becomes binding right away (the dates are occupied), the contract follows
|
||||
* once the contact data is known ({@see ProvideGuestContact}) – no contract is generated before that;
|
||||
* - {@see self::CONTRACT}: binding and contract mail at once (needs the guest's e-mail address);
|
||||
* - {@see self::RECORD}: only recorded as a request, everything else is done by hand.
|
||||
*/
|
||||
class RecordPortalBooking
|
||||
{
|
||||
public const CONFIRM = 'confirm';
|
||||
|
||||
public const CONTRACT = 'contract';
|
||||
|
||||
public const RECORD = 'record';
|
||||
|
||||
public function __construct(
|
||||
private CreateReservation $create,
|
||||
private ConfirmBooking $confirm,
|
||||
private PriceCalculator $calculator,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array<string, ?string> $guestData first_name and last_name are required, everything else optional
|
||||
*
|
||||
* @throws QuoteException
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Property $property, Channel $channel, StayRequest $stay, array $guestData, string $process = self::CONFIRM, ?string $portalReference = null, ?int $portalTotal = null, ?string $notes = null, bool $guestConfirmed = false): Booking
|
||||
{
|
||||
if ($channel->property_id !== $property->id) {
|
||||
throw new ReservationException('Der Kanal gehört nicht zu dieser Wohnung.');
|
||||
}
|
||||
|
||||
if ($process === self::CONTRACT && blank($guestData['email'] ?? null)) {
|
||||
throw new ReservationException('Für den sofortigen Vertragsversand wird die E-Mail-Adresse des Gastes benötigt.');
|
||||
}
|
||||
|
||||
$booking = $this->create->handle($property, $stay, $guestData, source: 'portal', sendMails: false);
|
||||
|
||||
$changes = ['origin_channel_id' => $channel->id, 'portal_reference' => filled($portalReference) ? trim($portalReference) : null, 'internal_notes' => filled($notes) ? trim($notes) : $booking->internal_notes];
|
||||
if ($guestConfirmed) {
|
||||
$changes['guest_confirmed_at'] = now();
|
||||
}
|
||||
if ($portalTotal !== null) {
|
||||
$changes += $this->priceOf($property, $stay, $portalTotal);
|
||||
}
|
||||
$booking->update($changes);
|
||||
|
||||
if ($process === self::RECORD) {
|
||||
return $booking->refresh();
|
||||
}
|
||||
|
||||
if ($process === self::CONTRACT) {
|
||||
$this->confirm->handle($booking, notifyGuest: true);
|
||||
} else {
|
||||
DB::transaction(fn () => $this->confirm->bind($booking));
|
||||
}
|
||||
|
||||
return $booking->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Price columns for a booking whose portal price differs from our own calculation: the difference becomes an
|
||||
* adjustment line, so the quote still adds up to what the portal charged.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*
|
||||
* @throws QuoteException
|
||||
*/
|
||||
private function priceOf(Property $property, StayRequest $stay, int $portalTotal): array
|
||||
{
|
||||
$quote = $this->calculator->calculate($property, $stay);
|
||||
$difference = $portalTotal - $quote->total();
|
||||
if ($difference === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$difference = max($difference, -$quote->rent());
|
||||
$quote = $quote->withLine(new QuoteLine(QuoteLineType::Adjustment, 'Abweichung Portalpreis', 1, $difference, $difference));
|
||||
|
||||
return [
|
||||
'price_adjustment' => $difference,
|
||||
'price_adjustment_label' => 'Abweichung Portalpreis',
|
||||
'quote' => $quote->toArray(),
|
||||
'total' => $quote->total(),
|
||||
'deposit' => $quote->deposit(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
@@ -44,6 +45,10 @@ public function handle(BlockedPeriod $block, string $resolution, ?int $targetId
|
||||
'linked_booking_id' => $resolution === 'booking' ? $target->id : null,
|
||||
'review_note' => 'Persönlich zugeordnet; nur die führende Belegung steuert Verfügbarkeit und Export.'];
|
||||
}
|
||||
// A stay confirmed as independent with a known booking channel (or privately) is no longer "unclear".
|
||||
if ($resolution === 'independent' && ($originId !== null || $attributes['is_private']) && in_array($block->occupationKind(), [OccupationKind::Unknown], true)) {
|
||||
$attributes['occupation_kind'] = OccupationKind::Reservation;
|
||||
}
|
||||
$block->forceFill(['representation_automatic' => false])->fill($attributes)->save();
|
||||
app(ReconcileChannelRepresentations::class)->handle($block->property);
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Availability\AvailabilityChecker;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Manual status change for processes the system does not drive itself (bookings entered by hand, portal bookings):
|
||||
* the landlord moves the booking along the stages and gives a reason, which is added to the internal notes.
|
||||
* Cancelling and declining are separate actions (they inform people and record costs). Making a booking binding
|
||||
* again checks the calendar like every other writer; no mail is sent and no contract is generated here.
|
||||
*/
|
||||
class SetBookingStatus
|
||||
{
|
||||
/** @var list<BookingStatus> */
|
||||
public const TARGETS = [BookingStatus::Reserved, BookingStatus::Confirmed, BookingStatus::DepositPaid, BookingStatus::Paid, BookingStatus::Completed];
|
||||
|
||||
public function __construct(private AvailabilityChecker $availability) {}
|
||||
|
||||
/**
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Booking $booking, BookingStatus $status, string $reason, string $by = 'Verwaltung'): Booking
|
||||
{
|
||||
if (! in_array($status, self::TARGETS, true)) {
|
||||
throw new ReservationException('Auf diesen Status kann nicht von Hand gewechselt werden. Stornieren und Ablehnen haben eigene Aktionen.');
|
||||
}
|
||||
|
||||
if (blank(trim($reason))) {
|
||||
throw new ReservationException('Bitte einen Grund für die Statusänderung angeben.');
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($booking, $status, $reason, $by): void {
|
||||
$booking->lockForTransition();
|
||||
$from = $booking->status;
|
||||
|
||||
if ($from === $status) {
|
||||
throw new ReservationException('Die Buchung hat diesen Status bereits.');
|
||||
}
|
||||
|
||||
$becomesBinding = in_array($status, BookingStatus::occupying(), true) && ! in_array($from, BookingStatus::occupying(), true);
|
||||
if ($becomesBinding && ! $this->availability->isAvailable($booking->property, $booking->arrival, $booking->departure, ignore: $booking)) {
|
||||
throw ReservationException::notAvailable();
|
||||
}
|
||||
|
||||
$changes = ['status' => $status];
|
||||
if ($becomesBinding) {
|
||||
$changes += ['hold_expires_at' => null, 'confirmed_at' => $booking->confirmed_at ?? now(), 'cancelled_at' => null];
|
||||
}
|
||||
if ($status === BookingStatus::Reserved) {
|
||||
$changes['hold_expires_at'] = null;
|
||||
}
|
||||
|
||||
$line = now()->format('d.m.Y H:i').' '.$by.': Status von „'.$from->getLabel().'“ auf „'.$status->getLabel().'“ gesetzt – '.trim($reason);
|
||||
$booking->update($changes + ['internal_notes' => trim(($booking->internal_notes ? $booking->internal_notes."\n" : '').$line)]);
|
||||
|
||||
// A booking taken back into the process no longer needs the cancellation follow-up.
|
||||
if ($becomesBinding) {
|
||||
BookingTask::query()->where('booking_id', $booking->id)->where('status', BookingTaskStatus::Open)
|
||||
->whereIn('kind', [BookingTaskKind::CancellationFee, BookingTaskKind::CancellationRequest])
|
||||
->update(['status' => BookingTaskStatus::Done, 'completed_by' => $by, 'completed_at' => now()]);
|
||||
}
|
||||
});
|
||||
|
||||
return $booking->refresh();
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,8 @@ public function records(?int $propertyId = null, ?int $guestId = null, bool $inc
|
||||
'source' => $booking->bookingChannelLabel(), 'status' => $booking->status->getLabel(),
|
||||
'status_key' => $booking->status->value, 'color' => $booking->status->getColor(),
|
||||
'occupies' => in_array($booking->status, BookingStatus::occupying(), true) || $booking->isHoldActive(),
|
||||
'needs_review' => false, 'review_note' => null, 'reason' => null, 'archived' => false,
|
||||
'needs_review' => false, 'review_note' => null, 'reason' => null, 'archived' => false, 'archived_booking' => $booking->archived_at !== null,
|
||||
'channel_id' => $booking->origin_channel_id ?? $booking->import_channel_id,
|
||||
'representations' => $booking->channel_representations_count,
|
||||
'mirrored_channels' => $booking->channelRepresentations->pluck('channel.name')->filter()->unique()->values()->all(),
|
||||
'url' => BookingResource::getUrl('view', ['record' => $booking->id]),
|
||||
@@ -74,7 +75,7 @@ public function records(?int $propertyId = null, ?int $guestId = null, bool $inc
|
||||
'status' => $block->trashed() ? 'Nicht mehr im Kalenderfeed' : ($block->needs_review ? 'Klärung erforderlich' : 'Im Kalender geführt'),
|
||||
'status_key' => $block->trashed() ? 'archived' : 'imported', 'color' => $block->needs_review ? 'warning' : $kind->getColor(),
|
||||
'occupies' => ! $block->trashed(), 'needs_review' => $block->needs_review, 'review_note' => $block->review_note, 'reason' => $block->blockDescription(),
|
||||
'archived' => $block->trashed(), 'representations' => $block->channel_representations_count,
|
||||
'archived' => $block->trashed(), 'archived_booking' => false, 'channel_id' => $block->origin_channel_id ?? $block->channel_id, 'representations' => $block->channel_representations_count,
|
||||
'mirrored_channels' => $block->channelRepresentations->pluck('channel.name')->filter()->unique()->values()->all(),
|
||||
'url' => $block->source === 'manual' ? BlockedPeriodResource::getUrl() : PortalOccupationResource::getUrl('view', ['record' => $block->id]),
|
||||
'guest_url' => $block->guest_id ? GuestResource::getUrl('edit', ['record' => $block->guest_id]) : null,
|
||||
|
||||
+6
-15
@@ -7,13 +7,9 @@
|
||||
use App\Filament\Resources\BlockedPeriods\BlockedPeriodResource;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Filament\Resources\BookingTasks\BookingTaskResource;
|
||||
use App\Filament\Resources\Cancellations\CancellationResource;
|
||||
use App\Filament\Resources\Channels\ChannelResource;
|
||||
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
|
||||
use App\Filament\Resources\Guests\GuestResource;
|
||||
use App\Filament\Resources\Photos\PhotoResource;
|
||||
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
|
||||
use App\Filament\Resources\Reviews\ReviewResource;
|
||||
use App\Filament\Resources\InboxMessages\InboxMessageResource;
|
||||
use Filament\Support\Contracts\HasDescription;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
@@ -26,24 +22,19 @@ enum AdminMode: string implements HasDescription, HasLabel
|
||||
case Expert = 'expert';
|
||||
|
||||
/**
|
||||
* Menu entries of the simple mode: day-to-day work with requests, bookings, contracts and the calendar.
|
||||
* Menu entries of the simple mode: the few things needed every day: calendar, bookings with their file, tasks, mailbox, guests and prices.
|
||||
*
|
||||
* @var list<class-string>
|
||||
*/
|
||||
public const SIMPLE_NAVIGATION = [
|
||||
OccupancyCalendar::class,
|
||||
InboxMessageResource::class,
|
||||
BookingResource::class,
|
||||
PortalOccupationResource::class,
|
||||
BookingTaskResource::class,
|
||||
ChannelTaskResource::class,
|
||||
InboxMessageResource::class,
|
||||
GuestResource::class,
|
||||
BlockedPeriodResource::class,
|
||||
PricesAndOffers::class,
|
||||
GuestResource::class,
|
||||
ChannelTaskResource::class,
|
||||
BookingTaskResource::class,
|
||||
CancellationResource::class,
|
||||
ChannelResource::class,
|
||||
ReviewResource::class,
|
||||
PhotoResource::class,
|
||||
];
|
||||
|
||||
public function getLabel(): string
|
||||
|
||||
@@ -25,7 +25,7 @@ class OccupancyCalendar extends Page
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCalendarDays;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $title = 'Belegungsplan';
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class PricesAndOffers extends Page
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCurrencyEuro;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Einrichtung';
|
||||
|
||||
protected static ?string $navigationLabel = 'Preise & Angebote';
|
||||
|
||||
@@ -39,7 +39,7 @@ class PricesAndOffers extends Page
|
||||
|
||||
protected static ?string $slug = 'preise-und-angebote';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
protected static ?int $navigationSort = 0;
|
||||
|
||||
#[Url(as: 'wohnung')]
|
||||
public ?int $propertyId = null;
|
||||
|
||||
@@ -45,13 +45,13 @@ class BlockedPeriodResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedNoSymbol;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $modelLabel = 'Sperrzeit';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Sperrzeiten';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?int $navigationSort = 10;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
@@ -128,12 +128,12 @@ public static function portalActions(): array
|
||||
TextEntry::make('recognized_representation')->label('Fachliche Einordnung')->state(fn (BlockedPeriod $record): string => ICalRuleEngine::REPRESENTATIONS[$record->ical_interpretation['representation'] ?? 'unspecified']),
|
||||
TextEntry::make('original')->label('Originalereignis (entfaltet)')->state(fn (BlockedPeriod $record): string => $record->ical_raw)->wrap()->extraAttributes(['style' => 'white-space:pre-wrap;overflow-wrap:anywhere']),
|
||||
]),
|
||||
Action::make('resolve')->label('Belegung zuordnen / klären')
|
||||
Action::make('resolve')->label('Klären: eigenständig oder Doppelung?')
|
||||
->visible(fn (BlockedPeriod $record): bool => ! $record->trashed() && in_array($record->source, ['channel', 'email'], true))
|
||||
->authorize(fn (BlockedPeriod $record): bool => auth()->user()?->can('update', $record) ?? false)
|
||||
->modalDescription('Nur nach persönlicher Prüfung zuordnen. Eine Darstellung steuert keine eigene Belegung mehr; die führende Buchung oder Sperre übernimmt Änderungen und Stornierungen. Kalenderereignisse und UIDs bleiben nachvollziehbar erhalten.')
|
||||
->modalDescription('Nur nach persönlicher Prüfung klären. Eigenständig mit Buchungskanal (oder privat) gilt danach als geklärt und verschwindet aus „Ungeklärt“. Eine Doppelung steuert keine eigene Belegung mehr; die führende Buchung oder Sperre übernimmt Änderungen und Stornierungen. Kalenderereignisse und UIDs bleiben nachvollziehbar erhalten.')
|
||||
->schema([
|
||||
Select::make('resolution')->label('Fachliche Klärung')->options(['independent' => 'Eigenständige Belegung bestätigen', 'block' => 'Weitere Darstellung einer Kalenderbelegung (Portalreservierung oder Sperrzeit)', 'booking' => 'Weitere Darstellung einer eigenen Buchung'])->default('independent')->required()->live(),
|
||||
Select::make('resolution')->label('Fachliche Klärung')->options(['independent' => 'Eigenständige Belegung – keine Doppelung (Buchungskanal unten angeben)', 'block' => 'Doppelung: dieselbe Belegung steht schon als Portalreservierung oder Sperrzeit im Kalender', 'booking' => 'Doppelung: dieselbe Belegung ist eine unserer eigenen Buchungen'])->default('independent')->required()->live(),
|
||||
Select::make('target_id')->label('Führende Belegung mit demselben Zeitraum')
|
||||
->visible(fn (Get $get): bool => $get('resolution') !== 'independent')
|
||||
->required(fn (Get $get): bool => $get('resolution') !== 'independent')
|
||||
|
||||
@@ -20,13 +20,13 @@ class BookingTaskResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBanknotes;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $modelLabel = 'Buchungsaufgabe';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Zahlungen & Wünsche';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ class BookingResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCalendarDays;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $modelLabel = 'Buchung';
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
use App\Actions\ConfirmBooking;
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Actions\RecordPortalBooking;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
@@ -27,18 +29,32 @@ class CreateBooking extends CreateRecord
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
try {
|
||||
$booking = app(CreateReservation::class)->handle(
|
||||
Property::findOrFail($data['property_id']),
|
||||
new StayRequest(
|
||||
CarbonImmutable::parse($data['arrival']),
|
||||
CarbonImmutable::parse($data['departure']),
|
||||
(int) $data['guests'],
|
||||
promoCode: $data['promo_code'] ?: null,
|
||||
),
|
||||
Arr::only($data, ['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city']),
|
||||
source: 'manual',
|
||||
sendMails: $data['send_mails'],
|
||||
$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']);
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
use App\Actions\CancelBooking;
|
||||
use App\Actions\ConfirmBooking;
|
||||
use App\Actions\DeclineBooking;
|
||||
use App\Actions\ProvideGuestContact;
|
||||
use App\Actions\SendOffer;
|
||||
use App\Actions\SetBookingStatus;
|
||||
use App\Documents\OfferTerms;
|
||||
use App\Documents\RentalContract;
|
||||
use App\Enums\BookingStatus;
|
||||
@@ -19,12 +21,14 @@
|
||||
use App\Pricing\PriceCalculator;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Support\BookingProgress;
|
||||
use App\Support\Money;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -127,6 +131,61 @@ protected function getHeaderActions(): array
|
||||
fn () => $send->handle($this->record, $this->offerChanges($data)),
|
||||
'Angebot gesendet',
|
||||
)),
|
||||
Action::make('provideContact')
|
||||
->label('Kontaktdaten eintragen')
|
||||
->icon(Heroicon::OutlinedUserPlus)
|
||||
->color(fn (): string => blank($this->record->guest?->email) ? 'warning' : 'gray')
|
||||
->visible(fn (): bool => ! in_array($this->record->status, [BookingStatus::Cancelled, BookingStatus::Declined, BookingStatus::Expired], true))
|
||||
->modalHeading('Kontaktdaten des Gastes')
|
||||
->modalDescription('Kontaktdaten aus Portalnachricht, E-Mail oder Telefonat. Danach kann der Vertragsprozess automatisch weiterlaufen oder von Hand fortgeführt werden.')
|
||||
->modalWidth('3xl')
|
||||
->fillForm(fn (): array => ['guest' => $this->record->guest->only(['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city']), 'process' => ProvideGuestContact::MANUAL, 'guest_confirmed' => $this->record->guest_confirmed_at !== null])
|
||||
->schema([
|
||||
Section::make('Gast')->columns(2)->schema([
|
||||
TextInput::make('guest.first_name')->label('Vorname')->required()->maxLength(100),
|
||||
TextInput::make('guest.last_name')->label('Nachname')->required()->maxLength(100),
|
||||
TextInput::make('guest.email')->label('E-Mail')->email()->maxLength(255),
|
||||
TextInput::make('guest.phone')->label('Telefon')->tel()->maxLength(50),
|
||||
TextInput::make('guest.street')->label('Straße und Hausnummer')->maxLength(150),
|
||||
TextInput::make('guest.postal_code')->label('PLZ')->maxLength(20),
|
||||
TextInput::make('guest.city')->label('Ort')->maxLength(100),
|
||||
]),
|
||||
Section::make('Wie geht es weiter?')->schema([
|
||||
Radio::make('process')->hiddenLabel()->options([
|
||||
ProvideGuestContact::MANUAL => 'Nur speichern – den Vertragsprozess führe ich von Hand weiter',
|
||||
ProvideGuestContact::AUTOMATIC => 'Automatisch weiter: Portal-Buchung → Bestätigung und Vertrag per E-Mail, Anfrage → Angebot per E-Mail',
|
||||
])->required(),
|
||||
Toggle::make('guest_confirmed')->label('Der Gast hat die Buchung per E-Mail bestätigt'),
|
||||
]),
|
||||
])
|
||||
->action(function (array $data, ProvideGuestContact $provide): void {
|
||||
try {
|
||||
$message = $provide->handle($this->record, $data['guest'], $data['process'], (bool) $data['guest_confirmed']);
|
||||
} catch (ReservationException|QuoteException $exception) {
|
||||
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->record->refresh();
|
||||
Notification::make()->title($message)->success()->send();
|
||||
}),
|
||||
Action::make('requestContact')
|
||||
->label('Gast um Kontaktdaten bitten')
|
||||
->icon(Heroicon::OutlinedChatBubbleLeftEllipsis)
|
||||
->color('gray')
|
||||
->visible(fn (): bool => blank($this->record->guest?->email) && ! in_array($this->record->status, [BookingStatus::Cancelled, BookingStatus::Declined, BookingStatus::Expired], true))
|
||||
->modalHeading('Gast um Kontaktdaten bitten')
|
||||
->modalDescription('Der Text lässt sich im Nachrichtenfenster des Portals einfügen (Sie senden ihn selbst). Mit „Als angefragt vermerken“ merkt sich die Buchungsakte, dass die Kontaktdaten erfragt wurden.')
|
||||
->modalSubmitActionLabel('Als angefragt vermerken')
|
||||
->fillForm(fn (): array => ['text' => $this->contactRequestText()])
|
||||
->schema([
|
||||
Textarea::make('text')->label('Nachricht an den Gast')->rows(10)->extraInputAttributes(['readonly' => true, 'onclick' => 'this.select()']),
|
||||
])
|
||||
->action(function (): void {
|
||||
$this->record->forceFill(['contact_requested_at' => now()])->saveQuietly();
|
||||
Notification::make()->title('Als angefragt vermerkt')->success()->send();
|
||||
}),
|
||||
Action::make('offerLink')
|
||||
->label('Angebotslink')
|
||||
->icon(Heroicon::OutlinedLink)
|
||||
@@ -250,6 +309,38 @@ protected function getHeaderActions(): array
|
||||
Textarea::make('internal_notes')->label('Interne Notizen')->rows(6),
|
||||
])
|
||||
->action(fn (array $data) => $this->record->update($data)),
|
||||
Action::make('setStatus')
|
||||
->label('Status von Hand ändern')
|
||||
->icon(Heroicon::OutlinedAdjustmentsHorizontal)
|
||||
->visible(fn (): bool => BookingProgress::kind($this->record) !== BookingProgress::OWN && $this->record->status !== BookingStatus::Declined)
|
||||
->modalHeading('Status von Hand ändern')
|
||||
->modalDescription('Für Buchungen, die das System nicht selbst weiterführt. Es werden keine E-Mails versendet. Wird die Buchung wieder verbindlich, prüft das System den Kalender. Stornieren und Ablehnen haben eigene Aktionen.')
|
||||
->schema([
|
||||
Select::make('status')->label('Neuer Status')->options(collect(SetBookingStatus::TARGETS)->mapWithKeys(fn (BookingStatus $status): array => [$status->value => $status->getLabel()])->all())->required(),
|
||||
Textarea::make('reason')->label('Grund / Anlass')->helperText('Wird in den internen Notizen festgehalten.')->required()->rows(2),
|
||||
])
|
||||
->action(function (array $data, SetBookingStatus $setStatus): void {
|
||||
try {
|
||||
$setStatus->handle($this->record, BookingStatus::from($data['status']), $data['reason'], auth()->user()->name);
|
||||
} catch (ReservationException $exception) {
|
||||
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->record->refresh();
|
||||
Notification::make()->title('Status geändert')->success()->send();
|
||||
}),
|
||||
Action::make('archive')
|
||||
->label(fn (): string => $this->record->archived_at ? 'Aus dem Archiv holen' : 'Archivieren')
|
||||
->icon(Heroicon::OutlinedArchiveBox)
|
||||
->visible(fn (): bool => $this->record->archived_at !== null || $this->record->canBeArchived())
|
||||
->modalDescription(fn (): string => $this->record->archived_at ? 'Die Buchung erscheint wieder in der Liste.' : 'Die Buchung verschwindet aus der Standardliste. Verlauf, E-Mails, Zahlungen und Dokumente bleiben vollständig erhalten.')
|
||||
->requiresConfirmation()
|
||||
->action(function (): void {
|
||||
$this->record->update(['archived_at' => $this->record->archived_at ? null : now()]);
|
||||
Notification::make()->title($this->record->archived_at ? 'Archiviert' : 'Wieder aktiv')->success()->send();
|
||||
}),
|
||||
Action::make('cancel')
|
||||
->label('Stornieren')
|
||||
->icon(Heroicon::OutlinedNoSymbol)
|
||||
@@ -277,6 +368,21 @@ protected function getHeaderActions(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Suggested message asking a portal guest for the contact data the contract needs.
|
||||
*/
|
||||
private function contactRequestText(): string
|
||||
{
|
||||
$booking = $this->record;
|
||||
$landlord = config('fewo.owner.name') ?: config('app.name');
|
||||
|
||||
return "Guten Tag {$booking->guest->first_name} {$booking->guest->last_name},\n\n"
|
||||
."vielen Dank für Ihre Buchung der {$booking->property->name} vom {$booking->arrival->format('d.m.Y')} bis {$booking->departure->format('d.m.Y')}. "
|
||||
."Für den Mietvertrag benötigen wir noch Ihre Kontaktdaten: vollständige Anschrift (Straße, PLZ, Ort), eine E-Mail-Adresse und eine Telefonnummer.\n\n"
|
||||
."Sobald wir die Angaben haben, senden wir Ihnen den Vertrag mit allen Informationen zu.\n\n"
|
||||
."Freundliche Grüße\n{$landlord}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Form data of the offer modal as SendOffer changes (euro input → cents).
|
||||
*
|
||||
|
||||
@@ -2,18 +2,24 @@
|
||||
|
||||
namespace App\Filament\Resources\Bookings\Schemas;
|
||||
|
||||
use App\Actions\RecordPortalBooking;
|
||||
use App\Filament\Forms\Components\EuroInput;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
/**
|
||||
* Manual entry of a booking received by phone or e-mail. The price is calculated automatically.
|
||||
* Manual entry of a booking received by phone or e-mail, or made binding by a portal (e.g. FeWo-direkt, usually
|
||||
* without the guest's contact data). The price is calculated automatically; a portal price can be entered.
|
||||
*/
|
||||
class BookingForm
|
||||
{
|
||||
@@ -28,7 +34,8 @@ public static function configure(Schema $schema): Schema
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->required(),
|
||||
->required()
|
||||
->live(),
|
||||
TextInput::make('guests')
|
||||
->label('Personen')
|
||||
->integer()
|
||||
@@ -45,12 +52,25 @@ public static function configure(Schema $schema): Schema
|
||||
TextInput::make('promo_code')
|
||||
->label('Aktionscode'),
|
||||
]),
|
||||
Section::make('Buchungsweg')
|
||||
->description('Telefon oder E-Mail: nichts auswählen. Hat ein Portal die Buchung bereits verbindlich gemacht (z. B. FeWo-direkt), das Portal wählen – dann genügen Name und Zeitraum, die Kontaktdaten können später nachgetragen werden.')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('channel_id')
|
||||
->label('Über Portal')
|
||||
->placeholder('Direkt / telefonisch / per E-Mail')
|
||||
->options(fn (Get $get): array => Channel::query()->where('property_id', $get('property_id'))->orderBy('name')->pluck('name', 'id')->all())
|
||||
->live(),
|
||||
TextInput::make('portal_reference')->label('Referenz im Portal (Buchungsnummer)')->maxLength(100)->visible(fn (Get $get): bool => filled($get('channel_id'))),
|
||||
EuroInput::make('portal_total')->label('Preis laut Portal (Gesamtpreis, optional)')->helperText('Weicht er von unserer Berechnung ab, wird die Differenz als Zeile „Abweichung Portalpreis“ geführt.')->visible(fn (Get $get): bool => filled($get('channel_id'))),
|
||||
]),
|
||||
Section::make('Gast')
|
||||
->description(fn (Get $get): ?string => filled($get('channel_id')) ? 'Bei Portalbuchungen ohne Kontaktdaten genügt der Name – E-Mail und Adresse können später ergänzt werden.' : null)
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('first_name')->label('Vorname')->required()->maxLength(255),
|
||||
TextInput::make('last_name')->label('Nachname')->required()->maxLength(255),
|
||||
TextInput::make('email')->label('E-Mail')->email()->required()->maxLength(255),
|
||||
TextInput::make('email')->label('E-Mail')->email()->required(fn (Get $get): bool => blank($get('channel_id')))->maxLength(255),
|
||||
TextInput::make('phone')->label('Telefon')->tel()->maxLength(50),
|
||||
TextInput::make('street')->label('Straße')->maxLength(255),
|
||||
TextInput::make('postal_code')->label('PLZ')->maxLength(20),
|
||||
@@ -59,8 +79,19 @@ public static function configure(Schema $schema): Schema
|
||||
Section::make('Abschluss')
|
||||
->schema([
|
||||
Textarea::make('internal_notes')->label('Interne Notiz'),
|
||||
Toggle::make('confirm_immediately')->label('Sofort verbindlich bestätigen')->default(true),
|
||||
Toggle::make('send_mails')->label('E-Mails an den Gast senden')->default(false),
|
||||
Toggle::make('confirm_immediately')->label('Sofort verbindlich bestätigen')->default(true)->visible(fn (Get $get): bool => blank($get('channel_id'))),
|
||||
Toggle::make('send_mails')->label('E-Mails an den Gast senden')->default(false)->visible(fn (Get $get): bool => blank($get('channel_id'))),
|
||||
Radio::make('portal_process')
|
||||
->label('Wie geht der Vertragsprozess weiter?')
|
||||
->options([
|
||||
RecordPortalBooking::CONFIRM => 'Buchung bestätigen (Zeitraum belegen), Vertrag später – sobald die Kontaktdaten da sind',
|
||||
RecordPortalBooking::CONTRACT => 'Buchung bestätigen und Vertrag jetzt per E-Mail senden (E-Mail-Adresse nötig)',
|
||||
RecordPortalBooking::RECORD => 'Nur als Anfrage erfassen – alles Weitere von Hand',
|
||||
])
|
||||
->default(RecordPortalBooking::CONFIRM)
|
||||
->required(fn (Get $get): bool => filled($get('channel_id')))
|
||||
->visible(fn (Get $get): bool => filled($get('channel_id'))),
|
||||
Toggle::make('guest_confirmed')->label('Der Gast hat die Buchung bereits per E-Mail bestätigt')->visible(fn (Get $get): bool => filled($get('channel_id'))),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
use App\Availability\OccupancyOverview;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
@@ -18,7 +21,7 @@ class BookingsTable
|
||||
public static function configure(Table $table, ?int $guestId = null): Table
|
||||
{
|
||||
return $table
|
||||
->description('Eigene Anfragen und Buchungen sowie erkannte Portalreservierungen in einer Liste. Fehlende Gastzuordnungen lassen sich in den Details ergänzen; unbekannte Belegungen haben einen eigenen Klärungsbereich.')
|
||||
->description('Eigene Anfragen und Buchungen sowie erkannte Portalreservierungen in einer Liste. „Akte öffnen“ zeigt alles zu einem Vorgang: nächster Schritt, Vertrag, Zahlungen, Aufgaben und E-Mails. Fehlende Gastzuordnungen lassen sich in den Details ergänzen; unbekannte Belegungen haben einen eigenen Klärungsbereich.')
|
||||
->records(function (?string $search, ?string $sortColumn, ?string $sortDirection, array $filters, int $page, int|string $recordsPerPage) use ($guestId, $table): LengthAwarePaginator {
|
||||
$propertyId = filled($filters['property']['value'] ?? null) ? (int) $filters['property']['value'] : null;
|
||||
$records = app(OccupancyOverview::class)->records($propertyId, $guestId);
|
||||
@@ -32,6 +35,18 @@ public static function configure(Table $table, ?int $guestId = null): Table
|
||||
if ($filters['without_guest']['isActive'] ?? false) {
|
||||
$records = $records->where('guest_assigned', false);
|
||||
}
|
||||
if (filled($filters['channel']['value'] ?? null)) {
|
||||
$records = $records->where('channel_id', (int) $filters['channel']['value']);
|
||||
}
|
||||
if ($filters['contact_missing']['isActive'] ?? false) {
|
||||
$records = $records->filter(fn (array $record): bool => $record['record_type'] === 'booking' && blank($record['guest_email']));
|
||||
}
|
||||
if (filled($filters['period']['arrival_from'] ?? null)) {
|
||||
$records = $records->filter(fn (array $record): bool => $record['arrival'] >= $filters['period']['arrival_from']);
|
||||
}
|
||||
if (filled($filters['period']['arrival_until'] ?? null)) {
|
||||
$records = $records->filter(fn (array $record): bool => $record['arrival'] <= $filters['period']['arrival_until']);
|
||||
}
|
||||
if (filled($filters['kind']['value'] ?? null)) {
|
||||
$records = $records->where('record_type', $filters['kind']['value']);
|
||||
}
|
||||
@@ -41,6 +56,10 @@ public static function configure(Table $table, ?int $guestId = null): Table
|
||||
// Cancelled, declined and expired requests leave the main list (they stay available as archive).
|
||||
$records = $records->reject(fn (array $record): bool => in_array($record['status_key'], ['cancelled', 'declined', 'expired'], true));
|
||||
}
|
||||
if (! ($filters['show_closed']['isActive'] ?? false)) {
|
||||
// Bookings the landlord moved to the archive; they keep their whole history and show again with the archive filter.
|
||||
$records = $records->reject(fn (array $record): bool => $record['archived_booking']);
|
||||
}
|
||||
$column = in_array($sortColumn, ['arrival', 'departure', 'reference', 'guest', 'source', 'total'], true) ? $sortColumn : 'arrival';
|
||||
$records = $records->sortBy($column, SORT_REGULAR, $sortDirection === 'desc');
|
||||
$perPage = $recordsPerPage === 'all' ? max(1, $records->count()) : $recordsPerPage;
|
||||
@@ -50,15 +69,16 @@ public static function configure(Table $table, ?int $guestId = null): Table
|
||||
->defaultSort('arrival')->searchable()->recordAction(null)
|
||||
->columns([
|
||||
TextColumn::make('reference')->label('Nr. / Referenz')->sortable(),
|
||||
TextColumn::make('kind_label')->label('Art')->badge(),
|
||||
TextColumn::make('kind_label')->label('Art')->badge()->toggleable(),
|
||||
TextColumn::make('status')->label('Status')->badge()->color(fn (array $record): string => $record['color']),
|
||||
TextColumn::make('guest')->label('Gast / Namensinformation')->sortable()
|
||||
->description(fn (array $record): string => $record['guest_assigned'] ? ($record['guest_email'] ?? 'E-Mail unbekannt') : 'Gastzuordnung offen'),
|
||||
TextColumn::make('source')->label('Buchungskanal / Quelle')->sortable(),
|
||||
TextColumn::make('source')->label('Buchungskanal / Quelle')->sortable()->toggleable(),
|
||||
TextColumn::make('arrival')->label('Anreise')->date('d.m.Y')->sortable(),
|
||||
TextColumn::make('departure')->label('Abreise')->date('d.m.Y')->sortable()
|
||||
->description(fn (array $record): string => $record['nights'].' Nächte'),
|
||||
TextColumn::make('persons')->label('Personen')->placeholder('Unbekannt')->toggleable(isToggledHiddenByDefault: true),
|
||||
IconColumn::make('archived_booking')->label('Archiviert')->boolean()->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('total')->label('Bekannter Gesamtpreis')->money('EUR', divideBy: 100, locale: 'de')->placeholder('Unbekannt')->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('property')->label('Wohnung')->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
@@ -71,11 +91,17 @@ public static function configure(Table $table, ?int $guestId = null): Table
|
||||
...collect(BookingStatus::cases())->mapWithKeys(fn (BookingStatus $status): array => [$status->value => $status->getLabel()])->all(),
|
||||
'imported' => 'Im Portalkalender geführt', 'archived' => 'Nicht mehr im Kalenderfeed',
|
||||
]),
|
||||
SelectFilter::make('channel')->label('Buchungskanal')->options(fn (): array => Channel::query()->orderBy('name')->pluck('name', 'id')->all()),
|
||||
Filter::make('period')->label('Anreise im Zeitraum')->schema([
|
||||
DatePicker::make('arrival_from')->label('Anreise ab'),
|
||||
DatePicker::make('arrival_until')->label('Anreise bis'),
|
||||
])->columns(2),
|
||||
Filter::make('upcoming')->label('Nur kommende Aufenthalte'),
|
||||
Filter::make('show_closed')->label('Archiv anzeigen (storniert, abgelehnt, abgelaufen)'),
|
||||
Filter::make('contact_missing')->label('Kontaktdaten des Gastes fehlen'),
|
||||
Filter::make('show_closed')->label('Archiv anzeigen (archiviert, storniert, abgelehnt, abgelaufen)'),
|
||||
Filter::make('without_guest')->label('Gastzuordnung offen'),
|
||||
])
|
||||
->recordUrl(fn (array $record): string => $record['url'])
|
||||
->recordActions([Action::make('view')->label('Details')->url(fn (array $record): string => $record['url'])]);
|
||||
->recordActions([Action::make('view')->label(fn (array $record): string => $record['record_type'] === 'booking' ? 'Akte öffnen' : 'Details')->icon('heroicon-o-folder-open')->button()->color('primary')->url(fn (array $record): string => $record['url'])]);
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,13 @@ class CancellationPolicyResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedReceiptPercent;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Einrichtung';
|
||||
|
||||
protected static ?string $modelLabel = 'Stornoregel';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Stornoregeln';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -30,13 +30,13 @@ class CancellationResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedArchiveBoxXMark;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $modelLabel = 'Stornierung';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Stornierungen';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -20,13 +20,13 @@ class ChannelTaskResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedClipboardDocumentCheck;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $modelLabel = 'Portal-Aufgabe';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Portal-Aufgaben';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ class ChannelResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedArrowsRightLeft;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Einrichtung';
|
||||
|
||||
protected static ?string $navigationLabel = 'Kalenderabgleich (iCal)';
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ class ContractAnnexResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPaperClip;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Einrichtung';
|
||||
|
||||
protected static ?string $modelLabel = 'Vertragsanlage';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Vertragsanlagen';
|
||||
|
||||
protected static ?int $navigationSort = 8;
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -25,13 +25,13 @@ class ContractTemplateResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedDocumentDuplicate;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Einrichtung';
|
||||
|
||||
protected static ?string $modelLabel = 'Vertragsvorlage';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Vertragsvorlagen';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ class GuestResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUsers;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $modelLabel = 'Gast';
|
||||
|
||||
@@ -33,7 +33,7 @@ class GuestResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'last_name';
|
||||
|
||||
protected static ?int $navigationSort = 4;
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@ class InboxMessageResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedInbox;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $navigationLabel = 'Postfach';
|
||||
|
||||
@@ -31,7 +31,7 @@ class InboxMessageResource extends Resource
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Postfach';
|
||||
|
||||
protected static ?int $navigationSort = 0;
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -21,13 +21,13 @@ class PortalEmailResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedEnvelopeOpen;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $modelLabel = 'Portal-E-Mail';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Portal-E-Mails';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
protected static ?int $navigationSort = 8;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ class ManagePortalOccupations extends ManageRecords
|
||||
public function getTabs(): array
|
||||
{
|
||||
return [
|
||||
'unclear' => Tab::make('Ungeklärt')->modifyQueryUsing(fn (Builder $query) => $query->whereNull('deleted_at')->unclear()),
|
||||
'unclear' => Tab::make('Ungeklärt (zu tun)')->modifyQueryUsing(fn (Builder $query) => $query->whereNull('deleted_at')->unclear()),
|
||||
'all' => Tab::make('Alle Importereignisse')->modifyQueryUsing(fn (Builder $query) => $query->whereNull('deleted_at')),
|
||||
'archive' => Tab::make('Nicht mehr im Feed')->modifyQueryUsing(fn (Builder $query) => $query->onlyTrashed()),
|
||||
];
|
||||
|
||||
@@ -39,7 +39,7 @@ class PortalOccupationResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedQuestionMarkCircle;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $navigationLabel = 'Ungeklärte Belegungen';
|
||||
|
||||
@@ -47,7 +47,7 @@ class PortalOccupationResource extends Resource
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Portalbelegungen & Klärung';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public static function getNavigationBadgeColor(): string
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->description('Unbekannte Belegungen und mögliche Mehrfachdarstellungen persönlich klären. Auch ungeklärte führende Einträge halten ihre Nächte belegt.')
|
||||
return $table->description('So geht es: 1. „Einordnen“ – ist es eine Portalreservierung, eine Sperrzeit oder unbekannt? 2. „Klären“ – ist es eigenständig oder dieselbe Belegung wie ein anderer Eintrag (Doppelung)? 3. Der Gast lässt sich unter „Gast zuordnen“ ergänzen. Auch ungeklärte führende Einträge halten ihre Nächte belegt.')
|
||||
->defaultSort('starts_on')->columns([
|
||||
TextColumn::make('starts_on')->label('Anreise / Beginn')->date('d.m.Y')->sortable(),
|
||||
TextColumn::make('ends_on')->label('Abreise / Ende')->date('d.m.Y'),
|
||||
@@ -92,7 +92,7 @@ public static function occupationActions(): array
|
||||
|
||||
public static function classificationAction(): Action
|
||||
{
|
||||
return Action::make('classify')->label('Belegungsart / Zweck bearbeiten')
|
||||
return Action::make('classify')->label('Einordnen: Reservierung, Sperrzeit oder unbekannt')
|
||||
->visible(fn (BlockedPeriod $record): bool => in_array($record->source, ['channel', 'email'], true) && ! $record->is_representation && ! $record->trashed())
|
||||
->authorize(fn (BlockedPeriod $record): bool => auth()->user()?->can('update', $record) ?? false)
|
||||
->modalDescription('Nur bekannte Sachverhalte bestätigen. Die Einordnung ändert keine Termine, hebt keine Sperre auf und führt keine Ereignisse automatisch zusammen. Überschneidungen bleiben gesonderte Prüffälle.')
|
||||
|
||||
@@ -29,7 +29,7 @@ class PropertyResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedHomeModern;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Einrichtung';
|
||||
|
||||
protected static ?string $modelLabel = 'Wohnung';
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ class ReviewResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedStar;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Verwaltung';
|
||||
|
||||
protected static ?string $modelLabel = 'Bewertung';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Bewertungen';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?int $navigationSort = 9;
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
'source',
|
||||
'import_channel_id',
|
||||
'origin_channel_id',
|
||||
'portal_reference',
|
||||
'contact_requested_at',
|
||||
'guest_confirmed_at',
|
||||
'archived_at',
|
||||
'referral_source',
|
||||
'utm_source',
|
||||
'utm_medium',
|
||||
@@ -151,6 +155,9 @@ protected function casts(): array
|
||||
'balance_requested_at' => 'immutable_datetime',
|
||||
'balance_reminded_at' => 'immutable_datetime',
|
||||
'arrival_info_sent_at' => 'immutable_datetime',
|
||||
'contact_requested_at' => 'immutable_datetime',
|
||||
'guest_confirmed_at' => 'immutable_datetime',
|
||||
'archived_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -341,6 +348,15 @@ public function offerHtml(string $key): HtmlString
|
||||
return OfferTerms::html($this, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the booking may be moved to the archive: it is over (closed, or the stay has ended) and holds nothing.
|
||||
*/
|
||||
public function canBeArchived(): bool
|
||||
{
|
||||
return in_array($this->status, [BookingStatus::Cancelled, BookingStatus::Declined, BookingStatus::Expired], true)
|
||||
|| ($this->departure->isPast() && in_array($this->status, BookingStatus::occupying(), true));
|
||||
}
|
||||
|
||||
public function isHoldActive(): bool
|
||||
{
|
||||
return in_array($this->status, BookingStatus::holding(), true) && $this->hold_expires_at?->isFuture();
|
||||
|
||||
@@ -75,7 +75,7 @@ public function panel(Panel $panel): Panel
|
||||
->authenticatedRoutes(function (): void {
|
||||
Route::post('wohnung-wechseln', SwitchPropertyController::class)->name('switch-property');
|
||||
})
|
||||
->navigationGroups(['Vermietung', 'Webseite', 'System'])
|
||||
->navigationGroups(['Verwaltung', 'Einrichtung', 'Webseite', 'System'])
|
||||
->colors([
|
||||
'primary' => Color::Sky,
|
||||
])
|
||||
|
||||
@@ -60,6 +60,10 @@ public static function steps(Booking $booking): array
|
||||
|
||||
$steps[] = ['label' => 'Anfrage / Eingang', 'state' => 'done', 'detail' => $booking->created_at?->format('d.m.Y')];
|
||||
|
||||
if (in_array($kind, [self::PORTAL_BOOKING, self::PORTAL_INQUIRY], true)) {
|
||||
$steps[] = ['label' => 'Kontaktdaten des Gastes', 'state' => filled($booking->guest?->email) ? 'done' : ($closed ? 'skipped' : 'current'), 'detail' => filled($booking->guest?->email) ? null : ($booking->contact_requested_at ? 'erfragt am '.$booking->contact_requested_at->format('d.m.Y') : 'fehlen noch')];
|
||||
}
|
||||
|
||||
$needsOffer = in_array($kind, [self::OWN, self::PORTAL_INQUIRY, self::MANUAL], true);
|
||||
if ($needsOffer) {
|
||||
$steps[] = [
|
||||
@@ -126,6 +130,7 @@ public static function next(Booking $booking): array
|
||||
$booking->status === BookingStatus::Cancelled => ['title' => 'Storniert', 'text' => self::cancelledText($booking, $costs !== null || $wish !== null), 'color' => $costs !== null ? 'warning' : 'gray'],
|
||||
$booking->status === BookingStatus::Declined => ['title' => 'Abgelehnt', 'text' => 'Der Zeitraum ist wieder frei.', 'color' => 'gray'],
|
||||
$booking->status === BookingStatus::Expired => ['title' => 'Abgelaufen', 'text' => 'Die Haltefrist ist verstrichen. Sie können die Anfrage trotzdem noch bestätigen, solange der Zeitraum frei ist.', 'color' => 'gray'],
|
||||
blank($booking->guest?->email) && $booking->departure > $today => ['title' => 'Kontaktdaten fehlen', 'text' => ($booking->contact_requested_at ? 'Die Kontaktdaten wurden am '.$booking->contact_requested_at->format('d.m.Y').' erfragt – Antwort abwarten. ' : 'Den Gast um Kontaktdaten bitten („Gast um Kontaktdaten bitten“). ').'Sobald sie da sind: „Kontaktdaten eintragen“ – dort lässt sich der Vertragsprozess automatisch starten oder von Hand weiterführen.', 'color' => 'warning'],
|
||||
$booking->status === BookingStatus::Reserved => ['title' => 'Anfrage prüfen', 'text' => $kind === self::PORTAL_BOOKING
|
||||
? 'Kontaktdaten des Gastes eintragen, dann „Direkt bestätigen“ – der Vertrag geht per E-Mail an den Gast.'
|
||||
: 'Angebot senden („Angebot senden“) oder ablehnen.'.($booking->hold_expires_at ? ' Vorgemerkt bis '.$booking->hold_expires_at->format('d.m.Y, H:i').' Uhr.' : ' Es ist kein Zeitraum vorgemerkt.'), 'color' => 'warning'],
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('bookings', function (Blueprint $table): void {
|
||||
$table->string('portal_reference', 100)->nullable()->after('origin_channel_id');
|
||||
$table->timestamp('contact_requested_at')->nullable();
|
||||
$table->timestamp('guest_confirmed_at')->nullable();
|
||||
$table->timestamp('archived_at')->nullable()->index();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('bookings', function (Blueprint $table): void {
|
||||
$table->dropColumn(['portal_reference', 'contact_requested_at', 'guest_confirmed_at', 'archived_at']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -16,6 +16,7 @@
|
||||
.occupancy-event.kind-block { border-color:#6b7280; }
|
||||
.occupancy-event.kind-unknown { border-color:#d97706; }
|
||||
.occupancy-event small { display:block; color:var(--plan-muted); }
|
||||
.occupancy-event .occupancy-open { color:#0369a1; font-weight:600; margin-top:.2rem; }
|
||||
.occupancy-event:focus-visible { outline:3px solid #0284c7; outline-offset:2px; }
|
||||
.occupancy-departure { font-size:.75rem; color:var(--plan-muted); margin-top:.4rem; }
|
||||
.occupancy-warning { color:#b45309; font-weight:600; font-size:.8rem; }
|
||||
@@ -63,6 +64,7 @@
|
||||
@endif
|
||||
@if (!$event['guest_assigned'] && $event['kind'] === 'reservation')<small>Gastzuordnung offen</small>@endif
|
||||
@if ($event['needs_review'])<small>Klärung erforderlich</small>@endif
|
||||
<small class="occupancy-open">{{ $event['record_type'] === 'booking' ? 'Akte öffnen →' : 'Details →' }}</small>
|
||||
</a>
|
||||
@endforeach
|
||||
@foreach ($day['departures'] as $event)
|
||||
@@ -74,7 +76,7 @@
|
||||
<div class="occupancy-list">
|
||||
<h2 style="font-size:1.1rem;font-weight:700">Alle Vorgänge dieses Zeitraums</h2>
|
||||
<table>
|
||||
<thead><tr><th>Zeitraum</th><th>Art / Status</th><th>Gast</th><th>Kanal / Quelle</th><th>Hinweise</th></tr></thead>
|
||||
<thead><tr><th>Zeitraum</th><th>Art / Status</th><th>Gast</th><th>Kanal / Quelle</th><th>Hinweise</th><th>Akte</th></tr></thead>
|
||||
<tbody>
|
||||
@forelse ($calendar['rows'] as $event)
|
||||
<tr>
|
||||
@@ -93,9 +95,10 @@
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $event['review_note'] ?? ($event['kind'] === 'block' ? $event['reason'] : null) }}@if ($event['representations'])<br>{{ $event['representations'] }} zugeordnete Kalenderdarstellung(en)@endif</td>
|
||||
<td><x-filament::button tag="a" size="sm" :href="$event['url']">{{ $event['record_type'] === 'booking' ? 'Akte öffnen' : 'Details' }}</x-filament::button></td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr><td colspan="5">Keine Vorgänge in diesem Zeitraum.</td></tr>
|
||||
<tr><td colspan="6">Keine Vorgänge in diesem Zeitraum.</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -39,6 +39,9 @@ public function test_rentals_staff_starts_in_the_simple_mode_with_the_daily_menu
|
||||
->assertSee('Anfragen & Buchungen', false)
|
||||
->assertSee('Sperrzeiten')
|
||||
->assertSee('Portal-Aufgaben')
|
||||
->assertSee('Verwaltung')
|
||||
->assertDontSee('Kalenderabgleich')
|
||||
->assertDontSee('Vertragsvorlagen')
|
||||
->assertDontSee('Wohnungen')
|
||||
->assertDontSee('Portal-E-Mails')
|
||||
->assertSee('Zur Expertenansicht wechseln');
|
||||
@@ -76,7 +79,7 @@ public function test_prices_and_offers_page_bundles_seasons_offers_and_extras_in
|
||||
->assertSee('Saisons & Preise', false)
|
||||
->assertSee('Sonderangebote & Rabattcodes', false)
|
||||
->assertSee('Hochsaison Test');
|
||||
$this->get(Dashboard::getUrl())->assertSee('Preise & Angebote', false)->assertSee('Bilder')->assertDontSee('Erscheinungsbilder');
|
||||
$this->get(Dashboard::getUrl())->assertSee('Preise & Angebote', false)->assertDontSee('Erscheinungsbilder');
|
||||
|
||||
$this->actingAs(User::factory()->role(UserRole::Content)->create());
|
||||
$this->get(PricesAndOffers::getUrl())->assertForbidden();
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
use App\Enums\ChannelExportMode;
|
||||
use App\Enums\ChannelStatus;
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Resources\Channels\ChannelResource;
|
||||
use App\Filament\Resources\Channels\Pages\CreateChannel;
|
||||
use App\Filament\Resources\Channels\Pages\EditChannel;
|
||||
use App\Filament\Resources\Channels\Pages\ListChannels;
|
||||
@@ -120,7 +119,6 @@ public function test_rentals_role_can_reach_portal_management_in_simple_mode():
|
||||
$this->property();
|
||||
$this->actingAs(User::factory()->role(UserRole::Rentals)->create(['admin_mode' => AdminMode::Simple]));
|
||||
Livewire::test(ListChannels::class)->assertSuccessful();
|
||||
$this->assertTrue(ChannelResource::shouldRegisterNavigation());
|
||||
}
|
||||
|
||||
public function test_another_landlords_channel_cannot_be_seen_or_edited(): void
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Actions\ProvideGuestContact;
|
||||
use App\Actions\RecordPortalBooking;
|
||||
use App\Actions\ResolveChannelOccupation;
|
||||
use App\Actions\SetBookingStatus;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Filament\Resources\Bookings\Pages\CreateBooking;
|
||||
use App\Filament\Resources\Bookings\Pages\ListBookings;
|
||||
use App\Filament\Resources\Bookings\Pages\ViewBooking;
|
||||
use App\Mail\BookingConfirmed;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Models\User;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Support\BookingProgress;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Database\Seeders\PropertySeeder;
|
||||
use Database\Seeders\SiteSeeder;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Portal bookings entered without contact data, the contract process that follows (automatic or by hand),
|
||||
* manual status changes, the archive and the clarification of portal occupations.
|
||||
*/
|
||||
class PortalBookingTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
private Channel $portal;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->travelTo(CarbonImmutable::parse('2026-10-22 10:00'));
|
||||
$this->seed([PropertySeeder::class, SiteSeeder::class]);
|
||||
$this->property = Property::sole();
|
||||
$this->portal = Channel::factory()->for($this->property)->create(['name' => 'FeWo-direkt', 'booking_model' => ChannelBookingModel::PortalBooking]);
|
||||
Mail::fake();
|
||||
Storage::fake('local');
|
||||
$this->withoutVite();
|
||||
}
|
||||
|
||||
public function test_a_portal_booking_without_contact_data_occupies_the_dates_but_creates_no_contract(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM, total: 123400, reference: 'HA-123');
|
||||
|
||||
$this->assertSame(BookingStatus::Confirmed, $booking->status);
|
||||
$this->assertSame($this->portal->id, $booking->origin_channel_id);
|
||||
$this->assertSame('HA-123', $booking->portal_reference);
|
||||
$this->assertSame(123400, $booking->total);
|
||||
$this->assertSame('', $booking->guest->email);
|
||||
$this->assertNull($booking->contract_path);
|
||||
$this->assertSame(BookingProgress::PORTAL_BOOKING, BookingProgress::kind($booking));
|
||||
$this->assertSame('Kontaktdaten fehlen', BookingProgress::next($booking)['title']);
|
||||
Mail::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_an_immediate_contract_needs_the_email_address(): void
|
||||
{
|
||||
$this->expectException(ReservationException::class);
|
||||
|
||||
$this->record(RecordPortalBooking::CONTRACT);
|
||||
}
|
||||
|
||||
public function test_entering_the_contact_data_can_start_the_contract_automatically(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM);
|
||||
|
||||
$message = app(ProvideGuestContact::class)->handle($booking, ['email' => 'Gast@Example.test', 'street' => 'Hauptstr. 1', 'postal_code' => '18225', 'city' => 'Kühlungsborn'], ProvideGuestContact::AUTOMATIC, guestConfirmed: true);
|
||||
|
||||
$booking->refresh();
|
||||
$this->assertSame('Kontaktdaten gespeichert, Vertrag gesendet', $message);
|
||||
$this->assertSame('gast@example.test', $booking->guest->email);
|
||||
$this->assertNotNull($booking->contract_path);
|
||||
$this->assertNotNull($booking->guest_confirmed_at);
|
||||
Mail::assertSent(BookingConfirmed::class, 1);
|
||||
}
|
||||
|
||||
public function test_entering_the_contact_data_by_hand_sends_nothing(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM);
|
||||
|
||||
app(ProvideGuestContact::class)->handle($booking, ['email' => 'gast@example.test'], ProvideGuestContact::MANUAL);
|
||||
|
||||
$this->assertNull($booking->fresh()->contract_path);
|
||||
$this->assertSame('Vertrag senden', BookingProgress::next($booking->fresh())['title']);
|
||||
Mail::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_a_recorded_request_stays_open_and_automatic_continuation_needs_an_email(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::RECORD);
|
||||
$this->assertSame(BookingStatus::Reserved, $booking->status);
|
||||
|
||||
$this->expectException(ReservationException::class);
|
||||
app(ProvideGuestContact::class)->handle($booking, ['phone' => '0123'], ProvideGuestContact::AUTOMATIC);
|
||||
}
|
||||
|
||||
public function test_the_booking_form_records_a_portal_booking_and_the_page_offers_the_contact_actions(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(CreateBooking::class)
|
||||
->fillForm([
|
||||
'property_id' => $this->property->id, 'guests' => 2, 'arrival' => '2026-11-07', 'departure' => '2026-11-10',
|
||||
'channel_id' => $this->portal->id, 'portal_reference' => 'HA-9', 'portal_process' => RecordPortalBooking::CONFIRM,
|
||||
'first_name' => 'Erika', 'last_name' => 'Muster',
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$booking = Booking::query()->sole();
|
||||
$this->assertSame('HA-9', $booking->portal_reference);
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
|
||||
->assertActionVisible('requestContact')
|
||||
->callAction('requestContact')
|
||||
->assertNotified('Als angefragt vermerkt')
|
||||
->callAction('provideContact', ['guest' => ['first_name' => 'Erika', 'last_name' => 'Muster', 'email' => 'erika@example.test'], 'process' => ProvideGuestContact::MANUAL, 'guest_confirmed' => false])
|
||||
->assertNotified('Kontaktdaten gespeichert');
|
||||
|
||||
$this->assertNotNull($booking->fresh()->contact_requested_at);
|
||||
$this->assertSame('erika@example.test', $booking->fresh()->guest->email);
|
||||
}
|
||||
|
||||
public function test_status_can_be_changed_by_hand_with_a_reason_and_the_calendar_is_checked(): void
|
||||
{
|
||||
$booking = $this->record(RecordPortalBooking::CONFIRM);
|
||||
$set = app(SetBookingStatus::class);
|
||||
|
||||
$set->handle($booking, BookingStatus::Paid, 'Zahlung über das Portal erhalten', 'Test');
|
||||
$this->assertSame(BookingStatus::Paid, $booking->fresh()->status);
|
||||
$this->assertStringContainsString('Zahlung über das Portal erhalten', $booking->fresh()->internal_notes);
|
||||
|
||||
$booking->update(['status' => BookingStatus::Expired]);
|
||||
$other = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => '2026-11-08', 'departure' => '2026-11-09']);
|
||||
try {
|
||||
$set->handle($booking->fresh(), BookingStatus::Confirmed, 'wieder aufnehmen');
|
||||
$this->fail('The dates are taken, the booking must not become binding.');
|
||||
} catch (ReservationException) {
|
||||
$this->assertSame(BookingStatus::Expired, $booking->fresh()->status);
|
||||
}
|
||||
|
||||
$other->delete();
|
||||
$set->handle($booking->fresh(), BookingStatus::Confirmed, 'wieder aufnehmen');
|
||||
$this->assertSame(BookingStatus::Confirmed, $booking->fresh()->status);
|
||||
|
||||
$this->expectException(ReservationException::class);
|
||||
$set->handle($booking->fresh(), BookingStatus::Cancelled, 'nicht erlaubt');
|
||||
}
|
||||
|
||||
public function test_the_manual_status_action_is_not_offered_for_the_own_website_process(): void
|
||||
{
|
||||
$own = Booking::factory()->for($this->property)->reserved(now()->addHours(48))->create(['source' => 'website', 'arrival' => '2026-11-07', 'departure' => '2026-11-10']);
|
||||
$portal = $this->record(RecordPortalBooking::CONFIRM, arrival: '2026-12-01', departure: '2026-12-04');
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $own->getRouteKey()])->assertDontSee('Status von Hand ändern');
|
||||
Livewire::test(ViewBooking::class, ['record' => $portal->getRouteKey()])->assertSee('Status von Hand ändern')
|
||||
->callAction(TestAction::make('setStatus')->arguments([]), ['status' => BookingStatus::Paid->value, 'reason' => 'Portal zahlt aus'])
|
||||
->assertNotified('Status geändert');
|
||||
$this->assertSame(BookingStatus::Paid, $portal->fresh()->status);
|
||||
}
|
||||
|
||||
public function test_archived_bookings_leave_the_list_but_keep_everything(): void
|
||||
{
|
||||
$past = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Completed, 'arrival' => '2026-09-01', 'departure' => '2026-09-05']);
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(ViewBooking::class, ['record' => $past->getRouteKey()])->callAction(TestAction::make('archive')->arguments([]))->assertNotified('Archiviert');
|
||||
$this->assertNotNull($past->fresh()->archived_at);
|
||||
|
||||
Livewire::test(ListBookings::class)->assertDontSee($past->reference)
|
||||
->filterTable('show_closed', true)->assertSee($past->reference);
|
||||
}
|
||||
|
||||
public function test_the_list_filters_by_channel_period_and_missing_contact_data(): void
|
||||
{
|
||||
$portalBooking = $this->record(RecordPortalBooking::CONFIRM, arrival: '2026-12-01', departure: '2026-12-04');
|
||||
$own = Booking::factory()->for($this->property)->create(['status' => BookingStatus::Confirmed, 'arrival' => '2026-11-07', 'departure' => '2026-11-10']);
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(ListBookings::class)
|
||||
->filterTable('channel', $this->portal->id)->assertSee($portalBooking->reference)->assertDontSee($own->reference)
|
||||
->removeTableFilter('channel')
|
||||
->filterTable('contact_missing', true)->assertSee($portalBooking->reference)->assertDontSee($own->reference)
|
||||
->removeTableFilter('contact_missing')
|
||||
->filterTable('period', ['arrival_from' => '2026-11-01', 'arrival_until' => '2026-11-30'])->assertSee($own->reference)->assertDontSee($portalBooking->reference);
|
||||
}
|
||||
|
||||
public function test_an_independent_occupation_with_a_booking_channel_is_no_longer_unclear(): void
|
||||
{
|
||||
$block = BlockedPeriod::factory()->for($this->property)->create(['channel_id' => $this->portal->id, 'source' => 'channel', 'external_uid' => 'u1', 'starts_on' => '2027-05-23', 'ends_on' => '2027-05-30', 'occupation_kind' => OccupationKind::Unknown, 'needs_review' => true]);
|
||||
$this->assertSame(1, BlockedPeriod::query()->unclear()->count());
|
||||
|
||||
app(ResolveChannelOccupation::class)->handle($block, 'independent', originId: $this->portal->id);
|
||||
|
||||
$this->assertSame(0, BlockedPeriod::query()->unclear()->count());
|
||||
$this->assertSame(OccupationKind::Reservation, $block->fresh()->occupation_kind);
|
||||
}
|
||||
|
||||
private function record(string $process, ?int $total = null, ?string $reference = null, string $arrival = '2026-11-07', string $departure = '2026-11-10'): Booking
|
||||
{
|
||||
return app(RecordPortalBooking::class)->handle(
|
||||
$this->property,
|
||||
$this->portal,
|
||||
new StayRequest(CarbonImmutable::parse($arrival), CarbonImmutable::parse($departure), 2),
|
||||
['first_name' => 'Erika', 'last_name' => 'Muster'],
|
||||
$process,
|
||||
$reference,
|
||||
$total,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user