Try our conversational search powered by Generative AI!

Can't release shipment

Vote:
 

Commerce 11.8.2

At the moment in commerce manager we're unable to click release shipment due to the button being greyed out.

I have looked through this forum and while others have come across this issue all the solutions haven't worked for me.

All variants have inventory assigned, along with a warehouse, I have tried both tracked and untracked inventory (I'd prefer untracked but i'll take track for it to work!!)

Looking through the forum and online I need to Adjust/Update the inventory.

Thus, I have tried the following:

        public Dictionary> RequestInventory(ICart cart)
        {
            var validationIssues = new Dictionary>();        
            cart.AdjustInventoryOrRemoveLineItems((item, issue) => validationIssues.AddValidationIssues(item, issue), _inventoryProcessor);
            return validationIssues;
        }

        public Dictionary RequestShipmentInventory(IShipment shipment, ICart cart)
        {
            var validationIssues = new Dictionary();
            _inventoryProcessor.AdjustInventoryOrRemoveLineItem(shipment, cart.OrderStatus, (item, issue) => validationIssues.Add(item, issue));

            // shipment.AdjustInventoryOrRemoveLineItems((item, issue) => validationIssues.AddValidationIssues(item, issue), _inventoryProcessor);
            return validationIssues;
        }

        public Dictionary> RequestInventory(IPurchaseOrder order)
        {
            var validationIssues = new Dictionary>();
            order.AdjustInventoryOrRemoveLineItems((item, issue) => validationIssues.AddValidationIssues(item, issue), _inventoryProcessor);
            return validationIssues;
        }

This doesn't make any difference at all, the button is still disabled.

I have tried to manually set the status:

cart.GetFirstShipment().OrderShipmentStatus = OrderShipmentStatus.InventoryAssigned;

And this also doesn't effect it.

Similary I have tried:

var order = _orderRepository.Load(orderReference.OrderGroupId);
            order.GetFirstShipment().OrderShipmentStatus = OrderShipmentStatus.InventoryAssigned;

Again no luck.

Any assistance or direction would be great.

#194165
Jun 14, 2018 18:43
Vote:
 

Was the order fully paid?

#194166
Jun 14, 2018 19:07
Vote:
 

Hi Quan,

We're using Braintree so we get the transaction back from them. Along the lines of:

            var paymentMethod = _paymentService.GetPaymentMethodByType(typeof(BraintreePaymentMethod));

            var payment = _orderGroupFactory.CreateCardPayment(order);
            order.AddPayment(payment, _orderGroupFactory);

            // Set values after adding to collection because of limitation in implementation
            payment.Amount = transaction.Amount.Value;
            payment.CardType = transaction.CreditCard.CardType.ToString();
            payment.CustomerName = transaction.CreditCard.CardholderName;
            payment.CreditCardNumber = transaction.CreditCard.MaskedNumber;
            payment.PaymentMethodId = paymentMethod.PaymentMethodId;
            payment.PaymentMethodName = "Braintree";
            payment.ExpirationMonth = int.Parse(transaction.CreditCard.ExpirationMonth);
            payment.ExpirationYear = int.Parse(transaction.CreditCard.ExpirationYear);
            payment.Status = transaction.Status.ToString();
            payment.AuthorizationCode = transaction.ProcessorAuthorizationCode;
            payment.BillingAddress = _mapper.Map(billingAddress, order.CreateOrderAddress("Billing"));

            order.OrderStatus = OrderStatus.InProgress;

And the value taken through the payment gateway matches the PO

#194181
Jun 15, 2018 9:53
Vote:
 

You need to set the Payment.TransactionType.

Capture or Sale are the most appropriate if you're charging. (It depends on if you've set up handling for any of them in your IPaymentGateway)

The payment also needs to be processed.

The UpdateTotalsActivity is responsible for setting OrderForm.CapturedPaymentTotal which is what the "IsPaid" clause that Quan mentioned looks at

Depending on your payment handling flow you could alternatively set the TransactionType to Authorization. UpdateTotalsActivity will then add those values to OrderForm.AuthorizedPaymentTotal instead which is also looked at when checking if the order is considered to be paid. 

#194186
Edited, Jun 15, 2018 10:47
Vote:
 

I have made the suggested changed:

            payment.Status = PaymentStatus.Processed.ToString();
            payment.TransactionType = Mediachase.Commerce.Orders.TransactionType.Sale.ToString();

And still this doesn't make a difference on being able to release the shipment

#194190
Jun 15, 2018 11:37
Vote:
 

Do you call IOrderGroup.ProcessPayments() somewhere?

order.ProcessPayments();

It processes the payments and also calls IOrderForm.UpdatePaymentTotals() which does what UpdateTotalsActivity did for the old API (which I for some reason assumed that you used above :P ).

If you don't have an IPaymentGateway/IPaymentPlugin setup for your Braintree implementation you can try calling UpdatePaymentTotals() directly:

order.GetFirstForm().UpdatePaymentTotals();
#194192
Edited, Jun 15, 2018 12:20
Vote:
 

I have:

                SavePaymentDetails(order, transaction, command.BillingAddress);
                order.ProcessPayments();
                orderReference = _orderRepository.Save(order);

Where SavePaymentDetails is the above pasted method where set the status etc.

I have also tried

order.GetFirstForm().UpdatePaymentTotals();

In case there was something wring with our payment gateway but still no difference.

#194193
Jun 15, 2018 12:43
Vote:
 

Alright, maybe it's not the payments. :)

Either way here's the things that I know of that sets the button as disabled:

  1. Shipping method is the predefined Store pickup but warehouse selected on the shipment is not a pickup location
  2. Shipment.ShippingMethodId is NOT set
  3. Shipment.ShippingAddressId is NOT set
  4. Order status is AwaitingExchange
  5. ShipmentStatus is NOT set to either AwaitingInventory or InventoryAssigned
  6. PurchaseOrder.Total is NOT covered fully by OrderForm.CapturedPaymentTotal + OrderForm.AuthorizedPaymentTotal (and returned items totals, if any), (In other words it's not considered to be paid as we discussed above)
  7. Any of the lineitems does not have appropriate levels of stock for the quantity to be delivered by that shipment.

For purposes of debugging order data I usually use these SQL queries:

DECLARE @OrderGroupId int = '12345' -- Set this to the ordergroupId of the order you want to check

SELECT * FROM OrderGroup og
JOIN OrderGroup_PurchaseOrder po ON og.OrderGroupId = po.ObjectId
WHERE og.OrderGroupId = @OrderGroupId

SELECT * 
FROM [dbo].[OrderForm] oform
JOIN OrderFormEx ofex ON oform.OrderFormId = ofex.ObjectId
WHERE oform.OrderGroupId = @OrderGroupId

SELECT *
FROM [dbo].Shipment sh
JOIN ShipmentEx shex ON sh.ShipmentId = shex.ObjectId
WHERE sh.OrderGroupId = @OrderGroupId

SELECT *
FROM [dbo].LineItem l
JOIN LineItemEx lex ON l.LineItemId = lex.ObjectId
WHERE OrderGroupId = @OrderGroupId
ORDER BY LineItemOrdering ASC

SELECT *
FROM OrderGroupAddress oga
JOIN OrderGroupAddressEx ogae ON oga.OrderGroupAddressId = ogae.ObjectId
WHERE oga.OrderGroupId = @OrderGroupId

SELECT *
FROM [dbo].OrderFormPayment ofp
WHERE ofp.OrderGroupId = @OrderGroupId

So if you can get a hold of the orders OrderGroupId you can see what the different values are, for example check OrderForm.CapturedPaymentTotal, Shipment.ShippingMethodId etc etc

#194196
Edited, Jun 15, 2018 14:31
Vote:
 

That's a very good summary Jeff. I'm going to make it easier to diagnose why a shipment can't be released. I know it has been a pain in the a** for quite some time, but I haven't had time to really do anything about it. Today I can!

#194197
Jun 15, 2018 14:59
Vote:
 

Thanks, this is helpful. I have run the query and this is what I found, I'm not sure how relvent.

  • In the Shipment table the Status is set to NULL and there is no WarehouseCode
  • In the LineItems table there is no warehousecode but I believe this is obsolete since v9
  • In the lineItems table the InStockQuanity is 0, having checked the [InventoryService] table I can see that they have plenty of stock in the PurchaseAvaliabityQunaity column
  • In the lineitem table IsInventoryAllocated and InventoryStatus are both 0

Apart from that they all look ok

#194206
Jun 15, 2018 15:28
Vote:
 

Looks like it came down to not setting the WarehouseCode on the shipment and possibly the order in which we processed the payment/saved to a PO.

In earlier versions of commerce we didn't have to explictly set the warehouse code and it just fell back to "default" has this been a change?

#194214
Jun 15, 2018 18:07
Vote:
 
  • In the Shipment table the Status is set to NULL and there is no WarehouseCode
    This is an issue, How does the code where you create your shipment look like? (what happens before running cart.AdjustInventoryOrRemoveLineItems()? Make sure WarehouseCode is set
  • In the LineItems table there is no warehousecode but I believe this is obsolete since v9
    That's correct, this shouldn't affect things in this case.
  • In the lineItems table the InStockQuanity is 0, having checked the [InventoryService] table I can see that they have plenty of stock in the PurchaseAvaliabityQunaity columnLineItem.InStockQuantity is one of the fields that step 7 above checks against. This shouldn't be 0 and should be set when inventory is assigned.
  • In the lineitem table IsInventoryAllocated and InventoryStatus are both 0Is InventoryAllocate should be set to 1 once the inventory has been assigned properly.

So yeah, there seems to be an issue assigning inventory.

Given the things that can disable the button that I listed above, the thing that most likely is stopping you from releasing is the Shipment status being NULL.

EDIT: Ah, you already found the issue. Good thing that it got resolved! :)

#194215
Edited, Jun 15, 2018 18:13
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.