diff --git a/docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx b/docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx index a8323e9b537..4bd1f2ab8ae 100644 Binary files a/docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx and b/docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx differ diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotificationClaimantOfHearingHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotificationClaimantOfHearingHandler.java index 64047745922..2cbe514decb 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotificationClaimantOfHearingHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotificationClaimantOfHearingHandler.java @@ -10,6 +10,8 @@ import uk.gov.hmcts.reform.civil.callback.CallbackHandler; import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; +import uk.gov.hmcts.reform.civil.enums.hearing.HearingNoticeList; +import uk.gov.hmcts.reform.civil.enums.hearing.ListingOrRelisting; import uk.gov.hmcts.reform.civil.model.Fee; import uk.gov.hmcts.reform.civil.notify.NotificationsProperties; import uk.gov.hmcts.reform.civil.enums.YesOrNo; @@ -155,8 +157,12 @@ private String getEmailTemplate(CaseData caseData, boolean isApplicantLip) { if (isApplicantLip) { return notificationsProperties.getHearingNotificationLipDefendantTemplate(); } + // If fee already paid do not renotify upon hearing being relisted + // If hearing type is OTHER no fee is due if (caseData.getHearingFeePaymentDetails() != null - && SUCCESS.equals(caseData.getHearingFeePaymentDetails().getStatus())) { + && SUCCESS.equals(caseData.getHearingFeePaymentDetails().getStatus()) + || caseData.getHearingNoticeList().equals(HearingNoticeList.OTHER) + || caseData.getListingOrRelisting().equals(ListingOrRelisting.RELISTING)) { return notificationsProperties.getHearingListedNoFeeClaimantLrTemplate(); } else { return notificationsProperties.getHearingListedFeeClaimantLrTemplate(); diff --git a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/HearingScheduledHandler.java b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/HearingScheduledHandler.java index b4c0ca8a146..48e45ae5c15 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/HearingScheduledHandler.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/handler/callback/user/HearingScheduledHandler.java @@ -22,6 +22,7 @@ import uk.gov.hmcts.reform.civil.callback.CallbackParams; import uk.gov.hmcts.reform.civil.callback.CaseEvent; import uk.gov.hmcts.reform.civil.enums.CaseState; +import uk.gov.hmcts.reform.civil.enums.hearing.HearingNoticeList; import uk.gov.hmcts.reform.civil.enums.hearing.ListingOrRelisting; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.CaseData; @@ -195,13 +196,23 @@ private CallbackResponse handleAboutToSubmit(CallbackParams callbackParams) { claimTrack = caseData.getResponseClaimTrack(); } - if (ListingOrRelisting.LISTING.equals(caseData.getListingOrRelisting())) { - caseDataBuilder.hearingDueDate( - calculateHearingDueDate(time.now().toLocalDate(), caseData.getHearingDate())); - caseDataBuilder.hearingFee(calculateAndApplyFee(hearingFeesService, caseData, claimTrack)); + // If hearing notice type if FAST or SMALL and it is a first time being listed, calculate fee and fee due date. + // If relisted, do not recalculate fee and fee due date, and move state to PREPARE_FOR_HEARING_CONDUCT_HEARING + if (!caseData.getHearingNoticeList().equals(HearingNoticeList.OTHER)) { + if (ListingOrRelisting.LISTING.equals(caseData.getListingOrRelisting())) { + caseDataBuilder.hearingDueDate(calculateHearingDueDate(time.now().toLocalDate(), caseData.getHearingDate())); + caseDataBuilder.hearingFee(calculateAndApplyFee(hearingFeesService, caseData, claimTrack)); + } else { + caseState = PREPARE_FOR_HEARING_CONDUCT_HEARING; + } + // If hearing notice type is OTHER and is being listed, do not calculate fee and fee due date + // If relisted, again do not calculate fee and fee due date, but move state to PREPARE_FOR_HEARING_CONDUCT_HEARING } else { - caseState = PREPARE_FOR_HEARING_CONDUCT_HEARING; + if (ListingOrRelisting.RELISTING.equals(caseData.getListingOrRelisting())) { + caseState = PREPARE_FOR_HEARING_CONDUCT_HEARING; + } } + caseDataBuilder.businessProcess(BusinessProcess.ready(HEARING_SCHEDULED)); return AboutToStartOrSubmitCallbackResponse.builder() .state(caseState.name()) diff --git a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGenerator.java b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGenerator.java index 27bb76edb62..5cbe8a4e58a 100644 --- a/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGenerator.java +++ b/src/main/java/uk/gov/hmcts/reform/civil/service/docmosis/hearing/HearingFormGenerator.java @@ -79,7 +79,7 @@ public HearingForm getTemplateData(CaseData caseData, String authorisation) { .courtName(courtLocationUtils.findPreferredLocationData(locations, caseData.getHearingLocation()).getSiteName()) .listingOrRelisting(caseData.getListingOrRelisting().toString()) .court(caseData.getHearingLocation().getValue().getLabel()) - .caseNumber(caseData.getLegacyCaseReference()) + .caseNumber(caseData.getCcdCaseReference().toString()) .creationDate(getDateFormatted(LocalDate.now())) .claimant(caseData.getApplicant1().getPartyName()) .claimantReference(checkReference(caseData) diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotificationClaimantOfHearingHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotificationClaimantOfHearingHandlerTest.java index 62954931d8f..8dffeda4dc7 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotificationClaimantOfHearingHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/camunda/notification/NotificationClaimantOfHearingHandlerTest.java @@ -12,6 +12,8 @@ import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest; import uk.gov.hmcts.reform.civil.callback.CallbackException; import uk.gov.hmcts.reform.civil.callback.CallbackParams; +import uk.gov.hmcts.reform.civil.enums.hearing.HearingNoticeList; +import uk.gov.hmcts.reform.civil.enums.hearing.ListingOrRelisting; import uk.gov.hmcts.reform.civil.model.BusinessProcess; import uk.gov.hmcts.reform.civil.model.PaymentDetails; import uk.gov.hmcts.reform.civil.model.SolicitorReferences; @@ -94,6 +96,8 @@ void shouldNotifyApplicantSolicitor_whenInvokedWithFeeAnd1v1() { .hearingDueDate(LocalDate.of(2022, 11, 23)) .addApplicant2(YesOrNo.NO) .addRespondent2(YesOrNo.NO) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS) + .listingOrRelisting(ListingOrRelisting.LISTING) .build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData) .request(CallbackRequest.builder().eventId("NOTIFY_CLAIMANT_HEARING").build()).build(); @@ -233,6 +237,8 @@ void shouldNotifyApplicantSolicitor_whenInvokedWithFeeAnd1v1WithNoSolicitorRefer .addApplicant2(YesOrNo.NO) .addRespondent2(YesOrNo.NO) .solicitorReferences(SolicitorReferences.builder().build()) + .hearingNoticeList(HearingNoticeList.FAST_TRACK_TRIAL) + .listingOrRelisting(ListingOrRelisting.LISTING) .build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData) .request(CallbackRequest.builder().eventId("NOTIFY_CLAIMANT_HEARING").build()).build(); @@ -262,6 +268,8 @@ void shouldNotifyApplicantSolicitor_whenInvokedWithFeeAnd1v2() { .addApplicant2(YesOrNo.NO) .addRespondent2(YesOrNo.YES) .respondent2(Party.builder().type(Party.Type.COMPANY).companyName("Party2").build()) + .hearingNoticeList(HearingNoticeList.FAST_TRACK_TRIAL) + .listingOrRelisting(ListingOrRelisting.LISTING) .build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData) .request(CallbackRequest.builder().eventId("NOTIFY_CLAIMANT_HEARING").build()).build(); @@ -289,6 +297,8 @@ void shouldNotifyApplicantSolicitor_whenInvokedWithFeeAnd2v1() { .hearingDueDate(LocalDate.of(2022, 11, 23)) .addApplicant2(YesOrNo.YES) .addRespondent2(YesOrNo.NO) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS) + .listingOrRelisting(ListingOrRelisting.LISTING) .build(); CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData) .request(CallbackRequest.builder().eventId("NOTIFY_CLAIMANT_HEARING").build()).build(); @@ -333,6 +343,63 @@ void shouldNotifyApplicantSolicitor_whenInvokedNoFeeAnd1v1() { ); } + @Test + void shouldNotifyApplicantSolicitor_whenInvokedNoFeeAnd1v1HearingOther() { + // Given + CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build().toBuilder() + .hearingDate(LocalDate.of(2022, 10, 7)) + .applicantSolicitor1UserDetails(IdamUserDetails.builder().email("applicantemail@hmcts.net").build()) + .respondentSolicitor1EmailAddress("respondent1email@hmcts.net") + .hearingReferenceNumber("000HN001") + .hearingTimeHourMinute("0830") + .addApplicant2(YesOrNo.NO) + .addRespondent2(YesOrNo.NO) + .hearingNoticeList(HearingNoticeList.OTHER) + .listingOrRelisting(ListingOrRelisting.LISTING) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData) + .request(CallbackRequest.builder().eventId("NOTIFY_CLAIMANT_HEARING").build()).build(); + // When + handler.handle(params); + // Then + verify(notificationService).sendMail( + "applicantemail@hmcts.net", + "test-template-no-fee-claimant-id", + getNotificationNoFeeOtherHearingTypeDataMap(caseData), + "notification-of-hearing-000HN001" + ); + } + + @Test + void shouldNotifyApplicantSolicitor_whenInvokedNoFeeAnd1v1HearingOtherAfterRetrigger() { + // Given + CaseData caseData = CaseDataBuilder.builder().atStateClaimDetailsNotified().build().toBuilder() + .hearingDate(LocalDate.of(2022, 10, 7)) + .applicantSolicitor1UserDetails(IdamUserDetails.builder().email("applicantemail@hmcts.net").build()) + .respondentSolicitor1EmailAddress("respondent1email@hmcts.net") + .hearingReferenceNumber("000HN001") + .hearingTimeHourMinute("0830") + .hearingFeePaymentDetails(PaymentDetails.builder() + .status(SUCCESS) + .build()) + .addApplicant2(YesOrNo.NO) + .addRespondent2(YesOrNo.NO) + .hearingNoticeList(HearingNoticeList.OTHER) + .listingOrRelisting(ListingOrRelisting.RELISTING) + .build(); + CallbackParams params = CallbackParamsBuilder.builder().of(ABOUT_TO_SUBMIT, caseData) + .request(CallbackRequest.builder().eventId("NOTIFY_CLAIMANT_HEARING").build()).build(); + // When + handler.handle(params); + // Then + verify(notificationService).sendMail( + "applicantemail@hmcts.net", + "test-template-no-fee-claimant-id", + getNotificationNoFeeDataMap(caseData), + "notification-of-hearing-000HN001" + ); + } + @Test void shouldNotifyApplicantSolicitor_whenInvokedNoFeeAnd1v2() { // Given @@ -446,6 +513,15 @@ private Map getNotificationNoFeeDataMap(CaseData caseData) { ); } + @NotNull + private Map getNotificationNoFeeOtherHearingTypeDataMap(CaseData caseData) { + return Map.of( + CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), "hearingFee", "£0.00", + "claimantReferenceNumber", "12345", "hearingDate", "07-10-2022", + "hearingTime", "08:30am", "hearingDueDate", "" + ); + } + @NotNull private Map getNotificationNoFeeDataMapHMC(CaseData caseData) { return Map.of( @@ -471,6 +547,14 @@ private Map getNotificationNoFeeDatePMDataMap(CaseData caseData) ); } + @NotNull + private Map getNotificationNoFeeDateHearingOtherDataMap(CaseData caseData) { + return Map.of( + CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(), + "claimantReferenceNumber", "", "hearingDate", "07-10-2022", "hearingTime", "03:30pm" + ); + } + @NotNull private Map getNotificationLipDataMap(CaseData caseData) { return Map.of( diff --git a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/HearingScheduledHandlerTest.java b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/HearingScheduledHandlerTest.java index fd1a0e185fe..e27299a9997 100644 --- a/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/HearingScheduledHandlerTest.java +++ b/src/test/java/uk/gov/hmcts/reform/civil/handler/callback/user/HearingScheduledHandlerTest.java @@ -229,6 +229,7 @@ void shouldSetHearingReadinessStateOnListing_whenAboutToSubmit(String listingTyp .addRespondent2(NO) .hearingDate(time.now().toLocalDate().plusWeeks(2)) .allocatedTrack(AllocatedTrack.SMALL_CLAIM) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS) .respondent1ResponseDeadline(LocalDateTime.now().minusDays(15)) .listingOrRelisting(listingOrRelisting) .build(); @@ -246,6 +247,7 @@ void shouldGetDueDateAndFeeSmallClaim_whenAboutToSubmit() { // Given CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .addRespondent2(NO) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS) .listingOrRelisting(ListingOrRelisting.LISTING) .hearingDate(time.now().toLocalDate().plusWeeks(2)) .allocatedTrack(AllocatedTrack.SMALL_CLAIM) @@ -272,6 +274,7 @@ void shouldSetHearingLocationListItemsNull_whenHearingLocationProvided() { DynamicListElement.builder().label("element 1").code("E0").build(), DynamicListElement.builder().label("element 2").code("E1").build())).build()) .addRespondent2(NO) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS) .listingOrRelisting(ListingOrRelisting.LISTING) .hearingDate(time.now().toLocalDate().plusWeeks(2)) .allocatedTrack(AllocatedTrack.SMALL_CLAIM) @@ -292,6 +295,7 @@ void shouldTriggerBusinessProcessHearingScheduledOnRelisting_whenAboutToSubmit() // Given CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .addRespondent2(NO) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS) .listingOrRelisting(ListingOrRelisting.RELISTING) .hearingDate(time.now().toLocalDate().plusWeeks(2)) .allocatedTrack(AllocatedTrack.SMALL_CLAIM) @@ -314,6 +318,7 @@ void shouldGetDueDateAndFeeFastAndClaimValueClaim_whenAboutToSubmit() { CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .caseAccessCategory(SPEC_CLAIM) .addRespondent2(NO) + .hearingNoticeList(HearingNoticeList.FAST_TRACK_TRIAL) .listingOrRelisting(ListingOrRelisting.LISTING) .hearingDate(time.now().toLocalDate().plusWeeks(5)) .allocatedTrack(null) @@ -338,6 +343,7 @@ void shouldGetDueDateAndFeeFastAndNoClaimValueClaim_whenAboutToSubmit() { CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .caseAccessCategory(SPEC_CLAIM) .addRespondent2(NO) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS) .listingOrRelisting(ListingOrRelisting.LISTING) .hearingDate(time.now().toLocalDate().plusWeeks(5)) .allocatedTrack(null) @@ -365,6 +371,7 @@ void shouldGetDueDateAndFeeFastClaim_whenAboutToSubmit() { // Given CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .addRespondent2(NO) + .hearingNoticeList(HearingNoticeList.SMALL_CLAIMS) .listingOrRelisting(ListingOrRelisting.LISTING) .hearingDate(time.now().toLocalDate().plusWeeks(5)) .allocatedTrack(AllocatedTrack.SMALL_CLAIM) @@ -390,6 +397,7 @@ void shouldGetDueDateAndFeeMultiClaim_whenAboutToSubmit() { // Given CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() .addRespondent2(NO) + .hearingNoticeList(HearingNoticeList.FAST_TRACK_TRIAL) .listingOrRelisting(ListingOrRelisting.LISTING) .hearingDate(time.now().toLocalDate().plusWeeks(5)) .allocatedTrack(AllocatedTrack.MULTI_CLAIM) @@ -431,6 +439,44 @@ void shouldReturnHearingNoticeCreated_WhenSubmitted() { .build()); } + @Test + void shouldNotGetDueDateAndFeeCalculationAndIsOther_whenAboutToSubmit() { + // Given + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .hearingNoticeList(HearingNoticeList.OTHER) + .listingOrRelisting(ListingOrRelisting.LISTING) + .hearingDate(time.now().toLocalDate().plusWeeks(5)) + .allocatedTrack(AllocatedTrack.SMALL_CLAIM) + .totalClaimAmount(new BigDecimal(12300)) + .respondent1ResponseDeadline(LocalDateTime.now().minusDays(15)) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + // When + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + // Then + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(updatedData.getHearingFee()).isNull(); + assertThat(updatedData.getHearingDueDate()).isNull(); + } + + @Test + void shouldTriggerBusinessProcessHearingScheduledOtherAndRelisting_whenAboutToSubmit() { + // Given + CaseData caseData = CaseDataBuilder.builder().atStateNotificationAcknowledged().build().toBuilder() + .hearingNoticeList(HearingNoticeList.OTHER) + .listingOrRelisting(ListingOrRelisting.RELISTING) + .hearingDate(time.now().toLocalDate().plusWeeks(2)) + .allocatedTrack(AllocatedTrack.SMALL_CLAIM) + .respondent1ResponseDeadline(LocalDateTime.now().minusDays(15)) + .build(); + CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT); + // When + var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params); + // Then + CaseData updatedData = mapper.convertValue(response.getData(), CaseData.class); + assertThat(updatedData.getBusinessProcess().getCamundaEvent()).isEqualTo(HEARING_SCHEDULED.name()); + } + private String prepareHHmmString(LocalDateTime localDateTime) { String hours = "0" + (localDateTime.getHour()); String minutes = "0" + localDateTime.getMinute();