Skip to content

Commit

Permalink
CIV-15766 Set Aside Judgment RPA (#5889)
Browse files Browse the repository at this point in the history
* CIV-15997 changes

* CIV-15997-changes

* CIV-15997 changes

* CIV-15997 validation message updated

* Initial Checkin

* changes

* update

* Intermediate commit

* fixes

* fix check style

* changed test

* fix

---------

Co-authored-by: kalachandrasekar1 <[email protected]>
Co-authored-by: kalachandrasekar1 <[email protected]>
Co-authored-by: krishnanuthalapati <[email protected]>
Co-authored-by: Azam <[email protected]>
  • Loading branch information
5 people authored Dec 17, 2024
1 parent 5fa58eb commit 29a3f2b
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@
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.CaseState;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.helpers.judgmentsonline.JudgmentsOnlineHelper;
import uk.gov.hmcts.reform.civil.helpers.judgmentsonline.SetAsideJudgmentOnlineMapper;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.judgmentonline.JudgmentSetAsideOrderType;
import uk.gov.hmcts.reform.civil.service.DeadlinesCalculator;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_START;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
Expand All @@ -45,7 +43,6 @@ public class SetAsideJudgmentCallbackHandler extends CallbackHandler {
"Application date to set aside judgment must be on or before the date of the order setting aside judgment";
private static final String ERROR_MESSAGE_DEFENCE_DATE =
"Date the defence was received must be on or before the date of the order setting aside judgment";
private final DeadlinesCalculator deadlinesCalculator;

@Override
protected Map<String, Callback> callbacks() {
Expand Down Expand Up @@ -99,20 +96,11 @@ private CallbackResponse saveJudgmentDetails(CallbackParams callbackParams) {
setAsideJudgmentOnlineMapper.moveToHistoricJudgment(caseData);

CaseData.CaseDataBuilder<?, ?> caseDataBuilder = caseData.toBuilder();
caseDataBuilder.businessProcess(BusinessProcess.ready(SET_ASIDE_JUDGMENT));
String nextState;
if (Objects.nonNull(caseData.getJoSetAsideOrderType()) && caseData.getJoSetAsideOrderType().equals(
JudgmentSetAsideOrderType.ORDER_AFTER_APPLICATION)) {
nextState = CaseState.AWAITING_RESPONDENT_ACKNOWLEDGEMENT.name();
caseDataBuilder.respondent1ResponseDeadline(deadlinesCalculator.plus28DaysAt4pmDeadline(
caseData.getJoSetAsideOrderDate().atTime(0, 0)));
} else {
nextState = caseData.getCcdState().name();
}
caseDataBuilder.businessProcess(BusinessProcess.ready(SET_ASIDE_JUDGMENT))
.joSetAsideCreatedDate(LocalDateTime.now());

return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseDataBuilder.build().toMap(objectMapper))
.state(nextState)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ public boolean hasNoOngoingBusinessProcess() {
private YesOrNo joShowRegisteredWithRTLOption;
private JudgmentDetails activeJudgment;
private List<Element<JudgmentDetails>> historicJudgment;
private LocalDateTime joSetAsideCreatedDate;

private String joDefendantName1;
private String joDefendantName2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package uk.gov.hmcts.reform.civil.model.judgmentonline;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum SetAsideApplicantTypeForRPA {
PROPER_OFFICER("PROPER OFFICER"),
PARTY_AGAINST("PARTY AGAINST");

private final String value;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package uk.gov.hmcts.reform.civil.model.judgmentonline;

public enum SetAsideResultTypeForRPA {
GRANTED
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ public class EventDetails {
private LocalDateTime dateOfJudgment;
private Boolean jointJudgment;
private Boolean judgmentToBeRegistered;
//Set Aside Judgment
private String result;
private String applicant;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate applicationDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate resultDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate datePaidInFull;
private String status;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate notificationReceiptDate;

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class EventHistory {
private List<Event> interlocutoryJudgment;
@Singular("defaultJudgment")
private List<Event> defaultJudgment;
@Singular("setAsideJudgment")
private List<Event> setAsideJudgment;
@Singular("statesPaid")
private List<Event> statesPaid;
@Singular("judgmentByAdmission")
Expand Down Expand Up @@ -73,6 +75,7 @@ public List<Event> flatEvents() {
breathingSpaceMentalHealthLifted,
interlocutoryJudgment,
defaultJudgment,
setAsideJudgment,
statesPaid,
judgmentByAdmission,
generalFormOfApplication,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum EventType {
INTENTION_TO_PROCEED_STATES_PAID("67"),
INTERLOCUTORY_JUDGMENT_GRANTED("252"),
DEFAULT_JUDGMENT_GRANTED("230"),
SET_ASIDE_JUDGMENT("170"),
JUDGEMENT_BY_ADMISSION("240"),
GENERAL_FORM_OF_APPLICATION("136"),
DEFENCE_STRUCK_OUT("57"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
import uk.gov.hmcts.reform.civil.model.dq.Respondent2DQ;
import uk.gov.hmcts.reform.civil.model.genapplication.GeneralApplication;
import uk.gov.hmcts.reform.civil.model.genapplication.GeneralApplicationsDetails;
import uk.gov.hmcts.reform.civil.model.judgmentonline.JudgmentSetAsideOrderType;
import uk.gov.hmcts.reform.civil.model.judgmentonline.JudgmentSetAsideReason;
import uk.gov.hmcts.reform.civil.model.judgmentonline.SetAsideApplicantTypeForRPA;
import uk.gov.hmcts.reform.civil.model.judgmentonline.SetAsideResultTypeForRPA;
import uk.gov.hmcts.reform.civil.model.robotics.Event;
import uk.gov.hmcts.reform.civil.model.robotics.EventDetails;
import uk.gov.hmcts.reform.civil.model.robotics.EventHistory;
Expand Down Expand Up @@ -95,6 +99,7 @@
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.MISCELLANEOUS;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.RECEIPT_OF_ADMISSION;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.RECEIPT_OF_PART_ADMISSION;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.SET_ASIDE_JUDGMENT;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.STATES_PAID;
import static uk.gov.hmcts.reform.civil.service.robotics.utils.RoboticsDataUtil.APPLICANT2_ID;
import static uk.gov.hmcts.reform.civil.service.robotics.utils.RoboticsDataUtil.APPLICANT_ID;
Expand Down Expand Up @@ -286,6 +291,7 @@ public EventHistory buildEvents(CaseData caseData, String authToken) {
buildInformAgreedExtensionDateForSpec(builder, caseData);
buildClaimTakenOfflineAfterDJ(builder, caseData);
buildCcjEvent(builder, caseData);
buildSetAsideJudgment(builder, caseData);
buildCoscEvent(builder, caseData);
return eventHistorySequencer.sortEvents(builder.build());
}
Expand Down Expand Up @@ -547,6 +553,52 @@ private void buildCcjEvent(EventHistory.EventHistoryBuilder builder, CaseData ca
}
}

private void buildSetAsideJudgment(EventHistory.EventHistoryBuilder builder, CaseData caseData) {
if (featureToggleService.isJOLiveFeedActive() && caseData.getJoSetAsideReason() != null) {
List<Event> events = new ArrayList<>();
events.add(buildSetAsideJudgmentEvent(builder, caseData, RESPONDENT_ID));
if (null != caseData.getRespondent2()) {
events.add(buildSetAsideJudgmentEvent(builder, caseData, RESPONDENT2_ID));
}
builder.setAsideJudgment(events);
}
}

private Event buildSetAsideJudgmentEvent(EventHistory.EventHistoryBuilder builder, CaseData caseData, String litigiousPartyID) {
return Event.builder()
.eventSequence(prepareEventSequence(builder.build()))
.litigiousPartyID(litigiousPartyID)
.eventCode(SET_ASIDE_JUDGMENT.getCode())
.dateReceived(caseData.getJoSetAsideCreatedDate())
.eventDetails(getSetAsideEventDetails(caseData))
.eventDetailsText("")
.build();
}

private EventDetails getSetAsideEventDetails(CaseData caseData) {
String applicant = null;
LocalDate appDate = null;
LocalDate resultDate = null;
if (JudgmentSetAsideReason.JUDGE_ORDER.equals(caseData.getJoSetAsideReason())) {
if (JudgmentSetAsideOrderType.ORDER_AFTER_APPLICATION.equals(caseData.getJoSetAsideOrderType())) {
appDate = caseData.getJoSetAsideApplicationDate();
} else if (JudgmentSetAsideOrderType.ORDER_AFTER_DEFENCE.equals(caseData.getJoSetAsideOrderType())) {
appDate = caseData.getJoSetAsideDefenceReceivedDate();
}
applicant = SetAsideApplicantTypeForRPA.PARTY_AGAINST.getValue();
resultDate = caseData.getJoSetAsideOrderDate();

} else if (JudgmentSetAsideReason.JUDGMENT_ERROR.equals(caseData.getJoSetAsideReason())) {
applicant = SetAsideApplicantTypeForRPA.PROPER_OFFICER.getValue();
}
return EventDetails.builder()
.result(SetAsideResultTypeForRPA.GRANTED.name())
.applicant(applicant)
.applicationDate(appDate)
.resultDate(resultDate)
.build();
}

private void buildJudgmentByAdmissionEventDetails(EventHistory.EventHistoryBuilder builder, CaseData caseData) {
boolean isResponsePayByInstallment = caseData.isPayByInstallment();
Optional<RepaymentPlanLRspec> repaymentPlan = Optional.ofNullable(caseData.getRespondent1RepaymentPlan());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ private EventHistory prepareEventHistory(List<Event> events) {
case DEFENCE_STRUCK_OUT:
builder.defenceStruckOut(event);
break;
case SET_ASIDE_JUDGMENT:
builder.setAsideJudgment(event);
break;
case CERTIFICATE_OF_SATISFACTION_OR_CANCELLATION:
builder.certificateOfSatisfactionOrCancellation(event);
break;

default:
throw new IllegalStateException("Unexpected event type: " + eventType);
}
Expand Down Expand Up @@ -165,6 +167,9 @@ private EventHistory prepareEventHistory(List<Event> events) {
if (isEmpty(builder.build().getDefenceStruckOut())) {
builder.defenceStruckOut(List.of(Event.builder().build()));
}
if (isEmpty(builder.build().getSetAsideJudgment())) {
builder.setAsideJudgment(List.of(Event.builder().build()));
}
if (isEmpty(builder.build().getCertificateOfSatisfactionOrCancellation())) {
builder.certificateOfSatisfactionOrCancellation(List.of(Event.builder().build()));
}
Expand Down Expand Up @@ -201,6 +206,7 @@ private List<Event> flatEvents(EventHistory eventHistory) {
eventHistory.getBreathingSpaceMentalHealthLifted(),
eventHistory.getInterlocutoryJudgment(),
eventHistory.getDefaultJudgment(),
eventHistory.getSetAsideJudgment(),
eventHistory.getJudgmentByAdmission(),
eventHistory.getGeneralFormOfApplication(),
eventHistory.getDefenceStruckOut(),
Expand Down
106 changes: 106 additions & 0 deletions src/main/resources/schema/rpa-json-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
"breathingSpaceMentalHealthLifted",
"interlocutoryJudgment",
"defaultJudgment",
"setAsideJudgment",
"judgmentByAdmission",
"generalFormOfApplication",
"defenceStruckOut",
Expand Down Expand Up @@ -547,6 +548,18 @@
],
"description": ""
},
"setAsideJudgment": {
"$id": "#/properties/events/properties/setAsideJudgment",
"anyOf": [
{
"$ref": "#/definitions/setAsideJudgmentEventType"
},
{
"$ref": "#/definitions/nullEventType"
}
],
"description": ""
},
"judgmentByAdmission": {
"$id": "#/properties/events/properties/judgmentByAdmission",
"anyOf": [
Expand Down Expand Up @@ -2017,6 +2030,99 @@
"additionalProperties": false
}
},
"setAsideJudgmentEventType": {
"$id": "#/definitions/setAsideJudgmentEventType",
"type": "array",
"additionalItems": false,
"items": {
"$id": "#/definitions/setAsideJudgmentEventType/items",
"type": "object",
"required": [
"eventSequence",
"eventCode",
"litigiousPartyID",
"dateReceived",
"eventDetails",
"eventDetailsText"
],
"properties": {
"eventSequence": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventSequence",
"$ref": "#/definitions/eventSequenceType"
},
"eventCode": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventCode",
"type": "string",
"const": "170",
"description": "The CASEMAN code for the setAsideJudgmentEventType event."
},
"dateReceived": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/dateReceived",
"$ref": "#/definitions/formatDate",
"description": ""
},
"litigiousPartyID": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/litigiousPartyID",
"$ref": "#/definitions/litigiousPartyIDType",
"description": ""
},
"eventDetails": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventDetails",
"type": [
"object",
"null"
],
"properties": {
"applicant": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventDetails/properties/applicant",
"type": [
"string",
"null"
],
"maxLength": 250,
"description": ""
},
"result": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventDetails/properties/result",
"type": [
"string",
"null"
],
"maxLength": 250,
"description": ""
},
"resultDate": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventDetails/properties/resultDate",
"$ref": "#/definitions/formatDateOrNull",
"description": ""
},
"applicationDate": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventDetails/properties/applicationDate",
"$ref": "#/definitions/formatDateOrNull",
"description": ""
},
"miscText": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventDetails/properties/miscText",
"type": "string",
"maxLength": 250,
"description": "The text for the miscellaneous event can contain any supporting explanatory text."
}
},
"additionalProperties": false
},
"eventDetailsText": {
"$id": "#/definitions/setAsideJudgmentEventType/items/properties/eventDetailsText",
"type": [
"string",
"null"
],
"maxLength": 250,
"description": ""
}
},
"additionalProperties": false
}
},
"judgmentByAdmissionEventType": {
"$id": "#/definitions/judgmentByAdmissionEventType",
"type": "array",
Expand Down
Loading

0 comments on commit 29a3f2b

Please sign in to comment.