Repository navigation
Keep the merchandise return API inside the panel's rules - #1062
Merged
Merged
Conversation
- Marking a return Received by hand is allowed only when a return receipt was posted or no receipt can take its goods in. The rule moves from the admin view model to IMerchandiseReturnWorkflowService.CanMarkReceived, shared by the panels and the API; the vendor panel keeps its exception. The API status endpoint refuses Received otherwise, and NextStatuses offers it only then (never in the list, as in the panel's list). - PUT on a return changes only the fields sent, so updating the staff notes keeps the customer's comment, external id and pickup address; the pickup date and address change only where the store setting allows them.
added 2 commits
November 18, 2026 07:44
The rule that only a return receipt marks a stock-tracked return received now runs in StatusChangeError, on the return as stored under the order's lock, so every caller gets it, not only the API handler and the panel. The vendor panel, which has no inventory documents, passes withoutReturnReceipts through a new ChangeStatus overload. CanMarkReceived also checks the products of a ManageStockByBundleProducts bundle, as a receipt books those.
- PUT refuses a pickup date or address the return's store does not allow with 400 PickupNotAllowed, read from that store's settings; a value sent back as stored is not a change, so a read-modify-write still works - an address with no field filled in clears the pickup address - the list offers Received in nextStatuses as the return read by id does - CanMarkReceived takes the order the panel loaded already - the panel tests stub the rule's answer instead of copying it - the edit page renders a return whose order or order item was deleted
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.
Resolves: none
Type: bugfix
Issue
Two gaps in the merchandise return API added in #1059, found in its review against the S6 plan:
POST /api/merchandisereturn/{key}/statuswithReceivedwas accepted for any return the flow allows, while the panel refuses it when a product tracking stock has no posted return receipt (the goods reach the stock and their inspection only through a receipt). Through the API a return could be marked received with nothing booked, and a receipt posted later no longer marks it.NextStatusesalso always offeredReceived.PUT /api/merchandisereturn/{key}overwrote every editable field with what was sent, so a body with onlystaffNotescleared the customer's comment, the external id and the pickup address. It also wrote the pickup date and address where the store does not allow them.Solution
IMerchandiseReturnWorkflowService.CanMarkReceived(a posted receipt, or no product in the return tracks stock) and is shared by the panels and the API; the vendor panel keeps its exception (no inventory documents there).ChangeStatusitself is unchanged.Receivedwith409andOrders.MerchandiseReturns.StatusChangeNotAllowedwhen the rule says no;NextStatusesoffersReceivedonly when it is allowed, and never in the list (as the panel's list does not).PUTchanges only the fields that were sent (an empty string still clears a text); the pickup date and address change only whenMerchandiseReturns_AllowToSpecifyPickupDate/...PickupAddressare on, as in the panel.Breaking changes
none (the API from #1059 is unreleased)
Testing
dotnet test src/Tests/Grand.Business.Checkout.Tests- 857 passed (newCanMarkReceivedtests).dotnet test src/Tests/Grand.Web.Admin.Tests- 2030 passed (panel Received tests now go through the shared rule).dotnet test src/Tests/Grand.Module.Api.Tests- 81 passed (Received refused/allowed/unknown return; PUT keeps unsent fields and respects the pickup settings).POST .../status {"status":15}returns 409 andGET .../{key}does not list 15 innextStatuses;PUT .../{key} {"staffNotes":"x"}keepscustomerComments.