From f3d25952cc17ba0c93dc582855c3c56f51ac4871 Mon Sep 17 00:00:00 2001 From: Vasyka Date: Thu, 16 Jul 2026 07:17:10 +0000 Subject: [PATCH] fix(finance): guard max() when byDay array is empty max(...[]) throws ArgumentCountError. Split the intermediate array and only call max() when it has elements. Fixes /app/finance 500 on tenants with no payments in the current period. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/Filament/Tenant/Pages/Finance.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Filament/Tenant/Pages/Finance.php b/app/Filament/Tenant/Pages/Finance.php index cc62e55..e7cc35b 100644 --- a/app/Filament/Tenant/Pages/Finance.php +++ b/app/Filament/Tenant/Pages/Finance.php @@ -123,7 +123,8 @@ class Finance extends Page // Totals + max (for bar chart scale). $totalIn = array_sum(array_column($byDay, 'in')); $totalOut = array_sum(array_column($byDay, 'out')); - $maxAbs = max(0.001, max(...array_map(fn ($d) => max($d['in'], $d['out']), $byDay))); + $dayMaxes = array_map(fn ($d) => max($d['in'], $d['out']), $byDay); + $maxAbs = max(0.001, $dayMaxes ? max($dayMaxes) : 0); return [ 'rows' => array_values($byDay),