Skip to content

Commit 5a0d604

Browse files
gmmagruderguygrewal77srinijg
authored
HDPI-7091: remove duplicate documents in case file view (#1994)
Co-authored-by: guygrewal77 <guygrewal7@gmail.com> Co-authored-by: guygrewal77 <163517291+guygrewal77@users.noreply.github.com> Co-authored-by: srinijg <srinivasan.joghee@hmcts.net>
1 parent cd78e89 commit 5a0d604

13 files changed

Lines changed: 591 additions & 123 deletions

src/main/java/uk/gov/hmcts/reform/pcs/ccd/CaseType.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private void buildCaseNotesTab(ConfigBuilder<PCSCase, State, AccessProfile> buil
183183
private void buildCasePartiesTab(ConfigBuilder<PCSCase, State, AccessProfile> builder) {
184184
builder.tab("caseParties", "Case Parties")
185185
.forRoles(PARTY_VISIBLE_TAB_ROLES)
186-
.label("Case Parties", null, "# Case Parties")
186+
.label("Case parties", null, "# Case Parties")
187187
.field("casePartiesTab_ClaimantDetails")
188188
.field("casePartiesTab_DefendantOneDetails")
189189
.field("casePartiesTab_DefendantsDetails");
@@ -243,19 +243,19 @@ private void buildCaseDetailsTab(ConfigBuilder<PCSCase, State, AccessProfile> bu
243243
.field("detailsTab_AntisocialAndConductDetails")
244244
.field("detailsTab_ApplicationsDetails")
245245
.label(
246-
"Claimant Details",
246+
"Claimant details",
247247
"detailsTab_ClaimantInformation!=\"\"",
248-
"## Claimant Details"
248+
"## Claimant details"
249249
)
250250
.field("detailsTab_ClaimantInformation")
251251
.field("detailsTab_ClaimantAddress")
252252
.field("detailsTab_ClaimantContactDetails")
253253
.field("detailsTab_ClaimantRegistrationAndLicensingDetails")
254254
.field("detailsTab_ClaimantCircumstances")
255255
.label(
256-
"Defendant Details",
256+
"Defendant details",
257257
"detailsTab_DefendantInformationDetails!=\"\"",
258-
"## Defendant Details"
258+
"## Defendant details"
259259
)
260260
.field("detailsTab_DefendantInformationDetails")
261261
.field("detailsTab_AdditionalDefendants")

src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseDetailsTabView.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.DemotionOfTenancyTabDetails;
3737
import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.NoticeTabDetails;
3838
import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.ProhibitedConductStandardContractTabDetails;
39+
import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.RequiredDocumentsTabDetails;
3940
import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.SuspensionOfRightToBuyTabDetails;
4041
import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.TenancyLicenceTabDetails;
4142
import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.UnderlesseeOrMortgageInformationTabDetails;
@@ -87,14 +88,14 @@ public class CaseDetailsTabView {
8788
private final RequiredDocumentsTabDetailsBuilder requiredDocumentsTabDetailsBuilder;
8889
private final NoticeDetailsBuilder noticeDetailsBuilder;
8990

90-
public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) {
91+
public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase, boolean isSubmitted) {
9192
ClaimTabDetails claimTabDetails = buildClaimTabDetails(pcsCase);
9293
GroundsForPossessionTabDetails groundsForPossessionTabDetails = buildGroundsForPossessionTabDetails(pcsCase);
93-
TenancyLicenceTabDetails tenancyLicenceTabDetails = buildTenancyLicenceTabDetails(pcsCase);
94-
NoticeTabDetails noticeTabDetails = noticeDetailsBuilder.buildNoticeTabDetails(pcsCase);
94+
TenancyLicenceTabDetails tenancyLicenceTabDetails = buildTenancyLicenceTabDetails(pcsCase, isSubmitted);
95+
NoticeTabDetails noticeTabDetails = noticeDetailsBuilder.buildNoticeTabDetails(pcsCase, isSubmitted);
9596
ActionsTakenTabDetails actionsTakenTabDetails = buildActionsTakenTabDetails(pcsCase);
9697
RentArrearsTabDetails rentArrearsTabDetails =
97-
rentArrearsTabDetailsBuilder.buildDetailedRentArrearsTabDetails(pcsCase);
98+
rentArrearsTabDetailsBuilder.buildDetailedRentArrearsTabDetails(pcsCase, isSubmitted);
9899
ReasonsForPossessionTabDetails reasonsForPossessionTabDetails =
99100
reasonsForPossessionTabDetailsBuilder.buildDetailsReasonsForPossession(pcsCase);
100101
ApplicationsTabDetails applicationsTabDetails = buildApplicationsTabDetails(pcsCase);
@@ -108,10 +109,12 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) {
108109
buildSuspensionOfRightToBuyTabDetails(pcsCase);
109110
String dateSubmitted = formatSubmittedDate(pcsCase.getDateSubmitted());
110111
OccupationContractOrLicenceTabDetails occupationContractLicenceTabDetails =
111-
buildOccupationContractLicenceTabDetails(pcsCase);
112+
buildOccupationContractLicenceTabDetails(pcsCase, isSubmitted);
112113
AntisocialAndConductTabDetails antisocialAndConductTabDetails = buildAntisocialAndConductTabDetails(pcsCase);
113114
ProhibitedConductStandardContractTabDetails prohibitedConductStandardContractTabDetails =
114115
buildProhibitedConductStandardContractTabDetails(pcsCase);
116+
RequiredDocumentsTabDetails requiredDocumentsTabDetails =
117+
requiredDocumentsTabDetailsBuilder.buildRequiredDocumentsTabDetails(pcsCase, isSubmitted);
115118

116119
CaseDetailsTab caseDetailsTab = CaseDetailsTab.builder()
117120
.claimDetails(claimTabDetails)
@@ -132,7 +135,7 @@ public CaseDetailsTab buildCaseDetailsTab(PCSCase pcsCase) {
132135
.occupationContractLicenceDetails(occupationContractLicenceTabDetails)
133136
.antisocialAndConductDetails(antisocialAndConductTabDetails)
134137
.prohibitedConductStandardContractDetails(prohibitedConductStandardContractTabDetails)
135-
.requiredDocumentsDetails(requiredDocumentsTabDetailsBuilder.buildRequiredDocumentsTabDetails(pcsCase))
138+
.requiredDocumentsDetails(requiredDocumentsTabDetails)
136139
.build();
137140

138141
if (claimantInformationTabDetails != null) {
@@ -212,7 +215,7 @@ private GroundsForPossessionTabDetails buildGroundsForPossessionTabDetails(PCSCa
212215
.build();
213216
}
214217

215-
private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase) {
218+
private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase, boolean isSubmitted) {
216219
if (pcsCase.getLegislativeCountry() != LegislativeCountry.ENGLAND) {
217220
return null;
218221
}
@@ -229,6 +232,11 @@ private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase)
229232
TenancyLicenceType tenancyType = tenancyLicenceDetails.getTypeOfTenancyLicence();
230233
LocalDate tenancyDate = tenancyLicenceDetails.getTenancyLicenceDate();
231234
VerticalYesNo hasTenancyLicence = tenancyLicenceDetails.getHasCopyOfTenancyLicence();
235+
List<ListValue<Document>> documents = tenancyLicenceDetails.getTenancyLicenceDocuments();
236+
237+
if (isSubmitted) {
238+
tenancyLicenceDetails.setTenancyLicenceDocuments(null);
239+
}
232240

233241
return TenancyLicenceTabDetails.builder()
234242
.typeOfTenancyLicence(tenancyType != null ? tenancyType.getLabel() : NO_ANSWER)
@@ -237,7 +245,7 @@ private TenancyLicenceTabDetails buildTenancyLicenceTabDetails(PCSCase pcsCase)
237245
)
238246
.tenancyLicenceDate(tenancyDate != null ? tenancyDate.format(DATE_FORMATTER) : NO_ANSWER)
239247
.hasCopyOfTenancyLicence(hasTenancyLicence != null ? hasTenancyLicence.getLabel() : NO_ANSWER)
240-
.tenancyLicenceDocuments(tenancyLicenceDetails.getTenancyLicenceDocuments())
248+
.tenancyLicenceDocuments(documents)
241249
.reasonsForNoTenancyLicenceDocuments(tenancyLicenceDetails.getReasonsForNoTenancyLicenceDocuments())
242250
.build();
243251
}
@@ -486,7 +494,10 @@ private SuspensionOfRightToBuyTabDetails buildSuspensionOfRightToBuyTabDetails(P
486494
.build();
487495
}
488496

489-
private OccupationContractOrLicenceTabDetails buildOccupationContractLicenceTabDetails(PCSCase pcsCase) {
497+
private OccupationContractOrLicenceTabDetails buildOccupationContractLicenceTabDetails(
498+
PCSCase pcsCase,
499+
boolean isSubmitted
500+
) {
490501
if (pcsCase.getLegislativeCountry() != LegislativeCountry.WALES) {
491502
return null;
492503
}
@@ -504,6 +515,10 @@ private OccupationContractOrLicenceTabDetails buildOccupationContractLicenceTabD
504515
LocalDate startDate = occupationLicenceDetailsWales.getLicenceStartDate();
505516
List<ListValue<Document>> documents = occupationLicenceDetailsWales.getLicenceDocuments();
506517

518+
if (isSubmitted) {
519+
occupationLicenceDetailsWales.setLicenceDocuments(null);
520+
}
521+
507522
return OccupationContractOrLicenceTabDetails.builder()
508523
.agreementType(agreementType != null ? agreementType.getLabel() : NO_ANSWER)
509524
.agreementTypeDescription(

src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/CaseTabView.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ public class CaseTabView {
4343
private final CaseDetailsTabView caseDetailsTabView;
4444

4545
public void setCaseTabFields(PCSCase pcsCase) {
46+
boolean isSubmitted = pcsCase.getDateSubmitted() != null;
4647
CasePartiesTab casePartiesTab = buildCasePartiesTab(pcsCase);
4748
SummaryTab summaryTab = caseSummaryTabView.buildSummaryTab(pcsCase);
48-
CaseDetailsTab detailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase);
49+
CaseDetailsTab detailsTab = caseDetailsTabView.buildCaseDetailsTab(pcsCase, isSubmitted);
4950
pcsCase.setCasePartiesTab(casePartiesTab);
5051
pcsCase.setSummaryTab(summaryTab);
5152
pcsCase.setCaseDetailsTab(detailsTab);

src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/DocumentsView.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ private List<ListValue<Document>> mapAndWrapDocuments(PcsCaseEntity pcsCaseEntit
4040

4141
return pcsCaseEntity.getDocuments().stream()
4242
.filter(documentEntity -> this.isDocumentVisibleToUser(documentEntity, currentUserId))
43+
.filter(this::isNotInCaseDetailsTab)
4344
.map(entity -> ListValue.<Document>builder()
4445
.id(entity.getId().toString())
4546
.value(Document.builder()
@@ -83,4 +84,25 @@ public static boolean isDescriptionEmpty(DocumentEntity documentEntity) {
8384
return ObjectUtils.isEmpty(documentEntity.getDescription())
8485
|| documentEntity.getDescription().trim().isEmpty();
8586
}
87+
88+
private boolean isNotInCaseDetailsTab(DocumentEntity documentEntity) {
89+
List<DocumentType> caseDetailsDocuments = List.of(
90+
DocumentType.TENANCY_AGREEMENT,
91+
DocumentType.POSSESSION_NOTICE,
92+
DocumentType.RENT_STATEMENT,
93+
DocumentType.ENERGY_PERFORMANCE_CERTIFICATE,
94+
DocumentType.EICR_REPORT,
95+
DocumentType.GAS_SAFETY_CERTIFICATE,
96+
DocumentType.OCCUPATION_LICENCE
97+
);
98+
99+
DocumentType type = documentEntity.getType();
100+
if (type == null || !caseDetailsDocuments.contains(type)) {
101+
return true;
102+
}
103+
104+
// Is not an additional document
105+
return !isDescriptionEmpty(documentEntity);
106+
}
107+
86108
}

src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/NoticeDetailsBuilder.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package uk.gov.hmcts.reform.pcs.ccd.view.builder;
22

33
import org.springframework.stereotype.Component;
4+
import uk.gov.hmcts.ccd.sdk.type.Document;
5+
import uk.gov.hmcts.ccd.sdk.type.ListValue;
46
import uk.gov.hmcts.ccd.sdk.type.YesOrNo;
57
import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServedDetails;
68
import uk.gov.hmcts.reform.pcs.ccd.domain.NoticeServiceMethod;
@@ -11,6 +13,7 @@
1113

1214
import java.time.LocalDate;
1315
import java.time.LocalDateTime;
16+
import java.util.List;
1417

1518
import static uk.gov.hmcts.reform.pcs.ccd.view.CaseDetailsTabUtil.DATE_FORMATTER;
1619
import static uk.gov.hmcts.reform.pcs.ccd.view.CaseDetailsTabUtil.NO_ANSWER;
@@ -19,15 +22,15 @@
1922
@Component
2023
public class NoticeDetailsBuilder {
2124

22-
public NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase) {
25+
public NoticeTabDetails buildNoticeTabDetails(PCSCase pcsCase, boolean isSubmitted) {
2326
if (pcsCase.getLegislativeCountry() == LegislativeCountry.WALES) {
24-
return buildNoticeTabDetailsWales(pcsCase);
27+
return buildNoticeTabDetailsWales(pcsCase, isSubmitted);
2528
}
2629

27-
return buildNoticeTabDetailsEngland(pcsCase);
30+
return buildNoticeTabDetailsEngland(pcsCase, isSubmitted);
2831
}
2932

30-
private NoticeTabDetails buildNoticeTabDetailsEngland(PCSCase pcsCase) {
33+
private NoticeTabDetails buildNoticeTabDetailsEngland(PCSCase pcsCase, boolean isSubmitted) {
3134
if (pcsCase.getNoticeServed() == null) {
3235
return NoticeTabDetails.builder()
3336
.noticeServed(NO_ANSWER)
@@ -44,13 +47,13 @@ private NoticeTabDetails buildNoticeTabDetailsEngland(PCSCase pcsCase) {
4447
.build();
4548

4649
if (noticeServed == YesOrNo.YES) {
47-
populateNoticeDetails(noticeTabDetails, pcsCase.getNoticeServedDetails());
50+
populateNoticeDetails(noticeTabDetails, pcsCase.getNoticeServedDetails(), isSubmitted);
4851
}
4952

5053
return noticeTabDetails;
5154
}
5255

53-
private NoticeTabDetails buildNoticeTabDetailsWales(PCSCase pcsCase) {
56+
private NoticeTabDetails buildNoticeTabDetailsWales(PCSCase pcsCase, boolean isSubmitted) {
5457
WalesNoticeDetails walesNoticeDetails = pcsCase.getWalesNoticeDetails();
5558

5659
if (walesNoticeDetails == null) {
@@ -71,17 +74,25 @@ private NoticeTabDetails buildNoticeTabDetailsWales(PCSCase pcsCase) {
7174
.noticeDate(NO_ANSWER)
7275
.build();
7376

74-
populateNoticeDetails(noticeTabDetails, pcsCase.getNoticeServedDetails());
77+
populateNoticeDetails(noticeTabDetails, pcsCase.getNoticeServedDetails(), isSubmitted);
7578

7679
return noticeTabDetails;
7780
}
7881

79-
private void populateNoticeDetails(NoticeTabDetails noticeTabDetails, NoticeServedDetails noticeServedDetails) {
82+
private void populateNoticeDetails(
83+
NoticeTabDetails noticeTabDetails,
84+
NoticeServedDetails noticeServedDetails,
85+
boolean isSubmitted
86+
) {
8087
if (noticeServedDetails == null || noticeServedDetails.getServiceMethod() == null) {
8188
return;
8289
}
8390

84-
noticeTabDetails.setNoticeDocuments(noticeServedDetails.getDocuments());
91+
List<ListValue<Document>> documents = noticeServedDetails.getDocuments();
92+
if (isSubmitted) {
93+
noticeServedDetails.setDocuments(null);
94+
}
95+
noticeTabDetails.setNoticeDocuments(documents);
8596
noticeTabDetails.setNoticeUploaded(String.valueOf(noticeServedDetails.getAbleToUploadDocument()));
8697
noticeTabDetails.setReasonsForNoNoticeDocument(noticeServedDetails.getUnableToUploadReason());
8798

src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RentArrearsTabDetailsBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private boolean hasCurrentGroundSummariesWithoutRentArrears(PCSCase pcsCase) {
7575
return hasRentArrearsFlag;
7676
}
7777

78-
public RentArrearsTabDetails buildDetailedRentArrearsTabDetails(PCSCase pcsCase) {
78+
public RentArrearsTabDetails buildDetailedRentArrearsTabDetails(PCSCase pcsCase, boolean isSubmitted) {
7979
if (pcsCase.getShowRentSectionPage() != YesOrNo.YES) {
8080
return null;
8181
}
@@ -136,6 +136,9 @@ public RentArrearsTabDetails buildDetailedRentArrearsTabDetails(PCSCase pcsCase)
136136
if (CollectionUtils.isEmpty(documents)) {
137137
rentArrearsTabDetails.setRentStatementPlaceholder(NO_ANSWER);
138138
} else {
139+
if (isSubmitted) {
140+
rentArrears.setStatementDocuments(null);
141+
}
139142
rentArrearsTabDetails.setRentStatement(documents);
140143
}
141144
} else {

src/main/java/uk/gov/hmcts/reform/pcs/ccd/view/builder/RequiredDocumentsTabDetailsBuilder.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
package uk.gov.hmcts.reform.pcs.ccd.view.builder;
22

33
import org.springframework.stereotype.Component;
4+
import uk.gov.hmcts.ccd.sdk.type.Document;
5+
import uk.gov.hmcts.ccd.sdk.type.ListValue;
46
import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase;
57
import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo;
68
import uk.gov.hmcts.reform.pcs.ccd.domain.tabs.details.RequiredDocumentsTabDetails;
79
import uk.gov.hmcts.reform.pcs.ccd.domain.wales.WalesDocuments;
810
import uk.gov.hmcts.reform.pcs.postcodecourt.model.LegislativeCountry;
911

12+
import java.util.List;
13+
1014
@Component
1115
public class RequiredDocumentsTabDetailsBuilder {
1216

1317
private static final String NO_ANSWER = " ";
1418

15-
public RequiredDocumentsTabDetails buildRequiredDocumentsTabDetails(PCSCase pcsCase) {
19+
public RequiredDocumentsTabDetails buildRequiredDocumentsTabDetails(PCSCase pcsCase, boolean isSubmitted) {
1620
WalesDocuments walesDocuments = pcsCase.getRequiredDocumentsWales();
1721
if (pcsCase.getLegislativeCountry() != LegislativeCountry.WALES || walesDocuments == null) {
1822
return null;
@@ -39,25 +43,35 @@ public RequiredDocumentsTabDetails buildRequiredDocumentsTabDetails(PCSCase pcsC
3943
walesDocuments.getNoEpcReason()
4044
);
4145
} else {
42-
requiredDocumentsTabDetails.setEnergyPerformanceCertificates(walesDocuments.getEnergyPerformance());
46+
List<ListValue<Document>> energyPerformance = walesDocuments.getEnergyPerformance();
47+
if (isSubmitted) {
48+
walesDocuments.setEnergyPerformance(null);
49+
}
50+
requiredDocumentsTabDetails.setEnergyPerformanceCertificates(energyPerformance);
4351
}
4452

4553
if (hasGasSafetyReport == VerticalYesNo.NO) {
4654
requiredDocumentsTabDetails.setNoGasSafetyReportReason(
4755
walesDocuments.getNoGasReportReason()
4856
);
4957
} else {
50-
requiredDocumentsTabDetails.setGasSafetyReports(walesDocuments.getGasSafetyReport());
58+
List<ListValue<Document>> gasSafetyReport = walesDocuments.getGasSafetyReport();
59+
if (isSubmitted) {
60+
walesDocuments.setGasSafetyReport(null);
61+
}
62+
requiredDocumentsTabDetails.setGasSafetyReports(gasSafetyReport);
5163
}
5264

5365
if (hasElectricalInstallationConditionReport == VerticalYesNo.NO) {
5466
requiredDocumentsTabDetails.setNoElectricalInstallationConditionReportReason(
5567
walesDocuments.getNoEicrReason()
5668
);
5769
} else {
58-
requiredDocumentsTabDetails.setElectricalInstallationReports(
59-
walesDocuments.getElectricalInstallation()
60-
);
70+
List<ListValue<Document>> electricalInstallation = walesDocuments.getElectricalInstallation();
71+
if (isSubmitted) {
72+
walesDocuments.setElectricalInstallation(null);
73+
}
74+
requiredDocumentsTabDetails.setElectricalInstallationReports(electricalInstallation);
6175
}
6276

6377
return requiredDocumentsTabDetails;

0 commit comments

Comments
 (0)