Skip to content

Commit

Permalink
CIV-16288 Implement email notifications (#6201)
Browse files Browse the repository at this point in the history
* add login new template

* add PARTY_REFERENCES

* add unit tests

* add the new code

* fix unit test

* fix checkStyle

* fix unit test

* fix the FULL_DEFENCE issue.

* fix the FULL_DEFENCE issue.

* fix checkstyle

* fix issue on preview

* fix checkstyle

* add unit test

* CIV-16288 Implement email notifications

* CIV-16288 Remove unused import

* CIV-16288 Fix states paid scenario

* CIV-16288 Remove unused import

---------

Co-authored-by: LeonardoPalmeiro <leonardo.palmeiro@hmcts.net>
Co-authored-by: LeonardoPalmeiro <93268657+LeonardoPalmeiro@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 27, 2025
1 parent b0a33a2 commit 042ed41
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@
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.YesOrNo;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.OrganisationService;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED_TRANSLATED_DOC;
import static uk.gov.hmcts.reform.civil.constants.SpecJourneyConstantLRSpec.HAS_PAID_THE_AMOUNT_CLAIMED;
import static uk.gov.hmcts.reform.civil.enums.RespondentResponseTypeSpec.FULL_DEFENCE;
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO;
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES;
import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.buildPartiesReferencesEmailSubject;
import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.getRespondentLegalOrganizationName;
import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.shouldSendMediationNotificationDefendant1LRCarm;
Expand Down Expand Up @@ -54,7 +56,7 @@ private CallbackResponse notifyRespondentForClaimantConfirmsToProceed(CallbackPa
boolean shouldSendEmailToDefendantLR = shouldSendMediationNotificationDefendant1LRCarm(caseData, carmEnabled);
if (shouldSendNotification(caseData, callbackParams.getRequest().getEventId())) {
notificationService.sendMail(
shouldSendEmailToDefendantLR || isIntermediateOrMultiClaimProceedForLipVsLR(caseData)
shouldSendEmailToDefendantLR || isClaimProceedForLipVsLR(caseData) || isClaimantNotProceedLipVsLRWithNoc(caseData)
? caseData.getRespondentSolicitor1EmailAddress() : caseData.getRespondent1().getPartyEmail(),
getEmailTemplate(caseData, shouldSendEmailToDefendantLR),
addProperties(caseData),
Expand All @@ -65,8 +67,13 @@ private CallbackResponse notifyRespondentForClaimantConfirmsToProceed(CallbackPa
}

private String getEmailTemplate(CaseData caseData, boolean shouldSendEmailToDefendantLR) {
if (isIntermediateOrMultiClaimProceedForLipVsLR(caseData)) {
return notificationsProperties.getRespondentSolicitorNotifyToProceedSpecWithAction();
if (isClaimProceedForLipVsLR(caseData)) {
return caseData.isSmallClaim()
? notificationsProperties.getRespondentSolicitorNotifyToProceedInMediation()
: notificationsProperties.getRespondentSolicitorNotifyToProceedSpecWithAction();
}
if (isClaimantNotProceedLipVsLRWithNoc(caseData)) {
return notificationsProperties.getRespondentSolicitorNotifyNotToProceedSpec();
}
if (shouldSendEmailToDefendantLR) {
return notificationsProperties.getNotifyDefendantLRForMediation();
Expand Down Expand Up @@ -103,7 +110,7 @@ public List<CaseEvent> handledEvents() {
@Override
public Map<String, String> addProperties(CaseData caseData) {

if (isIntermediateOrMultiClaimProceedForLipVsLR(caseData)) {
if (isClaimProceedForLipVsLR(caseData)) {
return Map.of(PARTY_REFERENCES, buildPartiesReferencesEmailSubject(caseData),
CLAIM_REFERENCE_NUMBER,
caseData.getCcdCaseReference().toString(),
Expand All @@ -112,7 +119,19 @@ public Map<String, String> addProperties(CaseData caseData) {
caseData.getRespondent1OrganisationPolicy(),
organisationService
),
APPLICANT_ONE_NAME, getPartyNameBasedOnType(caseData.getApplicant1())
APPLICANT_ONE_NAME, getPartyNameBasedOnType(caseData.getApplicant1()),
CASEMAN_REF, caseData.getLegacyCaseReference()
);
}
if (isClaimantNotProceedLipVsLRWithNoc(caseData)) {
return Map.of(PARTY_REFERENCES, buildPartiesReferencesEmailSubject(caseData),
CLAIM_REFERENCE_NUMBER,
caseData.getCcdCaseReference().toString(),
CLAIM_LEGAL_ORG_NAME_SPEC,
getRespondentLegalOrganizationName(
caseData.getRespondent1OrganisationPolicy(),
organisationService
)
);
}
if (shouldSendMediationNotificationDefendant1LRCarm(
Expand All @@ -123,7 +142,13 @@ APPLICANT_ONE_NAME, getPartyNameBasedOnType(caseData.getApplicant1())
CLAIM_REFERENCE_NUMBER,
caseData.getCcdCaseReference().toString(),
CLAIM_LEGAL_ORG_NAME_SPEC,
getRespondentLegalOrganizationName(caseData.getRespondent1OrganisationPolicy(), organisationService)
getRespondentLegalOrganizationName(caseData.getRespondent1OrganisationPolicy(), organisationService),
APPLICANT_ONE_NAME,
getPartyNameBasedOnType(caseData.getApplicant1()),
CASEMAN_REF,
caseData.getLegacyCaseReference(),
PARTY_REFERENCES,
buildPartiesReferencesEmailSubject(caseData)
);
}
return Map.of(
Expand All @@ -132,12 +157,24 @@ RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getRespondent1())
);
}

private boolean isIntermediateOrMultiClaimProceedForLipVsLR(CaseData caseData) {
List<String> responseClaimTrack = Arrays.asList("INTERMEDIATE_CLAIM", "MULTI_CLAIM");
return responseClaimTrack.contains(caseData.getResponseClaimTrack())
&& caseData.isLipvLROneVOne()
&& caseData.getApplicant1ProceedWithClaim().equals(
YesOrNo.YES)
private boolean isFullDefenceStatesPaid(CaseData caseData) {
return HAS_PAID_THE_AMOUNT_CLAIMED.equals(caseData.getDefenceRouteRequired())
&& FULL_DEFENCE.equals(caseData.getRespondent1ClaimResponseTypeForSpec());
}

private boolean isClaimProceedForLipVsLR(CaseData caseData) {
return caseData.isLipvLROneVOne()
&& ((isFullDefenceStatesPaid(caseData) && NO.equals(caseData.getCaseDataLiP().getApplicant1SettleClaim()))
|| YES.equals(caseData.getApplicant1ProceedWithClaim()))
&& featureToggleService.isDefendantNoCOnlineForCase(caseData);
}

private boolean isClaimantNotProceedLipVsLRWithNoc(CaseData caseData) {
return caseData.isLipvLROneVOne()
&& (
(isFullDefenceStatesPaid(caseData) && YES.equals(caseData.getCaseDataLiP().getApplicant1SettleClaim()))
|| NO.equals(caseData.getApplicant1ProceedWithClaim()))
&& featureToggleService.isDefendantNoCOnlineForCase(caseData);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ public class NotificationsProperties {
@NotEmpty
private String respondentSolicitorNotifyToProceedSpecWithAction;

@NotEmpty
private String respondentSolicitorNotifyToProceedInMediation;

@NotEmpty
private String applicantSolicitor1DefaultJudgmentReceived;

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ notifications:
respondentSolicitorNotifyToProceedSpec: "3ff54f97-76de-47a1-a381-680e2830fba8"
claimantSolicitorConfirmsToProceedSpecWithAction: "5d20822e-3a92-458d-94aa-2e989e192c7e"
respondentSolicitorNotifyToProceedSpecWithAction: "78856c57-8f78-4d5e-9abe-66f6cb0f07d6"
respondentSolicitorNotifyToProceedInMediation: "e231e271-93b9-49e8-99d3-5b3ceac4b3af"
applicantSolicitor1DefaultJudgmentReceived: "bceecea2-b70e-4288-be31-0a4203b31f3e"
claimantSolicitorCounterClaimForSpec: "082c6017-9bcf-4227-bc0a-bcfec2b8ebf4"
respondentSolicitorCounterClaimForSpec: "cb31a195-2a9f-4229-9abf-7f4935260ee1"
Expand Down
Loading

0 comments on commit 042ed41

Please sign in to comment.