Skip to content

Commit

Permalink
Merge pull request #316 from SkillsFundingAgency/FJA-5_new_fjaa_deliv…
Browse files Browse the repository at this point in the history
…ery_model

Fja 5 new fjaa delivery model
  • Loading branch information
alireid authored Jul 4, 2022
2 parents 4d2cc3b + 9c17421 commit 7528610
Show file tree
Hide file tree
Showing 20 changed files with 226 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal CommitmentsOuterApiBuilder WithCourseDeliveryModels()
.WithHeader("Content-Type", "application/json")
.WithBodyAsJson(new
{
DeliveryModels = new[] { "Regular", "PortableFlexiJob" },
DeliveryModels = new[] { "Regular", "PortableFlexiJob"},
}));

_server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using AutoFixture;
using Moq;
using NUnit.Framework;
using SFA.DAS.Authorization.Services;
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.CommitmentsV2.Api.Types.Responses;
using SFA.DAS.CommitmentsV2.Shared.Models;
Expand All @@ -31,33 +32,37 @@ public class EditApprenticeshipRequestViewModelToSelectDeliveryModelViewModelMap
private ProviderCourseDeliveryModels _providerCourseDeliveryModels;
private SelectDeliveryModelViewModel _result;
private long _cohortId;
private long _accountLegalEntityId;
private Fixture _autoFixture;

[SetUp]
public async Task Arrange()
{
_autoFixture = new Fixture();
_cohortId = _autoFixture.Create<long>();
_accountLegalEntityId = _autoFixture.Create<long>();

_standardTrainingProgrammes = _autoFixture.CreateMany<TrainingProgramme>().ToList();
_allTrainingProgrammes = _autoFixture.CreateMany<TrainingProgramme>().ToList();
_providerCourseDeliveryModels = _autoFixture.Create<ProviderCourseDeliveryModels>();

_getApprenticeshipResponse = _autoFixture.Build<GetApprenticeshipResponse>()
.With(x => x.CohortId, _cohortId)
.With(x => x.AccountLegalEntityId, _accountLegalEntityId)
.Create();

_getCohortResponse = _autoFixture.Build<GetCohortResponse>()
.With(x => x.LevyStatus, ApprenticeshipEmployerType.Levy)
.With(x => x.WithParty, Party.Employer)
.With(x => x.AccountLegalEntityId, _accountLegalEntityId)
.Without(x => x.TransferSenderId)
.Create();

_source = _autoFixture.Build<EditApprenticeshipRequestViewModel>()
.With(x=>x.DateOfBirth, new DateModel())
.With(x=>x.StartDate, new MonthYearModel(""))
.With(x=>x.EndDate, new MonthYearModel(""))
.With(x=>x.EmploymentEndDate, new MonthYearModel(""))
.With(x => x.DateOfBirth, new DateModel())
.With(x => x.StartDate, new MonthYearModel(""))
.With(x => x.EndDate, new MonthYearModel(""))
.With(x => x.EmploymentEndDate, new MonthYearModel(""))
.With(x => x.DeliveryModel, DeliveryModel.PortableFlexiJob)
.Create();

Expand All @@ -80,7 +85,7 @@ public async Task Arrange()
});

_approvalsApiClient = new Mock<IApprovalsApiClient>();
_approvalsApiClient.Setup(x => x.GetProviderCourseDeliveryModels(_getCohortResponse.ProviderId.Value, _source.CourseCode,
_approvalsApiClient.Setup(x => x.GetProviderCourseDeliveryModels(_getCohortResponse.ProviderId.Value, _source.CourseCode, _accountLegalEntityId,
It.IsAny<CancellationToken>())).ReturnsAsync(_providerCourseDeliveryModels);

_mapper = new EditApprenticeshipRequestViewModelToSelectDeliveryModelViewModelMapper(_commitmentsApiClient.Object, _approvalsApiClient.Object);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using AutoFixture;
using Moq;
using NUnit.Framework;
using SFA.DAS.Authorization.Services;
using SFA.DAS.CommitmentsV2.Types;
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals;
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals.Responses;
using SFA.DAS.EmployerCommitmentsV2.Web.Mappers.Cohort;
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Cohort;
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Shared;
using SFA.DAS.EmployerCommitmentsV2.Web.Services;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -18,9 +20,11 @@ public class ApprenticeRequestToSelectDeliveryModelViewModelMapperTests
private ApprenticeRequestToSelectDeliveryModelViewModelMapper _mapper;
private ApprenticeRequest _source;
private Mock<IApprovalsApiClient> _approvalsApiClient;
private Mock<IAuthorizationService> _authService;
private ProviderCourseDeliveryModels _providerCourseDeliveryModels;
private long _providerId;
private string _courseCode;
private long _accountLegalEntityId;
private SelectDeliveryModelViewModel _result;

[SetUp]
Expand All @@ -30,20 +34,22 @@ public async Task Arrange()

_providerId = autoFixture.Create<long>();
_courseCode = autoFixture.Create<string>();
_accountLegalEntityId = autoFixture.Create<long>();

_source = autoFixture.Build<ApprenticeRequest>()
.With(x => x.StartMonthYear, "062020")
.With(x => x.AccountId, 12345)
.With(x => x.CourseCode, "Course1")
.With(x => x.ProviderId, _providerId)
.With(x => x.AccountLegalEntityId, _accountLegalEntityId)
.With(x => x.CourseCode, _courseCode)
.With(x => x.DeliveryModel, DeliveryModel.PortableFlexiJob)
.Without(x => x.TransferSenderId).Create();

_providerCourseDeliveryModels = autoFixture.Create<ProviderCourseDeliveryModels>();

_approvalsApiClient = new Mock<IApprovalsApiClient>();
_approvalsApiClient.Setup(x => x.GetProviderCourseDeliveryModels(_providerId, _courseCode, It.IsAny<CancellationToken>())).ReturnsAsync(_providerCourseDeliveryModels);
_approvalsApiClient.Setup(x => x.GetProviderCourseDeliveryModels(_providerId, _courseCode, _accountLegalEntityId, It.IsAny<CancellationToken>())).ReturnsAsync(_providerCourseDeliveryModels);

_mapper = new ApprenticeRequestToSelectDeliveryModelViewModelMapper(_approvalsApiClient.Object);
_result = await _mapper.Map(TestHelper.Clone(_source));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,24 +556,6 @@ public async Task EmailOverlapIsMappedCorrectlyToDraftApprenticeshipAndToSummary
Assert.AreEqual(apprenticeshipId, course.DraftApprenticeships.First(x => x.HasOverlappingEmail).Id);
}

[Test]
public async Task EmailOverlapIsMappedCorrectlyToDraftApprenticeshipsAndToSummaryLineWhenTwoEmailOverlapsExistOnSameCourse()
{
var f = new DetailsViewModelMapperTestsFixture().WithTwoEmailOverlappingOnSameCourse();
var apprenticeshipId1 = f.EmailOverlapResponse.ApprenticeshipEmailOverlaps.First().Id;
var apprenticeshipId2 = f.EmailOverlapResponse.ApprenticeshipEmailOverlaps.Last().Id;

var result = await f.Map();
var course = result.Courses.FirstOrDefault();

Assert.NotNull(course);
Assert.NotNull(course.EmailOverlaps);
Assert.AreEqual(2, course.EmailOverlaps.NumberOfEmailOverlaps);
Assert.AreEqual(2, course.DraftApprenticeships.Count(x => x.HasOverlappingEmail));
Assert.IsTrue(course.DraftApprenticeships.First(x => x.Id == apprenticeshipId1).HasOverlappingEmail);
Assert.IsTrue(course.DraftApprenticeships.First(x => x.Id == apprenticeshipId2).HasOverlappingEmail);
}

[TestCase(true, true)]
[TestCase(false, false)]
public async Task ShowHasOverlappingUlnIsMappedCorrectlyWhenOverlap(bool hasOverlap, bool hasUlnOverlap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals.Responses;
using System.Threading;
using System.Threading.Tasks;
using SFA.DAS.EmployerCommitmentsV2.Web.Services;
using SFA.DAS.Authorization.Services;

namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Mappers.DraftApprenticeship
{
Expand All @@ -22,10 +24,12 @@ public class AddDraftApprenticeshipRequestToSelectDeliveryModelViewModelMapperTe
private Mock<ICommitmentsApiClient> _commitmentsApiClient;
private GetCohortResponse _getCohortResponse;
private Mock<IApprovalsApiClient> _approvalsApiClient;
private Mock<IAuthorizationService> _authService;
private ProviderCourseDeliveryModels _providerCourseDeliveryModels;
private long _providerId;
private string _courseCode;
private long _cohortId;
private long _accountLegalEntityId;
private SelectDeliveryModelViewModel _result;

[SetUp]
Expand All @@ -36,12 +40,14 @@ public async Task Arrange()
_providerId = autoFixture.Create<long>();
_courseCode = autoFixture.Create<string>();
_cohortId = autoFixture.Create<long>();
_accountLegalEntityId = autoFixture.Create<long>();

_source = autoFixture.Build<AddDraftApprenticeshipRequest>()
.With(x => x.StartMonthYear, "062020")
.With(x => x.CourseCode, "Course1")
.With(x => x.ProviderId, _providerId)
.With(x => x.CourseCode, _courseCode)
.With(x => x.AccountLegalEntityId, _accountLegalEntityId)
.With(x => x.CohortId, _cohortId)
.With(x => x.DeliveryModel, DeliveryModel.PortableFlexiJob)
.Create();
Expand All @@ -60,9 +66,10 @@ public async Task Arrange()
_providerCourseDeliveryModels = autoFixture.Create<ProviderCourseDeliveryModels>();

_approvalsApiClient = new Mock<IApprovalsApiClient>();
_approvalsApiClient.Setup(x => x.GetProviderCourseDeliveryModels(_providerId, _courseCode, It.IsAny<CancellationToken>())).ReturnsAsync(_providerCourseDeliveryModels);
_approvalsApiClient.Setup(x => x.GetProviderCourseDeliveryModels(_providerId, _courseCode, _accountLegalEntityId, It.IsAny<CancellationToken>())).ReturnsAsync(_providerCourseDeliveryModels);

_mapper = new AddDraftApprenticeshipRequestToSelectDeliveryModelViewModelMapper(_commitmentsApiClient.Object, _approvalsApiClient.Object);

_result = await _mapper.Map(TestHelper.Clone(_source));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using SFA.DAS.CommitmentsV2.Types;
using SFA.DAS.EmployerCommitmentsV2.Web.Mappers.DraftApprenticeship;
using SFA.DAS.EmployerCommitmentsV2.Web.Models.DraftApprenticeship;
using SFA.DAS.EmployerCommitmentsV2.Web.Services;
using SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Extensions;
using SFA.DAS.Encoding;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ public static string ToDescription(this DeliveryModel deliveryModel) =>
deliveryModel switch
{
DeliveryModel.PortableFlexiJob => "Portable flexi-job",
DeliveryModel.FlexiJobAgency => "Flexi-job agency",
_ => "Regular"
};

public static string ToIrregularDescription(this DeliveryModel deliveryModel) =>
deliveryModel switch
public static string ToIrregularDescription(this DeliveryModel deliveryModel)
{
return deliveryModel switch
{
DeliveryModel.PortableFlexiJob => "Portable flexi-job",
DeliveryModel.FlexiJobAgency => "Flexi-job agency",
_ => null,
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Shared;
using System.Linq;
using System.Threading.Tasks;
using SFA.DAS.EmployerCommitmentsV2.Web.Services;
using SFA.DAS.CommitmentsV2.Types;
using System.Collections.Generic;
using SFA.DAS.Authorization.Services;
using SFA.DAS.EmployerCommitmentsV2.Features;

namespace SFA.DAS.EmployerCommitmentsV2.Web.Mappers.Cohort
{
Expand All @@ -12,11 +17,11 @@ public class ApprenticeRequestToSelectDeliveryModelViewModelMapper : IMapper<App
private readonly IApprovalsApiClient _approvalsApiClient;

public ApprenticeRequestToSelectDeliveryModelViewModelMapper(IApprovalsApiClient approvalsApiClient)
=> _approvalsApiClient = approvalsApiClient;
=> (_approvalsApiClient) = (approvalsApiClient);

public async Task<SelectDeliveryModelViewModel> Map(ApprenticeRequest source)
{
var response = await _approvalsApiClient.GetProviderCourseDeliveryModels(source.ProviderId, source.CourseCode);
var response = await _approvalsApiClient.GetProviderCourseDeliveryModels(source.ProviderId, source.CourseCode, source.AccountLegalEntityId);

return new SelectDeliveryModelViewModel
{
Expand All @@ -29,7 +34,7 @@ public async Task<SelectDeliveryModelViewModel> Map(ApprenticeRequest source)
ProviderId = source.ProviderId,
ReservationId = source.ReservationId,
StartMonthYear = source.StartMonthYear,
TransferSenderId = source.TransferSenderId,
TransferSenderId = source.TransferSenderId
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Linq;
using System.Threading.Tasks;
using SFA.DAS.Authorization.Services;
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.CommitmentsV2.Shared.Interfaces;
using SFA.DAS.EmployerCommitmentsV2.Features;
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals;
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice;
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Shared;
Expand All @@ -21,7 +23,7 @@ public async Task<SelectDeliveryModelViewModel> Map(EditApprenticeshipRequestVie
var apprenticeship = await _commitmentsApiClient.GetApprenticeship(source.ApprenticeshipId);
var cohort = await _commitmentsApiClient.GetCohort(apprenticeship.CohortId);

var response = await _approvalsApiClient.GetProviderCourseDeliveryModels(cohort.ProviderId.HasValue ? cohort.ProviderId.Value : 0, source.CourseCode);
var response = await _approvalsApiClient.GetProviderCourseDeliveryModels(cohort.ProviderId.HasValue ? cohort.ProviderId.Value : 0, source.CourseCode, cohort.AccountLegalEntityId);

return new SelectDeliveryModelViewModel
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.Authorization.Services;
using SFA.DAS.CommitmentsV2.Api.Client;
using SFA.DAS.CommitmentsV2.Shared.Interfaces;
using SFA.DAS.CommitmentsV2.Types;
using SFA.DAS.EmployerCommitmentsV2.Features;
using SFA.DAS.EmployerCommitmentsV2.Services.Approvals;
using SFA.DAS.EmployerCommitmentsV2.Web.Models.DraftApprenticeship;
using SFA.DAS.EmployerCommitmentsV2.Web.Models.Shared;
using SFA.DAS.EmployerCommitmentsV2.Web.Services;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

Expand All @@ -20,7 +25,7 @@ public async Task<SelectDeliveryModelViewModel> Map(AddDraftApprenticeshipReques
{
var cohort = await _commitmentsApiClient.GetCohort(source.CohortId);

var response = await _approvalsApiClient.GetProviderCourseDeliveryModels(cohort.ProviderId.HasValue ? cohort.ProviderId.Value : 0, source.CourseCode);
var response = await _approvalsApiClient.GetProviderCourseDeliveryModels(cohort.ProviderId.HasValue ? cohort.ProviderId.Value : 0, source.CourseCode, source.AccountLegalEntityId);

return new SelectDeliveryModelViewModel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using SFA.DAS.CommitmentsV2.Types;
using SFA.DAS.EmployerCommitmentsV2.Web.Models.DraftApprenticeship;
using SFA.DAS.Encoding;
using SFA.DAS.EmployerCommitmentsV2.Web.Services;

namespace SFA.DAS.EmployerCommitmentsV2.Web.Mappers.DraftApprenticeship
{
Expand All @@ -16,7 +17,7 @@ public class EditDraftApprenticeshipViewModelMapper : IMapper<EditDraftApprentic
private readonly IEncodingService _encodingService;

public EditDraftApprenticeshipViewModelMapper(ICommitmentsApiClient commitmentsApiClient,
IEncodingService encodingService)
IEncodingService encodingService )
{
_commitmentsApiClient = commitmentsApiClient;
_encodingService = encodingService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class DetailsViewCourseGroupingModel
public string CourseName { get; set; }
public DeliveryModel DeliveryModel { get; set; }
public bool IsPortableFlexiJob => DeliveryModel == DeliveryModel.PortableFlexiJob;
public bool IsFlexiJobAgency => DeliveryModel == DeliveryModel.FlexiJobAgency;
public string DisplayCourseName => string.IsNullOrWhiteSpace(CourseName) ? "No training course" : CourseName;
public int Count => DraftApprenticeships?.Count ?? 0;
public FundingBandExcessModel FundingBandExcess { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<PackageReference Include="StructureMap.AspNetCore" Version="2.0.0" />
<PackageReference Include="WebEssentials.AspNetCore.CdnTagHelpers" Version="1.0.16" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Include="SFA.DAS.CommitmentsV2.Shared" Version="8.20.26" />
</ItemGroup>

<ItemGroup>
Expand All @@ -50,6 +51,9 @@
<Folder Include="Models\Apprentice\DataLock\" />
</ItemGroup>

<ItemGroup>
<None Remove="SFA.DAS.CommitmentsV2.Shared" />
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<dt class="govuk-summary-list__key"> Unique learner number </dt>
<dd class="govuk-summary-list__value"> @Model.OriginalApprenticeship.ULN</dd>
</div>
@if (Model.OriginalApprenticeship.DeliveryModel == DeliveryModel.PortableFlexiJob)
@if (Model.OriginalApprenticeship.DeliveryModel != DeliveryModel.Regular)
{
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key"> Apprenticeship delivery model</dt>
Expand Down
Loading

0 comments on commit 7528610

Please sign in to comment.