Skip to content

Commit

Permalink
Merge branch 'master' into feat/CIV-8997
Browse files Browse the repository at this point in the history
  • Loading branch information
ElifDenizEsea authored Nov 14, 2023
2 parents 78fdb96 + 9ac65c6 commit 120cf25
Show file tree
Hide file tree
Showing 4 changed files with 463 additions and 1,024 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,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::validateCorrespondenceAddress)
.put(callbackKey(MID, "specCorrespondenceAddress"), this::validateCorrespondenceApplicantAddress)
.put(callbackKey(MID, "determineLoggedInSolicitor"), this::determineLoggedInSolicitor)
.put(callbackKey(MID, "track"), this::handleDefendAllClaim)
.put(callbackKey(MID, "specHandleResponseType"), this::handleRespondentResponseTypeForSpec)
Expand Down Expand Up @@ -1060,26 +1060,12 @@ private AllocatedTrack getAllocatedTrack(CaseData caseData) {
);
}

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();
private CallbackResponse validateCorrespondenceApplicantAddress(CallbackParams callbackParams) {
if (SpecJourneyConstantLRSpec.DEFENDANT_RESPONSE_SPEC.equals(callbackParams.getRequest().getEventId())) {
return validateCorrespondenceApplicantAddress(callbackParams, postcodeValidator);
}
return AboutToStartOrSubmitCallbackResponse.builder().build();
return AboutToStartOrSubmitCallbackResponse.builder()
.build();
}

private CallbackResponse determineLoggedInSolicitor(CallbackParams callbackParams) {
Expand Down Expand Up @@ -1132,10 +1118,6 @@ 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 @@ -1283,9 +1265,9 @@ private CallbackResponse validateUnavailableDates(CallbackParams callbackParams)
}

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

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

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

if (caseData.getRespondent2() != null && caseData.getRespondent2Copy() != null) {
Party updatedRespondent2 = applyRespondent2Address(caseData, updatedData);
updatedData.respondent2DetailsForClaimDetailsTab(updatedRespondent2);
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());
}

// moving statement of truth value to correct field, this was not possible in mid event.
Expand Down Expand Up @@ -1500,10 +1495,8 @@ && 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 @@ -1575,21 +1568,6 @@ && isAwaitingAnotherDefendantResponse(caseData)) {
.build();
}

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

if (NO.equals(caseData.getTempCorrespondenceAddress2Required())) {
updatedRespondent2 = caseData.getRespondent2().toBuilder()
.primaryAddress(caseData.getTempCorrespondenceAddress2()).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 @@ -1604,19 +1582,19 @@ private void updateCorrespondenceAddress(CallbackParams callbackParams,
CaseData.CaseDataBuilder<?, ?> updatedCaseData,
CaseData caseData) {
if (solicitorHasCaseRole(callbackParams, RESPONDENTSOLICITORONE)
&& caseData.getRespondentSolicitor1ServiceAddressRequired() == YesOrNo.NO) {
Address newAddress = caseData.getRespondentSolicitor1ServiceAddress();
&& caseData.getSpecAoSRespondentCorrespondenceAddressRequired() == YesOrNo.NO) {
Address newAddress = caseData.getSpecAoSRespondentCorrespondenceAddressdetails();
updatedCaseData.specRespondentCorrespondenceAddressdetails(newAddress)
.respondentSolicitor1ServiceAddress(Address.builder().build());
.specAoSRespondentCorrespondenceAddressdetails(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.getRespondentSolicitor2ServiceAddressRequired() == YesOrNo.NO) {
&& caseData.getSpecAoSRespondent2CorrespondenceAddressRequired() == YesOrNo.NO) {
updatedCaseData.specRespondent2CorrespondenceAddressdetails(
caseData.getRespondentSolicitor2ServiceAddress())
.respondentSolicitor2ServiceAddress(Address.builder().build());
caseData.getSpecAoSRespondent2CorrespondenceAddressdetails())
.specAoSRespondent2CorrespondenceAddressdetails(Address.builder().build());
}
}

Expand Down
17 changes: 0 additions & 17 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,23 +723,6 @@ public boolean isApplicantNotRepresented() {

private FastTrackAllocation fastTrackAllocation;

/**
* used to temporary hold addresses.
*/
private final Address tempCorrespondenceAddress1;
/**
* used with tempCorrespondenceAddress1.
*/
private final YesOrNo tempCorrespondenceAddress1Required;
/**
* used to temporary hold addresses.
*/
private final Address tempCorrespondenceAddress2;
/**
* used with tempCorrespondenceAddress2.
*/
private final YesOrNo tempCorrespondenceAddress2Required;

@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.getRespondent2ResponseDate().toLocalDate(),
caseData.getRespondent1ResponseDate().toLocalDate(),
DEFENDANT_RESPONSE_EVENT,
respondent2DQUnavailableDates
);
Expand Down
Loading

0 comments on commit 120cf25

Please sign in to comment.