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

RIA-9470 add_late_remission_condition #2320

Merged
merged 4 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -29,6 +29,7 @@
import uk.gov.hmcts.reform.iacaseapi.domain.entities.DynamicList;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.HearingAdjournmentDay;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.HearingCentre;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.StrategicCaseFlag;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.CaseDetails;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
Expand Down Expand Up @@ -327,4 +328,9 @@ private static boolean hearingDateUnchanged(AsylumCase asylumCase, AsylumCase as

return prevHearingDate.equalsIgnoreCase(currentHearingDate);
}

public static boolean isRemissionExists(Optional<RemissionType> remissionType) {
return remissionType.isPresent()
&& remissionType.get() != RemissionType.NO_REMISSION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_TYPE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision.APPROVED;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision.PARTIALLY_APPROVED;
import static uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils.isRemissionExists;

import java.math.BigDecimal;
import java.util.Arrays;
Expand Down Expand Up @@ -219,12 +220,6 @@ private boolean isRemissionApprovedOrPartiallyApproved(Optional<RemissionDecisio
.contains(remissionDecision.get());
}

private boolean isRemissionExists(Optional<RemissionType> remissionType) {

return remissionType.isPresent()
&& remissionType.get() != RemissionType.NO_REMISSION;
}

private boolean completedStagesHasFeeUpdateStatus(
Optional<List<String>> completedStages, String preRequisiteFeeUpdateStatus) {
AtomicBoolean preRequisiteFeeUpdateStatusExists = new AtomicBoolean(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.HelpWithFeesOption.WILL_PAY_FOR_APPEAL;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision.*;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionOption.NO_REMISSION;
import static uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils.isRemissionExists;

import java.util.Arrays;
import java.util.Optional;
Expand Down Expand Up @@ -112,11 +113,6 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
return callbackResponse;
}

private boolean isRemissionExists(Optional<RemissionType> remissionType) {

return remissionType.isPresent() && remissionType.get() != RemissionType.NO_REMISSION;
}

private boolean isRemissionExistsAip(Optional<RemissionOption> remissionOption, Optional<HelpWithFeesOption> helpWithFeesOption) {
boolean isDlrmFeeRemission = featureToggler.getValue("dlrm-fee-remission-feature-flag", false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.HelpWithFeesOption.WILL_PAY_FOR_APPEAL;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision.*;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType.*;
import static uk.gov.hmcts.reform.iacaseapi.domain.handlers.HandlerUtils.isRemissionExists;

import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -137,12 +138,14 @@ private void checkPaymentConditions(AppealType appealType, AsylumCase asylumCase
Optional<String> eaHuPaymentType = asylumCase.read(EA_HU_APPEAL_TYPE_PAYMENT_OPTION, String.class);
boolean isEaHuEuAg = List.of(EA, HU, EU, AG).contains(appealType);
// old cases
if ((appealType == PA && remissionType.isEmpty() && paPaymentType.isEmpty())
|| (isEaHuEuAg && remissionType.isEmpty()
&& eaHuPaymentType.isEmpty())) {
if (!isRemissionExists(remissionType) && !isRemissionExists(lateRemissionType)
&& ((appealType == PA && paPaymentType.isEmpty()) || (isEaHuEuAg && eaHuPaymentType.isEmpty()))
) {
callbackResponse.addError(NOT_AVAILABLE_LABEL);
}
if (isEaHuEuAg && (remissionType.isEmpty() || remissionType.get() == NO_REMISSION)
if (!isRemissionExists(remissionType)
&& !isRemissionExists(lateRemissionType)
&& isEaHuEuAg
&& eaHuPaymentType.isPresent() && eaHuPaymentType.get().equals("payNow")
&& paymentStatus.isPresent() && paymentStatus.get() == PaymentStatus.PAID) {
callbackResponse.addError(NOT_AVAILABLE_LABEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,33 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.reset;
import static org.powermock.api.mockito.PowerMockito.when;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.*;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.*;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.AG;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.EA;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.EU;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.HU;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType.PA;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.APPEAL_TYPE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.APPELLANT_IN_DETENTION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.EA_HU_APPEAL_TYPE_PAYMENT_OPTION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.HELP_WITH_FEES_OPTION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.IS_ACCELERATED_DETAINED_APPEAL;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.IS_ADMIN;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.JOURNEY_TYPE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.LATE_REMISSION_TYPE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PAYMENT_STATUS;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.PA_APPEAL_TYPE_PAYMENT_OPTION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_DECISION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_OPTION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition.REMISSION_TYPE;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.HelpWithFeesOption.WILL_PAY_FOR_APPEAL;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionOption.NO_REMISSION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage.*;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType.HO_WAIVER_REMISSION;
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.PreSubmitCallbackStage.ABOUT_TO_START;

import java.util.Optional;
import java.util.stream.Stream;
Expand All @@ -26,7 +45,13 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.*;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AppealType;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCase;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.AsylumCaseFieldDefinition;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.HelpWithFeesOption;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionDecision;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionOption;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.RemissionType;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.CaseDetails;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.callback.Callback;
Expand Down Expand Up @@ -419,4 +444,49 @@ void should_not_allow_null_arguments() {
.isExactlyInstanceOf(NullPointerException.class);
}

@ParameterizedTest
@MethodSource("appealTypesWithRemissionOptions")
void should_pass_checkRemissionConditions_if_remission_or_late_remission_present(
AppealType appealType,
Optional<RemissionType> remissionType,
Optional<RemissionType> lateRemission) {

when(callback.getCaseDetails()).thenReturn(caseDetails);
when(callback.getEvent()).thenReturn(Event.MARK_APPEAL_PAID);
when(callback.getCaseDetails().getCaseData()).thenReturn(asylumCase);
when(asylumCase.read(APPEAL_TYPE, AppealType.class)).thenReturn(Optional.of(appealType));
when(asylumCase.read(REMISSION_TYPE, RemissionType.class)).thenReturn(remissionType);
when(asylumCase.read(LATE_REMISSION_TYPE, RemissionType.class)).thenReturn(lateRemission);
when(asylumCase.read(PA_APPEAL_TYPE_PAYMENT_OPTION, String.class)).thenReturn(Optional.empty());
when(asylumCase.read(EA_HU_APPEAL_TYPE_PAYMENT_OPTION, String.class)).thenReturn(Optional.empty());
when(asylumCase.read(REMISSION_DECISION, RemissionDecision.class)).thenReturn(Optional.of(RemissionDecision.REJECTED));


PreSubmitCallbackResponse<AsylumCase> returnedCallbackResponse =
markPaymentPaidPreparer.handle(ABOUT_TO_START, callback);

assertNotNull(returnedCallbackResponse);
assertThat(returnedCallbackResponse.getErrors()).isEmpty();
}

private static Stream<Arguments> appealTypesWithRemissionOptions() {
return Stream.of(
Arguments.of(EA, Optional.of(HO_WAIVER_REMISSION), Optional.empty()),
Arguments.of(EA, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(EA, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(HU, Optional.of(HO_WAIVER_REMISSION), Optional.empty()),
Arguments.of(HU, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(HU, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(EU, Optional.of(HO_WAIVER_REMISSION), Optional.empty()),
Arguments.of(EU, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(EU, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(PA, Optional.of(HO_WAIVER_REMISSION), Optional.empty()),
Arguments.of(PA, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(PA, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(AG, Optional.of(HO_WAIVER_REMISSION), Optional.empty()),
Arguments.of(AG, Optional.empty(), Optional.of(HO_WAIVER_REMISSION)),
Arguments.of(AG, Optional.of(NO_REMISSION), Optional.of(HO_WAIVER_REMISSION))
);
}

}
Loading