Creating Participation refunds
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Ein Erstattungsvorgang je Anmeldung.
|
||||
*
|
||||
* Der Vorgang läuft in zwei Schritten: die Aktionsleitung gibt Betrag und Grund frei (`pending`), der
|
||||
* Teili ergänzt über den Token-Link seine Bankverbindung (`accepted`). Solange nicht bestätigt wurde,
|
||||
* kann die Aktionsleitung abbrechen (`cancelled`) -- der Link verhält sich danach so, als hätte es nie
|
||||
* eine Freigabe gegeben.
|
||||
*
|
||||
* `event_participants.amount_paid` bleibt in jedem Fall unangetastet: der Vorgang ist freigegeben, aber
|
||||
* noch nicht ausgezahlt. Die Verrechnung kommt mit der Auszahlung.
|
||||
*
|
||||
* Bewusst KEIN Unique auf `event_participant_id`: abgebrochene Vorgänge bleiben als Historie stehen, und
|
||||
* danach darf eine neue Freigabe entstehen. Dass es höchstens einen offenen Vorgang gibt, setzt
|
||||
* ParticipantRefundRepository::openFor() durch.
|
||||
*/
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('participant_refunds', 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();
|
||||
|
||||
// Der öffentliche Link. Eigener Token statt des Teilnehmer-Identifiers, damit ein Abbruch den
|
||||
// Link tötet, ohne andere per Identifier erreichbare Funktionen (GiroCode) mitzunehmen.
|
||||
$table->string('token', 32)->unique();
|
||||
$table->string('status');
|
||||
|
||||
$table->float('amount', 2)->default(0);
|
||||
$table->string('reason')->nullable();
|
||||
$table->text('reason_note')->nullable();
|
||||
|
||||
$table->string('account_owner')->nullable();
|
||||
$table->string('account_iban')->nullable();
|
||||
|
||||
$table->foreignId('released_by')->nullable()->constrained('users', 'id')->nullOnDelete();
|
||||
$table->dateTime('released_at')->nullable();
|
||||
$table->dateTime('accepted_at')->nullable();
|
||||
$table->dateTime('cancelled_at')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('tenant')->references('slug')->on('tenants')->restrictOnDelete()->cascadeOnUpdate();
|
||||
$table->foreign('reason')->references('slug')->on('refund_reasons')->restrictOnDelete()->cascadeOnUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('participant_refunds');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user