On-the-hour Day times fit off-the-hour rentals
What & Why
When a gym facility books a rental window that doesn't land on a clean clock hour (e.g. Beach-Full
5:00 PM – 6:55 PM, 115 min), an admin scheduling that Day for athletes naturally wants to publish a clean on-the-hour time like
5:00 PM – 7:00 PM (120 min) so athletes aren't confused by odd minute boundaries. Today this trips the rental-capacity validator on the events-management page with:
> Error: Not enough time on rental Beach-Full 5:00 PM-6:55 PM. 60 min available for this event, but this date needs 115 min.
The validator compares Day minutes against the rental's exact minute window. We want admin-friendly rounding so a Day whose window is on the hour fits a rental window that is almost the same (off by a few minutes on the boundary) without erroring. Facility booking storage stays accurate; only the validator's interpretation gets a small slack.
The user request, verbatim: pick on-the-hour Day times that bracket the rental window (e.g. 5:00–7:00 PM for a 5:00–6:55 PM rental) without an error toast, because the odd minute boundaries are confusing to athletes.
Done looks like
- An admin on who edits a Day to a clean on-the-hour Start/End (e.g. 5:00 PM – 7:00 PM) that brackets a linked off-the-hour rental window (e.g. 5:00 PM – 6:55 PM) can save the event without the "Not enough time on rental" error, as long as the Day's start is at or after the rental's start (allowing the same small slack) and the Day's end is no more than 15 minutes past the rental's end.
- The same tolerance applies in both the bulk preflight () and the per-date assignment () so the toast and the actual save never disagree.
- Auto-fill behaviour when linking a rental on the Day editor populates the Day with on-the-hour rounded Start/End times (round start down, round end up to the nearest quarter-hour, capped at the closest clean :00) so admins don't have to fix it manually. The actual rental record's times are not modified.
- A small helper hint near the Start/End inputs explains the new behaviour: "Your Day can run up to 15 min past the rental's posted end time."
- Capacity math itself (preventing two events from sharing the same rental window) is unchanged for other events linked to the same rental — slack is granted only against the bracketing rental window for the Day being edited, not added to the rental's bookable minute pool against other events.
- Existing per-court overlap detection (Task #1042) is unchanged.
Out of scope
- Changing how / are stored or displayed in the rentals list — the facility's booking-of-record is preserved.
- Two-way sync to push rounded times back to Corsizio or the facility.
- A configurable tolerance UI; 15 minutes is hardcoded with a single shared constant.
- Changing the half-open same-court overlap rule (touching at the boundary still fine).
- The Day 2 / Day 3 both linked to the same single-day rental scenario shown in the screenshot — that "230 min proposed vs 115 min capacity" condition is the rental being legitimately overbooked across two calendar days against a single-date rental, and admins should still see an error there.
Steps
1.
Shared tolerance constant + capacity math — Add a constant. In the capacity helper, when computing whether the proposed Day(s) for the excluded event fit, treat the rental window as effectively extended by the tolerance on the end (and same allowance on the start, never below 0). Apply this only to the
proposed (excluded-event) minutes comparison, not to the cross-event pool. Update the helper's return shape to expose the effective window so callers can show consistent messaging. 2.
Preflight + assign routes use the tolerant math — Both and already call the shared helper; verify the error messages now reflect the tolerant window (or simply no longer fire when the Day is within tolerance) and adjust phrasing so the message references the posted rental window plus the slack ("up to 7:00 PM with a 15-min grace"). 3.
Auto-fill rounds to the hour — When an admin picks a rental in the Day editor and the form auto-fills Start/End from the rental window, round the Day's Start
down and End
up to the nearest quarter-hour, preferring the nearest clean :00 when within tolerance, so a 5:00 PM – 6:55 PM rental auto-fills as 5:00 PM – 7:00 PM. Skip rounding when the rental window is already on a clean hour boundary. 4.
Inline UI hint — Add a single short helper line under the Day's Start/End inputs (or under the rental-link row) explaining the tolerance so admins understand why an apparently "over" time is allowed. Use the shared constant for the number. 5.
Tests — Extend with cases for: (a) on-the-hour Day fits an off-the-hour rental within tolerance (no error), (b) Day exceeds tolerance (still errors), (c) the cross-event minute pool isn't enlarged by tolerance (two events together still detect a real overbook). Add a quick unit test for the auto-fill rounding helper.
Constraints
- America/Regina local-time parsing stays the way it is — all of this is minute-math, not date-math. Don't introduce UTC.
- Terminology in user-facing strings: "Days", "athletes" (per ).
- Do not modify schema or storage.
Relevant files
- - - - - - - - -
No comments:
Post a Comment