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>
114 lines
6.3 KiB
PHP
114 lines
6.3 KiB
PHP
@extends('layouts.layout-2')
|
|
|
|
@section('content')
|
|
@include('admin.inventory.partials.wawi-ui')
|
|
|
|
<div class="wawi-page">
|
|
<div class="wawi-page-head">
|
|
<div>
|
|
<h1 class="wawi-page-head__title">{{ __('Einkauf & Wareneingang') }}</h1>
|
|
<p class="wawi-page-head__subtitle">{{ __('Bestellungen und Wareneingänge von Rohstoffen und Verpackung') }}</p>
|
|
</div>
|
|
<div class="wawi-page-head__actions">
|
|
@if(Auth::user()->isAdmin())
|
|
<a href="{{ route('admin.inventory.stock-entries.create') }}" class="btn btn-primary btn-sm">
|
|
<span class="fas fa-plus mr-1"></span>{{ __('Neuer Einkauf') }}
|
|
</a>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
|
|
<div class="wawi-card">
|
|
<div class="card-datatable table-responsive p-2">
|
|
<table class="datatables-style table wawi-table">
|
|
<thead>
|
|
<tr>
|
|
<th style="max-width: 90px;"></th>
|
|
<th>{{ __('Status') }}</th>
|
|
<th>{{ __('Bestellt') }}</th>
|
|
<th>{{ __('Art') }}</th>
|
|
<th>{{ __('Artikel') }}</th>
|
|
<th>{{ __('Lieferant') }}</th>
|
|
<th>{{ __('Menge') }}</th>
|
|
<th style="max-width: 60px;"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach($values as $row)
|
|
<tr>
|
|
<td class="text-nowrap">
|
|
<a href="{{ route('admin.inventory.stock-entries.show', $row) }}" class="btn icon-btn btn-sm btn-primary" title="{{ __('Ansicht') }}">
|
|
<span class="far fa-eye"></span>
|
|
</a>
|
|
@if(Auth::user()->isAdmin() && $row->status === 'pending')
|
|
<a href="{{ route('admin.inventory.stock-entries.edit', $row) }}" class="btn icon-btn btn-sm btn-secondary" title="{{ __('Bearbeiten') }}">
|
|
<span class="far fa-edit"></span>
|
|
</a>
|
|
@endif
|
|
@if(Auth::user()->isAdmin())
|
|
<a href="{{ route('admin.inventory.stock-entries.copy', $row) }}" class="btn icon-btn btn-sm btn-info" title="{{ __('Duplizieren') }}">
|
|
<span class="far fa-copy"></span>
|
|
</a>
|
|
@endif
|
|
</td>
|
|
<td data-sort="{{ $row->status === 'pending' ? 0 : 1 }}">
|
|
@if($row->status === 'pending')
|
|
<span class="wawi-pill wawi-pill--warning">{{ __('Offen') }}</span>
|
|
@else
|
|
<span class="wawi-pill wawi-pill--ok">{{ __('Eingegangen') }}</span>
|
|
@endif
|
|
</td>
|
|
<td data-sort="{{ $row->ordered_at?->timestamp ?? 0 }}">{{ $row->ordered_at?->format('d.m.Y') }}</td>
|
|
<td>{{ $entryTypeLabels[$row->entry_type] ?? $row->entry_type }}</td>
|
|
<td>
|
|
@if($row->entry_type === 'ingredient' && $row->ingredient)
|
|
<span class="wawi-item-name">{{ $row->ingredient->name }}</span>
|
|
@elseif($row->packagingItem)
|
|
<span class="wawi-item-name">{{ $row->packagingItem->name }}</span>
|
|
@else
|
|
—
|
|
@endif
|
|
</td>
|
|
<td>{{ $row->supplier?->name ?? '—' }}</td>
|
|
<td>
|
|
@if($row->unit === 'gram')
|
|
{{ \App\Services\Util::formatNumber($row->ordered_quantity) }} g
|
|
@else
|
|
{{ \App\Services\Util::formatNumber($row->ordered_quantity, 0) }} {{ __('Stk.') }}
|
|
@endif
|
|
</td>
|
|
<td>
|
|
@if(Auth::user()->isAdmin())
|
|
<form action="{{ route('admin.inventory.stock-entries.destroy', $row) }}" method="post" class="d-inline"
|
|
onsubmit="return confirm(@json($row->status === 'pending' ? __('Eintrag wirklich löschen?') : __('Gebuchten Wareneingang wirklich löschen? Der Bestand wird entsprechend reduziert. Nicht möglich, wenn bereits Verbräuche oder Ausschuss darauf gebucht sind.')));">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="btn btn-link text-danger p-0" title="{{ __('Löschen') }}"><i class="far fa-trash-alt"></i></button>
|
|
</form>
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
@if(($listLimit ?? null) !== null && $values->count() >= $listLimit)
|
|
<p class="text-muted small px-3 pb-2 mb-0">
|
|
{{ __('Es werden offene Bestellungen plus die neuesten :n Wareneingänge angezeigt.', ['n' => $listLimit]) }}
|
|
<a href="{{ route('admin.inventory.stock-entries.index', ['all' => 1]) }}">{{ __('Alle anzeigen') }}</a>
|
|
</p>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
<script>
|
|
$(document).ready(function () {
|
|
$('.datatables-style').dataTable({
|
|
"bLengthChange": false,
|
|
"iDisplayLength": 100,
|
|
"order": [[1, "asc"], [2, "desc"]],
|
|
"columnDefs": [{"orderable": false, "targets": [0, 7]}],
|
|
"language": {"url": "/js/German.json"}
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|