Warenwirtschaft: F-06 — Chargenzeilen nach Validierungsfehler aus old() wiederherstellen
Vorbelegung der Chargen-Zeilen zentral in ProductionController::existingLines();
old('ingredient_lines') hat Vorrang vor dem gespeicherten Stand.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
a803e956e1
commit
122d28bc4f
5 changed files with 78 additions and 25 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<script>
|
||||
(function ($) {
|
||||
var recipeBase = @json(url('/admin/inventory/api/products'));
|
||||
var existingLines = @json($existingLines ?? (object) []);
|
||||
var existingLines = @json(($existingLines ?? []) === [] ? (object) [] : $existingLines);
|
||||
var excludeProductionId = @json($excludeProductionId ?? null);
|
||||
|
||||
var lineIndex = 0;
|
||||
|
|
|
|||
|
|
@ -19,17 +19,6 @@
|
|||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
@php
|
||||
// AP-27: Zeilen je Charge (batch_key) zusammenfassen — mehrere Einkäufe derselben Charge = eine Formularzeile.
|
||||
// F-04: Schlüssel = Rohstoff|Phase, damit ein Rohstoff in zwei Phasen je Phase seinen Anteil behält.
|
||||
$existingLines = $model
|
||||
? $model->productionIngredients->groupBy(fn ($l) => $l->formGroupKey())->map(function ($lines) {
|
||||
return $lines
|
||||
->groupBy(fn ($l) => $l->formBatchKey())
|
||||
->map(fn ($group, $key) => ['batch_key' => $key, 'quantity_used' => (float) $group->sum('quantity_used')])
|
||||
->values();
|
||||
})
|
||||
: [];
|
||||
@endphp
|
||||
@include('admin.inventory.productions._scripts', ['existingLines' => $existingLines, 'excludeProductionId' => null])
|
||||
{{-- Vorbelegung der Chargen-Zeilen: ProductionController::existingLines() (AP-27/F-04/F-06). --}}
|
||||
@include('admin.inventory.productions._scripts', ['existingLines' => $existingLines ?? [], 'excludeProductionId' => null])
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -27,15 +27,6 @@
|
|||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
@php
|
||||
// AP-27: Zeilen je Charge (batch_key) zusammenfassen — mehrere Einkäufe derselben Charge = eine Formularzeile.
|
||||
// F-04: Schlüssel = Rohstoff|Phase, damit ein Rohstoff in zwei Phasen je Phase seinen Anteil behält.
|
||||
$existingLines = $model->productionIngredients->groupBy(fn ($l) => $l->formGroupKey())->map(function ($lines) {
|
||||
return $lines
|
||||
->groupBy(fn ($l) => $l->formBatchKey())
|
||||
->map(fn ($group, $key) => ['batch_key' => $key, 'quantity_used' => (float) $group->sum('quantity_used')])
|
||||
->values();
|
||||
});
|
||||
@endphp
|
||||
@include('admin.inventory.productions._scripts', ['existingLines' => $existingLines, 'excludeProductionId' => $model->id])
|
||||
{{-- Vorbelegung der Chargen-Zeilen: ProductionController::existingLines() (AP-27/F-04/F-06). --}}
|
||||
@include('admin.inventory.productions._scripts', ['existingLines' => $existingLines ?? [], 'excludeProductionId' => $model->id])
|
||||
@endsection
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue