Add LX sleeves support

This commit is contained in:
Serghei Cebotari 2024-05-25 15:15:17 +03:00
parent 678bdb47b9
commit cc32e4792c
3 changed files with 38 additions and 12 deletions

View File

@ -17,6 +17,10 @@ public class SleevesCalculator : IFittingsCalculator
["20"] = 0,
["25"] = 0,
["32"] = 0,
["16PX"] = 0,
["20PX"] = 0,
["25PX"] = 0,
["32PX"] = 0,
["40"] = 0,
["50"] = 0,
["63"] = 0,
@ -30,9 +34,16 @@ public class SleevesCalculator : IFittingsCalculator
{
CaptureCollection collection = doubleCollection[0].Groups["Sleeve"].Captures;
foreach (Capture sleeve in collection)
{
if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40")
{
result[$"{sleeve.Value}PX"] += kvp.Value * 2;
}
else
{
result[sleeve.Value] += kvp.Value * 2;
}
}
continue;
}
var singleCollection = Regex.Matches(kvp.Key.Name, singlePattern);
@ -40,20 +51,31 @@ public class SleevesCalculator : IFittingsCalculator
{
CaptureCollection collection = singleCollection[0].Groups["Sleeve"].Captures;
foreach (Capture sleeve in collection)
{
if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40")
{
result[$"{sleeve.Value}PX"] += kvp.Value;
}
else
{
result[sleeve.Value] += kvp.Value;
}
}
}
}
return result
.ToDictionary(kvp =>
kvp.Key switch
{
"16" => new Product("11600011001"),
"20" => new Product("11600021001"),
"25" => new Product("11600031001"),
"32" => new Product("11600041001"),
"16" => new Product("11080011001"),
"20" => new Product("11080021001"),
"25" => new Product("11080031001"),
"32" => new Product("11080041001"),
"16PX" => new Product("11600011001"),
"20PX" => new Product("11600021001"),
"25PX" => new Product("11600031001"),
"32PX" => new Product("11600041001"),
"40" => new Product("11600051001"),
"50" => new Product("11397711002"),
"63" => new Product("11397811002"),

View File

@ -29,13 +29,17 @@ public class CanFillSleeves : IDisposable
var sleeves = _calculator.Calculate(products.First().Item2);
_writer.WriteProducts(sleeves);
Assert.Equal(25, _worksheet.Range["E2"].Value);
Assert.Equal(15, _worksheet.Range["E3"].Value);
Assert.Equal(7, _worksheet.Range["E4"].Value);
Assert.Equal(8, _worksheet.Range["E5"].Value);
Assert.Equal(1, _worksheet.Range["E6"].Value);
Assert.Equal(22, _worksheet.Range["E2"].Value);
Assert.Equal(12, _worksheet.Range["E3"].Value);
Assert.Equal(5, _worksheet.Range["E4"].Value);
Assert.Equal(6, _worksheet.Range["E5"].Value);
Assert.Equal(3, _worksheet.Range["E6"].Value);
Assert.Equal(3, _worksheet.Range["E7"].Value);
Assert.Equal(4, _worksheet.Range["E8"].Value);
Assert.Equal(2, _worksheet.Range["E8"].Value);
Assert.Equal(2, _worksheet.Range["E9"].Value);
Assert.Equal(1, _worksheet.Range["E10"].Value);
Assert.Equal(3, _worksheet.Range["E11"].Value);
Assert.Equal(4, _worksheet.Range["E12"].Value);
}
public void Dispose()