Include the last day of a date range in expense and time entry queries

SQLite stores date casts as "Y-m-d 00:00:00", so a between ending at
"Y-m-d" left out the month's last day and the week's Sunday (the own
expenses test failed on the 30th). Ranges now end before the next day.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-30 10:47:01 +02:00
co-authored by Claude Opus 5.5
parent f24bd3cc35
commit 38c5b43018
5 changed files with 35 additions and 5 deletions
@@ -178,3 +178,15 @@ it('links the job page to its expenses and shows the own expenses by month', fun
->assertSee('Lokakuu 2026')
->assertSee('Lokakuun hankinta');
});
it('lists an expense of the month\'s last day on the own expenses page', function () {
$user = User::factory()->create();
ExpenseModel::factory()->create(['customer_job_id' => $this->job->id, 'user_id' => $user->id, 'description' => 'Helmikuun viimeinen hankinta', 'spent_on' => '2026-02-28']);
ExpenseModel::factory()->create(['customer_job_id' => $this->job->id, 'user_id' => $user->id, 'description' => 'Maaliskuun hankinta', 'spent_on' => '2026-03-01']);
$this->actingAs($user)
->get(route('expenses.mine', ['kuukausi' => '2026-02']))
->assertOk()
->assertSee('Helmikuun viimeinen hankinta')
->assertDontSee('Maaliskuun hankinta');
});
@@ -166,3 +166,13 @@ it('keeps subcontractors to their own jobs and blocks removing tasks with hours'
$this->actingAs(User::factory()->subcontractor()->create());
$this->get(route('time.task', $this->task->id))->assertForbidden();
});
it('counts the hours of Sunday in the week', function () {
$sunday = now()->startOfWeek()->addDays(6)->toDateString();
TimeEntryModel::factory()->create(['task_id' => $this->task->id, 'user_id' => $this->employee->id, 'worked_on' => $sunday, 'hours' => 2]);
$sheet = Livewire::test('time::week')->instance()->sheet;
expect($sheet->totalQuarters)->toBe(8)
->and($sheet->dayTotals[$sunday])->toBe(8);
});