My tip to you if you want to find out what something does "under the hood" in epi is just to decompile it using Jetbrains dotPeek or ilSpy or something similar, and just read code :)
I think I explained this in my book.
I also explain it partly here https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-Commerce/9/Orders/order-processing/ (comments)
Basically RequestInventory will ask the inventory system: "Hi inventory system, this kind Goaral is buying 3 of this SKU. Can you allocate the stock for him so we can ship?". And the inventory system will be "OK, 3 requested and allocated", Or "We only have 2, but 1 can be backordered". This will happen when you actually place your order. The allocated inventory will be "committed" when the shipment is shipped, or will be reverted if you cancel the order before that.
It can be much more complicated underneath if you think about edge cases, but that is basically the idea.
Thank you for your tip Joel, but i already did that before i posted this post and it takes to much time digging, this post is my shortcut.. even tho i like digging i dont really have time for this in my project right now.
Quan, what makes me confused is that "PurchaseRequestedQuantity" is not reduced aven when we call the
_inventoryProcessor.AdjustInventoryOrRemoveLineItem(shipment, purchaseOrder.OrderStatus, (item, issue) => validationIssues.Add(item, issue));
both shipment is shipped and order completed but nothing happends..
from my understanding is should make a "CompleteInventoryRequest"
that should decrease the "PurchaseRequestedQuantity"?
I'm a bit confused here. Once the shipment is shipped (and the order is completed), you should not have to call AdjustInventoryOrRemoveLineItem. That is supposed to call only during check out process.
Once the order is completed the OperationKeys are cleared so the requests will not be changed at all.
Ok, so when and how should the PurchaseRequestedQuantity from InventoryRecord be decreased?
My bad. AdjustInventoryOrRemoveLineItem also do the job of "completing orders" (It should have been a different API). So what you did was correct, when the Shipment status = Shipped, OR Order status = Completed, then it will complete the request (by committing the requested quantity).
However that can only be done if the Shipment.OperationKeys is not empty ...
and the way working with the OperationKeys
are they set when we make first AdjustInventoryOrRemoveLineItem on cart or is that a manual job by calling "RequestInventory" and then setting them to shipments?
i tried to debug in different scenarions but hey never get set..
When you call ReserveInventory - which is called inside AdjustInventoryOrRemoveLineItem when you place the order, it should do all the work for you (request inventory, add operation keys to the shipment...)
Check in your database if the OperationKeys is there
hmm.. ok they are not set when i run AdjustInventoryOrRemoveLineItem on cart.. and they are not there i the table either..
is this a bug, do you know what version it´s fixed in?
I don't think there was a bug regarding to that. We tested this area very intensively and such bug should be caught early.
To make sure, did you look into Shipment table, column OperationKeys?
Can you try with the vanila Quicksilver setup to see if it works?
ok, i tried this on Quicksilver but it was working fine there..
I copied the exact code from Quicksilver but still its not set..
is there any requirementson on the shipment that needs to be set in order to set Operationkeys?
we run 10.2 commerce version
the difference i could see is we have created a shipment line in DB before calling the Adjust method and in QUicksilver that is first created when a order is placed.
does it matter? maybe it cannot exist in the DB before we call adjust method in order to have it set.. ?
question to EPiServer mostly i guess.
what does it do?
does it makes "RequestInventory", can someone explain when and what is does more exactly?