Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70a8c5072b | ||
|
|
20235b9139 | ||
|
|
565eee4325 | ||
|
|
fd744edf8c |
No files matched your search
@@ -43,6 +43,8 @@ MAIL_FROM_NAME="${APP_NAME}"
|
||||
FEWO_OWNER_NAME="Brigitte Stommer"
|
||||
FEWO_OWNER_EMAIL=fewo@stommer.de
|
||||
FEWO_NOTIFICATION_EMAIL=fewo@stommer.de
|
||||
# Nur Testbetrieb: alle E-Mails ausschließlich an diese Adresse (leer = normaler Versand)
|
||||
FEWO_MAIL_REDIRECT_TO=
|
||||
FEWO_BANK_ACCOUNT_HOLDER=
|
||||
FEWO_BANK_IBAN=
|
||||
FEWO_BANK_BIC=
|
||||
|
||||
@@ -3,26 +3,40 @@
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Property;
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
/**
|
||||
* Copies all seasons starting in a given year to the following year with the same calendar dates,
|
||||
* so a new price year only needs adjusting instead of re-entering.
|
||||
* Copies all seasons starting in a given year to the following year, so a new price year only needs adjusting
|
||||
* instead of re-entering. Optionally every season start is moved to the nearest given weekday (e.g. Saturday
|
||||
* as changeover day); seasons that were adjacent stay adjacent.
|
||||
*/
|
||||
class CopySeasonsToNextYear
|
||||
{
|
||||
/**
|
||||
* @param int|null $alignToWeekday ISO weekday (1 = Monday … 7 = Sunday) or null for the same calendar dates
|
||||
* @return array{created: int, skipped: int}
|
||||
*/
|
||||
public function handle(Property $property, int $year): array
|
||||
public function handle(Property $property, int $year, ?int $alignToWeekday = null): array
|
||||
{
|
||||
$created = 0;
|
||||
$skipped = 0;
|
||||
|
||||
$seasons = $property->seasons()->whereYear('starts_on', $year)->get();
|
||||
$seasons = $property->seasons()->whereYear('starts_on', $year)->orderBy('starts_on')->get();
|
||||
|
||||
// New start per old start date; an end that equals another season's start follows that start.
|
||||
$moved = [];
|
||||
foreach ($seasons as $season) {
|
||||
$moved[$season->starts_on->toDateString()] = $this->shift($season->starts_on, $alignToWeekday);
|
||||
}
|
||||
|
||||
foreach ($seasons as $season) {
|
||||
$startsOn = $season->starts_on->addYearNoOverflow();
|
||||
$endsOn = $season->ends_on->addYearNoOverflow();
|
||||
$startsOn = $moved[$season->starts_on->toDateString()];
|
||||
$endsOn = $moved[$season->ends_on->toDateString()] ?? $this->shift($season->ends_on, $alignToWeekday);
|
||||
if ($endsOn->lessThanOrEqualTo($startsOn)) {
|
||||
$skipped++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($property->seasons()->overlapping($startsOn, $endsOn)->exists()) {
|
||||
$skipped++;
|
||||
@@ -40,4 +54,19 @@ public function handle(Property $property, int $year): array
|
||||
|
||||
return ['created' => $created, 'skipped' => $skipped];
|
||||
}
|
||||
|
||||
/**
|
||||
* One year later; with a weekday, moved to the nearest such day (at most 3 days earlier or later).
|
||||
*/
|
||||
private function shift(CarbonImmutable $date, ?int $weekday): CarbonImmutable
|
||||
{
|
||||
$next = $date->addYearNoOverflow();
|
||||
if ($weekday === null) {
|
||||
return $next;
|
||||
}
|
||||
|
||||
$difference = ($weekday - $next->isoWeekday() + 7) % 7;
|
||||
|
||||
return $difference <= 3 ? $next->addDays($difference) : $next->subDays(7 - $difference);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use App\Filament\Pages\PricesAndOffers;
|
||||
use App\Filament\Resources\BlockedPeriods\BlockedPeriodResource;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
|
||||
use App\Filament\Resources\Guests\GuestResource;
|
||||
use App\Filament\Resources\Photos\PhotoResource;
|
||||
use App\Filament\Resources\Reviews\ReviewResource;
|
||||
use Filament\Support\Contracts\HasDescription;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
@@ -26,9 +28,11 @@ enum AdminMode: string implements HasDescription, HasLabel
|
||||
public const SIMPLE_NAVIGATION = [
|
||||
BookingResource::class,
|
||||
BlockedPeriodResource::class,
|
||||
PricesAndOffers::class,
|
||||
GuestResource::class,
|
||||
ChannelTaskResource::class,
|
||||
ReviewResource::class,
|
||||
PhotoResource::class,
|
||||
];
|
||||
|
||||
public function getLabel(): string
|
||||
@@ -42,7 +46,7 @@ public function getLabel(): string
|
||||
public function getDescription(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Simple => 'Nur das Tägliche: Anfragen, Buchungen und Verträge, Sperrzeiten, Gäste, Portal-Aufgaben, Bewertungen',
|
||||
self::Simple => 'Das Tägliche: Anfragen, Buchungen und Verträge, Sperrzeiten, Preise & Angebote, Gäste, Portal-Aufgaben, Bewertungen, Fotos',
|
||||
self::Expert => 'Alle Einstellungen: Preise, Angebote, Portale, Webseite, System',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Resources\Properties\Pages\EditProperty;
|
||||
use App\Filament\Resources\Properties\RelationManagers\ExtrasRelationManager;
|
||||
use App\Filament\Resources\Properties\RelationManagers\SeasonsRelationManager;
|
||||
use App\Filament\Resources\Properties\RelationManagers\SpecialOffersRelationManager;
|
||||
use App\Models\Property;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Livewire;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Text;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Livewire\Attributes\Url;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* The yearly price work in one place, without the other apartment settings: seasons & prices,
|
||||
* special offers & promo codes, extras. Reuses the relation managers of the apartment.
|
||||
*/
|
||||
class PricesAndOffers extends Page
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCurrencyEuro;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
|
||||
protected static ?string $navigationLabel = 'Preise & Angebote';
|
||||
|
||||
protected static ?string $title = 'Preise & Angebote';
|
||||
|
||||
protected static ?string $slug = 'preise-und-angebote';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
#[Url(as: 'wohnung')]
|
||||
public ?int $propertyId = null;
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return (bool) auth()->user()?->hasRole(UserRole::Admin, UserRole::Rentals);
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->propertyId ??= Property::query()->where('is_active', true)->value('id') ?? Property::query()->value('id');
|
||||
}
|
||||
|
||||
public function content(Schema $schema): Schema
|
||||
{
|
||||
$property = Property::find($this->propertyId);
|
||||
if ($property === null) {
|
||||
return $schema->components([Text::make('Es ist noch keine Wohnung angelegt (Expertenansicht › Wohnungen).')]);
|
||||
}
|
||||
|
||||
$context = ['ownerRecord' => $property, 'pageClass' => EditProperty::class];
|
||||
|
||||
return $schema->components([
|
||||
Select::make('propertyId')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
->live()
|
||||
->afterStateUpdated(fn () => $this->redirect(static::getUrl(['wohnung' => $this->propertyId])))
|
||||
->visible(fn (): bool => Property::query()->count() > 1),
|
||||
Tabs::make('prices')
|
||||
->persistTabInQueryString()
|
||||
->tabs([
|
||||
Tab::make('Saisons & Preise')->icon(Heroicon::OutlinedCalendar)->schema([
|
||||
Livewire::make(SeasonsRelationManager::class, $context)->key("seasons-{$property->id}"),
|
||||
]),
|
||||
Tab::make('Sonderangebote & Rabattcodes')->icon(Heroicon::OutlinedSparkles)->schema([
|
||||
Livewire::make(SpecialOffersRelationManager::class, $context)->key("offers-{$property->id}"),
|
||||
]),
|
||||
Tab::make('Extras')->icon(Heroicon::OutlinedGift)->schema([
|
||||
Livewire::make(ExtrasRelationManager::class, $context)->key("extras-{$property->id}"),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
@@ -35,6 +36,8 @@
|
||||
|
||||
class SeasonsRelationManager extends RelationManager
|
||||
{
|
||||
public const WEEKDAYS = [1 => 'Montag', 2 => 'Dienstag', 3 => 'Mittwoch', 4 => 'Donnerstag', 5 => 'Freitag', 6 => 'Samstag', 7 => 'Sonntag'];
|
||||
|
||||
protected static string $relationship = 'seasons';
|
||||
|
||||
protected static ?string $title = 'Saisons & Preise';
|
||||
@@ -111,6 +114,7 @@ public function table(Table $table): Table
|
||||
->headerActions([
|
||||
CreateAction::make(),
|
||||
$this->copyToNextYearAction(),
|
||||
$this->minimumStayRulesAction(),
|
||||
$this->priceCalculatorAction(),
|
||||
])
|
||||
->recordActions([
|
||||
@@ -179,22 +183,52 @@ private function seasonYears(): array
|
||||
return $years->combine($years)->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* The relaxations of the seasons' minimum stay, edited where the seasons are maintained.
|
||||
*/
|
||||
private function minimumStayRulesAction(): Action
|
||||
{
|
||||
return Action::make('minimumStayRules')
|
||||
->label('Regeln Mindestaufenthalt')
|
||||
->icon(Heroicon::OutlinedAdjustmentsHorizontal)
|
||||
->color('gray')
|
||||
->modalHeading('Mindestaufenthalt – Ausnahmen')
|
||||
->modalDescription('Jede Saison hat ihre Mindestnächte. Diese Regeln erlauben kürzere Aufenthalte, wenn sie den Kalender nicht zerstückeln. Sonderangebote können den Mindestaufenthalt zusätzlich aufheben.')
|
||||
->fillForm(fn (): array => $this->getOwnerRecord()->only(['changeover_weekday', 'min_stay_fill_gaps', 'min_stay_until_changeover', 'min_stay_absolute']))
|
||||
->schema([
|
||||
Select::make('changeover_weekday')->label('Typischer An- und Abreisetag')->options(self::WEEKDAYS)->placeholder('keiner'),
|
||||
Toggle::make('min_stay_fill_gaps')->label('Kalenderlücken: kürzer erlaubt, wenn die Buchung eine Lücke zwischen zwei Belegungen vollständig füllt'),
|
||||
Toggle::make('min_stay_until_changeover')->label('Kürzer erlaubt, wenn die Buchung am typischen Anreisetag endet (die Woche danach bleibt frei buchbar)'),
|
||||
TextInput::make('min_stay_absolute')->label('Untergrenze für alle Ausnahmen')->integer()->minValue(1)->maxValue(14)->suffix('Nächte')->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->getOwnerRecord()->update($data);
|
||||
Notification::make()->title('Regeln gespeichert')->success()->send();
|
||||
});
|
||||
}
|
||||
|
||||
private function copyToNextYearAction(): Action
|
||||
{
|
||||
return Action::make('copyToNextYear')
|
||||
->label('In Folgejahr kopieren')
|
||||
->icon(Heroicon::OutlinedDocumentDuplicate)
|
||||
->color('gray')
|
||||
->modalDescription('Alle Saisons, die im gewählten Jahr beginnen, werden mit gleichen Kalenderdaten und Preisen ins Folgejahr übernommen. Bereits belegte Zeiträume werden übersprungen.')
|
||||
->modalDescription('Alle Saisons, die im gewählten Jahr beginnen, werden mit Preisen und Mindestnächten ins Folgejahr übernommen. Bereits belegte Zeiträume werden übersprungen.')
|
||||
->schema([
|
||||
Select::make('year')
|
||||
->label('Jahr kopieren')
|
||||
->options(fn (): array => $this->seasonYears())
|
||||
->default((string) now()->year)
|
||||
->required(),
|
||||
Select::make('weekday')
|
||||
->label('Saisonbeginn legen auf')
|
||||
->helperText('Jeder Saisonbeginn wird auf den nächstgelegenen Wochentag verschoben (höchstens 3 Tage); aneinandergrenzende Saisons bleiben lückenlos.')
|
||||
->options(self::WEEKDAYS)
|
||||
->placeholder('gleiche Kalenderdaten wie im Vorjahr')
|
||||
->default(fn (): ?int => $this->getOwnerRecord()->changeover_weekday),
|
||||
])
|
||||
->action(function (array $data, CopySeasonsToNextYear $copySeasons): void {
|
||||
$result = $copySeasons->handle($this->getOwnerRecord(), (int) $data['year']);
|
||||
$result = $copySeasons->handle($this->getOwnerRecord(), (int) $data['year'], filled($data['weekday'] ?? null) ? (int) $data['weekday'] : null);
|
||||
|
||||
Notification::make()
|
||||
->title("{$result['created']} Saisons nach ".((int) $data['year'] + 1).' kopiert')
|
||||
|
||||
@@ -121,6 +121,9 @@ public function form(Schema $schema): Schema
|
||||
Toggle::make('is_combinable')
|
||||
->label('Mit anderen kombinierbaren Angeboten kombinierbar')
|
||||
->helperText('Sonst erhält der Gast automatisch das für ihn beste Einzelangebot.'),
|
||||
Toggle::make('waives_min_stay')
|
||||
->label('Mindestaufenthalt der Saison aufheben')
|
||||
->helperText('Wenn das Angebot gilt, darf der Aufenthalt kürzer sein als die Mindestnächte der Saison (z. B. Special Weekend mit 2 Nächten, kurze Lücke).'),
|
||||
]),
|
||||
Section::make('Bewerbung auf der Webseite')
|
||||
->description('Welche Angebote gerade erscheinen, ergibt sich automatisch: aktiv, ohne Aktionscode, im Buchungszeitraum, feste Termine nur solange frei, Lückenfüller je gefundener Lücke. Mehrere gleichzeitig werden im Baustein „Sonderangebote“ nebeneinander, als Liste oder rollierend gezeigt.')
|
||||
@@ -144,10 +147,7 @@ public function form(Schema $schema): Schema
|
||||
->visible(fn (Get $get): bool => $this->kind($get) === OfferKind::GapFiller)
|
||||
->schema([
|
||||
TextInput::make('max_gap_nights')->label('Lücken bis höchstens … Nächte')->integer()->minValue(1)->default(4)->required(),
|
||||
Toggle::make('waives_min_stay')
|
||||
->label('Mindestaufenthalt der Saison aufheben')
|
||||
->helperText('Damit auch kurze Lücken (z. B. 2 Nächte bei 5 Nächten Mindestaufenthalt) buchbar werden.')
|
||||
->default(true),
|
||||
|
||||
]),
|
||||
Section::make('Bedingungen')
|
||||
->description('Leere Felder bedeuten: keine Einschränkung.')
|
||||
|
||||
@@ -27,6 +27,10 @@
|
||||
'hold_hours',
|
||||
'check_in_time',
|
||||
'check_out_time',
|
||||
'changeover_weekday',
|
||||
'min_stay_fill_gaps',
|
||||
'min_stay_until_changeover',
|
||||
'min_stay_absolute',
|
||||
'is_active',
|
||||
])]
|
||||
class Property extends Model
|
||||
@@ -39,10 +43,25 @@ class Property extends Model
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
/**
|
||||
* Defaults of the minimum stay rules (as in the migration), also before the model is reloaded.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected $attributes = [
|
||||
'min_stay_fill_gaps' => true,
|
||||
'min_stay_until_changeover' => false,
|
||||
'min_stay_absolute' => 2,
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
'min_stay_fill_gaps' => 'boolean',
|
||||
'min_stay_until_changeover' => 'boolean',
|
||||
'changeover_weekday' => 'integer',
|
||||
'min_stay_absolute' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,7 @@ public function calculate(Property $property, StayRequest $stay, ?CarbonImmutabl
|
||||
$offers = $this->applicableOffers($property, $stay, $nightSeasons, $bookedAt);
|
||||
|
||||
$arrivalSeason = $nightSeasons[0];
|
||||
$minimumStayWaived = $offers->contains(fn (SpecialOffer $offer): bool => $offer->waives_min_stay && $offer->kind === OfferKind::GapFiller);
|
||||
if ($nights < $arrivalSeason->min_nights && ! $minimumStayWaived) {
|
||||
if ($nights < $arrivalSeason->min_nights && ! $this->minimumStayRelaxed($property, $stay, $offers)) {
|
||||
throw QuoteException::minimumStay($arrivalSeason->min_nights, $arrivalSeason->name);
|
||||
}
|
||||
|
||||
@@ -125,6 +124,30 @@ private function accommodationLines(array $nightSeasons): array
|
||||
), $runs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a stay shorter than the season's minimum is still allowed: an applicable offer waives it, or –
|
||||
* never below the property's absolute minimum – the stay fills a calendar gap completely, or it ends on the
|
||||
* typical changeover day (so the following week stays bookable).
|
||||
*
|
||||
* @param Collection<int, SpecialOffer> $offers
|
||||
*/
|
||||
private function minimumStayRelaxed(Property $property, StayRequest $stay, Collection $offers): bool
|
||||
{
|
||||
if ($offers->contains(fn (SpecialOffer $offer): bool => $offer->waives_min_stay)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($stay->nights() < max(1, (int) $property->min_stay_absolute)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($property->min_stay_until_changeover && $property->changeover_weekday !== null && $stay->departure->isoWeekday() === $property->changeover_weekday) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $property->min_stay_fill_gaps && $this->gaps->gapContaining($property, $stay->arrival, $stay->departure) === $stay->nights();
|
||||
}
|
||||
|
||||
/**
|
||||
* Active offers whose conditions the stay meets. The calendar gap is only looked up if a gap filler exists.
|
||||
*
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Support\StripImageMetadata;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Spatie\MediaLibrary\MediaCollections\Events\MediaHasBeenAddedEvent;
|
||||
@@ -23,6 +24,11 @@ public function register(): void
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
// Test environments: deliver every e-mail to one address only, so no guest gets test mails.
|
||||
if (filled(config('fewo.mail_redirect_to'))) {
|
||||
Mail::alwaysTo(config('fewo.mail_redirect_to'));
|
||||
}
|
||||
|
||||
// Photos: remove metadata (GPS position, camera data) from uploaded originals, which stay downloadable.
|
||||
Event::listen(MediaHasBeenAddedEvent::class, fn (MediaHasBeenAddedEvent $event) => StripImageMetadata::strip($event->media));
|
||||
|
||||
|
||||
@@ -50,6 +50,9 @@
|
||||
| Further retention periods (docs/LOESCHKONZEPT.md). The defaults are PROPOSALS – please have them
|
||||
| confirmed according to the general legal opinion (tax advisor / legal advice) and adjust here.
|
||||
*/
|
||||
// Test environments: every e-mail goes to this address only (instead of guests/landlord). Empty = normal delivery.
|
||||
'mail_redirect_to' => env('FEWO_MAIL_REDIRECT_TO'),
|
||||
|
||||
// Daily database backup (php artisan backup:database): number of dumps kept in storage/app/private/backups.
|
||||
'backup' => [
|
||||
'keep' => (int) env('FEWO_BACKUP_KEEP', 14),
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Relaxations of the seasons' minimum stay (see Property::minimumStayRules / PriceCalculator).
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('properties', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('changeover_weekday')->nullable()->after('check_out_time');
|
||||
$table->boolean('min_stay_fill_gaps')->default(true)->after('changeover_weekday');
|
||||
$table->boolean('min_stay_until_changeover')->default(false)->after('min_stay_fill_gaps');
|
||||
$table->unsignedTinyInteger('min_stay_absolute')->default(2)->after('min_stay_until_changeover');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('properties', function (Blueprint $table) {
|
||||
$table->dropColumn(['changeover_weekday', 'min_stay_fill_gaps', 'min_stay_until_changeover', 'min_stay_absolute']);
|
||||
});
|
||||
}
|
||||
};
|
||||
+2
-2
@@ -103,9 +103,9 @@ ## 7. Zugang zur Verwaltung (`/admin`)
|
||||
"cd test.fewo-stommer.de/current && /opt/RZphp84/bin/php-cli artisan users:create lars@stommer.com --name='Lars Stommer' --role=admin"
|
||||
```
|
||||
|
||||
Weitere Benutzer legt ein Administrator in der Verwaltung an (System › Benutzer): Name, E-Mail, **Rolle** (was die Person darf) und **Ansicht** (was das Menü zeigt), Passwort. Rollen: `admin` (alles inkl. Benutzer), `rentals` (Vermietung), `content` (Inhalte); ohne Rolle kein Zugang. Empfehlung: Lars `admin`, Brigitte `rentals` mit einfacher Ansicht.
|
||||
Weitere Benutzer legt ein Administrator in der Verwaltung an (System › Benutzer): Name, E-Mail, **Rolle** (was die Person darf) und **Ansicht** (was das Menü zeigt), Passwort. Rollen: `admin` (alles inkl. Benutzer), `rentals` (Vermietung), `content` (Inhalte); ohne Rolle kein Zugang. Festlegung 22.10.2026: Lars und Brigitte beide `admin` (dürfen alles); Brigitte mit **einfacher Ansicht** (beim Anlegen „Ansicht: Einfach“ wählen, sonst erhalten Administratoren die Expertenansicht).
|
||||
|
||||
**Ansichten:** *Einfache Ansicht* – nur Anfragen & Buchungen (inkl. Bestätigen, Mietvertrag, Zahlungen), Sperrzeiten, Gäste, Portal-Aufgaben, Bewertungen. *Expertenansicht* – alle Einstellungen, die die Rolle erlaubt (Preise, Angebote, Portale, Webseite, System). Ohne Auswahl: Administratoren Experten-, alle anderen einfache Ansicht. Umschalten jederzeit über das Benutzermenü oben rechts („Zur … Ansicht wechseln“). Die Ansicht blendet nur Menüpunkte aus; Rechte regelt allein die Rolle.
|
||||
**Ansichten:** *Einfache Ansicht* – Anfragen & Buchungen (Angebot senden, Mietvertrag, Zahlungen), Sperrzeiten, **Preise & Angebote** (Saisons, Sonderangebote/Rabattcodes, Extras), Gäste, Portal-Aufgaben, Bewertungen, Bilder. *Expertenansicht* – alle Einstellungen, die die Rolle erlaubt (Preise, Angebote, Portale, Webseite, System). Ohne Auswahl: Administratoren Experten-, alle anderen einfache Ansicht. Umschalten jederzeit über das Benutzermenü oben rechts („Zur … Ansicht wechseln“). Die Ansicht blendet nur Menüpunkte aus; Rechte regelt allein die Rolle.
|
||||
|
||||
**Passwort vergessen:** Ein Administrator vergibt unter System › Benutzer › Bearbeiten ein neues Passwort (eine Selbst-Zurücksetzung per E-Mail gibt es bewusst nicht). **Handy verloren:** dort Aktion „2FA zurücksetzen“ – die Person richtet die 2FA bei der nächsten Anmeldung neu ein.
|
||||
|
||||
|
||||
+2
-1
@@ -57,7 +57,8 @@ ## 5. Verwaltungssystem (Admin)
|
||||
|
||||
- **Dashboard:** nächste An-/Abreisen, offene Anfragen, fällige Zahlungen, Auslastung/Umsatz pro Jahr.
|
||||
- **Kalender:** alle Buchungen + Portal-Blockierungen + manuelle Sperrzeiten (Eigennutzung, Renovierung).
|
||||
- **Saisons & Preise:** pro Saison Zeitraum, Preis/Nacht, Mindestaufenthalt, optional An-/Abreisetage. Jahr kopieren („Preise 2027 = 2026“) mit einem Klick.
|
||||
- **Saisons & Preise:** pro Saison Zeitraum, Preis/Nacht, Mindestaufenthalt, optional An-/Abreisetage. Jahr kopieren („Preise 2027 = 2026“) mit einem Klick – optional mit **Saisonbeginn auf einen Wochentag** (z. B. Samstag; aneinandergrenzende Saisons bleiben lückenlos).
|
||||
- **Ausnahmen vom Mindestaufenthalt** (je Wohnung, „Preise & Angebote › Saisons › Regeln Mindestaufenthalt“): kürzer erlaubt, wenn die Buchung eine Kalenderlücke vollständig füllt oder am typischen Anreisetag endet; Sonderangebote jeder Art können ihn aufheben; absolute Untergrenze für alle Ausnahmen (Standard 2 Nächte).
|
||||
- **Preisbestandteile (konfigurierbar):** Endreinigung/Service (108 €), Zusatzperson ab 3. Person (7,50 €/Nacht), Extras (Bettwäsche 14 €, Handtücher 11 €, Paket 23 €), Kurtaxe (Hinweis, vor Ort), Anzahlungsquote 35 %, Restzahlungsfrist 4 Wochen.
|
||||
- Darstellung wahlweise wie heute („erste Nacht inkl. Endreinigung“) oder transparent getrennt – die Berechnung ist identisch.
|
||||
- **Sonderangebote & Sonderkonditionen:** werden bei jeder Preisberechnung automatisch geprüft (siehe 5a).
|
||||
|
||||
@@ -13,6 +13,16 @@
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
|
||||
// Strato: the domain points at the deployment folder and .htaccess forwards to releases/<version>/public,
|
||||
// and the web server then reports the rewritten path in REQUEST_URI/SCRIPT_NAME. Laravel would see
|
||||
// "/releases/…/public/angebot/2" instead of "/angebot/2" (signed links would fail). The site is always
|
||||
// served from the domain root, so the internal prefix is removed here.
|
||||
if (preg_match('~^/(?:releases/[^/?]+|current)/public(?=[/?]|$)~', $_SERVER['REQUEST_URI'] ?? '', $internalPrefix)) {
|
||||
$path = substr($_SERVER['REQUEST_URI'], strlen($internalPrefix[0]));
|
||||
$_SERVER['REQUEST_URI'] = str_starts_with($path, '/') ? $path : '/'.$path;
|
||||
$_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'] = '/index.php';
|
||||
}
|
||||
|
||||
// Bootstrap Laravel and handle the request...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Enums\AdminMode;
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Pages\PricesAndOffers;
|
||||
use App\Filament\Resources\BlockedPeriods\BlockedPeriodResource;
|
||||
use App\Filament\Resources\BlockedPeriods\Pages\ManageBlockedPeriods;
|
||||
use App\Filament\Resources\Properties\PropertyResource;
|
||||
@@ -12,6 +13,7 @@
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Property;
|
||||
use App\Models\Season;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
@@ -63,6 +65,23 @@ public function test_every_admin_resource_and_page_follows_the_admin_mode(): voi
|
||||
}
|
||||
}
|
||||
|
||||
public function test_prices_and_offers_page_bundles_seasons_offers_and_extras_in_the_simple_mode(): void
|
||||
{
|
||||
$property = Property::factory()->create();
|
||||
Season::factory()->for($property)->create(['name' => 'Hochsaison Test', 'starts_on' => now()->addMonth()->toDateString(), 'ends_on' => now()->addMonths(2)->toDateString()]);
|
||||
$this->actingAs(User::factory()->create(['admin_mode' => AdminMode::Simple]));
|
||||
|
||||
$this->get(PricesAndOffers::getUrl())
|
||||
->assertOk()
|
||||
->assertSee('Saisons & Preise', false)
|
||||
->assertSee('Sonderangebote & Rabattcodes', false)
|
||||
->assertSee('Hochsaison Test');
|
||||
$this->get(Dashboard::getUrl())->assertSee('Preise & Angebote', false)->assertSee('Bilder')->assertDontSee('Erscheinungsbilder');
|
||||
|
||||
$this->actingAs(User::factory()->role(UserRole::Content)->create());
|
||||
$this->get(PricesAndOffers::getUrl())->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_administrators_default_to_the_expert_mode(): void
|
||||
{
|
||||
$this->assertSame(AdminMode::Expert, User::factory()->create()->adminMode());
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Actions\CopySeasonsToNextYear;
|
||||
use App\Filament\Resources\Properties\Pages\EditProperty;
|
||||
use App\Filament\Resources\Properties\RelationManagers\SeasonsRelationManager;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Property;
|
||||
use App\Models\Season;
|
||||
use App\Models\SpecialOffer;
|
||||
use App\Models\User;
|
||||
use App\Pricing\PriceCalculator;
|
||||
use App\Pricing\PriceQuote;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MinimumStayRulesTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private Property $property;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->property = Property::factory()->create(['min_stay_absolute' => 2]);
|
||||
Season::factory()->for($this->property)->create(['name' => 'Hauptsaison', 'starts_on' => '2026-06-06', 'ends_on' => '2026-09-05', 'nightly_rate' => 9000, 'min_nights' => 7]);
|
||||
}
|
||||
|
||||
public function test_season_minimum_applies_without_a_rule(): void
|
||||
{
|
||||
$this->expectException(QuoteException::class);
|
||||
|
||||
$this->quote('2026-07-08', '2026-07-11');
|
||||
}
|
||||
|
||||
public function test_stay_filling_a_calendar_gap_completely_may_be_shorter(): void
|
||||
{
|
||||
BlockedPeriod::factory()->for($this->property)->create(['starts_on' => '2026-07-01', 'ends_on' => '2026-07-08']);
|
||||
BlockedPeriod::factory()->for($this->property)->create(['starts_on' => '2026-07-11', 'ends_on' => '2026-07-18']);
|
||||
|
||||
$this->assertSame(3, $this->quote('2026-07-08', '2026-07-11')->nights());
|
||||
|
||||
$this->expectException(QuoteException::class);
|
||||
$this->quote('2026-07-08', '2026-07-10');
|
||||
}
|
||||
|
||||
public function test_gap_rule_can_be_switched_off(): void
|
||||
{
|
||||
$this->property->update(['min_stay_fill_gaps' => false]);
|
||||
BlockedPeriod::factory()->for($this->property)->create(['starts_on' => '2026-07-01', 'ends_on' => '2026-07-08']);
|
||||
BlockedPeriod::factory()->for($this->property)->create(['starts_on' => '2026-07-11', 'ends_on' => '2026-07-18']);
|
||||
|
||||
$this->expectException(QuoteException::class);
|
||||
$this->quote('2026-07-08', '2026-07-11');
|
||||
}
|
||||
|
||||
public function test_stay_ending_on_the_changeover_day_may_be_shorter_but_not_below_the_absolute_minimum(): void
|
||||
{
|
||||
$this->property->update(['changeover_weekday' => 6, 'min_stay_until_changeover' => true]);
|
||||
|
||||
$this->assertSame(3, $this->quote('2026-07-08', '2026-07-11')->nights(), 'Wednesday to Saturday');
|
||||
|
||||
try {
|
||||
$this->quote('2026-07-10', '2026-07-11');
|
||||
$this->fail('one night is below the absolute minimum');
|
||||
} catch (QuoteException) {
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
$this->expectException(QuoteException::class);
|
||||
$this->quote('2026-07-08', '2026-07-10');
|
||||
}
|
||||
|
||||
public function test_any_special_offer_can_waive_the_minimum_stay(): void
|
||||
{
|
||||
SpecialOffer::factory()->for($this->property)->create(['name' => 'Special Weekend', 'arrival_weekdays' => [5], 'max_nights' => 2, 'waives_min_stay' => true, 'discount_value' => 10]);
|
||||
|
||||
$quote = $this->quote('2026-07-10', '2026-07-12');
|
||||
|
||||
$this->assertSame(2, $quote->nights());
|
||||
$this->assertGreaterThan(0, $quote->discount());
|
||||
}
|
||||
|
||||
public function test_copying_seasons_moves_their_start_to_the_weekday_and_keeps_them_adjacent(): void
|
||||
{
|
||||
Season::factory()->for($this->property)->create(['name' => 'Vorsaison', 'starts_on' => '2026-04-04', 'ends_on' => '2026-06-06', 'nightly_rate' => 7000, 'min_nights' => 3]);
|
||||
|
||||
$result = app(CopySeasonsToNextYear::class)->handle($this->property, 2026, 6);
|
||||
|
||||
$copies = $this->property->seasons()->whereYear('starts_on', 2027)->orderBy('starts_on')->get();
|
||||
$this->assertSame(2, $result['created']);
|
||||
$this->assertSame(['2027-04-03', '2027-06-05', '2027-06-05', '2027-09-04'], [
|
||||
$copies[0]->starts_on->toDateString(), $copies[0]->ends_on->toDateString(),
|
||||
$copies[1]->starts_on->toDateString(), $copies[1]->ends_on->toDateString(),
|
||||
]);
|
||||
$this->assertTrue($copies->every(fn (Season $season): bool => $season->starts_on->isSaturday()));
|
||||
}
|
||||
|
||||
public function test_rules_are_edited_next_to_the_seasons(): void
|
||||
{
|
||||
$this->actingAs(User::factory()->create());
|
||||
|
||||
Livewire::test(SeasonsRelationManager::class, ['ownerRecord' => $this->property, 'pageClass' => EditProperty::class])
|
||||
->callAction(TestAction::make('minimumStayRules')->table(), [
|
||||
'changeover_weekday' => 6,
|
||||
'min_stay_fill_gaps' => true,
|
||||
'min_stay_until_changeover' => true,
|
||||
'min_stay_absolute' => 3,
|
||||
])
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$this->assertSame([6, true, 3], [$this->property->fresh()->changeover_weekday, $this->property->fresh()->min_stay_until_changeover, $this->property->fresh()->min_stay_absolute]);
|
||||
}
|
||||
|
||||
private function quote(string $arrival, string $departure): PriceQuote
|
||||
{
|
||||
return app(PriceCalculator::class)->calculate($this->property->fresh(), new StayRequest(CarbonImmutable::parse($arrival), CarbonImmutable::parse($departure), 2), CarbonImmutable::parse('2026-03-01'));
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,7 @@ public function test_gap_filler_advertises_each_gap_found_in_the_calendar(): voi
|
||||
|
||||
public function test_gap_below_minimum_stay_is_not_advertised_unless_the_offer_waives_it(): void
|
||||
{
|
||||
$this->property->update(['min_stay_fill_gaps' => false]);
|
||||
BlockedPeriod::factory()->for($this->property)->create(['starts_on' => '2026-02-05', 'ends_on' => '2026-02-10']);
|
||||
BlockedPeriod::factory()->for($this->property)->create(['starts_on' => '2026-02-12', 'ends_on' => '2026-02-20']);
|
||||
$this->offer(['name' => 'Lückenfüller', 'kind' => OfferKind::GapFiller, 'max_gap_nights' => 4, 'discount_value' => 20]);
|
||||
|
||||
Reference in new issue
Block a user