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:
+3
-1
@@ -55,7 +55,9 @@ class EloquentTimeEntryRepository implements TimeEntryRepository
|
||||
{
|
||||
return TimeEntryModel::query()
|
||||
->where('user_id', $userId)
|
||||
->whereBetween('worked_on', [$from->format('Y-m-d'), $to->format('Y-m-d')])
|
||||
// Exclusive upper bound: SQLite keeps date casts as "Y-m-d 00:00:00".
|
||||
->where('worked_on', '>=', $from->format('Y-m-d'))
|
||||
->where('worked_on', '<', $to->modify('+1 day')->format('Y-m-d'))
|
||||
->orderBy('worked_on')
|
||||
->get()
|
||||
->map(fn (TimeEntryModel $model): TimeEntry => $this->toEntity($model))
|
||||
|
||||
Reference in New Issue
Block a user