3636import uk .gov .hmcts .reform .pcs .ccd .domain .tabs .details .DemotionOfTenancyTabDetails ;
3737import uk .gov .hmcts .reform .pcs .ccd .domain .tabs .details .NoticeTabDetails ;
3838import uk .gov .hmcts .reform .pcs .ccd .domain .tabs .details .ProhibitedConductStandardContractTabDetails ;
39+ import uk .gov .hmcts .reform .pcs .ccd .domain .tabs .details .RequiredDocumentsTabDetails ;
3940import uk .gov .hmcts .reform .pcs .ccd .domain .tabs .details .SuspensionOfRightToBuyTabDetails ;
4041import uk .gov .hmcts .reform .pcs .ccd .domain .tabs .details .TenancyLicenceTabDetails ;
4142import 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 (
0 commit comments