From d9319b1ec60422dbdede7ab2c3051ad968ede2c0 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 20 Jan 2026 16:39:32 +0530 Subject: [PATCH] changed logic in invoice chart --- app/Filament/Widgets/InvoiceChart.php | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Filament/Widgets/InvoiceChart.php b/app/Filament/Widgets/InvoiceChart.php index 47d370a..c49c29d 100644 --- a/app/Filament/Widgets/InvoiceChart.php +++ b/app/Filament/Widgets/InvoiceChart.php @@ -202,12 +202,22 @@ class InvoiceChart extends ChartWidget $completedInvoicesPerWeek = []; $weekIndex = 0; - while ($weekStart < $endOfMonth) { - $weekEnd = $weekStart->copy()->addDays(6); + while ($weekStart <= $endOfMonth) { + + // $weekEnd = $weekStart->copy()->addDays(6); + $weekEnd = $weekStart->copy()->addDays(6)->endOfDay(); + // If week end exceeds end of month, limit it + if ($weekEnd->greaterThan($endOfMonth)) { + $weekEnd = $endOfMonth->copy()->endOfDay(); + } + $startDay = $weekStart->format('j'); - $weekEndLimit = $weekEnd->copy()->subDay(); - $actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit; - $endDay = $actualEnd->format('j'); + $endDay = $weekEnd->format('j'); + + // $startDay = $weekStart->format('j'); + // $weekEndLimit = $weekEnd->copy()->subDay(); + // $actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit; + // $endDay = $actualEnd->format('j'); $labels[] = "{$monthName}({$startDay}-{$endDay})"; @@ -251,7 +261,8 @@ class InvoiceChart extends ChartWidget $completedInvoicesPerWeek[$weekIndex] = $queryCompleted->count(); // Move to next week - $weekStart = $weekEnd; + // $weekStart = $weekEnd; + $weekStart = $weekEnd->copy()->addDay(1); $weekIndex++; } -- 2.49.1