Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
0= no rule (no migration — old documents read as 0):ReservationMinimumDays/ReservationMaximumDays— length of a range by days, counted as the days booked (IncBothDaterespected); 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.ProductReservationExtensions:FirstBookableSlotnow includes the lead time, plusLastBookableDate(horizon),FirstEndDate/LastEndDate(length) andFindBrokenBookingRule, which the cart validator (ShoppingCartReservationProductValidator) calls with a localized warning per rule.FirstEndDatenext toLastEndDate(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.FirstEndDateinstead of being computed in the browser; bundle rebuilt.Interval,IntervalUnitId,IncBothDatewere not copied before either) and the four rules. Saved byUpdateProduct, so import/export (new columns) and the API DTO carry them too, as they carryInterval/IncBothDate.DefaultLanguage.xmlandUpgrade/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), adminProductValidatorTests, 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):