authorize('reports.view'); if ($this->validDay() === null) { $this->day = $clock->today()->format('Y-m-d'); } } #[Computed] public function report(): ?StockValueReportData { $day = $this->validDay(); return $day === null ? null : app(StockValueReport::class)->execute($day); } public function updatedDay(): void { $this->authorize('reports.view'); unset($this->report); } public function quantity(int $milli, string $unit): string { return StockQuantity::format($milli)."\u{00A0}".__('inventory.units.'.$unit); } public function signedMoney(int $cents): string { return ($cents < 0 ? '-' : '').$this->money(abs($cents)); } public function render(): mixed { return $this->view()->title(__('reports.stock_value.title')); } private function validDay(): ?string { if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $this->day) !== 1) { return null; } $date = CarbonImmutable::createFromFormat('!Y-m-d', $this->day); return $date !== null && $date->format('Y-m-d') === $this->day ? $this->day : null; } }; ?>
{{ __('reports.stock_value.title') }}

{{ __('reports.stock_value.intro') }}

@php($report = $this->report) @if ($report === null) @else

{{ __('reports.stock_value.total', ['date' => $this->dateLabel($day), 'amount' => $this->signedMoney($report->totalCents)]) }}

@if ($report->toOrder !== [])

@endif @if ($report->items === []) {{ __('reports.stock_value.empty') }} @else
@foreach ($report->items as $item) @endforeach
{{ __('reports.stock_value.table', ['date' => $this->dateLabel($day)]) }}
{{ __('reports.stock_usage.item') }} {{ __('reports.stock_usage.group') }} {{ __('inventory.columns.balance') }} {{ __('inventory.columns.value') }}
{{ $item->itemName }} @if ($item->needsReorder()) {{ __('inventory.status.reorder') }} @endif {{ $item->groupName }} {{ $this->quantity($item->balanceMilli, $item->unit) }} {{ $this->signedMoney($item->valueCents) }}
@endif @endif