Handling of event addons

This commit is contained in:
2026-08-12 17:18:45 +02:00
parent 085299336e
commit 6e4e6b645c
74 changed files with 3072 additions and 95 deletions
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->boolean('tax_liable')->default(false);
$table->unsignedTinyInteger('vat_rate')->default(0);
$table->string('tax_exemption_reason')->nullable();
$table->text('tax_exemption_note')->nullable();
});
}
public function down(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn([
'tax_liable',
'vat_rate',
'tax_exemption_reason',
'tax_exemption_note',
]);
});
}
};
@@ -0,0 +1,21 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->string('vat_pricing_mode')->default('inclusive');
});
}
public function down(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->dropColumn('vat_pricing_mode');
});
}
};
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Friert die umsatzsteuerliche Grundlage bei Event-Anlage aus den Tenant-Einstellungen ein. Die Werte sind
* danach unveränderlich, damit Preisermittlung und spätere Rechnungen von späteren Tenant-Änderungen
* unberührt bleiben. Bestandsevents erhalten die Defaults (keine USt).
*/
return new class extends Migration {
public function up(): void
{
Schema::table('events', function (Blueprint $table) {
$table->boolean('tax_liable')->default(false);
$table->unsignedTinyInteger('vat_rate')->default(0);
$table->string('vat_pricing_mode')->default('inclusive');
$table->string('tax_exemption_reason')->nullable();
$table->text('tax_exemption_note')->nullable();
});
}
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn([
'tax_liable',
'vat_rate',
'vat_pricing_mode',
'tax_exemption_reason',
'tax_exemption_note',
]);
});
}
};
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('tax_exemption_reasons', function (Blueprint $table) {
$table->string('slug')->primary();
$table->string('name');
$table->text('invoice_text')->nullable();
$table->boolean('requires_note')->default(false);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('tax_exemption_reasons');
}
};
@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* Befüllt die Referenztabelle mit den Befreiungsgründen (§ 14 Abs. 4 Nr. 8 UStG) und verknüpft danach den
* nullbaren Befreiungsgrund von Tenant und Event per Foreign Key. Das Seeding erfolgt hier (nicht im
* ProductionDataSeeder), damit die FK-Ziele auch auf bestehenden Datenbanken beim Migrieren existieren.
* Ein noch nicht konfigurierter Tenant hat keinen Grund (NULL).
*/
return new class extends Migration {
public function up(): void
{
$now = now();
DB::table('tax_exemption_reasons')->insertOrIgnore([
['slug' => 'small_business', 'name' => 'Kleinunternehmer (§ 19 UStG)', 'invoice_text' => 'Gemäß § 19 UStG wird keine Umsatzsteuer berechnet.', 'requires_note' => false, 'created_at' => $now, 'updated_at' => $now],
['slug' => 'education', 'name' => 'Bildungs-/Kursleistung (§ 4 Nr. 22a UStG)', 'invoice_text' => 'Die Leistung ist gemäß § 4 Nr. 22 Buchst. a UStG von der Umsatzsteuer befreit.', 'requires_note' => false, 'created_at' => $now, 'updated_at' => $now],
['slug' => 'youth_welfare', 'name' => 'Kinder- und Jugendhilfe (§ 4 Nr. 25 UStG)', 'invoice_text' => 'Die Leistung ist gemäß § 4 Nr. 25 UStG von der Umsatzsteuer befreit.', 'requires_note' => false, 'created_at' => $now, 'updated_at' => $now],
['slug' => 'custom', 'name' => 'Sonstiger Grund (Freitext)', 'invoice_text' => null, 'requires_note' => true, 'created_at' => $now, 'updated_at' => $now],
]);
Schema::table('tenants', function (Blueprint $table) {
$table->foreign('tax_exemption_reason')
->references('slug')->on('tax_exemption_reasons')
->restrictOnDelete()->cascadeOnUpdate();
});
Schema::table('events', function (Blueprint $table) {
$table->foreign('tax_exemption_reason')
->references('slug')->on('tax_exemption_reasons')
->restrictOnDelete()->cascadeOnUpdate();
});
}
public function down(): void
{
Schema::table('tenants', function (Blueprint $table) {
$table->dropForeign(['tax_exemption_reason']);
});
Schema::table('events', function (Blueprint $table) {
$table->dropForeign(['tax_exemption_reason']);
});
}
};
@@ -0,0 +1,81 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* Schärft die Befreiungsgründe: paragraphenbasierte Slugs, präzise Zitate (§ 4 Nr. 25 Buchst. a bzw.
* Nr. 22 Buchst. a), neuer Grund § 4 Nr. 24 (Jugendherbergen) und eine feste Anzeige-Reihenfolge.
* Slug-Renames kaskadieren über die FKs (ON UPDATE CASCADE) auf tenants/events.
*/
return new class extends Migration {
public function up(): void
{
Schema::table('tax_exemption_reasons', function (Blueprint $table) {
$table->unsignedSmallInteger('sort_order')->default(0);
});
// § 19 nur Slug + Sortierung
DB::table('tax_exemption_reasons')->where('slug', 'small_business')->update([
'slug' => 'ustg_19',
'sort_order' => 10,
]);
// § 4 Nr. 25 Buchst. a präzises Zitat (Durchführung kultureller/sportlicher Veranstaltungen)
DB::table('tax_exemption_reasons')->where('slug', 'youth_welfare')->update([
'slug' => 'ustg_4_25a',
'name' => 'Jugendhilfe Veranstaltungen (§ 4 Nr. 25 Buchst. a UStG)',
'invoice_text' => 'Die Leistung ist gemäß § 4 Nr. 25 Buchst. a UStG von der Umsatzsteuer befreit.',
'sort_order' => 30,
]);
// § 4 Nr. 22 Buchst. a korrekt benannt, ans Ende (vor Freitext)
DB::table('tax_exemption_reasons')->where('slug', 'education')->update([
'slug' => 'ustg_4_22a',
'name' => 'Vorträge/Kurse (§ 4 Nr. 22 Buchst. a UStG)',
'invoice_text' => 'Die Leistung ist gemäß § 4 Nr. 22 Buchst. a UStG von der Umsatzsteuer befreit.',
'sort_order' => 40,
]);
// Freitext ans Ende
DB::table('tax_exemption_reasons')->where('slug', 'custom')->update([
'sort_order' => 50,
]);
// § 4 Nr. 24 (Jugendherbergen) neu
$now = now();
DB::table('tax_exemption_reasons')->insertOrIgnore([
[
'slug' => 'ustg_4_24',
'name' => 'Jugendherbergen (§ 4 Nr. 24 UStG)',
'invoice_text' => 'Die Leistung ist gemäß § 4 Nr. 24 UStG von der Umsatzsteuer befreit.',
'requires_note' => false,
'sort_order' => 20,
'created_at' => $now,
'updated_at' => $now,
],
]);
}
public function down(): void
{
DB::table('tax_exemption_reasons')->where('slug', 'ustg_4_24')->delete();
DB::table('tax_exemption_reasons')->where('slug', 'ustg_19')->update(['slug' => 'small_business']);
DB::table('tax_exemption_reasons')->where('slug', 'ustg_4_25a')->update([
'slug' => 'youth_welfare',
'name' => 'Kinder- und Jugendhilfe (§ 4 Nr. 25 UStG)',
'invoice_text' => 'Die Leistung ist gemäß § 4 Nr. 25 UStG von der Umsatzsteuer befreit.',
]);
DB::table('tax_exemption_reasons')->where('slug', 'ustg_4_22a')->update([
'slug' => 'education',
'name' => 'Bildungs-/Kursleistung (§ 4 Nr. 22a UStG)',
'invoice_text' => 'Die Leistung ist gemäß § 4 Nr. 22 Buchst. a UStG von der Umsatzsteuer befreit.',
]);
Schema::table('tax_exemption_reasons', function (Blueprint $table) {
$table->dropColumn('sort_order');
});
}
};
@@ -0,0 +1,20 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
/**
* Setzt den Standard-Befreiungsgrund neuer Tenants auf Jugendhilfe (§ 4 Nr. 25 Buchst. a). Der Wert
* existiert in tax_exemption_reasons, der FK bleibt gültig. Bestehende Zeilen bleiben unverändert.
*/
return new class extends Migration {
public function up(): void
{
DB::statement("ALTER TABLE tenants ALTER COLUMN tax_exemption_reason SET DEFAULT 'ustg_4_25a'");
}
public function down(): void
{
DB::statement('ALTER TABLE tenants ALTER COLUMN tax_exemption_reason DROP DEFAULT');
}
};
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('events', function (Blueprint $table) {
// Veranstaltungsspezifische Pflicht-Auswahlfragen (Teilnahmeoptionen), je Frage genau eine Option.
// Struktur: [ { key, label, options: [ { value, label } ] } ]
$table->json('participation_options')->nullable();
});
}
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn('participation_options');
});
}
};
@@ -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 {
public function up(): void
{
// Gewählte Teilnahmeoptionen je Anmeldung -- eine Zeile pro beantworteter Frage.
// Frage-/Options-Label werden als Snapshot mitgespeichert, damit spätere Änderungen der
// Fragen-Definition am Event bestehende Anmeldungen/Auswertungen nicht verfälschen.
Schema::create('event_participant_options', function (Blueprint $table) {
$table->id();
$table->string('tenant');
$table->foreignId('event_id')->constrained('events', 'id')->cascadeOnDelete()->cascadeOnUpdate();
$table->foreignId('event_participant_id')->constrained('event_participants', 'id')->cascadeOnDelete()->cascadeOnUpdate();
$table->string('question_key');
$table->string('question_label');
$table->string('value');
$table->string('value_label');
$table->timestamps();
$table->foreign('tenant')->references('slug')->on('tenants')->restrictOnDelete()->cascadeOnUpdate();
});
}
public function down(): void
{
Schema::dropIfExists('event_participant_options');
}
};
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::table('events', function (Blueprint $table) {
// Buchbare Zusätze (Event-Addons) als Ja/Nein-Optionen mit Preis.
// Struktur: [ { key, title, description, price, flat } ]
$table->json('addons')->nullable();
});
}
public function down(): void
{
Schema::table('events', function (Blueprint $table) {
$table->dropColumn('addons');
});
}
};
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
// Gewählte Zusätze je Anmeldung -- eine Zeile pro gebuchtem Addon.
// Titel/Preis/Betrag werden als Snapshot mitgespeichert (relevant für die spätere Rechnung).
Schema::create('event_participant_addons', function (Blueprint $table) {
$table->id();
$table->string('tenant');
$table->foreignId('event_id')->constrained('events', 'id')->cascadeOnDelete()->cascadeOnUpdate();
$table->foreignId('event_participant_id')->constrained('event_participants', 'id')->cascadeOnDelete()->cascadeOnUpdate();
$table->string('addon_key');
$table->string('title');
$table->float('price')->default(0);
$table->boolean('flat')->default(false);
$table->integer('days')->default(0);
$table->float('amount')->default(0);
$table->timestamps();
$table->foreign('tenant')->references('slug')->on('tenants')->restrictOnDelete()->cascadeOnUpdate();
});
}
public function down(): void
{
Schema::dropIfExists('event_participant_addons');
}
};