From df9f34ea80b04252cf2db260fd230ae81a4ff5dd Mon Sep 17 00:00:00 2001 From: JoshBinns2000 <108285982+JoshBinns2000@users.noreply.github.com> Date: Wed, 22 Nov 2023 17:22:52 +0000 Subject: [PATCH] feat(FN-1089): fix next report period start (#2339) --- .../utilisation-report-upload.component-test.js | 6 +++--- .../utilisation-report-upload/index.js | 10 ++++++---- .../utilisation-report-upload.njk | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/portal/component-tests/utilisation-report-service/utilisation-report-upload.component-test.js b/portal/component-tests/utilisation-report-service/utilisation-report-upload.component-test.js index 426b3d721a..9cd4ccd65a 100644 --- a/portal/component-tests/utilisation-report-service/utilisation-report-upload.component-test.js +++ b/portal/component-tests/utilisation-report-service/utilisation-report-upload.component-test.js @@ -120,7 +120,7 @@ describe(page, () => { describe('when no reports are due', () => { const nextReportPeriod = 'March 2023'; - const nextReportPeriodStart = '1 March 2023'; + const nextReportPeriodSubmissionStart = '1 April 2023'; const lastUploadedReportPeriod = 'February 2023'; const uploadedByFullName = 'John Smith'; const formattedDateAndTimeUploaded = '25 February 2023 at 10:05 am'; @@ -131,7 +131,7 @@ describe(page, () => { primaryNav: 'utilisation_report_upload', dueReportDates: [], nextReportPeriod, - nextReportPeriodStart, + nextReportPeriodSubmissionStart, lastUploadedReportPeriod, uploadedByFullName, formattedDateAndTimeUploaded, @@ -144,7 +144,7 @@ describe(page, () => { it('should display specific text about the next report which can be uploaded', () => { wrapper.expectText('[data-cy="next-due-report-text"]') - .toRead(`The ${nextReportPeriod} report can be uploaded from ${nextReportPeriodStart}.`); + .toRead(`The ${nextReportPeriod} report can be uploaded from ${nextReportPeriodSubmissionStart}.`); }); it('should display details about the last uploaded report', () => { diff --git a/portal/server/controllers/utilisation-report-service/utilisation-report-upload/index.js b/portal/server/controllers/utilisation-report-service/utilisation-report-upload/index.js index 0c116093f9..da52f7605b 100644 --- a/portal/server/controllers/utilisation-report-service/utilisation-report-upload/index.js +++ b/portal/server/controllers/utilisation-report-service/utilisation-report-upload/index.js @@ -1,4 +1,4 @@ -const { format, startOfMonth } = require('date-fns'); +const { format, startOfMonth, addMonths } = require('date-fns'); const { extractCsvData, removeCellAddressesFromArray } = require('../../../utils/csv-utils'); const { validateCsvData, validateFilenameContainsReportPeriod } = require('./utilisation-report-validator'); const { getReportDueDate } = require('./utilisation-report-status'); @@ -35,7 +35,7 @@ const setSessionUtilisationReport = (req, nextDueReportDate) => { * @property {string} formattedDateAndTimeUploaded - The date uploaded formatted as 'd MMMM yyyy at h:mmaaa' * @property {string} lastUploadedReportPeriod - The report period of the report formatted as 'MMMM yyyy' * @property {string} nextReportPeriod - The upcoming report period (the current month) with format 'MMMM yyyy' - * @property {string} nextReportPeriodStart - The start of the upcoming report period with format 'd MMMM yyyy' + * @property {string} nextReportPeriodSubmissionStart - The start of the month when the next report period report can be submitted with format 'd MMMM yyyy' */ /** @@ -51,9 +51,11 @@ const getLastUploadedReportDetails = async (userToken, bankId) => { const nextReportDate = new Date(); const nextReportPeriod = format(nextReportDate, 'MMMM yyyy'); - const nextReportPeriodStart = format(startOfMonth(nextReportDate), 'd MMMM yyyy'); - return { ...reportAndUserDetails, nextReportPeriod, nextReportPeriodStart }; + const nextReportPeriodSubmissionStartDate = addMonths(nextReportDate, 1); + const nextReportPeriodSubmissionStart = format(startOfMonth(nextReportPeriodSubmissionStartDate), 'd MMMM yyyy'); + + return { ...reportAndUserDetails, nextReportPeriod, nextReportPeriodSubmissionStart }; }; const getUtilisationReportUpload = async (req, res) => { diff --git a/portal/templates/utilisation-report-service/utilisation-report-upload/utilisation-report-upload.njk b/portal/templates/utilisation-report-service/utilisation-report-upload/utilisation-report-upload.njk index 4c30425661..86c0b148a7 100644 --- a/portal/templates/utilisation-report-service/utilisation-report-upload/utilisation-report-upload.njk +++ b/portal/templates/utilisation-report-service/utilisation-report-upload/utilisation-report-upload.njk @@ -27,7 +27,7 @@ {% if dueReportDates.length === 0%}

- The {{ nextReportPeriod }} report can be uploaded from {{ nextReportPeriodStart }}. + The {{ nextReportPeriod }} report can be uploaded from {{ nextReportPeriodSubmissionStart }}.

The {{ lastUploadedReportPeriod }} report was sent to UKEF by {{ uploadedByFullName }} on {{ formattedDateAndTimeUploaded }}.