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

FLP-976-Permanent-banner-for-employer-when-withholding-payment-v2 #540

Merged
Show file tree
Hide file tree
Changes from 3 commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using SFA.DAS.EmployerCommitmentsV2.Web.Extensions;

namespace SFA.DAS.EmployerCommitmentsV2.Web.UnitTests.Extensions
{
[TestFixture]
public class DateTimeExtensionsTests
{
[Test]
public void TheGdsHumanisedDateIsPopulated()
{
var currentDate = DateTime.Now;

var gdsHumanisedDate = currentDate.ToGdsHumanisedDate();

Assert.That(gdsHumanisedDate, Is.Not.Empty);
}

[Test]
public void TheGdsHumanisedDateIsPopulatedWithSt()
{
var currentDate = new DateTime(2024, 1, 1);

var gdsHumanisedDate = currentDate.ToGdsHumanisedDate();

Assert.That(gdsHumanisedDate, Is.EqualTo("1st January 2024"));
}

[Test]
public void TheGdsHumanisedDateIsPopulatedWithNd()
{
var currentDate = new DateTime(2024, 1, 22);

var gdsHumanisedDate = currentDate.ToGdsHumanisedDate();

Assert.That(gdsHumanisedDate, Is.EqualTo("22nd January 2024"));
}

[Test]
public void TheGdsHumanisedDateIsPopulatedWithrd()
{
var currentDate = new DateTime(2024, 1, 3);

var gdsHumanisedDate = currentDate.ToGdsHumanisedDate();

Assert.That(gdsHumanisedDate, Is.EqualTo("3rd January 2024"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,32 @@ public static string ToGdsFormatLongMonthNameWithoutDay(this DateTime date)
{
return date.ToString("MMMM yyyy");
}

public static string ToGdsHumanisedDate(this DateTime date)
{
string ordinal;

switch (date.Day)
{
case 1:
case 21:
case 31:
ordinal = "st";
break;
case 2:
case 22:
ordinal = "nd";
break;
case 3:
case 23:
ordinal = "rd";
break;
default:
ordinal = "th";
break;
}

// Eg 12th January 2024
return string.Format("{0}{1} {2:MMMM yyyy}", date.Day, ordinal, date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public async Task<ApprenticeshipDetailsRequestViewModel> Map(ApprenticeshipDetai
EndpointAssessorName = response.Apprenticeship.EndpointAssessorName,
MadeRedundant = response.Apprenticeship.MadeRedundant,
HasPendingChangeOfProviderRequest = pendingChangeOfProviderRequest != null,
PaymentFrozenOn = response.PaymentsStatus.FrozenOn,
PendingChangeOfProviderRequestWithParty = pendingChangeOfProviderRequest?.WithParty,
HasContinuation = response.Apprenticeship.HasContinuation,
TrainingProviderHistory = response.ChangeOfProviderChain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ public class ApprenticeshipDetailsRequestViewModel : IAuthorizationContextModel
public bool HasPendingStartDateChange => PendingStartDateChange != null;
public bool HasPendingProviderInitiatedPriceChange => PendingPriceChange?.ProviderApprovedDate != null;
public bool HasPendingProviderInitiatedStartDateChange => PendingStartDateChange != null;
public bool HasWithheldPayment => PaymentStatus == "Withheld";
public string PriceChangeUrl { get; set; }
public string PendingPriceChangeUrl { get; set; }
public string PendingStartDateChangeUrl { get; set; }
public string PaymentStatusChangeUrl { get; set; }
public ApprenticeDetailsBanners ShowBannersFlags { get; set; }
public LearnerStatus LearnerStatus { get; set; }
public DateTime? PaymentFrozenOn { get; set; }

public ActionRequiredBanner GetActionRequiredBanners()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
var providerPaymentsInactiveBannerModel = new SuccessBannerModel("provider-payments-inactive-banner", "Provider payments have been set to \"Withheld\"", "The training provider has been informed of this update.");
<partial name="DetailsPartials/_SuccessBanner" model="providerPaymentsInactiveBannerModel" />
}
else if (Model.HasWithheldPayment && Model.PaymentFrozenOn.HasValue)
{
<partial name="DetailsPartials/_PaymentsWithheldBanner" />
}

@if (Model.HasPendingProviderInitiatedPriceChange)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@model SFA.DAS.EmployerCommitmentsV2.Web.Models.Apprentice.ApprenticeshipDetailsRequestViewModel

<div id="start-date-change-pending-banner" class="govuk-notification-banner govuk-notification-banner">
<div class="govuk-notification-banner__header">
<h2 class="govuk-notification-banner__title" id="govuk-notification-banner-title">
Important
</h2>
</div>
<div class="govuk-notification-banner__content">
<h3 class="govuk-notification-banner__heading">
Provider payments set to "Withheld" on the @Model.PaymentFrozenOn.Value.ToGdsHumanisedDate()"
</h3>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@using SFA.DAS.EmployerCommitmentsV2.Web
@using SFA.DAS.EmployerUrlHelper
@using SFA.DAS.EmployerCommitmentsV2.Web.Extensions;
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, WebEssentials.AspNetCore.CdnTagHelpers
@addTagHelper *, SFA.DAS.EmployerCommitmentsV2.Web