Skip to content

Commit

Permalink
Merge branch 'master' into feat/civ-10124
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth40342 committed Nov 14, 2023
2 parents 5ac7320 + f8969cd commit 5ce90d4
Show file tree
Hide file tree
Showing 4 changed files with 1,023 additions and 458 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected Map<String, Callback> callbacks() {
.put(callbackKey(MID, "upload"), this::emptyCallbackResponse)
.put(callbackKey(MID, "statement-of-truth"), this::resetStatementOfTruth)
.put(callbackKey(MID, "validate-payment-date"), this::validateRespondentPaymentDate)
.put(callbackKey(MID, "specCorrespondenceAddress"), this::validateCorrespondenceApplicantAddress)
.put(callbackKey(MID, "specCorrespondenceAddress"), this::validateCorrespondenceAddress)
.put(callbackKey(MID, "determineLoggedInSolicitor"), this::determineLoggedInSolicitor)
.put(callbackKey(MID, "track"), this::handleDefendAllClaim)
.put(callbackKey(MID, "specHandleResponseType"), this::handleRespondentResponseTypeForSpec)
Expand Down Expand Up @@ -1059,12 +1059,26 @@ private AllocatedTrack getAllocatedTrack(CaseData caseData) {
);
}

private CallbackResponse validateCorrespondenceApplicantAddress(CallbackParams callbackParams) {
if (SpecJourneyConstantLRSpec.DEFENDANT_RESPONSE_SPEC.equals(callbackParams.getRequest().getEventId())) {
return validateCorrespondenceApplicantAddress(callbackParams, postcodeValidator);
private CallbackResponse validateCorrespondenceAddress(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
if (caseData.getIsRespondent1() == YES
&& caseData.getRespondentSolicitor1ServiceAddressRequired() == NO) {
List<String> errors = postcodeValidator.validate(
caseData.getRespondentSolicitor1ServiceAddress().getPostCode());

return AboutToStartOrSubmitCallbackResponse.builder()
.errors(errors)
.build();
} else if (caseData.getIsRespondent2() == YES
&& caseData.getRespondentSolicitor2ServiceAddressRequired() == NO) {
List<String> errors = postcodeValidator.validate(
caseData.getRespondentSolicitor2ServiceAddress().getPostCode());

return AboutToStartOrSubmitCallbackResponse.builder()
.errors(errors)
.build();
}
return AboutToStartOrSubmitCallbackResponse.builder()
.build();
return AboutToStartOrSubmitCallbackResponse.builder().build();
}

private CallbackResponse determineLoggedInSolicitor(CallbackParams callbackParams) {
Expand Down Expand Up @@ -1117,6 +1131,10 @@ private CallbackResponse populateRespondent1Copy(CallbackParams callbackParams)
.respondent1Copy(caseData.getRespondent1())
.respondent1ClaimResponseTestForSpec(caseData.getRespondent1ClaimResponseTypeForSpec())
.respondent2ClaimResponseTestForSpec(caseData.getRespondent2ClaimResponseTypeForSpec())
.respondentSolicitor1ServiceAddress(Address.builder().build())
.respondentSolicitor2ServiceAddress(Address.builder().build())
.respondentSolicitor1ServiceAddressRequired(null)
.respondentSolicitor2ServiceAddressRequired(null)
.showConditionFlags(initialShowTags);

updatedCaseData.respondent1DetailsForClaimDetailsTab(caseData.getRespondent1().toBuilder().flags(null).build());
Expand Down Expand Up @@ -1264,9 +1282,9 @@ private CallbackResponse validateUnavailableDates(CallbackParams callbackParams)
}

private CallbackResponse validateDateOfBirth(CallbackParams callbackParams) {
Party respondent = callbackParams.getCaseData().getRespondent1();
if (respondent == null && callbackParams.getCaseData().getRespondent2() != null) {
respondent = callbackParams.getCaseData().getRespondent2();
Party respondent = callbackParams.getCaseData().getRespondent1Copy();
if (respondent == null && callbackParams.getCaseData().getRespondent2Copy() != null) {
respondent = callbackParams.getCaseData().getRespondent2Copy();
}
List<String> errors = dateOfBirthValidator.validate(respondent);

Expand Down Expand Up @@ -1344,9 +1362,9 @@ private CallbackResponse setApplicantResponseDeadline(CallbackParams callbackPar
AllocatedTrack allocatedTrack = caseData.getAllocatedTrack();
Party updatedRespondent1;

if (NO.equals(caseData.getSpecAoSApplicantCorrespondenceAddressRequired())) {
if (NO.equals(caseData.getTempAddress1Required())) {
updatedRespondent1 = caseData.getRespondent1().toBuilder()
.primaryAddress(caseData.getSpecAoSApplicantCorrespondenceAddressdetails()).build();
.primaryAddress(caseData.getTempAddress1()).build();
} else {
updatedRespondent1 = caseData.getRespondent1().toBuilder()
.primaryAddress(caseData.getRespondent1Copy().getPrimaryAddress())
Expand Down Expand Up @@ -1423,21 +1441,8 @@ && ifResponseTypeIsPartOrFullAdmission(caseData)) {
.businessProcess(BusinessProcess.ready(DEFENDANT_RESPONSE_SPEC));

if (caseData.getRespondent2() != null && caseData.getRespondent2Copy() != null) {
Party updatedRespondent2;

if (NO.equals(caseData.getSpecAoSRespondent2HomeAddressRequired())) {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getSpecAoSRespondent2HomeAddressDetails()).build();
} else {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getRespondent2Copy().getPrimaryAddress()).build();
}

updatedData
.respondent2(updatedRespondent2.toBuilder()
.flags(caseData.getRespondent2Copy().getFlags()).build())
.respondent2Copy(null);
updatedData.respondent2DetailsForClaimDetailsTab(updatedRespondent2.toBuilder().flags(null).build());
Party updatedRespondent2 = applyRespondent2Address(caseData, updatedData);
updatedData.respondent2DetailsForClaimDetailsTab(updatedRespondent2);
}

// moving statement of truth value to correct field, this was not possible in mid event.
Expand Down Expand Up @@ -1494,8 +1499,10 @@ && ifResponseTypeIsPartOrFullAdmission(caseData)) {
.build());
}

UnavailabilityDatesUtils.rollUpUnavailabilityDatesForRespondent(updatedData,
toggleService.isUpdateContactDetailsEnabled());
UnavailabilityDatesUtils.rollUpUnavailabilityDatesForRespondent(
updatedData,
toggleService.isUpdateContactDetailsEnabled()
);

updatedData.respondent1DetailsForClaimDetailsTab(updatedData.build().getRespondent1().toBuilder().flags(null).build());
if (ofNullable(caseData.getRespondent2()).isPresent()) {
Expand Down Expand Up @@ -1563,6 +1570,21 @@ && isAwaitingAnotherDefendantResponse(caseData)) {
.build();
}

private static Party applyRespondent2Address(CaseData caseData, CaseData.CaseDataBuilder<?, ?> updatedData) {
Party updatedRespondent2;

if (NO.equals(caseData.getTempAddress2Required())) {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getTempAddress2()).build();
} else {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getRespondent2Copy().getPrimaryAddress()).build();
}

updatedData.respondent2(updatedRespondent2).respondent2Copy(null);
return updatedRespondent2;
}

private boolean ifResponseTypeIsPartOrFullAdmission(CaseData caseData) {
return (RespondentResponseTypeSpec.PART_ADMISSION.equals(caseData.getRespondent1ClaimResponseTypeForSpec())
|| RespondentResponseTypeSpec.PART_ADMISSION.equals(
Expand All @@ -1577,19 +1599,19 @@ private void updateCorrespondenceAddress(CallbackParams callbackParams,
CaseData.CaseDataBuilder<?, ?> updatedCaseData,
CaseData caseData) {
if (solicitorHasCaseRole(callbackParams, RESPONDENTSOLICITORONE)
&& caseData.getSpecAoSRespondentCorrespondenceAddressRequired() == YesOrNo.NO) {
Address newAddress = caseData.getSpecAoSRespondentCorrespondenceAddressdetails();
&& caseData.getRespondentSolicitor1ServiceAddressRequired() == YesOrNo.NO) {
Address newAddress = caseData.getRespondentSolicitor1ServiceAddress();
updatedCaseData.specRespondentCorrespondenceAddressdetails(newAddress)
.specAoSRespondentCorrespondenceAddressdetails(Address.builder().build());
.respondentSolicitor1ServiceAddress(Address.builder().build());
if (getMultiPartyScenario(caseData) == ONE_V_TWO_ONE_LEGAL_REP) {
// to keep with heading tab
updatedCaseData.specRespondent2CorrespondenceAddressdetails(newAddress);
}
} else if (solicitorHasCaseRole(callbackParams, RESPONDENTSOLICITORTWO)
&& caseData.getSpecAoSRespondent2CorrespondenceAddressRequired() == YesOrNo.NO) {
&& caseData.getRespondentSolicitor2ServiceAddressRequired() == YesOrNo.NO) {
updatedCaseData.specRespondent2CorrespondenceAddressdetails(
caseData.getSpecAoSRespondent2CorrespondenceAddressdetails())
.specAoSRespondent2CorrespondenceAddressdetails(Address.builder().build());
caseData.getRespondentSolicitor2ServiceAddress())
.respondentSolicitor2ServiceAddress(Address.builder().build());
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/uk/gov/hmcts/reform/civil/model/CaseDataParent.java
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,23 @@ public boolean isApplicantNotRepresented() {

private FastTrackAllocation fastTrackAllocation;

/**
* used to temporary hold addresses.
*/
private final Address tempAddress1;
/**
* used with tempAddress1.
*/
private final YesOrNo tempAddress1Required;
/**
* used to temporary hold addresses.
*/
private final Address tempAddress2;
/**
* used with tempAddress1.
*/
private final YesOrNo tempAddress2Required;

@JsonIgnore
public boolean isResponseAcceptedByClaimant() {
return applicant1AcceptAdmitAmountPaidSpec == YesOrNo.YES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static void rollUpUnavailabilityDatesForRespondent(CaseData.CaseDataBuild
.getUnavailableDates();

List<Element<UnavailableDate>> updatedUnavailableDates = addEventAndDate(
caseData.getRespondent1ResponseDate().toLocalDate(),
caseData.getRespondent2ResponseDate().toLocalDate(),
DEFENDANT_RESPONSE_EVENT,
respondent2DQUnavailableDates
);
Expand Down
Loading

0 comments on commit 5ce90d4

Please sign in to comment.