Skip to content

Commit

Permalink
Add new fields to CSV download
Browse files Browse the repository at this point in the history
  • Loading branch information
dashton82 committed Apr 16, 2020
1 parent a2d4ea4 commit 8f0f38b
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public DetailsViewModelMapperTestsFixture()
.ReturnsAsync(Cohort);
CommitmentsApiClient.Setup(x => x.GetDraftApprenticeships(It.IsAny<long>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(DraftApprenticeshipsResponse);
CommitmentsApiClient.Setup(x => x.GetLegalEntity(It.IsAny<long>(), It.IsAny<CancellationToken>()))
CommitmentsApiClient.Setup(x => x.GetAccountLegalEntity(It.IsAny<long>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(AccountLegalEntityResponse);

AccountApiClient = new Mock<IAccountApiClient>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AutoFixture.NUnit3;
using System;
using AutoFixture.NUnit3;
using FluentAssertions;
using NUnit.Framework;
using SFA.DAS.CommitmentsV2.Api.Types.Responses;
Expand Down Expand Up @@ -56,6 +57,33 @@ public void Then_Maps_PlannedStartDate(
result.PlannedStartDate.Should().Be(source.StartDate.ToString("MMM yyyy"));
}

[Test, AutoData]
public void Then_Maps_PausedDate(
GetApprenticeshipsResponse.ApprenticeshipDetailsResponse source)
{
ApprenticeshipDetailsCsvModel result = source;

result.PausedDate.Should().Be(source.PauseDate.ToString("MMM yyyy"));
}

[Test, AutoData]
public void Then_Maps_DateOfBirth(GetApprenticeshipsResponse.ApprenticeshipDetailsResponse source)
{
ApprenticeshipDetailsCsvModel result = source;

result.DateOfBirth.Should().Be(source.DateOfBirth.ToString("dd MMM yyyy"));
}

[Test, AutoData]
public void Then_Maps_Empty_If_No_PausedDate(
GetApprenticeshipsResponse.ApprenticeshipDetailsResponse source)
{
source.PauseDate = DateTime.MinValue;
ApprenticeshipDetailsCsvModel result = source;

result.PausedDate.Should().BeEmpty();
}

[Test, AutoData]
public void Then_Maps_Status(
GetApprenticeshipsResponse.ApprenticeshipDetailsResponse source)
Expand All @@ -64,6 +92,42 @@ public void Then_Maps_Status(

result.Status.Should().Be(source.ApprenticeshipStatus.GetDescription());
}

[Test, AutoData]
public void Then_Maps_Reference(
GetApprenticeshipsResponse.ApprenticeshipDetailsResponse source)
{
ApprenticeshipDetailsCsvModel result = source;

result.CohortReference.Should().Be(source.CohortReference);
}

[Test, AutoData]
public void Then_Maps_Your_Reference(
GetApprenticeshipsResponse.ApprenticeshipDetailsResponse source)
{
ApprenticeshipDetailsCsvModel result = source;

result.EmployerRef.Should().Be(source.EmployerRef);
}

[Test, AutoData]
public void Then_Maps_Uln(
GetApprenticeshipsResponse.ApprenticeshipDetailsResponse source)
{
ApprenticeshipDetailsCsvModel result = source;

result.Uln.Should().Be(source.Uln);
}

[Test, AutoData]
public void Then_Maps_TotalAgreedPrice(
GetApprenticeshipsResponse.ApprenticeshipDetailsResponse source)
{
ApprenticeshipDetailsCsvModel result = source;

result.TotalAgreedPrice.Should().Be($"{source.TotalAgreedPrice.Value as object:n0}");
}

[Test, MoqAutoData]
public void Then_Maps_Alerts(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Globalization;
using CsvHelper.Configuration.Attributes;
using SFA.DAS.CommitmentsV2.Api.Types.Responses;
using SFA.DAS.CommitmentsV2.Shared.Extensions;
Expand All @@ -16,8 +18,20 @@ public class ApprenticeshipDetailsCsvModel
public string PlannedStartDate { get; private set; }
[Name("Planned end date")]
public string PlannedEndDate { get ; private set ; }
[Name("Paused Date")]
public string PausedDate { get; private set; }
[Name("Training provider")]
public string Provider { get; private set; }
[Name("Reference")]
public string CohortReference { get; private set; }
[Name("Uln")]
public string Uln { get; private set; }
[Name("Date of Birth")]
public string DateOfBirth { get; private set; }
[Name("Total agreed apprenticeship price")]
public string TotalAgreedPrice { get; private set; }
[Name("Your Reference")]
public string EmployerRef { get; private set; }
[Name("Status")]
public string Status { get ; private set ; }
[Name("Alerts")]
Expand All @@ -32,6 +46,12 @@ public static implicit operator ApprenticeshipDetailsCsvModel(GetApprenticeships
CourseName = model.CourseName,
PlannedStartDate = model.StartDate.ToGdsFormatWithoutDay(),
PlannedEndDate = model.EndDate.ToGdsFormatWithoutDay(),
PausedDate = model.PauseDate != DateTime.MinValue ? model.PauseDate.ToGdsFormatWithoutDay() : "",
CohortReference = model.CohortReference,
EmployerRef = model.EmployerRef,
Uln = model.Uln,
DateOfBirth = model.DateOfBirth.ToGdsFormat(),
TotalAgreedPrice = $"{model.TotalAgreedPrice.Value as object:n0}",
Status = model.ApprenticeshipStatus.GetDescription(),
Alerts = GenerateAlerts(model.Alerts)
};
Expand Down

0 comments on commit 8f0f38b

Please sign in to comment.