Phase 3: Zahlungen, Mietvertrag, Erinnerungen, Anreiseinformationen

- Zahlungen erfassen (inkl. Erstattungen), Status automatisch: Bestätigt → Anzahlung erhalten → Bezahlt → Abgeschlossen
- Anzahlungsfrist bei Bestätigung; kurzfristige Buchungen: Gesamtbetrag sofort
- Mietvertrag als PDF (dompdf, Font-Subsetting), bei Bestätigung gespeichert und angehängt; Texte im Admin (Muster)
- Täglich: Zahlungserinnerungen (Anzahlung/Rest überfällig, Kopie an Vermieter), Zahlungsaufforderung Rest 7 Tage vorher, Anreiseinfos 7 Tage vorher, Abschluss nach Abreise
- Admin: Zahlungen je Buchung, offene Beträge, Vertrag herunterladen/neu erzeugen

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 13:29:41 +02:00
1 parent e5f9e0762f
commit 0bf302fcf9
29 files changed
+1248 -18

No files matched your search

+11 -2
View File
@@ -3,6 +3,7 @@
namespace App\Actions;
use App\Availability\AvailabilityChecker;
use App\Documents\RentalContract;
use App\Enums\BookingStatus;
use App\Exceptions\ReservationException;
use App\Mail\BookingConfirmed;
@@ -11,11 +12,16 @@
use Illuminate\Support\Facades\Mail;
/**
* The landlord accepts a reservation. Expired reservations can still be confirmed while the dates are free.
* The landlord accepts a reservation: the booking becomes binding, payment due dates are fixed,
* the rental contract is generated and sent with the confirmation.
* Expired reservations can still be confirmed while the dates are free.
*/
class ConfirmBooking
{
public function __construct(private AvailabilityChecker $availability) {}
public function __construct(
private AvailabilityChecker $availability,
private RentalContract $contract,
) {}
/**
* @throws ReservationException
@@ -35,9 +41,12 @@ public function handle(Booking $booking, bool $notifyGuest = true): void
'status' => BookingStatus::Confirmed,
'hold_expires_at' => null,
'confirmed_at' => now(),
'deposit_due_on' => today()->addDays(config('fewo.deposit_due_days'))->toDateString(),
]);
});
$this->contract->generate($booking);
if ($notifyGuest) {
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new BookingConfirmed($booking));
}
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace App\Actions;
use App\Enums\BookingStatus;
use App\Enums\PaymentMethod;
use App\Models\Booking;
use App\Models\Payment;
use Carbon\CarbonInterface;
use Illuminate\Support\Facades\DB;
/**
* Records a received payment (or a refund with a negative amount) and moves the booking along:
* Bestätigt → Anzahlung erhalten → Bezahlt.
*/
class RecordPayment
{
public function handle(Booking $booking, int $amount, CarbonInterface $paidOn, PaymentMethod $method = PaymentMethod::Transfer, ?string $note = null, ?string $recordedBy = null): Payment
{
return DB::transaction(function () use ($booking, $amount, $paidOn, $method, $note, $recordedBy): Payment {
$payment = $booking->payments()->create([
'amount' => $amount,
'paid_on' => $paidOn->toDateString(),
'method' => $method,
'note' => $note,
'recorded_by' => $recordedBy,
]);
$booking->unsetRelation('payments');
$this->updateStatus($booking);
return $payment;
});
}
public function updateStatus(Booking $booking): void
{
$paymentStatuses = [BookingStatus::Confirmed, BookingStatus::DepositPaid, BookingStatus::Paid];
if (! in_array($booking->status, $paymentStatuses, true)) {
return;
}
$paid = $booking->paidAmount();
$status = match (true) {
$paid >= $booking->total => BookingStatus::Paid,
$paid >= $booking->deposit && $paid > 0 => BookingStatus::DepositPaid,
default => BookingStatus::Confirmed,
};
if ($status !== $booking->status) {
$booking->update(['status' => $status]);
}
}
}
+100
View File
@@ -0,0 +1,100 @@
<?php
namespace App\Actions;
use App\Enums\BookingStatus;
use App\Mail\ArrivalInformation;
use App\Mail\PaymentReminder;
use App\Models\Booking;
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.
*/
class SendBookingReminders
{
private const BALANCE_REQUEST_DAYS_BEFORE = 7;
private const ARRIVAL_INFO_DAYS_BEFORE = 7;
/**
* @return array{deposit_overdue: int, balance_request: int, balance_overdue: int, arrival_info: int, completed: int}
*/
public function handle(): array
{
$today = today();
$unpaid = [BookingStatus::Confirmed, BookingStatus::DepositPaid];
$depositOverdue = $this->bookings(fn (Builder $query) => $query
->where('status', BookingStatus::Confirmed)
->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');
$balanceRequest = $this->bookings(fn (Builder $query) => $query
->whereIn('status', $unpaid)
->whereNull('balance_requested_at')
->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');
$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');
$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)));
foreach ($arrivals as $booking) {
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new ArrivalInformation($booking));
$booking->update(['arrival_info_sent_at' => now()]);
}
$completed = Booking::query()
->where('status', BookingStatus::Paid)
->whereDate('departure', '<', $today)
->get();
$completed->each->update(['status' => BookingStatus::Completed]);
return [
'deposit_overdue' => $depositOverdue->count(),
'balance_request' => $balanceRequest->count(),
'balance_overdue' => $balanceOverdue->count(),
'arrival_info' => $arrivals->count(),
'completed' => $completed->count(),
];
}
/**
* @param callable(Builder<Booking>): Builder<Booking> $constraints
* @return Collection<int, Booking>
*/
private function bookings(callable $constraints): Collection
{
return $constraints(Booking::query()->with(['guest', 'property', 'payments']))
->whereHas('guest', fn (Builder $query) => $query->whereNull('anonymized_at'))
->get()
->toBase();
}
/**
* @param Collection<int, Booking> $bookings
*/
private function remind(Collection $bookings, string $kind, string $sentAtColumn): void
{
foreach ($bookings as $booking) {
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new PaymentReminder($booking, $kind));
$booking->update([$sentAtColumn => now()]);
}
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Documents;
use App\Models\Booking;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Support\Facades\Storage;
/**
* The rental contract as PDF. It is generated once at confirmation and stored, so later changes
* of texts or prices do not alter a contract the guest already received.
*/
class RentalContract
{
private const DISK = 'local';
public function generate(Booking $booking): string
{
$booking->loadMissing(['guest', 'property']);
$path = "contracts/Mietvertrag-{$booking->reference}.pdf";
Storage::disk(self::DISK)->put($path, Pdf::loadView('pdf.contract', ['booking' => $booking])->setPaper('a4')->output());
$booking->update(['contract_path' => $path]);
return $path;
}
public function absolutePath(Booking $booking): ?string
{
return $booking->contract_path && Storage::disk(self::DISK)->exists($booking->contract_path)
? Storage::disk(self::DISK)->path($booking->contract_path)
: null;
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Enums;
use Filament\Support\Contracts\HasLabel;
enum PaymentMethod: string implements HasLabel
{
case Transfer = 'transfer';
case Cash = 'cash';
case Other = 'other';
public function getLabel(): string
{
return match ($this) {
self::Transfer => 'Überweisung',
self::Cash => 'Bar',
self::Other => 'Sonstiges',
};
}
}
@@ -6,6 +6,7 @@
use App\Filament\Resources\Bookings\Pages\CreateBooking;
use App\Filament\Resources\Bookings\Pages\ListBookings;
use App\Filament\Resources\Bookings\Pages\ViewBooking;
use App\Filament\Resources\Bookings\RelationManagers\PaymentsRelationManager;
use App\Filament\Resources\Bookings\Schemas\BookingForm;
use App\Filament\Resources\Bookings\Schemas\BookingInfolist;
use App\Filament\Resources\Bookings\Tables\BookingsTable;
@@ -63,6 +64,13 @@ public static function getNavigationBadgeColor(): string
return 'warning';
}
public static function getRelations(): array
{
return [
PaymentsRelationManager::class,
];
}
public static function getPages(): array
{
return [
@@ -4,6 +4,7 @@
use App\Actions\ConfirmBooking;
use App\Actions\DeclineBooking;
use App\Documents\RentalContract;
use App\Enums\BookingStatus;
use App\Exceptions\ReservationException;
use App\Filament\Resources\Bookings\BookingResource;
@@ -75,7 +76,23 @@ protected function getHeaderActions(): array
Notification::make()->title('Vorgemerkt bis '.$this->record->hold_expires_at->format('d.m.Y, H:i'))->success()->send();
}),
Action::make('contract')
->label('Mietvertrag')
->icon(Heroicon::OutlinedDocumentText)
->color('gray')
->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 aktuellen Texten 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)
@@ -0,0 +1,81 @@
<?php
namespace App\Filament\Resources\Bookings\RelationManagers;
use App\Actions\RecordPayment;
use App\Enums\PaymentMethod;
use App\Filament\Forms\Components\EuroInput;
use App\Models\Booking;
use App\Models\Payment;
use App\Support\Money;
use Carbon\CarbonImmutable;
use Filament\Actions\Action;
use Filament\Actions\DeleteAction;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
/**
* @property Booking $ownerRecord
*/
class PaymentsRelationManager extends RelationManager
{
protected static string $relationship = 'payments';
protected static ?string $title = 'Zahlungen';
public function isReadOnly(): bool
{
return false;
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('amount')
->description(fn (): string => 'Bezahlt: '.Money::format($this->ownerRecord->paidAmount()).' · offen: '.Money::format($this->ownerRecord->openAmount()))
->columns([
TextColumn::make('paid_on')->label('Eingang')->date('d.m.Y'),
TextColumn::make('amount')->label('Betrag')->money('EUR', divideBy: 100, locale: 'de'),
TextColumn::make('method')->label('Art'),
TextColumn::make('note')->label('Notiz')->placeholder('–'),
TextColumn::make('recorded_by')->label('Erfasst von')->placeholder('–'),
])
->headerActions([
Action::make('record')
->label('Zahlung erfassen')
->icon(Heroicon::OutlinedBanknotes)
->fillForm(fn (): array => [
'amount' => number_format(($this->ownerRecord->openDeposit() ?: $this->ownerRecord->openAmount()) / 100, 2, '.', ''),
'paid_on' => today(),
'method' => PaymentMethod::Transfer,
])
->schema([
EuroInput::make('amount')->label('Betrag')->helperText('Erstattungen mit Minus erfassen.')->minValue(null)->required(),
DatePicker::make('paid_on')->label('Zahlungseingang')->required(),
Select::make('method')->label('Art')->options(PaymentMethod::class)->required(),
TextInput::make('note')->label('Notiz')->maxLength(255),
])
->action(function (array $data, RecordPayment $recordPayment): void {
$recordPayment->handle(
$this->ownerRecord,
(int) $data['amount'],
CarbonImmutable::parse($data['paid_on']),
$data['method'] instanceof PaymentMethod ? $data['method'] : PaymentMethod::from($data['method']),
$data['note'] ?: null,
auth()->user()?->name,
);
Notification::make()->title('Zahlung erfasst – Status: '.$this->ownerRecord->fresh()->status->getLabel())->success()->send();
}),
])
->recordActions([
DeleteAction::make()->after(fn (Payment $record) => app(RecordPayment::class)->updateStatus($this->ownerRecord->fresh())),
]);
}
}
@@ -48,6 +48,9 @@ public static function configure(Schema $schema): Schema
TextEntry::make('deposit')->label('Anzahlung')->money('EUR', divideBy: 100, locale: 'de'),
TextEntry::make('balance')->label('Restzahlung')->state(fn (Booking $record): string => Money::format($record->total - $record->deposit)),
TextEntry::make('balance_due_on')->label('Rest fällig am')->date('d.m.Y'),
TextEntry::make('paid')->label('Bezahlt')->state(fn (Booking $record): string => Money::format($record->paidAmount())),
TextEntry::make('open')->label('Offen')->state(fn (Booking $record): string => Money::format($record->openAmount()))->color(fn (Booking $record): string => $record->openAmount() > 0 ? 'danger' : 'success'),
TextEntry::make('deposit_due_on')->label('Anzahlung fällig am')->date('d.m.Y')->placeholder('–'),
]),
]),
Section::make('Nachricht des Gastes')
@@ -4,6 +4,7 @@
use App\Enums\BookingStatus;
use App\Models\Booking;
use App\Support\Money;
use Filament\Actions\ViewAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
@@ -16,7 +17,7 @@ class BookingsTable
public static function configure(Table $table): Table
{
return $table
->modifyQueryUsing(fn (Builder $query): Builder => $query->with(['guest', 'property']))
->modifyQueryUsing(fn (Builder $query): Builder => $query->with(['guest', 'property', 'payments']))
->defaultSort('created_at', 'desc')
->columns([
TextColumn::make('reference')
@@ -46,7 +47,8 @@ public static function configure(Table $table): Table
->label('Pers.'),
TextColumn::make('total')
->label('Gesamt')
->money('EUR', divideBy: 100, locale: 'de'),
->money('EUR', divideBy: 100, locale: 'de')
->description(fn (Booking $record): ?string => in_array($record->status, BookingStatus::occupying(), true) && $record->openAmount() > 0 ? 'offen '.Money::format($record->openAmount()) : null),
TextColumn::make('source')
->label('Quelle')
->toggleable(isToggledHiddenByDefault: true),
+36
View File
@@ -0,0 +1,36 @@
<?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;
/**
* Sent about a week before arrival: times, how to get in, house rules (texts from the admin).
*/
class ArrivalInformation extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public Booking $booking) {}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Bald geht es los: Ihre Anreise am '.$this->booking->arrival->format('d.m.Y'),
replyTo: [new Address(config('fewo.owner.email'), config('fewo.owner.name'))],
);
}
public function content(): Content
{
return new Content(
markdown: 'mail.arrival-information',
);
}
}
+12
View File
@@ -2,10 +2,12 @@
namespace App\Mail;
use App\Documents\RentalContract;
use App\Models\Booking;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
@@ -33,4 +35,14 @@ public function content(): Content
markdown: 'mail.booking-confirmed',
);
}
/**
* @return list<Attachment>
*/
public function attachments(): array
{
$path = app(RentalContract::class)->absolutePath($this->booking);
return $path ? [Attachment::fromPath($path)->as("Mietvertrag-{$this->booking->reference}.pdf")->withMime('application/pdf')] : [];
}
}
+50
View File
@@ -0,0 +1,50 @@
<?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;
/**
* Payment request or reminder to the guest. Overdue reminders are copied to the landlord.
*/
class PaymentReminder extends Mailable
{
use Queueable, SerializesModels;
public const DEPOSIT_OVERDUE = 'deposit_overdue';
public const BALANCE_REQUEST = 'balance_request';
public const BALANCE_OVERDUE = 'balance_overdue';
public function __construct(public Booking $booking, public string $kind) {}
public function envelope(): Envelope
{
return new Envelope(
subject: match ($this->kind) {
self::BALANCE_REQUEST => "Restzahlung für Ihre Buchung {$this->booking->reference}",
default => "Zahlungserinnerung zu Ihrer Buchung {$this->booking->reference}",
},
replyTo: [new Address(config('fewo.owner.email'), config('fewo.owner.name'))],
bcc: $this->kind === self::BALANCE_REQUEST ? [] : [new Address(config('fewo.notification_email'))],
);
}
public function content(): Content
{
return new Content(
markdown: 'mail.payment-reminder',
with: [
'amount' => $this->kind === self::DEPOSIT_OVERDUE && ! $this->booking->requiresFullPayment() ? $this->booking->openDeposit() : $this->booking->openAmount(),
'dueOn' => $this->kind === self::DEPOSIT_OVERDUE ? $this->booking->deposit_due_on : $this->booking->balance_due_on,
],
);
}
}
+46
View File
@@ -14,6 +14,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
/**
@@ -38,13 +39,19 @@
'quote',
'total',
'deposit',
'deposit_due_on',
'balance_due_on',
'contract_path',
'hold_expires_at',
'message',
'internal_notes',
'confirmed_at',
'cancelled_at',
'review_requested_at',
'deposit_reminded_at',
'balance_requested_at',
'balance_reminded_at',
'arrival_info_sent_at',
])]
class Booking extends Model
{
@@ -72,11 +79,16 @@ protected function casts(): array
'departure' => 'immutable_date',
'extras' => 'array',
'quote' => 'array',
'deposit_due_on' => 'immutable_date',
'balance_due_on' => 'immutable_date',
'hold_expires_at' => 'immutable_datetime',
'confirmed_at' => 'immutable_datetime',
'cancelled_at' => 'immutable_datetime',
'review_requested_at' => 'immutable_datetime',
'deposit_reminded_at' => 'immutable_datetime',
'balance_requested_at' => 'immutable_datetime',
'balance_reminded_at' => 'immutable_datetime',
'arrival_info_sent_at' => 'immutable_datetime',
];
}
@@ -132,6 +144,40 @@ public function review(): HasOne
return $this->hasOne(Review::class);
}
/**
* @return HasMany<Payment, $this>
*/
public function payments(): HasMany
{
return $this->hasMany(Payment::class)->orderBy('paid_on');
}
/**
* Sum of all payments in cents (refunds are negative).
*/
public function paidAmount(): int
{
return (int) ($this->relationLoaded('payments') ? $this->payments->sum('amount') : $this->payments()->sum('amount'));
}
public function openAmount(): int
{
return max(0, $this->total - $this->paidAmount());
}
public function openDeposit(): int
{
return max(0, $this->deposit - $this->paidAmount());
}
/**
* When the balance is already due at confirmation (short-term booking), the guest pays everything at once.
*/
public function requiresFullPayment(): bool
{
return $this->deposit_due_on !== null && $this->balance_due_on->lessThanOrEqualTo($this->deposit_due_on);
}
public function nights(): int
{
return (int) $this->arrival->diffInDays($this->departure);
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Models;
use App\Enums\PaymentMethod;
use Database\Factories\PaymentFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A received payment (negative amount = refund), in euro cents.
*/
#[Fillable(['booking_id', 'amount', 'paid_on', 'method', 'note', 'recorded_by'])]
class Payment extends Model
{
/** @use HasFactory<PaymentFactory> */
use HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'paid_on' => 'immutable_date',
'method' => PaymentMethod::class,
];
}
/**
* @return BelongsTo<Booking, $this>
*/
public function booking(): BelongsTo
{
return $this->belongsTo(Booking::class);
}
}
+9
View File
@@ -62,6 +62,15 @@
],
],
'contract' => [
'label' => 'Mietvertrag',
'fields' => [
'contract.intro' => ['label' => 'Einleitung', 'type' => 'textarea', 'default' => 'Zwischen Vermieter und Mieter wird folgender Mietvertrag über die Ferienwohnung geschlossen. Der Vertrag kommt mit der Buchungsbestätigung des Vermieters zustande.'],
'contract.terms' => ['label' => 'Mietbedingungen', 'type' => 'richtext', 'default' => '<p><strong>[MUSTER – bitte durch Ihre geprüften Mietbedingungen ersetzen]</strong></p><ol><li>Die Wohnung darf nur von den im Vertrag genannten Personen genutzt werden.</li><li>Der Mieter behandelt die Wohnung und das Inventar pfleglich und meldet Schäden unverzüglich.</li><li>Die Kurtaxe ist nicht im Mietpreis enthalten und wird vor Ort entrichtet.</li></ol>'],
'contract.closing' => ['label' => 'Schlusstext', 'type' => 'textarea', 'default' => 'Wir freuen uns auf Ihren Besuch und wünschen Ihnen schon jetzt einen erholsamen Aufenthalt an der Ostsee.'],
],
],
'legal' => [
'label' => 'Rechtliches',
'fields' => [
+301
View File
@@ -0,0 +1,301 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Settings
|--------------------------------------------------------------------------
|
| Set some default values. It is possible to add all defines that can be set
| in dompdf_config.inc.php. You can also override the entire config file.
|
*/
'show_warnings' => false, // Throw an Exception on warnings from dompdf
'public_path' => null, // Override the public path if needed
/*
* Dejavu Sans font is missing glyphs for converted entities, turn it off if you need to show € and £.
*/
'convert_entities' => true,
'options' => [
/**
* The location of the DOMPDF font directory
*
* The location of the directory where DOMPDF will store fonts and font metrics
* Note: This directory must exist and be writable by the webserver process.
* *Please note the trailing slash.*
*
* Notes regarding fonts:
* Additional .afm font metrics can be added by executing load_font.php from command line.
*
* Only the original "Base 14 fonts" are present on all pdf viewers. Additional fonts must
* be embedded in the pdf file or the PDF may not display correctly. This can significantly
* increase file size unless font subsetting is enabled. Before embedding a font please
* review your rights under the font license.
*
* Any font specification in the source HTML is translated to the closest font available
* in the font directory.
*
* The pdf standard "Base 14 fonts" are:
* Courier, Courier-Bold, Courier-BoldOblique, Courier-Oblique,
* Helvetica, Helvetica-Bold, Helvetica-BoldOblique, Helvetica-Oblique,
* Times-Roman, Times-Bold, Times-BoldItalic, Times-Italic,
* Symbol, ZapfDingbats.
*/
'font_dir' => storage_path('fonts'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
/**
* The location of the DOMPDF font cache directory
*
* This directory contains the cached font metrics for the fonts used by DOMPDF.
* This directory can be the same as DOMPDF_FONT_DIR
*
* Note: This directory must exist and be writable by the webserver process.
*/
'font_cache' => storage_path('fonts'),
/**
* The location of a temporary directory.
*
* The directory specified must be writeable by the webserver process.
* The temporary directory is required to download remote images and when
* using the PDFLib back end.
*/
'temp_dir' => sys_get_temp_dir(),
/**
* ==== IMPORTANT ====
*
* dompdf's "chroot": Prevents dompdf from accessing system files or other
* files on the webserver. All local files opened by dompdf must be in a
* subdirectory of this directory. DO NOT set it to '/' since this could
* allow an attacker to use dompdf to read any files on the server. This
* should be an absolute path.
* This is only checked on command line call by dompdf.php, but not by
* direct class use like:
* $dompdf = new DOMPDF(); $dompdf->load_html($htmldata); $dompdf->render(); $pdfdata = $dompdf->output();
*/
'chroot' => realpath(base_path()),
/**
* Protocol whitelist
*
* Protocols and PHP wrappers allowed in URIs, and the validation rules
* that determine if a resouce may be loaded. Full support is not guaranteed
* for the protocols/wrappers specified
* by this array.
*
* @var array
*/
'allowed_protocols' => [
'data://' => ['rules' => []],
'file://' => ['rules' => []],
'http://' => ['rules' => []],
'https://' => ['rules' => []],
],
/**
* Operational artifact (log files, temporary files) path validation
*/
'artifactPathValidation' => null,
/**
* @var string
*/
'log_output_file' => null,
/**
* Whether to enable font subsetting or not.
*/
'enable_font_subsetting' => true,
/**
* The PDF rendering backend to use
*
* Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
* 'auto'. 'auto' will look for PDFLib and use it if found, or if not it will
* fall back on CPDF. 'GD' renders PDFs to graphic files.
* {@link * Canvas_Factory} ultimately determines which rendering class to
* instantiate based on this setting.
*
* Both PDFLib & CPDF rendering backends provide sufficient rendering
* capabilities for dompdf, however additional features (e.g. object,
* image and font support, etc.) differ between backends. Please see
* {@link PDFLib_Adapter} for more information on the PDFLib backend
* and {@link CPDF_Adapter} and lib/class.pdf.php for more information
* on CPDF. Also see the documentation for each backend at the links
* below.
*
* The GD rendering backend is a little different than PDFLib and
* CPDF. Several features of CPDF and PDFLib are not supported or do
* not make any sense when creating image files. For example,
* multiple pages are not supported, nor are PDF 'objects'. Have a
* look at {@link GD_Adapter} for more information. GD support is
* experimental, so use it at your own risk.
*
* @link http://www.pdflib.com
* @link http://www.ros.co.nz/pdf
* @link http://www.php.net/image
*/
'pdf_backend' => 'CPDF',
/**
* html target media view which should be rendered into pdf.
* List of types and parsing rules for future extensions:
* http://www.w3.org/TR/REC-html40/types.html
* screen, tty, tv, projection, handheld, print, braille, aural, all
* Note: aural is deprecated in CSS 2.1 because it is replaced by speech in CSS 3.
* Note, even though the generated pdf file is intended for print output,
* the desired content might be different (e.g. screen or projection view of html file).
* Therefore allow specification of content here.
*/
'default_media_type' => 'screen',
/**
* The default paper size.
*
* North America standard is "letter"; other countries generally "a4"
*
* @see CPDF_Adapter::PAPER_SIZES for valid sizes ('letter', 'legal', 'A4', etc.)
*/
'default_paper_size' => 'a4',
/**
* The default paper orientation.
*
* The orientation of the page (portrait or landscape).
*
* @var string
*/
'default_paper_orientation' => 'portrait',
/**
* The default font family
*
* Used if no suitable fonts can be found. This must exist in the font folder.
*
* @var string
*/
'default_font' => 'DejaVu Sans',
/**
* Image DPI setting
*
* This setting determines the default DPI setting for images and fonts. The
* DPI may be overridden for inline images by explictly setting the
* image's width & height style attributes (i.e. if the image's native
* width is 600 pixels and you specify the image's width as 72 points,
* the image will have a DPI of 600 in the rendered PDF. The DPI of
* background images can not be overridden and is controlled entirely
* via this parameter.
*
* For the purposes of DOMPDF, pixels per inch (PPI) = dots per inch (DPI).
* If a size in html is given as px (or without unit as image size),
* this tells the corresponding size in pt.
* This adjusts the relative sizes to be similar to the rendering of the
* html page in a reference browser.
*
* In pdf, always 1 pt = 1/72 inch
*
* Rendering resolution of various browsers in px per inch:
* Windows Firefox and Internet Explorer:
* SystemControl->Display properties->FontResolution: Default:96, largefonts:120, custom:?
* Linux Firefox:
* about:config *resolution: Default:96
* (xorg screen dimension in mm and Desktop font dpi settings are ignored)
*
* Take care about extra font/image zoom factor of browser.
*
* In images, <img> size in pixel attribute, img css style, are overriding
* the real image dimension in px for rendering.
*
* @var int
*/
'dpi' => 96,
/**
* Enable embedded PHP
*
* If this setting is set to true then DOMPDF will automatically evaluate embedded PHP contained
* within <script type="text/php"> ... </script> tags.
*
* ==== IMPORTANT ==== Enabling this for documents you do not trust (e.g. arbitrary remote html pages)
* is a security risk.
* Embedded scripts are run with the same level of system access available to dompdf.
* Set this option to false (recommended) if you wish to process untrusted documents.
* This setting may increase the risk of system exploit.
* Do not change this settings without understanding the consequences.
* Additional documentation is available on the dompdf wiki at:
* https://github.com/dompdf/dompdf/wiki
*
* @var bool
*/
'enable_php' => false,
/**
* Enable inline JavaScript
*
* If this setting is set to true then DOMPDF will automatically insert JavaScript code contained
* within <script type="text/javascript"> ... </script> tags as written into the PDF.
* NOTE: This is PDF-based JavaScript to be executed by the PDF viewer,
* not browser-based JavaScript executed by Dompdf.
*
* @var bool
*/
'enable_javascript' => true,
/**
* Enable remote file access
*
* If this setting is set to true, DOMPDF will access remote sites for
* images and CSS files as required.
*
* ==== IMPORTANT ====
* This can be a security risk, in particular in combination with isPhpEnabled and
* allowing remote html code to be passed to $dompdf = new DOMPDF(); $dompdf->load_html(...);
* This allows anonymous users to download legally doubtful internet content which on
* tracing back appears to being downloaded by your server, or allows malicious php code
* in remote html pages to be executed by your server with your account privileges.
*
* This setting may increase the risk of system exploit. Do not change
* this settings without understanding the consequences. Additional
* documentation is available on the dompdf wiki at:
* https://github.com/dompdf/dompdf/wiki
*
* @var bool
*/
'enable_remote' => false,
/**
* List of allowed remote hosts
*
* Each value of the array must be a valid hostname.
*
* This will be used to filter which resources can be loaded in combination with
* isRemoteEnabled. If enable_remote is FALSE, then this will have no effect.
*
* Leave to NULL to allow any remote host.
*
* @var array|null
*/
'allowed_remote_hosts' => null,
/**
* A ratio applied to the fonts height to be more like browsers' line height
*/
'font_height_ratio' => 1.1,
/**
* Use the HTML5 Lib parser
*
* @deprecated This feature is now always on in dompdf 2.x
*
* @var bool
*/
'enable_html5_parser' => true,
],
];
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use App\Enums\PaymentMethod;
use App\Models\Booking;
use App\Models\Payment;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Payment>
*/
class PaymentFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'booking_id' => Booking::factory(),
'amount' => 10000,
'paid_on' => now()->toDateString(),
'method' => PaymentMethod::Transfer,
];
}
}
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('payments', function (Blueprint $table) {
$table->id();
$table->foreignId('booking_id')->constrained()->cascadeOnDelete();
$table->integer('amount');
$table->date('paid_on');
$table->string('method')->default('transfer');
$table->string('note')->nullable();
$table->string('recorded_by')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('payments');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('bookings', function (Blueprint $table) {
$table->date('deposit_due_on')->nullable()->after('deposit');
$table->string('contract_path')->nullable()->after('balance_due_on');
$table->dateTime('deposit_reminded_at')->nullable()->after('review_requested_at');
$table->dateTime('balance_requested_at')->nullable()->after('deposit_reminded_at');
$table->dateTime('balance_reminded_at')->nullable()->after('balance_requested_at');
$table->dateTime('arrival_info_sent_at')->nullable()->after('balance_reminded_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('bookings', function (Blueprint $table) {
$table->dropColumn(['deposit_due_on', 'contract_path', 'deposit_reminded_at', 'balance_requested_at', 'balance_reminded_at', 'arrival_info_sent_at']);
});
}
};
+1 -1
View File
@@ -148,7 +148,7 @@ ## 10. Umsetzungsphasen
1. **Fundament:** Laravel + Filament, Datenmodell, Saisons/Preise, Preisberechnung (mit Tests). ✅
2. **Kalender & Anfrage:** Belegung, Anfrageformular, Auto-Angebot per Mail, Vorreservierung mit Haltezeit, Sonderangebote, Sperrzeiten, Buchungsverwaltung. ✅
3. **Buchungsworkflow:** Bestätigung, Mietvertrag-PDF, Zahlungsfristen & Erinnerungen.
3. **Buchungsworkflow:** Bestätigung, Mietvertrag-PDF, Zahlungsfristen & Erinnerungen, Anreiseinfos. ✅ (Mietbedingungen/Storno noch als Muster)
4. **Webseite:** Design, Inhalte, Galerie, SEO, Barrierefreiheit.
5. **Connectoren:** iCal-Import/-Export, Sync-Log, Konfliktwarnung.
6. **Go-Live:** Strato-Deployment, Umleitungen, Inhalte/Rechtstexte, Testbuchungen.
@@ -0,0 +1,34 @@
<x-mail::message>
# Bald sind Sie an der Ostsee!
Guten Tag {{ $booking->guest->full_name }},
in wenigen Tagen beginnt Ihr Aufenthalt in der **{{ $booking->property->name }}**. Hier die wichtigsten Informationen:
**Adresse:** {{ $booking->property->address }}<br>
**Anreise:** {{ $booking->arrival->translatedFormat('l, d.m.Y') }}@if ($booking->property->check_in_time) ab {{ substr($booking->property->check_in_time, 0, 5) }} Uhr @endif<br>
**Abreise:** {{ $booking->departure->translatedFormat('l, d.m.Y') }}@if ($booking->property->check_out_time) bis {{ substr($booking->property->check_out_time, 0, 5) }} Uhr @endif
@if (\App\Support\Content::get('stay.arrival_info'))
{{ \App\Support\Content::html('stay.arrival_info') }}
@else
Zur Schlüsselübergabe melden wir uns noch persönlich bei Ihnen.
@endif
@if (\App\Support\Content::get('stay.house_rules'))
## Hausregeln
{{ \App\Support\Content::html('stay.house_rules') }}
@endif
@if ($booking->openAmount() > 0)
<x-mail::panel>
Noch offen: **{{ \App\Support\Money::format($booking->openAmount()) }}** – bitte überweisen Sie den Betrag vor Ihrer Anreise.
</x-mail::panel>
@endif
Bei Fragen erreichen Sie uns unter {{ config('fewo.owner.phone') }}. Gute Anreise!
Herzliche Grüße<br>
{{ config('fewo.owner.name') }}
</x-mail::message>
@@ -14,20 +14,17 @@
## Zahlung
Bitte überweisen Sie die Anzahlung von **{{ \App\Support\Money::format($booking->deposit) }}** innerhalb von {{ config('fewo.deposit_due_days') }} Tagen und den Restbetrag von **{{ \App\Support\Money::format($booking->total - $booking->deposit) }}** bis zum {{ $booking->balance_due_on->format('d.m.Y') }}.
@if (config('fewo.bank.iban'))
<x-mail::panel>
Kontoinhaber: {{ config('fewo.bank.account_holder') }}<br>
IBAN: {{ config('fewo.bank.iban') }}<br>
@if (config('fewo.bank.bic'))
BIC: {{ config('fewo.bank.bic') }}<br>
@endif
Verwendungszweck: {{ $booking->reference }}
</x-mail::panel>
@if ($booking->requiresFullPayment())
Da Ihre Anreise kurz bevorsteht, überweisen Sie bitte den **Gesamtbetrag von {{ \App\Support\Money::format($booking->total) }}** bis zum **{{ $booking->deposit_due_on->format('d.m.Y') }}**.
@else
Bitte überweisen Sie die **Anzahlung von {{ \App\Support\Money::format($booking->deposit) }}** bis zum **{{ $booking->deposit_due_on?->format('d.m.Y') }}** und den **Restbetrag von {{ \App\Support\Money::format($booking->total - $booking->deposit) }}** bis zum **{{ $booking->balance_due_on->format('d.m.Y') }}**. An die Restzahlung erinnern wir Sie rechtzeitig.
@endif
Rechtzeitig vor Ihrer Anreise erhalten Sie von uns alle Informationen zu Schlüsselübergabe, Parken und WLAN.
@include('mail.partials.bank')
Ihren **Mietvertrag** finden Sie als PDF im Anhang.
Eine Woche vor Ihrer Anreise erhalten Sie von uns alle Informationen zu Schlüsselübergabe, Parken und WLAN.
Herzliche Grüße<br>
{{ config('fewo.owner.name') }}
@@ -0,0 +1,10 @@
@if (config('fewo.bank.iban'))
<x-mail::panel>
Kontoinhaber: {{ config('fewo.bank.account_holder') }}<br>
IBAN: {{ config('fewo.bank.iban') }}<br>
@if (config('fewo.bank.bic'))
BIC: {{ config('fewo.bank.bic') }}<br>
@endif
Verwendungszweck: {{ $booking->reference }}
</x-mail::panel>
@endif
@@ -1,7 +1,7 @@
<x-mail::table>
| Leistung | Betrag |
|:---------|-------:|
@foreach ($booking->quote['lines'] as $line)
@foreach ($booking->quote['lines'] ?? [] as $line)
| {{ $line['label'] }} | {{ \App\Support\Money::format($line['amount']) }} |
@endforeach
| **Gesamtpreis** | **{{ \App\Support\Money::format($booking->total) }}** |
@@ -0,0 +1,26 @@
<x-mail::message>
@if ($kind === \App\Mail\PaymentReminder::BALANCE_REQUEST)
# Ihre Restzahlung
Guten Tag {{ $booking->guest->full_name }},
Ihr Aufenthalt in der **{{ $booking->property->name }}** vom {{ $booking->arrival->format('d.m.Y') }} bis {{ $booking->departure->format('d.m.Y') }} rückt näher – wir freuen uns schon auf Sie!
Bitte überweisen Sie den **Restbetrag von {{ \App\Support\Money::format($amount) }}** bis zum **{{ $dueOn->format('d.m.Y') }}**.
@else
# Zahlungserinnerung
Guten Tag {{ $booking->guest->full_name }},
zu Ihrer Buchung **{{ $booking->reference }}** ({{ $booking->arrival->format('d.m.Y') }} – {{ $booking->departure->format('d.m.Y') }}) konnten wir bis heute keinen Zahlungseingang über **{{ \App\Support\Money::format($amount) }}** feststellen (fällig am {{ $dueOn->format('d.m.Y') }}).
Sicher ist das nur ein Versehen. Bitte holen Sie die Überweisung in den nächsten Tagen nach. Sollten Sie bereits gezahlt haben, betrachten Sie diese Nachricht bitte als gegenstandslos.
@endif
@include('mail.partials.bank')
Bei Fragen antworten Sie einfach auf diese E-Mail.
Herzliche Grüße<br>
{{ config('fewo.owner.name') }}
</x-mail::message>
+97
View File
@@ -0,0 +1,97 @@
@php($money = fn (int $cents): string => \App\Support\Money::format($cents))
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Mietvertrag {{ $booking->reference }}</title>
<style>
@page { margin: 22mm 20mm 20mm 20mm; }
body { font-family: 'DejaVu Sans', sans-serif; font-size: 9.5pt; color: #1f2933; line-height: 1.45; }
h1 { font-size: 17pt; margin: 0 0 2mm; color: #1d3a4d; }
h2 { font-size: 11pt; margin: 7mm 0 2mm; color: #1d3a4d; border-bottom: 0.3mm solid #c9d2d8; padding-bottom: 1mm; }
.muted { color: #5f6b73; }
table { width: 100%; border-collapse: collapse; }
.parties td { width: 50%; vertical-align: top; padding-right: 6mm; }
.lines td { padding: 1.2mm 0; border-bottom: 0.2mm solid #e4e8eb; }
.lines td.amount { text-align: right; white-space: nowrap; }
.lines tr.total td { font-weight: bold; border-bottom: 0; border-top: 0.4mm solid #1d3a4d; }
.facts td { padding: 0.8mm 0; }
.facts td.label { width: 38%; color: #5f6b73; }
.rich p { margin: 0 0 2mm; }
.rich ol, .rich ul { margin: 0 0 2mm 5mm; padding: 0; }
.footer { position: fixed; bottom: -12mm; left: 0; right: 0; font-size: 7.5pt; color: #8a959c; text-align: center; }
</style>
</head>
<body>
<div class="footer">{{ config('fewo.owner.name') }} · {{ config('fewo.owner.street') }} · {{ config('fewo.owner.city') }} · {{ config('fewo.owner.phone') }} · {{ config('fewo.owner.email') }}</div>
<h1>Mietvertrag Ferienwohnung</h1>
<p class="muted">Buchungsnummer {{ $booking->reference }} · ausgestellt am {{ ($booking->confirmed_at ?? now())->format('d.m.Y') }}</p>
<p>{{ \App\Support\Content::get('contract.intro') }}</p>
<table class="parties">
<tr>
<td>
<h2>Vermieter</h2>
{{ config('fewo.owner.name') }}<br>
{{ config('fewo.owner.street') }}<br>
{{ config('fewo.owner.city') }}<br>
Tel. {{ config('fewo.owner.phone') }} · {{ config('fewo.owner.email') }}
</td>
<td>
<h2>Mieter</h2>
{{ $booking->guest->full_name }}<br>
@if ($booking->guest->street){{ $booking->guest->street }}<br>@endif
@if ($booking->guest->city){{ $booking->guest->postal_code }} {{ $booking->guest->city }}<br>@endif
{{ $booking->guest->email }}@if ($booking->guest->phone) · {{ $booking->guest->phone }}@endif
</td>
</tr>
</table>
<h2>Mietobjekt und Mietzeit</h2>
<table class="facts">
<tr><td class="label">Objekt</td><td>{{ $booking->property->name }}, {{ $booking->property->address }}@if ($booking->property->size_sqm), {{ $booking->property->size_sqm }} m²@endif</td></tr>
<tr><td class="label">Anreise</td><td>{{ $booking->arrival->translatedFormat('l, d.m.Y') }}@if ($booking->property->check_in_time) ab {{ substr($booking->property->check_in_time, 0, 5) }} Uhr @endif</td></tr>
<tr><td class="label">Abreise</td><td>{{ $booking->departure->translatedFormat('l, d.m.Y') }}@if ($booking->property->check_out_time) bis {{ substr($booking->property->check_out_time, 0, 5) }} Uhr @endif</td></tr>
<tr><td class="label">Übernachtungen</td><td>{{ $booking->nights() }}</td></tr>
<tr><td class="label">Personen</td><td>{{ $booking->guests }}</td></tr>
</table>
<h2>Mietpreis</h2>
<table class="lines">
@foreach ($booking->quote['lines'] ?? [] as $line)
<tr><td>{{ $line['label'] }}</td><td class="amount">{{ $money($line['amount']) }}</td></tr>
@endforeach
<tr class="total"><td>Gesamtpreis</td><td class="amount">{{ $money($booking->total) }}</td></tr>
</table>
<p class="muted">Die Kurtaxe ist nicht enthalten und wird vor Ort entrichtet.</p>
<h2>Zahlung</h2>
@if ($booking->requiresFullPayment())
<p>Der Gesamtbetrag von <strong>{{ $money($booking->total) }}</strong> ist bis zum <strong>{{ $booking->deposit_due_on->format('d.m.Y') }}</strong> zu überweisen.</p>
@else
<p>Anzahlung <strong>{{ $money($booking->deposit) }}</strong> bis zum <strong>{{ $booking->deposit_due_on?->format('d.m.Y') }}</strong>,
Restbetrag <strong>{{ $money($booking->total - $booking->deposit) }}</strong> bis zum <strong>{{ $booking->balance_due_on->format('d.m.Y') }}</strong>.</p>
@endif
@if (config('fewo.bank.iban'))
<p>Bankverbindung: {{ config('fewo.bank.account_holder') }} · IBAN {{ config('fewo.bank.iban') }}@if (config('fewo.bank.bic')) · BIC {{ config('fewo.bank.bic') }}@endif · Verwendungszweck: {{ $booking->reference }}</p>
@endif
<h2>Mietbedingungen</h2>
<div class="rich">{{ \App\Support\Content::html('contract.terms') }}</div>
@if (\App\Support\Content::get('stay.cancellation'))
<h2>Rücktritt / Stornierung</h2>
<div class="rich">{{ \App\Support\Content::html('stay.cancellation') }}</div>
@endif
@if (\App\Support\Content::get('stay.house_rules'))
<h2>Hausordnung</h2>
<div class="rich">{{ \App\Support\Content::html('stay.house_rules') }}</div>
@endif
<p style="margin-top: 8mm">{{ \App\Support\Content::get('contract.closing') }}</p>
<p>{{ config('fewo.owner.name') }}</p>
</body>
</html>
+6
View File
@@ -4,6 +4,7 @@
use App\Actions\MonitorChannels;
use App\Actions\RemindChannelTasks;
use App\Actions\RequestReviews;
use App\Actions\SendBookingReminders;
use Illuminate\Support\Facades\Schedule;
Schedule::command('bookings:expire-holds')->everyFiveMinutes()->withoutOverlapping();
@@ -22,6 +23,11 @@
->everyFifteenMinutes()
->withoutOverlapping();
Schedule::call(fn (SendBookingReminders $sendBookingReminders) => $sendBookingReminders->handle())
->name('bookings:reminders')
->dailyAt('09:00')
->withoutOverlapping();
Schedule::call(fn (RequestReviews $requestReviews) => $requestReviews->handle())
->name('reviews:request')
->dailyAt('10:00')
+141
View File
@@ -0,0 +1,141 @@
<?php
namespace Tests\Feature;
use App\Actions\ConfirmBooking;
use App\Actions\CreateReservation;
use App\Actions\RecordPayment;
use App\Actions\SendBookingReminders;
use App\Enums\BookingStatus;
use App\Filament\Resources\Bookings\Pages\ViewBooking;
use App\Filament\Resources\Bookings\RelationManagers\PaymentsRelationManager;
use App\Mail\ArrivalInformation;
use App\Mail\BookingConfirmed;
use App\Mail\PaymentReminder;
use App\Models\Booking;
use App\Models\Property;
use App\Models\User;
use App\Pricing\StayRequest;
use Carbon\CarbonImmutable;
use Database\Seeders\PropertySeeder;
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;
class PaymentWorkflowTest extends TestCase
{
use RefreshDatabase;
private Property $property;
protected function setUp(): void
{
parent::setUp();
$this->travelTo(CarbonImmutable::parse('2026-10-22 10:00'));
Storage::fake('local');
Mail::fake();
$this->seed(PropertySeeder::class);
$this->property = Property::sole();
}
public function test_confirmation_fixes_due_dates_and_sends_the_contract(): void
{
$booking = $this->confirmed('2026-12-01', '2026-12-05');
$this->assertSame('2026-10-29', $booking->deposit_due_on->toDateString());
$this->assertFalse($booking->requiresFullPayment());
Storage::disk('local')->assertExists($booking->contract_path);
$this->assertStringStartsWith('%PDF', Storage::disk('local')->get($booking->contract_path));
Mail::assertSent(BookingConfirmed::class, fn (BookingConfirmed $mail): bool => count($mail->attachments()) === 1);
}
public function test_short_term_booking_requires_full_payment(): void
{
$booking = $this->confirmed('2026-11-07', '2026-11-10');
$this->assertTrue($booking->requiresFullPayment());
$this->assertStringContainsString('Gesamtbetrag', (new BookingConfirmed($booking))->render());
}
public function test_payments_move_the_booking_through_its_statuses(): void
{
$booking = $this->confirmed('2026-12-01', '2026-12-05');
$record = new RecordPayment;
$record->handle($booking, $booking->deposit, today());
$this->assertSame(BookingStatus::DepositPaid, $booking->fresh()->status);
$record->handle($booking->fresh(), $booking->total - $booking->deposit, today());
$this->assertSame(BookingStatus::Paid, $booking->fresh()->status);
$this->assertSame(0, $booking->fresh()->openAmount());
$record->handle($booking->fresh(), -5000, today(), note: 'Erstattung');
$this->assertSame(BookingStatus::DepositPaid, $booking->fresh()->status);
}
public function test_reminders_are_sent_once_at_the_right_time(): void
{
$booking = $this->confirmed('2026-12-01', '2026-12-05');
$reminders = new SendBookingReminders;
$this->travelTo(CarbonImmutable::parse('2026-10-30 09:00'));
$this->assertSame(1, $reminders->handle()['deposit_overdue']);
$this->assertSame(0, $reminders->handle()['deposit_overdue']);
Mail::assertSent(PaymentReminder::class, fn (PaymentReminder $mail): bool => $mail->kind === PaymentReminder::DEPOSIT_OVERDUE && $mail->hasBcc(config('fewo.notification_email')));
(new RecordPayment)->handle($booking, $booking->deposit, today());
$this->travelTo(CarbonImmutable::parse('2026-10-26 09:00'));
$this->assertSame(0, $reminders->handle()['balance_request'], 'balance is due on 03.11.; request 7 days before');
$this->travelTo(CarbonImmutable::parse('2026-10-27 09:00'));
$this->assertSame(1, $reminders->handle()['balance_request']);
$this->travelTo(CarbonImmutable::parse('2026-11-04 09:00'));
$this->assertSame(1, $reminders->handle()['balance_overdue']);
$this->travelTo(CarbonImmutable::parse('2026-11-24 09:00'));
$this->assertSame(1, $reminders->handle()['arrival_info']);
Mail::assertSent(ArrivalInformation::class);
(new RecordPayment)->handle($booking->fresh(), $booking->fresh()->openAmount(), today());
$this->travelTo(CarbonImmutable::parse('2026-12-06 09:00'));
$this->assertSame(1, $reminders->handle()['completed']);
$this->assertSame(BookingStatus::Completed, $booking->fresh()->status);
}
public function test_payment_is_recorded_and_contract_downloaded_in_the_admin(): void
{
$this->actingAs(User::factory()->create());
$booking = $this->confirmed('2026-12-01', '2026-12-05');
Livewire::test(PaymentsRelationManager::class, ['ownerRecord' => $booking, 'pageClass' => ViewBooking::class])
->callAction(TestAction::make('record')->table(), [
'amount' => number_format($booking->deposit / 100, 2, '.', ''),
'paid_on' => '2026-10-25',
'method' => 'transfer',
])
->assertHasNoFormErrors();
$this->assertSame(BookingStatus::DepositPaid, $booking->fresh()->status);
Livewire::test(ViewBooking::class, ['record' => $booking->getRouteKey()])
->callAction('contract')
->assertFileDownloaded("Mietvertrag-{$booking->reference}.pdf");
}
private function confirmed(string $arrival, string $departure): Booking
{
$booking = app(CreateReservation::class)->handle(
$this->property,
new StayRequest(CarbonImmutable::parse($arrival), CarbonImmutable::parse($departure), 2),
['first_name' => 'Anna', 'last_name' => 'Muster', 'email' => 'anna@example.com', 'city' => 'Köln'],
);
app(ConfirmBooking::class)->handle($booking);
return $booking->fresh();
}
}