Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ public static String fieldContains(String fieldId, Enum<?> value) {
return "%sCONTAINS\"%s\"".formatted(fieldId, value.name());
}

public static String and(String... conditions) {
return String.join(" AND ", conditions);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ public class XuiGenAppRequest implements GenAppRequest {
@CCD(label = "Does the defendant need help paying the fee for this application?")
private VerticalYesNo needHwf;

@CCD(label = "Have they already applied for help with their application fee?")
private VerticalYesNo appliedForHwf;

@CCD(max = 100)
@CCD(
label = "Enter their Help with Fees reference number",
hint = "The defendant will have received this number when they applied for Help with Fees. This reference "
+ "must not have been used for a previous application. For example, HWF-A1B-23C",
max = 60
)
private String hwfReference;

private VerticalYesNo otherPartiesAgreed;
Expand Down Expand Up @@ -65,4 +71,7 @@ public class XuiGenAppRequest implements GenAppRequest {
@CCD(searchable = false)
private String maxFee;

@CCD(searchable = false)
private VerticalYesNo showHwfScreens;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
import uk.gov.hmcts.reform.pcs.ccd.entity.GenAppEntity;
import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity;
import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.AppliedForHelpWithFees;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.ChooseAnApplication;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.DocumentUploadWanted;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.HearingInNext14Days;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.HelpWithFeesNeeded;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.MustApplyForHelpWithFees;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.OtherPartiesAgreed;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.SelectParty;
import uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication.StartAdjourn;
Expand Down Expand Up @@ -81,6 +83,8 @@ public void configureDecentralised(DecentralisedConfigBuilder<PCSCase, State, Us
.add(new SelectParty())
.add(new HearingInNext14Days())
.add(new HelpWithFeesNeeded())
.add(new AppliedForHelpWithFees())
.add(new MustApplyForHelpWithFees())
.add(new OtherPartiesAgreed())
.add(new WhatOrderWanted())
.add(new DocumentUploadWanted())
Expand All @@ -96,6 +100,8 @@ private PCSCase start(EventPayload<PCSCase, State> eventPayload) {

applyApplicationFeeAmounts(caseData);

caseData.getXuiGenAppRequest().setShowHwfScreens(VerticalYesNo.YES);

return caseData;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import uk.gov.hmcts.reform.pcs.ccd.ShowConditions;
import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration;
import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder;
import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase;
import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo;
import uk.gov.hmcts.reform.pcs.ccd.domain.genapp.XuiGenAppRequest;

import static uk.gov.hmcts.reform.pcs.ccd.ShowConditions.fieldEquals;

@Slf4j
@AllArgsConstructor
public class AppliedForHelpWithFees implements CcdPageConfiguration {

@Override
public void addTo(PageBuilder pageBuilder) {
pageBuilder
.page("appliedForHelpWithFees")
.pageLabel("Confirm if they have they already applied for help with their application fee")
.showCondition(ShowConditions.and(
fieldEquals("xui_genapp_ShowHwfScreens", VerticalYesNo.YES),
fieldEquals("xui_genapp_NeedHwf", VerticalYesNo.YES)
))
.label("appliedForHelpWithFees-lineSeparator", "---")
.complex(PCSCase::getXuiGenAppRequest)
.mandatory(XuiGenAppRequest::getAppliedForHwf)
.mandatory(XuiGenAppRequest::getHwfReference, fieldEquals("xui_genapp_AppliedForHwf", VerticalYesNo.YES))
.done();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void addTo(PageBuilder pageBuilder) {
.complex(PCSCase::getXuiGenAppRequest)
.readonly(XuiGenAppRequest::getStandardFee, NEVER_SHOW, true)
.readonly(XuiGenAppRequest::getMaxFee, NEVER_SHOW, true)
.readonly(XuiGenAppRequest::getShowHwfScreens, NEVER_SHOW, true)
.mandatory(XuiGenAppRequest::getApplicationType)
.done();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import uk.gov.hmcts.ccd.sdk.api.CaseDetails;
import uk.gov.hmcts.ccd.sdk.api.callback.AboutToStartOrSubmitResponse;
import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration;
import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder;
import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase;
import uk.gov.hmcts.reform.pcs.ccd.domain.State;
import uk.gov.hmcts.reform.pcs.ccd.domain.genapp.GenAppType;
import uk.gov.hmcts.reform.pcs.ccd.domain.genapp.XuiGenAppRequest;

Expand All @@ -17,7 +20,7 @@ public class HearingInNext14Days implements CcdPageConfiguration {
@Override
public void addTo(PageBuilder pageBuilder) {
pageBuilder
.page("hearingInNext14Days")
.page("hearingInNext14Days", this::midEvent)
.pageLabel("Is the defendant’s court hearing in the next 14 days?")
.showCondition(fieldEquals("xui_genapp_ApplicationType", GenAppType.ADJOURN))
.label("hearingInNext14Days-lineSeparator", "---")
Expand All @@ -26,4 +29,17 @@ public void addTo(PageBuilder pageBuilder) {
.done();
}

private AboutToStartOrSubmitResponse<PCSCase, State> midEvent(CaseDetails<PCSCase, State> details,
CaseDetails<PCSCase, State> detailsBefore) {

PCSCase caseData = details.getData();
XuiGenAppRequest xuiGenAppRequest = caseData.getXuiGenAppRequest();

xuiGenAppRequest.setShowHwfScreens(xuiGenAppRequest.getWithin14Days());

return AboutToStartOrSubmitResponse.<PCSCase, State>builder()
.data(caseData)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,47 @@
import lombok.extern.slf4j.Slf4j;
import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration;
import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder;
import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase;
import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo;
import uk.gov.hmcts.reform.pcs.ccd.domain.genapp.XuiGenAppRequest;

import static uk.gov.hmcts.reform.pcs.ccd.ShowConditions.fieldEquals;

@Slf4j
@AllArgsConstructor
public class HelpWithFeesNeeded implements CcdPageConfiguration {

private static final String PLACEHOLDER = """
<div class="govuk-notification-banner" role="region" aria-labelledby="placeholder-banner">
<div class="govuk-notification-banner__content">
<p class="govuk-notification-banner__heading" id="placeholder-banner">
Placeholder
</p>
</div>
</div>
private static final String INFO_MARKDOWN = """
<p class="govuk-body govuk-!-margin-bottom-1">It usually costs ${xui_genapp_StandardFee} to apply. The fee will
increase to ${xui_genapp_MaxFee} if:</p>
<ul class="govuk-list govuk-list--bullet">
<li class="govuk-!-font-size-19">the defendant has already told the other party that they are making
this application, and</li>
<li class="govuk-!-font-size-19">the other party did not agree to it
(this means that they objected to it)</li>
</ul>
<p class="govuk-body">You’ll see the final application fee before you pay.</p>

<p class="govuk-body govuk-!-margin-bottom-1">The defendant may be able to get help paying the fee
if they (one or more of the following):</p>
<ul class="govuk-list govuk-list--bullet">
<li class="govuk-!-font-size-19">are on certain benefits</li>
<li class="govuk-!-font-size-19">have little or no savings</li>
<li class="govuk-!-font-size-19">have low income</li>
</ul>
""";

@Override
public void addTo(PageBuilder pageBuilder) {
pageBuilder
.page("helpWithFeesNeeded")
.pageLabel("Confirm if the defendant needs help paying fees")
.showCondition(fieldEquals("xui_genapp_ShowHwfScreens", VerticalYesNo.YES))
.label("helpWithFeesNeeded-lineSeparator", "---")
.label("helpWithFeesNeeded-placeholder", PLACEHOLDER);
.label("helpWithFeesNeeded-info", INFO_MARKDOWN)
.complex(PCSCase::getXuiGenAppRequest)
.mandatory(XuiGenAppRequest::getNeedHwf)
.done();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import uk.gov.hmcts.ccd.sdk.api.CaseDetails;
import uk.gov.hmcts.ccd.sdk.api.callback.AboutToStartOrSubmitResponse;
import uk.gov.hmcts.reform.pcs.ccd.ShowConditions;
import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration;
import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder;
import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase;
import uk.gov.hmcts.reform.pcs.ccd.domain.State;
import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo;

import static uk.gov.hmcts.reform.pcs.ccd.ShowConditions.fieldEquals;

@Slf4j
@AllArgsConstructor
public class MustApplyForHelpWithFees implements CcdPageConfiguration {

private static final String INFO_MARKDOWN = """
<p class="govuk-body">
The defendant needs to <a href="https://www.gov.uk/get-help-with-court-fees" target="_blank"
rel="noopener noreferrer" class="govuk-link">apply for Help with Fees (GOV.UK, opens in new tab)</a>
before you can continue with this application. If you are applying for Help with Fees on the defendant’s
behalf, you should do that now before you continue with this application.
</p>
<p class="govuk-body">
Enter the court form number 'N244' when asked. This will be one of the first questions
when you (or they) apply for Help with Fees.
</p>
<p class="govuk-body">
After you (or they) have applied you (or they) will receive a Help With Fees reference number.
Enter the reference number when you return to this application.
</p>
<p class="govuk-body">
If they receive any benefit that qualifies them for Help with Fees, you (or they) must include
evidence of it when you (or they) apply online for Help with Fees.
</p>
<p class="govuk-body">
If you already have their Help with Fees reference number, you can return to the previous screen
and enter it there.
</p>
""";

@Override
public void addTo(PageBuilder pageBuilder) {
pageBuilder
.page("mustApplyForHelpWithFees", this::midEvent)
.pageLabel("The defendant needs to apply for help with their application fee")
.showCondition(ShowConditions.and(
fieldEquals("xui_genapp_ShowHwfScreens", VerticalYesNo.YES),
fieldEquals("xui_genapp_NeedHwf", VerticalYesNo.YES),
fieldEquals("xui_genapp_AppliedForHwf", VerticalYesNo.NO)
))
.label("mustApplyForHelpWithFees-lineSeparator", "---")
.label("mustApplyForHelpWithFees-info", INFO_MARKDOWN);
}

private AboutToStartOrSubmitResponse<PCSCase, State> midEvent(CaseDetails<PCSCase, State> details,
CaseDetails<PCSCase, State> detailsBefore) {

return AboutToStartOrSubmitResponse.<PCSCase, State>builder()
.errorMessageOverride("You cannot continue until you have their reference number for Help with Fees")
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package uk.gov.hmcts.reform.pcs.ccd;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import uk.gov.hmcts.reform.pcs.ccd.domain.State;

import java.util.List;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;

class ShowConditionsTest {
Expand Down Expand Up @@ -39,6 +45,24 @@ void shouldCreateShowConditionForFieldContains() {
assertThat(showCondition).isEqualTo("testFieldId1CONTAINS\"BLUE\"");
}

@ParameterizedTest
@MethodSource("joinWithAndScenarios")
void shouldJoinShowConditionWithAnd(List<String> showConditionsToJoin, String expectedJoinedShowConditions) {
String showCondition = ShowConditions.and(showConditionsToJoin.toArray(new String[0]));

assertThat(showCondition).isEqualTo(expectedJoinedShowConditions);
}

private static Stream<Arguments> joinWithAndScenarios() {
return Stream.of(
// Show conditions to join, expected joined show condition
Arguments.argumentSet("no params", List.of(), ""),
Arguments.argumentSet("one param", List.of("a"), "a"),
Arguments.argumentSet("two params", List.of("a", "b"), "a AND b"),
Arguments.argumentSet("three params", List.of("a", "b", "c"), "a AND b AND c")
);
}

private enum TestEnum {
RED,
GREEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void shouldSetRepresentedPartiesFieldWhenUserRepresentsOne() {
.thenReturn(Optional.of(expectedPartyNameList));

PCSCase caseData = PCSCase.builder()
.xuiGenAppRequest(XuiGenAppRequest.builder().build())
.build();

// When
Expand Down Expand Up @@ -133,6 +134,7 @@ void shouldSetMultipleRepresentedPartiesFlag(int numRepresentedParties, Vertical
.thenReturn(Optional.of(expectedPartyNameList));

PCSCase caseData = PCSCase.builder()
.xuiGenAppRequest(XuiGenAppRequest.builder().build())
.build();

// When
Expand Down Expand Up @@ -160,6 +162,7 @@ void shouldNotSetRepresentedPartiesFieldWhenUserDoesNotRepresentAny() {
.thenReturn(Optional.empty());

PCSCase caseData = PCSCase.builder()
.xuiGenAppRequest(XuiGenAppRequest.builder().build())
.build();

// When
Expand Down Expand Up @@ -193,6 +196,20 @@ void shouldSetTheApplicationFees() {
feeSetterCaptor.getValue().accept(caseData, formattedMaxFee);
assertThat(caseData.getXuiGenAppRequest().getMaxFee()).isEqualTo(formattedMaxFee);
}

@Test
void shouldSetShowHwfScreensFlagToYes() {
// Given
PCSCase caseData = PCSCase.builder()
.xuiGenAppRequest(XuiGenAppRequest.builder().build())
.build();

// When
callStartHandler(caseData);

// Then
assertThat(caseData.getXuiGenAppRequest().getShowHwfScreens()).isEqualTo(VerticalYesNo.YES);
}
}

@Nested
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package uk.gov.hmcts.reform.pcs.ccd.page.makeanapplication;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import uk.gov.hmcts.ccd.sdk.api.callback.AboutToStartOrSubmitResponse;
import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase;
import uk.gov.hmcts.reform.pcs.ccd.domain.State;
import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo;
import uk.gov.hmcts.reform.pcs.ccd.domain.genapp.XuiGenAppRequest;
import uk.gov.hmcts.reform.pcs.ccd.page.BasePageTest;

import static org.assertj.core.api.Assertions.assertThat;

class HearingInNext14DaysTest extends BasePageTest {

@BeforeEach
void setUp() {
setPageUnderTest(new HearingInNext14Days());
}

@ParameterizedTest
@EnumSource(value = VerticalYesNo.class)
void shouldSetShowHwfScreens(VerticalYesNo hearingWithinNext14Days) {
// Given
PCSCase caseData = PCSCase.builder()
.xuiGenAppRequest(XuiGenAppRequest.builder()
.within14Days(hearingWithinNext14Days)
.build())
.build();

// When
AboutToStartOrSubmitResponse<PCSCase, State> response = callMidEventHandler(caseData);

// Then
PCSCase updatedCaseData = response.getData();
assertThat(updatedCaseData.getXuiGenAppRequest().getShowHwfScreens()).isEqualTo(hearingWithinNext14Days);
}

}
Loading