@extends('layouts.app') @section('title', 'Food Cost') @section('content') @php $money = fn ($v) => \App\Support\Fmt::money($v); $num = fn ($v) => \App\Support\Fmt::plain($v, 2); $signedMoney = fn ($v) => \App\Support\Fmt::signedMoney($v); $bandMeaning = [ 'Healthy' => 'Variance within 2%', 'Watch' => 'Variance between 2% and 5%', 'Flagged' => 'Variance above 5%', ]; $sortLink = function (string $key) use ($period, $band, $sort, $dir) { return route('kitchen.food-cost', [ 'period' => $period, 'band' => $band, 'sort' => $key, 'dir' => ($sort === $key && $dir === 'desc') ? 'asc' : 'desc', ]); }; $sortHead = function (string $key, string $label, bool $right = true) use ($sort, $dir, $sortLink) { return '' .''.$label.' ' .($sort === $key ? ($dir === 'asc' ? '↑' : '↓') : '').''; }; @endphp

Theoretical against actual usage, banded by variance

Food Cost

CSV
@include('partials.flashes')
Period {{ $periods[$period]['label'] }} {{ $periods[$period]['days'] }} service days
Should have cost {{ $money($totals['should']) }}
Did cost {{ $money($totals['did']) }}
Difference {{ $signedMoney($totals['diff']) }}
Cost per child per day {{ $money($totals['perChild']) }}
@foreach (['all' => 'All', 'Healthy' => 'Healthy', 'Watch' => 'Watch', 'Flagged' => 'Flagged'] as $key => $label) {{ $label }} ({{ $bandCounts[$key] }}) @endforeach

Theoretical vs actual by item

@foreach ($bands as $b) @include('kitchen.partials.band', ['band' => $b]) {{ $bandMeaning[$b] }} @endforeach
{!! $sortHead('item', 'Item', false) !!} {!! $sortHead('theoretical', 'Theoretical') !!} {!! $sortHead('actual', 'Actual') !!} {!! $sortHead('variance', 'Variance') !!} {!! $sortHead('variancePct', 'Variance %') !!} {!! $sortHead('should_cost', 'Should have cost') !!} {!! $sortHead('did_cost', 'Did cost') !!} {!! $sortHead('diff', 'Difference') !!} {!! $sortHead('band', 'Band', false) !!} @forelse ($rows as $row) @empty @endforelse @if ($rows->isNotEmpty()) @endif
{{ $row['item'] }} {{ $num($row['theoretical']) }} {{ $num($row['actual']) }} {{ $row['variance'] > 0 ? '+' : '' }}{{ $num($row['variance']) }} {{ $num($row['variancePct'], 1) }}% {{ $money($row['should_cost']) }} {{ $money($row['did_cost']) }} {{ $signedMoney($row['diff']) }} @include('kitchen.partials.band', ['band' => $row['band']])
No items in this band.
Totals ({{ $band === 'all' ? 'all bands' : $band }}) {{ $num($rows->sum('theoretical')) }} {{ $num($rows->sum('actual')) }} {{ $num($rows->sum('variance')) }} {{ $money($rows->sum('should_cost')) }} {{ $money($rows->sum('did_cost')) }} {{ $signedMoney($rows->sum('diff')) }}
@endsection