diff --git a/src/SFA.DAS.EmployerCommitmentsV2.UnitTests/Services/Approvals/ApprovalsApiClient.cs b/src/SFA.DAS.EmployerCommitmentsV2.UnitTests/Services/Approvals/ApprovalsApiClient.cs index 72c4792c..542e5688 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.UnitTests/Services/Approvals/ApprovalsApiClient.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.UnitTests/Services/Approvals/ApprovalsApiClient.cs @@ -78,4 +78,17 @@ public async Task When_Calling_GetSelectDirectTransferConnections_Then_The_Data_ actual.Should().BeSameAs(response); } + + [Test, AutoData] + public async Task When_Calling_GetSelectLevyTransferConnections_Then_The_Data_Is_Returned(long accountId, GetSelectLevyTransferConnectionResponse response) + { + var outerApiClient = new Mock(); + var expectedUrl = $"{accountId}/unapproved/add/select-funding/select-accepted-levy-connection"; + outerApiClient.Setup(x => x.Get(expectedUrl)).ReturnsAsync(response); + var approvalsApiClient = new ApprovalsApiClient(outerApiClient.Object); + + var actual = await approvalsApiClient.GetSelectLevyTransferConnection(accountId); + + actual.Should().BeSameAs(response); + } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenGettingSelectAcceptedLevyConnections.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenGettingSelectAcceptedLevyConnections.cs new file mode 100644 index 00000000..4a8e078e --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenGettingSelectAcceptedLevyConnections.cs @@ -0,0 +1,28 @@ +using FluentAssertions; +using SFA.DAS.CommitmentsV2.Shared.Interfaces; +using SFA.DAS.EmployerCommitmentsV2.Web.Controllers; +using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; +using SFA.DAS.Testing.AutoFixture; + +namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.CohortControllerTests; + +[TestFixture] +public class WhenGettingSelectAcceptedLevyConnections +{ + [Test, MoqAutoData] + public async Task WithSelectAcceptedLevyTransfersThenReturnsView( + BaseSelectProviderRequest request, + SelectAcceptedLevyTransferConnectionViewModel viewModel, + [Frozen] Mock mockMapper, + [Greedy] CohortController controller) + { + mockMapper + .Setup(mapper => mapper.Map(request)) + .ReturnsAsync(viewModel); + + var result = await controller.SelectAcceptedLevyTransferConnection(request) as ViewResult; + + result.Should().NotBeNull(); + result.Model.Should().Be(viewModel); + } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenGettingSelectDirectConnections.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenGettingSelectDirectConnections.cs new file mode 100644 index 00000000..a56c34f4 --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenGettingSelectDirectConnections.cs @@ -0,0 +1,28 @@ +using FluentAssertions; +using SFA.DAS.CommitmentsV2.Shared.Interfaces; +using SFA.DAS.EmployerCommitmentsV2.Web.Controllers; +using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; +using SFA.DAS.Testing.AutoFixture; + +namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.CohortControllerTests; + +[TestFixture] +public class WhenGettingSelectDirectConnections +{ + [Test, MoqAutoData] + public async Task WithSelectDirectTransfersThenReturnsView( + BaseSelectProviderRequest request, + SelectTransferConnectionViewModel viewModel, + [Frozen] Mock mockMapper, + [Greedy] CohortController controller) + { + mockMapper + .Setup(mapper => mapper.Map(request)) + .ReturnsAsync(viewModel); + + var result = await controller.SelectDirectTransferConnection(request) as ViewResult; + + result.Should().NotBeNull(); + result.Model.Should().Be(viewModel); + } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenPostingSelectFunding.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenPostingSelectFunding.cs new file mode 100644 index 00000000..58c64b6b --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenPostingSelectFunding.cs @@ -0,0 +1,75 @@ +using FluentAssertions; +using SFA.DAS.CommitmentsV2.Api.Client; +using SFA.DAS.CommitmentsV2.Shared.Interfaces; +using SFA.DAS.EmployerCommitmentsV2.Contracts; +using SFA.DAS.EmployerCommitmentsV2.Interfaces; +using SFA.DAS.EmployerCommitmentsV2.Web.Controllers; +using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; +using SFA.DAS.EmployerUrlHelper; +using SFA.DAS.Encoding; + +namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.CohortControllerTests; + +[TestFixture] +public class WhenPostingSelectFunding +{ + private CohortController _controller; + private SelectFundingViewModel _model; + + [SetUp] + public void Arrange() + { + var autoFixture = new Fixture(); + _model = autoFixture.Create(); + + _controller = new CohortController(Mock.Of(), + Mock.Of>(), + Mock.Of(), + Mock.Of(), + Mock.Of(), + Mock.Of(), + Mock.Of()); + } + + [TearDown] + public void TearDown() => _controller?.Dispose(); + + [TestCase(FundingType.AdditionalReservations)] + [TestCase(FundingType.UnallocatedReservations)] + [TestCase(FundingType.CurrentLevy)] + public async Task And_This_Funding_Option_Is_Selected_Then_User_Is_Redirected_To_SelectProvider_Page(FundingType fundingType) + { + _model.FundingType = fundingType; + //Act + var result = await _controller.SetFundingType(_model); + + //Assert + var redirectToActionResult = result as RedirectToActionResult; + redirectToActionResult.ActionName.Should().Be("SelectProvider"); + } + + [Test] + public async Task And_DirectTransfers_Is_Selected_Then_User_Is_Redirected_To_SelectDirectTransferConnection_Page() + { + _model.FundingType = FundingType.DirectTransfers; + //Act + var result = await _controller.SetFundingType(_model); + + //Assert + var redirectToActionResult = result as RedirectToActionResult; + redirectToActionResult.ActionName.Should().Be("SelectDirectTransferConnection"); + } + + [Test] + public async Task And_LtmTransfers_Is_Selected_Then_User_Is_Redirected_To_SelectLtmTransfers_Page() + { + _model.FundingType = FundingType.LtmTransfers; + //Act + var result = await _controller.SetFundingType(_model); + + //Assert + var redirectToActionResult = result as RedirectToActionResult; + redirectToActionResult.ActionName.Should().Be("SelectAcceptedLevyTransferConnection"); + } + +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenPostingSelectLevyConnection.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenPostingSelectLevyConnection.cs new file mode 100644 index 00000000..fb483634 --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Controllers/CohortControllerTests/WhenPostingSelectLevyConnection.cs @@ -0,0 +1,69 @@ +using FluentAssertions; +using SFA.DAS.CommitmentsV2.Api.Client; +using SFA.DAS.CommitmentsV2.Shared.Interfaces; +using SFA.DAS.EmployerCommitmentsV2.Contracts; +using SFA.DAS.EmployerCommitmentsV2.Interfaces; +using SFA.DAS.EmployerCommitmentsV2.Web.Controllers; +using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; +using SFA.DAS.EmployerUrlHelper; +using SFA.DAS.Encoding; + +namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Controllers.CohortControllerTests; + +[TestFixture] +public class WhenPostingSelectLevyConnection +{ + private CohortController _controller; + private SelectAcceptedLevyTransferConnectionViewModel _model; + + [SetUp] + public void Arrange() + { + var autoFixture = new Fixture(); + _model = autoFixture.Create(); + + foreach (var app in _model.Applications) + { + app.ApplicationAndSenderHashedId = app.ApplicationHashedId + "|" + app.SendingEmployerPublicHashedId; + } + + _model.ApplicationAndSenderHashedId = _model.Applications.First().ApplicationAndSenderHashedId; + + _controller = new CohortController(Mock.Of(), + Mock.Of>(), + Mock.Of(), + Mock.Of(), + Mock.Of(), + Mock.Of(), + Mock.Of()); + } + + [TearDown] + public void TearDown() => _controller?.Dispose(); + + [Test] + public async Task Then_User_Is_Redirected_To_SelectProvider_Page() + { + //Act + var result = _controller.SelectAcceptedLevyTransferConnection(_model); + + //Assert + var redirectToActionResult = result as RedirectToActionResult; + redirectToActionResult.ActionName.Should().Be("SelectProvider"); + } + + [Test] + public async Task Then_Verify_RouteValues() + { + //Act + var result = _controller.SelectAcceptedLevyTransferConnection(_model); + var ids = _model.ApplicationAndSenderHashedId.Split("|"); + + //Assert + var redirectToActionResult = result as RedirectToActionResult; + redirectToActionResult.RouteValues["AccountHashedId"].Should().Be(_model.AccountHashedId); + redirectToActionResult.RouteValues["EncodedPledgeApplicationId"].Should().Be(ids[0]); + redirectToActionResult.RouteValues["TransferSenderId"].Should().Be(ids[1]); + redirectToActionResult.RouteValues["AccountLegalEntityHashedId"].Should().Be(_model.AccountLegalEntityHashedId); + } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Mappers/Cohort/SelectFundingRequestToSelectFundingViewModelMapperTests.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Mappers/Cohort/SelectFundingRequestToSelectFundingViewModelMapperTests.cs index 520c735a..95fb333e 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Mappers/Cohort/SelectFundingRequestToSelectFundingViewModelMapperTests.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Mappers/Cohort/SelectFundingRequestToSelectFundingViewModelMapperTests.cs @@ -80,4 +80,10 @@ public void HasAdditionalReservationFundsAvailableIsMappedCorrectly() { _result.HasAdditionalReservationFundsAvailable.Should().Be(_fundingOptionsResponse.HasAdditionalReservationFundsAvailable); } + + [Test] + public void HasLtmTransfersAvailableIsMappedCorrectly() + { + _result.HasLtmTransfersAvailable.Should().Be(_fundingOptionsResponse.HasLtmTransfersAvailable); + } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Mappers/Cohort/WhenMappingBaseSelectProviderRequestToLevyConnectionViewModelTests.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Mappers/Cohort/WhenMappingBaseSelectProviderRequestToLevyConnectionViewModelTests.cs new file mode 100644 index 00000000..c727bb52 --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Mappers/Cohort/WhenMappingBaseSelectProviderRequestToLevyConnectionViewModelTests.cs @@ -0,0 +1,75 @@ +using FluentAssertions; +using SFA.DAS.EmployerCommitmentsV2.Contracts; +using SFA.DAS.EmployerCommitmentsV2.Services.Approvals.Responses; +using SFA.DAS.EmployerCommitmentsV2.Web.Mappers.Cohort; +using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; +using SFA.DAS.Encoding; + +namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Mappers.Cohort; + +[TestFixture] +public class WhenMappingBaseSelectProviderRequestToLevyConnectionViewModelTests +{ + private Mock _approvalsApiClient; + private Mock _encodingService; + private BaseSelectProviderRequestToSelectAcceptedLevyTransferConnectionViewModelMapper _mapper; + private BaseSelectProviderRequest _request; + private GetSelectLevyTransferConnectionResponse _response; + + [SetUp] + public void Arrange() + { + var autoFixture = new Fixture(); + _approvalsApiClient = new Mock(); + _encodingService = new Mock(); + _request = autoFixture.Create(); + _response = autoFixture.Create(); + + _approvalsApiClient.Setup(x => x.GetSelectLevyTransferConnection(_request.AccountId, CancellationToken.None)) + .ReturnsAsync(_response); + _encodingService.Setup(x => x.Encode(It.IsAny(), EncodingType.PledgeApplicationId)).Returns((long input, EncodingType _) => input.ToString() + "AppId"); + _encodingService.Setup(x => x.Encode(It.IsAny(), EncodingType.PledgeId)).Returns((long input, EncodingType _) => input.ToString() + "PledgeId"); + _encodingService.Setup(x => x.Encode(It.IsAny(), EncodingType.PublicAccountId)).Returns((long input, EncodingType _) => input.ToString() + "PublicId"); + + _mapper = new BaseSelectProviderRequestToSelectAcceptedLevyTransferConnectionViewModelMapper(_approvalsApiClient.Object, _encodingService.Object); + } + + [Test] + public async Task Then_AccountId_Is_Mapped() + { + //Act + var result = await _mapper.Map(_request); + + //Assert + _approvalsApiClient.Verify(x => x.GetSelectLevyTransferConnection(_request.AccountId, CancellationToken.None)); + } + + [Test] + public async Task Then_AccountHashedId_Is_Mapped() + { + //Act + var result = await _mapper.Map(_request); + + //Assert + result.AccountHashedId.Should().Be(_request.AccountHashedId); + } + + [Test] + public async Task Then_List_Of_Applications_Is_Mapped() + { + //Act + var result = await _mapper.Map(_request); + + //Assert + result.Applications.Should().BeEquivalentTo(_response.Applications.Select(x => new LevyTransferDisplayConnection() + { + Id = x.Id, + ApplicationHashedId = x.Id + "AppId", + SendingEmployerPublicHashedId = x.SenderEmployerAccountId + "PublicId", + OpportunityHashedId = x.OpportunityId + "PledgeId", + ApplicationAndSenderHashedId = x.Id + "AppId" + "|" + x.SenderEmployerAccountId + "PublicId", + DisplayName = (x.IsNamePublic ? x.SenderEmployerAccountName : "Opportunity") + $" ({x.OpportunityId + "PledgeId"}) - £{x.TotalAmount.ToString("N")}" + })); + } + +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Validators/SelectAcceptedLevyTransferConnectionViewModelValidatorTests.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Validators/SelectAcceptedLevyTransferConnectionViewModelValidatorTests.cs new file mode 100644 index 00000000..5ebb35f8 --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Validators/SelectAcceptedLevyTransferConnectionViewModelValidatorTests.cs @@ -0,0 +1,33 @@ +using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; +using SFA.DAS.EmployerCommitmentsV2.Web.Validators; + +namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Validators; + +public class SelectAcceptedLevyTransferConnectionViewModelValidatorTests : ValidatorTestBase +{ + [Test] + [InlineAutoData("5143541", true)] + [InlineAutoData(" ", false)] + [InlineAutoData("", false)] + [InlineAutoData(null, false)] + public void WhenValidatingSelectAcceptedLevyTransferConnection_ValidateTheAccountHashedId(string accountHashedId, bool expectedValid, SelectAcceptedLevyTransferConnectionViewModel viewModel) + { + //Arrange + viewModel.AccountHashedId = accountHashedId; + + //Assert + AssertValidationResult(x => x.AccountHashedId, viewModel, expectedValid); + } + + [Test] + [InlineAutoData(" ", false, "Select a transfer")] + [InlineAutoData("", false, "Select a transfer")] + public void WhenValidatingSelectTransferConnection_ValidateTransferConnectionCode(string selectedCode, bool expectedValid, string errorMessage, SelectAcceptedLevyTransferConnectionViewModel viewModel) + { + //Arrange + viewModel.ApplicationAndSenderHashedId = selectedCode; + + //Assert + AssertValidationResult(x => x.ApplicationAndSenderHashedId, viewModel, expectedValid, errorMessage); + } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Validators/SelectTransferConnectionViewModelValidatorTests.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Validators/SelectTransferConnectionViewModelValidatorTests.cs index 55068437..12266ffc 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Validators/SelectTransferConnectionViewModelValidatorTests.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web.UnitTests/Validators/SelectTransferConnectionViewModelValidatorTests.cs @@ -20,9 +20,9 @@ public void WhenValidatingSelectTransferConnection_ValidateTheAccountHashedId(st } [Test] - [InlineAutoData(" ", false, "Please select a connection")] - [InlineAutoData("", false, "Please select a connection")] - [InlineAutoData(null, false, "Please select a connection")] + [InlineAutoData(" ", false, "Select a connection")] + [InlineAutoData("", false, "Select a connection")] + [InlineAutoData(null, false, "Select a connection")] [InlineAutoData("CCC", true, null)] public void WhenValidatingSelectTransferConnection_ValidateTransferConnectionCode(string transferConnectionCode, bool expectedValid, string errorMessage, SelectTransferConnectionViewModel viewModel) { diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Controllers/CohortController.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/Controllers/CohortController.cs index 43304f9c..a7c3d34d 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web/Controllers/CohortController.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Controllers/CohortController.cs @@ -564,11 +564,12 @@ public async Task SetFundingType(SelectFundingViewModel selectedFu FundingType = selectedFunding.FundingType }; - if (selectedFunding.FundingType == FundingType.DirectTransfers) + return selectedFunding.FundingType switch { - return RedirectToAction("SelectDirectTransferConnection", redirectRequest); - } - return RedirectToAction("SelectProvider", redirectRequest); + FundingType.DirectTransfers => RedirectToAction("SelectDirectTransferConnection", redirectRequest), + FundingType.LtmTransfers => RedirectToAction("SelectAcceptedLevyTransferConnection", redirectRequest), + _ => RedirectToAction("SelectProvider", redirectRequest) + }; } [HttpGet] @@ -594,6 +595,31 @@ public ActionResult SelectDirectTransferConnection(SelectTransferConnectionViewM }); } + [HttpGet] + [Route("add/select-funding/select-accepted-levy-connection")] + public async Task SelectAcceptedLevyTransferConnection(BaseSelectProviderRequest request) + { + var viewModel = await _modelMapper.Map(request); + + return View(viewModel); + } + + [HttpPost] + [Route("add/select-funding/select-accepted-levy-connection")] + public ActionResult SelectAcceptedLevyTransferConnection(SelectAcceptedLevyTransferConnectionViewModel selectedLevyTransferConnection) + { + var ids = selectedLevyTransferConnection.ApplicationAndSenderHashedId.Split('|'); + + return RedirectToAction("SelectProvider", new BaseSelectProviderRequest + { + AccountHashedId = selectedLevyTransferConnection.AccountHashedId, + EncodedPledgeApplicationId = ids[0], + TransferSenderId = ids[1], + AccountLegalEntityHashedId = selectedLevyTransferConnection.AccountLegalEntityHashedId, + }); + } + + [HttpGet] [Route("AgreementNotSigned")] public async Task AgreementNotSigned(LegalEntitySignedAgreementViewModel viewModel) diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Mappers/Cohort/BaseSelectProviderRequestToSelectLevyApplicationViewModelMapper.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/Mappers/Cohort/BaseSelectProviderRequestToSelectLevyApplicationViewModelMapper.cs new file mode 100644 index 00000000..0348db37 --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Mappers/Cohort/BaseSelectProviderRequestToSelectLevyApplicationViewModelMapper.cs @@ -0,0 +1,68 @@ +using SFA.DAS.CommitmentsV2.Shared.Interfaces; +using SFA.DAS.EmployerCommitmentsV2.Contracts; +using SFA.DAS.EmployerCommitmentsV2.Services.Approvals.Responses; +using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; +using SFA.DAS.Encoding; + +namespace SFA.DAS.EmployerCommitmentsV2.Web.Mappers.Cohort; + +public class BaseSelectProviderRequestToSelectAcceptedLevyTransferConnectionViewModelMapper : IMapper +{ + private readonly IApprovalsApiClient _approvalsApiClient; + private readonly IEncodingService _encodingService; + + public BaseSelectProviderRequestToSelectAcceptedLevyTransferConnectionViewModelMapper(IApprovalsApiClient approvalsApiClient, IEncodingService encodingService) + { + _approvalsApiClient = approvalsApiClient; + _encodingService = encodingService; + } + + public async Task Map(BaseSelectProviderRequest source) + { + var result = await _approvalsApiClient.GetSelectLevyTransferConnection(source.AccountId); + + return new SelectAcceptedLevyTransferConnectionViewModel + { + AccountHashedId = source.AccountHashedId, + Applications = result.Applications == null ? new List() : + result.Applications.Select(x => new LevyTransferDisplayConnection() + { + Id = x.Id, + ApplicationHashedId = GetApplicationHashedId(x), + SendingEmployerPublicHashedId = GetSendingEmployerPublicHashedId(x), + OpportunityHashedId = GetOpportunityHashedId(x), + DisplayName = BuildTitle(x), + ApplicationAndSenderHashedId = $"{GetApplicationHashedId(x)}|{GetSendingEmployerPublicHashedId(x)}" + + }).ToList() + }; + } + + private string GetOpportunityHashedId(LevyTransferConnection x) + { + return _encodingService.Encode(x.OpportunityId, EncodingType.PledgeId); + } + + private string GetSendingEmployerPublicHashedId(LevyTransferConnection x) + { + return _encodingService.Encode(x.SenderEmployerAccountId, EncodingType.PublicAccountId); + } + + private string GetApplicationHashedId(LevyTransferConnection x) + { + return _encodingService.Encode(x.Id, EncodingType.PledgeApplicationId); + } + + private string BuildTitle(LevyTransferConnection levyTransferConnection) + { + string title = "Opportunity"; + string hashedId = GetOpportunityHashedId(levyTransferConnection); + if (levyTransferConnection.IsNamePublic) + { + title = levyTransferConnection.SenderEmployerAccountName; + } + + title += $" ({hashedId}) - £{levyTransferConnection.TotalAmount.ToString("N")}"; + return title; + } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Mappers/Cohort/SelectFundingViewModelMapper.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/Mappers/Cohort/SelectFundingViewModelMapper.cs index 871bac73..a3bfcaa2 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web/Mappers/Cohort/SelectFundingViewModelMapper.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Mappers/Cohort/SelectFundingViewModelMapper.cs @@ -1,7 +1,5 @@ -using Microsoft.Azure.KeyVault.WebKey; -using SFA.DAS.CommitmentsV2.Shared.Interfaces; +using SFA.DAS.CommitmentsV2.Shared.Interfaces; using SFA.DAS.EmployerCommitmentsV2.Contracts; -using SFA.DAS.EmployerCommitmentsV2.Services.Approvals.Responses; using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; namespace SFA.DAS.EmployerCommitmentsV2.Web.Mappers.Cohort; @@ -35,6 +33,7 @@ public async Task Map(SelectFundingRequest source) EncodedPledgeApplicationId = source.EncodedPledgeApplicationId, IsLevyAccount = selectFundingDetails.IsLevyAccount, HasDirectTransfersAvailable = selectFundingDetails.HasDirectTransfersAvailable, + HasLtmTransfersAvailable = selectFundingDetails.HasLtmTransfersAvailable, HasUnallocatedReservationsAvailable = selectFundingDetails.HasUnallocatedReservationsAvailable, HasAdditionalReservationFundsAvailable = selectFundingDetails.HasAdditionalReservationFundsAvailable }; diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Cohort/SelectAcceptedLevyTransferConnectionViewModel.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Cohort/SelectAcceptedLevyTransferConnectionViewModel.cs new file mode 100644 index 00000000..c111731c --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Cohort/SelectAcceptedLevyTransferConnectionViewModel.cs @@ -0,0 +1,20 @@ +namespace SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; + +public class SelectAcceptedLevyTransferConnectionViewModel +{ + public string AccountHashedId { get; set; } + public string AccountLegalEntityHashedId { get; set; } + public string ApplicationAndSenderHashedId { get; set; } + public List Applications { get; set; } +} + + +public class LevyTransferDisplayConnection +{ + public long Id { get; set; } + public string ApplicationHashedId { get; set; } + public string OpportunityHashedId { get; set; } + public string SendingEmployerPublicHashedId { get; set; } + public string DisplayName { get; set; } + public string ApplicationAndSenderHashedId { get; set; } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Cohort/SelectFundingViewModel.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Cohort/SelectFundingViewModel.cs index 1e9d76e0..044ac536 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Cohort/SelectFundingViewModel.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Models/Cohort/SelectFundingViewModel.cs @@ -16,6 +16,7 @@ public class SelectFundingViewModel public bool IsLevyAccount { get; set; } public bool HasDirectTransfersAvailable { get; set; } + public bool HasLtmTransfersAvailable { get; set; } public bool HasUnallocatedReservationsAvailable { get; set; } public bool HasAdditionalReservationFundsAvailable { get; set; } public FundingType? FundingType { get; set; } @@ -27,5 +28,6 @@ public enum FundingType : short DirectTransfers = 1, UnallocatedReservations = 2, AdditionalReservations = 3, - CurrentLevy = 4 + CurrentLevy = 4, + LtmTransfers = 5 } diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Validators/SelectAcceptedLevyTransferConnectionViewModelValidator.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/Validators/SelectAcceptedLevyTransferConnectionViewModelValidator.cs new file mode 100644 index 00000000..8d5e0292 --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Validators/SelectAcceptedLevyTransferConnectionViewModelValidator.cs @@ -0,0 +1,12 @@ +using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort; + +namespace SFA.DAS.EmployerCommitmentsV2.Web.Validators; + +public class SelectAcceptedLevyTransferConnectionViewModelValidator : AbstractValidator +{ + public SelectAcceptedLevyTransferConnectionViewModelValidator() + { + RuleFor(x => x.AccountHashedId).NotEmpty(); + RuleFor(x => x.ApplicationAndSenderHashedId).NotEmpty().WithMessage("Select a transfer"); + } +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Validators/SelectTransferConnectionViewModelValidator.cs b/src/SFA.DAS.EmployerCommitmentsV2.Web/Validators/SelectTransferConnectionViewModelValidator.cs index 1100a407..db2384f5 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web/Validators/SelectTransferConnectionViewModelValidator.cs +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Validators/SelectTransferConnectionViewModelValidator.cs @@ -7,6 +7,6 @@ public class SelectTransferConnectionViewModelValidator : AbstractValidator x.AccountHashedId).NotEmpty(); - RuleFor(x => x.TransferConnectionCode).NotEmpty().WithMessage("Please select a connection"); + RuleFor(x => x.TransferConnectionCode).NotEmpty().WithMessage("Select a connection"); } } \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectAcceptedLevyTransferConnection.cshtml b/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectAcceptedLevyTransferConnection.cshtml new file mode 100644 index 00000000..bc198ad2 --- /dev/null +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectAcceptedLevyTransferConnection.cshtml @@ -0,0 +1,66 @@ +@using Microsoft.AspNetCore.Mvc.TagHelpers +@using SFA.DAS.CommitmentsV2.Shared.Extensions +@using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort +@using SFA.DAS.EmployerUrlHelper.Mvc + +@{ + ViewBag.Title = "Select transfer funds"; + ViewBag.GaData.Vpv = "/unapproved/add/select-funding/select-accepted-levy-connection"; +} + +@model SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort.SelectAcceptedLevyTransferConnectionViewModel + +
+
+ + + +

@ViewBag.Title

+ +

+ These are your approved transfer funds. +

+

+ You can only use one transfer per application, but you can add multiple apprenticeships to that transfer if funding amount allows. +

+

+ If you cannot find the transfer you need, you can manage your transfers (opens in new tab) +

+ +
+ +

Which transfer would you like to select?

+ + @Html.AntiForgeryToken() + +
+
+ @if (!ViewData.ModelState.IsValid) + { + + Error: @ViewData.ModelState[nameof(SelectAcceptedLevyTransferConnectionViewModel.ApplicationAndSenderHashedId)].Errors.First().ErrorMessage + + } +
+ @foreach (var entity in Model.Applications) + { +
+ + +
+ } +
+
+
+ +
+ +
+
+ +@section Back +{ + Back +} \ No newline at end of file diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectDirectTransferConnection.cshtml b/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectDirectTransferConnection.cshtml index a0e8b52d..993d98d7 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectDirectTransferConnection.cshtml +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectDirectTransferConnection.cshtml @@ -1,9 +1,10 @@ @using Microsoft.AspNetCore.Mvc.TagHelpers +@using SFA.DAS.CommitmentsV2.Shared.Extensions @using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort @using SFA.DAS.EmployerUrlHelper.Mvc @{ - ViewBag.Title = "Select a connection to transfer from"; + ViewBag.Title = "Select a connection"; ViewBag.GaData.Vpv = "/unapproved/add/select-funding/select-direct-connection"; } @@ -39,7 +40,7 @@ @Html.AntiForgeryToken() -
+
@if (!ViewData.ModelState.IsValid) { @@ -56,7 +57,6 @@ @entity.FundingEmployerAccountName
-
}
diff --git a/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectFunding.cshtml b/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectFunding.cshtml index 9a5f5b4f..b358b5fb 100644 --- a/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectFunding.cshtml +++ b/src/SFA.DAS.EmployerCommitmentsV2.Web/Views/Cohort/SelectFunding.cshtml @@ -17,15 +17,26 @@

@ViewBag.Title

- You can choose existing funding that you have previously applied for or - reserve new funding. + @if (Model.IsLevyAccount) + { + + You can choose from funds you’ve already set up or use your current levy funds. + + + } + else + { + + You can choose from funds you’ve already set up or reserve new funding. + + }
@Html.AntiForgeryToken() -

What funding would you like to select?

+

Which funding would you like to select?

@@ -36,32 +47,35 @@ }
- @if(Model.HasDirectTransfersAvailable) + + @if (Model.HasLtmTransfersAvailable) + { +
+ + +
+ } + @if (Model.HasDirectTransfersAvailable) {
- - + +
} - @if(!Model.IsLevyAccount && Model.HasUnallocatedReservationsAvailable) + @if (!Model.IsLevyAccount && Model.HasUnallocatedReservationsAvailable) {
- +