I faced a similar issue on a version 9.15.10 and solved it by rewriting the discount lines in the orders' request XML to always set the quantity of the discount lines to 1 and set the unit price to the total sum of the discount line.
Please be aware that I have removed chunks of code that I deemed irrelevant from the notification subscriber below, so I am not sure it will build, but I hope it can be of help anyway.
[Subscribe(Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.Order.OnAfterGenerateOrderXml)]
public class OrderAfterGenerateXml : NotificationSubscriber
{
private static readonly Logger _logger = LogManager.GetLogger("OnAfterGenerateOrderXml");
/// <summary>
/// Call to invoke observer.
/// </summary>
/// <param name="notification">The notification.</param>
/// <param name="args">The args.</param>
public override void OnNotify(string notification, NotificationArgs args)
{
var myArgs = (Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.Order.OnAfterGenerateOrderXmlArgs)args;
if (myArgs != null && myArgs.Document != null && myArgs.Order != null)
{
var document = myArgs.Document;
var order = myArgs.Order;
if (order.Complete)
{
XmlNode orderNode = document.SelectSingleNode("//item[@table='EcomOrders']");
// fix discount lines
FixDiscountLines(orderNode, document);
}
}
}
private void FixDiscountLines(XmlNode orderNode, XmlDocument document)
{
var orderLineNodes = orderNode.SelectNodes("//item[@table='EcomOrderLines']");
foreach (XmlNode orderLineNode in orderLineNodes)
{
var orderLineTypeNode = orderLineNode.SelectSingleNode("column[@columnName='OrderLineTypeName']");
var discountTypeNode = orderLineNode.SelectSingleNode("column[@columnName='OrderLineDiscountType']");
if (orderLineTypeNode != null && discountTypeNode != null)
{
if (orderLineTypeNode.InnerText == "ProductDiscount" && discountTypeNode.InnerText == "Amount")
{
var orderLineQuantityNode = orderLineNode.SelectSingleNode("column[@columnName='OrderLineQuantity']");
var orderLinePriceWithoutVatNode = orderLineNode.SelectSingleNode("column[@columnName='OrderLinePriceWithoutVat']");
var orderLineUnitPriceWithoutVatNode = orderLineNode.SelectSingleNode("column[@columnName='OrderLineUnitPriceWithoutVat']");
var orderLineDiscountValueNode = orderLineNode.SelectSingleNode("column[@columnName='OrderLineDiscountValue']");
if (orderLineQuantityNode != null && orderLineQuantityNode.InnerText != "1" && orderLinePriceWithoutVatNode != null && orderLineUnitPriceWithoutVatNode != null)
{
orderLineQuantityNode.InnerText = "1";
orderLineUnitPriceWithoutVatNode.InnerText = orderLinePriceWithoutVatNode.InnerText;
orderLineDiscountValueNode.InnerText = orderLinePriceWithoutVatNode.InnerText.Replace("-", "");
}
}
}
}
}
}