Skip to content

Commit

Permalink
CIV-0000 sprint CIV-15078, CIV-15290 (#1521)
Browse files Browse the repository at this point in the history
* CIV-15078 CoSc check your answer screen (#1511)

* Initial Commit

* CIV-15078 initial commit

* CIV-15078 changes

* Push

* CIV-15078 changes

* Fix code review

---------

Co-authored-by: ShwetaTandel-hmcts <[email protected]>
Co-authored-by: Azam <[email protected]>

* CIV-15290 CoSC - set CoSCApplicationStatus to Active on successful payment of application fee (#1508)

* Initial Commit

* CIV-15290 New main case variable when application paid

* CIV-15290 New main case variable when application paid

* CIV-15290 New main case variable when application paid

* CIV-15078 initial commit

* CIV-15078 changes

* Push

* CIV-15078 changes

* add the cosc FeatureToggleService and logic when is paid

* Fix code review

* remove unused code

* add tests

* add FeatureToggleService from master and add the correct logic on GeneralApplicationAfterPaymentCallbackHandler

* removed field in casedata

* fixed checktyles

* removed toggle

---------

Co-authored-by: ShwetaTandel-hmcts <[email protected]>
Co-authored-by: kalachandrasekar1 <[email protected]>
Co-authored-by: kalachandrasekar1 <[email protected]>
Co-authored-by: LeonardoPalmeiro <[email protected]>
Co-authored-by: Sherlyn Khaw <[email protected]>
Co-authored-by: Azam <[email protected]>

---------

Co-authored-by: kalachandrasekar1 <[email protected]>
Co-authored-by: ShwetaTandel-hmcts <[email protected]>
Co-authored-by: Azam <[email protected]>
Co-authored-by: hmcts-version1-ignacio <[email protected]>
Co-authored-by: kalachandrasekar1 <[email protected]>
Co-authored-by: LeonardoPalmeiro <[email protected]>
Co-authored-by: krishnanuthalapati <[email protected]>
  • Loading branch information
8 people authored Oct 17, 2024
1 parent a8e214d commit 3eca14c
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public enum CaseEvent {
NOTIFY_HEARING_NOTICE_DEFENDANT(CAMUNDA),
END_SCHEDULER_CHECK_UNLESS_ORDER_DEADLINE(CAMUNDA),
INITIATE_GENERAL_APPLICATION_AFTER_PAYMENT(USER),
INITIATE_COSC_APPLICATION_AFTER_PAYMENT(USER),
migrateCase(CAMUNDA), // NOSONAR
APPROVE_CONSENT_ORDER(USER),
TRIGGER_LOCATION_UPDATE(USER),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class GeneralAppFeesConfiguration {
private final String consentedOrWithoutNoticeKeyword;
private final String applicationUncloakAdditionalFee;
private final String appnToVaryOrSuspend;
private final String certificateOfSatisfaction;

public GeneralAppFeesConfiguration(
@Value("${fees.api.url}") String url,
Expand All @@ -31,7 +32,8 @@ public GeneralAppFeesConfiguration(
@Value("${genApp.fee.keywords.withNotice}") String withNoticeKeyword,
@Value("${genApp.fee.keywords.consentedOrWithoutNotice}") String consentedOrWithoutNoticeKeyword,
@Value("${genApp.fee.keywords.uncloakFee}") String applicationUncloakAdditionalFee,
@Value("${genApp.fee.keywords.appnToVaryOrSuspend}") String appnToVaryOrSuspend) {
@Value("${genApp.fee.keywords.appnToVaryOrSuspend}") String appnToVaryOrSuspend,
@Value("${genApp.fee.keywords.certificateOfSatisfaction}") String certificateOfSatisfaction) {
this.url = url;
this.endpoint = endpoint;
this.service = service;
Expand All @@ -43,6 +45,7 @@ public GeneralAppFeesConfiguration(
this.consentedOrWithoutNoticeKeyword = consentedOrWithoutNoticeKeyword;
this.applicationUncloakAdditionalFee = applicationUncloakAdditionalFee;
this.appnToVaryOrSuspend = appnToVaryOrSuspend;
this.certificateOfSatisfaction = certificateOfSatisfaction;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public enum GeneralApplicationTypes {
ADJOURN_HEARING("Adjourn a hearing"),
UNLESS_ORDER("Unless order"),
OTHER("Other"),
VARY_PAYMENT_TERMS_OF_JUDGMENT("Vary payment terms of judgment");
VARY_PAYMENT_TERMS_OF_JUDGMENT("Vary payment terms of judgment"),
CONFIRM_CCJ_DEBT_PAID("Confirm you've paid a judgment debt");

private final String displayedValue;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.enums.PaymentStatus;
import uk.gov.hmcts.reform.civil.enums.dq.GeneralApplicationTypes;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.PaymentDetails;
Expand All @@ -24,6 +25,7 @@
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INITIATE_GENERAL_APPLICATION_AFTER_PAYMENT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INITIATE_COSC_APPLICATION_AFTER_PAYMENT;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -57,8 +59,13 @@ private CallbackResponse generalAppAfterPayment(CallbackParams callbackParams) {
return getCallbackResponse(caseDataBuilder);
}

caseDataBuilder.businessProcess(BusinessProcess
.ready(INITIATE_GENERAL_APPLICATION_AFTER_PAYMENT));
if (caseData.getGeneralAppType().getTypes().contains(GeneralApplicationTypes.CONFIRM_CCJ_DEBT_PAID)) {
caseDataBuilder.businessProcess(BusinessProcess
.ready(INITIATE_COSC_APPLICATION_AFTER_PAYMENT));
} else {
caseDataBuilder.businessProcess(BusinessProcess
.ready(INITIATE_GENERAL_APPLICATION_AFTER_PAYMENT));
}

return getCallbackResponse(caseDataBuilder);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/uk/gov/hmcts/reform/civil/model/CaseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import uk.gov.hmcts.reform.civil.enums.dq.Language;
import uk.gov.hmcts.reform.civil.enums.dq.OrderMadeOnTypes;
import uk.gov.hmcts.reform.civil.enums.dq.OrderOnCourts;
import uk.gov.hmcts.reform.civil.model.citizenui.CertOfSC;
import uk.gov.hmcts.reform.civil.model.citizenui.HelpWithFees;
import uk.gov.hmcts.reform.civil.model.citizenui.RespondentLiPResponse;
import uk.gov.hmcts.reform.civil.model.common.Element;
Expand Down Expand Up @@ -341,6 +342,7 @@ public class CaseData implements MappableObject {
private String generalAppAddlnInfoText;
private String generalAppWrittenRepText;
private YesOrNo respondentResponseDeadlineChecked;
private final CertOfSC certOfSC;
//Case name for manage case
private String caseNameGaInternal;
private String claimantBilingualLanguagePreference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class GeneralAppFeesService {
= List.of(GeneralApplicationTypes.ADJOURN_HEARING);
protected static final List<GeneralApplicationTypes> SD_CONSENT_TYPES
= List.of(GeneralApplicationTypes.SETTLE_BY_CONSENT);
protected static final List<GeneralApplicationTypes> CONFIRM_YOU_PAID_CCJ_DEBT
= List.of(GeneralApplicationTypes.CONFIRM_CCJ_DEBT_PAID);

public Fee getFeeForGA(CaseData caseData) {
Fee result = Fee.builder().calculatedAmountInPence(BigDecimal.valueOf(Integer.MAX_VALUE)).build();
Expand Down Expand Up @@ -78,6 +80,11 @@ public Fee getFeeForGA(CaseData caseData) {
result = setAsideFeeForGA;
}
}
if (isUpdateCoScGATypeSize(typeSize, caseData.getGeneralAppType().getTypes())) {
typeSize--;
Fee certOfSatisfactionOrCancel = getFeeForGA(feesConfiguration.getCertificateOfSatisfaction(), "miscellaneous", "other");
result = getCoScFeeResult(result, certOfSatisfactionOrCancel);
}
if (typeSize > 0) {
Fee defaultFee = getDefaultFee(caseData);
if (defaultFee.getCalculatedAmountInPence()
Expand Down Expand Up @@ -174,4 +181,15 @@ private Fee buildFeeDto(FeeLookupResponseDto feeLookupResponseDto) {
.version(feeLookupResponseDto.getVersion().toString())
.build();
}

private boolean isUpdateCoScGATypeSize(int typeSize, List<GeneralApplicationTypes> types) {
return typeSize > 0 && CollectionUtils.containsAny(types, CONFIRM_YOU_PAID_CCJ_DEBT);
}

private Fee getCoScFeeResult(Fee existingResult, Fee certOfSatisfactionOrCancel) {
if (certOfSatisfactionOrCancel.getCalculatedAmountInPence().compareTo(existingResult.getCalculatedAmountInPence()) < 0) {
return certOfSatisfactionOrCancel;
}
return existingResult;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.CaseLink;
import uk.gov.hmcts.reform.civil.model.IdamUserDetails;
import uk.gov.hmcts.reform.civil.model.citizenui.CertOfSC;
import uk.gov.hmcts.reform.civil.model.common.Element;
import uk.gov.hmcts.reform.civil.model.documents.CaseDocument;
import uk.gov.hmcts.reform.civil.model.documents.Document;
Expand Down Expand Up @@ -834,6 +835,7 @@ private GeneralApplication buildGeneralApplication(GeneralApplication generalApp
.caseManagementCategory(GACaseManagementCategory.builder().build())
.locationName(EMPTY)
.generalAppHearingDate(GAHearingDateGAspec.builder().build())
.certOfSC(CertOfSC.builder().build())
.applicantPartyName(EMPTY).build();

return applicationBuilder.build();
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ genApp:
consentedOrWithoutNotice: GeneralAppWithoutNotice
uncloakFee: HACFOOnNotice
appnToVaryOrSuspend: AppnToVaryOrSuspend
certificateOfSatisfaction: CoS
lrd:
endpoint: /refdata/location/court-venues

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.enums.PaymentStatus;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.enums.dq.GeneralApplicationTypes;
import uk.gov.hmcts.reform.civil.handler.callback.BaseCallbackHandlerTest;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.Fee;
Expand All @@ -34,6 +35,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INITIATE_COSC_APPLICATION_AFTER_PAYMENT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.INITIATE_GENERAL_APPLICATION_AFTER_PAYMENT;
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.NO;
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES;
Expand All @@ -51,14 +53,24 @@ public class GeneralApplicationAfterPaymentCallbackHandlerTest extends BaseCallb
private GeneralApplicationAfterPaymentCallbackHandler handler;
@Autowired
private ObjectMapper objectMapper;

@MockBean
private GaForLipService gaForLipService;

private static final String STRING_CONSTANT = "STRING_CONSTANT";
private static final Long CHILD_CCD_REF = 1646003133062762L;
private static final Long PARENT_CCD_REF = 1645779506193000L;

@Test
void shouldTriggerCoscBusinessProcess() {
CaseData caseData = getSampleGeneralApplicationCaseData(NO, YES);
caseData = addGeneralAppType(caseData, GeneralApplicationTypes.CONFIRM_CCJ_DEBT_PAID);
CallbackParams params = callbackParamsOf(caseData, ABOUT_TO_SUBMIT);
when(gaForLipService.isLipApp(any(CaseData.class))).thenReturn(false);
var response = (AboutToStartOrSubmitCallbackResponse) handler.handle(params);
CaseData responseCaseData = objectMapper.convertValue(response.getData(), CaseData.class);
assertThat(responseCaseData.getBusinessProcess().getCamundaEvent()).isEqualTo(INITIATE_COSC_APPLICATION_AFTER_PAYMENT.name());
}

@Test
void shouldTriggerTheEventAndAboutToSubmit() {
CaseData caseData = getSampleGeneralApplicationCaseData(NO, YES);
Expand Down Expand Up @@ -146,4 +158,12 @@ private CaseData addPaymentStatusToGAPbaDetails(CaseData caseData, PaymentStatus
.generalAppPBADetails(pbaDetails)
.build();
}

private CaseData addGeneralAppType(CaseData caseData, GeneralApplicationTypes generalApplicationTypes) {
return caseData.toBuilder().generalAppType(
GAApplicationType.builder().types(List.of(generalApplicationTypes))
.build())
.build();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class GeneralAppFeesServiceTest {
private static final BigDecimal TEST_FEE_AMOUNT_PENCE_275 = new BigDecimal("27500");
private static final BigDecimal TEST_FEE_AMOUNT_POUNDS_14 = new BigDecimal("14.00");
private static final BigDecimal TEST_FEE_AMOUNT_PENCE_14 = new BigDecimal("1400");
private static final BigDecimal TEST_FEE_AMOUNT_POUNDS_15 = new BigDecimal("15.00");
private static final BigDecimal TEST_FEE_AMOUNT_PENCE_15 = new BigDecimal("1500");
private static final String AppnToVaryOrSuspend = "AppnToVaryOrSuspend";
private static final String CERT_OF_SATISFACTION_OR_CANCEL = "CertificateOfSorC";
private static final String WithoutNotice = "GeneralAppWithoutNotice";
private static final String GAOnNotice = "GAOnNotice";
private static final String GAFree = "CopyPagesUpTo10";
Expand All @@ -75,6 +78,10 @@ class GeneralAppFeesServiceTest {
public static final String FREE_REF = "FREE";
private static final Fee FEE_PENCE_0 = Fee.builder()
.calculatedAmountInPence(BigDecimal.ZERO).code(FREE_REF).version("1").build();
private static final FeeLookupResponseDto FEE_POUNDS_15 = FeeLookupResponseDto.builder()
.feeAmount(TEST_FEE_AMOUNT_POUNDS_15).code("test_fee_code").version(1).build();
private static final Fee FEE_PENCE_15 = Fee.builder()
.calculatedAmountInPence(TEST_FEE_AMOUNT_PENCE_15).code("test_fee_code").version("1").build();

@Captor
private ArgumentCaptor<String> stringArgumentCaptor;
Expand Down Expand Up @@ -328,6 +335,7 @@ void default_types_with_notice_should_pay_275() {
allTypes.removeAll(GeneralAppFeesService.SET_ASIDE);
allTypes.removeAll(GeneralAppFeesService.ADJOURN_TYPES);
allTypes.removeAll(GeneralAppFeesService.SD_CONSENT_TYPES);
allTypes.removeAll(GeneralAppFeesService.CONFIRM_YOU_PAID_CCJ_DEBT);
//single
for (GeneralApplicationTypes generalApplicationType : allTypes) {
CaseData caseData = getFeeCase(
Expand Down Expand Up @@ -366,6 +374,7 @@ void default_types_without_notice_should_pay_108() {
allTypes.removeAll(GeneralAppFeesService.SET_ASIDE);
allTypes.removeAll(GeneralAppFeesService.ADJOURN_TYPES);
allTypes.removeAll(GeneralAppFeesService.SD_CONSENT_TYPES);
allTypes.removeAll(GeneralAppFeesService.CONFIRM_YOU_PAID_CCJ_DEBT);
//single
for (GeneralApplicationTypes generalApplicationType : allTypes) {
CaseData caseData = getFeeCase(
Expand Down Expand Up @@ -611,6 +620,7 @@ void mix_default_vary_should_be_14() {

List<GeneralApplicationTypes> randomList = getRandomDefaultTypes();
randomList.add(GeneralApplicationTypes.VARY_PAYMENT_TERMS_OF_JUDGMENT);

CaseData caseDataOutside14Days = getFeeCase(
randomList,
YesOrNo.YES, YesOrNo.YES, LocalDate.now().plusDays(15)
Expand Down Expand Up @@ -675,13 +685,36 @@ void mix_default_vary_set_aside_should_be_14() {
.isEqualTo(FEE_PENCE_14);
}

@Test
void shouldReturnFeeData_whenCertificateOfSatisfactionOrCancelRequested() {
when(feesConfiguration.getChannel()).thenReturn("default");
when(feesConfiguration.getJurisdiction1()).thenReturn("civil");
when(feesConfiguration.getJurisdiction2()).thenReturn("civil");
when(feesConfiguration.getCertificateOfSatisfaction()).thenReturn("CertificateOfSorC");

when(feesApiClient.lookupFee(
anyString(),
anyString(),
anyString(),
anyString(),
anyString(),
eq(CERT_OF_SATISFACTION_OR_CANCEL)
)).thenReturn(FEE_POUNDS_15);

CaseData caseData = getFeeCase(
List.of(GeneralApplicationTypes.CONFIRM_CCJ_DEBT_PAID), YesOrNo.NO, YesOrNo.NO, null);
Fee feeDto = feesService.getFeeForGA(caseData);
assertThat(feeDto).isEqualTo(FEE_PENCE_15);
}

private List<GeneralApplicationTypes> getRandomDefaultTypes() {
List<GeneralApplicationTypes> allTypes =
Stream.of(GeneralApplicationTypes.values()).collect(Collectors.toList());
allTypes.removeAll(GeneralAppFeesService.VARY_TYPES);
allTypes.removeAll(GeneralAppFeesService.SET_ASIDE);
allTypes.removeAll(GeneralAppFeesService.ADJOURN_TYPES);
allTypes.removeAll(GeneralAppFeesService.SD_CONSENT_TYPES);
allTypes.removeAll(GeneralAppFeesService.CONFIRM_YOU_PAID_CCJ_DEBT);
Collections.shuffle(allTypes);
Random rand = new Random();
int min = 1;
Expand Down

0 comments on commit 3eca14c

Please sign in to comment.