Skip to content

Commit

Permalink
feat(FN-1089): fix next report period start (#2339)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshBinns2000 authored Nov 22, 2023
1 parent a1aecf9 commit df9f34e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -131,7 +131,7 @@ describe(page, () => {
primaryNav: 'utilisation_report_upload',
dueReportDates: [],
nextReportPeriod,
nextReportPeriodStart,
nextReportPeriodSubmissionStart,
lastUploadedReportPeriod,
uploadedByFullName,
formattedDateAndTimeUploaded,
Expand All @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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'
*/

/**
Expand All @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</h1>
{% if dueReportDates.length === 0%}
<p class="govuk-body" data-cy="next-due-report-text">
The {{ nextReportPeriod }} report can be uploaded from {{ nextReportPeriodStart }}.
The {{ nextReportPeriod }} report can be uploaded from {{ nextReportPeriodSubmissionStart }}.
</p>
<p class="govuk-body" data-cy="uploaded-report-details">
The {{ lastUploadedReportPeriod }} report was sent to UKEF by {{ uploadedByFullName }} on {{ formattedDateAndTimeUploaded }}.
Expand Down

0 comments on commit df9f34e

Please sign in to comment.