Führe Rabattcodes, Nutzerkreis der Lizenzoption und Pflichtangaben der Kasse ein

Domäne: Rabattcodes mit Geltungsbereich (Warenkorb oder gewählte Ziele) und
Einlösungsberechtigung (allgemein oder freigeschaltete Konten) unabhängig
voneinander; Prüfung bei Eingabe, in jeder Übersicht und unter Sperre vor
Bestellabschluss (Prüfsumme der Übersicht enthält den Rabatt). Rabatt je
Position, Zwischensumme und Zahlbetrag in der Bestellung; Stripe erhält den
Preis nach Rabatt. Nutzerkreis (Einzel-/Mehrfachlizenz, Trainerzahl) an der
Angebotsfassung, kopiert in Bestellposition und Erwerb, Teil der Prüfung
"Bereits erworben". OfferService::activate lehnt Angebote ohne veröffentlichten
Artikelstand ab. Kasse: Zustimmungen als Pflichtangabe mit Nachweis,
"Zahlungspflichtig bestellen", Rechnungsweg für Organisationen, Erstattung über
Stripe, Widerruf erklären. Produktivfreigabe SHOP_LIVE_RELEASE standardmäßig aus.

Bestandstests geändert (fachlich überholt, Assertions nicht abgeschwächt): die
Schaltfläche heißt "Zahlungspflichtig bestellen" (§ 312j BGB), die Summe heißt
"Zu zahlen", der Vereinshinweis steht als Rollenliste; Bestellungen über die
Kasse senden jetzt die Zustimmungen.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-22 19:42:02 +01:00
1 parent cb80835c92
commit 0154182f3b
40 files changed
+2151 -92

No files matched your search

@@ -0,0 +1,113 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Verkaufsstart Deutschland (A1): nur ergänzend, nichts wird gelöscht oder umbenannt; ein Rollback des Codes lässt
* die neuen Spalten und Tabellen liegen (der frühere Code kennt sie nicht).
*
* - Rabattcodes mit Geltungsbereich (Warenkorb oder ausgewählte Ziele) und Einlösungsberechtigung (allgemein oder
* nur für freigeschaltete Konten). Freigaben werden nie gelöscht, nur entzogen.
* - Nutzerkreis der Lizenzoption (Einzel- oder Mehrfachlizenz, Zahl der Trainer) an der Angebotsfassung, kopiert in
* die Bestellposition. Lizenzinhaber, berechtigte Trainer und Downloadzugriff sind getrennte Angaben.
* - Rabatt, Zahlbetrag, Zahlungsweg und Zustimmungsnachweis an der Bestellung.
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('discount_codes', function (Blueprint $table) {
$table->id();
$table->string('code')->unique();
$table->string('label');
$table->string('kind', 12);
$table->unsignedTinyInteger('percent')->nullable();
$table->unsignedInteger('amount_cents')->nullable();
$table->string('scope', 12)->default('warenkorb');
$table->string('eligibility', 12)->default('allgemein');
$table->timestamp('valid_from')->nullable();
$table->timestamp('valid_until')->nullable();
$table->boolean('active')->default(true);
$table->text('note')->nullable();
$table->timestamps();
});
Schema::create('discount_code_targets', function (Blueprint $table) {
$table->id();
$table->foreignId('discount_code_id')->constrained('discount_codes')->cascadeOnDelete();
$table->string('target_type', 16);
$table->unsignedBigInteger('target_id');
$table->timestamps();
$table->unique(['discount_code_id', 'target_type', 'target_id']);
});
Schema::create('discount_code_releases', function (Blueprint $table) {
$table->id();
$table->foreignId('discount_code_id')->constrained('discount_codes')->cascadeOnDelete();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->foreignId('granted_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('granted_at');
$table->timestamp('valid_until')->nullable();
$table->foreignId('revoked_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('revoked_at')->nullable();
$table->text('reason')->nullable();
$table->timestamps();
$table->index(['discount_code_id', 'user_id']);
});
Schema::table('offer_versions', function (Blueprint $table) {
$table->string('licence_scope', 12)->nullable();
$table->unsignedSmallInteger('trainer_count')->nullable();
});
Schema::table('order_lines', function (Blueprint $table) {
$table->string('licence_scope', 12)->nullable();
$table->unsignedSmallInteger('trainer_count')->nullable();
$table->unsignedInteger('discount_cents')->default(0);
});
Schema::table('orders', function (Blueprint $table) {
$table->unsignedInteger('subtotal_cents')->nullable();
$table->unsignedInteger('discount_cents')->default(0);
$table->foreignId('discount_code_id')->nullable()->constrained('discount_codes')->nullOnDelete();
$table->json('discount_snapshot')->nullable();
$table->string('payment_method', 16)->nullable();
$table->timestamp('terms_accepted_at')->nullable();
$table->json('terms_snapshot')->nullable();
$table->timestamp('withdrawal_requested_at')->nullable();
$table->text('withdrawal_note')->nullable();
});
Schema::table('payments', function (Blueprint $table) {
$table->string('provider_payment_ref')->nullable();
$table->unsignedInteger('amount_cents')->nullable();
});
}
public function down(): void
{
Schema::table('payments', function (Blueprint $table) {
$table->dropColumn(['provider_payment_ref', 'amount_cents']);
});
Schema::table('orders', function (Blueprint $table) {
$table->dropConstrainedForeignId('discount_code_id');
$table->dropColumn([
'subtotal_cents', 'discount_cents', 'discount_snapshot', 'payment_method',
'terms_accepted_at', 'terms_snapshot', 'withdrawal_requested_at', 'withdrawal_note',
]);
});
Schema::table('order_lines', function (Blueprint $table) {
$table->dropColumn(['licence_scope', 'trainer_count', 'discount_cents']);
});
Schema::table('offer_versions', function (Blueprint $table) {
$table->dropColumn(['licence_scope', 'trainer_count']);
});
Schema::dropIfExists('discount_code_releases');
Schema::dropIfExists('discount_code_targets');
Schema::dropIfExists('discount_codes');
}
};