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-15613 Order Review Obligation Changes #5919

Open
wants to merge 10 commits into
base: feat/CIV-15265
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
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.ObligationReason;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.ObligationData;
import uk.gov.hmcts.reform.civil.model.ObligationWAFlag;
import uk.gov.hmcts.reform.civil.model.common.Element;
import uk.gov.hmcts.reform.civil.service.FeatureToggleService;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

Expand All @@ -41,28 +44,39 @@ protected Map<String, Callback> callbacks() {
}

private CallbackResponse orderReviewObligationCheck(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData().toBuilder()
.build();

CaseData caseData = callbackParams.getCaseData();
LocalDate currentDate = LocalDate.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d MMMM yyyy");

caseData.setObligationWAFlag(null);

caseData.getStoredObligationData().stream()
.map(Element::getValue)
.filter(data -> !data.getObligationDate().isAfter(currentDate) && YesOrNo.NO.equals(data.getObligationWATaskRaised()))
.forEach(data -> {
data.setObligationWATaskRaised(YesOrNo.YES);
// TODO: add logic here to trigger WA tasks for obligations that are due
});

CaseData.CaseDataBuilder<?, ?> updatedCaseData = caseData.toBuilder();
.findFirst()
.ifPresent(data -> {
ObligationWAFlag.ObligationWAFlagBuilder obligationWAFlagBuilder = ObligationWAFlag.builder();
boolean isLiftAStay = ObligationReason.LIFT_A_STAY.equals(data.getObligationReason());
boolean isDismissCase = ObligationReason.DISMISS_CASE.equals(data.getObligationReason());
boolean isCaseStayed = CaseState.CASE_STAYED.equals(caseData.getCcdState());
boolean isCaseDismissed = CaseState.CASE_DISMISSED.equals(caseData.getCcdState());

List<Element<ObligationData>> storedObligationDataList = caseData.getStoredObligationData();
if ((!isLiftAStay && !isDismissCase) || (isLiftAStay && isCaseStayed) || (isDismissCase && !isCaseDismissed)) {
kannan-v-hmcts marked this conversation as resolved.
Show resolved Hide resolved
obligationWAFlagBuilder.currentDate(currentDate.format(formatter))
.obligationReason(data.getObligationReason().name())
.obligationReasonDisplayValue(data.getObligationReason().getDisplayedValue());
}

updatedCaseData.storedObligationData(storedObligationDataList);
data.setObligationWATaskRaised(YesOrNo.YES);
caseData.setObligationWAFlag(obligationWAFlagBuilder.build());
});

return AboutToStartOrSubmitCallbackResponse.builder()
.data(updatedCaseData.build().toMap(mapper))
.data(caseData.toBuilder()
.storedObligationData(caseData.getStoredObligationData())
.obligationWAFlag(caseData.getObligationWAFlag())
.build().toMap(mapper))
.build();

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@ public boolean hasNoOngoingBusinessProcess() {
private String messageHistory;
private DynamicList messagesToReplyTo;
private List<Element<Message>> messages;
private ObligationWAFlag obligationWAFlag;

/**
* There are several fields that can hold the I2P of applicant1 depending
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package uk.gov.hmcts.reform.civil.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class ObligationWAFlag {

private String obligationReason;
private String obligationReasonDisplayValue;
private String currentDate;
}
Loading
Loading