diff --git a/Btms.Business.Tests/Services/Decisions/DecisionServiceTests.cs b/Btms.Business.Tests/Services/Decisions/DecisionServiceTests.cs
new file mode 100644
index 00000000..64332850
--- /dev/null
+++ b/Btms.Business.Tests/Services/Decisions/DecisionServiceTests.cs
@@ -0,0 +1,19 @@
+using Btms.Business.Services.Decisions;
+using Xunit;
+
+namespace Btms.Business.Tests.Services.Decisions;
+
+public class DecisionServiceTests
+{
+ [Fact]
+ public async Task DeriveDecision()
+ {
+ // Arrange
+ var sut = new DecisionService();
+
+ // Act
+
+ // Assert
+ await Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business.Tests/Services/Decisions/Finders/ChedADecisionFinderTests.cs b/Btms.Business.Tests/Services/Decisions/Finders/ChedADecisionFinderTests.cs
new file mode 100644
index 00000000..afba8cc4
--- /dev/null
+++ b/Btms.Business.Tests/Services/Decisions/Finders/ChedADecisionFinderTests.cs
@@ -0,0 +1,19 @@
+using Btms.Business.Services.Decisions.Finders;
+using Xunit;
+
+namespace Btms.Business.Tests.Services.Decisions.Finders;
+
+public class ChedADecisionFinderTests
+{
+ [Fact]
+ public async Task Find_Should_DoThings()
+ {
+ // Arrange
+ var sut = new ChedADecisionFinder();
+
+ // Act
+
+ // Assert
+ await Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business.Tests/Services/Decisions/Finders/ChedDDecisionFinderTests.cs b/Btms.Business.Tests/Services/Decisions/Finders/ChedDDecisionFinderTests.cs
new file mode 100644
index 00000000..323a9f36
--- /dev/null
+++ b/Btms.Business.Tests/Services/Decisions/Finders/ChedDDecisionFinderTests.cs
@@ -0,0 +1,19 @@
+using Btms.Business.Services.Decisions.Finders;
+using Xunit;
+
+namespace Btms.Business.Tests.Services.Decisions.Finders;
+
+public class ChedDDecisionFinderTests
+{
+ [Fact]
+ public async Task Find_Should_DoThings()
+ {
+ // Arrange
+ var sut = new ChedDDecisionFinder();
+
+ // Act
+
+ // Assert
+ await Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business.Tests/Services/Decisions/Finders/ChedPDecisionFinderTests.cs b/Btms.Business.Tests/Services/Decisions/Finders/ChedPDecisionFinderTests.cs
new file mode 100644
index 00000000..e49d7d0e
--- /dev/null
+++ b/Btms.Business.Tests/Services/Decisions/Finders/ChedPDecisionFinderTests.cs
@@ -0,0 +1,19 @@
+using Btms.Business.Services.Decisions.Finders;
+using Xunit;
+
+namespace Btms.Business.Tests.Services.Decisions.Finders;
+
+public class ChedPDecisionFinderTests
+{
+ [Fact]
+ public async Task Find_Should_DoThings()
+ {
+ // Arrange
+ var sut = new ChedPDecisionFinder();
+
+ // Act
+
+ // Assert
+ await Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business.Tests/Services/Decisions/Finders/ChedPPDecisionFinderTests.cs b/Btms.Business.Tests/Services/Decisions/Finders/ChedPPDecisionFinderTests.cs
new file mode 100644
index 00000000..c242a766
--- /dev/null
+++ b/Btms.Business.Tests/Services/Decisions/Finders/ChedPPDecisionFinderTests.cs
@@ -0,0 +1,19 @@
+using Btms.Business.Services.Decisions.Finders;
+using Xunit;
+
+namespace Btms.Business.Tests.Services.Decisions.Finders;
+
+public class ChedPPDecisionFinderTests
+{
+ [Fact]
+ public async Task Find_Should_DoThings()
+ {
+ // Arrange
+ var sut = new ChedPPDecisionFinder();
+
+ // Act
+
+ // Assert
+ await Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business.Tests/Services/LinkingServiceTests.cs b/Btms.Business.Tests/Services/Linking/LinkingServiceTests.cs
similarity index 99%
rename from Btms.Business.Tests/Services/LinkingServiceTests.cs
rename to Btms.Business.Tests/Services/Linking/LinkingServiceTests.cs
index ace93c73..ce8e6653 100644
--- a/Btms.Business.Tests/Services/LinkingServiceTests.cs
+++ b/Btms.Business.Tests/Services/Linking/LinkingServiceTests.cs
@@ -1,6 +1,6 @@
using Btms.Backend.Data;
using Btms.Backend.Data.InMemory;
-using Btms.Business.Services;
+using Btms.Business.Services.Linking;
using Btms.Metrics;
using Btms.Model.Alvs;
using Btms.Model.ChangeLog;
@@ -12,7 +12,7 @@
using Items = Btms.Model.Alvs.Items;
using Movement = Btms.Model.Movement;
-namespace Btms.Business.Tests.Services;
+namespace Btms.Business.Tests.Services.Linking;
public class LinkingServiceTests
{
diff --git a/Btms.Business/Btms.Business.csproj b/Btms.Business/Btms.Business.csproj
index 0057217c..2e59068d 100644
--- a/Btms.Business/Btms.Business.csproj
+++ b/Btms.Business/Btms.Business.csproj
@@ -35,4 +35,8 @@
+
+
+
+
diff --git a/Btms.Business/Extensions/ServiceCollectionExtensions.cs b/Btms.Business/Extensions/ServiceCollectionExtensions.cs
index f68acb7a..095c29e1 100644
--- a/Btms.Business/Extensions/ServiceCollectionExtensions.cs
+++ b/Btms.Business/Extensions/ServiceCollectionExtensions.cs
@@ -2,7 +2,6 @@
using Btms.Business.Pipelines;
using Btms.Business.Pipelines.Matching;
using Btms.Business.Pipelines.Matching.Rules;
-using Btms.Business.Services;
using Btms.Backend.Data.Extensions;
using Btms.BlobService;
using Btms.BlobService.Extensions;
@@ -14,6 +13,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Btms.Business.Pipelines.PreProcessing;
+using Btms.Business.Services.Decisions;
+using Btms.Business.Services.Linking;
using Btms.Types.Alvs;
namespace Btms.Business.Extensions
@@ -61,6 +62,7 @@ public static IServiceCollection AddBusinessServices(this IServiceCollection ser
});
services.AddScoped();
+ services.AddScoped();
services.AddScoped, ImportNotificationPreProcessor>();
services.AddScoped, MovementPreProcessor>();
diff --git a/Btms.Business/Services/Decisions/DecisionCode.cs b/Btms.Business/Services/Decisions/DecisionCode.cs
new file mode 100644
index 00000000..7f916bd5
--- /dev/null
+++ b/Btms.Business/Services/Decisions/DecisionCode.cs
@@ -0,0 +1,15 @@
+namespace Btms.Business.Services.Decisions;
+
+public enum DecisionCode
+{
+ E03,
+ C03,
+ C05,
+ C06,
+ C07,
+ C08,
+ N02,
+ N03,
+ N04,
+ N07
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/DecisionContext.cs b/Btms.Business/Services/Decisions/DecisionContext.cs
new file mode 100644
index 00000000..f4a5d876
--- /dev/null
+++ b/Btms.Business/Services/Decisions/DecisionContext.cs
@@ -0,0 +1,10 @@
+using Btms.Model;
+using Btms.Model.Ipaffs;
+
+namespace Btms.Business.Services.Decisions;
+
+public class DecisionContext
+{
+ public List Notifications { get; set; } = new();
+ public List Movements { get; set; } = new();
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/DecisionResult.cs b/Btms.Business/Services/Decisions/DecisionResult.cs
new file mode 100644
index 00000000..67f02dd6
--- /dev/null
+++ b/Btms.Business/Services/Decisions/DecisionResult.cs
@@ -0,0 +1,3 @@
+namespace Btms.Business.Services.Decisions;
+
+public record DecisionResult(DecisionCode DecisionCode);
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/DecisionService.cs b/Btms.Business/Services/Decisions/DecisionService.cs
new file mode 100644
index 00000000..800441fc
--- /dev/null
+++ b/Btms.Business/Services/Decisions/DecisionService.cs
@@ -0,0 +1,58 @@
+using Btms.Business.Services.Decisions.Finders;
+using Btms.Model.Ipaffs;
+
+namespace Btms.Business.Services.Decisions;
+
+public class DecisionService : IDecisionService
+{
+ public async Task DeriveDecision(DecisionContext decisionContext)
+ {
+ // Validate and prerequisite checks
+
+ var decisions = decisionContext.Notifications.Select(x => (x.Id, GetDecision(x))).ToList();
+
+ foreach (var movement in decisionContext.Movements)
+ {
+ // Generate list matched items -> decisions
+
+ foreach (var item in movement.Items)
+ {
+ // check decisions list for match reference, if no match then drop out with "no-match"
+
+ }
+
+ // Return decision based on prioritisation from confluence
+ }
+
+ await Task.CompletedTask;
+ return new DecisionResult(DecisionCode.N02);
+ }
+
+ private DecisionResult GetDecision(ImportNotification notification)
+ {
+ // get decision finder - fold IUU stuff into the decision finder for fish?
+ IDecisionFinder finder;
+ switch (notification.ImportNotificationType)
+ {
+ case ImportNotificationTypeEnum.Ced:
+ finder = new ChedDDecisionFinder();
+ break;
+
+ case ImportNotificationTypeEnum.Cveda:
+ finder = new ChedADecisionFinder();
+ break;
+
+ case ImportNotificationTypeEnum.Cvedp:
+ finder = new ChedPDecisionFinder();
+ break;
+
+ case ImportNotificationTypeEnum.Chedpp:
+ finder = new ChedPPDecisionFinder();
+ break;
+
+ default: throw new InvalidOperationException("Invalid ImportNotificationType");
+ }
+
+ return finder.FindDecision(notification);
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/Finders/ChedADecisionFinder.cs b/Btms.Business/Services/Decisions/Finders/ChedADecisionFinder.cs
new file mode 100644
index 00000000..b9b2c379
--- /dev/null
+++ b/Btms.Business/Services/Decisions/Finders/ChedADecisionFinder.cs
@@ -0,0 +1,11 @@
+using Btms.Model.Ipaffs;
+
+namespace Btms.Business.Services.Decisions.Finders;
+
+public class ChedADecisionFinder : IDecisionFinder
+{
+ public DecisionResult FindDecision(ImportNotification notification)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/Finders/ChedDDecisionFinder.cs b/Btms.Business/Services/Decisions/Finders/ChedDDecisionFinder.cs
new file mode 100644
index 00000000..3d289f48
--- /dev/null
+++ b/Btms.Business/Services/Decisions/Finders/ChedDDecisionFinder.cs
@@ -0,0 +1,11 @@
+using Btms.Model.Ipaffs;
+
+namespace Btms.Business.Services.Decisions.Finders;
+
+public class ChedDDecisionFinder : IDecisionFinder
+{
+ public DecisionResult FindDecision(ImportNotification notification)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/Finders/ChedPDecisionFinder.cs b/Btms.Business/Services/Decisions/Finders/ChedPDecisionFinder.cs
new file mode 100644
index 00000000..3f6bf36c
--- /dev/null
+++ b/Btms.Business/Services/Decisions/Finders/ChedPDecisionFinder.cs
@@ -0,0 +1,11 @@
+using Btms.Model.Ipaffs;
+
+namespace Btms.Business.Services.Decisions.Finders;
+
+public class ChedPDecisionFinder : IDecisionFinder
+{
+ public DecisionResult FindDecision(ImportNotification notification)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/Finders/ChedPPDecisionFinder.cs b/Btms.Business/Services/Decisions/Finders/ChedPPDecisionFinder.cs
new file mode 100644
index 00000000..c9f4265c
--- /dev/null
+++ b/Btms.Business/Services/Decisions/Finders/ChedPPDecisionFinder.cs
@@ -0,0 +1,11 @@
+using Btms.Model.Ipaffs;
+
+namespace Btms.Business.Services.Decisions.Finders;
+
+public class ChedPPDecisionFinder : IDecisionFinder
+{
+ public DecisionResult FindDecision(ImportNotification notification)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/Finders/IDecisionFinder.cs b/Btms.Business/Services/Decisions/Finders/IDecisionFinder.cs
new file mode 100644
index 00000000..18634895
--- /dev/null
+++ b/Btms.Business/Services/Decisions/Finders/IDecisionFinder.cs
@@ -0,0 +1,8 @@
+using Btms.Model.Ipaffs;
+
+namespace Btms.Business.Services.Decisions.Finders;
+
+public interface IDecisionFinder
+{
+ DecisionResult FindDecision(ImportNotification notification);
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/Decisions/IDecisionService.cs b/Btms.Business/Services/Decisions/IDecisionService.cs
new file mode 100644
index 00000000..c1483ae8
--- /dev/null
+++ b/Btms.Business/Services/Decisions/IDecisionService.cs
@@ -0,0 +1,6 @@
+namespace Btms.Business.Services.Decisions;
+
+public interface IDecisionService
+{
+ public Task DeriveDecision(DecisionContext decisionContext);
+}
\ No newline at end of file
diff --git a/Btms.Business/Services/ILinkingService.cs b/Btms.Business/Services/Linking/ILinkingService.cs
similarity index 76%
rename from Btms.Business/Services/ILinkingService.cs
rename to Btms.Business/Services/Linking/ILinkingService.cs
index b918b926..61482f64 100644
--- a/Btms.Business/Services/ILinkingService.cs
+++ b/Btms.Business/Services/Linking/ILinkingService.cs
@@ -1,5 +1,5 @@
-namespace Btms.Business.Services;
+namespace Btms.Business.Services.Linking;
public interface ILinkingService
{
diff --git a/Btms.Business/Services/ImportNotificationLinkContext.cs b/Btms.Business/Services/Linking/ImportNotificationLinkContext.cs
similarity index 87%
rename from Btms.Business/Services/ImportNotificationLinkContext.cs
rename to Btms.Business/Services/Linking/ImportNotificationLinkContext.cs
index d8b38217..ab482bb5 100644
--- a/Btms.Business/Services/ImportNotificationLinkContext.cs
+++ b/Btms.Business/Services/Linking/ImportNotificationLinkContext.cs
@@ -1,7 +1,7 @@
using Btms.Model.ChangeLog;
using Btms.Model.Ipaffs;
-namespace Btms.Business.Services;
+namespace Btms.Business.Services.Linking;
public record ImportNotificationLinkContext(ImportNotification PersistedImportNotification, ChangeSet? ChangeSet) : LinkContext
{
diff --git a/Btms.Business/Services/LinkContext.cs b/Btms.Business/Services/Linking/LinkContext.cs
similarity index 93%
rename from Btms.Business/Services/LinkContext.cs
rename to Btms.Business/Services/Linking/LinkContext.cs
index 93b5be8e..e996c059 100644
--- a/Btms.Business/Services/LinkContext.cs
+++ b/Btms.Business/Services/Linking/LinkContext.cs
@@ -2,7 +2,7 @@
using Btms.Model.ChangeLog;
using Btms.Model.Ipaffs;
-namespace Btms.Business.Services;
+namespace Btms.Business.Services.Linking;
public abstract record LinkContext
{
diff --git a/Btms.Business/Services/LinkException.cs b/Btms.Business/Services/Linking/LinkException.cs
similarity index 66%
rename from Btms.Business/Services/LinkException.cs
rename to Btms.Business/Services/Linking/LinkException.cs
index c820f124..23c50146 100644
--- a/Btms.Business/Services/LinkException.cs
+++ b/Btms.Business/Services/Linking/LinkException.cs
@@ -1,3 +1,3 @@
-namespace Btms.Business.Services;
+namespace Btms.Business.Services.Linking;
public class LinkException(Exception inner) : Exception("Failed to link", inner);
\ No newline at end of file
diff --git a/Btms.Business/Services/LinkOutcome.cs b/Btms.Business/Services/Linking/LinkOutcome.cs
similarity index 56%
rename from Btms.Business/Services/LinkOutcome.cs
rename to Btms.Business/Services/Linking/LinkOutcome.cs
index 7507e588..d4922b6a 100644
--- a/Btms.Business/Services/LinkOutcome.cs
+++ b/Btms.Business/Services/Linking/LinkOutcome.cs
@@ -1,4 +1,4 @@
-namespace Btms.Business.Services;
+namespace Btms.Business.Services.Linking;
public enum LinkOutcome
{
diff --git a/Btms.Business/Services/LinkResult.cs b/Btms.Business/Services/Linking/LinkResult.cs
similarity index 86%
rename from Btms.Business/Services/LinkResult.cs
rename to Btms.Business/Services/Linking/LinkResult.cs
index acd48fc3..9f6b3ada 100644
--- a/Btms.Business/Services/LinkResult.cs
+++ b/Btms.Business/Services/Linking/LinkResult.cs
@@ -1,7 +1,7 @@
using Btms.Model;
using Btms.Model.Ipaffs;
-namespace Btms.Business.Services;
+namespace Btms.Business.Services.Linking;
public class LinkResult(LinkOutcome state)
{
diff --git a/Btms.Business/Services/LinkingService.cs b/Btms.Business/Services/Linking/LinkingService.cs
similarity index 99%
rename from Btms.Business/Services/LinkingService.cs
rename to Btms.Business/Services/Linking/LinkingService.cs
index 1c7e6714..025bd140 100644
--- a/Btms.Business/Services/LinkingService.cs
+++ b/Btms.Business/Services/Linking/LinkingService.cs
@@ -1,16 +1,14 @@
using System.Text.RegularExpressions;
using Btms.Backend.Data;
using Btms.Backend.Data.Extensions;
-using Btms.Common.Extensions;
using Btms.Metrics;
using Btms.Model;
using Btms.Model.ChangeLog;
using Btms.Model.Ipaffs;
using Btms.Model.Relationships;
-using Json.Patch;
using Microsoft.Extensions.Logging;
-namespace Btms.Business.Services;
+namespace Btms.Business.Services.Linking;
public static partial class LinkingServiceLogging
{
diff --git a/Btms.Business/Services/MovementLinkContext.cs b/Btms.Business/Services/Linking/MovementLinkContext.cs
similarity index 86%
rename from Btms.Business/Services/MovementLinkContext.cs
rename to Btms.Business/Services/Linking/MovementLinkContext.cs
index e55fe312..0826c6d9 100644
--- a/Btms.Business/Services/MovementLinkContext.cs
+++ b/Btms.Business/Services/Linking/MovementLinkContext.cs
@@ -1,7 +1,7 @@
using Btms.Model;
using Btms.Model.ChangeLog;
-namespace Btms.Business.Services;
+namespace Btms.Business.Services.Linking;
public record MovementLinkContext(Movement PersistedMovement, ChangeSet? ChangeSet) : LinkContext
{
diff --git a/Btms.Consumers.Tests/ClearanceRequestConsumerTests.cs b/Btms.Consumers.Tests/ClearanceRequestConsumerTests.cs
index 6320736c..42aaa3ba 100644
--- a/Btms.Consumers.Tests/ClearanceRequestConsumerTests.cs
+++ b/Btms.Consumers.Tests/ClearanceRequestConsumerTests.cs
@@ -1,5 +1,5 @@
using Btms.Business.Pipelines.PreProcessing;
-using Btms.Business.Services;
+using Btms.Business.Services.Linking;
using Btms.Consumers.Extensions;
using Btms.Model;
using Btms.Model.Auditing;
diff --git a/Btms.Consumers.Tests/NotificationsConsumerTests.cs b/Btms.Consumers.Tests/NotificationsConsumerTests.cs
index 2dd44195..37a17b4b 100644
--- a/Btms.Consumers.Tests/NotificationsConsumerTests.cs
+++ b/Btms.Consumers.Tests/NotificationsConsumerTests.cs
@@ -1,6 +1,5 @@
using Btms.Business.Pipelines.PreProcessing;
-using Btms.Business.Services;
-using Btms.Consumers;
+using Btms.Business.Services.Linking;
using Btms.Consumers.Extensions;
using Btms.Model.Auditing;
using Btms.Types.Ipaffs;
diff --git a/Btms.Consumers/AlvsClearanceRequestConsumer.cs b/Btms.Consumers/AlvsClearanceRequestConsumer.cs
index 8a7550e6..b96c2c77 100644
--- a/Btms.Consumers/AlvsClearanceRequestConsumer.cs
+++ b/Btms.Consumers/AlvsClearanceRequestConsumer.cs
@@ -1,9 +1,9 @@
-using Btms.Business.Services;
using Btms.Types.Alvs;
using Microsoft.Extensions.Logging;
using SlimMessageBus;
using Btms.Consumers.Extensions;
using Btms.Business.Pipelines.PreProcessing;
+using Btms.Business.Services.Linking;
namespace Btms.Consumers
{
diff --git a/Btms.Consumers/NotificationConsumer.cs b/Btms.Consumers/NotificationConsumer.cs
index 66c08c2d..72e99c2f 100644
--- a/Btms.Consumers/NotificationConsumer.cs
+++ b/Btms.Consumers/NotificationConsumer.cs
@@ -1,9 +1,9 @@
-using Btms.Business.Services;
using Btms.Types.Ipaffs;
using SlimMessageBus;
using Btms.Consumers.Extensions;
using Microsoft.Extensions.Logging;
using Btms.Business.Pipelines.PreProcessing;
+using Btms.Business.Services.Linking;
namespace Btms.Consumers
{