Shipment doesn't move to ReadyToShip

I can’t manage to get a shipment to move to ReadyToShip state. I use the Litium Adyen payment app for payments and the DirectShipment app.

Order is placed and when it’s confirmed a shipment is created.

_eventBroker.Subscribe<SalesOrderConfirmed>(async x =>
{
	var shipmentIdBase = x.Item.Id.Replace("LS", "LSS");
	var shippingAddress = x.Item.ShippingInfo.First().ShippingAddress.Clone();

	var digitalGoodsRows = x.Item.Rows.Where(salesOrderRow => salesOrderRow.OrderRowType == OrderRowType.Product && salesOrderRow.ProductType == ProductType.DigitalGoods);
	if (digitalGoodsRows?.Any() ?? false)
	{
		var digitalGoodsShipment = await _shipmentManager.Create(x.Item.SystemId, new CreateShipmentArgs
		{
			Id = $"{shipmentIdBase}-1",
			Rows = digitalGoodsRows.Select(salesOrderRow => new ProductToShipRow
			{
				Quantity = salesOrderRow.Quantity,
				ArticleNumber = salesOrderRow.ArticleNumber
			}).ToList(),
			ShippingMethod = x.Item.ShippingInfo.First().ShippingOption.OptionId,
			Address = shippingAddress,
		});

		using (_securityContextService.ActAsSystem())
		{
			_shipmentService.Create(digitalGoodsShipment);
		}

		var stateTransitionResult = _stateTransitionsService.SetState<Sales.Shipment>(digitalGoodsShipment.SystemId, ShipmentState.Processing);
	}
});

After the shipment is created I set the state to Processing. This creates a capture transaction and the Payment gets Completed. Nothing happens to the shipment though, it’s still in Processing state.
From what I’ve read in the documentation and in other threads in this forum the shipment should automatically move to ReadyToShip when the payment is captured/completed. Am I missing something?

I’ve tried to move the transaction “manually” by doing this.

_eventBroker.Subscribe<Processing>(x =>
{
    var stateTransitionResult = _stateTransitionsService.SetState<Sales.Shipment>(x.SystemId, ShipmentState.ReadyToShip);
});

The stateTransitonResult.Success is True but the shipment stays in processing state. Why? I can’t find any errors in the logs.

Litium version: 8.12

Hi,

Use OrderFullfillmentService.CreateShippment. Then you do not need to set processing state manually.
Do you have any custom code in Validate function of ProcessingToReadyToShipCondition of the accelerator project?

Thanks, I’ll try that instead.

We have no custom code in ProcessingToReadyToShipCondition.Validate at this time.

The shipment is still stuck in processing state. How do I get the shipment to ReadyToShip state? Payment gets completed and no errors in the logs. Am I missing something when I create the shipment? Or have I misunderstood that the shipment automatically should go to ReadyToShip when the payment is captured?

_eventBroker.Subscribe<SalesOrderConfirmed>(x =>
{
	var salesOrder = x.Item;
	var shipmentIdBase = salesOrder.Id.Replace("LS", "LSS");
	var shippingAddress = salesOrder.ShippingInfo.First().ShippingAddress;

	var digitalGoodsRows = salesOrder.Rows.Where(salesOrderRow => salesOrderRow.OrderRowType == Sales.OrderRowType.Product && salesOrderRow.ProductType == Sales.ProductType.DigitalGoods);
	if (digitalGoodsRows?.Any() ?? false)
	{
		_orderFulfilmentService.CreateShipment(new Connect.Erp.Shipment
		{
			OrderId = salesOrder.Id,
			Id = $"{shipmentIdBase}-1",
			ShippingMethod = salesOrder.ShippingInfo.First().ShippingOption.OptionId,
			Address = new Address
			{
				Address1 = shippingAddress.Address1,
				Address2 = shippingAddress.Address2,
				CareOf = shippingAddress.CareOf,
				City = shippingAddress.City,
				Country = shippingAddress.Country,
				Email = shippingAddress.Email,
				Fax = shippingAddress.Fax,
				FirstName = shippingAddress.FirstName,
				LastName = shippingAddress.LastName,
				HouseExtension = shippingAddress.HouseExtension,
				HouseNumber = shippingAddress.HouseNumber,
				MobilePhone = shippingAddress.MobilePhone,
				OrganizationName = shippingAddress.OrganizationName,
				State = shippingAddress.State,
				Title = shippingAddress.Title,
				Zip = shippingAddress.ZipCode
			},
			Rows = digitalGoodsRows.Select(r => new ShipmentRow
			{
				ArticleNumber = r.ArticleNumber,
				OrderRowId = r.Id,
				Quantity = r.Quantity,
			}).ToList()
		});
	}
});

Can we get some help here? Is this a bug that I should report?

I use code similar to yours, except I use the service called ShipmentManager for creating the shipment. Don’t know if that makes any difference:

var shipment = await _shipmentManager.Create(salesOrder.SystemId, new CreateShipmentArgs
{
Address = shippingInfo.ShippingAddress,
Id = salesOrder.Id + “_Shipment”,
Rows = orderOverView.GetShippableProducts(),
ShippingMethod = shippingInfo.ShippingOption.OptionId,
});

_shipmentService.Create(shipment);

no payment errors, and shipment moves to ReadyToShip.

Yes, I used that approach at first but was recommended, here in this thread, to use the OrderFulfilmentService.Create instead.

If you use ShipmentManager.Create and ShipmentService.Create you need to do the state transition to processing on the shipment yourself right? Do you do the state transition to ReadyToShip yourself as well?

What payment app are you using?

Ahhhhh. This is so stupid. I’ve been stuck on this for weeks and now I’ve figured it out.

I’ve been watching the state on the shipments on orders in backoffice expecting the ReadyToShip state to show up there. Seems like it doesn’t. One would expect the state to be reflected in the UI right? I’ve been trying to find the shipment state in the database but I can’t find it. Maybe someone can shed some light what the shipment state value is based on then?

How I figured this out was that I added this event listener and the shipment gets shipped.

_eventBroker.Subscribe<ReadyToShip>(x =>
{
    var stateTransitionResult = _stateTransitionsService.SetState<Sales.Shipment>(x.SystemId, ShipmentState.Shipped);
});

So it obviously gets in to the ReadyToShip state it’s just that it’s never reflected on the shipment on the order in backoffice. There it stays in processing. Not sure if that’s a bug or a feature?

Well I can continue working then.

You find the state in the database in the Common.EntityState table (from memory), it contains order states as well etc.

By the way, the same goes for payment states, they are not fully reflected in backoffice either.
It makes no difference between non-authorized and authorized payments, they both show the same status in UI. Captured payments show up as its own status.

Thanks @Martin.Brandt. Good info.

Payment states isn’t in Common.EntityState from what I can see though. I’m guessing it’s because they are more complex with the transactions and each transaction has it’s own type and result that makes up the state of the payment.

Bug reported for ReadyToShip state not reflected on shipment in backoffice.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.