Repository navigation
Add reservation products to an existing order in the admin - #1176
Merged
Merged
Conversation
Staff pick a slot of an hour product or a date range of a day product in the add-product popup. The free slots come from the same availability the storefront reads, for the order's customer, and the product's booking rules apply. The slots are booked for the new order item before it is added; when another order took them meanwhile, the popup says so and nothing is added. A range by days is priced per day, the order item gets the rental dates and the reservation text the checkout writes.
| public class OrderProductViewModelServiceTests | ||
| { | ||
| private Mock<IMediator> _mediator; | ||
| private Mock<IProductReservationService> _productReservationService; |
| { | ||
| private Mock<IMediator> _mediator; | ||
| private Mock<IProductReservationService> _productReservationService; | ||
| private Mock<IShoppingCartValidator> _validator; |
- Free the reserved slots when inserting the order item fails before the order is saved with it. - Refuse adding a product to a canceled order and hide Add new there. - Show the posted reservation again with the warnings it got. - Show a message when the free time cannot be read in the popup.
|
|
||
| var model = (result as ViewResult)?.Model as OrderModel.AddOrderProductModel.ProductDetailsModel; | ||
| Assert.IsNotNull(model); | ||
| CollectionAssert.AreEqual(new[] { "MinimumDays" }, model.Warnings); |
| public class OrderProductViewModelServiceTests | ||
| { | ||
| private Mock<IMediator> _mediator; | ||
| private Mock<IOrderService> _orderService; |
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
Adding a reservation product to an existing order in the admin was not possible: the add-product popup showed a hard-coded "Reservation products are not currently supported for adding to an existing order". Staff who take a booking by phone had no way to put it on the customer's order.
Solution
IProductReservationService.GetAvailability, R12), for the order's customer, through a newOrder/ReservationAvailabilityGET action (Edit permission, order and product scoped as the other add-product actions).TryBook(R2/R6, under the product lock) for the new order item before the item is added. When another cart or order took them meanwhile, the popup shows the warning and nothing is added.PlaceOrderCommandHandler.ReservationInfomoved toProductReservationExtensions.FormatReservationInfo.PricingService(ProductReservationExtensions.RentalDays). Quantity is 1 for a reservation, as in the cart.DefaultLanguage.xmlandUpgrade/en_250.xml.Breaking changes
OrderProductViewModelServicetakes two more constructor dependencies (IProductReservationService,ISettingService);IOrderProductViewModelServicehas a new methodGetReservationAvailability.Testing
Unit tests:
OrderProductViewModelServiceTests(free slot booked for the new item, slot taken meanwhile, validator warning books nothing, day range priced per day with store dates),ProductReservationExtensionsTests(RentalDaysacross a clock change,FormatReservationInfo). Fulldotnet test GrandNode.slnxgreen.E2E on a clone of the shared reservations DB: steps 2–5 above (climbing wall 09:00 slot booked for the new item; 10:00 slot held by
customer2meanwhile → warning, no item; tent 12–15 Jan across a Wednesday booked on Tent 1 at 3 × day price; 24 Dec start → "no reservation can start"; Store panel popup and availability).