diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.UnitTests/Infrastructure/OuterApi/OuterApiServiceTest.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.UnitTests/Infrastructure/OuterApi/OuterApiServiceTest.cs index 73c702ce3..eff2da471 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.UnitTests/Infrastructure/OuterApi/OuterApiServiceTest.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.UnitTests/Infrastructure/OuterApi/OuterApiServiceTest.cs @@ -4,6 +4,7 @@ using Moq; using NUnit.Framework; using SFA.DAS.ProviderCommitments.Infrastructure.OuterApi; +using SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Requests.Apprentices; using SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Requests.Authorization; using SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Requests.DraftApprenticeships; using SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Requests.Provider; @@ -123,4 +124,26 @@ public async Task Then_SyncLearnerData_Request_Is_Made_And_Response_Returned( actual.Success.Should().Be(apiResponse.Success); actual.Message.Should().Be(apiResponse.Message); } + + [Test, MoqAutoData] + public async Task Then_The_Request_Is_Made_And_GetApprenticeshipResponse_Returned( + long apprenticeshipId, + long provideId, + GetApprenticeshipResponse apiResponse, + [Frozen] Mock apiClient, + OuterApiService service) + { + //Arrange + var request = new GetApprenticeshipRequest(apprenticeshipId,provideId); + apiClient.Setup(x => + x.Get( + It.Is(c => c.GetUrl.Equals(request.GetUrl)))) + .ReturnsAsync(apiResponse); + + //Act + var actual = await service.GetApprenticeship(apprenticeshipId,provideId); + + //Assert + actual.Should().Be(apiResponse); + } } \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/OverlappingTrainingDateRequestControllerTestFixture.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/OverlappingTrainingDateRequestControllerTestFixture.cs index 14c4ae89a..291e10497 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/OverlappingTrainingDateRequestControllerTestFixture.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/OverlappingTrainingDateRequestControllerTestFixture.cs @@ -8,11 +8,14 @@ using SFA.DAS.CommitmentsV2.Types; using SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Requests.DraftApprenticeship; using SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Requests.OverlappingTrainingDateRequest; +using SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Responses; using SFA.DAS.ProviderCommitments.Interfaces; using SFA.DAS.ProviderCommitments.Web.Authentication; using SFA.DAS.ProviderCommitments.Web.Controllers; +using SFA.DAS.ProviderCommitments.Web.Extensions; using SFA.DAS.ProviderCommitments.Web.Models; using SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate; +using SFA.DAS.ProviderCommitments.Web.Services.Cache; using SFA.DAS.ProviderUrlHelper; using CreateCohortRequest = SFA.DAS.ProviderCommitments.Application.Commands.CreateCohort.CreateCohortRequest; using CreateCohortResponse = SFA.DAS.ProviderCommitments.Application.Commands.CreateCohort.CreateCohortResponse; @@ -33,8 +36,8 @@ public class OverlappingTrainingDateRequestControllerTestFixture private readonly Mock _outerApiService; private readonly DraftApprenticeshipOverlapOptionRequest _draftApprenticeshipOverlapOptionRequest; private readonly OverlapOptionsForChangeEmployerRequest _overlapOptionsForChangeEmployerRequest; - private GetApprenticeshipResponse _apprenticeshipDetails; - + private CommitmentsV2.Api.Types.Responses.GetApprenticeshipResponse _apprenticeshipDetails; + private readonly DraftApprenticeshipOverlapOptionWithPendingRequest _overlapRequest; private readonly DraftApprenticeshipOverlapOptionWithPendingRequestViewModel _overlapViewModel; @@ -47,26 +50,41 @@ public class OverlappingTrainingDateRequestControllerTestFixture private readonly DraftApprenticeshipOverlapAlertRequest _draftApprenticeshipOverlapAlertRequest; private readonly UpdateDraftApprenticeshipApimRequest _updateDraftApprenticeshipRequest; + private readonly Mock _cacheStorageService; + + private readonly Infrastructure.OuterApi.Responses.GetApprenticeshipResponse _getApprenticeshipResponse; + + private readonly ChangeEmployerCacheItem _changeEmployerCacheItem; + + private readonly ValidateUlnOverlapOnStartDateQueryResult _validateUlnOverlapOnStartDateQueryResult; + public OverlappingTrainingDateRequestControllerTestFixture() { _autoFixture = new Fixture(); _mockModelMapper = new Mock(); - + var linkGenerator = new Mock(); + var providerId = _autoFixture.Create(); + var apprenticeShipId = _autoFixture.Create(); + _changeEmployerCacheItem = new ChangeEmployerCacheItem(Guid.NewGuid()) + { StartDate = "052026", EndDate = "052027", Uln = "123456" }; + _draftApprenticeshipOverlapAlertRequest = _autoFixture.Create(); _updateDraftApprenticeshipRequest = _autoFixture.Create(); + _getApprenticeshipResponse = _autoFixture.Create(); + _cacheStorageService = new Mock(); _model = new DraftApprenticeshipViewModel { - ProviderId = _autoFixture.Create(), + ProviderId = providerId, EmployerAccountLegalEntityPublicHashedId = _autoFixture.Create(), AccountLegalEntityId = _autoFixture.Create(), ReservationId = _autoFixture.Create() }; - _draftApprenticeshipOverlapOptionRequest = new DraftApprenticeshipOverlapOptionRequest() { DraftApprenticeshipHashedId = "XXXXX", ApprenticeshipId = 1 }; - _overlapOptionsForChangeEmployerRequest = new OverlapOptionsForChangeEmployerRequest { ProviderId = 2, ApprenticeshipId = 1, CacheKey = Guid.NewGuid() }; + _draftApprenticeshipOverlapOptionRequest = new DraftApprenticeshipOverlapOptionRequest() { DraftApprenticeshipHashedId = "XXXXX", ApprenticeshipId = apprenticeShipId, ProviderId = providerId }; + _overlapOptionsForChangeEmployerRequest = new OverlapOptionsForChangeEmployerRequest { ProviderId = providerId, ApprenticeshipId = apprenticeShipId, CacheKey = Guid.NewGuid() }; _tempData = new Mock(); @@ -104,22 +122,28 @@ public OverlappingTrainingDateRequestControllerTestFixture() .Returns(_linkGeneratorRedirectUrl) .Callback((string value) => _ = value); - _outerApiService = new Mock(); var commitmentsApiClient = new Mock(); var validateUlnOverlapResult = new ValidateUlnOverlapResult(); + _validateUlnOverlapOnStartDateQueryResult = new ValidateUlnOverlapOnStartDateQueryResult() { HasOverlapWithIlrWithdrawnApprenticeship = true, HasOverlapWithApprenticeshipId = _overlapOptionsForChangeEmployerRequest.ApprenticeshipId }; commitmentsApiClient.Setup(x => x.ValidateUlnOverlap(It.IsAny(), It.IsAny())).ReturnsAsync(() => validateUlnOverlapResult); + _outerApiService.Setup(x => x.ValidateUlnOverlapOnStartDate(It.Is(t => t == _overlapOptionsForChangeEmployerRequest.ProviderId), + It.Is(t => t == _changeEmployerCacheItem.Uln), It.Is(t => t == DateTimeExtensions.FormatMonthYearDateToDateFormat(_changeEmployerCacheItem.StartDate)), + It.Is(t => t == DateTimeExtensions.FormatMonthYearDateToDateFormat(_changeEmployerCacheItem.EndDate)))) + .ReturnsAsync(() => _validateUlnOverlapOnStartDateQueryResult); _mockModelMapper.Setup(x => x.Map(It.IsAny())).ReturnsAsync(() => new CreateOverlappingTrainingDateApimRequest()); _mockModelMapper.Setup(x => x.Map(It.IsAny())).ReturnsAsync(() => new CreateCohortRequest()); _mockModelMapper.Setup(x => x.Map(It.IsAny())).ReturnsAsync(() => new DraftApprenticeshipOverlapOptionViewModel()); - _apprenticeshipDetails = new GetApprenticeshipResponse() + _apprenticeshipDetails = new CommitmentsV2.Api.Types.Responses.GetApprenticeshipResponse() { Id = 1, Status = ApprenticeshipStatus.Live }; - commitmentsApiClient.Setup(x => x.GetApprenticeship(It.IsAny(), It.IsAny())).ReturnsAsync(() => _apprenticeshipDetails); + + _outerApiService.Setup(x => x.GetApprenticeship(It.Is(t => t == _draftApprenticeshipOverlapOptionRequest.ApprenticeshipId.Value), + It.Is(t => t == _draftApprenticeshipOverlapOptionRequest.ProviderId))).ReturnsAsync(_getApprenticeshipResponse); _overlapRequest = _autoFixture.Create(); _overlapViewModel = _autoFixture.Create(); @@ -130,20 +154,24 @@ public OverlappingTrainingDateRequestControllerTestFixture() _changeOfEmployerNotifiedRequest = _autoFixture.Create(); _changeOfEmployerNotifiedViewModel = _autoFixture.Create(); + _cacheStorageService.Setup(x => x.RetrieveFromCache(It.IsAny())). + ReturnsAsync(_changeEmployerCacheItem); + _controller = new OverlappingTrainingDateRequestController( mediator.Object, _mockModelMapper.Object, linkGenerator.Object, commitmentsApiClient.Object, Mock.Of(), - _outerApiService.Object + _outerApiService.Object, + _cacheStorageService.Object ); _controller.TempData = _tempData.Object; } public OverlappingTrainingDateRequestControllerTestFixture SetApprenticeshipStatus(ApprenticeshipStatus status) { - _apprenticeshipDetails.Status = status; + _getApprenticeshipResponse.Status = (short)status; return this; } @@ -186,6 +214,15 @@ public OverlappingTrainingDateRequestControllerTestFixture VerifyOverlapOptionsF return this; } + public OverlappingTrainingDateRequestControllerTestFixture VerifyOverlapOptionsForChangeEmployerViewModelViewReturnedWithNoWithdrawnReasonCode() + { + var viewResult = _actionResult as ViewResult; + viewResult.Should().NotBeNull(); + var model = viewResult.Model as OverlapOptionsForChangeEmployerViewModel; + model.HasWithdrawnStatusCode.Should().BeFalse(); + return this; + } + public async Task DraftApprenticeshipOverlapOptions() { _actionResult = await _controller.DraftApprenticeshipOverlapOptions(_draftApprenticeshipOverlapOptionViewModel); @@ -228,7 +265,7 @@ public OverlappingTrainingDateRequestControllerTestFixture SetupUpdateDraftAppre { _mockModelMapper.Setup(m => m.Map(It.Is(x => x.Uln == _model.Uln))).ReturnsAsync(_updateDraftApprenticeshipRequest); return this; - } + } public OverlappingTrainingDateRequestControllerTestFixture GetChangeOfEmployerNotified() { @@ -289,8 +326,8 @@ public OverlappingTrainingDateRequestControllerTestFixture VerifyEmployerNotifie using (new AssertionScope()) { model.Should().NotBeNull(); - _employerNotifiedRequest.CohortReference.Should().Be(model.CohortReference); - _employerNotifiedRequest.ProviderId.Should().Be(model.ProviderId); + _employerNotifiedRequest.CohortReference.Should().Be(model.CohortReference); + _employerNotifiedRequest.ProviderId.Should().Be(model.ProviderId); } return this; } @@ -314,9 +351,9 @@ public OverlappingTrainingDateRequestControllerTestFixture GetDraftApprenticeshi return this; } - public OverlappingTrainingDateRequestControllerTestFixture GetOverlapOptionsForChangeEmployer() + public async Task GetOverlapOptionsForChangeEmployer() { - _actionResult = _controller.OverlapOptionsForChangeEmployer(_overlapOptionsForChangeEmployerRequest); + _actionResult = await _controller.OverlapOptionsForChangeEmployer(_overlapOptionsForChangeEmployerRequest); return this; } @@ -339,7 +376,7 @@ public OverlappingTrainingDateRequestControllerTestFixture VerifyOverlapRequests } return this; } - + public OverlappingTrainingDateRequestControllerTestFixture GetDraftApprenticeshipOverlapAlert() { _actionResult = _controller.DraftApprenticeshipOverlapAlert(_draftApprenticeshipOverlapAlertRequest); @@ -394,5 +431,17 @@ public OverlappingTrainingDateRequestControllerTestFixture VerifyExistingDraftAp return this; } + + public OverlappingTrainingDateRequestControllerTestFixture SetupWithdrawnStatusCode(int? statusCode) + { + _getApprenticeshipResponse.WithdrawnReasonCode = statusCode; + return this; + } + + public OverlappingTrainingDateRequestControllerTestFixture SetupHasOverlapWithIlrWithdrawnApprenticeship(bool value) + { + _validateUlnOverlapOnStartDateQueryResult.HasOverlapWithIlrWithdrawnApprenticeship = value; + return this; + } } } \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/WhenIGetDraftApprenticeshipOverlapOptions.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/WhenIGetDraftApprenticeshipOverlapOptions.cs index 239f832d9..19307fa2d 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/WhenIGetDraftApprenticeshipOverlapOptions.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/WhenIGetDraftApprenticeshipOverlapOptions.cs @@ -21,6 +21,13 @@ public async Task AndWhenIGetDraftApprenticeshipOverlapOptions_CorrectViewModelI _fixture.VerifyDraftApprenticeshipOverlapOptionsViewReturned(); } + [Test] + public async Task AndWhenIGetDraftApprenticeshipOverlapOptions_NotWithdrawnFromIlrPreviousApprenticeship_CorrectViewModelIsReturned() + { + await _fixture.SetupWithdrawnStatusCode(null).GetDraftApprenticeshipOverlapOptions(); + _fixture.VerifyDraftApprenticeshipOverlapOptionsViewReturned(); + } + [Test] public async Task AndWhenIGetDraftApprenticeshipOverlapOptions_ModelIsMapped() { @@ -30,6 +37,14 @@ await _fixture _fixture.VerifyWhenGettingOverlappingTrainingDate_ModelIsMapped(); } + [Test] + public async Task AndWhenIGetDraftApprenticeshipOverlapOptions_NotWithdrawnFromIlrPreviousApprenticeship_ModelIsMapped() + { + await _fixture.SetupWithdrawnStatusCode(null) + .GetDraftApprenticeshipOverlapOptions(); + _fixture.VerifyWhenGettingOverlappingTrainingDate_ModelIsMapped(); + } + [Test] public async Task AndWhenWhenUserSelectsToSendOverlapEmailToEmployer() { @@ -63,6 +78,7 @@ public async Task ThenEnableStopRequestEmailIsMappedCorrectly(CommitmentsV2.Type { await _fixture .SetApprenticeshipStatus(apprenticeshipStatus) + .SetupWithdrawnStatusCode(null) .GetDraftApprenticeshipOverlapOptions(); _fixture.VerifyEnableEmployerRequestEmail(sendEmail); diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/WhenIGetOverlapOptionsForChangeEmployer.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/WhenIGetOverlapOptionsForChangeEmployer.cs index a9823a775..897c21045 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/WhenIGetOverlapOptionsForChangeEmployer.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Controllers/OverlappingTrainingDateRequestControllerTests/WhenIGetOverlapOptionsForChangeEmployer.cs @@ -12,10 +12,17 @@ public void Arrange() } [Test] - public void AndWhenGetDraftApprenticeshipOverlapOptionsChangeEmployerEndpointIsCalled_CorrectViewModelIsReturned() + public async Task AndWhenGetDraftApprenticeshipOverlapOptionsChangeEmployerEndpointIsCalled_CorrectViewModelIsReturned() { - _fixture.GetOverlapOptionsForChangeEmployer(); + await _fixture.GetOverlapOptionsForChangeEmployer(); _fixture.VerifyOverlapOptionsForChangeEmployerViewModelViewReturned(); } + + [Test] + public async Task AndWhenGetDraftApprenticeshipOverlapOptionsChangeEmployerEndpointIsCalled_NotWithdrawnFromIlrPreviousApprenticeship_CorrectViewModelIsReturned() + { + await _fixture.SetupWithdrawnStatusCode(null).SetupHasOverlapWithIlrWithdrawnApprenticeship(false).GetOverlapOptionsForChangeEmployer(); + _fixture.VerifyOverlapOptionsForChangeEmployerViewModelViewReturnedWithNoWithdrawnReasonCode(); + } } } \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Models/WhenGettingOverlapOptionsForChangeEmployerViewModelTests.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Models/WhenGettingOverlapOptionsForChangeEmployerViewModelTests.cs new file mode 100644 index 000000000..d8829a5ab --- /dev/null +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Models/WhenGettingOverlapOptionsForChangeEmployerViewModelTests.cs @@ -0,0 +1,32 @@ +using SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate; + +namespace SFA.DAS.ProviderCommitments.Web.UnitTests.Models; + +public class WhenGettingOverlapOptionsForChangeEmployerViewModelTests +{ + [Test] + public void WhenHasWithdrawnReasonCode_ShouldSelectChangeEmployerOverlapIlrWithdrawnPartial() + { + // Arrange + var model = new OverlapOptionsForChangeEmployerViewModel { HasWithdrawnStatusCode = true }; + + // Act + string partialName = model.GetTargetPartialViewName(); + + // Assert + Assert.That(partialName, Is.EqualTo("_ChangeEmployerOverlapIlrWithdrawnPartial")); + } + + [Test] + public void WhenHasWithdrawnReasonCode_ShouldSelectOverlapOptionsForChangeEmployerPartial() + { + // Arrange + var model = new OverlapOptionsForChangeEmployerViewModel { HasWithdrawnStatusCode = false }; + + // Act + string partialName = model.GetTargetPartialViewName(); + + // Assert + Assert.That(partialName, Is.EqualTo("_OverlapOptionsForChangeEmployerPartial")); + } +} diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Validators/OverlappingTrainingDates/OverlapOptionsForChangeEmployerViewModelValidatorTests.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Validators/OverlappingTrainingDates/OverlapOptionsForChangeEmployerViewModelValidatorTests.cs index fbd208c2c..8777bb154 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Validators/OverlappingTrainingDates/OverlapOptionsForChangeEmployerViewModelValidatorTests.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web.UnitTests/Validators/OverlappingTrainingDates/OverlapOptionsForChangeEmployerViewModelValidatorTests.cs @@ -12,30 +12,35 @@ public class OverlapOptionsForChangeEmployerViewModelValidatorTests [TestCase(1, true)] public void Validate_ProviderId_ShouldBeValidated(int providerId, bool expectedValid) { - var model = new OverlapOptionsForChangeEmployerViewModel { ProviderId = providerId }; + var model = new OverlapOptionsForChangeEmployerViewModel { ProviderId = providerId, HasWithdrawnStatusCode = false }; AssertValidationResult(request => request.ProviderId, model, expectedValid); } - [TestCase(0, false)] [TestCase(1, true)] public void Validate_ApprenticeshipId_ShouldBeValidated(int apprenticeshipId, bool expectedValid) { - var model = new OverlapOptionsForChangeEmployerViewModel { ApprenticeshipId = apprenticeshipId }; + var model = new OverlapOptionsForChangeEmployerViewModel { ApprenticeshipId = apprenticeshipId, HasWithdrawnStatusCode = false }; AssertValidationResult(request => request.ApprenticeshipId, model, expectedValid); } - [TestCase(null, false)] [TestCase(OverlapOptions.CompleteActionLater, true)] [TestCase(OverlapOptions.ContactTheEmployer, true)] [TestCase(OverlapOptions.SendStopRequest, true)] public void Validate_Selection_ShouldBeValidated(OverlapOptions? selection, bool expectedValid) { - var model = new OverlapOptionsForChangeEmployerViewModel { OverlapOptions = selection }; + var model = new OverlapOptionsForChangeEmployerViewModel { OverlapOptions = selection, HasWithdrawnStatusCode = false }; AssertValidationResult(request => request.OverlapOptions, model, expectedValid); } + [TestCase(0, true)] + public void Validate_ProviderId_ShouldBeValidated_HasWithdrawnStatusCode(int providerId, bool expectedValid) + { + var model = new OverlapOptionsForChangeEmployerViewModel { ProviderId = providerId, HasWithdrawnStatusCode = true }; + AssertValidationResult(request => request.ProviderId, model, expectedValid); + } + private static void AssertValidationResult(Expression> property, OverlapOptionsForChangeEmployerViewModel instance, bool expectedValid) { var validator = new OverlapOptionsForChangeEmployerViewModelValidator(); @@ -51,4 +56,4 @@ private static void AssertValidationResult(Expression OverlapOptionsForChangeEmployer(OverlapOptionsForChangeEmployerRequest request) { + GetApprenticeshipResponse apprenticeshipDetails = new GetApprenticeshipResponse(); + var cacheItem = await _cacheStorage.RetrieveFromCache(request.CacheKey); + + var validateUlnStartDateOverlapResponse = await _outerApiService.ValidateUlnOverlapOnStartDate(request.ProviderId, cacheItem.Uln, DateTimeExtensions.FormatMonthYearDateToDateFormat(cacheItem.StartDate), DateTimeExtensions.FormatMonthYearDateToDateFormat(cacheItem.EndDate)); + + if(validateUlnStartDateOverlapResponse.HasOverlapWithApprenticeshipId.HasValue) + { + apprenticeshipDetails = await _outerApiService.GetApprenticeship(validateUlnStartDateOverlapResponse.HasOverlapWithApprenticeshipId.Value, request.ProviderId); + } + var viewModel = new OverlapOptionsForChangeEmployerViewModel { DraftApprenticeshipHashedId = request.ApprenticeshipHashedId, @@ -51,7 +66,10 @@ public IActionResult OverlapOptionsForChangeEmployer(OverlapOptionsForChangeEmpl ApprenticeshipHashedId = request.ApprenticeshipHashedId, ProviderId = request.ProviderId, CacheKey = request.CacheKey, - Status = request.Status + Status = request.Status, + HasWithdrawnStatusCode = apprenticeshipDetails?.WithdrawnReasonCode.HasValue ?? false, + IsSameProvider = apprenticeshipDetails?.ProviderId == request.ProviderId, + ProviderName = apprenticeshipDetails?.ProviderName }; return View(viewModel); @@ -61,14 +79,19 @@ public IActionResult OverlapOptionsForChangeEmployer(OverlapOptionsForChangeEmpl [Route("overlap-options-change-employer")] public async Task OverlapOptionsForChangeEmployer(OverlapOptionsForChangeEmployerViewModel viewModel) { - if (viewModel.OverlapOptions != OverlapOptions.SendStopRequest) + if (!viewModel.HasWithdrawnStatusCode) { - return RedirectToAction(ControllerConstants.ApprenticeController.Actions.Index, ControllerConstants.ApprenticeController.Name, new { viewModel.ProviderId }); - } + if (viewModel.OverlapOptions != OverlapOptions.SendStopRequest) + { + return RedirectToAction(ControllerConstants.ApprenticeController.Actions.Index, ControllerConstants.ApprenticeController.Name, new { viewModel.ProviderId }); + } - var request = await _modelMapper.Map(viewModel); + var request = await _modelMapper.Map(viewModel); - return RedirectToAction(nameof(ChangeOfEmployerNotified), request); + return RedirectToAction(nameof(ChangeOfEmployerNotified), request); + } + + return RedirectToAction(ControllerConstants.ApprenticeController.Actions.Index, ControllerConstants.ApprenticeController.Name, new { viewModel.ProviderId }); } [HttpGet] @@ -100,36 +123,53 @@ public async Task DraftApprenticeshipOverlapOptionsWithPendingReq [Route("overlap-options")] public async Task DraftApprenticeshipOverlapOptions(DraftApprenticeshipOverlapOptionRequest request) { - var apprenticeshipDetails = await _commitmentsApiClient.GetApprenticeship(request.ApprenticeshipId.Value); - - var enableStopRequestEmail = apprenticeshipDetails.Status == ApprenticeshipStatus.Live - || apprenticeshipDetails.Status == ApprenticeshipStatus.WaitingToStart - || apprenticeshipDetails.Status == ApprenticeshipStatus.Paused - || apprenticeshipDetails.Status == ApprenticeshipStatus.Completed - || apprenticeshipDetails.Status == ApprenticeshipStatus.Stopped; - if (request.DraftApprenticeshipId.HasValue) + var apprenticeshipDetails = await _outerApiService.GetApprenticeship(request.ApprenticeshipId.Value, request.ProviderId); + DraftApprenticeshipOverlapOptionViewModel vm; + + if (apprenticeshipDetails.WithdrawnReasonCode.HasValue) { - var pendingOverlapRequests = await _outerApiService.GetOverlapRequest(request.DraftApprenticeshipId.Value); - if (pendingOverlapRequests.DraftApprenticeshipId.HasValue) + vm = new DraftApprenticeshipOverlapOptionViewModel { - return RedirectToAction(nameof(DraftApprenticeshipOverlapOptionsWithPendingRequest), new + DraftApprenticeshipHashedId = request.DraftApprenticeshipHashedId, + Status = (ApprenticeshipStatus)apprenticeshipDetails.Status, + EnableStopRequestEmail = false, + HasWithdrawnStatusCode = true, + IsSameProvider = apprenticeshipDetails.ProviderId == request.ProviderId, + ProviderName = apprenticeshipDetails.ProviderName + }; + } + else + { + var enableStopRequestEmail = apprenticeshipDetails.Status == (short)ApprenticeshipStatus.Live + || apprenticeshipDetails.Status == (short)ApprenticeshipStatus.WaitingToStart + || apprenticeshipDetails.Status == (short)ApprenticeshipStatus.Paused + || apprenticeshipDetails.Status == (short)ApprenticeshipStatus.Completed + || apprenticeshipDetails.Status == (short)ApprenticeshipStatus.Stopped; + + if (request.DraftApprenticeshipId.HasValue) + { + var pendingOverlapRequests = await _outerApiService.GetOverlapRequest(request.DraftApprenticeshipId.Value); + if (pendingOverlapRequests.DraftApprenticeshipId.HasValue) { - ProviderId = apprenticeshipDetails.ProviderId, - CohortReference = request.CohortReference, - DraftApprenticeshipHashedId = request.DraftApprenticeshipHashedId, - CreatedOn = pendingOverlapRequests.CreatedOn, - Status = apprenticeshipDetails.Status, - EnableStopRequestEmail = enableStopRequestEmail - }); + return RedirectToAction(nameof(DraftApprenticeshipOverlapOptionsWithPendingRequest), new + { + ProviderId = apprenticeshipDetails.ProviderId, + CohortReference = request.CohortReference, + DraftApprenticeshipHashedId = request.DraftApprenticeshipHashedId, + CreatedOn = pendingOverlapRequests.CreatedOn, + Status = apprenticeshipDetails.Status, + EnableStopRequestEmail = enableStopRequestEmail + }); + } } - } - var vm = new DraftApprenticeshipOverlapOptionViewModel - { - DraftApprenticeshipHashedId = request.DraftApprenticeshipHashedId, - Status = apprenticeshipDetails.Status, - EnableStopRequestEmail = enableStopRequestEmail - }; + vm = new DraftApprenticeshipOverlapOptionViewModel + { + DraftApprenticeshipHashedId = request.DraftApprenticeshipHashedId, + Status = (ApprenticeshipStatus)apprenticeshipDetails.Status, + EnableStopRequestEmail = enableStopRequestEmail + }; + } return View(vm); } @@ -181,7 +221,7 @@ public IActionResult ChangeOfEmployerNotified(ChangeOfEmployerNotifiedRequest re { var vm = new ChangeOfEmployerNotifiedViewModel { ProviderId = request.ProviderId }; return View(vm); - } + } [HttpGet] [Route("{cohortReference}/employer-notified")] diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Extensions/DateTimeExtensions.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Extensions/DateTimeExtensions.cs index 792998967..0194e4c60 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Extensions/DateTimeExtensions.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Extensions/DateTimeExtensions.cs @@ -1,4 +1,7 @@ -namespace SFA.DAS.ProviderCommitments.Web.Extensions +using System.Globalization; +using SFA.DAS.ProviderCommitments.Web.Services.Cache; + +namespace SFA.DAS.ProviderCommitments.Web.Extensions { public static class DateTimeExtensions { @@ -8,6 +11,7 @@ public static class DateTimeExtensions return new DateTime(dateValue.Value.Year, dateValue.Value.Month, 1).Date; } + public static string ToGdsHumanisedDate(this DateTime date) { string ordinal; @@ -19,14 +23,17 @@ public static string ToGdsHumanisedDate(this DateTime date) case 31: ordinal = "st"; break; + case 2: case 22: ordinal = "nd"; break; + case 3: case 23: ordinal = "rd"; break; + default: ordinal = "th"; break; @@ -35,5 +42,11 @@ public static string ToGdsHumanisedDate(this DateTime date) // Eg 12th January 2024 return string.Format("{0}{1} {2:MMMM yyyy}", date.Day, ordinal, date); } + + public static string FormatMonthYearDateToDateFormat(string date) + { + var formatDate = DateTime.ParseExact(date, "MMyyyy", CultureInfo.InvariantCulture); + return formatDate.ToString("dd-MM-yyyy"); + } } -} +} \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Mappers/Apprentice/ChangeOfEmployerOverlapAlertViewModelMapper.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Mappers/Apprentice/ChangeOfEmployerOverlapAlertViewModelMapper.cs index 210b5cbe5..ee1fa1f59 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Mappers/Apprentice/ChangeOfEmployerOverlapAlertViewModelMapper.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Mappers/Apprentice/ChangeOfEmployerOverlapAlertViewModelMapper.cs @@ -1,4 +1,5 @@ -using SFA.DAS.CommitmentsV2.Shared.Interfaces; +using OpenTelemetry.Resources; +using SFA.DAS.CommitmentsV2.Shared.Interfaces; using SFA.DAS.CommitmentsV2.Shared.Models; using SFA.DAS.CommitmentsV2.Types; using SFA.DAS.Encoding; @@ -38,6 +39,9 @@ public async Task Map(ChangeOfEmployerOve var cacheItem = await _cacheStorage.RetrieveFromCache(source.CacheKey); var data = await GetApprenticeshipData(source.ProviderId, source.ApprenticeshipId, cacheItem.AccountLegalEntityId); + + cacheItem.Uln = data.Apprenticeship.Uln; + await _cacheStorage.SaveToCache(source.CacheKey.ToString(), cacheItem, TimeSpan.FromHours(1)); var newStartDate = new MonthYearModel(cacheItem.StartDate); var newEndDate = new MonthYearModel(cacheItem.EndDate); diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Models/OveralppingTrainingDate/DraftApprenticeshipOverlapOptionViewModel.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Models/OveralppingTrainingDate/DraftApprenticeshipOverlapOptionViewModel.cs index 21ab245cd..52e81a7e7 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Models/OveralppingTrainingDate/DraftApprenticeshipOverlapOptionViewModel.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Models/OveralppingTrainingDate/DraftApprenticeshipOverlapOptionViewModel.cs @@ -1,5 +1,5 @@ -using SFA.DAS.ProviderCommitments.Web.ModelBinding; -using SFA.DAS.CommitmentsV2.Types; +using SFA.DAS.CommitmentsV2.Types; +using SFA.DAS.ProviderCommitments.Web.ModelBinding; namespace SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate { @@ -12,6 +12,9 @@ public class DraftApprenticeshipOverlapOptionViewModel : IAuthorizationContextMo public long? DraftApprenticeshipId { get; set; } public ApprenticeshipStatus Status { get; set; } public bool EnableStopRequestEmail { get; set; } + public bool HasWithdrawnStatusCode { get; set; } + public bool IsSameProvider { get; set; } + public string ProviderName { get; set; } } public enum OverlapOptions @@ -20,4 +23,4 @@ public enum OverlapOptions ContactTheEmployer, CompleteActionLater } -} +} \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Models/OveralppingTrainingDate/OverlapOptionsForChangeEmployerViewModel.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Models/OveralppingTrainingDate/OverlapOptionsForChangeEmployerViewModel.cs index 0813dd165..dc45c0b32 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Models/OveralppingTrainingDate/OverlapOptionsForChangeEmployerViewModel.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Models/OveralppingTrainingDate/OverlapOptionsForChangeEmployerViewModel.cs @@ -5,5 +5,10 @@ public class OverlapOptionsForChangeEmployerViewModel : DraftApprenticeshipOverl public Guid CacheKey { get; set; } public string ApprenticeshipHashedId { get; set; } public long? ApprenticeshipId { get; set; } + + public string GetTargetPartialViewName() + { + return HasWithdrawnStatusCode ? "_ChangeEmployerOverlapIlrWithdrawnPartial" : "_OverlapOptionsForChangeEmployerPartial"; + } } } \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Services/Cache/ChangeEmployerCacheItem.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Services/Cache/ChangeEmployerCacheItem.cs index 4b9c44104..4ac6973e7 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Services/Cache/ChangeEmployerCacheItem.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Services/Cache/ChangeEmployerCacheItem.cs @@ -21,5 +21,6 @@ public ChangeEmployerCacheItem(Guid key) public string EmploymentEndDate { get; set; } public int? Price { get; set; } public int? EmploymentPrice { get; set; } + public string Uln { get; set; } } } \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Validators/OverlappingTrainingDate/DraftApprenticeshipOverlapOptionViewModelValidator.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Validators/OverlappingTrainingDate/DraftApprenticeshipOverlapOptionViewModelValidator.cs index 06260e9fe..03820154d 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Validators/OverlappingTrainingDate/DraftApprenticeshipOverlapOptionViewModelValidator.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Validators/OverlappingTrainingDate/DraftApprenticeshipOverlapOptionViewModelValidator.cs @@ -8,7 +8,7 @@ public class DraftApprenticeshipOverlapOptionViewModelValidator : AbstractValida public DraftApprenticeshipOverlapOptionViewModelValidator() { RuleFor(x => x.ProviderId).GreaterThan(0); - RuleFor(x => x.OverlapOptions).NotNull().WithMessage("You need to select what you would like to do"); + RuleFor(x => x.OverlapOptions).NotNull().Unless(x => x.HasWithdrawnStatusCode).WithMessage("You need to select what you would like to do"); } } -} +} \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Validators/OverlappingTrainingDate/OverlapOptionsForChangeEmployerViewModelValidator.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Validators/OverlappingTrainingDate/OverlapOptionsForChangeEmployerViewModelValidator.cs index ecb4204e2..d712faddd 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Validators/OverlappingTrainingDate/OverlapOptionsForChangeEmployerViewModelValidator.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Validators/OverlappingTrainingDate/OverlapOptionsForChangeEmployerViewModelValidator.cs @@ -7,10 +7,10 @@ public class OverlapOptionsForChangeEmployerViewModelValidator : AbstractValidat { public OverlapOptionsForChangeEmployerViewModelValidator() { - RuleFor(x => x.ProviderId).GreaterThan(0); - RuleFor(x => x.CacheKey).NotNull(); - RuleFor(x => x.ApprenticeshipId).GreaterThan(0); - RuleFor(x => x.OverlapOptions).NotNull().WithMessage("You need to select what you would like to do"); + RuleFor(x => x.ProviderId).GreaterThan(0).Unless(x => x.HasWithdrawnStatusCode); + RuleFor(x => x.CacheKey).NotNull().Unless(x => x.HasWithdrawnStatusCode); + RuleFor(x => x.ApprenticeshipId).GreaterThan(0).Unless(x => x.HasWithdrawnStatusCode); + RuleFor(x => x.OverlapOptions).NotNull().Unless(x => x.HasWithdrawnStatusCode).WithMessage("You need to select what you would like to do"); } } } diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/OverlappingTrainingDateRequest/DraftApprenticeshipOverlapOptions.cshtml b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/OverlappingTrainingDateRequest/DraftApprenticeshipOverlapOptions.cshtml index d2782d20a..2e67440c3 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/OverlappingTrainingDateRequest/DraftApprenticeshipOverlapOptions.cshtml +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/OverlappingTrainingDateRequest/DraftApprenticeshipOverlapOptions.cshtml @@ -1,63 +1,16 @@ -@using SFA.DAS.CommitmentsV2.Shared.Extensions -@using SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate +@using SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate @model DraftApprenticeshipOverlapOptionViewModel -@{ - ViewData["Title"] = "Planned start date overlaps with existing training"; - ViewBag.GaData.Vpv = "/unapproved/add/apprenticeship/overlap-options"; +@if (Model.HasWithdrawnStatusCode) +{ + +} +else +{ + } -
-
- -

Planned start date overlaps with existing training

-

The dates may be overlapping because:

-
    -
  • the previous employer has not added or updated the stop date
  • -
  • the previous employer has entered an incorrect stop date
  • -
- -
-
-
- -

Do you want to send a stop date request?

-
- - @Html.ValidationMessageFor(m => m.OverlapOptions, null, new { @class = "govuk-error-message", id = "error-message-" + Html.IdFor(m => m.OverlapOptions) }) -
- @if (Model.EnableStopRequestEmail) - { -
- - -
- A draft apprenticeship record will be saved and the employer will have 2 weeks to action the changes -
-
- } -
- - -
- The details entered for this apprentice will not be saved. Go back to view apprentice details -
-
-
-
-
- -
-
-
- @section breadcrumb - { +{ -} +} \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/OverlappingTrainingDateRequest/OverlapOptionsForChangeEmployer.cshtml b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/OverlappingTrainingDateRequest/OverlapOptionsForChangeEmployer.cshtml index 05848e84d..fdc522b59 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/OverlappingTrainingDateRequest/OverlapOptionsForChangeEmployer.cshtml +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/OverlappingTrainingDateRequest/OverlapOptionsForChangeEmployer.cshtml @@ -3,67 +3,9 @@ @using SFA.DAS.CommitmentsV2.Types; @model OverlapOptionsForChangeEmployerViewModel -@{ - ViewBag.Title = "Planned start date overlaps with existing training"; - ViewBag.GaData.Vpv = "/unapproved/add/apprenticeship/overlap-options-change-employer"; + - var radioHeading = Model.Status == ApprenticeshipStatus.Stopped ? "Do you want to update a stop date?" : "Do you want to send a stop date request?"; -} - -
-
- -

@ViewBag.Title

-

The dates may be overlapping because:

-
    -
  • the previous employer has not added or updated the stop date
  • -
  • the previous employer has entered an incorrect stop date
  • -
- -
- - - - - - -
-
- -

@radioHeading

-
- - @Html.ValidationMessageFor(m => m.OverlapOptions, null, new { @class = "govuk-error-message", id = "error-message-" + Html.IdFor(m => m.OverlapOptions) }) -
-
- - -
- A draft learner record will be saved and the employer will have 2 weeks to action the changes -
-
-
- - -
- The details entered for this learner will not be saved. Go back to view learner details. -
-
-
-
-
- -
-
-
- -@section breadcrumb -{ - -} \ No newline at end of file + @section breadcrumb + { + + } \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_ChangeEmployerOverlapIlrWithdrawnPartial.cshtml b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_ChangeEmployerOverlapIlrWithdrawnPartial.cshtml new file mode 100644 index 000000000..a7969e701 --- /dev/null +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_ChangeEmployerOverlapIlrWithdrawnPartial.cshtml @@ -0,0 +1,46 @@ +@using SFA.DAS.CommitmentsV2.Shared.Extensions +@using SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate +@using SFA.DAS.ProviderCommitments.Web.RouteValues +@model OverlapOptionsForChangeEmployerViewModel + +@{ + ViewBag.Title = "Planned start date overlaps with existing training"; + ViewBag.GaData.Vpv = "/unapproved/add/apprenticeship/overlap-options-change-employer"; +} + +
+
+

@ViewBag.Title

+ +

The learner's unique learner number (ULN) is already linked to a previous learner record which has been withdrawn through the ILR.

+ +

You cannot send a stop date request for this record because the stop date on the previous record has come from the ILR.

+ +

What you can do next

+ +
+ @if (Model.IsSameProvider) + { +
+

As your organisation @Model.ProviderName is the training provider for the previous ILR record you can:

+ +
    +
  1. Submit an updated ILR record through Submit Learner Data with the correct training and stop dates for this learner.
  2. +
  3. After 15 minutes return to the Apprenticeship Service to add the learner again or change the planned training dates.
  4. +
+
+ } + else + { +
+

Change the training dates for the learner so there is no longer an overlap

+ +

If this not possible, contact the support team on 0800 150 600. Telephone lines are open 8am to 8pm, Monday to Friday.

+
+ } +
+ + Go back to Manage your learners + +
+
\ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_DraftApprenticeshipOverlapOptionsPartial.cshtml b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_DraftApprenticeshipOverlapOptionsPartial.cshtml new file mode 100644 index 000000000..2060840b3 --- /dev/null +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_DraftApprenticeshipOverlapOptionsPartial.cshtml @@ -0,0 +1,58 @@ +@using SFA.DAS.CommitmentsV2.Shared.Extensions +@using SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate +@model DraftApprenticeshipOverlapOptionViewModel + +@{ + ViewData["Title"] = "Planned start date overlaps with existing training"; + ViewBag.GaData.Vpv = "/unapproved/add/apprenticeship/overlap-options"; +} + +
+
+ +

Planned start date overlaps with existing training

+

The dates may be overlapping because:

+
    +
  • the previous employer has not added or updated the stop date
  • +
  • the previous employer has entered an incorrect stop date
  • +
+ +
+
+
+ +

Do you want to send a stop date request?

+
+ + @Html.ValidationMessageFor(m => m.OverlapOptions, null, new { @class = "govuk-error-message", id = "error-message-" + Html.IdFor(m => m.OverlapOptions) }) +
+ @if (Model.EnableStopRequestEmail) + { +
+ + +
+ A draft apprenticeship record will be saved and the employer will have 2 weeks to action the changes +
+
+ } +
+ + +
+ The details entered for this apprentice will not be saved. Go back to view apprentice details +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_OverlapIlrWithdrawnPartial.cshtml b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_OverlapIlrWithdrawnPartial.cshtml new file mode 100644 index 000000000..6154ddd68 --- /dev/null +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_OverlapIlrWithdrawnPartial.cshtml @@ -0,0 +1,55 @@ +@using SFA.DAS.CommitmentsV2.Shared.Extensions +@using SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate +@using SFA.DAS.ProviderCommitments.Web.RouteValues +@model DraftApprenticeshipOverlapOptionViewModel + +@{ + ViewBag.Title = "Planned start date overlaps with existing training"; + ViewBag.GaData.Vpv = "/unapproved/add/apprenticeship/overlap-options"; +} + +
+
+

@ViewBag.Title

+ +
+ @Html.HiddenFor(x => x.HasWithdrawnStatusCode) + @Html.HiddenFor(x => x.DraftApprenticeshipHashedId) + @Html.HiddenFor(x => x.CohortReference) + @Html.HiddenFor(x => x.ProviderId) + +

The learner's unique learner number (ULN) is already linked to a previous learner record which has been withdrawn through the ILR.

+ +

You cannot send a stop date request for this record because the stop date on the previous record has come from the ILR.

+ +

What you can do next

+ +
+ @if (Model.IsSameProvider) + { +
+

As your organisation @Model.ProviderName is the training provider for the previous ILR record you can:

+ +
    +
  1. Submit an updated ILR record through Submit Learner Data with the correct training and stop dates for this learner.
  2. +
  3. After 15 minutes return to the Apprenticeship Service to add the learner again or change the planned training dates.
  4. +
+
+ } + else + { +
+

Change the training dates for the learner so there is no longer an overlap

+ +

If this not possible, contact the support team on 0800 150 600. Telephone lines are open 8am to 8pm, Monday to Friday.

+
+ } +
+ + +
+
+ +
\ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_OverlapOptionsForChangeEmployerPartial.cshtml b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_OverlapOptionsForChangeEmployerPartial.cshtml new file mode 100644 index 000000000..fb2f15305 --- /dev/null +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments.Web/Views/Shared/_OverlapOptionsForChangeEmployerPartial.cshtml @@ -0,0 +1,65 @@ +@using SFA.DAS.CommitmentsV2.Shared.Extensions +@using SFA.DAS.ProviderCommitments.Web.Models.OveralppingTrainingDate +@using SFA.DAS.CommitmentsV2.Types; +@model OverlapOptionsForChangeEmployerViewModel + +@{ + ViewBag.Title = "Planned start date overlaps with existing training"; + ViewBag.GaData.Vpv = "/unapproved/add/apprenticeship/overlap-options-change-employer"; + + var radioHeading = Model.Status == ApprenticeshipStatus.Stopped ? "Do you want to update a stop date?" : "Do you want to send a stop date request?"; +} + +
+
+ +

@ViewBag.Title

+

The dates may be overlapping because:

+
    +
  • the previous employer has not added or updated the stop date
  • +
  • the previous employer has entered an incorrect stop date
  • +
+
+ + + + + + + +
+
+ +

@radioHeading

+
+ + @Html.ValidationMessageFor(m => m.OverlapOptions, null, new { @class = "govuk-error-message", id = "error-message-" + Html.IdFor(m => m.OverlapOptions) }) +
+
+ + +
+ A draft learner record will be saved and the employer will have 2 weeks to action the changes +
+
+
+ + +
+ The details entered for this learner will not be saved. Go back to view learner details. +
+
+
+
+
+ +
+ +
+
diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/IOuterApiService.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/IOuterApiService.cs index ecf180239..746c6eae5 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/IOuterApiService.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/IOuterApiService.cs @@ -93,4 +93,6 @@ public interface IOuterApiService Task DraftApprenticeshipSetReference(long providerId, long cohortId, long apprenticeshipId, DraftApprenticeshipSetReferenceApimRequest request); Task DraftApprenticeshipAddEmail(long providerId, long cohortId, long apprenticeshipId, DraftApprenticeAddEmailApimRequest request); + + Task GetApprenticeship(long apprenticeshipId, long providerId); } \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/OuterApiService.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/OuterApiService.cs index 886523563..44865e67d 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/OuterApiService.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/OuterApiService.cs @@ -334,4 +334,10 @@ public async Task ConfirmEditApprenticeship(l return await outerApiClient.Post(apiRequest); } + + public async Task GetApprenticeship(long apprenticeshipId, long providerId) + { + var request = new GetApprenticeshipRequest(apprenticeshipId, providerId); + return await outerApiClient.Get(request); + } } \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Requests/Apprentices/GetApprenticeshipRequest.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Requests/Apprentices/GetApprenticeshipRequest.cs new file mode 100644 index 000000000..59477cb53 --- /dev/null +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Requests/Apprentices/GetApprenticeshipRequest.cs @@ -0,0 +1,15 @@ +namespace SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Requests.Apprentices; + +public class GetApprenticeshipRequest : IGetApiRequest +{ + private readonly long _apprenticeshipId; + private readonly long _providerId; + + public GetApprenticeshipRequest(long apprenticeshipId, long providerId) + { + _apprenticeshipId = apprenticeshipId; + _providerId = providerId; + } + + public string GetUrl => $"provider/{_providerId}/apprentices/{_apprenticeshipId}"; +} \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Responses/GetApprenticeshipResponse.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Responses/GetApprenticeshipResponse.cs new file mode 100644 index 000000000..875633498 --- /dev/null +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Responses/GetApprenticeshipResponse.cs @@ -0,0 +1,71 @@ +using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using SFA.DAS.Common.Domain.Types; + +namespace SFA.DAS.ProviderCommitments.Infrastructure.OuterApi.Responses; + +public class GetApprenticeshipResponse +{ + public long Id { get; set; } + public long CohortId { get; set; } + public long ProviderId { get; set; } + public string ProviderName { get; set; } + public long EmployerAccountId { get; set; } + public long AccountId => EmployerAccountId; + public long AccountLegalEntityId { get; set; } + public string EmployerName { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public string Email { get; set; } + public string Uln { get; set; } + public string CourseCode { get; set; } + public string StandardUId { get; set; } + public string Version { get; set; } + public string Option { get; set; } + public string CourseName { get; set; } + public string DeliveryModel { get; set; } + public DateTime? StartDate { get; set; } + public DateTime? ActualStartDate { get; set; } + public DateTime EndDate { get; set; } + public DateTime? DateOfBirth { get; set; } + public string EmployerReference { get; set; } + public string ProviderReference { get; set; } + public short Status { get; set; } + public DateTime? StopDate { get; set; } + public DateTime? PauseDate { get; set; } + public DateTime? CompletionDate { get; set; } + public string EndpointAssessorName { get; set; } + public bool HasHadDataLockSuccess { get; set; } + public long? ContinuationOfId { get; set; } + public long? ContinuedById { get; set; } + public DateTime? OriginalStartDate { get; set; } + public long? PreviousProviderId { get; set; } + public long? PreviousEmployerAccountId { get; set; } + public byte? ApprenticeshipEmployerTypeOnApproval { get; set; } + public bool? MadeRedundant { get; set; } + public short? ConfirmationStatus { get; set; } + public bool EmailAddressConfirmedByApprentice { get; set; } + public bool EmailShouldBePresent { get; set; } + public int? PledgeApplicationId { get; set; } + public int? EmploymentPrice { get; set; } + public DateTime? EmploymentEndDate { get; set; } + public bool? RecognisePriorLearning { get; set; } + public int? DurationReducedBy { get; set; } + public int? PriceReducedBy { get; set; } + public long? TransferSenderId { get; set; } + public int? DurationReducedByHours { get; set; } + public int? TrainingTotalHours { get; set; } + public bool? IsDurationReducedByRpl { get; set; } + + [JsonConverter(typeof(StringEnumConverter))] + public LearningType? LearningType { get; set; } + + public int? EmployerVerificationStatus { get; set; } + public string EmployerVerificationNotes { get; set; } + public bool HasChangeHistory { get; set; } + public int? WithdrawnReasonCode { get; set; } + public bool FreezeStatus { get; set; } + public byte? FreezePaymentsReason { get; set; } + public DateTime? PaymentFreezeDate { get; set; } +} \ No newline at end of file diff --git a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Responses/GetOverlappingApprenticeshipDetailsQueryResult.cs b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Responses/GetOverlappingApprenticeshipDetailsQueryResult.cs index 5c65bcc77..299d8a19a 100644 --- a/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Responses/GetOverlappingApprenticeshipDetailsQueryResult.cs +++ b/src/SFA.DAS.ProviderCommitments/SFA.DAS.ProviderCommitments/Infrastructure/OuterApi/Responses/GetOverlappingApprenticeshipDetailsQueryResult.cs @@ -4,5 +4,6 @@ public class ValidateUlnOverlapOnStartDateQueryResult { public long? HasOverlapWithApprenticeshipId { get; set; } public bool HasStartDateOverlap { get; set; } + public bool HasOverlapWithIlrWithdrawnApprenticeship { get; set; } } -} +} \ No newline at end of file