Warenwirtschaft: AP-31 Löschen mit Soft-Delete + Abhängigkeitsprüfung
Anforderung 15.07.2026: Nahezu alle WaWi-Einträge sind jetzt löschbar (Soft-Delete, deleted_at), mit Abhängigkeitsprüfung und Bestätigungs- warnung vor jeder Löschung. - Migration: deleted_at auf 14 WaWi-Tabellen (Stammdaten, ingredients, stock_entries, stock_disposals, productions); SoftDeletes-Trait in den Models (suppliers/packaging_items hatten es bereits). - Neuer App\Services\DeletionGuard: zentrale Abhängigkeitsprüfung je Entität — referenzierte Einträge sind nicht löschbar, Fehlermeldung nennt die Verwendungen (behebt auch Audit M-4: kein 500er/stiller Cascade-Verlust mehr beim Löschen verwendeter Stammdaten). - SettingCrudController::destroy() prüft Blocker; Supplier-, PackagingItem-, Ingredient-destroy ebenso (Ingredient: vollständige Prüfung inkl. Produktion/Ausschuss, Route GET→DELETE, Audit M-6). - Wareneingänge: auch gebuchte Eingänge löschbar, sofern kein Produktions-Verbrauch/Ausschuss darauf gebucht ist. - Ausschuss: löschbar (Menge steht dem Bestand wieder zur Verfügung). - Produktionen: löschbar (admin >= 7); Produktbestand wird per Gegenbuchung zurückgeführt (reverseProductionStock, append-only, withTrashed), Rohstoffverbrauch zählt nicht mehr (Bestandsqueries schließen gelöschte Produktionen aus). - lastNetPricePerSupplier: DB::query statt Model-Query (Global Scope auf Sub-Select-Alias). - Debug-Log-Reste im PackagingItemController entfernt (Audit N-16). - Views: Lösch-Buttons mit deutschen Bestätigungswarnungen (Ausschuss, Produktionen, gebuchte Wareneingänge, INCI als DELETE-Formular). Tests: neuer InventoryDeletionTest (10 Tests), StorageSettingsTest an neue Löschregel angepasst. Volle Suite: 214 grün, 783 Assertions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
d8d4a9be55
commit
35b9076cbc
32 changed files with 844 additions and 41 deletions
|
|
@ -9,6 +9,7 @@ use App\Models\PackagingItem;
|
|||
use App\Models\PackagingMaterial;
|
||||
use App\Models\Supplier;
|
||||
use App\Repositories\PackagingItemRepository;
|
||||
use App\Services\DeletionGuard;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PackagingItemController extends Controller
|
||||
|
|
@ -58,13 +59,6 @@ class PackagingItemController extends Controller
|
|||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
\Log::debug('PackagingItem STORE – raw input', [
|
||||
'category_raw' => $request->input('category'),
|
||||
'category_hex' => bin2hex((string) $request->input('category')),
|
||||
'all_input' => $request->all(),
|
||||
]);
|
||||
\Log::debug('PackagingItem STORE – validated', $validated);
|
||||
|
||||
$item = $this->packagingItemRepository->create($validated);
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
|
@ -90,13 +84,6 @@ class PackagingItemController extends Controller
|
|||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
\Log::debug('PackagingItem UPDATE – raw input', [
|
||||
'category_raw' => $request->input('category'),
|
||||
'category_hex' => bin2hex((string) $request->input('category')),
|
||||
'all_input' => $request->all(),
|
||||
]);
|
||||
\Log::debug('PackagingItem UPDATE – validated', $validated);
|
||||
|
||||
$this->packagingItemRepository->update($packagingItem, $validated);
|
||||
|
||||
\Session::flash('alert-save', '1');
|
||||
|
|
@ -110,6 +97,14 @@ class PackagingItemController extends Controller
|
|||
{
|
||||
$category = $packagingItem->category === 'shipping' ? 'shipping' : 'packaging';
|
||||
|
||||
$guard = app(DeletionGuard::class);
|
||||
$blockers = $guard->blockersFor($packagingItem);
|
||||
if ($blockers !== []) {
|
||||
\Session::flash('alert-error', $guard->message($blockers));
|
||||
|
||||
return redirect()->route('admin.inventory.packaging-items.index', ['category' => $category]);
|
||||
}
|
||||
|
||||
$packagingItem->delete();
|
||||
|
||||
\Session::flash('alert-success', __('Eintrag gelöscht'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue