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) <noreply@anthropic.com>
This commit is contained in:
2026-07-16 07:17:10 +00:00
parent d6ef62013a
commit f3d25952cc
+2 -1
View File
@@ -123,7 +123,8 @@ class Finance extends Page
// Totals + max (for bar chart scale). // Totals + max (for bar chart scale).
$totalIn = array_sum(array_column($byDay, 'in')); $totalIn = array_sum(array_column($byDay, 'in'));
$totalOut = array_sum(array_column($byDay, 'out')); $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 [ return [
'rows' => array_values($byDay), 'rows' => array_values($byDay),