Phase 1: Wohnungen, Saisons & Preisberechnung

- Datenmodell Property/Season/Extra (Beträge in Cent), Seeder mit Preisliste 2026
- PriceCalculator: Saison-Splitting, Mindestaufenthalt, Zusatzperson, Endreinigung, Extras, Anzahlung/Restzahlung
- Filament-Verwaltung: Wohnungen, Saisons (Überschneidungsprüfung, Lückenwarnung, Kopie ins Folgejahr, Preisrechner), Zusatzleistungen
- Tests für Preisberechnung und Saisonverwaltung

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 09:19:49 +02:00
1 parent bf4c1c0838
commit 2e9a391b37
35 files changed
+1766 -12

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
<?php
namespace Database\Factories;
use App\Enums\ExtraPricing;
use App\Models\Extra;
use App\Models\Property;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Extra>
*/
class ExtraFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'property_id' => Property::factory(),
'name' => fake()->randomElement(['Bettwäsche', 'Handtuchpaket', 'Kinderbett']),
'price' => fake()->numberBetween(5, 25) * 100,
'pricing' => ExtraPricing::PerItem,
'is_active' => true,
'sort_order' => 0,
];
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace Database\Factories;
use App\Models\Property;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Property>
*/
class PropertyFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$name = 'Ferienwohnung '.fake()->unique()->lastName();
return [
'name' => $name,
'slug' => str($name)->slug()->toString(),
'address' => fake()->streetAddress().', 18225 Kühlungsborn',
'size_sqm' => fake()->numberBetween(35, 90),
'max_guests' => 4,
'included_guests' => 2,
'extra_guest_fee_per_night' => 750,
'cleaning_fee' => 10800,
'deposit_percent' => 35,
'balance_due_days_before_arrival' => 28,
'is_active' => true,
];
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace Database\Factories;
use App\Models\Property;
use App\Models\Season;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Season>
*/
class SeasonFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$startsOn = fake()->dateTimeBetween('now', '+1 year');
return [
'property_id' => Property::factory(),
'name' => fake()->randomElement(['Vorsaison', 'Hauptsaison', 'Nachsaison']),
'starts_on' => $startsOn->format('Y-m-d'),
'ends_on' => (clone $startsOn)->modify('+4 weeks')->format('Y-m-d'),
'nightly_rate' => fake()->numberBetween(50, 120) * 100,
'min_nights' => 2,
];
}
}
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('properties', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->string('address')->nullable();
$table->unsignedSmallInteger('size_sqm')->nullable();
$table->unsignedTinyInteger('max_guests');
$table->unsignedTinyInteger('included_guests');
$table->unsignedInteger('extra_guest_fee_per_night')->default(0);
$table->unsignedInteger('cleaning_fee')->default(0);
$table->unsignedTinyInteger('deposit_percent')->default(35);
$table->unsignedSmallInteger('balance_due_days_before_arrival')->default(28);
$table->time('check_in_time')->nullable();
$table->time('check_out_time')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('properties');
}
};
@@ -0,0 +1,35 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('seasons', function (Blueprint $table) {
$table->id();
$table->foreignId('property_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->date('starts_on');
$table->date('ends_on');
$table->unsignedInteger('nightly_rate');
$table->unsignedTinyInteger('min_nights')->default(1);
$table->timestamps();
$table->index(['property_id', 'starts_on']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('seasons');
}
};
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('extras', function (Blueprint $table) {
$table->id();
$table->foreignId('property_id')->constrained()->cascadeOnDelete();
$table->string('name');
$table->string('description')->nullable();
$table->unsignedInteger('price');
$table->string('pricing');
$table->boolean('is_active')->default(true);
$table->unsignedSmallInteger('sort_order')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('extras');
}
};
+4 -4
View File
@@ -15,11 +15,11 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
'name' => 'Admin',
'email' => 'admin@example.com',
]);
$this->call(PropertySeeder::class);
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace Database\Seeders;
use App\Enums\ExtraPricing;
use App\Models\Property;
use Illuminate\Database\Seeder;
/**
* The real apartment with its 2026 price list (taken over from the previous website).
*/
class PropertySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$property = Property::create([
'name' => 'Ferienwohnung Stommer',
'slug' => 'ferienwohnung-stommer',
'address' => 'Strandstraße 15, 18225 Kühlungsborn',
'size_sqm' => 53,
'max_guests' => 3,
'included_guests' => 2,
'extra_guest_fee_per_night' => 750,
'cleaning_fee' => 10800,
'deposit_percent' => 35,
'balance_due_days_before_arrival' => 28,
]);
$property->seasons()->createMany([
['name' => 'Neujahr', 'starts_on' => '2025-12-26', 'ends_on' => '2026-01-03', 'nightly_rate' => 11500, 'min_nights' => 6],
['name' => 'Winter', 'starts_on' => '2026-01-03', 'ends_on' => '2026-03-07', 'nightly_rate' => 5500, 'min_nights' => 2],
['name' => 'Nebensaison', 'starts_on' => '2026-03-07', 'ends_on' => '2026-04-03', 'nightly_rate' => 6500, 'min_nights' => 2],
['name' => 'Vorsaison', 'starts_on' => '2026-04-03', 'ends_on' => '2026-05-23', 'nightly_rate' => 8500, 'min_nights' => 2],
['name' => 'Hauptsaison', 'starts_on' => '2026-05-23', 'ends_on' => '2026-06-20', 'nightly_rate' => 9500, 'min_nights' => 2],
['name' => 'Hochsaison', 'starts_on' => '2026-06-20', 'ends_on' => '2026-08-29', 'nightly_rate' => 11500, 'min_nights' => 2],
['name' => 'Hauptsaison', 'starts_on' => '2026-08-29', 'ends_on' => '2026-09-26', 'nightly_rate' => 9500, 'min_nights' => 3],
['name' => 'Nachsaison', 'starts_on' => '2026-09-26', 'ends_on' => '2026-10-31', 'nightly_rate' => 8500, 'min_nights' => 2],
['name' => 'Zwischensaison', 'starts_on' => '2026-10-31', 'ends_on' => '2026-12-19', 'nightly_rate' => 6500, 'min_nights' => 2],
['name' => 'Weihnachten', 'starts_on' => '2026-12-19', 'ends_on' => '2026-12-26', 'nightly_rate' => 8500, 'min_nights' => 4],
['name' => 'Neujahr', 'starts_on' => '2026-12-26', 'ends_on' => '2027-01-03', 'nightly_rate' => 11500, 'min_nights' => 6],
]);
$property->extras()->createMany([
['name' => 'Bettwäsche', 'description' => 'Betten werden bei Anreise bezogen', 'price' => 1400, 'pricing' => ExtraPricing::PerItem, 'sort_order' => 1],
['name' => 'Handtuchpaket', 'description' => '1 Badetuch, 1 Handtuch, 1 Duschvorleger', 'price' => 1100, 'pricing' => ExtraPricing::PerItem, 'sort_order' => 2],
['name' => 'Bettwäsche + Handtuchpaket', 'description' => 'Kombipaket pro Person', 'price' => 2300, 'pricing' => ExtraPricing::PerItem, 'sort_order' => 3],
]);
}
}