We having an issue relating to inventory levels and behaviour that results in the overselling items that should have 0 inventory and be out of stock.
The issue is intermittent and happening a number of times every day.
We are also unable to replicate the issue locally in development nor in internal test environment so appears to be isolated to the DXC live environment.
Has anyone else experienced a similar issues ?
Having added some logging to try understand what is happening, we can see what appears to be happening is inventory is returning to it’s previous level a short period of time after hitting zero, an example from our logs:
Order placed for last item in stock:
- Purchased at: 09:41
- Item SKU: XXXXXX11
- Expected stock level: 1
- Log shows inventory query returns stock level 1 before placing the order:
- 09:41:45, [Pre-Purchase] Stock levels for item XXXXXX11: 1
- Log shows inventory query returns stock level 0 after placing the order:
- 09:41:48, [Post-Purchase] Stock levels for item XXXXXX11: 0
Next order placed on the same say when item is out of stock:
- Purchased at: 11:45
- Item: XXXXXX11
- Expected stock level: 0
- Log shows inventory query returns stock level 1 before placing the order
- 11:45:13, [Pre-Purchase] Stock levels for item XXXXXX11: 1
- Log shows inventory query returns stock level 0 after placing the order
- 11:45:23, [Post-Purchase] Stock levels for item XXXXXX11: 0
Note these log entries are from the same application server so we do not believe this is a load balancing issue
The following code snippets detail the processing of orders within the solution:
....Following successful payment
// Save cart as purchase order with an initial status of 'On Hold'
var orderReference = _orderRepository.SaveAsPurchaseOrder(cart);
// Load saved purchase order asset status
var purchaseOrder = _orderRepository.Load<IPurchaseOrder>(orderReference.OrderGroupId);
purchaseOrder.OrderStatus = OrderStatus.InProgress;
purchaseOrder.PricesIncludeTax = true;
// Ensure shipment has warehouse code and inventory status
var shipment = purchaseOrder.GetFirstShipment();
shipment.WarehouseCode = _warehouseSettingsProvider.DefaultWarehouseCode;
shipment.OrderShipmentStatus = OrderShipmentStatus.InventoryAssigned;
// Save purchase order changes and remove the cart
_orderRepository.Save(purchaseOrder);
_orderRepository.Delete(cart.OrderLink);
// Run inventory activity
_inventoryProcessor.AdjustInventoryOrRemoveLineItem(shipment, purchaseOrder.OrderStatus, (item, issue) => validationIssues.Add(item, issue));
_orderRepository.Save(purchaseOrder);
... Continue with displaying order confirmation
4 times per day an order status import occurs which updates the order status to completed and shipping status to shipped:
var purchaseOrder = _purchaseOrderRepository.Load(trackingNumber);
if (purchaseOrder != null)
{
order.Id = purchaseOrder.OrderLink.OrderGroupId;
var shipment = purchaseOrder.GetFirstShipment();
shipment.ShipmentTrackingNumber = courierTrackingNumber;
shipment.OrderShipmentStatus = OrderShipmentStatus.Shipped;
purchaseOrder.OrderStatus = OrderStatus.Completed;
_orderRepository.Save(purchaseOrder);
_mailService.SendDispatchEmail(emailAddress, order);
}
Has anyone experienced any similar issues ?
Is there anything in the code snippets you can see that should be executed differently, or any steps missing ?
The project is using CMS v11.11.2, Commerce v12.17.2
Thanks,
Stephen