Vulnerability in EPiServer.Forms
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);
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);
public Dictionary> RequestInventory(IPurchaseOrder order)
var validationIssues = new Dictionary>();
order.AdjustInventoryOrRemoveLineItems((item, issue) => validationIssues.AddValidationIssues(item, issue), _inventoryProcessor);
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.
Was the order fully paid?
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);
// 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
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.
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
Do you call IOrderGroup.ProcessPayments() somewhere?
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:
SavePaymentDetails(order, transaction, command.BillingAddress);
orderReference = _orderRepository.Save(order);
Where SavePaymentDetails is the above pasted method where set the status etc.
I have also tried
In case there was something wring with our payment gateway but still no difference.
Alright, maybe it's not the payments. :)
Either way here's the things that I know of that sets the button as disabled:
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
FROM [dbo].[OrderForm] oform
JOIN OrderFormEx ofex ON oform.OrderFormId = ofex.ObjectId
WHERE oform.OrderGroupId = @OrderGroupId
FROM [dbo].Shipment sh
JOIN ShipmentEx shex ON sh.ShipmentId = shex.ObjectId
WHERE sh.OrderGroupId = @OrderGroupId
FROM [dbo].LineItem l
JOIN LineItemEx lex ON l.LineItemId = lex.ObjectId
WHERE OrderGroupId = @OrderGroupId
ORDER BY LineItemOrdering ASC
FROM OrderGroupAddress oga
JOIN OrderGroupAddressEx ogae ON oga.OrderGroupAddressId = ogae.ObjectId
WHERE oga.OrderGroupId = @OrderGroupId
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
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!
Thanks, this is helpful. I have run the query and this is what I found, I'm not sure how relvent.
Apart from that they all look ok
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?
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! :)