@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') ?? '—' }} {{ formatWawiQuantity($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 }} {{ formatWawiQuantity($remainingByLocation[$location->id], 0) }} g
{{-- 17.09.2026: Bestandsrechnung zum Nachvollziehen — alle Eingänge (auch Rest 0), Verbrauch, Ausschuss --}} @php $bd = $breakdown; $unboundCount = $bd['unbound_disposals']->count(); $zeroCount = $bd['entries']->filter(fn ($e) => (float) $e->getAttribute('remaining_quantity') <= 0)->count(); $summaryParts = [trans_choice(':count Eingang|:count Eingänge', $bd['entries']->count(), ['count' => $bd['entries']->count()])]; if ($zeroCount > 0) { $summaryParts[] = $zeroCount . ' ' . __('davon aufgebraucht'); } if ($unboundCount > 0) { $summaryParts[] = $unboundCount . ' ' . __('Ausschuss ohne Chargenbezug'); } @endphp
@forelse($bd['entries'] as $entry) @php $isEmpty = (float) $entry->getAttribute('remaining_quantity') <= 0; @endphp @empty @endforelse
{{ __('Eingang') }} {{ __('Charge') }} {{ __('Lagerort') }} {{ __('MHD') }} {{ __('Eingang') }} {{ __('Produktion') }} {{ __('Ausschuss (Charge)') }} {{ __('Ausschuss (o. Charge)') }} {{ __('Rest') }}
{{ $entry->received_at?->format('d.m.Y') ?? '—' }} #{{ $entry->id }} @if($entry->supplier)
{{ $entry->supplier->name }}
@endif
{{ $entry->batch_number ?: '—' }} {{ $entry->location?->name ?? '—' }} {{ $entry->best_before?->format('d.m.Y') ?? '—' }} {{ formatWawiQuantity($entry->received_quantity) }} g {{ (float) $entry->getAttribute('production_quantity') > 0 ? '− ' . formatWawiQuantity($entry->getAttribute('production_quantity')) . ' g' : '—' }} {{ (float) $entry->getAttribute('bound_disposal_quantity') > 0 ? '− ' . formatWawiQuantity($entry->getAttribute('bound_disposal_quantity')) . ' g' : '—' }} {{ (float) $entry->getAttribute('unbound_disposal_quantity') > 0 ? '− ' . formatWawiQuantity($entry->getAttribute('unbound_disposal_quantity')) . ' g' : '—' }} {{ formatWawiQuantity($entry->getAttribute('remaining_quantity')) }} g @if($isEmpty) {{ __('aufgebraucht') }} @endif
{{ __('Noch kein gebuchter Wareneingang.') }}
{{ __('Summe Wareneingänge') }} {{ formatWawiQuantity($bd['received_total']) }} g
{{ __('− Produktionsverbrauch') }} − {{ formatWawiQuantity($bd['production_total']) }} g @if($bd['production_other'] > 0) {{ __('davon :qty g ohne zuordenbaren Eingang (z. B. Eingang nachträglich gelöscht)', ['qty' => formatWawiQuantity($bd['production_other'])]) }} @endif
{{ __('− Ausschuss mit Chargenbezug') }} − {{ formatWawiQuantity($bd['disposed_bound_total'] + $bd['disposed_other']) }} g @if($bd['disposed_other'] > 0) {{ __('davon :qty g ohne zuordenbaren Eingang (Eingang nachträglich gelöscht)', ['qty' => formatWawiQuantity($bd['disposed_other'])]) }} @endif
{{ __('− Ausschuss ohne Chargenbezug') }} − {{ formatWawiQuantity($bd['disposed_unbound_total']) }} g @if($bd['disposed_unbound_unallocated'] > 0) {{ __('davon :qty g keinem Eingang zurechenbar (mehr Ausschuss als Eingang am Lagerort)', ['qty' => formatWawiQuantity($bd['disposed_unbound_unallocated'])]) }} @endif
{{ __('= Gesamtbestand') }} {{ formatWawiQuantity($bd['remaining_total']) }} g
@if($bd['unbound_disposals']->isNotEmpty()) @endif
@endsection