Skip to content

Commit

Permalink
Som bugfixes to fix the StockUnit logic and handle the concatenation …
Browse files Browse the repository at this point in the history
…of columns.
  • Loading branch information
MatthiasSort committed Nov 27, 2023
1 parent 71932da commit 8a8a78c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.0.12</Version>
<Version>10.0.13</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Ecom Provider</Title>
<Description>Ecom Provider</Description>
Expand Down
12 changes: 7 additions & 5 deletions src/EcomDestinationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ public void Write(Dictionary<string, object> row, Mapping mapping, bool discardD
row[columnMapping.SourceColumn.Name] = stockLocationID;
}

if (mappingColumns.Any(obj => obj.DestinationColumn.Name == columnMapping.DestinationColumn.Name && obj.GetId() != columnMapping.GetId()))
if (mappingColumns.Any(obj => obj.DestinationColumn.Name == columnMapping.DestinationColumn.Name && obj.GetId() < columnMapping.GetId()))
{
dataRow[columnMapping.DestinationColumn.Name] += columnMapping.ConvertInputToOutputFormat(row[columnMapping.SourceColumn.Name]) + "";

Check warning on line 1058 in src/EcomDestinationWriter.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'ColumnMapping.ConvertInputToOutputFormat(object)' is obsolete: 'Use ConvertInputValueToOutputValue instead.'

Check warning on line 1058 in src/EcomDestinationWriter.cs

View workflow job for this annotation

GitHub Actions / call-workflow / Build

'ColumnMapping.ConvertInputToOutputFormat(object)' is obsolete: 'Use ConvertInputValueToOutputValue instead.'
}
Expand Down Expand Up @@ -1124,7 +1124,7 @@ public void Write(Dictionary<string, object> row, Mapping mapping, bool discardD
}
break;
case "EcomStockUnit":
WriteStockUnits(row, columnMappings, dataRow);
WriteStockUnits(row, columnMappings, dataRow, mapping);
break;
}

Expand All @@ -1135,7 +1135,7 @@ public void Write(Dictionary<string, object> row, Mapping mapping, bool discardD
{
object dataToRow = columnMapping.ConvertInputValueToOutputValue(rowValue);

if (mappingColumns.Any(obj => obj.DestinationColumn.Name == columnMapping.DestinationColumn.Name && obj.GetId() != columnMapping.GetId()))
if (mappingColumns.Any(obj => obj.DestinationColumn.Name == columnMapping.DestinationColumn.Name && obj.GetId() < columnMapping.GetId()))
{
dataRow[columnMapping.DestinationColumn.Name] += dataToRow.ToString();
}
Expand Down Expand Up @@ -1860,12 +1860,14 @@ private string HandleGroupId(Dictionary<string, object> row, Dictionary<string,
return groupID;
}

private void WriteStockUnits(Dictionary<string, object> row, Dictionary<string, ColumnMapping> columnMappings, DataRow dataRow)
private void WriteStockUnits(Dictionary<string, object> row, Dictionary<string, ColumnMapping> columnMappings, DataRow dataRow, Mapping mapping)
{
if (!columnMappings.TryGetValue("StockUnitId", out _))
{
{
if (columnMappings.TryGetValue("StockUnitProductID", out var stockUnitProductIDColumn) && columnMappings.TryGetValue("StockUnitVariantID", out var stockUnitVariantIDColumn))
{
mapping.AddMapping(mapping.SourceTable.Columns.FirstOrDefault(), mapping.DestinationTable.Columns.Where(obj => obj.Name.Equals("StockUnitId", StringComparison.OrdinalIgnoreCase)).FirstOrDefault());

var productID = row[stockUnitProductIDColumn.SourceColumn.Name].ToString();
var variantID = row[stockUnitVariantIDColumn.SourceColumn.Name].ToString();
if (productID.Equals(variantID, StringComparison.OrdinalIgnoreCase))
Expand Down

0 comments on commit 8a8a78c

Please sign in to comment.