diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs index 296af0a517..ac21a2fe51 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Domain/EmailTemplates/EmailTemplateBuilderTests.cs @@ -1,4 +1,5 @@ using FluentAssertions; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; using NUnit.Framework; using SFA.DAS.FindApprenticeshipJobs.Application.Commands.SavedSearch.SendNotification; using SFA.DAS.FindApprenticeshipJobs.Domain.EmailTemplates; @@ -163,8 +164,9 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Correct_Snippet() }, Distance = 10, TrainingCourse = "Software Engineering", - Wage = "�30,000", - ClosingDate = "2022-12-31" + Wage = "£30,000", + ClosingDate = "2022-12-31", + VacancySource = "FAA" } }; @@ -176,7 +178,7 @@ ABC Company * Distance: 10 miles * Training course: Software Engineering - * Annual wage: �30,000 + * Wage: £30,000 a year 2022-12-31 @@ -214,7 +216,7 @@ public void GetSavedSearchVacanciesSnippet_Should_Return_Correct_Snippet_With_No }, Distance = 10, TrainingCourse = "Software Engineering", - Wage = "�30,000", + Wage = "£30,000", ClosingDate = "2022-12-31" } }; @@ -226,7 +228,7 @@ ABC Company 123 Main St, 12345 * Training course: Software Engineering - * Annual wage: �30,000 + * Wage: £30,000 a year 2022-12-31 @@ -240,7 +242,121 @@ ABC Company // Assert snippet.Should().Be(expectedSnippet); } - + + [TestCase("Competitive", "", "Competitive")] + [TestCase("", "month", "£30,000 a year")] + [TestCase("", "hour", "£30,000 a year")] + public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wage_Text_For_Faa_VacancySource_And_Different_WageTypes( + string wagetype, string wageUnit, string expectedWageText) + { + // Arrange + var environmentHelper = new EmailEnvironmentHelper("test") + { + VacancyDetailsUrl = "https://example.com/vacancy/{vacancy-reference}" + }; + + var vacancies = new List + { + new() + { + Title = "Software Developer", + VacancyReference = "12345", + EmployerName = "ABC Company", + Address = new PostSendSavedSearchNotificationCommand.Address + { + AddressLine1 = "123 Main St", + Postcode = "12345" + }, + Distance = 10, + TrainingCourse = "Software Engineering", + Wage = "£30,000", + ClosingDate = "2022-12-31", + VacancySource = "FAA", + WageUnit = wageUnit, + WageType = wagetype + } + }; + + string expectedSnippet = $""" + + #[Software Developer](https://example.com/vacancy/12345) + ABC Company + 123 Main St, 12345 + + * Distance: 10 miles + * Training course: Software Engineering + * Wage: {expectedWageText} + + 2022-12-31 + + --- + + """; + + // Act + var snippet = EmailTemplateBuilder.GetSavedSearchVacanciesSnippet(environmentHelper, vacancies, true); + + // Assert + snippet.Should().Be(expectedSnippet); + } + + [TestCase("Competitive", "", "Depends on experience")] + [TestCase("", "month", "£30,000 a month")] + [TestCase("", "hour", "£30,000 an hour")] + public void GetSavedSearchVacanciesSnippet_Should_Return_Snippet_With_Correct_Wage_Text_For_Nhs_VacancySource_And_Different_WageTypes( + string wagetype, string wageUnit, string expectedWageText) + { + // Arrange + var environmentHelper = new EmailEnvironmentHelper("test") + { + VacancyDetailsNhsUrl = "https://example.com/vacancy/nhs/{vacancy-reference}" + }; + + var vacancies = new List + { + new() + { + Title = "Mental Health Nurse", + VacancyReference = "12345", + EmployerName = "NHS Jobs", + Address = new PostSendSavedSearchNotificationCommand.Address + { + AddressLine1 = "123 Main St", + Postcode = "12345" + }, + Distance = 10, + TrainingCourse = "", + Wage = "£30,000", + ClosingDate = "2022-12-31", + VacancySource = "NHS", + WageUnit = wageUnit, + WageType = wagetype + } + }; + + string expectedSnippet = $""" + + #[Mental Health Nurse](https://example.com/vacancy/nhs/12345) + NHS Jobs + 123 Main St, 12345 + + * Distance: 10 miles + * Training course: See more details on NHS Jobs + * Wage: {expectedWageText} + + 2022-12-31 + + --- + + """; + + // Act + var snippet = EmailTemplateBuilder.GetSavedSearchVacanciesSnippet(environmentHelper, vacancies, true); + + // Assert + snippet.Should().Be(expectedSnippet); + } + private static object[] _titleTestCases = [ new object?[] { "Foo", new Dictionary {{1, "Route 1"},{2,"Route 2"}}, new Dictionary {{1, "Level 1"}, {2, "Level 2"}}, null, true, "Foo in all of England" }, diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs index d7f8c4b8c6..ceab7b0991 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Commands/SavedSearch/SendNotification/PostSendSavedSearchNotificationCommand.cs @@ -41,11 +41,17 @@ public class Vacancy public string? Wage { get; set; } + public string? WageUnit { get; set; } + + public string? WageType { get; set; } + public string? ClosingDate { get; set; } public string? TrainingCourse { get; set; } public double? Distance { get; set; } + + public string? VacancySource { get; set; } } public class Address diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs index 9cb749e1aa..d6affef43d 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/SavedSearch/GetSavedSearches/GetSavedSearchesQueryResult.cs @@ -30,9 +30,12 @@ public class ApprenticeshipVacancy public string? EmployerName { get; set; } public Address Address { get; set; } = null!; public string? Wage { get; set; } + public string? WageUnit { get; set; } + public string? WageType { get; set; } public string? ClosingDate { get; set; } public string? TrainingCourse { get; set; } public decimal? Distance { get; set; } + public string? VacancySource { get; set; } public static implicit operator ApprenticeshipVacancy(GetVacanciesListItem source) { @@ -44,9 +47,12 @@ public static implicit operator ApprenticeshipVacancy(GetVacanciesListItem sourc Title = source.Title, EmployerName = source.EmployerName, Wage = source.WageText, + WageUnit = source.WageUnit, + WageType = source.WageType, Address = source.VacancyAddress, TrainingCourse = $"{source.CourseTitle} (level {source.CourseLevel})", Distance = source.Distance.HasValue ? Math.Round(source.Distance.Value, 1) : null, + VacancySource = source.VacancySource, }; } } diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailEnvironmentHelper.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailEnvironmentHelper.cs index dd5cb1b86d..383832a664 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailEnvironmentHelper.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailEnvironmentHelper.cs @@ -19,6 +19,8 @@ public class EmailEnvironmentHelper(string environmentName) public string VacancyDetailsUrl { get; set; } = $"{GetBaseUrl(environmentName)}apprenticeship/{{vacancy-reference}}"; + public string VacancyDetailsNhsUrl { get; set; } = + $"{GetBaseUrl(environmentName)}apprenticeship/nhs/{{vacancy-reference}}"; private static string GetBaseUrl(string environmentName) { diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs index 49e344f32e..b8a27725b0 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Domain/EmailTemplates/EmailTemplateBuilder.cs @@ -66,8 +66,24 @@ public static string GetSavedSearchVacanciesSnippet( foreach (var vacancy in vacancies) { + string? trainingCourseText; + string? wageText; + sb.AppendLine(); - sb.AppendLine($"#[{vacancy.Title}]({environmentHelper.VacancyDetailsUrl.Replace("{vacancy-reference}", vacancy.VacancyReference)})"); + if (vacancy.VacancySource == "NHS") + { + sb.AppendLine($"#[{vacancy.Title}]({environmentHelper.VacancyDetailsNhsUrl.Replace("{vacancy-reference}", vacancy.VacancyReference)})"); + trainingCourseText = "See more details on NHS Jobs"; + wageText = (vacancy.WageType == "Competitive") ? + "Depends on experience" : + vacancy.Wage + ((vacancy.WageUnit == "hour") ? " an " : " a ") + vacancy.WageUnit; + } + else + { + sb.AppendLine($"#[{vacancy.Title}]({environmentHelper.VacancyDetailsUrl.Replace("{vacancy-reference}", vacancy.VacancyReference)})"); + trainingCourseText = vacancy.TrainingCourse; + wageText = (vacancy.WageType == "Competitive") ? vacancy.WageType : vacancy.Wage + " a year"; + } sb.AppendLine(vacancy.EmployerName); sb.AppendLine(!string.IsNullOrEmpty(vacancy.Address.AddressLine4) ? $"{vacancy.Address.AddressLine4}, {vacancy.Address.Postcode}" : !string.IsNullOrEmpty(vacancy.Address.AddressLine3) ? $"{vacancy.Address.AddressLine3}, {vacancy.Address.Postcode}" : @@ -80,9 +96,9 @@ public static string GetSavedSearchVacanciesSnippet( { sb.AppendLine($"* Distance: {vacancy.Distance} miles"); } - - sb.AppendLine($"* Training course: {vacancy.TrainingCourse}"); - sb.AppendLine($"* Annual wage: {vacancy.Wage}"); + + sb.AppendLine($"* Training course: {trainingCourseText}"); + sb.AppendLine($"* Wage: {wageText}"); sb.AppendLine(); sb.AppendLine($"{vacancy.ClosingDate}"); diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs index 9bfcf8c511..15a54e9588 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetVacanciesResponse.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace SFA.DAS.FindApprenticeshipJobs.InnerApi.Responses { @@ -31,6 +31,12 @@ public class GetVacanciesListItem [JsonPropertyName("wageText")] public string WageText { get; set; } + [JsonPropertyName("wageUnit")] + public string WageUnit { get; set; } + + [JsonPropertyName("wageType")] + public string WageType { get; set; } + [JsonPropertyName("address")] public VacancyAddress VacancyAddress { get; set; } @@ -42,6 +48,9 @@ public class GetVacanciesListItem [JsonPropertyName("standardLevel")] public string CourseLevel { get; set; } + + [JsonPropertyName("vacancySource")] + public string VacancySource { get; set; } } public class VacancyAddress