-
Notifications
You must be signed in to change notification settings - Fork 2
Hdpi 4312 confirm eviction summary #1550
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
base: master
Are you sure you want to change the base?
Changes from all commits
f85c09a
5e5a643
2051b40
f6229ee
464d212
102f9d6
bcd77ad
dd08a0f
3d56407
5eb187a
25648ea
1d105e2
3e6165b
afbd098
e294cb0
2db4061
a5e7fb6
8595499
3bcc795
d68f6e1
1d6f98f
21df5f8
cd9b42c
4541fd4
1b81801
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Component; | ||
| import uk.gov.hmcts.ccd.sdk.type.YesOrNo; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; | ||
| import uk.gov.hmcts.reform.pcs.ccd.repository.PcsCaseRepository; | ||
| import uk.gov.hmcts.reform.pcs.ccd.repository.enforcetheorder.EnforcementOrderRepository; | ||
| import uk.gov.hmcts.reform.pcs.ccd.util.DateUtil; | ||
| import uk.gov.hmcts.reform.pcs.exception.CaseNotFoundException; | ||
|
|
||
| import java.time.Instant; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| import static uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction.MarkupContent.CONFIRM_EVICTION_SUMMARY_NO_DATES; | ||
| import static uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction.MarkupContent.CONFIRM_EVICTION_SUMMARY_WITH_DATES; | ||
|
|
||
| @Component | ||
| @Slf4j | ||
| @AllArgsConstructor | ||
| public class EnforcementOrderMediator { | ||
|
|
||
| private final PcsCaseRepository pcsCaseRepository; | ||
| private final EnforcementOrderRepository enforcementOrderRepository; | ||
| private final DateUtil dateUtil; | ||
|
|
||
| public void handleEnforcementRequirements(long caseReference, PCSCase pcsCase) { | ||
| if (caseReference > 0 && pcsCase != null) { | ||
| Optional<EnforcementOrderEntity> optionalEnforcementOrder = getEnforcementOrder(caseReference); | ||
| if (optionalEnforcementOrder.isPresent()) { | ||
| EnforcementOrderEntity enforcementOrderEntity = optionalEnforcementOrder.get(); | ||
| if (enforcementOrderEntity.getBailiffDate() != null) { | ||
| hasBailiffDate(pcsCase, enforcementOrderEntity.getBailiffDate()); | ||
| } else { | ||
| noBailiffDate(pcsCase); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Optional<EnforcementOrderEntity> getEnforcementOrder(long caseReference) { | ||
| PcsCaseEntity pcsCaseEntity = pcsCaseRepository.findByCaseReference(caseReference) | ||
| .orElseThrow(() -> new CaseNotFoundException(caseReference)); | ||
| List<ClaimEntity> claims = pcsCaseEntity.getClaims(); | ||
| if (claims != null && !claims.isEmpty()) { | ||
| return enforcementOrderRepository.findByClaimId(claims.getFirst().getId()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we know which type of enforcement case should be retrieved as there could be different ones linked to the same enf_case ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yer this is a pain point and had me stuck. Have had conversations with Nafees on this a few times. It may just link to the latest ... which at the time ... I did not have HDPI-4220 which has adds the "created" field. However, again, the latest of which? It is possible we may need the enforcement type to be applied to the enf_case table for this type of scenario but all of this is unknown at the moment.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can find the enf_case associated with the warrant of possession if you use enforcementOrderService. retrieveEnforcementOrder.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Confirm Eviction may not have come from that though. |
||
| } | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| private void hasBailiffDate(PCSCase pcsCase, Instant instant) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this method also be made static or this and the method below changed to non-static ? |
||
| pcsCase.setShowConfirmEvictionJourney(YesOrNo.YES); | ||
| pcsCase.setConfirmEvictionSummaryMarkup(String.format( | ||
| CONFIRM_EVICTION_SUMMARY_WITH_DATES, | ||
| dateUtil.formatDate(instant), | ||
| dateUtil.minusHoursFormatted(instant, 72))); | ||
| } | ||
|
|
||
| private static void noBailiffDate(PCSCase pcsCase) { | ||
| pcsCase.setShowConfirmEvictionJourney(YesOrNo.NO); | ||
| pcsCase.setConfirmEvictionSummaryMarkup(CONFIRM_EVICTION_SUMMARY_NO_DATES); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.event.confirmeviction; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import org.springframework.stereotype.Component; | ||
| import uk.gov.hmcts.ccd.sdk.api.CCDConfig; | ||
| import uk.gov.hmcts.ccd.sdk.api.DecentralisedConfigBuilder; | ||
| import uk.gov.hmcts.ccd.sdk.api.Event; | ||
| import uk.gov.hmcts.ccd.sdk.api.EventPayload; | ||
| import uk.gov.hmcts.ccd.sdk.api.Permission; | ||
| import uk.gov.hmcts.ccd.sdk.api.callback.SubmitResponse; | ||
| import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole; | ||
| 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.page.enforcetheorder.confirmeviction.ConfirmEvictionConfigurer; | ||
|
|
||
| import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.confirmEviction; | ||
|
|
||
| @Component | ||
| @AllArgsConstructor | ||
| public class ConfirmEviction implements CCDConfig<PCSCase, State, UserRole> { | ||
|
|
||
| private final ConfirmEvictionConfigurer confirmEvictionConfigurer; | ||
|
|
||
| @Override | ||
| public void configureDecentralised(DecentralisedConfigBuilder<PCSCase, State, UserRole> configBuilder) { | ||
| Event.EventBuilder<PCSCase, UserRole, State> eventBuilder = | ||
| configBuilder | ||
| .decentralisedEvent(confirmEviction.name(), this::submit) | ||
| .forAllStates() | ||
| .name("Confirm the eviction details") | ||
| .grant(Permission.CRUD, UserRole.PCS_SOLICITOR) | ||
| .showSummary(); | ||
| confirmEvictionConfigurer.configurePages(new PageBuilder(eventBuilder)); | ||
| } | ||
|
|
||
| private SubmitResponse<State> submit(EventPayload<PCSCase, State> eventPayload) { | ||
| return SubmitResponse.defaultResponse(); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import org.springframework.stereotype.Component; | ||
| import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; | ||
| import uk.gov.hmcts.reform.pcs.ccd.common.PageConfigurer; | ||
|
|
||
| @Component | ||
| @AllArgsConstructor | ||
| public class ConfirmEvictionConfigurer implements PageConfigurer { | ||
|
|
||
| @Override | ||
| public void configurePages(PageBuilder pageBuilder) { | ||
| pageBuilder | ||
| .add(new ConfirmEvictionDetailsPage()) | ||
| .add(new EvictionDatePage()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; | ||
|
|
||
| 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.page.CcdPage; | ||
|
|
||
| public class ConfirmEvictionDetailsPage implements CcdPageConfiguration, CcdPage { | ||
|
|
||
| public static final String CONFIRM_EVICTION_DETAILS_CONTENT = """ | ||
| <p class="govuk-body"> | ||
| The bailiff has arranged a date for the eviction and they need you to confirm if you are | ||
| available. | ||
| </p> | ||
| <p class="govuk-body"> | ||
| They will also ask you to confirm if the person being evicted poses any risk. | ||
| </p> | ||
| <p class="govuk-body"> | ||
| The bailiff needs this information to carry out the eviction safely. If you do not provide it, | ||
| they may not be able to complete the eviction. | ||
| </p> | ||
| <p class="govuk-body govuk-!-font-weight-bold govuk-!-font-size-24">What you’ll need | ||
| </p> | ||
| <p class="govuk-body govuk-!-margin-bottom-0">You’ll need to know:</p> | ||
| <ul class="govuk-list govuk-list--bullet"> | ||
| <li class="govuk-!-font-size-19">who will attend the eviction (you, or someone else)</li> | ||
| <li class="govuk-!-font-size-19">if you (or they) can attend the eviction on the date suggested | ||
| by the bailiff</li> | ||
| </ul> | ||
| <p class="govuk-body govuk-!-margin-bottom-0">We will also ask you to:</p> | ||
| <ul class="govuk-list govuk-list--bullet"> | ||
| <li class="govuk-!-font-size-19">describe the person who will be evicted</li> | ||
| <li class="govuk-!-font-size-19">tell us how to access the property</li> | ||
| <li class="govuk-!-font-size-19">book a locksmith (this is to make sure that the person being | ||
| evicted cannot return to the property)</li> | ||
| </ul> | ||
| <p class="govuk-body"> | ||
| Once you have confirmed the eviction date, we’ll send you an email reminding you to book a | ||
| locksmith. | ||
| </p> | ||
| """; | ||
|
|
||
| @Override | ||
| public void addTo(PageBuilder pageBuilder) { | ||
| String pageKey = getPageKey(); | ||
| pageBuilder | ||
| .page(pageKey) | ||
| .pageLabel("Confirm the eviction details") | ||
| .label(pageKey + "-line-separator", "---") | ||
| .label(pageKey + "-content", CONFIRM_EVICTION_DETAILS_CONTENT); | ||
| } | ||
|
|
||
| @Override | ||
| public String getPageKey() { | ||
| return CcdPage.derivePageKey(this.getClass()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; | ||
|
|
||
| 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.page.CcdPage; | ||
|
|
||
| public class EvictionDatePage implements CcdPageConfiguration, CcdPage { | ||
|
|
||
| @Override | ||
| public void addTo(PageBuilder pageBuilder) { | ||
| String pageKey = getPageKey(); | ||
| pageBuilder | ||
| .page(pageKey) | ||
| .pageLabel("The eviction date") | ||
| .label(pageKey + "-line-separator", "---"); | ||
| } | ||
|
|
||
| @Override | ||
| public String getPageKey() { | ||
| return CcdPage.derivePageKey(this.getClass()); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.page.enforcetheorder.confirmeviction; | ||
|
|
||
| import lombok.AccessLevel; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
| public class MarkupContent { | ||
|
|
||
| public static String CONFIRM_EVICTION_SUMMARY_WITH_DATES = | ||
| """ | ||
| <h2 class="govuk-heading-m govuk-!-padding-top-1">Confirm the eviction date</h2> | ||
| <p class="govuk-body govuk-!-padding-bottom-2"> | ||
| The bailiff has given you an eviction date of %s. | ||
| They need you to confirm if you are available on this date. | ||
| </p> | ||
| <p class="govuk-body govuk-!-padding-bottom-2"> | ||
| You must confirm the eviction details before %s. | ||
| If you try to confirm the eviction after this | ||
| date, the bailiff will cancel your eviction. | ||
| They will also ask you to confirm if the defendants | ||
| (the person or people being evicted) pose any risk to the | ||
| bailiff. | ||
| The bailiff needs this information to carry out the eviction | ||
| safely. | ||
| </p> | ||
| <p class="govuk-body"> | ||
| To confirm the eviction date, select ‘Confirm the eviction | ||
| date’ from the dropdown menu. | ||
| </p> | ||
| """; | ||
|
|
||
| public static String CONFIRM_EVICTION_SUMMARY_NO_DATES = | ||
| """ | ||
| <h2 class="govuk-heading-m govuk-!-padding-top-1">You cannot enforce the order at the moment</h2> | ||
| <p class="govuk-body govuk-!-padding-bottom-2"> | ||
| You cannot enforce the order at the moment (use a bailiff to evict someone). | ||
| </p> | ||
| <p class="govuk-body govuk-!-font-weight-bold govuk-!-padding-bottom-2"> How to find out why you cannot | ||
| enforce the order | ||
| </p> | ||
| <p class="govuk-body govuk-!-margin-bottom-0">To find out why you cannot enforce the order, you can:</p> | ||
| <ul class="govuk-list govuk-list--bullet"> | ||
| <li class="govuk-!-font-size-19">check the tab: ‘Case file view’ (you should see an order from the court, | ||
| explaining why you cannot enforce), or</li> | ||
| <li class="govuk-!-font-size-19"> | ||
| <a href="https://www.gov.uk/find-court-tribunal" | ||
| rel="noreferrer noopener" | ||
| target="_blank" class="govuk-link"> | ||
| contact your local court.</a> You will need to tell them your case number | ||
| (you can find this at the top of this page). If you do not know the name of your local court, select the | ||
| ‘Money’ category and then the ‘Housing’ category to find it.</li> | ||
| </ul> | ||
| """; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,9 @@ | |
| import org.springframework.data.jpa.repository.JpaRepository; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.enforcetheorder.EnforcementOrderEntity; | ||
|
|
||
| import java.util.Optional; | ||
| import java.util.UUID; | ||
|
|
||
| public interface EnforcementOrderRepository extends JpaRepository<EnforcementOrderEntity, UUID> { | ||
|
|
||
| Optional<EnforcementOrderEntity> findByClaimId(UUID claimId); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't need this if EnforcementOrderService is used to retrieve the Enforcement order.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah actually it is used earlier in the process. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.util; | ||
|
|
||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import java.time.Instant; | ||
| import java.time.ZoneId; | ||
| import java.time.format.DateTimeFormatter; | ||
| import java.util.Locale; | ||
|
|
||
| @Component | ||
| public class DateUtil { | ||
|
|
||
| public String formatDate(Instant instant) { | ||
| DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("EEEE, d MMMM yyyy", Locale.UK); | ||
| return instant.atZone(ZoneId.of("UTC")).format(outputFormatter); | ||
| } | ||
|
|
||
| public String minusHoursFormatted(Instant instant, int hours) { | ||
| DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("d MMMM yyyy", Locale.UK); | ||
| return instant.atZone(ZoneId.of("UTC")).minusHours(hours).format(outputFormatter); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ALTER TABLE enf_case | ||
| ADD COLUMN bailiff_date timestamp with time zone; | ||
guygrewal77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use EnforcementOrderService.retrieveEnforcementOrder() to retrieve by case_reference and enforcement type as the eviction would follow from Warrant of Possession.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with the other comment this is where the sticking point is at the moment. This is coded up to the current 'knowledge' and there are changes on route.
I can not use that method suggested as it requires the SelectEnforcementType. If I overload the method within there ... then I am doing the same as what I am doing here in the EnforcementOrderMediator. The EnforcementOrderMediator purpose is from this point in the journey.
The sticking point is we do not know which the Confirm Eviction is against.
There can be multiple Eviction Orders against an Claim and from that multiple types of Evictions. In reality it will probably not be many but currently there is no link from the Confirm to the specific eviction the confirm is against.
With the de-prioritising of Enforcement and the unknown elements this is as close as we can get at the moment.