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:
+4
-1
@@ -34,7 +34,10 @@ class EloquentExpenseQueries implements ExpenseQueries
|
||||
|
||||
return $this->summaries(ExpenseModel::query()
|
||||
->where('user_id', $userId)
|
||||
->whereBetween('spent_on', [$start->toDateString(), $start->copy()->endOfMonth()->toDateString()]));
|
||||
// An upper bound before the next month: SQLite keeps date casts as "Y-m-d 00:00:00",
|
||||
// which a between ending at the month's last "Y-m-d" would leave out.
|
||||
->where('spent_on', '>=', $start->toDateString())
|
||||
->where('spent_on', '<', $start->copy()->addMonth()->toDateString()));
|
||||
}
|
||||
|
||||
public function find(int $id): ?ExpenseSummary
|
||||
|
||||
Reference in New Issue
Block a user