Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.21.8</Version>
<Version>10.21.9</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Live Integration</Title>
<Description>Live Integration</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,24 @@ public static class OrderHandler
/// </summary>
private static readonly string OrderXmlLogFolder = "/Files/System/Log/LiveIntegration/OrderXml";

/// <summary>
/// Prefix used by OrderLine.Id for order lines that were created as part of a multi order line
/// request but have not actually been persisted yet. Lines with this placeholder Id still need
/// to be saved before they can be used as a ParentLineId reference.
/// </summary>
private const string NewMultiOrderLineIdPrefix = "DW_NEWMULTIORDERLINEID_";

private readonly record struct OrderResponseContext(Settings Settings, bool ErpControlsDiscountForUser);

/// <summary>
/// Determines whether an order line has not actually been persisted yet, including lines whose
/// Id was pre-assigned a temporary multi order line placeholder before saving.
/// </summary>
private static bool IsUnsavedOrderLine(OrderLine orderLine)
{
return string.IsNullOrEmpty(orderLine.Id) || orderLine.Id.StartsWith(NewMultiOrderLineIdPrefix, StringComparison.OrdinalIgnoreCase);
}

/// <summary>
/// Gets the cache level for order information.
/// </summary>
Expand Down Expand Up @@ -533,7 +549,7 @@ private static void ProcessDiscountOrderLine(in OrderResponseContext ctx, Order
}

parentLine = parentLineWithVariant ?? parentLine;
if (parentLine != null && string.IsNullOrEmpty(parentLine.Id))
if (parentLine != null && IsUnsavedOrderLine(parentLine))
{
Services.OrderLines.Save(parentLine);
orderLineIds.Add(parentLine.Id);
Expand Down Expand Up @@ -723,7 +739,7 @@ private static void ProcessTaxOrderLine(Settings settings, Order order, XmlNode
}

parentLine = parentLineWithVariant ?? parentLine;
if (parentLine != null && string.IsNullOrEmpty(parentLine.Id))
if (parentLine != null && IsUnsavedOrderLine(parentLine))
{
Services.OrderLines.Save(parentLine);
orderLineIds.Add(parentLine.Id);
Expand Down
Loading