Zahlungsaufgaben, Freigabe-/Storno-Link, Vertragsvorlagen, Anreise-Mail
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m36s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m36s
- Zahlungen werden nicht mehr automatisch angemahnt: faellige Anzahlung/Restzahlung werden Aufgaben (Zahlungen & Wuensche, Tages-/Wochenuebersicht); Mail nur per Klick; je Portal und Buchungstyp abschaltbar - Freigabe-Link in der Eingangsbestaetigung, Storno-Link in der Buchungsbestaetigung; je Wohnung Wunsch / sofort / sofort bis Frist; Stornowuensche und Kosten bleiben Aufgabe des Gastgebers - Vertragsvorlagen mit Versionen (je Angebot, Portal oder Wohnung waehlbar), benutzte Versionen gesperrt; Angebot und finaler Vertrag als unveraenderliche PDF mit SHA-256, Vertrag wird nie neu geschrieben - Anreise-Mail je Wohnung einstellbar (Standard 3 Tage), neue Textfelder Schluessel/Parken/Ankunftstag Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eafab8a2cb
commit
a73b164ea1
51 files changed
+1807
-52
No files matched your search
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Enums\CancellationMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Mail\BookingCancelled;
|
||||
use App\Mail\CancellationRequested;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* The guest uses the cancellation link of the booking confirmation. Depending on the property's setting the
|
||||
* booking is cancelled at once (dates released) or only a request task is created for the landlord – costs
|
||||
* are never settled automatically. Repeating the click changes nothing.
|
||||
*/
|
||||
class CancelBookingByGuest
|
||||
{
|
||||
/**
|
||||
* What a click on the link does for this booking today.
|
||||
*/
|
||||
public function modeFor(Booking $booking): CancellationMode
|
||||
{
|
||||
$property = $booking->property;
|
||||
$freeUntil = $booking->arrival->subDays($property->free_cancellation_days);
|
||||
|
||||
return match ($property->cancellation_mode) {
|
||||
CancellationMode::Instant => CancellationMode::Instant,
|
||||
CancellationMode::InstantWhenFree => today()->lessThanOrEqualTo($freeUntil) ? CancellationMode::Instant : CancellationMode::Request,
|
||||
default => CancellationMode::Request,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CancellationMode|null what happened (Instant = cancelled, Request = request recorded); null when it had happened before
|
||||
*
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Booking $booking, ?string $message = null): ?CancellationMode
|
||||
{
|
||||
$outcome = DB::transaction(function () use ($booking, $message): ?CancellationMode {
|
||||
$booking->lockForTransition();
|
||||
|
||||
$alreadyAsked = BookingTask::query()->where('booking_id', $booking->id)->where('kind', BookingTaskKind::CancellationRequest)->exists();
|
||||
if ($booking->status === BookingStatus::Cancelled || $alreadyAsked) {
|
||||
return null;
|
||||
}
|
||||
if (! in_array($booking->status, BookingStatus::occupying(), true) || $booking->arrival->isPast()) {
|
||||
throw ReservationException::invalidTransition($booking->status->getLabel(), 'storniert');
|
||||
}
|
||||
|
||||
$mode = $this->modeFor($booking);
|
||||
if ($mode === CancellationMode::Instant) {
|
||||
$booking->update(['status' => BookingStatus::Cancelled, 'cancelled_at' => now()]);
|
||||
}
|
||||
BookingTask::query()->create([
|
||||
'booking_id' => $booking->id,
|
||||
'kind' => BookingTaskKind::CancellationRequest,
|
||||
'status' => BookingTaskStatus::Open,
|
||||
'note' => trim(($mode === CancellationMode::Instant ? 'Vom Gast storniert – bitte Stornokosten und Rückzahlung prüfen. ' : '').($message ?? '')) ?: null,
|
||||
]);
|
||||
|
||||
return $mode;
|
||||
});
|
||||
|
||||
if ($outcome !== null) {
|
||||
$this->notify($booking, $outcome);
|
||||
}
|
||||
|
||||
return $outcome;
|
||||
}
|
||||
|
||||
private function notify(Booking $booking, CancellationMode $mode): void
|
||||
{
|
||||
$booking->loadMissing(['guest', 'property']);
|
||||
$cancelled = $mode === CancellationMode::Instant;
|
||||
|
||||
$sends = [
|
||||
fn () => Mail::to(Settings::notificationRecipients())->send(new CancellationRequested($booking, $cancelled)),
|
||||
fn () => $booking->guest?->email ? Mail::to($booking->guest->email, $booking->guest->full_name)->send(new BookingCancelled($booking, $cancelled)) : null,
|
||||
];
|
||||
foreach ($sends as $send) {
|
||||
try {
|
||||
$send();
|
||||
} catch (Throwable $exception) {
|
||||
Log::warning('Stornomitteilung nicht zugestellt', ['booking' => $booking->id, 'exception' => $exception::class]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Mail\OfferAnswered;
|
||||
use App\Models\Booking;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* The guest releases a held request or offer through the link in the mail – the dates are free again at once.
|
||||
* Repeating it is harmless. The link only reaches requests that are still held; a binding booking is never touched.
|
||||
*/
|
||||
class ReleaseReservation
|
||||
{
|
||||
/**
|
||||
* @return bool true when this call released the dates, false when they had been released before
|
||||
*
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Booking $booking): bool
|
||||
{
|
||||
$released = DB::transaction(function () use ($booking): bool {
|
||||
$booking->lockForTransition();
|
||||
|
||||
if ($booking->status === BookingStatus::Declined && $booking->declined_by === 'guest') {
|
||||
return false;
|
||||
}
|
||||
if (! in_array($booking->status, BookingStatus::holding(), true)) {
|
||||
throw ReservationException::invalidTransition($booking->status->getLabel(), 'freigegeben');
|
||||
}
|
||||
|
||||
$booking->update(['status' => BookingStatus::Declined, 'declined_by' => 'guest', 'hold_expires_at' => null]);
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if ($released) {
|
||||
try {
|
||||
Mail::to(Settings::notificationRecipients())->send(new OfferAnswered($booking, accepted: false));
|
||||
} catch (Throwable $exception) {
|
||||
Log::warning('Meldung über Freigabe nicht zugestellt', ['booking' => $booking->id, 'exception' => $exception::class]);
|
||||
}
|
||||
}
|
||||
|
||||
return $released;
|
||||
}
|
||||
}
|
||||
@@ -3,22 +3,27 @@
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Mail\ArrivalInformation;
|
||||
use App\Mail\PaymentReminder;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Daily booking workflow: payment requests and reminders, arrival information, completion after departure.
|
||||
* Every message is sent at most once per booking.
|
||||
* Daily booking workflow. Payments are never chased automatically: due payments become tasks for the landlord
|
||||
* (BookingTask, once per booking and kind) who checks the payment and sends the reminder on a click
|
||||
* ({@see SendPaymentReminder}). Only the arrival information goes out by itself, once per booking, the configured
|
||||
* number of days before arrival. Completion after departure.
|
||||
*/
|
||||
class SendBookingReminders
|
||||
{
|
||||
private const BALANCE_REQUEST_DAYS_BEFORE = 7;
|
||||
|
||||
private const ARRIVAL_INFO_DAYS_BEFORE = 7;
|
||||
/** Upper bound of the per-property setting; the property decides the actual day. */
|
||||
private const ARRIVAL_INFO_MAX_DAYS_BEFORE = 14;
|
||||
|
||||
/**
|
||||
* @return array{deposit_overdue: int, balance_request: int, balance_overdue: int, arrival_info: int, completed: int}
|
||||
@@ -33,7 +38,7 @@ public function handle(): array
|
||||
->whereNull('deposit_reminded_at')
|
||||
->whereDate('deposit_due_on', '<', $today))
|
||||
->filter(fn (Booking $booking): bool => $booking->openDeposit() > 0);
|
||||
$this->remind($depositOverdue, PaymentReminder::DEPOSIT_OVERDUE, 'deposit_reminded_at');
|
||||
$depositTasks = $this->createTasks($depositOverdue, BookingTaskKind::DepositReminder, fn (Booking $booking) => $booking->deposit_due_on);
|
||||
|
||||
$balanceRequest = $this->bookings(fn (Builder $query) => $query
|
||||
->whereIn('status', $unpaid)
|
||||
@@ -41,20 +46,21 @@ public function handle(): array
|
||||
->whereDate('balance_due_on', '>=', $today)
|
||||
->whereDate('balance_due_on', '<=', $today->copy()->addDays(self::BALANCE_REQUEST_DAYS_BEFORE)))
|
||||
->filter(fn (Booking $booking): bool => ! $booking->requiresFullPayment() && $booking->openAmount() > 0 && $booking->status === BookingStatus::DepositPaid);
|
||||
$this->remind($balanceRequest, PaymentReminder::BALANCE_REQUEST, 'balance_requested_at');
|
||||
$requestTasks = $this->createTasks($balanceRequest, BookingTaskKind::BalanceRequest, fn (Booking $booking) => $booking->balance_due_on);
|
||||
|
||||
$balanceOverdue = $this->bookings(fn (Builder $query) => $query
|
||||
->whereIn('status', $unpaid)
|
||||
->whereNull('balance_reminded_at')
|
||||
->whereDate('balance_due_on', '<', $today))
|
||||
->filter(fn (Booking $booking): bool => $booking->openAmount() > 0 && ($booking->status === BookingStatus::DepositPaid || $booking->requiresFullPayment()));
|
||||
$this->remind($balanceOverdue, PaymentReminder::BALANCE_OVERDUE, 'balance_reminded_at');
|
||||
$overdueTasks = $this->createTasks($balanceOverdue, BookingTaskKind::BalanceReminder, fn (Booking $booking) => $booking->balance_due_on);
|
||||
|
||||
$arrivals = $this->bookings(fn (Builder $query) => $query
|
||||
->whereIn('status', BookingStatus::occupying())
|
||||
->whereNull('arrival_info_sent_at')
|
||||
->whereDate('arrival', '>=', $today)
|
||||
->whereDate('arrival', '<=', $today->copy()->addDays(self::ARRIVAL_INFO_DAYS_BEFORE)));
|
||||
->whereDate('arrival', '<=', $today->copy()->addDays(self::ARRIVAL_INFO_MAX_DAYS_BEFORE)))
|
||||
->filter(fn (Booking $booking): bool => $booking->arrival->lessThanOrEqualTo($today->copy()->addDays($booking->property->arrival_info_days_before)));
|
||||
foreach ($arrivals as $booking) {
|
||||
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new ArrivalInformation($booking));
|
||||
$booking->update(['arrival_info_sent_at' => now()]);
|
||||
@@ -67,9 +73,9 @@ public function handle(): array
|
||||
$completed->each->update(['status' => BookingStatus::Completed]);
|
||||
|
||||
return [
|
||||
'deposit_overdue' => $depositOverdue->count(),
|
||||
'balance_request' => $balanceRequest->count(),
|
||||
'balance_overdue' => $balanceOverdue->count(),
|
||||
'deposit_overdue' => $depositTasks,
|
||||
'balance_request' => $requestTasks,
|
||||
'balance_overdue' => $overdueTasks,
|
||||
'arrival_info' => $arrivals->count(),
|
||||
'completed' => $completed->count(),
|
||||
];
|
||||
@@ -81,7 +87,7 @@ public function handle(): array
|
||||
*/
|
||||
private function bookings(callable $constraints): Collection
|
||||
{
|
||||
return $constraints(Booking::query()->with(['guest', 'property', 'payments']))
|
||||
return $constraints(Booking::query()->with(['guest', 'property', 'payments', 'importChannel', 'originChannel']))
|
||||
->whereHas('guest', fn (Builder $query) => $query->whereNull('anonymized_at')->whereNotNull('email')->where('email', '!=', ''))
|
||||
->get()
|
||||
->toBase();
|
||||
@@ -89,12 +95,20 @@ private function bookings(callable $constraints): Collection
|
||||
|
||||
/**
|
||||
* @param Collection<int, Booking> $bookings
|
||||
* @param callable(Booking): mixed $dueOn
|
||||
* @return int the number of tasks created now
|
||||
*/
|
||||
private function remind(Collection $bookings, string $kind, string $sentAtColumn): void
|
||||
private function createTasks(Collection $bookings, BookingTaskKind $kind, callable $dueOn): int
|
||||
{
|
||||
foreach ($bookings as $booking) {
|
||||
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new PaymentReminder($booking, $kind));
|
||||
$booking->update([$sentAtColumn => now()]);
|
||||
$created = 0;
|
||||
foreach ($bookings->filter(fn (Booking $booking): bool => $booking->wantsPaymentTasks()) as $booking) {
|
||||
$task = BookingTask::query()->firstOrCreate(
|
||||
['booking_id' => $booking->id, 'kind' => $kind],
|
||||
['status' => BookingTaskStatus::Open, 'due_on' => $dueOn($booking)],
|
||||
);
|
||||
$created += $task->wasRecentlyCreated ? 1 : 0;
|
||||
}
|
||||
|
||||
return $created;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Mail\OfferMade;
|
||||
use App\Models\Booking;
|
||||
use App\Models\ContractTemplate;
|
||||
use App\Pricing\PriceCalculator;
|
||||
use App\Pricing\PriceQuote;
|
||||
use App\Pricing\QuoteException;
|
||||
@@ -42,7 +43,7 @@ public function __construct(
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array{arrival?: string, departure?: string, guests?: int, promo_code?: ?string, price_adjustment?: ?int, price_adjustment_label?: ?string, valid_until?: ?string, offer_message?: ?string, guest?: array<string, ?string>} $changes
|
||||
* @param array{arrival?: string, departure?: string, guests?: int, promo_code?: ?string, price_adjustment?: ?int, price_adjustment_label?: ?string, valid_until?: ?string, offer_message?: ?string, contract_template_id?: int|string|null, guest?: array<string, ?string>} $changes
|
||||
*
|
||||
* @throws QuoteException
|
||||
* @throws ReservationException
|
||||
@@ -97,7 +98,7 @@ public function handle(Booking $booking, array $changes = [], bool $sendMail = t
|
||||
'offer_version' => $booking->offer_version + 1,
|
||||
'offer_sent_at' => now(),
|
||||
'offer_message' => $changes['offer_message'] ?? null,
|
||||
'offer_terms' => OfferTerms::capture(),
|
||||
'offer_terms' => OfferTerms::capture($this->templateFor($booking, $changes)),
|
||||
]);
|
||||
$booking->refresh();
|
||||
$booking->update(['offer_hash' => OfferTerms::hash($booking)]);
|
||||
@@ -113,6 +114,20 @@ public function handle(Booking $booking, array $changes = [], bool $sendMail = t
|
||||
return $booking;
|
||||
}
|
||||
|
||||
/**
|
||||
* The contract template of this offer: chosen explicitly, else the portal's default, else the property's.
|
||||
*
|
||||
* @param array<string, mixed> $changes
|
||||
*/
|
||||
private function templateFor(Booking $booking, array $changes): ?ContractTemplate
|
||||
{
|
||||
$id = filled($changes['contract_template_id'] ?? null)
|
||||
? (int) $changes['contract_template_id']
|
||||
: ($booking->importChannel ?? $booking->originChannel)?->contract_template_id ?? $booking->property->contract_template_id;
|
||||
|
||||
return $id ? ContractTemplate::query()->find($id) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the offer mail. The offer is already saved (and its validity runs), so a failing mail server is
|
||||
* recorded in the admin inbox and reported to the caller instead of being lost.
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Mail\PaymentReminder;
|
||||
use App\Models\BookingTask;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Sends the payment mail belonging to a task – only when the landlord decides to, after checking the payment.
|
||||
* The task is completed and the dispatch is recorded on the booking; a failing mail server leaves the task open.
|
||||
*/
|
||||
class SendPaymentReminder
|
||||
{
|
||||
/**
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(BookingTask $task, string $by): void
|
||||
{
|
||||
$reminder = $task->kind->reminder();
|
||||
$booking = $task->booking->loadMissing(['guest', 'property', 'payments']);
|
||||
|
||||
if ($reminder === null) {
|
||||
throw new ReservationException('Zu dieser Aufgabe gibt es keine Zahlungs-E-Mail.');
|
||||
}
|
||||
if (blank($booking->guest?->email)) {
|
||||
throw new ReservationException('Der Gast hat keine E-Mail-Adresse.');
|
||||
}
|
||||
if ($booking->openAmount() <= 0) {
|
||||
throw new ReservationException('Die Buchung ist bereits vollständig bezahlt.');
|
||||
}
|
||||
|
||||
[$kind, $column] = $reminder;
|
||||
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new PaymentReminder($booking, $kind));
|
||||
$booking->update([$column => now()]);
|
||||
$task->complete($by);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Documents;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\ContractTemplate;
|
||||
use App\Support\Content;
|
||||
use Filament\Forms\Components\RichEditor\RichContentRenderer;
|
||||
use Illuminate\Support\HtmlString;
|
||||
@@ -28,13 +29,16 @@ class OfferTerms
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array{captured_at: string, texts: array<string, ?string>, deposit_due_days: int, owner: array<string, mixed>, bank: array<string, mixed>}
|
||||
* @return array{captured_at: string, template: ?array{id: int, name: string, version: int}, texts: array<string, ?string>, deposit_due_days: int, owner: array<string, mixed>, bank: array<string, mixed>}
|
||||
*/
|
||||
public static function capture(): array
|
||||
public static function capture(?ContractTemplate $template = null): array
|
||||
{
|
||||
$overrides = $template?->overrides() ?? [];
|
||||
|
||||
return [
|
||||
'captured_at' => now()->toIso8601String(),
|
||||
'texts' => collect(self::TEXT_KEYS)->mapWithKeys(fn (string $key): array => [$key => Content::get($key)])->all(),
|
||||
'template' => $template ? ['id' => $template->id, 'name' => $template->name, 'version' => $template->version] : null,
|
||||
'texts' => collect(self::TEXT_KEYS)->mapWithKeys(fn (string $key): array => [$key => $overrides[$key] ?? Content::get($key)])->all(),
|
||||
'deposit_due_days' => (int) config('fewo.deposit_due_days'),
|
||||
'owner' => (array) config('fewo.owner'),
|
||||
'bank' => (array) config('fewo.bank'),
|
||||
|
||||
@@ -28,12 +28,18 @@ public function generate(Booking $booking, bool $draft = false): string
|
||||
// fetching anything over the network. Each website has its own (A14).
|
||||
$logo = $booking->website()?->brandPath(Site::BRAND_DOCUMENT_LOGO);
|
||||
|
||||
Storage::disk(self::DISK)->put($path, Pdf::loadView('pdf.contract', [
|
||||
// The final contract is a document of record: once stored it is never rewritten (confirmation resends reuse it).
|
||||
if (! $draft && $booking->contract_path !== null && Storage::disk(self::DISK)->exists($booking->contract_path)) {
|
||||
return $booking->contract_path;
|
||||
}
|
||||
|
||||
$pdf = Pdf::loadView('pdf.contract', [
|
||||
'booking' => $booking,
|
||||
'draft' => $draft,
|
||||
'logo' => $logo,
|
||||
])->setPaper('a4')->output());
|
||||
$booking->update([$draft ? 'offer_path' : 'contract_path' => $path]);
|
||||
])->setPaper('a4')->output();
|
||||
Storage::disk(self::DISK)->put($path, $pdf);
|
||||
$booking->update([$draft ? 'offer_path' : 'contract_path' => $path, $draft ? 'offer_pdf_sha256' : 'contract_pdf_sha256' => hash('sha256', $pdf)]);
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Filament\Pages\PricesAndOffers;
|
||||
use App\Filament\Resources\BlockedPeriods\BlockedPeriodResource;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Filament\Resources\BookingTasks\BookingTaskResource;
|
||||
use App\Filament\Resources\Channels\ChannelResource;
|
||||
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
|
||||
use App\Filament\Resources\Guests\GuestResource;
|
||||
@@ -37,6 +38,7 @@ enum AdminMode: string implements HasDescription, HasLabel
|
||||
PricesAndOffers::class,
|
||||
GuestResource::class,
|
||||
ChannelTaskResource::class,
|
||||
BookingTaskResource::class,
|
||||
ChannelResource::class,
|
||||
ReviewResource::class,
|
||||
PhotoResource::class,
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Mail\PaymentReminder;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What the landlord has to do about a booking. Payment tasks are created by the daily run; nothing is
|
||||
* sent to the guest until the landlord has checked the payment and chooses to send the mail.
|
||||
*/
|
||||
enum BookingTaskKind: string implements HasLabel
|
||||
{
|
||||
case DepositReminder = 'deposit_reminder';
|
||||
case BalanceRequest = 'balance_request';
|
||||
case BalanceReminder = 'balance_reminder';
|
||||
case CancellationRequest = 'cancellation_request';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::DepositReminder => 'Anzahlung überfällig – anmahnen',
|
||||
self::BalanceRequest => 'Restzahlung bald fällig – anfordern',
|
||||
self::BalanceReminder => 'Restzahlung überfällig – anmahnen',
|
||||
self::CancellationRequest => 'Stornierungswunsch des Gastes',
|
||||
};
|
||||
}
|
||||
|
||||
public function isPayment(): bool
|
||||
{
|
||||
return $this !== self::CancellationRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mail kind (App\Mail\PaymentReminder) and the booking column that records its dispatch.
|
||||
*
|
||||
* @return array{0: string, 1: string}|null
|
||||
*/
|
||||
public function reminder(): ?array
|
||||
{
|
||||
return match ($this) {
|
||||
self::DepositReminder => [PaymentReminder::DEPOSIT_OVERDUE, 'deposit_reminded_at'],
|
||||
self::BalanceRequest => [PaymentReminder::BALANCE_REQUEST, 'balance_requested_at'],
|
||||
self::BalanceReminder => [PaymentReminder::BALANCE_OVERDUE, 'balance_reminded_at'],
|
||||
self::CancellationRequest => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum BookingTaskStatus: string implements HasColor, HasLabel
|
||||
{
|
||||
case Open = 'open';
|
||||
case Done = 'done';
|
||||
case Dismissed = 'dismissed';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Open => 'Offen',
|
||||
self::Done => 'Erledigt',
|
||||
self::Dismissed => 'Verworfen',
|
||||
};
|
||||
}
|
||||
|
||||
public function getColor(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Open => 'warning',
|
||||
self::Done => 'success',
|
||||
self::Dismissed => 'gray',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What the cancellation link in the booking confirmation does.
|
||||
*/
|
||||
enum CancellationMode: string implements HasLabel
|
||||
{
|
||||
/** The guest sends a request; the landlord decides and settles costs. */
|
||||
case Request = 'request';
|
||||
|
||||
/** The booking is cancelled at once and the dates are released. */
|
||||
case Instant = 'instant';
|
||||
|
||||
/** Cancelled at once while the stay is still far enough away (free cancellation), otherwise a request. */
|
||||
case InstantWhenFree = 'instant_when_free';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Request => 'Nur Stornierungswunsch – ich entscheide',
|
||||
self::Instant => 'Sofort stornieren (Ein-Klick)',
|
||||
self::InstantWhenFree => 'Sofort stornieren bis zur Frist der kostenfreien Stornierung, danach Wunsch',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public function getLabel(): string
|
||||
self::Requests => 'Offene Anfragen und Angebote',
|
||||
self::News => 'Neu seit der letzten Übersicht',
|
||||
self::Stays => 'An- und Abreisen',
|
||||
self::Payments => 'Überfällige Zahlungen',
|
||||
self::Payments => 'Zahlungsaufgaben und Gästewünsche',
|
||||
self::Portals => 'Portale: Aufgaben und Klärungsfälle',
|
||||
self::Reviews => 'Bewertungen zur Freigabe',
|
||||
};
|
||||
@@ -38,7 +38,7 @@ public function getDescription(): string
|
||||
self::Requests => 'Anfragen und Angebote, die auf Sie oder den Gast warten, mit Frist',
|
||||
self::News => 'Neue Anfragen, Buchungen, Stornierungen und Portalbuchungen',
|
||||
self::Stays => 'Heute und morgen, in der Wochenübersicht die nächsten 7 Tage',
|
||||
self::Payments => 'Anzahlungen und Restzahlungen nach Fälligkeit',
|
||||
self::Payments => 'Offene Aufgaben: fällige Zahlungen (nur wo Sie selbst mahnen) und Stornierungswünsche',
|
||||
self::Portals => 'Offene Portal-Aufgaben, zu prüfende Portal-Mails und Kalendereinträge, Abgleichsfehler',
|
||||
self::Reviews => 'Neue Bewertungen, die noch nicht freigegeben sind',
|
||||
};
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BookingTasks;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Resources\BookingTasks\Pages\ListBookingTasks;
|
||||
use App\Filament\Resources\BookingTasks\Tables\BookingTasksTable;
|
||||
use App\Models\BookingTask;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class BookingTaskResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
|
||||
protected static ?string $model = BookingTask::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBanknotes;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
|
||||
protected static ?string $modelLabel = 'Buchungsaufgabe';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Zahlungen & Wünsche';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return BookingTasksTable::configure($table);
|
||||
}
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
$open = BookingTask::query()->open()->count();
|
||||
|
||||
return $open > 0 ? (string) $open : null;
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): string
|
||||
{
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListBookingTasks::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BookingTasks\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\BookingTasks\BookingTaskResource;
|
||||
use App\Models\Property;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListBookingTasks extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = BookingTaskResource::class;
|
||||
|
||||
protected function scopeToProperty(Builder $query, Property $property): Builder
|
||||
{
|
||||
return $query->whereHas('booking', fn (Builder $booking) => $booking->where('property_id', $property->id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BookingTasks\Tables;
|
||||
|
||||
use App\Actions\SendPaymentReminder;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Models\BookingTask;
|
||||
use App\Support\Money;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Throwable;
|
||||
|
||||
class BookingTasksTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', 'desc')
|
||||
->description('Fällige Zahlungen und Wünsche von Gästen. Es wird nichts automatisch an Gäste gesendet: Bitte erst den Zahlungseingang prüfen, dann die Erinnerung per Klick senden oder die Aufgabe abhaken.')
|
||||
->columns([
|
||||
TextColumn::make('booking.reference')->label('Buchung')->weight('medium')->description(fn (BookingTask $record): string => $record->booking->guest?->full_name ?? ''),
|
||||
TextColumn::make('kind')->label('Aufgabe')->badge(),
|
||||
TextColumn::make('due_on')->label('Fällig seit')->date('d.m.Y')->placeholder('–'),
|
||||
TextColumn::make('open')->label('Offen')->state(fn (BookingTask $record): string => Money::format($record->booking->openAmount())),
|
||||
TextColumn::make('status')->label('Status')->badge()
|
||||
->description(fn (BookingTask $record): ?string => $record->completed_by ? "{$record->completed_by}, {$record->completed_at?->format('d.m. H:i')}" : null),
|
||||
TextColumn::make('note')->label('Hinweis')->wrap()->placeholder('–'),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')->label('Status')->options(BookingTaskStatus::class)->default(BookingTaskStatus::Open->value),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('booking')
|
||||
->label('Buchung')
|
||||
->icon(Heroicon::OutlinedArrowTopRightOnSquare)
|
||||
->color('gray')
|
||||
->url(fn (BookingTask $record): string => BookingResource::getUrl('view', ['record' => $record->booking])),
|
||||
Action::make('send')
|
||||
->label('Mail an Gast senden')
|
||||
->icon(Heroicon::OutlinedEnvelope)
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Haben Sie den Zahlungseingang geprüft? Der Gast erhält die Zahlungs-E-Mail sofort.')
|
||||
->visible(fn (BookingTask $record): bool => $record->status === BookingTaskStatus::Open && $record->kind->reminder() !== null)
|
||||
->action(function (BookingTask $record, SendPaymentReminder $send): void {
|
||||
try {
|
||||
$send->handle($record, auth()->user()->name);
|
||||
} catch (ReservationException $exception) {
|
||||
Notification::make()->title('Nicht möglich')->body($exception->getMessage())->danger()->send();
|
||||
|
||||
return;
|
||||
} catch (Throwable) {
|
||||
Notification::make()->title('E-Mail konnte nicht gesendet werden')->body('Die Aufgabe bleibt offen.')->danger()->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Notification::make()->title('E-Mail gesendet')->success()->send();
|
||||
}),
|
||||
Action::make('done')
|
||||
->label('Erledigt')
|
||||
->icon(Heroicon::OutlinedCheck)
|
||||
->color('success')
|
||||
->visible(fn (BookingTask $record): bool => $record->status === BookingTaskStatus::Open)
|
||||
->action(fn (BookingTask $record) => $record->complete(auth()->user()->name)),
|
||||
Action::make('dismiss')
|
||||
->label('Verwerfen')
|
||||
->icon(Heroicon::OutlinedXMark)
|
||||
->color('gray')
|
||||
->requiresConfirmation()
|
||||
->visible(fn (BookingTask $record): bool => $record->status === BookingTaskStatus::Open)
|
||||
->action(fn (BookingTask $record) => $record->update(['status' => BookingTaskStatus::Dismissed])),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Filament\Actions\AssignGuestAction;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Models\Booking;
|
||||
use App\Models\ContractTemplate;
|
||||
use App\Pricing\PriceCalculator;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
@@ -20,6 +21,7 @@
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
@@ -85,6 +87,13 @@ protected function getHeaderActions(): array
|
||||
TextInput::make('price_adjustment_label')->label('Bezeichnung')->placeholder('Nachlass / Zuschlag')->maxLength(80),
|
||||
Text::make(fn (Get $get): string => $this->offerPricePreview($get))->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Vertragsvorlage')->schema([
|
||||
Select::make('contract_template_id')
|
||||
->label('Vorlage für dieses Angebot')
|
||||
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
|
||||
->placeholder('Standard (Portal / Wohnung / Webseite)')
|
||||
->helperText('Die Texte werden beim Versand fest im Angebot abgelegt.'),
|
||||
]),
|
||||
Section::make('Gültigkeit & Nachricht')->columns(2)->schema([
|
||||
DateTimePicker::make('valid_until')
|
||||
->label('Angebot gültig bis')
|
||||
@@ -187,16 +196,6 @@ protected function getHeaderActions(): array
|
||||
->visible(fn (): bool => $this->record->contract_path !== null)
|
||||
->action(fn (RentalContract $contract) => response()->download($contract->absolutePath($this->record) ?? abort(404), "Mietvertrag-{$this->record->reference}.pdf")),
|
||||
ActionGroup::make([
|
||||
Action::make('regenerateContract')
|
||||
->label('Mietvertrag neu erzeugen')
|
||||
->icon(Heroicon::OutlinedArrowPath)
|
||||
->visible(fn (): bool => in_array($this->record->status, [...BookingStatus::occupying()], true))
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Der Vertrag wird mit den Bedingungen des angenommenen Angebots neu erstellt. Der Gast erhält ihn nicht automatisch.')
|
||||
->action(function (RentalContract $contract): void {
|
||||
$contract->generate($this->record);
|
||||
Notification::make()->title('Mietvertrag neu erzeugt')->success()->send();
|
||||
}),
|
||||
Action::make('notes')
|
||||
->label('Interne Notiz bearbeiten')
|
||||
->icon(Heroicon::OutlinedPencilSquare)
|
||||
|
||||
@@ -74,7 +74,7 @@ public static function configure(Schema $schema): Schema
|
||||
->visible(fn (Booking $record): bool => $record->isDirect()),
|
||||
TextEntry::make('offer')
|
||||
->label('Angebot')
|
||||
->state(fn (Booking $record): string => 'Version '.$record->offer_version.', gesendet '.$record->offer_sent_at?->format('d.m.Y, H:i').' · Prüfsumme '.substr((string) $record->offer_hash, 0, 12))
|
||||
->state(fn (Booking $record): string => 'Version '.$record->offer_version.', gesendet '.$record->offer_sent_at?->format('d.m.Y, H:i').' · Prüfsumme '.substr((string) $record->offer_hash, 0, 12).(isset($record->offer_terms['template']) ? ' · Vorlage '.$record->offer_terms['template']['name'].' v'.$record->offer_terms['template']['version'] : ''))
|
||||
->visible(fn (Booking $record): bool => $record->offer_version > 0),
|
||||
TextEntry::make('accepted_at')->label('Angenommen am')->dateTime('d.m.Y, H:i:s')->visible(fn (Booking $record): bool => $record->accepted_at !== null),
|
||||
TextEntry::make('confirmation')
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
use App\Enums\ChannelExportMode;
|
||||
use App\Enums\ChannelStatus;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ContractTemplate;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
@@ -49,7 +50,20 @@ public static function configure(Schema $schema, bool $selectProperty = false):
|
||||
->maxLength(100),
|
||||
Select::make('status')->label('Kanalstatus')->options(ChannelStatus::class)->default(ChannelStatus::Setup)->required(),
|
||||
Select::make('booking_model')->label('Buchungsmodell')->options(ChannelBookingModel::class)->default(ChannelBookingModel::Mixed)->required()
|
||||
->helperText('Fachliche Einordnung; löst keine automatischen Buchungsentscheidungen aus.'),
|
||||
->helperText('„Portalbuchung“ und „Gemischt“ gelten als Sofortbuchung: automatische Angebote für diese Wohnung warten, bis das Portal unseren Kalender abgerufen hat. „Vermittlung / Anfrage“: keine Sofortbuchung.'),
|
||||
Select::make('contract_template_id')
|
||||
->label('Vertragsvorlage für dieses Portal')
|
||||
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
|
||||
->placeholder('Standard der Wohnung')
|
||||
->helperText('Für Angebote zu Buchungen, die über dieses Portal kommen und dessen Vorgaben (z. B. Stornofristen) entsprechen müssen.'),
|
||||
Toggle::make('payment_tasks_inquiry')
|
||||
->label('Zahlungsaufgaben bei Anfragen über dieses Portal')
|
||||
->helperText('Fällige Anzahlungen/Restzahlungen erscheinen als Aufgabe (Mails an Gäste gehen nie automatisch).')
|
||||
->default(true),
|
||||
Toggle::make('payment_tasks_reservation')
|
||||
->label('Zahlungsaufgaben bei Reservierungen über dieses Portal')
|
||||
->helperText('Aus, wenn das Portal das Geld einzieht und mahnt (z. B. FeWo-direkt Online-Buchung).')
|
||||
->default(false),
|
||||
Select::make('connector')
|
||||
->label('Kalenderanbindung')
|
||||
->helperText('Diese Verbindung gleicht Belegungszeiträume über iCal ab. Weitere Portalfunktionen benötigen eine eigene Anbindung.')
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContractTemplates;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Resources\ContractTemplates\Pages\CreateContractTemplate;
|
||||
use App\Filament\Resources\ContractTemplates\Pages\EditContractTemplate;
|
||||
use App\Filament\Resources\ContractTemplates\Pages\ListContractTemplates;
|
||||
use App\Filament\Resources\ContractTemplates\Schemas\ContractTemplateForm;
|
||||
use App\Filament\Resources\ContractTemplates\Tables\ContractTemplatesTable;
|
||||
use App\Models\ContractTemplate;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use UnitEnum;
|
||||
|
||||
class ContractTemplateResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
|
||||
protected static ?string $model = ContractTemplate::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedDocumentDuplicate;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
|
||||
protected static ?string $modelLabel = 'Vertragsvorlage';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Vertragsvorlagen';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ContractTemplateForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ContractTemplatesTable::configure($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* A version used in an offer is a document of record and is never edited; a new version is made instead.
|
||||
*/
|
||||
public static function canEdit(Model $record): bool
|
||||
{
|
||||
return ! $record->isUsed();
|
||||
}
|
||||
|
||||
public static function canDelete(Model $record): bool
|
||||
{
|
||||
return ! $record->isUsed();
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListContractTemplates::route('/'),
|
||||
'create' => CreateContractTemplate::route('/create'),
|
||||
'edit' => EditContractTemplate::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContractTemplates\Pages;
|
||||
|
||||
use App\Filament\Resources\ContractTemplates\ContractTemplateResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateContractTemplate extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ContractTemplateResource::class;
|
||||
|
||||
/**
|
||||
* A new template starts with version 1; further versions are made from an existing one.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$data['version'] = 1;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContractTemplates\Pages;
|
||||
|
||||
use App\Filament\Resources\ContractTemplates\ContractTemplateResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditContractTemplate extends EditRecord
|
||||
{
|
||||
protected static string $resource = ContractTemplateResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [DeleteAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContractTemplates\Pages;
|
||||
|
||||
use App\Filament\Resources\ContractTemplates\ContractTemplateResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListContractTemplates extends ListRecords
|
||||
{
|
||||
protected static string $resource = ContractTemplateResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [CreateAction::make()];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContractTemplates\Schemas;
|
||||
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ContractTemplateForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
$editor = fn (string $field, string $label): RichEditor => RichEditor::make("texts.{$field}")
|
||||
->label($label)
|
||||
->toolbarButtons([['bold', 'italic', 'link'], ['bulletList', 'orderedList']])
|
||||
->columnSpanFull();
|
||||
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')->label('Name der Vorlage')->required()->maxLength(120)
|
||||
->helperText('z. B. „Direktbuchung“ oder „Portal XY“. Versionen derselben Vorlage haben denselben Namen.'),
|
||||
TextInput::make('version')->label('Version')->integer()->default(1)->disabled()->dehydrated(false)
|
||||
->helperText('Neue Versionen entstehen über „Neue Version“ in der Liste. Eine Vorlage, die in einem Angebot verwendet wurde, kann nicht mehr geändert werden.'),
|
||||
Section::make('Texte dieser Vorlage')
|
||||
->description('Nur ausgefüllte Felder ersetzen die Texte der Webseite (Texte › Aufenthalt / Vertrag); leere Felder übernehmen den Webseitentext. Beim Versand des Angebots wird eine Kopie fest abgelegt.')
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
$editor('terms', 'Mietbedingungen'),
|
||||
$editor('cancellation', 'Rücktritt / Stornierung'),
|
||||
$editor('house_rules', 'Hausordnung'),
|
||||
Textarea::make('texts.intro')->label('Vertragseinleitung')->rows(3)->columnSpanFull(),
|
||||
Textarea::make('texts.closing')->label('Vertragsschluss')->rows(3)->columnSpanFull(),
|
||||
Textarea::make('texts.contract_note')->label('Hinweis im Angebots-PDF')->rows(3)->columnSpanFull(),
|
||||
]),
|
||||
Textarea::make('notes')->label('Interne Notiz')->rows(2)->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContractTemplates\Tables;
|
||||
|
||||
use App\Models\ContractTemplate;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ContractTemplatesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('name')
|
||||
->columns([
|
||||
TextColumn::make('name')->label('Vorlage')->searchable()->weight('medium'),
|
||||
TextColumn::make('version')->label('Version')->badge(),
|
||||
IconColumn::make('used')->label('In Angeboten verwendet')->boolean()->state(fn (ContractTemplate $record): bool => $record->isUsed()),
|
||||
TextColumn::make('updated_at')->label('Geändert')->dateTime('d.m.Y, H:i'),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
Action::make('newVersion')
|
||||
->label('Neue Version')
|
||||
->icon(Heroicon::OutlinedDocumentDuplicate)
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Es wird eine Kopie mit der nächsten Versionsnummer angelegt, die Sie dann bearbeiten können. Die bisherige Version bleibt unverändert.')
|
||||
->action(function (ContractTemplate $record): void {
|
||||
$copy = $record->newVersion();
|
||||
Notification::make()->title('Version '.$copy->version.' angelegt')->success()->send();
|
||||
}),
|
||||
DeleteAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Filament\Resources\Properties\Schemas;
|
||||
|
||||
use App\Enums\CancellationMode;
|
||||
use App\Enums\OfferMode;
|
||||
use App\Filament\Forms\Components\EuroInput;
|
||||
use App\ImageWorlds\ImageWorldRegistry;
|
||||
use App\Models\ContractTemplate;
|
||||
use App\Models\Site;
|
||||
use Closure;
|
||||
use Filament\Forms\Components\Select;
|
||||
@@ -116,6 +118,34 @@ public static function configure(Schema $schema): Schema
|
||||
->minValue(1)
|
||||
->suffix('Stunden')
|
||||
->default(48),
|
||||
Select::make('cancellation_mode')
|
||||
->label('Stornierungslink in der Buchungsbestätigung')
|
||||
->options(CancellationMode::class)
|
||||
->default(CancellationMode::Request)
|
||||
->required()
|
||||
->live()
|
||||
->helperText('Bei Sofort-Stornierung wird der Zeitraum frei; Kosten und Rückzahlung bleiben immer Ihre Aufgabe.'),
|
||||
TextInput::make('free_cancellation_days')
|
||||
->label('Kostenfrei stornierbar bis')
|
||||
->integer()
|
||||
->minValue(0)
|
||||
->suffix('Tage vor Anreise')
|
||||
->default(14)
|
||||
->visible(fn (Get $get): bool => $get('cancellation_mode') === CancellationMode::InstantWhenFree->value || $get('cancellation_mode') === CancellationMode::InstantWhenFree),
|
||||
Select::make('contract_template_id')
|
||||
->label('Standard-Vertragsvorlage')
|
||||
->options(fn (): array => ContractTemplate::query()->orderBy('name')->orderBy('version')->get()->mapWithKeys(fn (ContractTemplate $template): array => [$template->id => $template->label()])->all())
|
||||
->placeholder('Texte der Webseite')
|
||||
->helperText('Wird bei neuen Angeboten verwendet, sofern das Portal keine eigene Vorlage hat.'),
|
||||
TextInput::make('arrival_info_days_before')
|
||||
->label('Anreise-E-Mail senden')
|
||||
->helperText('Automatische Mail mit den letzten Hinweisen (Texte unter Texte › Aufenthalt).')
|
||||
->required()
|
||||
->integer()
|
||||
->minValue(1)
|
||||
->maxValue(14)
|
||||
->suffix('Tage vor Anreise')
|
||||
->default(3),
|
||||
Toggle::make('pre_reservation_enabled')
|
||||
->label('Anfrage blockiert den Kalender (Vorreservierung)')
|
||||
->helperText('Aus: eine bloße Anfrage sperrt keinen Zeitraum. Dann ist kein automatisches Angebot möglich.')
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\CancelBookingByGuest;
|
||||
use App\Actions\ReleaseReservation;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\CancellationMode;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\Booking;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
/**
|
||||
* Pages behind the signed links in the guest's mails: release a held request, cancel a booking. Opening a page
|
||||
* changes nothing; only the button on it does (POST, signed, rate limited).
|
||||
*/
|
||||
class SelfServiceController extends Controller
|
||||
{
|
||||
public function showRelease(Booking $booking): View
|
||||
{
|
||||
$booking->loadMissing(['guest', 'property']);
|
||||
|
||||
return view('self-service.release', [
|
||||
'booking' => $booking,
|
||||
'canRelease' => in_array($booking->status, BookingStatus::holding(), true) && $booking->isHoldActive(),
|
||||
'released' => $booking->status === BookingStatus::Declined && $booking->declined_by === 'guest',
|
||||
'action' => $this->signed('reservations.release.confirm', $booking, now()->addHour()),
|
||||
'title' => 'Zeitraum freigeben',
|
||||
]);
|
||||
}
|
||||
|
||||
public function release(Booking $booking, ReleaseReservation $release): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$release->handle($booking);
|
||||
} catch (ReservationException $exception) {
|
||||
return redirect()->to($this->signed('reservations.release', $booking, now()->addDays(2)))->with('self-service.error', $exception->getMessage());
|
||||
}
|
||||
|
||||
return redirect()->to($this->signed('reservations.release', $booking, now()->addDays(30)))->with('self-service.success', 'Vielen Dank – der Zeitraum ist wieder freigegeben.');
|
||||
}
|
||||
|
||||
public function showCancel(Booking $booking, CancelBookingByGuest $cancel): View
|
||||
{
|
||||
$booking->loadMissing(['guest', 'property']);
|
||||
$open = in_array($booking->status, BookingStatus::occupying(), true) && ! $booking->arrival->isPast();
|
||||
|
||||
return view('self-service.cancel', [
|
||||
'booking' => $booking,
|
||||
'canCancel' => $open && ! $booking->cancellationRequested(),
|
||||
'alreadyAsked' => $booking->status === BookingStatus::Cancelled || $booking->cancellationRequested(),
|
||||
'instant' => $cancel->modeFor($booking) === CancellationMode::Instant,
|
||||
'action' => $this->signed('bookings.cancel.confirm', $booking, now()->addHour()),
|
||||
'title' => 'Buchung stornieren',
|
||||
]);
|
||||
}
|
||||
|
||||
public function cancel(Request $request, Booking $booking, CancelBookingByGuest $cancel): RedirectResponse
|
||||
{
|
||||
$data = $request->validate(['message' => ['nullable', 'string', 'max:1000']]);
|
||||
$back = fn (int $days): string => $this->signed('bookings.cancel', $booking, now()->addDays($days));
|
||||
|
||||
try {
|
||||
$outcome = $cancel->handle($booking, $data['message'] ?? null);
|
||||
} catch (ReservationException $exception) {
|
||||
return redirect()->to($back(2))->with('self-service.error', $exception->getMessage());
|
||||
}
|
||||
|
||||
$success = match ($outcome) {
|
||||
CancellationMode::Instant => 'Ihre Buchung ist storniert. Eine Bestätigung haben wir Ihnen per E-Mail gesendet.',
|
||||
CancellationMode::Request => 'Wir haben Ihren Stornierungswunsch erhalten. Ihre Buchung bleibt bestehen, bis wir uns bei Ihnen gemeldet haben.',
|
||||
default => 'Ihr Stornierungswunsch liegt uns bereits vor.',
|
||||
};
|
||||
|
||||
return redirect()->to($back(30))->with('self-service.success', $success);
|
||||
}
|
||||
|
||||
private function signed(string $name, Booking $booking, DateTimeInterface $expiration): string
|
||||
{
|
||||
$parameters = ['booking' => $booking];
|
||||
|
||||
return $booking->website()?->temporarySignedRoute($name, $expiration, $parameters)
|
||||
?? URL::temporarySignedRoute($name, $expiration, $parameters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Booking;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Address;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* To the guest after using the cancellation link: either the booking is cancelled or the request was received.
|
||||
*/
|
||||
class BookingCancelled extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public function __construct(public Booking $booking, public bool $cancelled) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: ($this->cancelled ? 'Stornierung ' : 'Ihr Stornierungswunsch ').$this->booking->reference,
|
||||
replyTo: [new Address(config('fewo.owner.email'), config('fewo.owner.name'))],
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(markdown: 'mail.booking-cancelled');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Booking;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* To the landlord: a guest cancelled a booking or asks to.
|
||||
*/
|
||||
class CancellationRequested extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public function __construct(public Booking $booking, public bool $cancelled) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(subject: ($this->cancelled ? 'Storniert: ' : 'Stornierungswunsch: ').$this->booking->reference.' – '.$this->booking->guest->full_name);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(markdown: 'mail.cancellation-requested');
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
use App\Documents\OfferTerms;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\ChannelBookingModel;
|
||||
use App\Enums\ReferralSource;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Models\Concerns\HasChannelProvenance;
|
||||
@@ -57,6 +59,8 @@
|
||||
'offer_path',
|
||||
'offer_terms',
|
||||
'offer_hash',
|
||||
'offer_pdf_sha256',
|
||||
'contract_pdf_sha256',
|
||||
'message',
|
||||
'internal_notes',
|
||||
'confirmed_at',
|
||||
@@ -266,6 +270,31 @@ public function requiresFullPayment(): bool
|
||||
return $this->deposit_due_on !== null && $this->balance_due_on->lessThanOrEqualTo($this->deposit_due_on);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the landlord chases payments of this booking. Own bookings: always. Portal bookings: as configured
|
||||
* per channel and kind – a reservation whose payment the portal collects (e.g. instant booking) needs no
|
||||
* tasks, a mere inquiry passed on by the portal does.
|
||||
*/
|
||||
public function wantsPaymentTasks(): bool
|
||||
{
|
||||
$channel = $this->importChannel ?? $this->originChannel;
|
||||
if ($channel === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $channel->booking_model === ChannelBookingModel::PortalBooking
|
||||
? $channel->payment_tasks_reservation
|
||||
: $channel->payment_tasks_inquiry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the guest already asked to cancel (or cancelled) through the cancellation link.
|
||||
*/
|
||||
public function cancellationRequested(): bool
|
||||
{
|
||||
return BookingTask::query()->where('booking_id', $this->id)->where('kind', BookingTaskKind::CancellationRequest)->exists();
|
||||
}
|
||||
|
||||
public function nights(): int
|
||||
{
|
||||
return (int) $this->arrival->diffInDays($this->departure);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\BookingTaskKind;
|
||||
use App\Enums\BookingTaskStatus;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Something the landlord has to do about a booking. One task per booking and kind; a finished or
|
||||
* dismissed task is never created again.
|
||||
*/
|
||||
#[Fillable(['booking_id', 'kind', 'status', 'due_on', 'note', 'completed_by', 'completed_at'])]
|
||||
class BookingTask extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'kind' => BookingTaskKind::class,
|
||||
'status' => BookingTaskStatus::class,
|
||||
'due_on' => 'immutable_date',
|
||||
'completed_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Booking, $this>
|
||||
*/
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<BookingTask> $query
|
||||
* @return Builder<BookingTask>
|
||||
*/
|
||||
#[Scope]
|
||||
protected function open(Builder $query): Builder
|
||||
{
|
||||
return $query->where('status', BookingTaskStatus::Open);
|
||||
}
|
||||
|
||||
public function complete(string $by): void
|
||||
{
|
||||
$this->update(['status' => BookingTaskStatus::Done, 'completed_by' => $by, 'completed_at' => now()]);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
* A sales channel (portal) of a property. Our system leads: occupations are imported from the
|
||||
* channel and every channel gets its own export feed without its own occupations.
|
||||
*/
|
||||
#[Fillable(['property_id', 'name', 'connector', 'settings', 'is_active', 'requires_manual_blocking', 'manage_url', 'status', 'booking_model', 'import_enabled', 'export_enabled', 'export_mode', 'external_poll_minutes', 'echo_behavior', 'echo_notes', 'operating_notes', 'portal_verified_at'])]
|
||||
#[Fillable(['property_id', 'name', 'connector', 'settings', 'is_active', 'requires_manual_blocking', 'manage_url', 'status', 'booking_model', 'import_enabled', 'export_enabled', 'export_mode', 'external_poll_minutes', 'echo_behavior', 'echo_notes', 'operating_notes', 'portal_verified_at', 'payment_tasks_inquiry', 'payment_tasks_reservation', 'contract_template_id'])]
|
||||
#[Hidden(['export_token', 'previous_export_token', 'export_snapshot', 'settings', 'ical_analysis'])]
|
||||
class Channel extends Model
|
||||
{
|
||||
@@ -72,6 +72,8 @@ protected function casts(): array
|
||||
'booking_model' => ChannelBookingModel::class,
|
||||
'echo_behavior' => ChannelEchoBehavior::class,
|
||||
'portal_verified_at' => 'immutable_datetime',
|
||||
'payment_tasks_inquiry' => 'boolean',
|
||||
'payment_tasks_reservation' => 'boolean',
|
||||
'export_mode' => ChannelExportMode::class,
|
||||
'import_enabled' => 'boolean',
|
||||
'export_enabled' => 'boolean',
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* A version of contract texts for offers (e.g. conditions demanded by a portal). The texts replace the website
|
||||
* texts of the same meaning when an offer is made; the offer then freezes a copy. A version that has been used in
|
||||
* an offer is never edited – a new version is created instead.
|
||||
*/
|
||||
#[Fillable(['name', 'version', 'texts', 'notes'])]
|
||||
class ContractTemplate extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
/** Form/storage key => website text key it replaces in an offer. */
|
||||
public const TEXTS = [
|
||||
'intro' => 'contract.intro',
|
||||
'terms' => 'contract.terms',
|
||||
'closing' => 'contract.closing',
|
||||
'cancellation' => 'stay.cancellation',
|
||||
'house_rules' => 'stay.house_rules',
|
||||
'contract_note' => 'offer.contract_note',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return ['texts' => 'array', 'version' => 'integer'];
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return $this->name.' (Version '.$this->version.')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Texts by website text key; blank ones fall back to the website texts.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function overrides(): array
|
||||
{
|
||||
$overrides = [];
|
||||
foreach (self::TEXTS as $field => $key) {
|
||||
$value = $this->texts[$field] ?? null;
|
||||
if (filled($value) && trim(strip_tags((string) $value)) !== '') {
|
||||
$overrides[$key] = (string) $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $overrides;
|
||||
}
|
||||
|
||||
public function isUsed(): bool
|
||||
{
|
||||
return Booking::query()->where('offer_terms->template->id', $this->id)->exists();
|
||||
}
|
||||
|
||||
public function newVersion(): self
|
||||
{
|
||||
$latest = static::query()->where('name', $this->name)->max('version');
|
||||
|
||||
return static::query()->create([
|
||||
'name' => $this->name,
|
||||
'version' => $latest + 1,
|
||||
'texts' => $this->texts,
|
||||
'notes' => $this->notes,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\CancellationMode;
|
||||
use App\Enums\OfferMode;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Carbon\CarbonImmutable;
|
||||
@@ -32,6 +33,10 @@
|
||||
'hold_hours',
|
||||
'offer_mode',
|
||||
'pre_reservation_enabled',
|
||||
'arrival_info_days_before',
|
||||
'cancellation_mode',
|
||||
'free_cancellation_days',
|
||||
'contract_template_id',
|
||||
'check_in_time',
|
||||
'check_out_time',
|
||||
'changeover_weekday',
|
||||
@@ -61,6 +66,9 @@ class Property extends Model
|
||||
'min_stay_absolute' => 2,
|
||||
'offer_mode' => 'manual',
|
||||
'pre_reservation_enabled' => true,
|
||||
'arrival_info_days_before' => 3,
|
||||
'cancellation_mode' => 'request',
|
||||
'free_cancellation_days' => 14,
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
@@ -69,6 +77,9 @@ protected function casts(): array
|
||||
'is_active' => 'boolean',
|
||||
'offer_mode' => OfferMode::class,
|
||||
'pre_reservation_enabled' => 'boolean',
|
||||
'arrival_info_days_before' => 'integer',
|
||||
'cancellation_mode' => CancellationMode::class,
|
||||
'free_cancellation_days' => 'integer',
|
||||
'min_stay_fill_gaps' => 'boolean',
|
||||
'min_stay_until_changeover' => 'boolean',
|
||||
'changeover_weekday' => 'integer',
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
use App\Enums\ReviewStatus;
|
||||
use App\Filament\Pages\OccupancyCalendar;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Filament\Resources\BookingTasks\BookingTaskResource;
|
||||
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
|
||||
use App\Filament\Resources\InboxMessages\InboxMessageResource;
|
||||
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
|
||||
use App\Filament\Resources\Reviews\ReviewResource;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\BookingTask;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ChannelTask;
|
||||
use App\Models\InboxMessage;
|
||||
@@ -50,7 +52,7 @@ public function build(array $sections, bool $weekly, CarbonImmutable $since): ar
|
||||
DigestSection::Requests => ['Offene Anfragen und Angebote', $this->requests(), BookingResource::getUrl('index'), 'Buchungen öffnen'],
|
||||
DigestSection::News => ['Neu seit '.$since->format('d.m. H:i').' Uhr', $this->news($since), BookingResource::getUrl('index'), 'Buchungen öffnen'],
|
||||
DigestSection::Stays => [$weekly ? 'An- und Abreisen der nächsten 7 Tage' : 'An- und Abreisen heute und morgen', $this->stays($weekly ? 7 : 2), OccupancyCalendar::getUrl(), 'Belegungsplan öffnen'],
|
||||
DigestSection::Payments => ['Überfällige Zahlungen', $this->payments(), BookingResource::getUrl('index'), 'Buchungen öffnen'],
|
||||
DigestSection::Payments => ['Zahlungsaufgaben und Gästewünsche', $this->payments(), BookingTaskResource::getUrl('index'), 'Aufgaben öffnen'],
|
||||
DigestSection::Portals => ['Portale: Aufgaben und Klärungsfälle', $this->portals(), ChannelTaskResource::getUrl('index'), 'Portal-Aufgaben öffnen'],
|
||||
DigestSection::Reviews => ['Bewertungen zur Freigabe', $this->reviews(), ReviewResource::getUrl('index'), 'Bewertungen öffnen'],
|
||||
};
|
||||
@@ -149,13 +151,8 @@ private function stayEvents(array &$events, CarbonImmutable $from, CarbonImmutab
|
||||
*/
|
||||
private function payments(): Collection
|
||||
{
|
||||
return Booking::query()->whereIn('status', [BookingStatus::Confirmed, BookingStatus::DepositPaid])->with(['guest', 'property', 'payments'])->orderBy('arrival')->get()
|
||||
->map(fn (Booking $booking): ?string => match (true) {
|
||||
$booking->status === BookingStatus::Confirmed && $booking->deposit_due_on?->isPast() && $booking->openDeposit() > 0 => $this->booking($booking).' – Anzahlung '.Money::format($booking->openDeposit()).' seit '.$booking->deposit_due_on->format('d.m.').' fällig',
|
||||
$booking->balance_due_on?->isPast() && $booking->openAmount() > 0 => $this->booking($booking).' – offen '.Money::format($booking->openAmount()).' seit '.$booking->balance_due_on->format('d.m.').' fällig',
|
||||
default => null,
|
||||
})
|
||||
->filter()
|
||||
return BookingTask::query()->open()->with('booking.guest', 'booking.property')->oldest()->get()
|
||||
->map(fn (BookingTask $task): string => $this->booking($task->booking).' – '.$task->kind->getLabel().($task->due_on ? ' (seit '.$task->due_on->format('d.m.').')' : ''))
|
||||
->values();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\Booking;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
/**
|
||||
* Signed links the guest finds in mails to release a held request or to cancel a booking (no account needed).
|
||||
* They only open a page; nothing changes before the guest confirms there.
|
||||
*/
|
||||
class SelfServiceLinks
|
||||
{
|
||||
/** Releases a request or offer the guest does not want; valid as long as the dates are held. */
|
||||
public static function release(Booking $booking): string
|
||||
{
|
||||
return self::signed('reservations.release', $booking, $booking->hold_expires_at ?? now()->addDays(14));
|
||||
}
|
||||
|
||||
/** Cancels (or asks to cancel) a binding booking; valid until the day of arrival. */
|
||||
public static function cancel(Booking $booking): string
|
||||
{
|
||||
return self::signed('bookings.cancel', $booking, CarbonImmutable::parse($booking->arrival)->endOfDay());
|
||||
}
|
||||
|
||||
private static function signed(string $route, Booking $booking, \DateTimeInterface $until): string
|
||||
{
|
||||
$parameters = ['booking' => $booking];
|
||||
|
||||
return $booking->website()?->temporarySignedRoute($route, $until, $parameters)
|
||||
?? URL::temporarySignedRoute($route, $until, $parameters);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user