Skip to content

Commit

Permalink
Showing 20 changed files with 2,033 additions and 36 deletions.
48 changes: 33 additions & 15 deletions azure/finance.template.json
Original file line number Diff line number Diff line change
@@ -69,11 +69,10 @@
},
"sharedApimName": {
"type": "string"
},
},
"appServiceAllowedIPs": {
"type": "array",
"defaultValue": [
]
"defaultValue": []
},
"sharedEnvVirtualNetworkName": {
"type": "string"
@@ -103,15 +102,13 @@
"workerAppServicePlanName": "[concat(variables('resourceNamePrefix'), 'wkr-asp')]",
"resourceGroupName": "[concat(variables('resourceNamePrefix'), '-rg')]"
},
"resources": [
{
"resources": [{
"apiVersion": "2020-06-01",
"name": "[variables('resourceGroupName')]",
"type": "Microsoft.Resources/resourceGroups",
"location": "[parameters('resourceGroupLocation')]",
"tags": "[parameters('tags')]",
"properties": {
}
"properties": {}
},
{
"apiVersion": "2020-06-01",
@@ -155,6 +152,27 @@
}
}
},
{
"apiVersion": "2020-06-01",
"name": "WorkerAppInsights",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[variables('resourceGroupName')]",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[concat(variables('deploymentUrlBase'),'application-insights.json')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
"appInsightsName": {
"value": "[variables('workerAppServiceName')]"
},
"attachedService": {
"value": "[variables('workerAppServiceName')]"
}
}
}
},
{
"condition": "[greater(length(parameters('uiCustomHostName')), 0)]",
"apiVersion": "2020-06-01",
@@ -206,8 +224,7 @@
},
"appServiceAppSettings": {
"value": {
"array": [
{
"array": [{
"name": "LoggingRedisConnectionString",
"value": "[parameters('loggingRedisConnectionString')]"
},
@@ -305,8 +322,7 @@
},
"appServiceAppSettings": {
"value": {
"array": [
{
"array": [{
"name": "LoggingRedisConnectionString",
"value": "[parameters('loggingRedisConnectionString')]"
},
@@ -424,8 +440,7 @@
},
"appServiceAppSettings": {
"value": {
"array": [
{
"array": [{
"name": "LoggingRedisConnectionString",
"value": "[parameters('loggingRedisConnectionString')]"
},
@@ -444,14 +459,17 @@
{
"name": "StorageConnectionString",
"value": "[parameters('storageConnectionString')]"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference('WorkerAppInsights').outputs.InstrumentationKey.value]"
}
]
}
},
"appServiceConnectionStrings": {
"value": {
"array": [
{
"array": [{
"name": "AzureWebJobsDashboard",
"connectionString": "[parameters('storageConnectionString')]",
"type": "Custom"
Original file line number Diff line number Diff line change
@@ -152,6 +152,7 @@
<Build Include="StoredProcedures\GetPayeSchemesAddedByGovernmentGateway_ByAccountId.sql" />
<Build Include="StoredProcedures\UpdateAccount_SetAccountApprenticeshipEmployerType.sql" />
<None Include="Scripts\Manual\CON-1493-ExpireLegalAgreements.sql" />
<None Include="Scripts\Manual\CON-2796 Migrate And Add v5 Legal Agreement.sql" />
</ItemGroup>
<ItemGroup>
<RefactorLog Include="SFA.DAS.EmployerApprenticeshipsService.Database.refactorlog" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Replace all pending v3 / v4 agreements with pending v5 agreement
UPDATE [employer_account].[EmployerAgreement]
SET TemplateId = 6
WHERE TemplateId IN (4, 5) AND StatusId = 1

UPDATE [employer_account].[AccountLegalEntity]
SET PendingAgreementVersion = 5
WHERE PendingAgreementVersion IN (3, 4)

-- Create a pending v5 agreement for all account legal entities (except those that have them)
INSERT INTO [employer_account].[EmployerAgreement] (TemplateId, StatusId, AccountLegalEntityId)
SELECT 6, 1, Id
FROM [employer_account].[AccountLegalEntity]
WHERE PendingAgreementVersion IS NULL AND PendingAgreementId IS NULL AND Deleted IS NULL AND SignedAgreementVersion != 5

UPDATE ale
SET PendingAgreementVersion = 5, PendingAgreementId = ea.Id
FROM [employer_account].[AccountLegalEntity] ale
JOIN [employer_account].[EmployerAgreement] ea ON ea.AccountLegalEntityId = ale.Id AND ea.TemplateId = 6 AND ea.StatusId = 1
WHERE PendingAgreementVersion IS NULL AND PendingAgreementId IS NULL AND Deleted IS NULL
Original file line number Diff line number Diff line change
@@ -28,4 +28,12 @@ BEGIN
INSERT INTO [employer_account].[EmployerAgreementTemplate] (Id, PartialViewName, VersionNumber, AgreementType, CreatedDate, PublishedDate)
VALUES (5, '_Agreement_V4', 4, 2, GETDATE(), Convert(DateTime,'2020-8-20'))
SET IDENTITY_INSERT [employer_account].[EmployerAgreementTemplate] OFF
END

IF (NOT EXISTS (SELECT 1 FROM [employer_account].[EmployerAgreementTemplate] WHERE PartialViewName = '_Agreement_V5'))
BEGIN
SET IDENTITY_INSERT [employer_account].[EmployerAgreementTemplate] ON
INSERT INTO [employer_account].[EmployerAgreementTemplate] (Id, PartialViewName, VersionNumber, AgreementType, CreatedDate, PublishedDate)
VALUES (6, '_Agreement_V5', 5, 2, GETDATE(), Convert(DateTime,'2021-1-20'))
SET IDENTITY_INSERT [employer_account].[EmployerAgreementTemplate] OFF
END
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using SFA.DAS.EmployerAccounts.Web.Extensions;
using SFA.DAS.EmployerAccounts.Web.ViewModels;

namespace SFA.DAS.EmployerAccounts.Web.UnitTests.Extensions
{
[TestFixture]
public class AgreementTemplateExtensionsTests
{
[TestCase(1, "")]
[TestCase(2, "This is a variation of the agreement that we published 1 May 2017. We updated it to add clause 7 (transfer of funding).")]
[TestCase(3, "This is a new agreement.")]
[TestCase(4, "This is a new agreement.")]
[TestCase(5, "This is a new agreement.")]
public void InsetTextSetCorrectlyForNoPreviouslySignedAgreements(int agreementVersion, string expectedResult)
{
var model = new AgreementTemplateViewModel
{
VersionNumber = agreementVersion
};

Assert.AreEqual(expectedResult, model.InsetText(new List<OrganisationAgreementViewModel>()));
}

[TestCase(1, "")]
[TestCase(2, "This is a variation of the agreement that we published 1 May 2017. We updated it to add clause 7 (transfer of funding).")]
[TestCase(3, "This is a new agreement.")]
[TestCase(4, "This is a new agreement.")]
[TestCase(5, "This is a new agreement.")]
public void InsetTextSetCorrectlyForPreviouslySignedv1Agreements(int agreementVersion, string expectedResult)
{
var model = new AgreementTemplateViewModel
{
VersionNumber = agreementVersion
};

var agreements = new List<OrganisationAgreementViewModel>
{
new OrganisationAgreementViewModel
{
SignedDate = DateTime.Today,
Template = new AgreementTemplateViewModel
{
VersionNumber = 1
}
}
};

Assert.AreEqual(expectedResult, model.InsetText(agreements));
}

[TestCase(1, "")]
[TestCase(2, "This is a variation of the agreement that we published 1 May 2017. We updated it to add clause 7 (transfer of funding).")]
[TestCase(3, "This is a new agreement.")]
[TestCase(4, "This is a new agreement.")]
[TestCase(5, "This is a new agreement.")]
public void InsetTextSetCorrectlyForPreviouslySignedv2Agreements(int agreementVersion, string expectedResult)
{
var model = new AgreementTemplateViewModel
{
VersionNumber = agreementVersion
};

var agreements = new List<OrganisationAgreementViewModel>
{
new OrganisationAgreementViewModel
{
SignedDate = DateTime.Today,
Template = new AgreementTemplateViewModel
{
VersionNumber = 2
}
}
};

Assert.AreEqual(expectedResult, model.InsetText(agreements));
}

[TestCase(1, "")]
[TestCase(2, "This is a variation of the agreement that we published 1 May 2017. We updated it to add clause 7 (transfer of funding).")]
[TestCase(3, "This is a new agreement.")]
[TestCase(4, "This is a variation to the agreement we published 9 January 2020. You only need to accept it if you want to access incentive payments for hiring a new apprentice.")]
[TestCase(5, "This is a variation to the agreement we published 9 January 2020.")]
public void InsetTextSetCorrectlyForPreviouslySignedv3Agreements(int agreementVersion, string expectedResult)
{
var model = new AgreementTemplateViewModel
{
VersionNumber = agreementVersion
};

var agreements = new List<OrganisationAgreementViewModel>
{
new OrganisationAgreementViewModel
{
SignedDate = DateTime.Today,
Template = new AgreementTemplateViewModel
{
VersionNumber = 3
}
}
};

Assert.AreEqual(expectedResult, model.InsetText(agreements));
}

[TestCase(1, "")]
[TestCase(2, "This is a variation of the agreement that we published 1 May 2017. We updated it to add clause 7 (transfer of funding).")]
[TestCase(3, "This is a new agreement.")]
[TestCase(4, "This is a variation to the agreement we published 9 January 2020. You only need to accept it if you want to access incentive payments for hiring a new apprentice.")]
[TestCase(5, "This is a variation to the agreement we published 9 January 2020.")]
public void InsetTextSetCorrectlyForPreviouslySignedv4Agreements(int agreementVersion, string expectedResult)
{
var model = new AgreementTemplateViewModel
{
VersionNumber = agreementVersion
};

var agreements = new List<OrganisationAgreementViewModel>
{
new OrganisationAgreementViewModel
{
SignedDate = DateTime.Today,
Template = new AgreementTemplateViewModel
{
VersionNumber = 4
}
}
};

Assert.AreEqual(expectedResult, model.InsetText(agreements));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using SFA.DAS.EmployerAccounts.Web.ViewModels;
using System.Collections.Generic;
using System.Linq;

namespace SFA.DAS.EmployerAccounts.Web.Extensions
{
public static class AgreementTemplateExtensions
{
public const int AgreementVersionV3 = 3;
public static readonly int[] VariationsOfv3Agreement = {3, 4, 5};

public static string InsetText(this AgreementTemplateViewModel agreementTemplate, ICollection<OrganisationAgreementViewModel> organisationAgreementViewModel)
{
@@ -19,25 +20,26 @@ public static string InsetText(this AgreementTemplateViewModel agreementTemplate
case 3:
return "This is a new agreement.";
case 4:
bool v3Accepted = GetV3AgreementStatus(organisationAgreementViewModel);
return v3Accepted ? "This is a variation to the agreement we published 9 January 2020. You only need to accept it if you want to access incentive payments for hiring a new apprentice." : "This is a new agreement.";
return HasSignedVariationOfv3Agreement(organisationAgreementViewModel) ? "This is a variation to the agreement we published 9 January 2020. You only need to accept it if you want to access incentive payments for hiring a new apprentice." : "This is a new agreement.";
case 5:
return HasSignedVariationOfv3Agreement(organisationAgreementViewModel) ? "This is a variation to the agreement we published 9 January 2020." : "This is a new agreement.";
default:
return string.Empty;
}
}

private static bool GetV3AgreementStatus(ICollection<OrganisationAgreementViewModel> organisationAgreementViewModel)
private static bool HasSignedVariationOfv3Agreement(ICollection<OrganisationAgreementViewModel> organisationAgreementViewModel)
{
bool v3Accepted = false;
foreach (var organisation in organisationAgreementViewModel)
{
if (organisation.SignedDateText != string.Empty && organisation.Template.VersionNumber == AgreementVersionV3)
if (organisation.SignedDateText != string.Empty &&
VariationsOfv3Agreement.Contains(organisation.Template.VersionNumber))
{
v3Accepted = true;
return true;
}
}

return v3Accepted;
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -873,6 +873,7 @@
<Content Include="Views\EmployerAgreement\AcceptedEmployerAgreement.cshtml" />
<Content Include="Views\Shared\_ZenDeskApiPush.cshtml" />
<Content Include="Views\Shared\_Agreement_v4.cshtml" />
<Content Include="Views\Shared\_Agreement_v5.cshtml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SFA.DAS.Account.Api.Client\SFA.DAS.EAS.Account.Api.Client.csproj">
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
<a class="govuk-link" href="@Url.Action(ControllerConstants.GetSignedPdfAgreementActionName, ControllerConstants.EmployerAgreementControllerName)" target="_blank">
Download your accepted agreement
</a>
&nbsp;(<abbr>PDF</abbr>, 334<abbr>KB</abbr>)
&nbsp;(<abbr>PDF</abbr>, 225<abbr>KB</abbr>)
</p>

<h3 class="govuk-heading-m">What happens next</h3>
Original file line number Diff line number Diff line change
@@ -108,7 +108,7 @@ else
{
<div class="card">
<h3 class="heading-medium"><a href="@Url.EmployerIncentivesAction()">Apply for the hire a new apprentice payment</a></h3>
<p>You can apply for the payment if you hire new apprentices from 1 August 2020 to 31 January 2021.</p>
<p>You can apply for the payment if you hire new apprentices from 1 August 2020 to 31 March 2021.</p>
</div>
<div class="card">
<h3 class="heading-medium"><a href="@Url.EmployerIncentivesAction("payments/payment-applications")">Your hire a new apprentice payment applications</a></h3>
Loading

0 comments on commit 3f695ba

Please sign in to comment.