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

DFR-3051 Fix MIAM legacy exemptions #1744

Merged
merged 25 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b4e8560
Add new version for MIAM exemption enums
jthmcts May 30, 2024
0eac507
Implement MIAM invalid legacy exemptions checks
jthmcts Jun 14, 2024
8031100
Remove Do not use text
jthmcts Jun 14, 2024
0525322
Update Form A template reference to PR version
jthmcts Jun 14, 2024
e7d226e
Fix clearing legacy MIAM fields
jthmcts Jun 14, 2024
05abd09
Fix Mini Form A values
jthmcts Jun 14, 2024
c379f91
Add javadocs
jthmcts Jun 14, 2024
5b7d84d
Merge branch 'master' into DFR-3051
jthmcts Jun 14, 2024
92e9066
Merge branch 'master' into DFR-3051
jthmcts Jun 18, 2024
3da76ae
Fix functional test
jthmcts Jun 18, 2024
868a129
Fix checkstyle
jthmcts Jun 18, 2024
3d6fc53
Merge branch 'master' into DFR-3051
jthmcts Jun 21, 2024
7273f14
Merge branch 'master' into DFR-3051
jthmcts Jun 21, 2024
283ca1b
Merge branch 'master' into DFR-3051
jthmcts Jun 24, 2024
3de6814
Merge branch 'master' into DFR-3051
jthmcts Jun 26, 2024
676996e
Merge branch 'master' into DFR-3051
jthmcts Jun 26, 2024
fe466cf
Merge branch 'master' into DFR-3051
jthmcts Jun 26, 2024
deea967
Merge branch 'master' into DFR-3051
jthmcts Jun 26, 2024
539e555
Merge branch 'master' into DFR-3051
jthmcts Jul 8, 2024
7b9450b
Merge branch 'master' into DFR-3051
jthmcts Jul 15, 2024
ac7af1f
Merge branch 'master' into DFR-3051
jthmcts Jul 17, 2024
3d88447
Merge branch 'master' into DFR-3051
jthmcts Jul 22, 2024
b944e57
Merge branch 'master' into DFR-3051
jthmcts Jul 23, 2024
f68aa86
Merge branch 'master' into DFR-3051
jthmcts Jul 23, 2024
bd40f6f
Merge branch 'master' into DFR-3051
jthmcts Jul 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_DOMESTIC_VIOLENCE_CHECKLIST;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_EXEMPTIONS_CHECKLIST;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_OTHER_GROUNDS_CHECKLIST;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_OTHER_GROUNDS_CHECKLIST_V2;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_OTHER_GROUNDS_TEXTBOX;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_PREVIOUS_ATTENDANCE_CHECKLIST;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_PREVIOUS_ATTENDANCE_CHECKLIST_V2;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_PREVIOUS_ATTENDANCE_TEXTBOX;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_URGENCY_CHECKLIST;
import static uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CCDConfigConstant.MIAM_URGENCY_TEXTBOX;
Expand Down Expand Up @@ -419,8 +421,8 @@ private String[] getMiamExemptionFields() {
MIAM_EXEMPTIONS_CHECKLIST,
MIAM_DOMESTIC_VIOLENCE_CHECKLIST,
MIAM_URGENCY_CHECKLIST,
MIAM_PREVIOUS_ATTENDANCE_CHECKLIST,
MIAM_OTHER_GROUNDS_CHECKLIST,
MIAM_PREVIOUS_ATTENDANCE_CHECKLIST_V2,
MIAM_OTHER_GROUNDS_CHECKLIST_V2,
MIAM_DOMESTIC_ABUSE_TEXTBOX,
MIAM_URGENCY_TEXTBOX,
MIAM_PREVIOUS_ATTENDANCE_TEXTBOX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
}
}
],
"MIAMOtherGroundsChecklist": "FR_ms_MIAMOtherGroundsChecklist_Value_1",
"MIAMOtherGroundsChecklistV2": "FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_V2_VALUE_5",
"applicantSolicitorAddress": {
"County": "Essex",
"Country": "United Kingdom",
Expand Down Expand Up @@ -179,7 +179,7 @@
"FR_ms_MIAMDomesticViolenceChecklist_Value_3",
"FR_ms_MIAMDomesticViolenceChecklist_Value_2"
],
"MIAMPreviousAttendanceChecklist": "FR_ms_MIAMPreviousAttendanceChecklist_Value_1",
"MIAMPreviousAttendanceChecklistV2": "FR_ms_MIAMPreviousAttendanceChecklistV2_Value_4",
"additionalPropertyOrderDecision": "No",
"applicantSolicitorConsentForEmails": "Yes"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.ccd.client.model.CallbackRequest;
import uk.gov.hmcts.reform.ccd.client.model.CaseDetails;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.MiamCheckService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.miam.MiamCheckService;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.service.FeeService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.PBAPaymentService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.PrdOrganisationService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.miam.MiamLegacyExemptionsService;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -53,12 +55,16 @@
@SuppressWarnings("unchecked")
public class PBAPaymentController extends BaseController {

private static final String MIAM_INVALID_LEGACY_EXEMPTIONS_ERROR_MESSAGE =
"The following MIAM exemptions that are no longer valid. Please re-submit the exemptions using Amend Application Details.";

private final FeeService feeService;
private final PBAPaymentService pbaPaymentService;
private final CaseDataService caseDataService;
private final AssignCaseAccessService assignCaseAccessService;
private final CcdDataStoreService ccdDataStoreService;
private final PrdOrganisationService prdOrganisationService;
private final MiamLegacyExemptionsService miamLegacyExemptionsService;

@SuppressWarnings("unchecked")
@PostMapping(path = "/pba-payment", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down Expand Up @@ -107,7 +113,15 @@ public ResponseEntity<AboutToStartOrSubmitCallbackResponse> applicantOrganisatio

validateCaseData(callbackRequest);
final Map<String, Object> mapOfCaseData = caseDetails.getData();
if (miamLegacyExemptionsService.isLegacyExemptionsInvalid(mapOfCaseData)) {
return miamInvalidLegacyExemptionsFailure(mapOfCaseData);
}

return assignApplicantSolicitor(caseDetails, authToken);
}

private ResponseEntity<AboutToStartOrSubmitCallbackResponse> assignApplicantSolicitor(CaseDetails caseDetails,
String authToken) {
if (assignCaseAccessService.isCreatorRoleActiveOnCase(caseDetails)) {
try {
String applicantOrgId = getApplicantOrgId(caseDetails);
Expand Down Expand Up @@ -144,6 +158,7 @@ public ResponseEntity<AboutToStartOrSubmitCallbackResponse> applicantOrganisatio
log.info("Applicant Policy Already Applied, Case ID: {}", caseDetails.getId());
}

final Map<String, Object> mapOfCaseData = caseDetails.getData();
mapOfCaseData.put(SUBMIT_CASE_DATE, LocalDate.now());

return ResponseEntity.ok(AboutToStartOrSubmitCallbackResponse.builder().data(mapOfCaseData).build());
Expand Down Expand Up @@ -190,4 +205,17 @@ private ResponseEntity<AboutToStartOrSubmitCallbackResponse> paymentFailure(Map<
.errors(List.of(paymentError))
.build());
}

private ResponseEntity<AboutToStartOrSubmitCallbackResponse> miamInvalidLegacyExemptionsFailure(Map<String, Object> caseData) {
List<String> invalidLegacyExemptions = miamLegacyExemptionsService.getInvalidLegacyExemptions(caseData);

List<String> errors = new ArrayList<>();
errors.add(MIAM_INVALID_LEGACY_EXEMPTIONS_ERROR_MESSAGE);
errors.addAll(invalidLegacyExemptions);

return ResponseEntity.ok(AboutToStartOrSubmitCallbackResponse.builder()
.data(caseData)
.errors(errors)
.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.CaseFlagsService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.OnlineFormDocumentService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.miam.MiamLegacyExemptionsService;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -69,6 +70,7 @@ public class UpdateContestedCaseController extends BaseController {

private final OnlineFormDocumentService onlineFormDocumentService;
private final CaseFlagsService caseFlagsService;
private final MiamLegacyExemptionsService miamLegacyExemptionsService;

@PostMapping(path = "/update-contested-case", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Handles update Contested Case details and cleans up the data fields based on the options chosen for Contested Cases")
Expand Down Expand Up @@ -142,6 +144,7 @@ private void updateContestedMiamDetails(Map<String, Object> caseData) {
} else {
removeMiamCertificationDetails(caseData);
}
removeLegacyExemptions(caseData);
}

private void removeMiamCertificationDetailsForApplicantAttendedMiam(Map<String, Object> caseData) {
Expand Down Expand Up @@ -177,6 +180,10 @@ private void removeMiamExceptionDetails(Map<String, Object> caseData) {
caseData.put(MIAM_ADDITIONAL_INFO_OTHER_GROUNDS_TEXTBOX, null);
}

private void removeLegacyExemptions(Map<String, Object> caseData) {
miamLegacyExemptionsService.removeLegacyExemptions(caseData);
}

private void updateContestedPeriodicPaymentOrder(Map<String, Object> caseData, String typeOfApplication) {
ArrayList natureOfApplicationList = typeOfApplication.equals(TYPE_OF_APPLICATION_DEFAULT_TO)
? (ArrayList) caseData.get("natureOfApplicationChecklist") : (ArrayList) caseData.get("natureOfApplicationChecklistSchedule");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,31 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.EventType;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.MiamWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.OnStartDefaultValueService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.miam.MiamLegacyExemptionsService;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class AmendApplicationContestedAboutToStartHandler extends FinremCallbackHandler {

private static final String MIAM_INVALID_LEGACY_EXEMPTIONS_WARNING_MESSAGE =
"The following MIAM exemptions are no longer valid and will be removed from the case data.";

private final OnStartDefaultValueService onStartDefaultValueService;
private final MiamLegacyExemptionsService miamLegacyExemptionsService;

public AmendApplicationContestedAboutToStartHandler(FinremCaseDetailsMapper finremCaseDetailsMapper,
OnStartDefaultValueService onStartDefaultValueService) {
OnStartDefaultValueService onStartDefaultValueService,
MiamLegacyExemptionsService miamLegacyExemptionsService) {
super(finremCaseDetailsMapper);
this.onStartDefaultValueService = onStartDefaultValueService;
this.miamLegacyExemptionsService = miamLegacyExemptionsService;
}


@Override
public boolean canHandle(CallbackType callbackType, CaseType caseType, EventType eventType) {
return CallbackType.ABOUT_TO_START.equals(callbackType)
Expand All @@ -38,8 +48,28 @@ public GenericAboutToStartOrSubmitCallbackResponse<FinremCaseData> handle(Finrem
onStartDefaultValueService.defaultCivilPartnershipField(callbackRequest);
onStartDefaultValueService.defaultTypeOfApplication(callbackRequest);

FinremCaseData caseData = callbackRequest.getCaseDetails().getData();
List<String> warnings = null;

MiamWrapper miamWrapper = caseData.getMiamWrapper();
if (miamLegacyExemptionsService.isLegacyExemptionsInvalid(miamWrapper)) {
warnings = getMiamInvalidLegacyExemptionWarnings(miamWrapper);
}
miamLegacyExemptionsService.convertLegacyExemptions(miamWrapper);

return GenericAboutToStartOrSubmitCallbackResponse.<FinremCaseData>builder()
.data(callbackRequest.getCaseDetails().getData())
.warnings(warnings)
.build();
}

private List<String> getMiamInvalidLegacyExemptionWarnings(MiamWrapper miamWrapper) {
List<String> invalidLegacyExemptions = miamLegacyExemptionsService.getInvalidLegacyExemptions(miamWrapper);

List<String> warnings = new ArrayList<>();
warnings.add(MIAM_INVALID_LEGACY_EXEMPTIONS_WARNING_MESSAGE);
warnings.addAll(invalidLegacyExemptions);

return warnings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.MiamDomesticViolence;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.MiamExemption;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.MiamOtherGrounds;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.MiamPreviousAttendance;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.MiamUrgencyReason;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.NatureApplication;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.NatureOfApplicationSchedule;
Expand Down Expand Up @@ -176,18 +174,25 @@ private ContestedMiniFormADetails.ContestedMiniFormADetailsBuilder setMiamDetail
}

private String getMiamOtherGroundsChecklist(MiamWrapper miamDetails) {
return Optional.ofNullable(miamDetails.getMiamOtherGroundsChecklist())
.map(MiamOtherGrounds::getText)
.orElse(null);
if (miamDetails.getMiamOtherGroundsChecklistV2() != null) {
return miamDetails.getMiamOtherGroundsChecklistV2().getText();
} else if (miamDetails.getMiamOtherGroundsChecklist() != null) {
return miamDetails.getMiamOtherGroundsChecklist().getText();
} else {
return null;
}
}

private String getMiamPreviousAttendanceChecklist(MiamWrapper miamDetails) {
return Optional.ofNullable(miamDetails.getMiamPreviousAttendanceChecklist())
.map(MiamPreviousAttendance::getText)
.orElse(null);
if (miamDetails.getMiamPreviousAttendanceChecklistV2() != null) {
return miamDetails.getMiamPreviousAttendanceChecklistV2().getText();
} else if (miamDetails.getMiamPreviousAttendanceChecklist() != null) {
return miamDetails.getMiamPreviousAttendanceChecklist().getText();
} else {
return null;
}
}


private List<String> getNatureOfApplicationChecklist(FinremCaseData caseData) {
List<NatureApplication> natureApplicationList = caseData.getNatureApplicationWrapper()
.getNatureOfApplicationChecklist();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ public class CCDConfigConstant {
public static final String MIAM_DOMESTIC_VIOLENCE_CHECKLIST = "MIAMDomesticViolenceChecklist";
public static final String MIAM_URGENCY_CHECKLIST = "MIAMUrgencyReasonChecklist";
public static final String MIAM_PREVIOUS_ATTENDANCE_CHECKLIST = "MIAMPreviousAttendanceChecklist";
public static final String MIAM_PREVIOUS_ATTENDANCE_CHECKLIST_V2 = "MIAMPreviousAttendanceChecklistV2";
public static final String MIAM_OTHER_GROUNDS_CHECKLIST = "MIAMOtherGroundsChecklist";
public static final String MIAM_OTHER_GROUNDS_CHECKLIST_V2 = "MIAMOtherGroundsChecklistV2";
public static final String MIAM_DOMESTIC_ABUSE_TEXTBOX = "evidenceUnavailableDomesticAbuseMIAM";
public static final String MIAM_PREVIOUS_ATTENDANCE_TEXTBOX = "evidenceUnavailablePreviousAttendanceMIAM";
public static final String MIAM_OTHER_GROUNDS_TEXTBOX = "evidenceUnavailableOtherGroundsMIAM";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
@RequiredArgsConstructor
public enum MiamOtherGrounds {
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_1("FR_ms_MIAMOtherGroundsChecklist_Value_1",
"Do not use after 29/04/2024 - The applicant is bankrupt evidenced by an application by "
"The applicant is bankrupt evidenced by an application by "
+ "the prospective applicant for a bankruptcy order;"),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_2("FR_ms_MIAMOtherGroundsChecklist_Value_2",
"Do not use after 29/04/2024 - The applicant is bankrupt evidenced by a petition by a "
"The applicant is bankrupt evidenced by a petition by a "
+ "creditor of the prospective applicant for a bankruptcy order"),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_3("FR_ms_MIAMOtherGroundsChecklist_Value_3",
"Do not use after 29/04/2024 - The applicant is bankrupt evidenced by a bankruptcy order "
"The applicant is bankrupt evidenced by a bankruptcy order "
+ "in respect of the prospective applicant."),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_4("FR_ms_MIAMOtherGroundsChecklist_Value_4",
"Do not use after 29/04/2024 - The prospective applicant does not have sufficient contact "
"The prospective applicant does not have sufficient contact "
+ "details for any of the prospective respondents to enable a family mediator to contact any"
+ " of the prospective respondents for the purpose of scheduling the MIAM."),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_5("FR_ms_MIAMOtherGroundsChecklist_Value_5",
"The application would be made without notice (Paragraph 5.1 of Practice Direction 18A sets "
+ "out the circumstances in which applications may be made without notice.)"),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_6("FR_ms_MIAMOtherGroundsChecklist_Value_6",
"Do not use after 29/04/2024 - (i) the prospective applicant is or all of the prospective "
"(i) the prospective applicant is or all of the prospective "
+ "respondents are subject to a disability or other inability that would prevent attendance "
+ "at a MIAM unless appropriate facilities can be offered by an authorised mediator; (ii) "
+ "the prospective applicant has contacted as many authorised family mediators as have an "
Expand All @@ -36,25 +36,25 @@ public enum MiamOtherGrounds {
+ "addresses and telephone numbers or e-mail addresses for such authorised family mediators, and "
+ "the dates of contact, can be provided to the court if requested."),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_7("FR_ms_MIAMOtherGroundsChecklist_Value_7",
"Do not use after 29/04/2024 - the prospective applicant or all of the prospective respondents "
"the prospective applicant or all of the prospective respondents "
+ "cannot attend a MIAM because he or she is, or they are, as the case may be (i) in prison or "
+ "any other institution in which he or she is or they are required to be detained; (ii) subject "
+ "to conditions of bail that prevent contact with the other person; or (iii) subject to a licence "
+ "with a prohibited contact requirement in relation to the other person."),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_8("FR_ms_MIAMOtherGroundsChecklist_Value_8",
"Do not use after 29/04/2024 - The prospective applicant or all of the prospective respondents "
"The prospective applicant or all of the prospective respondents "
+ "are not habitually resident in England and Wales."),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_9("FR_ms_MIAMOtherGroundsChecklist_Value_9",
"A child is one of the prospective parties."),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_10("FR_ms_MIAMOtherGroundsChecklist_Value_10",
"Do not use after 29/04/2024 - (i) the prospective applicant has contacted as many authorised "
"(i) the prospective applicant has contacted as many authorised "
+ "family mediators as have an office within fifteen miles of his or her home (or three of them if "
+ "there are three or more), and all of them have stated that they are not available to conduct a MIAM "
+ "within fifteen business days of the date of contact; and (ii) the names, postal addresses and telephone numbers"
+ " or e-mail addresses for such authorised family mediators, and the dates of contact, can be provided"
+ " to the court if requested."),
FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_11("FR_ms_MIAMOtherGroundsChecklist_Value_11",
"Do not use after 29/04/2024 - There is no authorised family mediator with an office within fifteen miles "
"There is no authorised family mediator with an office within fifteen miles "
+ "of the prospective applicant’s home."),

FR_MS_MIAM_OTHER_GROUNDS_CHECKLIST_VALUE_12("FR_ms_MIAMOtherGroundsChecklist_Value_12",
Expand Down
Loading