@extends('layouts.layout-2') @php $statusPill = match ($status) { 'critical' => '' . __('Kritisch') . '', 'critical_ordered' => '' . __('Kritisch · bereits bestellt') . '', 'warning' => '' . __('Bald nachbestellen') . '', default => '' . __('Ausreichend') . '', }; $stockCritical = in_array($status, ['critical', 'critical_ordered'], true); @endphp @section('content') @include('admin.inventory.partials.wawi-ui')

{{ $ingredient->name }} {!! $statusPill !!}

{{ __('Rohstoffbestellung & Bestand') }} @if($ingredient->alt_name) · {{ __('Alternativer Name') }}: {{ $ingredient->alt_name }} @endif

{{ \App\Services\Util::formatNumber($remaining, 0) }} g
{{ __('Gesamtbestand') }}
{{ $openTotal > 0 ? \App\Services\Util::formatNumber($openTotal, 0) . ' g' : '—' }}
{{ __('Offen bestellt') }}
{{ ($daily !== null && $daily > 0) ? \App\Services\Util::formatNumber($daily, 0) . ' g' : '—' }}
{{ __('Verbrauch / Tag') }}
{{ $expectedEmpty !== null ? $expectedEmpty->format('d.m.Y') : '—' }}
{{ __('Voraussichtlich auf Null') }} @if($expectedEmpty !== null) ({{ $daysUntilEmpty }} {{ trans_choice('Tag|Tagen', $daysUntilEmpty) }}) @endif
{{ __('Enthalten in') }}
@forelse($ingredient->products as $product) @php $usage = $recipeUsage[$product->id] ?? null; @endphp @empty @endforelse
{{ __('Produkt') }} {{ __('Produktbestand') }} {{ __('Anteil (%)') }} {{ __('Verbrauch (g/Stück)') }}
{{ $product->name }} {{ \App\Services\Util::formatNumber($productStock[$product->id] ?? 0, 0) }} {{ __('Stück') }} @if($usage) {{ \App\Services\Util::formatNumber($usage['percent'], 2) }} % @else — @endif @if($usage && $usage['consumption_per_piece'] !== null) {{ \App\Services\Util::formatNumber($usage['consumption_per_piece'], 2) }} g ({{ __('netto') }} {{ \App\Services\Util::formatNumber($usage['grams_per_piece'], 2) }} g) @else — @endif
{{ __('Dieser Rohstoff wird in keiner aktiven Rezeptur verwendet.') }}
{{ __('Lieferanten & Bestellung') }}
@if(Auth::user()->isAdmin()) @endif @forelse($ingredient->suppliers as $supplier) @php $deliveryTime = $ingredient->delivery_time ?: $supplier->delivery_time; $lastPrice = $lastPriceBySupplier[$supplier->id] ?? null; // AP-21: Bestellweg pro INCI-Lieferant — Pivot-URL gesetzt ⇒ Shop, leer ⇒ Mail. $orderUrl = $supplier->pivot->url; $orderEmail = $supplier->order_email ?: $supplier->email; @endphp @if(Auth::user()->isAdmin()) @endif @empty @endforelse
{{ __('Lieferant') }} {{ __('Lieferzeit') }}{{ __('Letzter Einkauf (Netto/kg)') }}
{{ $supplier->name }} @if($supplier->pivot->preferred) {{ __('bevorzugt') }} @endif @if($supplier->pivot->supplier_sku)
{{ __('Art.-Nr.') }}: {{ $supplier->pivot->supplier_sku }}
@endif
{{ $deliveryTime ?: '—' }} @if($lastPrice !== null) {{ \App\Services\Util::formatNumber($lastPrice, 2) }} € @else — @endif @if($orderUrl) {{ __('Zum Shop') }} @elseif($orderEmail) {{ __('Per Mail') }} @else — @endif
{{ __('Diesem Rohstoff ist kein Lieferant zugeordnet.') }}
@if(Auth::user()->isAdmin()) @endif
{{ __('Offene Bestellungen / unterwegs') }}
@forelse($openOrders as $order) @empty @endforelse
{{ __('Bestellt am') }} {{ __('Lieferant') }} {{ __('Lagerort') }} {{ __('Bestellte Menge') }}
{{ $order->ordered_at?->format('d.m.Y') ?? '—' }} {{ $order->supplier?->name ?? '—' }} {{ $order->location?->name ?? '—' }} {{ \App\Services\Util::formatNumber($order->ordered_quantity, 0) }} g
{{ __('Keine offenen Bestellungen.') }}
@if($openOrders->isNotEmpty()) @endif
{{ __('Verfügbare Chargen') }}
{{-- AP-27: Anzeige je Charge (batch_number) summiert; Einzel-Einkäufe als Unterzeilen --}} @forelse($chargeGroups as $group) @if($group['entries']->count() > 1) @foreach($group['entries'] as $charge) @endforeach @endif @empty @endforelse @if($chargeGroups->isNotEmpty() && count($remainingByLocation) > 0) @foreach($locations as $location) @if(isset($remainingByLocation[$location->id]) && $remainingByLocation[$location->id] > 0) @endif @endforeach @endif
{{ __('Charge') }} {{ __('Lieferant') }} {{ __('Lagerort') }} {{ __('MHD') }} {{ __('Restbestand') }}
{{ $group['batch_number'] ?: '#' . $group['entries']->first()->id }} @if($group['entries']->count() > 1) {{ $group['entries']->count() }} {{ __('Einkäufe') }} @endif {{ $group['suppliers']->isNotEmpty() ? $group['suppliers']->implode(', ') : '—' }} {{ $group['locations']->isNotEmpty() ? $group['locations']->implode(', ') : '—' }} {{ $group['best_before']?->format('d.m.Y') ?? '—' }} {{ \App\Services\Util::formatNumber($group['remaining'], 0) }} g
↳ {{ __('Einkauf vom') }} {{ $charge->received_at?->format('d.m.Y') ?? '—' }} {{ $charge->supplier?->name ?? '—' }} {{ $charge->location?->name ?? '—' }} {{ $charge->best_before?->format('d.m.Y') ?? '—' }} {{ formatWawiQuantity($charge->getAttribute('remaining_quantity'), 0) }} g
{{ __('Kein Restbestand vorhanden.') }}
{{ __('Bestand') }} {{ $location->name }} {{ \App\Services\Util::formatNumber($remainingByLocation[$location->id], 0) }} g
@endsection