Skip to content

Commit

Permalink
CIV-13440 trial arrangements date to be 4 weeks before hearing date (#…
Browse files Browse the repository at this point in the history
…4213)

Co-authored-by: dharmendra kumar <[email protected]>
  • Loading branch information
kannan-v-hmcts and dharmendrak committed Jul 24, 2024
1 parent d79ea3d commit d4ac136
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/main/common/models/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,19 @@ export class Claim {
return new Date(dateAtStartOfDay);
}

fourWeeksBeforeHearingDate() {
const hearingDateTime = new Date(this.caseProgressionHearing.hearingDate).getTime();
const threeWeeksMilli = 28 * 24 * 60 * 60 * 1000;
const dateAtStartOfDay = new Date(hearingDateTime - threeWeeksMilli).setHours(0, 0, 0, 0);
return new Date(dateAtStartOfDay);
}

fourWeeksBeforeHearingDateString() {
const fourWeeksBefore = this.fourWeeksBeforeHearingDate();
const options: DateTimeFormatOptions = {day: 'numeric', month: 'long', year: 'numeric'};
return fourWeeksBefore.toLocaleDateString('en-GB', options);
}

private sixWeeksBeforeHearingDate(): Date {
const hearingDateTime = new Date(this.caseProgressionHearing.hearingDate).getTime();
const sixWeeksMilli = 42 * 24 * 60 * 60 * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const getFinaliseTrialArrangementContents = (claimId: string, claim: Clai
.addMainTitle('PAGES.FINALISE_TRIAL_ARRANGEMENTS.TITLE')
.addLeadParagraph('COMMON.CASE_NUMBER_PARAM', {claimId:caseNumberPrettify(claimId)}, 'govuk-!-margin-bottom-1')
.addLeadParagraph('COMMON.CLAIM_AMOUNT_WITH_VALUE', {claimAmount: currencyFormatWithNoTrailingZeros(claim.totalClaimAmount)})
.addWarning('PAGES.FINALISE_TRIAL_ARRANGEMENTS.YOU_HAVE_UNTIL_DATE',{hearingDueDate: formatDateToFullDate(claim.threeWeeksBeforeHearingDate(), getLng(lang)) })
.addWarning('PAGES.FINALISE_TRIAL_ARRANGEMENTS.YOU_HAVE_UNTIL_DATE',{hearingDueDate: formatDateToFullDate(claim.fourWeeksBeforeHearingDate(), getLng(lang)) })
.addParagraph('PAGES.FINALISE_TRIAL_ARRANGEMENTS.YOU_SHOULD_FINALISE')
.addTitle('PAGES.FINALISE_TRIAL_ARRANGEMENTS.IS_THE_CASE_READY_FOR_TRIAL')
.addLink('PAGES.FINALISE_TRIAL_ARRANGEMENTS.DIRECTIONS_ORDER', CASE_DOCUMENT_DOWNLOAD_URL.replace(':id', claimId).replace(':documentId', getSystemGeneratedCaseDocumentIdByType(claim.systemGeneratedCaseDocuments, DocumentType.SDO_ORDER)),
Expand Down
14 changes: 14 additions & 0 deletions src/test/unit/common/models/claim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,20 @@ describe('Documents', () => {
});
});

describe('test of method fourWeeksBeforeHearingDate', () => {
const claim = new Claim();

it('should return formatted date 4 weeks prior to 29 July 2023', () => {
//Given
const expectedDate = '1 July 2023';
claim.caseProgressionHearing = new CaseProgressionHearing([getCaseProgressionDocuments()], null, new Date(2023, 6, 29), null);
//When
const actualDate = claim.fourWeeksBeforeHearingDateString();
//Then
expect(expectedDate).toEqual(actualDate);
});
});

describe('test of method isSixWeeksOrLessFromTrial', () => {
const claim = new Claim();

Expand Down

0 comments on commit d4ac136

Please sign in to comment.