diff --git a/src/CommitmentsV2/SFA.DAS.CommitmentsV2.ExternalHandlers/EventHandlers/LearningWithdrawnEventHandler.cs b/src/CommitmentsV2/SFA.DAS.CommitmentsV2.ExternalHandlers/EventHandlers/LearningWithdrawnEventHandler.cs index 51f393391..91715b494 100644 --- a/src/CommitmentsV2/SFA.DAS.CommitmentsV2.ExternalHandlers/EventHandlers/LearningWithdrawnEventHandler.cs +++ b/src/CommitmentsV2/SFA.DAS.CommitmentsV2.ExternalHandlers/EventHandlers/LearningWithdrawnEventHandler.cs @@ -2,13 +2,11 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -using Microsoft.Azure.ServiceBus; using Microsoft.Extensions.Logging; using NServiceBus; using SFA.DAS.CommitmentsV2.Configuration; using SFA.DAS.CommitmentsV2.Data; using SFA.DAS.CommitmentsV2.Data.Extensions; -using SFA.DAS.CommitmentsV2.Domain; using SFA.DAS.CommitmentsV2.Domain.Exceptions; using SFA.DAS.CommitmentsV2.Domain.Extensions; using SFA.DAS.CommitmentsV2.Domain.Interfaces; @@ -32,7 +30,7 @@ public class LearningWithdrawnEventHandler( IWithDrawalNotificationToEmployerService service) : IHandleMessages { -public async Task Handle(LearningWithdrawnEvent message, IMessageHandlerContext context) + public async Task Handle(LearningWithdrawnEvent message, IMessageHandlerContext context) { try { @@ -41,11 +39,10 @@ public async Task Handle(LearningWithdrawnEvent message, IMessageHandlerContext logger.LogInformation("LearnerWithdrawals feature is not active. Ignoring LearningWithdrawnEvent for ApprenticeshipId {ApprenticeshipId}", message.ApprenticeshipId); return; } - logger.LogInformation("LearningWithdrawnEvent for ApprenticeshipId {ApprenticeshipId} with WithdrawalDate {WithdrawalDate} and WithdrawalReasonCode {WithdrawalReasonCode}", - message.ApprenticeshipId, message.WithdrawalDate, message.WithdrawalReasonCode); + logger.LogInformation("LearningWithdrawnEvent for ApprenticeshipId {ApprenticeshipId} with WithdrawalDate {WithdrawalDate}", message.ApprenticeshipId, message.WithdrawalDate); var db = dbContext.Value; var apprentice = await db.GetApprenticeshipAggregate(message.ApprenticeshipId, default); - + var withdrawalDate = new DateTime(message.WithdrawalDate.Year, message.WithdrawalDate.Month, 1); if (message.WithdrawalReasonCode < 0) { @@ -66,7 +63,7 @@ public async Task Handle(LearningWithdrawnEvent message, IMessageHandlerContext ChangeType = LearningChangeType.AutoApproved, LearningKey = message.LearningKey, AppliedDate = message.Created, - Description = BuildWithdrawalReasonDesciption(message.WithdrawalReasonCode) + Description = BuildWithdrawalReasonDescription() }; await context.Send(historyCommand); } @@ -77,13 +74,9 @@ public async Task Handle(LearningWithdrawnEvent message, IMessageHandlerContext } } - private static string BuildWithdrawalReasonDesciption(short withdrawalReasonCode) + private string BuildWithdrawalReasonDescription() { - if (Constants.IlrWithdrawalReasons.TryGetValue(withdrawalReasonCode, out var description)) - { - return $"ILR Learner status changed from Live to Withdrawn due to {withdrawalReasonCode} - '{description}'"; - } - return $"ILR Learner status changed from Live to Withdrawn due to {withdrawalReasonCode} - 'Unknown Reason Code'"; + return "ILR Learner status changed from Live to Stopped"; } private void ValidateStopDateForWithdrawal(DateTime stopDate, Apprenticeship apprenticeship) @@ -114,7 +107,7 @@ private void ValidateStopDateForWithdrawal(DateTime stopDate, Apprenticeship app } } - if(stopDate.Day != 1) + if (stopDate.Day != 1) { throw new DomainException(nameof(stopDate), "Invalid Stop Date. Stop date must be the 1st of the month."); } diff --git a/src/CommitmentsV2/SFA.DAS.CommitmentsV2.ExternalMessageHandlers.UnitTests/EventHandlers/LearningWithdrawnEventHandlerTests.cs b/src/CommitmentsV2/SFA.DAS.CommitmentsV2.ExternalMessageHandlers.UnitTests/EventHandlers/LearningWithdrawnEventHandlerTests.cs index 7e2449792..b33e18e4a 100644 --- a/src/CommitmentsV2/SFA.DAS.CommitmentsV2.ExternalMessageHandlers.UnitTests/EventHandlers/LearningWithdrawnEventHandlerTests.cs +++ b/src/CommitmentsV2/SFA.DAS.CommitmentsV2.ExternalMessageHandlers.UnitTests/EventHandlers/LearningWithdrawnEventHandlerTests.cs @@ -90,22 +90,22 @@ public async Task When_LearnerWithDrawnEvent_AppliedToExistingApprenticeshipWith apprentice.MadeRedundant.Should().BeFalse(); } - [TestCase(29, "Learner has been made redundant")] - [TestCase(2, "Learner has transferred to another provider")] - [TestCase(46, "Exclusion")] - [TestCase(97, "Other")] - [TestCase(98, "Reason not known")] - [TestCase(99, "Unknown Reason Code")] - [TestCase(100, "Unknown Reason Code")] - [TestCase(0, "Unknown Reason Code")] - public async Task When_LearnerWithDrawnEvent_AppliedToExistingApprenticeship_StoreLearnerHistoryCommand_IsPublished(short code, string description) + [TestCase(29)] + [TestCase(2)] + [TestCase(46)] + [TestCase(97)] + [TestCase(98)] + [TestCase(99)] + [TestCase(100)] + [TestCase(0)] + public async Task When_LearnerWithDrawnEvent_AppliedToExistingApprenticeship_StoreLearnerHistoryCommand_IsPublished(short code) { var apprentice = await _fixture.SetupApprenticeship(PaymentStatus.Active); var stopDate = DateTime.Today.AddMonths(-1); _fixture.SetEventValues(apprentice.Id, new DateTime(stopDate.Year, stopDate.Month, 1), code); await _fixture.Handle(); - _fixture.VerifyStoreLearnerHistoryCommandIsSent($"ILR Learner status changed from Live to Withdrawn due to {code} - '{description}'"); + _fixture.VerifyStoreLearnerHistoryCommandIsSent("ILR Learner status changed from Live to Stopped"); } [Test] diff --git a/src/CommitmentsV2/SFA.DAS.CommitmentsV2/Domain/Constants.cs b/src/CommitmentsV2/SFA.DAS.CommitmentsV2/Domain/Constants.cs index 1a6e5f8d6..ba2e8337a 100644 --- a/src/CommitmentsV2/SFA.DAS.CommitmentsV2/Domain/Constants.cs +++ b/src/CommitmentsV2/SFA.DAS.CommitmentsV2/Domain/Constants.cs @@ -26,23 +26,4 @@ public static class FieldLengths public const int ProviderReference = 50; public const int Uln = 50; } - - public static readonly Dictionary IlrWithdrawalReasons = new Dictionary - { - { 2, "Learner has transferred to another provider" }, - { 3, "Learner injury / illness" }, - { 7, "Learner has transferred between providers due to intervention by or with the written agreement of the ESFA" }, - { 29, "Learner has been made redundant" }, - { 40, "Learner has transferred to a new learning aim with the same provider" }, - { 41, "Learner has transferred to another provider to undertake learning that meets a specific government strategy" }, - { 42, "Academic failure / left in bad standing / not permitted to progress – HE learning aims only" }, - { 43, "Financial reasons" }, - { 44, "Other personal reasons" }, - { 45, "Written off after lapse of time – HE learning aims only" }, - { 46, "Exclusion" }, - { 47, "Learner has transferred to another provider due to merger" }, - { 48, "Industry placement learner has withdrawn due to circumstances outside the providers' control" }, - { 97, "Other" }, - { 98, "Reason not known" } - }; } \ No newline at end of file