Files
fewo-stommer/app/Filament/Resources/Properties/Schemas/PropertyForm.php
T
LarsandClaude Sonnet 5.5 eafab8a2cb
Deploy FeWo mit PipelineManager / deploy (push) Failing after 3m38s
Buchungsprozess: Angebots-Snapshot, atomare Annahme, Auto-Angebot, Kanalfreigabe
- Angebotsbedingungen und Zahlungsdaten werden je Version eingefroren (offer_terms, offer_hash)
- Annahme in einer gesperrten Transaktion, idempotent, mit Nachweis; Mail- und Portalfehler
  machen eine gespeicherte Buchung nicht ungueltig (Postfach, Nachversand)
- Je Wohnung: manuelle/automatische Angebote, optionale Vorreservierung
- Automatische Freigabe abhaengig von aktuellen Importen und Feed-Abruf bei Sofortbuchungsportalen
- Deutsche Fehlerseiten, Buchungsseite zeigt Angebots- und Zustellstatus
- Dokumentation: BOOKING-E2E-*.md, BOOKING-COMPLIANCE-HANDOVER.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-30 12:01:02 +01:00

139 lines
7.0 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\OfferMode;
use App\Filament\Forms\Components\EuroInput;
use App\ImageWorlds\ImageWorldRegistry;
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),
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.');
}
}]),
]),
]);
}
}