Files
fewo-stommer/app/Filament/Resources/Properties/Schemas/PropertyForm.php
T
LarsandClaude Opus 5.5 3bcfc09417
Deploy FeWo mit PipelineManager / deploy (push) Successful in 4m44s
Pakete 8, 5 und 6: Beträge und Zahlungen, Ändern und Stornieren, A6 im Vorgang
- Paket 8: Zahlungsarten (Gast an uns, laut Portal, Auszahlung, Erstattung),
  Portalbeträge als Angaben mit Quelle, Übersicht nach Zuständigkeit (R09).
- Paket 5: Ändern mit Folgenvorschau, vereinbart oder dem Gast vorgeschlagen
  (signierter Link), ein Stornoweg mit Grund und Erstattung, Portalstorno erst
  nach Bestätigung.
- Paket 6: eigene Nutzung, Besuch und Sperre als Vorgang mit Kurabgabe und
  Aufenthaltsbestätigung; Bestandsübernahme der Sperren mit identischem Export.
- Wirksame Einstellungen (Expertenansicht), Abnahmekatalog T01–T14, Ergebnis-,
  Abnahme- und Konfigurationsdokument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 22:16:47 +01:00

160 lines
8.5 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\AdminMode;
use App\Enums\CancellationMode;
use App\Enums\ProcessSetting;
use App\Filament\Forms\Components\EuroInput;
use App\Filament\Forms\ProcessSettingFields;
use App\Filament\Pages\HandlingSettings;
use App\ImageWorlds\ImageWorldRegistry;
use App\Models\ContractTemplate;
use App\Models\Site;
use App\Models\User;
use App\Support\Settings;
use Filament\Forms\Components\KeyValue;
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),
EuroInput::make('tourist_tax_rate')
->label('Kurabgabe je Person und Nacht')
->helperText('Ihr Satz laut Gemeinde. Wird bei eigener Nutzung und privaten Aufenthalten als eigene Position berechnet; Befreiungen tragen Sie im Vorgang ein. Leer lassen: keine Berechnung.'),
]),
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),
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),
KeyValue::make('contract_data')
->label('Vertragsdaten der Wohnung')
->helperText('Für Platzhalter in Vertragsvorlagen, z. B. Name „wlan_passwort“ → {{ wohnung.wlan_passwort }}. Nur Kleinbuchstaben, Ziffern und Unterstrich im Namen.')
->keyLabel('Name')
->valueLabel('Wert')
->columnSpanFull(),
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.'),
]),
Section::make('Abweichende Abwicklung dieser Wohnung')
->description('Nur nötig, wenn diese Wohnung anders bearbeitet wird als in „So arbeite ich“ eingestellt. Leere Felder folgen Ihren Standardeinstellungen.')
->visible(fn (): bool => auth()->user() instanceof User && auth()->user()->adminMode() === AdminMode::Expert)
->collapsed()
->columns(2)
->schema(ProcessSettingFields::make('process_overrides.', HandlingSettings::settings(), function (ProcessSetting $setting): string {
$defaults = (array) (Settings::tenant()?->process_defaults ?? []);
return $setting->describe($setting->normalize($defaults[$setting->value] ?? null) ?? $setting->default());
})),
]);
}
}