Warenwirtschaft: AP-48 — Produktbestand-Buchungsgründe pflegbar, getrennt Ein/Aus

Kundenentscheid 26.08. (D-5): Eingang und Ausgang haben eigene, pflegbare
Gründe-Listen statt einer festen Liste im Controller.

- Neues Modell/Tabelle stock_movement_reasons (label, direction in/out, pos,
  active, SoftDeletes) inkl. Seed der bisherigen Gründe sinnvoll auf Ein-/Ausgang
  aufgeteilt.
- CRUD wie DisposalReason (SettingCrudController + FormRequest + Formular mit
  Richtungs-Auswahl); zwei Listen (Eingangs-/Ausgangs-Gründe) auf der Seite
  Einstellungen → Allgemeines, „Neu anlegen" mit vorbelegter Richtung.
- Produktbestand-Maske: das Grund-Dropdown wird jetzt je nach Eingang/Ausgang
  per JS aus den passenden, gepflegten Gründen befüllt (manualReasons entfernt).
- DeletionGuard: StockMovementReason immer löschbar.

Migration create_stock_movement_reasons auf Dev-/Live-DB. 4 Tests, Suite 326 grün.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-08-28 09:22:32 +00:00
parent e08c8dec40
commit 190713c21b
12 changed files with 381 additions and 22 deletions

View file

@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* AP-48 (Kundenentscheid 26.08.2026): Buchungsgründe für den Produktbestand
* werden pflegbar — mit GETRENNTEN Listen für Eingang und Ausgang. Bisher waren
* die Gründe fest im Controller hinterlegt (eine Liste für beide Richtungen).
*/
public function up(): void
{
Schema::create('stock_movement_reasons', function (Blueprint $table) {
$table->id();
$table->string('label', 100);
$table->enum('direction', ['in', 'out']);
$table->unsignedTinyInteger('pos')->default(0);
$table->boolean('active')->default(true);
$table->timestamps();
$table->softDeletes();
});
$now = now();
$seed = [
'in' => ['Initialbestand', 'Korrektur', 'Inventur', 'Retoure', 'Sonstiges'],
'out' => ['Korrektur', 'Inventur', 'Testervergabe', 'Verlust / Bruch', 'Sonstiges'],
];
$rows = [];
foreach ($seed as $direction => $labels) {
foreach ($labels as $pos => $label) {
$rows[] = [
'label' => $label,
'direction' => $direction,
'pos' => $pos,
'active' => true,
'created_at' => $now,
'updated_at' => $now,
];
}
}
DB::table('stock_movement_reasons')->insert($rows);
}
public function down(): void
{
Schema::dropIfExists('stock_movement_reasons');
}
};