Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIV-14262 Defendant LiP Email notification Notice of Discontinuance #5106

Closed
wants to merge 117 commits into from
Closed
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
30446bc
CIV-14146: Added midEvent and validations
sjamihmcts Jul 1, 2024
70922fe
CIV-14128:Updated midEvent and caseData fields
sjamihmcts Jul 1, 2024
c78c588
CIV-14128: Added more unit tests
sjamihmcts Jul 2, 2024
1af507f
Merge branch 'master' into feat/CIV-14146_Service
sjamihmcts Jul 2, 2024
a1bda00
CIV-14128: Fix checkstyle errors
sjamihmcts Jul 2, 2024
cad29fa
CIV-14146: Fix checkstyle errors
sjamihmcts Jul 2, 2024
3b28b37
CIV-14146: Remove this field as this is not needed for now
sjamihmcts Jul 2, 2024
6a78d3a
CIV-14146: Organized imports
sjamihmcts Jul 2, 2024
2fde3a5
Merge branch 'master' into feat/CIV-14146_Service
sjamihmcts Jul 2, 2024
ec45a4e
CIV-14146: Updated tests
sjamihmcts Jul 2, 2024
c1d55ff
Merge remote-tracking branch 'origin/feat/CIV-14146_Service' into fea…
sjamihmcts Jul 2, 2024
e3ca5bb
Merge branch 'master' into feat/CIV-14146_Service
sjamihmcts Jul 2, 2024
a70d6a0
Merge branch 'master' into feat/CIV-14146_Service
Azam-Hmcts Jul 4, 2024
ae91573
Merge branch 'master' into feat/CIV-14146_Service
Azam-Hmcts Jul 4, 2024
41f01a3
Merge branch 'master' into feat/CIV-14146_Service
Azam-Hmcts Jul 4, 2024
f4ae47d
CIV-14194 initial commit
kalachandrasekar1 Jul 4, 2024
dc0b57d
Merge branch 'master' into feat/CIV-14194
kalachandrasekar1 Jul 5, 2024
728d4c7
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 5, 2024
9914458
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 5, 2024
6d3ff3e
CIV-14194 test cases added
kalachandrasekar1 Jul 5, 2024
3596e21
Merge branch 'master' into feat/CIV-14194
kalachandrasekar1 Jul 8, 2024
851320f
CIV-14194 removed extra space
kalachandrasekar1 Jul 8, 2024
8177964
CIV-14194 testcase updated
kalachandrasekar1 Jul 8, 2024
4c0fa38
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 8, 2024
52cb287
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 8, 2024
60b6690
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 8, 2024
cc362db
Merge remote-tracking branch 'origin/feat/CIV-14194' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 8, 2024
9949486
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 8, 2024
a2be09c
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 9, 2024
332c318
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 10, 2024
d9486f7
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 10, 2024
ccb300c
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 10, 2024
22c1d37
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 10, 2024
e28c2b5
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 10, 2024
0d92359
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 10, 2024
bcfd8ac
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 10, 2024
e4afdca
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 10, 2024
816226c
CIV-14244 Discontinue Claim notification
Omaira-Melo-Hmcts Jul 10, 2024
00ff58b
CIV-14244 Flow flag condition updated
Omaira-Melo-Hmcts Jul 11, 2024
770c3d5
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 12, 2024
ff3141a
CIV-14244 Flow flag condition updated
Omaira-Melo-Hmcts Jul 12, 2024
8e2711d
Merge remote-tracking branch 'origin/feat/CIV-14244' into feat/IV-14259
kalachandrasekar1 Jul 15, 2024
9195407
CIV-14259 initial commit
kalachandrasekar1 Jul 15, 2024
b433575
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 16, 2024
fcd5e67
CIV-14244 Flow flag condition updated
Omaira-Melo-Hmcts Jul 16, 2024
08d6a04
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 16, 2024
1fe8a2e
CIV-14244 Resolve imports sonar issue
Omaira-Melo-Hmcts Jul 16, 2024
26c8f7a
CIV-14244 Notification properties update
Omaira-Melo-Hmcts Jul 16, 2024
7ab6289
Merge branch 'master' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 16, 2024
59ec99e
CIV-14244 Fixin error test
Omaira-Melo-Hmcts Jul 16, 2024
6ca083d
CIV-14244 Fixin error test
Omaira-Melo-Hmcts Jul 16, 2024
85f0fa0
CIV-14244 Unused util
Omaira-Melo-Hmcts Jul 16, 2024
1165bbb
CIV-14244 Test class for GenerateNoticeOfDiscontinueClaim
Omaira-Melo-Hmcts Jul 16, 2024
3989d4d
CIV-14244 Duplication error
Omaira-Melo-Hmcts Jul 16, 2024
a3c0243
CIV-14259 testcase added
kalachandrasekar1 Jul 16, 2024
bc2e94e
CIV-14259 changes
kalachandrasekar1 Jul 16, 2024
d1bb94d
Merge branch 'feat/CIV-14244' into feat/CIV-14259
kalachandrasekar1 Jul 16, 2024
95ad0ec
Civ-14259 checkstyle fixed
kalachandrasekar1 Jul 16, 2024
c2d9e8c
CIV-14244 Fixing error for the condition to discontinue.
Omaira-Melo-Hmcts Jul 16, 2024
27f1f11
CIV-14244 Deleting the states not needed in the flowstate
Omaira-Melo-Hmcts Jul 16, 2024
f3355b9
CIV-14244 Update the flag for camunda into runtime
Omaira-Melo-Hmcts Jul 16, 2024
beb13af
Merge branch 'master' into feat/CIV-14244
sherlynkhaw Jul 16, 2024
ac31e2f
CIV-14244 Reverting changes for flowFlag on stateflowEngine
Omaira-Melo-Hmcts Jul 16, 2024
53e23f1
Merge remote-tracking branch 'origin/feat/CIV-14244' into feat/CIV-14244
Omaira-Melo-Hmcts Jul 16, 2024
edaa66d
CIV-14244 Reverting changes for flowFlag on stateflowEngine
Omaira-Melo-Hmcts Jul 16, 2024
b2ff72e
CIV-14259 code refactored
kalachandrasekar1 Jul 16, 2024
9afa62b
Merge branch 'feat/CIV-14244' into feat/CIV-14259
kalachandrasekar1 Jul 16, 2024
4b82646
CIV-14244 Reverting changes for flowFlag on stateflowEngine
Omaira-Melo-Hmcts Jul 16, 2024
8c44edc
CIV-14259 merge issue fixed
kalachandrasekar1 Jul 16, 2024
7ce3912
Merge branch 'master' into feat/CIV-14244
Azam-Hmcts Jul 16, 2024
1ac3bfa
Merge branch 'master' into feat/CIV-14259
kalachandrasekar1 Jul 17, 2024
e05e945
removed toString()
kalachandrasekar1 Jul 17, 2024
18ceb41
Merge branch 'master' into feat/CIV-14259
kalachandrasekar1 Jul 17, 2024
da81ab5
CIV-14244 Forgot upload the Defentand2 blank handler for continue wit…
Omaira-Melo-Hmcts Jul 17, 2024
9fb0dc6
CIV-14244 Error on test name
Omaira-Melo-Hmcts Jul 17, 2024
7eb9ce2
CIV-14262 Send email notification to defendant one.
Omaira-Melo-Hmcts Jul 17, 2024
2c849ee
CIV-14262 Send email notification to defendant one.
Omaira-Melo-Hmcts Jul 17, 2024
bfae6ff
CIV-14262 Send email notification to defendant one test
Omaira-Melo-Hmcts Jul 17, 2024
74a68af
CIV-14262 Send email notification to defendant one
Omaira-Melo-Hmcts Jul 17, 2024
83f7723
CIV-14262 Send email notification to defendant one
Omaira-Melo-Hmcts Jul 17, 2024
d1fbf89
Merge branch 'master' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 17, 2024
4b05b70
CIV-14262 Updating tests
Omaira-Melo-Hmcts Jul 17, 2024
304f3be
CIV-14262 Updating tests
Omaira-Melo-Hmcts Jul 17, 2024
82747a6
CIV-14262 Updating tests
Omaira-Melo-Hmcts Jul 17, 2024
edcdd5e
CIV-14262 Updating tests
Omaira-Melo-Hmcts Jul 18, 2024
8893729
CIV-14385 initial commit
kalachandrasekar1 Jul 18, 2024
4104fbd
Merge branch 'feat/CIV-14244' into feat/CIV-14259
kalachandrasekar1 Jul 18, 2024
a14a251
Merge branch 'master' into feat/CIV-14259
kalachandrasekar1 Jul 18, 2024
4177913
Merge remote-tracking branch 'origin/feat/14385' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 18, 2024
59434d1
Merge branch 'master' into feat/CIV-14259
kalachandrasekar1 Jul 18, 2024
d3f9c5f
Merge branch 'master' into feat/CIV-14244
krishnanuthalapati Jul 18, 2024
b080cd2
Merge branch 'feat/CIV-14259' into feat/14385
kalachandrasekar1 Jul 18, 2024
49a640d
Update Jenkinsfile_CNP
kalachandrasekar1 Jul 18, 2024
43ae1f2
Update Jenkinsfile_CNP
kalachandrasekar1 Jul 18, 2024
e109cee
CIV-14259 template name updated
kalachandrasekar1 Jul 18, 2024
c0995b2
Merge branch 'feat/CIV-14259' into feat/CIV-14385
kalachandrasekar1 Jul 18, 2024
b9d672f
Merge remote-tracking branch 'origin/feat/CIV-14259' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 18, 2024
c4d34bb
Merge remote-tracking branch 'origin/feat/CIV-14385' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 18, 2024
dfa199c
CIV-14262 Testing purpose
Omaira-Melo-Hmcts Jul 18, 2024
5b940e9
CIV-14262 Testing purpose
Omaira-Melo-Hmcts Jul 18, 2024
9e713d1
Merge branch 'master' into feat/CIV-14259
kalachandrasekar1 Jul 18, 2024
00a60cd
CIV-14259 testing issue fixed
kalachandrasekar1 Jul 18, 2024
a5c8c6b
CIV-14262 Testing purpose
Omaira-Melo-Hmcts Jul 19, 2024
a70156e
CIV-14259 review comments updated
kalachandrasekar1 Jul 19, 2024
1dee78b
checkstyle fixed
kalachandrasekar1 Jul 19, 2024
72b8208
CIV-14244 Fixing defendant2 notification error
Omaira-Melo-Hmcts Jul 19, 2024
c50e5da
Merge branch 'feat/CIV-14259' into feat/CIV-14385
kalachandrasekar1 Jul 19, 2024
7086135
Merge branch 'master' into feat/CIV-14385
kalachandrasekar1 Jul 19, 2024
fc87bc3
Merge branch 'feat/CIV-14244' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 19, 2024
a525560
Merge branch 'master' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 19, 2024
cc538d9
Merge branch 'master' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 19, 2024
09a2e13
Merge branch 'master' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 22, 2024
db940a8
Merge branch 'master' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 22, 2024
240f479
Merge branch 'master' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 22, 2024
640ec54
Merge remote-tracking branch 'origin/feat/CIV-14385' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 22, 2024
d60924e
Merge remote-tracking branch 'origin/feat/CIV-14262' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 22, 2024
1454272
Merge branch 'master' into feat/CIV-14262
Omaira-Melo-Hmcts Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ public enum DocumentType {
JUDGMENT_BY_ADMISSION_DEFENDANT,
JUDGMENT_BY_DETERMINATION_CLAIMANT,
JUDGMENT_BY_DETERMINATION_DEFENDANT,
ORDER_NOTICE_TRANSLATED_DOCUMENT;
ORDER_NOTICE_TRANSLATED_DOCUMENT,
NOTICE_OF_DISCONTINUANCE;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public enum DocCategory {
DQ_APP1("DQApplicant"),
DQ_DEF1("DQRespondent"),
DQ_DEF2("DQRespondentTwo"),
HEARING_NOTICES("hearingNotices");
HEARING_NOTICES("hearingNotices"),
NOTICE_OF_DISCONTINUE("discontinueNotices");

private final String value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,32 @@
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
import uk.gov.hmcts.reform.civil.enums.DocCategory;
import uk.gov.hmcts.reform.civil.enums.settlediscontinue.SettleDiscontinueYesOrNoList;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.docmosis.settlediscontinue.NoticeOfDiscontinuanceFormGenerator;
import uk.gov.hmcts.reform.civil.utils.AssignCategoryId;

import java.util.List;
import java.util.Map;

import static java.util.Objects.nonNull;
import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.GEN_NOTICE_OF_DISCONTINUANCE;

@Service
@RequiredArgsConstructor
@SuppressWarnings("unchecked")
public class GenerateDiscontinueClaimCallbackHandler extends CallbackHandler {

private static final List<CaseEvent> EVENTS = List.of(
GEN_NOTICE_OF_DISCONTINUANCE
GEN_NOTICE_OF_DISCONTINUANCE
);
private static final String TASK_ID = "GenerateNoticeOfDiscontinueClaim";
private final ObjectMapper objectMapper;

private final AssignCategoryId assignCategoryId;
private final NoticeOfDiscontinuanceFormGenerator formGenerator;
private final RuntimeService runTimeService;

@Override
Expand All @@ -49,8 +57,40 @@ public String camundaActivityId(CallbackParams callbackParams) {

private CallbackResponse aboutToSubmit(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
CaseData.CaseDataBuilder<?, ?> caseDataBuilder = caseData.toBuilder();
updateCamundaVars(caseData);
return AboutToStartOrSubmitCallbackResponse.builder().build();
buildDocument(callbackParams, caseDataBuilder);
CaseData updatedData = caseDataBuilder.build();

if (nonNull(updatedData.getNoticeOfDiscontinueCWDoc())) {
assignDiscontinuanceCategoryId(updatedData.getNoticeOfDiscontinueCWDoc());
} else {
assignDiscontinuanceCategoryId(updatedData.getNoticeOfDiscontinueAllParitiesDoc());
}
return AboutToStartOrSubmitCallbackResponse.builder()
.data(updatedData.toMap(objectMapper))
.build();
}

private void buildDocument(CallbackParams callbackParams, CaseData.CaseDataBuilder<?, ?> caseDataBuilder) {
CaseData caseData = callbackParams.getCaseData();
CaseDocument caseDocument = formGenerator.generateDocs(
callbackParams.getCaseData(),
callbackParams.getParams().get(BEARER_TOKEN).toString());
if (isPermissionRequired(caseData)) {
caseDataBuilder.noticeOfDiscontinueCWDoc(caseDocument);
} else {
caseDataBuilder.noticeOfDiscontinueAllParitiesDoc(caseDocument);
}
}

private boolean isPermissionRequired(CaseData caseData) {
return SettleDiscontinueYesOrNoList.YES.equals(caseData.getCourtPermissionNeeded())
&& SettleDiscontinueYesOrNoList.YES.equals(caseData.getIsPermissionGranted());
}

private void assignDiscontinuanceCategoryId(CaseDocument caseDocument) {
assignCategoryId.assignCategoryIdToCaseDocument(caseDocument, DocCategory.NOTICE_OF_DISCONTINUE.getValue());
}

private void updateCamundaVars(CaseData caseData) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.docmosis;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse;
import uk.gov.hmcts.reform.civil.callback.Callback;
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.service.docmosis.settlediscontinue.NoticeOfDiscontinuanceLiPLetterGenerator;

import java.util.List;
import java.util.Map;

import static uk.gov.hmcts.reform.civil.callback.CallbackParams.Params.BEARER_TOKEN;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.SEND_DISCONTINUANCE_LETTER_LIP_DEFENDANT1;

@Service
@RequiredArgsConstructor
public class PostNoticeOfDiscontinuanceLetterLiPDefendant1Handler extends CallbackHandler {

private static final List<CaseEvent> EVENTS = List.of(
SEND_DISCONTINUANCE_LETTER_LIP_DEFENDANT1);

public static final String TASK_ID = "PostNoticeOfDiscontinuanceDefendant1LIP";
private final NoticeOfDiscontinuanceLiPLetterGenerator lipLetterGenerator;

@Override
protected Map<String, Callback> callbacks() {
return Map.of(
callbackKey(ABOUT_TO_SUBMIT),
this::sendNoticeOfDiscontinuanceLetterToLiPDefendant1
);
}

@Override
public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
}

@Override
public List<CaseEvent> handledEvents() {
return EVENTS;
}

private CallbackResponse sendNoticeOfDiscontinuanceLetterToLiPDefendant1(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
if (isRespondent1Lip(caseData)) {
generateNoticeOfDiscontinuanceLiPDefendantLetter(callbackParams);
}
return AboutToStartOrSubmitCallbackResponse.builder().build();
}

private boolean isRespondent1Lip(CaseData caseData) {
return YesOrNo.NO.equals(caseData.getRespondent1Represented());
}

private void generateNoticeOfDiscontinuanceLiPDefendantLetter(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
lipLetterGenerator.printNoticeOfDiscontinuanceLetter(caseData, callbackParams.getParams().get(BEARER_TOKEN).toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DISCONTINUANCE_DEFENDANT1;
import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.getRespondentLegalOrganizationName;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getAllPartyNames;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -62,6 +63,13 @@ private CallbackResponse notifyDefendantClaimDiscontinued(CallbackParams callbac
addProperties(caseData),
getReferenceTemplate(caseData)
);
} else {
notificationService.sendMail(
caseData.getRespondent1().getPartyEmail(),
getLIPTemplate(),
addPropertiesLip(caseData),
getReferenceTemplate(caseData)
);
}

return AboutToStartOrSubmitCallbackResponse.builder().build();
Expand All @@ -71,6 +79,10 @@ private String getLRTemplate() {
return notificationsProperties.getNotifyClaimDiscontinuedLRTemplate();
}

private String getLIPTemplate() {
return notificationsProperties.getNotifyLipUpdateTemplate();
}

private String getReferenceTemplate(CaseData caseData) {
return String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference());
}
Expand All @@ -84,4 +96,12 @@ public Map<String, String> addProperties(CaseData caseData) {
getRespondentLegalOrganizationName(caseData.getRespondent1OrganisationPolicy(), organisationService)
);
}

public Map<String, String> addPropertiesLip(CaseData caseData) {
return Map.of(
CLAIMANT_V_DEFENDANT, getAllPartyNames(caseData),
CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(),
PARTY_NAME, caseData.getRespondent1().getPartyName()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,9 @@ public boolean hasNoOngoingBusinessProcess() {
private SettleDiscontinueYesOrNoList isDiscontinuingAgainstBothDefendants;
private SettlementReason settleReason;
private final MarkPaidConsentList markPaidConsent;

private YesOrNo claimantsConsentToDiscontinuance;
private CaseDocument noticeOfDiscontinueCWDoc;
private CaseDocument noticeOfDiscontinueAllParitiesDoc;
@JsonUnwrapped
private FeePaymentOutcomeDetails feePaymentOutcomeDetails;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package uk.gov.hmcts.reform.civil.model.docmosis.settleanddiscontinue;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import uk.gov.hmcts.reform.civil.model.common.MappableObject;

import java.time.LocalDate;

@Getter
@Builder
@AllArgsConstructor
@EqualsAndHashCode
public class NoticeOfDiscontinuanceForm implements MappableObject {

private final String caseNumber;
private final String claimant1Name;
private final String claimant2Name;
private final String defendant1Name;
private final String defendant2Name;
private final String claimantNum;
private final String defendantNum;
private String claimantWhoIsDiscontinue;
private String claimantsConsentToDiscontinuance;
private String courtPermission;
private String permissionGranted;
private String judgeName;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy")
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate judgementDate;
private String discontinuingAgainstBothDefendants;
private String discontinuingAgainstOneDefendant;
private String typeOfDiscontinuance;
private String typeOfDiscontinuanceTxt;
private String partOfDiscontinuanceTxt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public enum DocmosisTemplates {
JUDGMENT_BY_ADMISSION_CLAIMANT("CV-SPC-DEC-ENG-00916.docx", "Judgment_by_admission_claimant.pdf"),
JUDGMENT_BY_ADMISSION_DEFENDANT("CV-SPC-DEC-ENG-00915.docx", "Judgment_by_admission_defendant.pdf"),
JUDGMENT_BY_DETERMINATION_CLAIMANT("CV-SPC-DEC-ENG-00982.docx", "Judgment_by_determination_claimant.pdf"),
JUDGMENT_BY_DETERMINATION_DEFENDANT("CV-SPC-DEC-ENG-00981.docx", "Judgment_by_determination_defendant.pdf");
JUDGMENT_BY_DETERMINATION_DEFENDANT("CV-SPC-DEC-ENG-00981.docx", "Judgment_by_determination_defendant.pdf"),
NOTICE_OF_DISCONTINUANCE_PDF("CV-CMC-GNO-ENG-SD0001.docx", "notice_of_discontinuance_%s.pdf");

private final String template;
private final String documentTitle;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package uk.gov.hmcts.reform.civil.service.docmosis.settlediscontinue;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.civil.documentmanagement.DocumentManagementService;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
import uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType;
import uk.gov.hmcts.reform.civil.documentmanagement.model.PDF;
import uk.gov.hmcts.reform.civil.enums.settlediscontinue.SettleDiscontinueYesOrNoList;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.docmosis.DocmosisDocument;
import uk.gov.hmcts.reform.civil.model.docmosis.settleanddiscontinue.NoticeOfDiscontinuanceForm;
import uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates;
import uk.gov.hmcts.reform.civil.service.docmosis.DocumentGeneratorService;
import uk.gov.hmcts.reform.civil.service.docmosis.TemplateDataGenerator;

import static java.util.Objects.nonNull;
import static uk.gov.hmcts.reform.civil.service.docmosis.DocmosisTemplates.NOTICE_OF_DISCONTINUANCE_PDF;

@Slf4j
@Service
@RequiredArgsConstructor
public class NoticeOfDiscontinuanceFormGenerator implements TemplateDataGenerator<NoticeOfDiscontinuanceForm> {

private final DocumentManagementService documentManagementService;
private final DocumentGeneratorService documentGeneratorService;

public CaseDocument generateDocs(CaseData caseData, String authorisation) {
NoticeOfDiscontinuanceForm templateData = getNoticeOfDiscontinueData(caseData);
DocmosisTemplates docmosisTemplate = NOTICE_OF_DISCONTINUANCE_PDF;
DocmosisDocument docmosisDocument =
documentGeneratorService.generateDocmosisDocument(templateData, docmosisTemplate);

return documentManagementService.uploadDocument(
authorisation,
new PDF(
getFileName(caseData, docmosisTemplate),
docmosisDocument.getBytes(),
DocumentType.NOTICE_OF_DISCONTINUANCE
)
);
}

private String getFileName(CaseData caseData, DocmosisTemplates docmosisTemplate) {
return String.format(docmosisTemplate.getDocumentTitle(), caseData.getLegacyCaseReference());
}

private NoticeOfDiscontinuanceForm getNoticeOfDiscontinueData(CaseData caseData) {
var noticeOfDiscontinueBuilder = NoticeOfDiscontinuanceForm.builder()
.caseNumber(caseData.getLegacyCaseReference())
.claimant1Name(caseData.getApplicant1().getPartyName())
.claimant2Name(nonNull(caseData.getApplicant2()) ? caseData.getApplicant2().getPartyName() : null)
.defendant1Name(caseData.getRespondent1().getPartyName())
.defendant2Name(nonNull(caseData.getRespondent2()) ? caseData.getRespondent2().getPartyName() : null)
.claimantNum(nonNull(caseData.getApplicant2()) ? "Claimant 1" : "Claimant")
.defendantNum(nonNull(caseData.getRespondent2()) ? "Defendant 1" : "Defendant")
.claimantWhoIsDiscontinue(getClaimantWhoIsDiscontinue(caseData))
.claimantsConsentToDiscontinuance(nonNull(caseData.getClaimantsConsentToDiscontinuance())
? caseData.getClaimantsConsentToDiscontinuance().toString() : null)
.courtPermission(caseData.getCourtPermissionNeeded().getDisplayedValue())
.permissionGranted(nonNull(caseData.getIsPermissionGranted()) ? caseData.getIsPermissionGranted().getDisplayedValue() : null)
.judgeName(isCourtPermissionGranted(caseData)
? caseData.getPermissionGrantedComplex().getPermissionGrantedJudge() : null)
.judgementDate(isCourtPermissionGranted(caseData)
? caseData.getPermissionGrantedComplex().getPermissionGrantedDate() : null)
.typeOfDiscontinuance(caseData.getTypeOfDiscontinuance().toString())
.typeOfDiscontinuanceTxt(caseData.getTypeOfDiscontinuance().getType())
.partOfDiscontinuanceTxt(caseData.getPartDiscontinuanceDetails())
.discontinuingAgainstOneDefendant(nonNull(caseData.getDiscontinuingAgainstOneDefendant())
? caseData.getDiscontinuingAgainstOneDefendant().getValue().getLabel() : null)
.discontinuingAgainstBothDefendants(nonNull(caseData.getIsDiscontinuingAgainstBothDefendants())
? caseData.getIsDiscontinuingAgainstBothDefendants().getDisplayedValue() : null);
return noticeOfDiscontinueBuilder.build();
}

private String getClaimantWhoIsDiscontinue(CaseData caseData) {
return nonNull(caseData.getClaimantWhoIsDiscontinuing())
? caseData.getClaimantWhoIsDiscontinuing().getValue().getLabel()
: caseData.getApplicant1().getPartyName();
}

private boolean isCourtPermissionGranted(CaseData caseData) {
return nonNull(caseData.getIsPermissionGranted())
&& SettleDiscontinueYesOrNoList.YES.equals(caseData.getIsPermissionGranted());
}
}

Loading
Loading