Warenwirtschaft: F-07 — Verpackungsvorschau aus dem Produktionsergebnis
Stückliste je Ergebnisprodukt wird ins Formular gegeben; die Vorschau rechnet Outputs × Stückliste (wie die Buchung) und reagiert auf Hinzufügen/Entfernen, Produkt- und Mengenwechsel. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
122d28bc4f
commit
fd1572df35
3 changed files with 49 additions and 14 deletions
|
|
@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue