Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APPMAN-1019 LTM transfers #536

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
consumed the new field
  • Loading branch information
Pauljgraham committed Nov 28, 2024
commit 1b4d3fb53dbe0eea72a022a38f8d3bfe64d5effb
Original file line number Diff line number Diff line change
@@ -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<SelectFundingViewModel>();

_controller = new CohortController(Mock.Of<ICommitmentsApiClient>(),
Mock.Of<ILogger<CohortController>>(),
Mock.Of<ILinkGenerator>(),
Mock.Of<IModelMapper>(),
Mock.Of<IEncodingService>(),
Mock.Of<IApprovalsApiClient>(),
Mock.Of<ICacheStorageService>());
}

[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("SelectDirectTransferConnection");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ public void HasAdditionalReservationFundsAvailableIsMappedCorrectly()
{
_result.HasAdditionalReservationFundsAvailable.Should().Be(_fundingOptionsResponse.HasAdditionalReservationFundsAvailable);
}

[Test]
public void HasLtmTransfersAvailableIsMappedCorrectly()
{
_result.HasLtmTransfersAvailable.Should().Be(_fundingOptionsResponse.HasLtmTransfersAvailable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,12 @@ public async Task<ActionResult> 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("SelectDirectTransferConnection", redirectRequest),
_ => RedirectToAction("SelectProvider", redirectRequest)
};
}

[HttpGet]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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;
Expand All @@ -27,6 +26,7 @@ public async Task<SelectFundingViewModel> Map(SelectFundingRequest source)
EncodedPledgeApplicationId = source.EncodedPledgeApplicationId,
IsLevyAccount = selectFundingDetails.IsLevyAccount,
HasDirectTransfersAvailable = selectFundingDetails.HasDirectTransfersAvailable,
HasLtmTransfersAvailable = selectFundingDetails.HasLtmTransfersAvailable,
HasUnallocatedReservationsAvailable = selectFundingDetails.HasUnallocatedReservationsAvailable,
HasAdditionalReservationFundsAvailable = selectFundingDetails.HasAdditionalReservationFundsAvailable
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -27,5 +28,6 @@ public enum FundingType : short
DirectTransfers = 1,
UnallocatedReservations = 2,
AdditionalReservations = 3,
CurrentLevy = 4
CurrentLevy = 4,
LtmTransfers = 5
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,34 @@
</span>
}
<div class="govuk-radios">
@if(Model.HasDirectTransfersAvailable)
@if (Model.HasDirectTransfersAvailable)
{
<div class="govuk-radios__item" id="radio-item-funding-type">
<input class="govuk-radios__input" id="FundingType-1" name="FundingType" type="radio" value="1">
<label class="govuk-label govuk-radios__label" for="FundingType-1">
@if (Model.IsLevyAccount)
{
<span>Transfer funds from a connection</span>
<p class="govuk-hint">
A levy paying business that has set up a connection with you in the service
</p>
}
else
{
<span>Direct transfer funds from a connection</span>
<p class="govuk-hint">
A direct transfer from an organisation you're connected with
</p>
}
</label>
<input class="govuk-radios__input" id="FundingType-5" name="FundingType" type="radio" value="5">
<label class="govuk-label govuk-radios__label" for="FundingType-5">
<span>Transfer funds</span>
<p class="govuk-hint">
A funding opportunity (pledge) from a levy-paying business
</p>
</label>
</div>
}
@if (Model.HasDirectTransfersAvailable)
{
<div class="govuk-radios__item" id="radio-item-funding-type">
<input class="govuk-radios__input" id="FundingType-1" name="FundingType" type="radio" value="1">
<label class="govuk-label govuk-radios__label" for="FundingType-1">
<span>Transfer funds from a connection</span>
<p class="govuk-hint">
A levy-paying business that has set up a connection with you in the service
</p>
</label>
</div>
}
@if(!Model.IsLevyAccount && Model.HasUnallocatedReservationsAvailable)
@if (!Model.IsLevyAccount && Model.HasUnallocatedReservationsAvailable)
{
<div class="govuk-radios__item" id="radio-item-funding-type">
<input class="govuk-radios__input" id="FundingType-2" name="FundingType" type="radio" value="2">
<input class="govuk-radios__input" id="FundingType-2" name="FundingType" type="radio" value="2">
<label class="govuk-label govuk-radios__label" for="FundingType-2">
Reserved funds
<p class="govuk-hint">
Expand All @@ -70,7 +72,7 @@
@if (!Model.IsLevyAccount && Model.HasAdditionalReservationFundsAvailable)
{
<div class="govuk-radios__item" id="radio-item-funding-type">
<input class="govuk-radios__input" id="FundingType-3" name="FundingType" type="radio" value="3">
<input class="govuk-radios__input" id="FundingType-3" name="FundingType" type="radio" value="3">
<label class="govuk-label govuk-radios__label" for="FundingType-3">
I want to reserve new funds
<p class="govuk-hint">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class GetSelectFundingOptionsResponse
{
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; }
}