Skip to content

Commit

Permalink
CIV-11647 Claimant list matcher (#3617)
Browse files Browse the repository at this point in the history
* CIV-11647 Claimant list matcher

* CIV-11647 Claimant list matcher

* CIV-11647 Old matcher copied to new one

* CIV-11647 Old matcher copied to new one

* CIV-11647 Old matcher copied to new one

---------

Co-authored-by: jarekPierchala <[email protected]>
  • Loading branch information
ElifDenizEsea and jarekPierchala authored Nov 27, 2023
1 parent b479300 commit df5307f
Show file tree
Hide file tree
Showing 5 changed files with 353 additions and 38 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ sonarqube {
property "sonar.projectKey", "civil-service"
property "sonar.coverage.jacoco.xmlReportPaths", "${jacocoTestReport.reports.xml.destination.path}"
property "sonar.coverage.exclusions", "**/model/**, **/config/**/*Configuration.java, **/testingsupport/**, **/*ExternalTaskListener.java, **/*BaseExternalTaskHandler.java, **/stereotypes/**, **/*Exception.java, **/EventHistoryMapper*.java, **/model/hearingvalues/**, **/enums/hearing/**, **/fees/client/**, **/enums/sdo/**, **/service/PaymentsService.java, **/RetriggerCases*.java"
property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java"
property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java, **/*CcdDashboardClaimantClaimMatcher.java"
property "sonar.exclusions", "**/hmc/model/**, **/model/hearingvalues/**"
property "sonar.host.url", "https://sonar.reform.hmcts.net/"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@Slf4j
@AllArgsConstructor
public class CcdDashboardClaimMatcher implements Claim {
public class CcdDashboardClaimantClaimMatcher implements Claim {

private static final LocalTime FOUR_PM = LocalTime.of(16, 1, 0);
private CaseData caseData;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
package uk.gov.hmcts.reform.civil.model.citizenui;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import uk.gov.hmcts.reform.civil.enums.CaseState;
import uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec;
import uk.gov.hmcts.reform.civil.enums.RespondentResponseTypeSpec;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.sdo.FastTrackHearingTime;
import uk.gov.hmcts.reform.civil.model.sdo.SmallClaimsHearing;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;

import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Objects;
import java.util.Optional;

@Slf4j
@AllArgsConstructor
public class CcdDashboardDefendantClaimMatcher implements Claim {

private static final LocalTime FOUR_PM = LocalTime.of(16, 1, 0);
private CaseData caseData;
private FeatureToggleService featureToggleService;

@Override
public boolean hasResponsePending() {
return caseData.getRespondent1ResponseDate() == null && !isPaperResponse();
}

@Override
public boolean hasResponsePendingOverdue() {
return caseData.getRespondent1ResponseDeadline() != null
&& caseData.getRespondent1ResponseDeadline().isBefore(LocalDate.now().atTime(FOUR_PM))
&& caseData.hasBreathingSpace();
}

@Override
public boolean hasResponseDueToday() {
return caseData.getRespondent1ResponseDeadline() != null
&& caseData.getRespondent1ResponseDeadline().toLocalDate().isEqual(LocalDate.now())
&& caseData.getRespondent1ResponseDeadline().isBefore(LocalDate.now().atTime(FOUR_PM));
}

@Override
public boolean hasResponseFullAdmit() {
return caseData.getRespondent1ClaimResponseTypeForSpec() != null
&& caseData.getRespondent1ClaimResponseTypeForSpec() == RespondentResponseTypeSpec.FULL_ADMISSION;
}

@Override
public boolean defendantRespondedWithFullAdmitAndPayImmediately() {
return hasResponseFullAdmit()
&& isPayImmediately();
}

@Override
public boolean defendantRespondedWithFullAdmitAndPayBySetDate() {
return hasResponseFullAdmit()
&& caseData.isPayBySetDate()
&& (Objects.isNull(caseData.getApplicant1AcceptFullAdmitPaymentPlanSpec()));
}

@Override
public boolean defendantRespondedWithFullAdmitAndPayByInstallments() {
return hasResponseFullAdmit()
&& caseData.isPayByInstallment()
&& (Objects.isNull(caseData.getApplicant1AcceptFullAdmitPaymentPlanSpec()));
}

@Override
public boolean hasResponseDeadlineBeenExtended() {
return caseData.getRespondent1TimeExtensionDate() != null;
}

@Override
public boolean isEligibleForCCJ() {
return caseData.getRespondent1ResponseDeadline() != null
&& caseData.getRespondent1ResponseDeadline().isBefore(LocalDate.now().atTime(FOUR_PM))
&& caseData.getPaymentTypeSelection() == null;
}

@Override
public boolean claimantConfirmedDefendantPaid() {
return caseData.getRespondent1CourtOrderPayment() != null && caseData.respondent1PaidInFull();
}

@Override
public boolean isSettled() {
return !caseData.isRespondentResponseFullDefence()
&& (caseData.respondent1PaidInFull()
|| caseData.isResponseAcceptedByClaimant())
&& Objects.isNull(caseData.getCcjPaymentDetails())
&& !caseData.hasApplicantRejectedRepaymentPlan()
|| caseData.isPartAdmitClaimSettled();
}

@Override
public boolean isSentToCourt() {
return false;
}

@Override
public boolean claimantRequestedCountyCourtJudgement() {
return caseData.getApplicant1DQ() != null && caseData.getApplicant1DQ().getApplicant1DQRequestedCourt() != null
&& !hasSdoBeenDrawn();
}

@Override
public boolean isWaitingForClaimantToRespond() {
return RespondentResponseTypeSpec.FULL_DEFENCE == caseData.getRespondent1ClaimResponseTypeForSpec()
&& caseData.getApplicant1ResponseDate() == null;
}

@Override
public boolean isProceedOffline() {
return false;
}

@Override
public boolean isPaperResponse() {
if (!featureToggleService.isLipVLipEnabled()) {
return false;
}

return Objects.nonNull(caseData.getTakenOfflineDate()) && Objects.nonNull(caseData.getCcdState())
&& caseData.getCcdState().equals(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM);
}

@Override
public boolean hasChangeRequestFromDefendant() {
return false;
}

@Override
public boolean hasChangeRequestedFromClaimant() {
return false;
}

@Override
public boolean isPassedToCountyCourtBusinessCentre() {
return false;
}

@Override
public boolean hasClaimantAskedToSignSettlementAgreement() {
return false;
}

@Override
public boolean hasClaimantAcceptedPartialAdmissionAmount() {
return hasDefendantStatedTheyPaid() && caseData.isResponseAcceptedByClaimant();
}

@Override
public boolean haveBothPartiesSignedSettlementAgreement() {
return false;
}

@Override
public boolean hasCCJByRedetermination() {
return caseData.hasApplicantAcceptedRepaymentPlan();
}

@Override
public boolean hasDefendantStatedTheyPaid() {
return defendantRespondedWithPartAdmit()
&& isPayImmediately() && !caseData.getApplicant1ResponseDeadlinePassed()
&& !(caseData.hasApplicantRejectedRepaymentPlan() || caseData.isPartAdmitClaimNotSettled());
}

private boolean isPayImmediately() {
return RespondentResponsePartAdmissionPaymentTimeLRspec.IMMEDIATELY == caseData.getDefenceAdmitPartPaymentTimeRouteRequired();
}

@Override
public boolean defendantRespondedWithPartAdmit() {
return RespondentResponseTypeSpec.PART_ADMISSION == caseData.getRespondent1ClaimResponseTypeForSpec()
&& !caseData.getApplicant1ResponseDeadlinePassed()
&& !(caseData.hasApplicantRejectedRepaymentPlan() || caseData.isPartAdmitClaimNotSettled());
}

@Override
public boolean isHearingFormGenerated() {
return !caseData.getHearingDocuments().isEmpty();
}

@Override
public boolean hasSdoBeenDrawn() {
return caseData.getSDODocument().isPresent();
}

@Override
public boolean isBeforeHearing() {
return isBeforeSmallClaimHearing() || (isBeforeFastTrackHearing() || noHearingScheduled());
}

private boolean noHearingScheduled() {
return caseData.getSmallClaimsHearing() == null && caseData.getFastTrackHearingTime() == null;
}

private boolean isBeforeSmallClaimHearing() {
return Optional.ofNullable(caseData.getSmallClaimsHearing())
.map(SmallClaimsHearing::getDateFrom)
.map(hearingFromDate -> hearingFromDate.isAfter(LocalDate.now()))
.orElse(false);
}

private boolean isBeforeFastTrackHearing() {
return Optional.ofNullable(caseData.getFastTrackHearingTime())
.map(FastTrackHearingTime::getDateFrom)
.map(hearingFromDate -> hearingFromDate.isAfter(LocalDate.now()))
.orElse(false);
}

@Override
public boolean isMoreDetailsRequired() {
return hasSdoBeenDrawn() && isBeforeHearing() && featureToggleService.isCaseProgressionEnabled();
}

@Override
public boolean isMediationSuccessful() {
return !hasSdoBeenDrawn()
&& Objects.nonNull(caseData.getMediation())
&& Objects.nonNull(caseData.getMediation().getMediationSuccessful())
&& Objects.nonNull(caseData.getMediation().getMediationSuccessful().getMediationAgreement());
}

@Override
public boolean isMediationUnsuccessful() {
return !hasSdoBeenDrawn()
&& Objects.nonNull(caseData.getMediation())
&& Objects.nonNull(caseData.getMediation().getUnsuccessfulMediationReason())
&& !caseData.getMediation().getUnsuccessfulMediationReason().isEmpty();
}

@Override
public boolean isMediationPending() {
return Objects.nonNull(caseData.getCcdState())
&& caseData.getCcdState().equals(CaseState.IN_MEDIATION)
&& Objects.nonNull(caseData.getMediation())
&& Objects.nonNull(caseData.getMediation().getMediationSuccessful())
&& Objects.isNull(caseData.getMediation().getMediationSuccessful().getMediationAgreement());
}

@Override
public boolean isCourtReviewing() {
return (!hasSdoBeenDrawn()
&& caseData.isRespondentResponseFullDefence()
&& caseData.getCcdState().equals(CaseState.JUDICIAL_REFERRAL))
|| (caseData.hasApplicantRejectedRepaymentPlan());
}

@Override
public boolean hasClaimEnded() {
return (Objects.nonNull(caseData.getApplicant1ProceedsWithClaimSpec())
&& caseData.getApplicant1ProceedsWithClaimSpec().equals(YesOrNo.NO)
&& caseData.isRespondentResponseFullDefence())
|| caseData.getApplicant1ResponseDeadlinePassed();
}

@Override
public boolean isClaimRejectedAndOfferSettleOutOfCourt() {
return false;
}

@Override
public boolean claimantAcceptedOfferOutOfCourt() {
return false;
}

@Override
public boolean hasClaimantRejectOffer() {
return false;
}

@Override
public boolean isPartialAdmissionRejected() {
return CaseState.JUDICIAL_REFERRAL.equals(caseData.getCcdState())
&& caseData.isPartAdmitClaimSpec();
}

@Override
public boolean isSDOOrderCreated() {
return caseData.getHearingDate() == null
&& CaseState.CASE_PROGRESSION.equals(caseData.getCcdState());
}

@Override
public boolean isClaimantDefaultJudgement() {
return caseData.getRespondent1ResponseDeadline() != null
&& caseData.getRespondent1ResponseDeadline().isBefore(LocalDate.now().atTime(FOUR_PM))
&& caseData.getPaymentTypeSelection() != null;
}

}
Loading

0 comments on commit df5307f

Please sign in to comment.