Registry Mirror
Skip to content

Conversation

@grandnode-dev

@grandnode-dev grandnode-dev commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Type: feature

Issue

A reservation product could be booked for any length, starting right now or any time in the future. A store renting tents by the weekend or needing a day to prepare a climbing session had no way to say so.

Solution

  • Four product fields, 0 = no rule (no migration — old documents read as 0):
    • ReservationMinimumDays / ReservationMaximumDays — length of a range by days, counted as the days booked (IncBothDate respected); shown for day products only;
    • ReservationLeadTimeHours — no reservation starting sooner; a range by days starts at the store's midnight of its first day, so with a lead time today cannot be booked;
    • ReservationHorizonDays — no reservation starting later than the store's today plus these days.
  • One set of rules in ProductReservationExtensions: FirstBookableSlot now includes the lead time, plus LastBookableDate (horizon), FirstEndDate / LastEndDate (length) and FindBrokenBookingRule, which the cart validator (ShoppingCartReservationProductValidator) calls with a localized warning per rule.
  • The availability endpoint (R12) uses the same rules, so the picker offers only what the cart accepts: each start date gets a FirstEndDate next to LastEndDate (capped by the maximum), a date whose free run is shorter than the minimum is not a start, dates past the horizon are dropped, slots within the lead time are not returned. A run is read past the last date asked by the minimum length, so a start near the end of a read is not lost.
  • Picker: the earliest end date comes from FirstEndDate instead of being computed in the browser; bundle rebuilt.
  • The horizon limits the start only: a range starting within it may run past it, as the cart accepts.
  • Values are clamped where they are used (days of length ≤ 365, lead time ≤ a year, horizon ≤ 3650 days), so a value written by an import or the API cannot overflow a date or shrink the availability read; the controller's year guard leaves room for reading a year on.
  • Admin/Store/Vendor: the four fields in the reservation section of the Info tab (shared partial), validated within the same bounds and maximum ≥ minimum.
  • Copying a product now keeps its calendar settings (Interval, IntervalUnitId, IncBothDate were not copied before either) and the four rules. Saved by UpdateProduct, so import/export (new columns) and the API DTO carry them too, as they carry Interval/IncBothDate.
  • New resources in DefaultLanguage.xml and Upgrade/en_250.xml.

Breaking changes

None. The availability JSON of day products gains FirstEndDate.

Testing

Unit tests: ProductReservationExtensionsTests (each rule, boundaries, 0 = off, both-dates counting, lead time from the store's midnight, horizon from the store's today across UTC midnight, availability length clamps, out-of-range values), ProductReservationServiceTests (a range runs past the horizon, read on by the minimum, dates past the horizon, hour lead time + horizon), CopyProductServiceTests, ShoppingCartValidatorsTests (minimum and lead time warnings with the number, a range within all rules), admin ProductValidatorTests, controller JSON. Full solution: the parallel run fails a varying few tests in other projects (known flakiness); every failing project passes on its own.

E2E on a clone of the shared reservations DB (before the review fixes):

  1. Admin → tent: minimum 2, maximum 1 → rejected; minimum 2, maximum 7 → saved. Climbing wall: lead time 12 h; min/max are hidden for an hour product.
  2. Availability of the tent: each start's first end = start + 2, last end ≤ start + 7; 23 Dec is not a start (its run ends before the 24–26 Dec gap allows two days); 31 Dec still starts a range. E-bike (no rules) unchanged.
  3. Climbing wall at 15:45: no slots today, tomorrow's from 09:00.
  4. Add to cart: tent 1 day → minimum warning, 8 days → maximum warning, 2 days → added; climbing wall slot at 16:00 today → lead time warning, tomorrow's first slot → added.
  5. Tent product page: after picking a start, only the end dates from the first to the last end date are enabled.

Four product fields, 0 = no rule: minimum and maximum days of a range by
days, lead time in hours (a day starts at the store's midnight) and a
horizon in days from the store's today. One set of rules in
ProductReservationExtensions is used by the cart validator, the
availability endpoint and the product page, so the picker offers only
what the cart accepts: the availability gives each start date its first
end date, caps the last one, and drops dates past the horizon.

The fields are edited in the reservation section of the product Info tab
(Admin, Store, Vendor) and carried by import/export and the API DTO.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 14:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

The horizon limits the start of a reservation only; availability read
the slots up to the horizon, so no range could run past it while the
cart accepted one. Rule values are clamped (365 days, a year of lead
time, ten years of horizon), so a value set by an import or the API
cannot overflow a date or shrink the read; the admin validator takes
the same bounds. A copied product keeps its calendar settings and rules.
@grandnode-dev
grandnode-dev merged commit e656a2a into develop Dec 2, 2026
9 checks passed
@grandnode-dev
grandnode-dev deleted the feature/reservation-booking-rules branch December 2, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants