Warenwirtschaft: OPT-7 Buchungs-Härtung (Audit H-2, H-3, M-1, M-9)
- H-2: quantity_used muss > 0 sein (FormRequest-Regel + Service-Guard) — negative Zeilen konnten sich in der Summenprüfung aufheben und Chargen-Restbestände aufblähen. - H-3: expandBatchLines() dekrementiert die gecachten Restmengen — zwei Zeilen derselben Charge belasten nicht mehr denselben Einkauf doppelt (FEFO korrekt über beide Zeilen). - M-1: Ausschuss validiert Chargen-Konsistenz (gehört zum Rohstoff, received) und Restbestand (je Charge bzw. gesamt). - M-9: lockForUpdate auf die Produktionszeile bei Update und Löschen. Tests: neuer ProductionHardeningTest (4). Suite: 223 grün, 806 Assertions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
84450385e3
commit
c69721d174
5 changed files with 231 additions and 1 deletions
|
|
@ -193,6 +193,8 @@ class ProductionController extends Controller
|
|||
}
|
||||
|
||||
\DB::transaction(function () use ($production, $productStockService) {
|
||||
// Audit M-9: Zeile sperren, damit Löschen nicht mit parallelem Update kollidiert.
|
||||
Production::query()->lockForUpdate()->findOrFail($production->id);
|
||||
$productStockService->reverseProductionStock($production, (int) auth()->id());
|
||||
$production->delete();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue