Calculation errors for refunded amounts
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Trennt die Abrechnungstypen, die in der Ausgabenrechnung einer Veranstaltung zählen, von denen, die es
|
||||
* nicht tun.
|
||||
*
|
||||
* Anlass ist die Beitragserstattung: Sie ist keine Aufwandsposition, sondern die Rücknahme einer
|
||||
* Einnahme. Die Einnahmenseite berücksichtigt sie bereits -- ein abgemeldeter Teili fällt aus
|
||||
* `EventResource::getParticipants()` heraus, sein gezahlter Beitrag verschwindet also dort schon. Als
|
||||
* Ausgabe gezählt, ginge derselbe Vorgang ein zweites Mal in die Bilanz.
|
||||
*
|
||||
* Betroffen ist nur die Budgetrechnung der Veranstaltung. In der Kassensicht (Kostenstellen-Liste,
|
||||
* Dashboard) bleibt der Betrag stehen -- dort fließt er tatsächlich ab.
|
||||
*/
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('invoice_types', function (Blueprint $table) {
|
||||
$table->boolean('counts_as_expense')->default(true)->after('selectable');
|
||||
});
|
||||
|
||||
DB::table('invoice_types')
|
||||
->where('slug', 'participation_refund')
|
||||
->update(['counts_as_expense' => false]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('invoice_types', function (Blueprint $table) {
|
||||
$table->dropColumn('counts_as_expense');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Gründe, aus denen ein Teil des gezahlten Beitrags beim Verband bleibt.
|
||||
*
|
||||
* Wird nicht der volle Beitrag erstattet, ist der Rest eine Einnahme, die begründet sein muss -- in der
|
||||
* Buchhaltung ist ein einbehaltener Betrag ohne Grund nicht haltbar. Aufgebaut wie
|
||||
* {@see \App\Enumerations\RefundReason}: app-weite Stammdaten, `slug` als Schlüssel.
|
||||
*/
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('retention_reasons', function (Blueprint $table) {
|
||||
$table->string('slug')->primary();
|
||||
$table->string('name');
|
||||
$table->text('document_text')->nullable();
|
||||
$table->boolean('requires_note')->default(false);
|
||||
$table->integer('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
DB::table('retention_reasons')->insert([
|
||||
[
|
||||
'slug' => 'cancellation_fee',
|
||||
'name' => 'Stornogebühr laut Ausschreibung',
|
||||
'document_text' => 'Einbehalten wurde die in der Ausschreibung genannte Stornogebühr.',
|
||||
'requires_note' => false,
|
||||
'sort_order' => 10,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'slug' => 'incurred_costs',
|
||||
'name' => 'Bereits entstandene Kosten',
|
||||
'document_text' => 'Einbehalten wurden Kosten, die zum Zeitpunkt der Abmeldung bereits entstanden waren.',
|
||||
'requires_note' => false,
|
||||
'sort_order' => 20,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
'slug' => 'material',
|
||||
'name' => 'Bereits beschafftes Material',
|
||||
'document_text' => 'Einbehalten wurden Kosten für Material, das bereits beschafft wurde.',
|
||||
'requires_note' => false,
|
||||
'sort_order' => 30,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
[
|
||||
// Der Text entsteht erst aus dem Freitext der Aktionsleitung -- deshalb hier leer.
|
||||
'slug' => 'custom',
|
||||
'name' => 'Sonstiger Grund',
|
||||
'document_text' => null,
|
||||
'requires_note' => true,
|
||||
'sort_order' => 40,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('retention_reasons');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Was beim Verband bleibt und warum.
|
||||
*
|
||||
* Nur belegt, wenn weniger erstattet wird als gezahlt wurde. Bei voller Erstattung bleiben die Felder
|
||||
* leer bzw. auf 0 -- dann gibt es nichts zu begründen.
|
||||
*
|
||||
* `retained_amount` wird beim Einreichen festgeschrieben und nicht zur Laufzeit gerechnet: Danach führt
|
||||
* `event_participants.amount_paid` bereits den Rest, eine Differenz daraus wäre ab dem Moment falsch.
|
||||
*/
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('participant_refunds', function (Blueprint $table) {
|
||||
$table->string('retention_reason')->nullable()->after('reason_note');
|
||||
$table->text('retention_reason_note')->nullable()->after('retention_reason');
|
||||
$table->float('retained_amount', 2)->default(0)->after('retention_reason_note');
|
||||
});
|
||||
|
||||
// Der Fremdschlüssel in einem eigenen Aufruf: zusammen mit dem Anlegen der Spalte hat MariaDB ihn
|
||||
// hier stillschweigend übergangen, und ein `down()` lief anschließend ins Leere.
|
||||
Schema::table('participant_refunds', function (Blueprint $table) {
|
||||
$table->foreign('retention_reason')->references('slug')->on('retention_reasons')
|
||||
->restrictOnDelete()->cascadeOnUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('participant_refunds', function (Blueprint $table) {
|
||||
$table->dropForeign(['retention_reason']);
|
||||
$table->dropColumn(['retention_reason', 'retention_reason_note', 'retained_amount']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user