Files
fewo-stommer/app/Filament/Resources/Properties/Schemas/PropertyForm.php
T
LarsandClaude Sonnet 5.5 a73b164ea1
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m36s
Zahlungsaufgaben, Freigabe-/Storno-Link, Vertragsvorlagen, Anreise-Mail
- 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>
2026-10-30 12:46:29 +01:00

169 lines
9.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
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;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\TimePicker;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\Utilities\Set;
use Filament\Schemas\Schema;
use Illuminate\Support\Str;
class PropertyForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make('Wohnung')
->columns(2)
->schema([
TextInput::make('name')
->label('Name')
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(fn (Set $set, ?string $state, string $operation) => $operation === 'create' ? $set('slug', Str::slug((string) $state)) : null),
TextInput::make('slug')
->label('URL-Kürzel')
->required()
->maxLength(255)
->alphaDash()
->unique(ignoreRecord: true),
TextInput::make('address')
->label('Adresse')
->maxLength(255),
TextInput::make('size_sqm')
->label('Größe')
->numeric()
->minValue(1)
->suffix('m²'),
TimePicker::make('check_in_time')
->label('Anreise ab')
->seconds(false),
TimePicker::make('check_out_time')
->label('Abreise bis')
->seconds(false),
Select::make('site_id')
->label('Website')
->options(fn (): array => Site::query()->pluck('name', 'id')->all())
->placeholder('keine'),
Select::make('image_world')
->label('Bildwelt')
->options(fn (): array => app(ImageWorldRegistry::class)->options())
->placeholder('wie die Website')
->helperText('Nur setzen, wenn diese Wohnung anders aussehen soll als die Website – etwa eine Bergwohnung auf einer Küsten-Website.'),
Toggle::make('is_active')
->label('Aktiv (auf der Webseite buchbar)')
->default(true),
]),
Section::make('Belegung & Preise')
->description('Übernachtungspreise werden je Saison gepflegt (Reiter „Saisons“ unten).')
->columns(2)
->schema([
TextInput::make('max_guests')
->label('Maximale Personen')
->required()
->integer()
->minValue(1),
TextInput::make('included_guests')
->label('Im Preis enthaltene Personen')
->required()
->integer()
->minValue(1)
->lte('max_guests'),
EuroInput::make('extra_guest_fee_per_night')
->label('Aufpreis je weitere Person und Nacht')
->required()
->default(0),
EuroInput::make('cleaning_fee')
->label('Endreinigung & Service (einmalig)')
->required()
->default(0),
]),
Section::make('Zahlungsbedingungen')
->columns(2)
->schema([
TextInput::make('deposit_percent')
->label('Anzahlung')
->helperText('Anteil am Mietpreis (Übernachtungen ohne Endreinigung und Extras)')
->required()
->integer()
->minValue(0)
->maxValue(100)
->suffix('%')
->default(35),
TextInput::make('balance_due_days_before_arrival')
->label('Restzahlung fällig')
->required()
->integer()
->minValue(0)
->suffix('Tage vor Anreise')
->default(28),
TextInput::make('hold_hours')
->label('Vorreservierung halten')
->helperText('So lange bleibt ein angefragter Zeitraum ohne Ihre Bestätigung blockiert.')
->required()
->integer()
->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.')
->default(true)
->live(),
Select::make('offer_mode')
->label('Bearbeitung von Anfragen')
->options(OfferMode::class)
->default(OfferMode::Manual)
->required()
->helperText('Automatisch: das Angebot geht sofort an den Gast, wenn die Kalenderprüfung bestanden ist (Kalenderstand aktuell, bei Portalen mit Sofortbuchung unser Feed nachweislich abgerufen). Sonst entscheiden Sie von Hand. Unabhängig vom Testbetrieb der E-Mails.')
->rules([fn (Get $get): Closure => function (string $attribute, mixed $value, Closure $fail) use ($get): void {
if (($value === OfferMode::Automatic->value || $value === OfferMode::Automatic) && ! $get('pre_reservation_enabled')) {
$fail('Automatische Angebote brauchen die Vorreservierung: ohne Sperre im Kalender kann ein verbindlich annehmbares Angebot nicht sicher erteilt werden.');
}
}]),
]),
]);
}
}