We are using the code below to create a return for an order with discount. I am not sure what to expect in this case, but the result is strange. It seems that the discount is not recalculated and that gives strange values for the returnlineitem. After executing the code below the ReturnLineItem in ReturnsForms will still have the same value for OrderLevelDiscountAmount. I expected this to be lowered when one item was removed. I tried using ApplyDiscounts (with ReevaluatePromotions = true), but that makes no difference. The documentation I found for this is not very clear. Can someone point me to a working example for this scenario? And what should I expect as ExtendedPrice for a ReturnLineItem using IReturnLineItemCalculator?
var purchaseOrderFactory = ServiceLocator.Current.GetInstance<IPurchaseOrderFactory>();
var returnOrderForm = purchaseOrderFactory.CreateReturnOrderForm(order);
order.ReturnForms.Add(returnOrderForm);
var shipment = order.GetFirstShipment();
var returnShipment = purchaseOrderFactory.CreateReturnShipment(shipment);
returnOrderForm.Shipments.Add(returnShipment);
// originalLineItem.Quantity = 3 and discount = 10%
var returnLineItem = _purchaseOrderFactory.CreateReturnLineItem(originalLineItem, 1,
"Some reason");
returnShipment.LineItems.Add(returnLineItem);
_returnOrderService.CompleteReturn(order, returnForm);
...
_orderRepository.Save(order);
The calculations made by DefaultReturnLineItemCalculator doesn't make sense as far as I can se. At least not for my case. I ended up implementing my own version instead.
Hi,
We are using the code below to create a return for an order with discount. I am not sure what to expect in this case, but the result is strange. It seems that the discount is not recalculated and that gives strange values for the returnlineitem. After executing the code below the ReturnLineItem in ReturnsForms will still have the same value for OrderLevelDiscountAmount. I expected this to be lowered when one item was removed. I tried using ApplyDiscounts (with ReevaluatePromotions = true), but that makes no difference. The documentation I found for this is not very clear. Can someone point me to a working example for this scenario? And what should I expect as ExtendedPrice for a ReturnLineItem using IReturnLineItemCalculator?
Episerver Commerce 13.32.1, CMS 11.20.11