Merge pull request 'changed logic in invoice chart' (#206) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s

Reviewed-on: #206
This commit was merged in pull request #206.
This commit is contained in:
2026-01-20 10:59:15 +00:00

View File

@@ -193,10 +193,9 @@ class InvoiceChart extends ChartWidget
} }
elseif ($activeFilter == 'this_month') { elseif ($activeFilter == 'this_month') {
$startOfMonth = now()->startOfMonth()->setTime(8, 0, 0); $startOfMonth = now()->startOfMonth()->setTime(8, 0, 0);
$endOfMonth = now()->endOfMonth()->addDay()->setTime(8, 0, 0); // include full last day $endOfMonth = now()->endOfMonth()->addDay()->setTime(23, 59, 59); // include full last day
$monthName = $startOfMonth->format('M'); $monthName = $startOfMonth->format('M');
// Prepare weekly labels like "May(1-7)", "May(8-14)", etc.
$labels = []; $labels = [];
$weekStart = $startOfMonth->copy(); $weekStart = $startOfMonth->copy();
$importedInvoicesPerWeek = []; $importedInvoicesPerWeek = [];
@@ -204,7 +203,7 @@ class InvoiceChart extends ChartWidget
$weekIndex = 0; $weekIndex = 0;
while ($weekStart < $endOfMonth) { while ($weekStart < $endOfMonth) {
$weekEnd = $weekStart->copy()->addDays(7); $weekEnd = $weekStart->copy()->addDays(6);
$startDay = $weekStart->format('j'); $startDay = $weekStart->format('j');
$weekEndLimit = $weekEnd->copy()->subDay(); $weekEndLimit = $weekEnd->copy()->subDay();
$actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit; $actualEnd = $weekEndLimit->greaterThan($endOfMonth) ? $endOfMonth : $weekEndLimit;
@@ -298,6 +297,7 @@ class InvoiceChart extends ChartWidget
{ {
return 'bar'; return 'bar';
} }
public static function getDefaultName(): string public static function getDefaultName(): string
{ {
return 'invoice-chart'; return 'invoice-chart';