Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIV-10820 cos notify claim details screen add date deemed served #3433

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6a41366
CIV-10820 update Cos Notify Claim Details screen with deemed served date
MMNycz Oct 18, 2023
a84e01d
Update Jenkinsfile_CNP
MMNycz Oct 18, 2023
7e1f15e
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
MMNycz Oct 18, 2023
8738526
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Oct 19, 2023
f55d3a9
Update Jenkinsfile_CNP
MMNycz Oct 19, 2023
4f77efd
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Oct 31, 2023
f53f587
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Nov 3, 2023
64b889d
CIV-10820 fix errorMessage and respondentDedline
MMNycz Nov 3, 2023
b47b567
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
MMNycz Nov 6, 2023
18858a2
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Nov 6, 2023
ac3c0d8
CIV-18020 - update error message according to change in AC
MMNycz Nov 15, 2023
16d567b
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
MMNycz Nov 15, 2023
20821de
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
kdaHMCTS Nov 21, 2023
a449777
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
MMNycz Nov 21, 2023
47b00c8
Update suppressions.xml
MMNycz Nov 21, 2023
417834f
Merge branch 'CIV-10820-CoS-Notify-Claim-Details-Screen-add-date-deem…
MMNycz Nov 21, 2023
9eae4ad
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
MMNycz Nov 21, 2023
6279795
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
kdaHMCTS Nov 22, 2023
a7efad9
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 6, 2023
3f2944d
Update suppressions.xml
MMNycz Dec 6, 2023
6303324
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
MMNycz Dec 7, 2023
02a45f9
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
kdaHMCTS Dec 8, 2023
b5dd0ff
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
kdaHMCTS Dec 11, 2023
4434e43
Update NotifyClaimDetailsCallbackHandler.java
MMNycz Dec 13, 2023
ff7feb3
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 13, 2023
35dfb98
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
MMNycz Dec 13, 2023
a4ef21b
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
kdaHMCTS Dec 14, 2023
4cc6f94
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 14, 2023
5db3a10
CIV-10820 add log info to check multipartyScenario
MMNycz Dec 14, 2023
b029094
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 14, 2023
e654c76
CIV-10820
MMNycz Dec 15, 2023
3c7cb21
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 15, 2023
888369a
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 15, 2023
701d3fc
Update NotifyClaimDetailsCallbackHandlerTest.java
MMNycz Dec 18, 2023
37ba615
CIV-10820 fix unit test
MMNycz Dec 18, 2023
aab5844
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 18, 2023
fc39536
CIV-10820 fix single error message
MMNycz Dec 19, 2023
b32d133
Merge branch 'master' into CIV-10820-CoS-Notify-Claim-Details-Screen-…
MMNycz Dec 19, 2023
eeac415
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 20, 2023
7a390e5
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 20, 2023
4d1b23f
uodate branch with master
kdaHMCTS Dec 20, 2023
0395c50
uodate branch with master
kdaHMCTS Dec 20, 2023
ec0b273
CIC-10820 update validate date to plus14Days
MMNycz Dec 20, 2023
5754e19
Merge branch 'CIV-10820-CoS-Notify-Claim-Details-Screen-add-date-deem…
MMNycz Dec 20, 2023
44440f9
Update NotifyClaimDetailsCallbackHandlerTest.java
MMNycz Dec 20, 2023
023c26c
CIV-10820 fix issue with incorrect deadline display on confimration s…
MMNycz Dec 21, 2023
b45a0e8
Merge branch 'master' of https://github.com/hmcts/civil-service into …
MMNycz Dec 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse;
import uk.gov.hmcts.reform.ccd.client.model.SubmittedCallbackResponse;
import uk.gov.hmcts.reform.civil.bankholidays.WorkingDayIndicator;
import uk.gov.hmcts.reform.civil.callback.Callback;
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.documentmanagement.model.Document;
import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario;
import uk.gov.hmcts.reform.civil.model.common.Element;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.CertificateOfService;
import uk.gov.hmcts.reform.civil.model.DocumentWithRegex;
import uk.gov.hmcts.reform.civil.model.ServedDocumentFiles;
import uk.gov.hmcts.reform.civil.model.common.DynamicList;
import uk.gov.hmcts.reform.civil.model.common.DynamicListElement;
import uk.gov.hmcts.reform.civil.documentmanagement.model.Document;
import uk.gov.hmcts.reform.civil.model.common.Element;
import uk.gov.hmcts.reform.civil.service.DeadlinesCalculator;
import uk.gov.hmcts.reform.civil.service.ExitSurveyContentService;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;
import uk.gov.hmcts.reform.civil.service.Time;
import uk.gov.hmcts.reform.civil.utils.AssignCategoryId;
import uk.gov.hmcts.reform.civil.utils.ElementUtils;
Expand Down Expand Up @@ -52,6 +54,7 @@
import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.DATE_TIME_AT;
import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.formatLocalDateTime;

@Slf4j
@Service
@RequiredArgsConstructor
public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implements ParticularsOfClaimValidator {
Expand Down Expand Up @@ -81,21 +84,31 @@ public class NotifyClaimDetailsCallbackHandler extends CallbackHandler implement
"Your claim will progress offline if you only notify one Defendant of the claim details.";

public static final String DOC_SERVED_DATE_IN_FUTURE =
"Date you served the documents must be today or in the past";
"On what day did you serve must be today or in the past";

public static final String DOC_SERVED_DATE_OLDER_THAN_14DAYS =
"Date of Service should not be more than 14 days old";
"On what day did you serve should not be more than 14 days old";

public static final String DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS =
"The date of service must be no greater than 2 working days in the future";

public static final String DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS =
"The date of service should not be more than 14 days old";

public static final String DATE_OF_SERVICE_DATE_IS_WORKING_DAY =
"For the date of service please enter a working day";

public static final String DOC_SERVED_MANDATORY =
"Supporting evidence is required";

public static final String BOTH_CERTIFICATE_SERVED_SAME_DATE =
"Date of Service for both certificate must be the same";
"The date of Service for defendant 1 and defendant 2 must be the same";

private final ExitSurveyContentService exitSurveyContentService;
private final ObjectMapper objectMapper;
private final Time time;
private final DeadlinesCalculator deadlinesCalculator;
private final WorkingDayIndicator workingDayIndicator;
private final FeatureToggleService featureToggleService;
private final AssignCategoryId assignCategoryId;

Expand Down Expand Up @@ -208,24 +221,31 @@ private CallbackResponse submitClaim(CallbackParams callbackParams) {

private LocalDateTime getEarliestDateOfService(CaseData caseData) {
LocalDateTime date = time.now();
LocalDateTime deemedDate1 = null;
LocalDateTime deemedDate2 = null;

if (Objects.nonNull(caseData.getCosNotifyClaimDetails1())
&& Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateOfServiceForDefendant())) {
LocalDateTime cosDate1 = caseData.getCosNotifyClaimDetails1()
.getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime());
if (cosDate1.isBefore(date)) {
date = cosDate1;
}
&& Objects.nonNull(caseData.getCosNotifyClaimDetails1().getCosDateDeemedServedForDefendant())) {
deemedDate1 = caseData.getCosNotifyClaimDetails1()
.getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime());
}

if (Objects.nonNull(caseData.getCosNotifyClaimDetails2())
&& Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateOfServiceForDefendant())) {
LocalDateTime cosDate2 = caseData.getCosNotifyClaimDetails2()
.getCosDateOfServiceForDefendant().atTime(time.now().toLocalTime());
if (cosDate2.isBefore(date)) {
date = cosDate2;
}
&& Objects.nonNull(caseData.getCosNotifyClaimDetails2().getCosDateDeemedServedForDefendant())) {
deemedDate2 = caseData.getCosNotifyClaimDetails2()
.getCosDateDeemedServedForDefendant().atTime(time.now().toLocalTime());
}

if (deemedDate1 != null && deemedDate2 != null) {
return deemedDate1.isBefore(deemedDate2) ? deemedDate1 : deemedDate2;
} else if (deemedDate1 != null) {
return deemedDate1;
} else if (deemedDate2 != null) {
return deemedDate2;
} else {
// If both deemedDate1 and deemedDate2 are null, use the current date and time
return date;
}
return date;
}

private CaseData saveCoSDetailsDoc(CaseData caseData, int lipNumber) {
Expand Down Expand Up @@ -369,12 +389,9 @@ private CallbackResponse validateCoSDetailsDefendant1(final CallbackParams callb
caseData.getCosNotifyClaimDetails1().setCosDocSaved(NO);
}

final String dateValidationErrorMessage = getServiceOfDateValidationMessage(
caseData.getCosNotifyClaimDetails1());
List<String> dateValidationErrorMessages = getServiceOfDateValidationMessages(caseData.getCosNotifyClaimDetails1());
errors.addAll(dateValidationErrorMessages);

if (!dateValidationErrorMessage.isEmpty()) {
errors.add(dateValidationErrorMessage);
}
if (Objects.nonNull(caseData.getCosNotifyClaimDetails1())
&& isMandatoryDocMissing(caseData.getCosNotifyClaimDetails1())) {
errors.add(DOC_SERVED_MANDATORY);
Expand All @@ -396,12 +413,8 @@ private CallbackResponse validateCoSDetailsDefendant2(final CallbackParams callb
if (Objects.nonNull(caseData.getCosNotifyClaimDetails2())) {
caseData.getCosNotifyClaimDetails2().setCosDocSaved(NO);
}
final String dateValidationErrorMessage = getServiceOfDateValidationMessage(
caseData.getCosNotifyClaimDetails2());

if (!dateValidationErrorMessage.isEmpty()) {
errors.add(dateValidationErrorMessage);
}
List<String> dateValidationErrorMessages = getServiceOfDateValidationMessages(caseData.getCosNotifyClaimDetails2());
errors.addAll(dateValidationErrorMessages);

if (isBothDefendantLip(caseData) && !isBothDefendantWithSameDateOfService(caseData)) {
errors.add(BOTH_CERTIFICATE_SERVED_SAME_DATE);
Expand All @@ -426,26 +439,75 @@ private boolean isMandatoryDocMissing(CertificateOfService certificateOfService)
return Objects.isNull(certificateOfService.getCosEvidenceDocument());
}

private String getServiceOfDateValidationMessage(CertificateOfService certificateOfService) {
final String errorMessage = "";
private List<String> getServiceOfDateValidationMessages(CertificateOfService certificateOfService) {
List<String> errorMessages = new ArrayList<>();

if (Objects.nonNull(certificateOfService)) {
if (isCosDefendantNotifyDateFutureDate(certificateOfService.getCosDateOfServiceForDefendant())) {
return DOC_SERVED_DATE_IN_FUTURE;
} else if (isCosDefendantNotifyDateOlderThan14Days(certificateOfService.getCosDateOfServiceForDefendant())) {
return DOC_SERVED_DATE_OLDER_THAN_14DAYS;
errorMessages.add(DOC_SERVED_DATE_IN_FUTURE);
}

if (isCosDefendantNotifyDateOlderThan14Days(certificateOfService.getCosDateOfServiceForDefendant())) {
errorMessages.add(DOC_SERVED_DATE_OLDER_THAN_14DAYS);
}

if (isDeemedServedWithinMaxWorkingDays(certificateOfService.getCosDateDeemedServedForDefendant())) {
errorMessages.add(DATE_OF_SERVICE_NOT_GREATER_THAN_2_WORKING_DAYS);
}

if (isDeemedServedDateIsNotWorkingDay(certificateOfService.getCosDateDeemedServedForDefendant())) {
errorMessages.add(DATE_OF_SERVICE_DATE_IS_WORKING_DAY);
}

if (isDeemedServedDateOlderThan14Days(certificateOfService.getCosDateDeemedServedForDefendant())) {
errorMessages.add(DATE_OF_SERVICE_DATE_OLDER_THAN_14DAYS);
}
}
return errorMessage;

return errorMessages;
}

private boolean isCosDefendantNotifyDateFutureDate(LocalDate cosDateOfServiceForDefendant) {
return time.now().toLocalDate().isBefore(cosDateOfServiceForDefendant);
}

private boolean isCosDefendantNotifyDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) {
return time.now().isAfter(deadlinesCalculator.plus14DaysAt4pmDeadline(cosDateOfServiceForDefendant
.atTime(time.now().toLocalTime())));
LocalDateTime notificationDeadline = deadlinesCalculator.plus14DaysDeadline(cosDateOfServiceForDefendant
.atTime(time.now().toLocalTime()));
LocalDateTime currentDateTime = time.now();
LocalDateTime today4pm = currentDateTime.toLocalDate().atTime(16, 0);

boolean isAfter4pmToday = currentDateTime.isAfter(today4pm)
&& currentDateTime.toLocalDate().equals(notificationDeadline.toLocalDate());

boolean isAfter14DaysAt4pmDeadline = currentDateTime.isAfter(notificationDeadline);

return isAfter14DaysAt4pmDeadline || isAfter4pmToday;
}

private boolean isDeemedServedDateOlderThan14Days(LocalDate cosDateOfServiceForDefendant) {
LocalDateTime deemedServedDeadline = deadlinesCalculator.plus14DaysDeadline(cosDateOfServiceForDefendant
.atTime(time.now().toLocalTime()));
LocalDateTime currentDateTime = time.now();
LocalDateTime today4pm = currentDateTime.toLocalDate().atTime(16, 0);

boolean isAfter4pmToday = currentDateTime.isAfter(today4pm)
&& currentDateTime.toLocalDate().equals(deemedServedDeadline.toLocalDate());

boolean isAfter14DaysAt4pmDeadline = currentDateTime.isAfter(deemedServedDeadline);

return isAfter14DaysAt4pmDeadline || isAfter4pmToday;
}

public boolean isDeemedServedWithinMaxWorkingDays(LocalDate cosDateOfServiceForDefendant) {
LocalDate currentDate = LocalDate.now();
LocalDate maxWorkingDaysDate = deadlinesCalculator.plusWorkingDays(currentDate, 2);

return cosDateOfServiceForDefendant.isAfter(maxWorkingDaysDate);
}

private boolean isDeemedServedDateIsNotWorkingDay(LocalDate cosDateOfServiceForDefendant) {
return !workingDayIndicator.isWorkingDay(cosDateOfServiceForDefendant);
}

private boolean isBothDefendantLip(CaseData caseData) {
Expand All @@ -458,8 +520,8 @@ private boolean isBothDefendantLip(CaseData caseData) {
private boolean isBothDefendantWithSameDateOfService(CaseData caseData) {
if (Objects.nonNull(caseData.getCosNotifyClaimDetails1())
&& Objects.nonNull(caseData.getCosNotifyClaimDetails2())) {
if (caseData.getCosNotifyClaimDetails1().getCosDateOfServiceForDefendant()
.equals(caseData.getCosNotifyClaimDetails2().getCosDateOfServiceForDefendant())) {
if (caseData.getCosNotifyClaimDetails1().getCosDateDeemedServedForDefendant()
.equals(caseData.getCosNotifyClaimDetails2().getCosDateDeemedServedForDefendant())) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class CertificateOfService {

@JsonProperty("cosDateOfServiceForDefendant")
private LocalDate cosDateOfServiceForDefendant;
@JsonProperty("cosDateDeemedServedForDefendant")
private LocalDate cosDateDeemedServedForDefendant;
@JsonProperty("cosServedDocumentFiles")
private String cosServedDocumentFiles;
@JsonProperty("cosEvidenceDocument")
Expand Down
Loading
Loading