From 4921d3fc7b2fe4cd683cfde3a9108188d53f8673 Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Fri, 30 Aug 2024 15:35:50 +0100 Subject: [PATCH] Do not display draft return versions in set up https://eaflood.atlassian.net/browse/WATER-4407 > Part of the work to replace NALD for handling return requirements When we [started displaying return versions](https://github.com/DEFRA/water-abstraction-system/pull/1054) in the view licence set up tab we should have excluded those with a 'draft' status. These have been imported from NALD, but found to have no return requirements which isn't valid in NALD. A decision will be made on what to do with them once we return requirements has gone live in WRLS. Till then, we just need to ensure they don't appear in this table. --- app/services/licences/fetch-return-versions.service.js | 1 + .../licences/fetch-return-versions.service.test.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/services/licences/fetch-return-versions.service.js b/app/services/licences/fetch-return-versions.service.js index 98df4264c8..0146a85791 100644 --- a/app/services/licences/fetch-return-versions.service.js +++ b/app/services/licences/fetch-return-versions.service.js @@ -28,6 +28,7 @@ async function _fetch (licenceId) { 'reason' ]) .where('licenceId', licenceId) + .whereNot('status', 'draft') .orderBy([ { column: 'startDate', order: 'desc' }, { column: 'version', order: 'desc' } diff --git a/test/services/licences/fetch-return-versions.service.test.js b/test/services/licences/fetch-return-versions.service.test.js index 8919ea17b3..ed55dfdc26 100644 --- a/test/services/licences/fetch-return-versions.service.test.js +++ b/test/services/licences/fetch-return-versions.service.test.js @@ -24,7 +24,7 @@ describe('Fetch Return Versions service', () => { describe('when the licence has return versions data', () => { beforeEach(async () => { - // NOTE: We add 2, both with the same start date to ensure the order that they are returned is as expected + // NOTE: We add these 2, both with the same start date to ensure the order that they are returned as expected supersededReturnVersion = await ReturnVersionHelper.add({ startDate, status: 'superseded', version: 100 }) @@ -32,6 +32,11 @@ describe('Fetch Return Versions service', () => { licenceId: supersededReturnVersion.licenceId, startDate, status: 'current', version: 101 }) + // We add this 3rd one with a status of draft to ensure it is not included + await ReturnVersionHelper.add({ + licenceId: supersededReturnVersion.licenceId, startDate: new Date('2022-05-01'), status: 'draft', version: 102 + }) + currentReturnVersionModLog = await ModLogHelper.add({ reasonDescription: 'Record Loaded During Migration', returnVersionId: currentReturnVersion.id })