changed logic in invoice chart
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 15s
Laravel Pint / pint (pull_request) Successful in 2m30s
Laravel Larastan / larastan (pull_request) Failing after 3m22s

This commit is contained in:
dhanabalan
2026-01-20 16:39:32 +05:30
parent 8cb5f5c251
commit d9319b1ec6

View File

@@ -202,12 +202,22 @@ class InvoiceChart extends ChartWidget
$completedInvoicesPerWeek = []; $completedInvoicesPerWeek = [];
$weekIndex = 0; $weekIndex = 0;
while ($weekStart < $endOfMonth) { while ($weekStart <= $endOfMonth) {
$weekEnd = $weekStart->copy()->addDays(6);
// $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'); $startDay = $weekStart->format('j');
$weekEndLimit = $weekEnd->copy()->subDay(); $endDay = $weekEnd->format('j');
$actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
$endDay = $actualEnd->format('j'); // $startDay = $weekStart->format('j');
// $weekEndLimit = $weekEnd->copy()->subDay();
// $actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
// $endDay = $actualEnd->format('j');
$labels[] = "{$monthName}({$startDay}-{$endDay})"; $labels[] = "{$monthName}({$startDay}-{$endDay})";
@@ -251,7 +261,8 @@ class InvoiceChart extends ChartWidget
$completedInvoicesPerWeek[$weekIndex] = $queryCompleted->count(); $completedInvoicesPerWeek[$weekIndex] = $queryCompleted->count();
// Move to next week // Move to next week
$weekStart = $weekEnd; // $weekStart = $weekEnd;
$weekStart = $weekEnd->copy()->addDay(1);
$weekIndex++; $weekIndex++;
} }