Registry Mirror
Skip to content

Conversation

@grandnode-dev

Copy link
Copy Markdown
Member

Type: feature

Issue

Staff had no way to take a reservation slot out of sale (equipment under repair, a booking taken by phone) other than deleting it. A deleted slot is gone from the calendar, and generating the calendar again to bring it back adds duplicates of the slots that are still there.

Solution

  • ProductReservation.BlockedNote: a slot with a note is blocked. No migration — old documents read as not blocked.
  • A blocked slot is taken for everyone: every "free" query of ProductReservationService (SlotsToBook for the hour slot and the day range, GetAvailability, GetFirstVacantDates) skips it, so the cart validator, the checkout claim, the picker and the product page follow without changes of their own.
  • BlockReservations(productId, ids, note) / UnblockReservations(productId, ids):
    • only slots of the product that no order booked are blocked; a booked one belongs to its order and stays;
    • blocking a slot held in a cart ends the hold — that cart item gets the usual "already reserved" warning on its next check;
    • blocking runs under the product lock the checkout uses, so a slot is either booked or blocked, never both;
    • blocking again replaces the note; each change publishes EntityUpdated (audit trail).
  • New state ReservationState.Blocked (booked > blocked > held > free); the grid's state filter has it, and the Free/Held filters leave blocked slots out.
  • Calendar grid (Admin, Store, Vendor — shared controller and partial): a note field and Block selected / Unblock selected in the bulk bar; a grey "Blocked" chip with the note under it. The note is required, trimmed, at most 400 characters, and rendered as text. Same HasAccess scope and product filter as Delete selected.
  • Deleting: Clear calendar keeps blocked slots and says how many it kept (unblock first to remove them); Clear old, Delete selected and the row Delete remove them like any vacant slot, since staff chose them explicitly or their date has passed.
  • New resources in DefaultLanguage.xml and Upgrade/en_250.xml (Admin and Vendor prefixes).
  • The note is never shown on the storefront; no API or import/export surface.

Breaking changes

None. IProductReservationService gains two methods.

Testing

Unit tests: ProductReservationExtensionsTests (state of a blocked slot), ProductReservationServiceTests (availability by hours and by days, first vacant dates, hold and booking of a blocked hour slot, a day range around a blocked day, state filter, block/unblock incl. held, booked, another product's slot, replaced note, events, LiteDB, delete selected takes blocked slots), BaseProductReservationControllerTests (scope, required/too long note, trimmed note and distinct ids, booked slots reported, unblock, Clear calendar keeps blocked, Clear old deletes them, list state + note, POST only). Full solution green; Grand.Module.Api.Tests failed one unrelated warehouse test once in the parallel run and passes on its own.

E2E on a clone of the shared reservations DB (the clone has no new resources, so keys show):

  1. Admin → tent → Reservation calendar: tick Tent 1 on two days, Block selected with an empty note → refused; with a note → both show "Blocked" with the note.
  2. Also block Tent 2 on the first of those days: the storefront availability no longer offers that day as a start, and the day before ends there.
  3. As a customer add a climbing wall slot to the cart; in Admin block that held slot → the cart shows "Already reserved" and the hour is gone from the product page.
  4. Clear calendar on the climbing wall → only the blocked slot is left, the message says it was kept; Unblock selected → the hour is offered again.
  5. Vendor → e-bike: block a day. Store manager → a product limited to the store: block a slot; a POST for a product the store does not own is refused.

Copilot AI balanced review requested due to automatic review settings December 2, 2026 17:01

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.

support added 2 commits December 2, 2026 20:22
Blocking one day of a held day range now releases the other days of that
cart item too, so they are not kept from other customers until the hold
runs out and the cart no longer shows a hold label for an item it cannot
book. The service trims the note and enforces its maximum length for every
caller. A selection that is only partly blocked says how many slots were
left out instead of blaming a booking.
A slot was blocked when its note was not empty, so every query had to test
both null and the empty string. ProductReservation.IsBlocked now decides
the state and the note only says why. Queries test IsBlocked != true, which
also matches a slot stored before the field existed.
The rule that Clear calendar keeps blocked slots lived in the controller,
which filtered the slots in memory and deleted them one by one.
IProductReservationService.ClearCalendar now deletes the unblocked vacant
slots in one filtered delete and returns what it deleted and kept. The
blocked-slot query is one BlockedSlots helper next to BookableSlots.
private IQueryable<ProductReservation> BookableSlots(string productId)
{
//!= true: a slot stored before the field has none, and only a test that is not "true" matches a missing field
return VacantSlots(productId).Where(x => x.IsBlocked != true);
var deleted = await _productReservationRepository.CountAsync(query);
//one filtered delete: a slot booked or blocked meanwhile is checked as it is deleted, and stays
await _productReservationRepository.DeleteManyAsync(x =>
x.ProductId == productId && (x.OrderId == "" || x.OrderId == null) && x.IsBlocked != true);
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