Skip to content

Commit

Permalink
Merge branch 'master' into CIV-8903-dashboard-settlement-agreement
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-pearson authored Nov 14, 2023
2 parents 7aa2ffd + ef0198c commit 6a8cf15
Show file tree
Hide file tree
Showing 20 changed files with 1,204 additions and 473 deletions.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01067.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01068.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01069.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01073.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01075.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01076.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-GAP-ENG-01078.docx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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.TRIGGER_LOCATION_UPDATE;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.TRIGGER_UPDATE_GA_LOCATION;
Expand Down Expand Up @@ -44,9 +45,10 @@ public List<CaseEvent> handledEvents() {

private CallbackResponse triggerGaEvent(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
String authToken = callbackParams.getParams().get(BEARER_TOKEN).toString();
try {
if (caseData.getGeneralApplications() != null && !caseData.getGeneralApplications().isEmpty()) {
caseData = helperService.updateApplicationLocationDetailsInClaim(caseData);
caseData = helperService.updateApplicationLocationDetailsInClaim(caseData, authToken);
helperService.triggerEvent(caseData, TRIGGER_LOCATION_UPDATE);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import uk.gov.hmcts.reform.civil.enums.CaseState;
import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.enums.finalorders.CostEnums;
import uk.gov.hmcts.reform.civil.enums.finalorders.FinalOrderToggle;
import uk.gov.hmcts.reform.civil.enums.finalorders.HearingLengthFinalOrderList;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
Expand Down Expand Up @@ -66,6 +67,9 @@
import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.TWO_V_ONE;
import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario;
import static uk.gov.hmcts.reform.civil.enums.caseprogression.FinalOrderSelection.ASSISTED_ORDER;
import static uk.gov.hmcts.reform.civil.enums.finalorders.CostEnums.CLAIMANT;
import static uk.gov.hmcts.reform.civil.enums.finalorders.CostEnums.STANDARD_BASIS;
import static uk.gov.hmcts.reform.civil.enums.finalorders.CostEnums.SUBJECT_DETAILED_ASSESSMENT;
import static uk.gov.hmcts.reform.civil.enums.finalorders.FinalOrderRepresentationList.CLAIMANT_AND_DEFENDANT;
import static uk.gov.hmcts.reform.civil.model.common.DynamicList.fromList;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element;
Expand Down Expand Up @@ -289,6 +293,10 @@ private DynamicList populateCurrentHearingLocation(CaseData caseData, String aut
.assistedOrderCostsFirstDropdownDate(advancedDate)
.assistedOrderAssessmentThirdDropdownDate(advancedDate)
.makeAnOrderForCostsYesOrNo(YesOrNo.NO)
.makeAnOrderForCostsList(CLAIMANT)
.assistedOrderClaimantDefendantFirstDropdown(SUBJECT_DETAILED_ASSESSMENT)
.assistedOrderAssessmentSecondDropdownList1(STANDARD_BASIS)
.assistedOrderAssessmentSecondDropdownList2(CostEnums.NO)
.build())
.publicFundingCostsProtection(YesOrNo.NO)
.finalOrderAppealComplex(FinalOrderAppeal.builder()
Expand Down
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::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 @@ -1060,12 +1060,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 @@ -1118,6 +1132,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 @@ -1265,9 +1283,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 @@ -1345,9 +1363,9 @@ private CallbackResponse setApplicantResponseDeadline(CallbackParams callbackPar
AllocatedTrack allocatedTrack = caseData.getAllocatedTrack();
Party updatedRespondent1;

if (NO.equals(caseData.getSpecAoSApplicantCorrespondenceAddressRequired())) {
if (NO.equals(caseData.getTempCorrespondenceAddress1Required())) {
updatedRespondent1 = caseData.getRespondent1().toBuilder()
.primaryAddress(caseData.getSpecAoSApplicantCorrespondenceAddressdetails()).build();
.primaryAddress(caseData.getTempCorrespondenceAddress1()).build();
} else {
updatedRespondent1 = caseData.getRespondent1().toBuilder()
.primaryAddress(caseData.getRespondent1Copy().getPrimaryAddress())
Expand Down Expand Up @@ -1424,21 +1442,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 @@ -1495,8 +1500,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 @@ -1568,6 +1575,21 @@ && 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 @@ -1582,19 +1604,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 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 @@ -14,4 +14,6 @@ public class CaseLocationCivil {
private String region;
private String siteName;
private String baseLocation;
private String address;
private String postcode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import uk.gov.hmcts.reform.civil.model.genapplication.GADetailsRespondentSol;
import uk.gov.hmcts.reform.civil.model.genapplication.GeneralApplication;
import uk.gov.hmcts.reform.civil.model.genapplication.GeneralApplicationsDetails;
import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -31,6 +32,7 @@ public class GenAppStateHelperService {

private final CoreCaseDataService coreCaseDataService;
private final CaseDetailsConverter caseDetailsConverter;
private final InitiateGeneralApplicationService genAppService;

private final ObjectMapper objectMapper;

Expand Down Expand Up @@ -69,16 +71,19 @@ public boolean triggerEvent(CaseData caseData, CaseEvent event) {
return true;
}

public CaseData updateApplicationLocationDetailsInClaim(CaseData caseData) {
public CaseData updateApplicationLocationDetailsInClaim(CaseData caseData, String authToken) {

if (!Collections.isEmpty(caseData.getGeneralApplications())) {
List<GeneralApplication> genApps = new ArrayList<>();
CaseData finalCaseData = caseData;
LocationRefData locationDetails = genAppService.getWorkAllocationLocationDetails(finalCaseData.getCaseManagementLocation().getBaseLocation(), authToken);
caseData.getGeneralApplications().forEach(generalApplicationElement -> {
GeneralApplication generalApplication = generalApplicationElement.getValue();
generalApplication.getCaseManagementLocation().setBaseLocation(finalCaseData.getCaseManagementLocation().getBaseLocation());
generalApplication.getCaseManagementLocation().setRegion(finalCaseData.getCaseManagementLocation().getRegion());
generalApplication.getCaseManagementLocation().setSiteName(finalCaseData.getLocationName());
generalApplication.getCaseManagementLocation().setSiteName(locationDetails.getSiteName());
generalApplication.getCaseManagementLocation().setAddress(locationDetails.getCourtAddress());
generalApplication.getCaseManagementLocation().setPostcode(locationDetails.getPostcode());
Map<String, Object> genAppMap = generalApplication.toMap(objectMapper);
genAppMap.put("isCcmccLocation", YesOrNo.NO);
generalApplication = objectMapper.convertValue(genAppMap, GeneralApplication.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ private GeneralApplication buildApplication(CaseData.CaseDataBuilder dataBuilder

Pair<CaseLocationCivil, Boolean> caseLocation = getWorkAllocationLocation(caseData, authToken);
//Setting Work Allocation location and location name
if (Objects.isNull(caseLocation.getLeft().getSiteName())
&& Objects.nonNull(caseLocation.getLeft().getBaseLocation())) {
LocationRefData locationDetails = getWorkAllocationLocationDetails(caseLocation.getLeft().getBaseLocation(), authToken);
caseLocation.getLeft().setSiteName(locationDetails.getSiteName());
caseLocation.getLeft().setAddress(locationDetails.getCourtAddress());
caseLocation.getLeft().setPostcode(locationDetails.getPostcode());
}
applicationBuilder.caseManagementLocation(caseLocation.getLeft());
applicationBuilder.isCcmccLocation(caseLocation.getRight() ? YES : NO);
applicationBuilder.locationName(hasSDOBeenMade(caseData.getCcdState())
Expand Down Expand Up @@ -343,6 +350,8 @@ public Pair<CaseLocationCivil, Boolean> getWorkAllocationLocation(CaseData caseD
.region(ccmccLocation.getRegionId())
.baseLocation(ccmccLocation.getEpimmsId())
.siteName(ccmccLocation.getSiteName())
.address(ccmccLocation.getCourtAddress())
.postcode(ccmccLocation.getPostcode())
.build();
return Pair.of(courtLocation, true);
}
Expand All @@ -369,6 +378,15 @@ private CaseLocationCivil getClaimant1PreferredLocation(CaseData caseData) {
.build();
}

public LocationRefData getWorkAllocationLocationDetails(String baseLocation, String authToken) {
List<LocationRefData> locationDetails = locationRefDataService.getCourtLocationsByEpimmsId(authToken, baseLocation);
if (locationDetails != null && !locationDetails.isEmpty()) {
return locationDetails.get(0);
} else {
return LocationRefData.builder().build();
}
}

private boolean isDefendant1RespondedFirst(CaseData caseData) {
return caseData.getRespondent2ResponseDate() == null
|| (caseData.getRespondent1ResponseDate() != null
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 6a8cf15

Please sign in to comment.