diff --git a/app/Http/Controllers/Admin/Inventory/ProductionController.php b/app/Http/Controllers/Admin/Inventory/ProductionController.php index 3c3564a..f7cabc4 100644 --- a/app/Http/Controllers/Admin/Inventory/ProductionController.php +++ b/app/Http/Controllers/Admin/Inventory/ProductionController.php @@ -285,12 +285,23 @@ class ProductionController extends Controller $existingOutputIds = $production?->outputs?->pluck('product_id')->map(fn ($id) => (int) $id)->all() ?? []; $outputProducts = Product::query() + ->with('packagings:id,name') ->where(fn ($q) => $q->where('active', 1)->where('is_set', false)) ->when($existingOutputIds !== [], fn ($q) => $q->orWhereIn('id', $existingOutputIds)) ->orderBy('name') ->get($columns); - return ['products' => $products, 'outputProducts' => $outputProducts]; + // F-07: Verpackungs-Stückliste je Ergebnisprodukt für die Vorschau im Browser — + // dieselbe Basis wie die Buchung (syncPackagingSnapshot: Outputs × Stückliste). + $packagingBom = $outputProducts + ->mapWithKeys(fn (Product $p) => [(int) $p->id => $p->packagings->map(fn ($pk) => [ + 'id' => (int) $pk->id, + 'name' => $pk->name, + 'per_unit' => (float) ($pk->pivot->quantity ?? 1), + ])->values()->all()]) + ->all(); + + return ['products' => $products, 'outputProducts' => $outputProducts, 'packagingBom' => $packagingBom]; } /** diff --git a/resources/views/admin/inventory/productions/_form_fields.blade.php b/resources/views/admin/inventory/productions/_form_fields.blade.php index 9a84d83..8cc0f41 100644 --- a/resources/views/admin/inventory/productions/_form_fields.blade.php +++ b/resources/views/admin/inventory/productions/_form_fields.blade.php @@ -139,7 +139,7 @@ {{-- AP-41: Verpackungs-Vorschau direkt unter die INCI-Tabelle — man sieht auf einen Blick, was zusätzlich zu den Rohstoffen gebraucht wird. --}} -
{{ __('Verpackung (Vorschau)') }}
+
{{ __('Verpackung (Vorschau)') }} {{ __('aus dem Produktionsergebnis') }}
@@ -175,7 +175,7 @@
{{ __('Chargen-Nr.') }}
-
+
{{ __('Artikel') }}{{ __('Stück gesamt') }}