Skip to content

Commit

Permalink
CIV-15759 CIV-16208 Add new rpa event: 600 COSC (#5836)
Browse files Browse the repository at this point in the history
* Add new rpa event: 600 COSC

* fix linting

* test

* update rpa

* update field names to match rpa

* fix rpa json

* add jo live feed active flag

* fix cr comments

* fix cr comments

* updated code to fit new acs

* fix

* fixed litigious party

* fix cr comments

* fix cr comments

* added cr changed

* added cr changes

---------

Co-authored-by: krishnanuthalapati <[email protected]>
Co-authored-by: Azam <[email protected]>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent 17dcd53 commit 51592ad
Show file tree
Hide file tree
Showing 22 changed files with 453 additions and 21 deletions.
Binary file added file.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.hmcts.reform.civil.enums;
package uk.gov.hmcts.reform.civil.enums.cosc;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package uk.gov.hmcts.reform.civil.enums.cosc;

import lombok.Getter;

@Getter
public enum CoscRPAStatus {
CANCELLED,
SATISFIED
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
import uk.gov.hmcts.reform.civil.helpers.judgmentsonline.JudgmentsOnlineHelper;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.judgmentonline.JudgmentDetails;

import uk.gov.hmcts.reform.civil.model.judgmentonline.JudgmentState;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

import static java.util.Objects.nonNull;
import static java.util.Optional.ofNullable;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CHECK_AND_MARK_PAID_IN_FULL;
import static uk.gov.hmcts.reform.civil.enums.cosc.CoscRPAStatus.CANCELLED;
import static uk.gov.hmcts.reform.civil.enums.cosc.CoscRPAStatus.SATISFIED;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -72,7 +75,9 @@ private CallbackResponse checkAndMarkDefendantPaidInFull(CallbackParams callback
caseData.getCertOfSC().getDefendantFinalPaymentDate()
));
caseData.setJoRepaymentSummaryObject(JudgmentsOnlineHelper.calculateRepaymentBreakdownSummary(caseData.getActiveJudgment()));
caseData.setJoDefendantMarkedPaidInFullIssueDate(LocalDateTime.now());
}
caseData.setJoCoscRpaStatus(JudgmentState.CANCELLED.equals(caseData.getActiveJudgment().getState()) ? CANCELLED : SATISFIED);

return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseData.toMap(objectMapper))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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.enums.CoscApplicationStatus.PROCESSED;
import static uk.gov.hmcts.reform.civil.enums.cosc.CoscApplicationStatus.PROCESSED;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements;

@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CHECK_PAID_IN_FULL_SCHED_DEADLINE;
import static uk.gov.hmcts.reform.civil.enums.CoscApplicationStatus.ACTIVE;
import static uk.gov.hmcts.reform.civil.enums.cosc.CoscApplicationStatus.ACTIVE;

@Slf4j
@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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.CoscApplicationStatus;
import uk.gov.hmcts.reform.civil.enums.cosc.CoscApplicationStatus;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.Time;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import uk.gov.hmcts.reform.civil.helpers.judgmentsonline.JudgmentsOnlineHelper;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;

import uk.gov.hmcts.reform.civil.model.judgmentonline.JudgmentState;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -28,6 +29,8 @@
import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.JUDGMENT_PAID_IN_FULL;
import static uk.gov.hmcts.reform.civil.enums.cosc.CoscRPAStatus.SATISFIED;
import static uk.gov.hmcts.reform.civil.enums.cosc.CoscRPAStatus.CANCELLED;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -73,7 +76,10 @@ private CallbackResponse saveJudgmentPaidInFullDetails(CallbackParams callbackPa
caseData.setActiveJudgment(paidInFullJudgmentOnlineMapper.addUpdateActiveJudgment(caseData));
caseData.setJoRepaymentSummaryObject(JudgmentsOnlineHelper.calculateRepaymentBreakdownSummary(caseData.getActiveJudgment()));
CaseData.CaseDataBuilder<?, ?> caseDataBuilder = caseData.toBuilder();
caseDataBuilder.businessProcess(BusinessProcess.ready(JUDGMENT_PAID_IN_FULL));
caseDataBuilder
.businessProcess(BusinessProcess.ready(JUDGMENT_PAID_IN_FULL))
.joCoscRpaStatus(JudgmentState.CANCELLED.equals(caseData.getActiveJudgment().getState()) ? CANCELLED : SATISFIED)
.joMarkedPaidInFullIssueDate(LocalDateTime.now());
return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseDataBuilder.build().toMap(objectMapper))
.build();
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import uk.gov.hmcts.reform.civil.enums.ClaimType;
import uk.gov.hmcts.reform.civil.enums.ClaimTypeUnspec;
import uk.gov.hmcts.reform.civil.enums.ConfirmationToggle;
import uk.gov.hmcts.reform.civil.enums.CoscApplicationStatus;
import uk.gov.hmcts.reform.civil.enums.cosc.CoscApplicationStatus;
import uk.gov.hmcts.reform.civil.enums.CourtStaffNextSteps;
import uk.gov.hmcts.reform.civil.enums.DecisionOnRequestReconsiderationOptions;
import uk.gov.hmcts.reform.civil.enums.EmploymentTypeCheckboxFixedListLRspec;
Expand All @@ -41,6 +41,7 @@
import uk.gov.hmcts.reform.civil.enums.TimelineUploadTypeSpec;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.enums.sendandreply.SendAndReplyOption;
import uk.gov.hmcts.reform.civil.enums.cosc.CoscRPAStatus;
import uk.gov.hmcts.reform.civil.enums.settlediscontinue.ConfirmOrderGivesPermission;
import uk.gov.hmcts.reform.civil.enums.settlediscontinue.DiscontinuanceTypeList;
import uk.gov.hmcts.reform.civil.enums.settlediscontinue.MarkPaidConsentList;
Expand Down Expand Up @@ -691,6 +692,9 @@ public boolean hasNoOngoingBusinessProcess() {
private LocalDate joIssueDate;
private JudgmentState joState;
private LocalDate joFullyPaymentMadeDate;
private LocalDateTime joMarkedPaidInFullIssueDate;
private LocalDateTime joDefendantMarkedPaidInFullIssueDate;
private CoscRPAStatus joCoscRpaStatus;
private String joOrderedAmount;
private String joCosts;
private String joTotalAmount;
Expand Down Expand Up @@ -744,7 +748,7 @@ public boolean hasNoOngoingBusinessProcess() {
private FeePaymentOutcomeDetails feePaymentOutcomeDetails;
private LocalDate coscSchedulerDeadline;
private CoscApplicationStatus coSCApplicationStatus;

//Caseworker events
private YesOrNo obligationDatePresent;
private CourtStaffNextSteps courtStaffNextSteps;
Expand Down Expand Up @@ -1251,6 +1255,16 @@ public boolean isCcjRequestJudgmentByAdmission() {
&& getCcjPaymentDetails().getCcjPaymentPaidSomeOption() != null;
}

@JsonIgnore
public boolean hasCoscCert() {
if (getSystemGeneratedCaseDocuments() != null) {
return getSystemGeneratedCaseDocuments().stream()
.filter(systemGeneratedCaseDocument -> systemGeneratedCaseDocument.getValue()
.getDocumentType().equals(DocumentType.CERTIFICATE_OF_DEBT_PAYMENT)).findAny().isPresent();
}
return false;
}

@JsonIgnore
public Address getRespondent1CorrespondanceAddress() {
return Optional.ofNullable(getCaseDataLiP())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,10 @@ public class EventDetails {
private LocalDateTime dateOfJudgment;
private Boolean jointJudgment;
private Boolean judgmentToBeRegistered;
@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 @@ -52,6 +52,8 @@ public class EventHistory {
private List<Event> generalFormOfApplication;
@Singular("defenceStruckOut")
private List<Event> defenceStruckOut;
@Singular("certificateOfSatisfactionOrCancellation")
private List<Event> certificateOfSatisfactionOrCancellation;

@JsonIgnore
public List<Event> flatEvents() {
Expand All @@ -74,7 +76,8 @@ public List<Event> flatEvents() {
statesPaid,
judgmentByAdmission,
generalFormOfApplication,
defenceStruckOut
defenceStruckOut,
certificateOfSatisfactionOrCancellation
);
return eventsList.stream()
.filter(Objects::nonNull)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public enum EventType {
DEFAULT_JUDGMENT_GRANTED("230"),
JUDGEMENT_BY_ADMISSION("240"),
GENERAL_FORM_OF_APPLICATION("136"),
DEFENCE_STRUCK_OUT("57");
DEFENCE_STRUCK_OUT("57"),
CERTIFICATE_OF_SATISFACTION_OR_CANCELLATION("600");

private String code;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.ACKNOWLEDGEMENT_OF_SERVICE_RECEIVED;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.BREATHING_SPACE_ENTERED;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.BREATHING_SPACE_LIFTED;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.CERTIFICATE_OF_SATISFACTION_OR_CANCELLATION;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.CONSENT_EXTENSION_FILING_DEFENCE;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.DEFAULT_JUDGMENT_GRANTED;
import static uk.gov.hmcts.reform.civil.model.robotics.EventType.DEFENCE_FILED;
Expand Down Expand Up @@ -285,6 +286,7 @@ public EventHistory buildEvents(CaseData caseData, String authToken) {
buildInformAgreedExtensionDateForSpec(builder, caseData);
buildClaimTakenOfflineAfterDJ(builder, caseData);
buildCcjEvent(builder, caseData);
buildCoscEvent(builder, caseData);
return eventHistorySequencer.sortEvents(builder.build());
}

Expand Down Expand Up @@ -496,6 +498,34 @@ private void buildBreathingSpaceEvent(EventHistory.EventHistoryBuilder builder,
}
}

private void buildCoscEvent(EventHistory.EventHistoryBuilder builder, CaseData caseData) {
boolean joMarkedPaidInFullDateExists = caseData.getJoMarkedPaidInFullIssueDate() != null;

if (featureToggleService.isJOLiveFeedActive()
&& ((joMarkedPaidInFullDateExists && caseData.getJoDefendantMarkedPaidInFullIssueDate() == null)
|| caseData.hasCoscCert())
) {
// date received when mark paid in full by claimant is issued or when the scheduler runs at the cosc deadline at 4pm
LocalDateTime dateReceived = joMarkedPaidInFullDateExists
? caseData.getJoMarkedPaidInFullIssueDate() : caseData.getJoDefendantMarkedPaidInFullIssueDate();

builder.certificateOfSatisfactionOrCancellation((Event.builder()
.eventSequence(prepareEventSequence(builder.build()))
.litigiousPartyID(joMarkedPaidInFullDateExists ? APPLICANT_ID : RESPONDENT_ID)
.eventCode(CERTIFICATE_OF_SATISFACTION_OR_CANCELLATION.getCode())
.dateReceived(dateReceived)
.eventDetails(EventDetails.builder()
.status(caseData.getJoCoscRpaStatus().toString())
.datePaidInFull(getCoscDate(caseData))
.notificationReceiptDate(joMarkedPaidInFullDateExists
? caseData.getJoMarkedPaidInFullIssueDate().toLocalDate()
: caseData.getJoDefendantMarkedPaidInFullIssueDate().toLocalDate())
.build())
.eventDetailsText("")
.build()));
}
}

private void buildCcjEvent(EventHistory.EventHistoryBuilder builder, CaseData caseData) {
if (caseData.isCcjRequestJudgmentByAdmission()) {
buildJudgmentByAdmissionEventDetails(builder, caseData);
Expand Down Expand Up @@ -2423,4 +2453,13 @@ private LocalDateTime setApplicant1ResponseDate(CaseData caseData) {
}
return applicant1ResponseDate;
}

private LocalDate getCoscDate(CaseData caseData) {
if (caseData.getJoFullyPaymentMadeDate() != null) {
return caseData.getJoFullyPaymentMadeDate();
} else if (caseData.getCertOfSC() != null && caseData.getCertOfSC().getDefendantFinalPaymentDate() != null) {
return caseData.getCertOfSC().getDefendantFinalPaymentDate();
}
throw new IllegalArgumentException("Payment date cannot be null");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ private EventHistory prepareEventHistory(List<Event> events) {
case DEFENCE_STRUCK_OUT:
builder.defenceStruckOut(event);
break;
case CERTIFICATE_OF_SATISFACTION_OR_CANCELLATION:
builder.certificateOfSatisfactionOrCancellation(event);
break;

default:
throw new IllegalStateException("Unexpected event type: " + eventType);
}
Expand Down Expand Up @@ -161,6 +165,9 @@ private EventHistory prepareEventHistory(List<Event> events) {
if (isEmpty(builder.build().getDefenceStruckOut())) {
builder.defenceStruckOut(List.of(Event.builder().build()));
}
if (isEmpty(builder.build().getCertificateOfSatisfactionOrCancellation())) {
builder.certificateOfSatisfactionOrCancellation(List.of(Event.builder().build()));
}
return builder
.build();
}
Expand Down Expand Up @@ -196,7 +203,8 @@ private List<Event> flatEvents(EventHistory eventHistory) {
eventHistory.getDefaultJudgment(),
eventHistory.getJudgmentByAdmission(),
eventHistory.getGeneralFormOfApplication(),
eventHistory.getDefenceStruckOut()
eventHistory.getDefenceStruckOut(),
eventHistory.getCertificateOfSatisfactionOrCancellation()
);
return eventsList.stream()
.filter(Objects::nonNull)
Expand Down
Loading

0 comments on commit 51592ad

Please sign in to comment.