Warenwirtschaft: F-16 — fachliche Vorbedingungen innerhalb der Sperre prüfen

- Statusservice: Vorbedingung (Ausgangsstatus, Zahlungsfreigabe) wird nach
  lockForUpdate erneut geprüft (Board übergibt sie als Closure).
- Wareneingang: Transaktion + Sperre, „offen“ wird innerhalb der Sperre geprüft.
- Ausschuss: betroffene Wareneingänge sperren und Restbestand in der
  Transaktion erneut prüfen.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-09-08 11:09:53 +00:00
parent c2a17835ef
commit 731b2461e2
7 changed files with 170 additions and 36 deletions

View file

@ -19,6 +19,7 @@ use App\Services\InventoryService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Illuminate\View\View;
class StockEntryController extends Controller
@ -46,9 +47,8 @@ class StockEntryController extends Controller
$model = new StockEntry([
'ordered_at' => now()->toDateString(),
'entry_type' => 'ingredient',
// AP-50: Köln als Standard-Lagerort vorbelegen (wie in der Produktion).
'location_id' => Location::query()->where('name', 'like', '%öln%')->value('id')
?? Location::query()->where('active', true)->orderBy('name')->value('id'),
// AP-50/F-17: Köln (aktiv) als Standard-Lagerort — zentral in Location::defaultId().
'location_id' => Location::defaultId(),
]);
$ingredientId = (int) $request->query('ingredient_id');
@ -213,7 +213,13 @@ class StockEntryController extends Controller
$data['best_before'] = null;
}
$this->stockEntryRepository->receive($stockEntry, $data);
try {
$this->stockEntryRepository->receive($stockEntry, $data);
} catch (ValidationException $e) {
\Session::flash('alert-error', $e->errors()['status'][0] ?? __('Eintrag nicht mehr offen.'));
return redirect()->route('admin.inventory.stock-entries.show', $stockEntry);
}
\Session::flash('alert-save', '1');