-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIV-11647 Claimant list matcher (#3617)
* 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
1 parent
b479300
commit df5307f
Showing
5 changed files
with
353 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
297 changes: 297 additions & 0 deletions
297
...ain/java/uk/gov/hmcts/reform/civil/model/citizenui/CcdDashboardDefendantClaimMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
Oops, something went wrong.