Stornoregeln mit automatischer Kostenberechnung, Storno-Verwaltung, Vertragsanlagen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m34s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 3m34s
- Stornoregel (Stufen nach Tagen vor Anreise, Mietpreis oder Gesamtpreis, Ersatzmieter-Gebuehr), je Vertragsvorlage, beim Angebot eingefroren, als Platzhalter im Vertrag - Stornierung (Gast-Link oder Verwaltung) berechnet die Kosten, legt einen Stornofall an; Verwaltung Stornierungen mit Vorschlag, Festlegung, Saldo, Abrechnung und Erlass; Gast sieht die Kosten vorab auf der Storno-Seite - Vertragsanlagen als eigene versionierte Dokumente mit Bedingung (immer, Zusatzleistung, Portal, von Hand), je Angebot ausgewaehlt und eingefroren; Zusatzleistungen in der Buchung erfassbar - FeWo-direkt-Installation legt die Stornoregel aus Paragraf 13 an Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5baf39441f
commit
0c4187edaf
37 files changed
+1440
-10
No files matched your search
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ContractAnnexes;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Resources\ContractAnnexes\Pages\CreateContractAnnex;
|
||||
use App\Filament\Resources\ContractAnnexes\Pages\EditContractAnnex;
|
||||
use App\Filament\Resources\ContractAnnexes\Pages\ListContractAnnexes;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ContractAnnex;
|
||||
use App\Models\Extra;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Contract annexes as documents of their own, versioned, with a condition that decides per booking whether the
|
||||
* annex is attached (always, when an extra service is booked, for a portal, only by hand).
|
||||
*/
|
||||
class ContractAnnexResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
|
||||
protected static ?string $model = ContractAnnex::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPaperClip;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
|
||||
protected static ?string $modelLabel = 'Vertragsanlage';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Vertragsanlagen';
|
||||
|
||||
protected static ?int $navigationSort = 8;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
TextInput::make('name')->label('Name (intern)')->required()->maxLength(120)->helperText('z. B. „WLAN“, „Wäschepaket“, „Key Pickup“. Versionen haben denselben Namen.'),
|
||||
TextInput::make('title')->label('Überschrift im Vertrag')->required()->maxLength(200),
|
||||
Select::make('condition_type')
|
||||
->label('Wann wird die Anlage angehängt?')
|
||||
->options([
|
||||
ContractAnnex::ALWAYS => 'Immer, wenn die Vorlage sie enthält',
|
||||
ContractAnnex::EXTRA => 'Wenn eine bestimmte Zusatzleistung gebucht ist',
|
||||
ContractAnnex::CHANNEL => 'Nur bei Buchungen über ein bestimmtes Portal',
|
||||
ContractAnnex::MANUAL => 'Nur von Hand (im Angebot auswählen)',
|
||||
])
|
||||
->default(ContractAnnex::ALWAYS)
|
||||
->required()
|
||||
->live(),
|
||||
Select::make('condition_id')
|
||||
->label('Zusatzleistung / Portal')
|
||||
->options(fn (Get $get): array => match ($get('condition_type')) {
|
||||
ContractAnnex::EXTRA => Extra::query()->orderBy('name')->pluck('name', 'id')->all(),
|
||||
ContractAnnex::CHANNEL => Channel::query()->orderBy('name')->pluck('name', 'id')->all(),
|
||||
default => [],
|
||||
})
|
||||
->visible(fn (Get $get): bool => in_array($get('condition_type'), [ContractAnnex::EXTRA, ContractAnnex::CHANNEL], true))
|
||||
->required(fn (Get $get): bool => in_array($get('condition_type'), [ContractAnnex::EXTRA, ContractAnnex::CHANNEL], true)),
|
||||
RichEditor::make('body')
|
||||
->label('Text der Anlage (mit Platzhaltern wie {{ mieter }}, {{ wohnung.wlan_passwort }})')
|
||||
->toolbarButtons([['bold', 'italic', 'underline', 'link'], ['h2', 'h3'], ['bulletList', 'orderedList'], ['undo', 'redo']])
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
Textarea::make('notes')->label('Interne Notiz')->rows(2)->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('name')
|
||||
->columns([
|
||||
TextColumn::make('name')->label('Anlage')->weight('medium')->searchable(),
|
||||
TextColumn::make('version')->label('Version')->badge(),
|
||||
TextColumn::make('condition')->label('Bedingung')->state(fn (ContractAnnex $record): string => match ($record->condition_type) {
|
||||
ContractAnnex::EXTRA => 'Zusatzleistung: '.(Extra::query()->find($record->condition_id)?->name ?? '?'),
|
||||
ContractAnnex::CHANNEL => 'Portal: '.(Channel::query()->find($record->condition_id)?->name ?? '?'),
|
||||
ContractAnnex::MANUAL => 'Nur von Hand',
|
||||
default => 'Immer',
|
||||
}),
|
||||
IconColumn::make('used')->label('In Angeboten')->boolean()->state(fn (ContractAnnex $record): bool => $record->isUsed()),
|
||||
])
|
||||
->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 bisherige Version bleibt unverändert.')
|
||||
->action(function (ContractAnnex $record): void {
|
||||
Notification::make()->title('Version '.$record->newVersion()->version.' angelegt')->success()->send();
|
||||
}),
|
||||
DeleteAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' => ListContractAnnexes::route('/'),
|
||||
'create' => CreateContractAnnex::route('/create'),
|
||||
'edit' => EditContractAnnex::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user