Task to do https://eonx.atlassian.net/browse/ZEU-4956
- Cancel Order Items for specific purchases regarding the following retailer products
- KAYO
- Ikea
- Deliveroo
- Kogan
- The reorder logic is applied for this products
Issue on the current process
- In order for us to cancel an Order Item created from a Vendor Api product (current case happens with BHN), we would need to fetch a stock request that has a vendor request id. The vendor request id is needed for us to do a cancellation request against their api.
- The issue lies on the following
- 1 Stock request(stockRequest1) per stock when we do a reorder based on the backfill value
- we set the vendor request id here since we are requesting against the vendor api for the stock
- no promise yet since its created from the reorder logic
- 1 Stock request(stockRequest2) per stock every time we allocate them to an order item promise
- we do not set the vendor request id here since this process is considered a pre purchased stock allocation wherein it fetches the stock that was reordered.
- it does however have a promise since we have created them when creating the Order
- The cancellation will fail for the Order Item since we will be fetching stockRequest2 by the promise but will have no vendor request id.
Proposed Solution
- After we allocate the reordered stock to an order item. We will do the following
- Create a repository method to fetch the stockRequest1 by the stockRequest2 id and related stock id with the following filters
- stock request id is not eqaual to the stockRequest2 id
- the same stock id
- mode is in_advance
- If there is a stock request fetched, update stockRequest2 vendor request id and external product ref from the stock request result
- With this solution, we are sure that both stock requests will have the vendor request id and the stock request used will not fail on cancellation of an order item
-