Warenwirtschaft: AP-27 Wareneingang gleiche Charge zusammenführen

- Chargen-Existenz-Check beim Buchen (JSON-Endpoint batch-check): Hinweis
  „Charge bereits im Haus" + Vorbelegung MHD/Qualität aus dem letzten Eingang
- Rohstoffbestand-Detail: Chargen je batch_number summiert
  (InventoryService::chargeGroupsForIngredient), Einkäufe als Unterzeilen
- Produktion: Charge-Dropdown je Charge mit Summen-Rest (batches im
  Recipe-Payload), Verbrauch wird per expandBatchLines FEFO auf die
  Einzel-Einkäufe der Charge verteilt; Service-API bleibt je stock_entry
- Jeder Einkauf bleibt eigener stock_entry (Preis/Datum/Audit)
- Hinweise-Doku + Plan V6.0 §6 fortgeschrieben

Tests: StockEntryChargeMergeTest (7 neu); Suite 193 grün, 698 Assertions

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-07-06 13:36:19 +00:00
parent e47d848d3d
commit 7a5b5e0f7b
16 changed files with 673 additions and 34 deletions

View file

@ -53,6 +53,12 @@ class ProductionController extends Controller
$payload = $request->validatedPayload();
try {
// AP-27: Chargen-Zeilen (batch_key) FEFO auf die Einzel-Wareneingänge der Charge auflösen.
$ingredientLines = $this->productionService->expandBatchLines(
$payload['ingredient_lines'],
$payload['location_id']
);
$production = $this->productionService->store(
[
'product_id' => $payload['product_id'],
@ -61,7 +67,7 @@ class ProductionController extends Controller
'quantity' => $payload['quantity'],
'notes' => $payload['notes'],
],
$payload['ingredient_lines'],
$ingredientLines,
(int) $request->user()->id
);
} catch (ValidationException $e) {
@ -119,6 +125,13 @@ class ProductionController extends Controller
$payload = $request->validatedPayload();
try {
// AP-27: Beim Bearbeiten die eigene Produktion aus der Rest-Berechnung ausnehmen.
$ingredientLines = $this->productionService->expandBatchLines(
$payload['ingredient_lines'],
$payload['location_id'],
$production->id
);
$production = $this->productionService->updateProduction(
$production,
[
@ -128,7 +141,7 @@ class ProductionController extends Controller
'quantity' => $payload['quantity'],
'notes' => $payload['notes'],
],
$payload['ingredient_lines'],
$ingredientLines,
(int) $request->user()->id
);
} catch (ValidationException $e) {