aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerghei Cebotari <serghei@cebotari.ru>2024-05-25 15:15:17 +0300
committerSerghei Cebotari <serghei@cebotari.ru>2024-05-25 15:15:17 +0300
commitcc32e4792c03d64bc4b2bf7c8e6b07eed5e714ba (patch)
treedc3c0fe47d038540b52be29fcf3ce5052c667daf
parent678bdb47b94293b53f463a785ada781248fd7148 (diff)
Add LX sleeves support
-rw-r--r--RhSolutions.AddIn/Services/SleevesCalculator.cs34
-rw-r--r--RhSolutions.Tests/CanFillSleeves.cs16
-rw-r--r--RhSolutions.Tests/TestWorkbooks/TestSpecificationSleeves.xlsxbin359048 -> 358970 bytes
3 files changed, 38 insertions, 12 deletions
diff --git a/RhSolutions.AddIn/Services/SleevesCalculator.cs b/RhSolutions.AddIn/Services/SleevesCalculator.cs
index 84dcbbb..d892aa6 100644
--- a/RhSolutions.AddIn/Services/SleevesCalculator.cs
+++ b/RhSolutions.AddIn/Services/SleevesCalculator.cs
@@ -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,
@@ -31,7 +35,14 @@ public class SleevesCalculator : IFittingsCalculator
CaptureCollection collection = doubleCollection[0].Groups["Sleeve"].Captures;
foreach (Capture sleeve in collection)
{
- result[sleeve.Value] += kvp.Value * 2;
+ if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40")
+ {
+ result[$"{sleeve.Value}PX"] += kvp.Value * 2;
+ }
+ else
+ {
+ result[sleeve.Value] += kvp.Value * 2;
+ }
}
continue;
}
@@ -41,7 +52,14 @@ public class SleevesCalculator : IFittingsCalculator
CaptureCollection collection = singleCollection[0].Groups["Sleeve"].Captures;
foreach (Capture sleeve in collection)
{
- result[sleeve.Value] += kvp.Value;
+ if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40")
+ {
+ result[$"{sleeve.Value}PX"] += kvp.Value;
+ }
+ else
+ {
+ result[sleeve.Value] += kvp.Value;
+ }
}
}
}
@@ -50,10 +68,14 @@ public class SleevesCalculator : IFittingsCalculator
.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"),
diff --git a/RhSolutions.Tests/CanFillSleeves.cs b/RhSolutions.Tests/CanFillSleeves.cs
index 3b8adfa..2fed50c 100644
--- a/RhSolutions.Tests/CanFillSleeves.cs
+++ b/RhSolutions.Tests/CanFillSleeves.cs
@@ -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()
diff --git a/RhSolutions.Tests/TestWorkbooks/TestSpecificationSleeves.xlsx b/RhSolutions.Tests/TestWorkbooks/TestSpecificationSleeves.xlsx
index 742ceaf..f59a74c 100644
--- a/RhSolutions.Tests/TestWorkbooks/TestSpecificationSleeves.xlsx
+++ b/RhSolutions.Tests/TestWorkbooks/TestSpecificationSleeves.xlsx
Binary files differ