Skip to content

Fix bonus calculation crash and time entry form responses - #79

Open
travismolick wants to merge 2 commits into
mainfrom
fix/time-entry-bonus-and-redirects
Open

travismolick wants to merge 2 commits into
mainfrom
fix/time-entry-bonus-and-redirects

Conversation

@travismolick

Copy link
Copy Markdown
Contributor

Fixes two bugs found while writing the tests in #78:

  • TimeEntry::calculateBonusTime() crashed with "Attempt to read property "department_id" on null" when called without preloaded bonuses. In that case it queries the bonuses itself, already filtered by department, so they have no pivot. It now checks the pivot only when there is one. Nothing in the app calls it that way today, so this prevents a future crash rather than fixing a live one.
  • VolunteerController::storeTimeEntry() and destroyTimeEntry() were declared to return JsonResponse, but return a redirect for non-JSON requests, so form submits threw a TypeError (500). The return types now allow RedirectResponse.

Each fix has a test (TimeEntryBonusTest, TimeEntryFormRedirectTest) that fails without it.

@travismolick
travismolick requested review from a team and Gawdl3y October 18, 2026 23:02
@travismolick travismolick self-assigned this Oct 18, 2026
@travismolick travismolick added the bug Something isn't working label Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant