diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/ISettings.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/ISettings.cs index 7636cda..1984588 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/ISettings.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/ISettings.cs @@ -229,6 +229,12 @@ public interface ISettings /// The website identifier. int AreaId { get; set; } + /// + /// Gets or sets LCY Currency + /// + /// The LCY currency identifier. + string LcyCurrency { get; set; } + /// /// Gets or sets the text for product discounts. /// diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/Settings.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/Settings.cs index 47253fd..246b813 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/Settings.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Configuration/Settings.cs @@ -48,7 +48,7 @@ public Settings() CalculateOrderUsingProductNumber = true; AutoPingInterval = Constants.DefaultPingInterval; ConnectionTimeout = Constants.DefaultConnectionTimeout; - CartCommunicationType = Constants.CartCommunicationType.Full; + CartCommunicationType = Constants.CartCommunicationType.Full; } /// @@ -118,6 +118,12 @@ public string InstanceName /// The website identifier. public int AreaId { get; set; } + /// + /// Gets or sets LCY Currency + /// + /// The LCY currency identifier. + public string LcyCurrency { get; set; } + /// /// Global tag for connection availability /// @@ -432,6 +438,7 @@ public static void UpdateFrom(ISettings source, ISettings target) target.Endpoint = source.Endpoint; target.ShopId = source.ShopId; target.AreaId = source.AreaId; + target.LcyCurrency = source.LcyCurrency; target.SecurityKey = source.SecurityKey; target.ConnectionTimeout = source.ConnectionTimeout; target.AutoPingInterval = source.AutoPingInterval < Constants.MinPingInterval ? Constants.MinPingInterval : source.AutoPingInterval; @@ -494,8 +501,8 @@ public static void UpdateFrom(ISettings source, ISettings target) } target.InstanceId = source.InstanceId; target.InstanceLabel = source.InstanceLabel; - target.SettingsFile = source.SettingsFile; - if(source is Settings sourceSettings) + target.SettingsFile = source.SettingsFile; + if (source is Settings sourceSettings) { sourceSettings._notificationRecipients = null; } @@ -526,12 +533,12 @@ internal List NotificationRecipients } private List GetNotificationRecipients() - { + { var recipients = new List(); if (!string.IsNullOrEmpty(NotificationEmail) && StringHelper.IsValidEmailAddress(NotificationEmail)) recipients.Add(NotificationEmail); if (!string.IsNullOrEmpty(RecipientGroups)) - { + { recipients.AddRange(GetRecipients(RecipientGroups.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(id => Converter.ToInt32(id)))); } return recipients.Distinct().ToList(); @@ -570,6 +577,6 @@ private static List GetRecipients(IEnumerable groupIds) result.Add(user.Email); } return result; - } + } } } \ No newline at end of file diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj index b4b15fe..b272422 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj @@ -1,6 +1,6 @@  - 10.4.32 + 10.4.33 1.0.0.0 Live Integration Live Integration diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs index d777a1c..900c43e 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/LiveIntegrationAddIn.cs @@ -155,6 +155,16 @@ public LiveIntegrationAddIn() [AddInParameterOrder(43)] public int AreaId { get; set; } + /// + /// Gets or sets LCY Currency + /// + /// The LCY currency identifier. + [AddInParameter("ERP Local Currency")] + [AddInParameterEditor(typeof(DropDownParameterEditor), "none=true;explanation=When DynamicWeb currency is selected the integration will send an empty string for the Currency Code in the Live Integration requests, allowing ERP apply its default local currency behavior automatically")] + [AddInParameterGroup("General")] + [AddInParameterOrder(45)] + public string LcyCurrency { get; set; } + /// /// Number format culture /// @@ -734,6 +744,12 @@ IEnumerable IParameterOptions.GetParameterOptions(string dropdo options.Add(new(nameof(ConnectionType.Endpoint), ConnectionType.Endpoint)); options.Add(new("Dynamicweb connector web service", ConnectionType.WebService)); break; + case "ERP Local Currency": + foreach (var currency in Services.Currencies.GetAllCurrencies()) + { + options.Add(new($"{currency.GetName(Services.Languages.GetDefaultLanguageId())} - {currency.Code}", currency.Code)); + } + break; default: throw new ArgumentException($"Unsupported dropdown: {dropdownName}", nameof(dropdownName)); } diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/XmlGenerators/OrderXmlGenerator.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/XmlGenerators/OrderXmlGenerator.cs index 52f76f5..83e36eb 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/XmlGenerators/OrderXmlGenerator.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/XmlGenerators/OrderXmlGenerator.cs @@ -5,6 +5,7 @@ using Dynamicweb.Ecommerce.Orders; using Dynamicweb.Extensibility.Notifications; using Dynamicweb.Security.UserManagement; +using System; using System.Linq; using System.Xml; @@ -201,6 +202,11 @@ private XmlNode BuildOrderXml(Settings currentSettings, XmlDocument xmlDocument, var tableNode = CreateTableNode(xmlDocument, "EcomOrders"); var itemNode = CreateAndAppendItemNode(tableNode, "EcomOrders"); var user = UserManagementServices.Users.GetUserById(order.CustomerAccessUserId); + var currencyCode = order.CurrencyCode; + if (string.Equals(currentSettings.LcyCurrency, currencyCode, StringComparison.OrdinalIgnoreCase)) + { + currencyCode = ""; + } AddCustomerInformation(currentSettings, itemNode, order, user); AddOrderDeliveryInformation(settings, itemNode, order, user); @@ -210,7 +216,7 @@ private XmlNode BuildOrderXml(Settings currentSettings, XmlDocument xmlDocument, AddChildXmlNode(itemNode, "OrderId", order.Id); AddChildXmlNode(itemNode, "OrderAutoId", order.AutoId.ToString()); AddChildXmlNode(itemNode, "OrderIntegrationOrderId", order.IntegrationOrderId); - AddChildXmlNode(itemNode, "OrderCurrencyCode", order.CurrencyCode); + AddChildXmlNode(itemNode, "OrderCurrencyCode", currencyCode); AddChildXmlNode(itemNode, "OrderDate", order.Date.ToIntegrationString()); if (!settings.GenerateXmlForHash) { diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/XmlGenerators/ProductInfoXmlGenerator.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/XmlGenerators/ProductInfoXmlGenerator.cs index 65da720..86ae5b8 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/XmlGenerators/ProductInfoXmlGenerator.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/XmlGenerators/ProductInfoXmlGenerator.cs @@ -70,6 +70,10 @@ private XmlNode BuildProductInfoXml(Settings currentSettings, XmlDocument xmlDoc } var currencyCode = settings.Context?.Currency?.Code; + if(string.Equals(currentSettings.LcyCurrency, currencyCode, StringComparison.OrdinalIgnoreCase)) + { + currencyCode = ""; + } var tableNode = xmlDocument.CreateElement("Products"); tableNode.SetAttribute("type", "filter");