From 0eaa542c65c6507f496518b28a0beffd2d53d6f1 Mon Sep 17 00:00:00 2001 From: MJANOWICZ Date: Fri, 1 Nov 2024 12:02:33 +0000 Subject: [PATCH 1/2] BST-111613 Max of rentalIncome updated --- .../MaxOfLettingsReachedController.scala | 17 +++++---- ...rsAboutFranchiseOrLettingsController.scala | 12 +++---- .../RentalIncomeListController.scala | 2 +- .../AboutFranchisesOrLettings.scala | 6 ++-- app/views/maxOfLettingsReached.scala.html | 35 +++++++++++++++---- conf/messages | 6 +++- conf/messages.cy | 13 ++++++- .../MaxOfLettingsReachedControllerSpec.scala | 10 ++++++ .../RentalIncomeListControllerSpec.scala | 2 +- 9 files changed, 77 insertions(+), 26 deletions(-) diff --git a/app/controllers/MaxOfLettingsReachedController.scala b/app/controllers/MaxOfLettingsReachedController.scala index a397f5ec5..1aceebfb1 100644 --- a/app/controllers/MaxOfLettingsReachedController.scala +++ b/app/controllers/MaxOfLettingsReachedController.scala @@ -82,12 +82,14 @@ class MaxOfLettingsReachedController @Inject() ( case Some("franchiseLetting") => updateAboutFranchisesOrLettings(_.copy(currentMaxOfLetting = data)) case Some("lettings") => updateAboutFranchisesOrLettings(_.copy(currentMaxOfLetting = data)) + case Some("rentalIncome") => updateAboutFranchisesOrLettings(_.copy(rentalIncomeMax = Some(data))) + } session .saveOrUpdate(updatedData) .map { _ => src match { - case Some("connection") => + case Some("connection") => connectionNavigator .cyaPageDependsOnSession(updatedData) .filter(_ => connectionNavigator.from == "CYA") @@ -96,12 +98,7 @@ class MaxOfLettingsReachedController @Inject() ( .nextWithoutRedirectToCYA(MaxOfLettingsReachedId, updatedData) .apply(updatedData) ) - case Some("franchiseCatering") => - franchiseNavigator.nextPage(MaxOfLettingsReachedCateringId, updatedData).apply(updatedData) - case Some("franchiseLetting") => - franchiseNavigator.nextPage(MaxOfLettingsReachedCurrentId, updatedData).apply(updatedData) - case Some("lettings") => - franchiseNavigator.nextPage(MaxOfLettingsReachedCurrentId, updatedData).apply(updatedData) + case _ => franchiseNavigator.nextPage(MaxOfLettingsReachedCurrentId, updatedData).apply(updatedData) } } .map(Redirect) @@ -132,6 +129,12 @@ class MaxOfLettingsReachedController @Inject() ( request.sessionData.aboutFranchisesOrLettings.flatMap(_.currentMaxOfLetting), "franchiseLetting" ) + case Some("rentalIncome") => + ( + controllers.aboutfranchisesorlettings.routes.RentalIncomeListController.show(4).url, + request.sessionData.aboutFranchisesOrLettings.flatMap(_.rentalIncomeMax), + "rentalIncome" + ) case Some("lettings") => ( controllers.aboutfranchisesorlettings.routes.AddOrRemoveLettingController.show(9).url, diff --git a/app/controllers/aboutfranchisesorlettings/CheckYourAnswersAboutFranchiseOrLettingsController.scala b/app/controllers/aboutfranchisesorlettings/CheckYourAnswersAboutFranchiseOrLettingsController.scala index 642f9cead..a5c242462 100644 --- a/app/controllers/aboutfranchisesorlettings/CheckYourAnswersAboutFranchiseOrLettingsController.scala +++ b/app/controllers/aboutfranchisesorlettings/CheckYourAnswersAboutFranchiseOrLettingsController.scala @@ -145,20 +145,20 @@ class CheckYourAnswersAboutFranchiseOrLettingsController @Inject() ( } aboutFranchiseOrLettings match { - case AboutFranchisesOrLettings(Some(AnswerYes), Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _) + case AboutFranchisesOrLettings(Some(AnswerYes), Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) if aboutFranchiseOrLettings.lettingSections.nonEmpty => controllers.aboutfranchisesorlettings.routes.AddAnotherLettingOtherPartOfPropertyController .show(getLettingsIndex(session)) .url - case AboutFranchisesOrLettings(Some(AnswerYes), Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case AboutFranchisesOrLettings(Some(AnswerYes), Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => controllers.aboutfranchisesorlettings.routes.LettingOtherPartOfPropertyController.show().url - case AboutFranchisesOrLettings(Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) + case AboutFranchisesOrLettings(Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) if isNoOrNone(aboutFranchiseOrLettings.lettingOtherPartOfProperty) => controllers.aboutfranchisesorlettings.routes.FranchiseOrLettingsTiedToPropertyController.show().url - case AboutFranchisesOrLettings(Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) + case AboutFranchisesOrLettings(Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) if aboutFranchiseOrLettings.cateringConcessionOrFranchise.contains( AnswerYes ) && aboutFranchiseOrLettings.cateringOperationSections.nonEmpty => @@ -166,11 +166,11 @@ class CheckYourAnswersAboutFranchiseOrLettingsController @Inject() ( .show(getCateringsIndex(session)) .url - case AboutFranchisesOrLettings(Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) + case AboutFranchisesOrLettings(Some(AnswerYes), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) if aboutFranchiseOrLettings.cateringConcessionOrFranchise.contains(AnswerYes) => controllers.aboutfranchisesorlettings.routes.ConcessionOrFranchiseController.show().url - case AboutFranchisesOrLettings(Some(AnswerNo), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => + case AboutFranchisesOrLettings(Some(AnswerNo), _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _) => controllers.aboutfranchisesorlettings.routes.FranchiseOrLettingsTiedToPropertyController.show().url case _ => diff --git a/app/controllers/aboutfranchisesorlettings/RentalIncomeListController.scala b/app/controllers/aboutfranchisesorlettings/RentalIncomeListController.scala index 367f37121..78e209778 100644 --- a/app/controllers/aboutfranchisesorlettings/RentalIncomeListController.scala +++ b/app/controllers/aboutfranchisesorlettings/RentalIncomeListController.scala @@ -95,7 +95,7 @@ class RentalIncomeListController @Inject() ( ), answer => if (answer == AnswerYes && numberOfRentalIncomes >= 5 && navigator.from != "CYA") { - Future.successful(Redirect(controllers.routes.MaxOfLettingsReachedController.show(Some("lettings")))) + Future.successful(Redirect(controllers.routes.MaxOfLettingsReachedController.show(Some("rentalIncome")))) } else { rentalIncomeData match { case Some(entries) if entries.isDefinedAt(index) => diff --git a/app/models/submissions/aboutfranchisesorlettings/AboutFranchisesOrLettings.scala b/app/models/submissions/aboutfranchisesorlettings/AboutFranchisesOrLettings.scala index ca4f4184a..ff5f58f65 100644 --- a/app/models/submissions/aboutfranchisesorlettings/AboutFranchisesOrLettings.scala +++ b/app/models/submissions/aboutfranchisesorlettings/AboutFranchisesOrLettings.scala @@ -39,7 +39,8 @@ case class AboutFranchisesOrLettings( cateringOrFranchiseFee: Option[AnswersYesNo] = None, // added for 6030 journey - Feb 2024 lettings: Option[IndexedSeq[LettingPartOfProperty]] = None, // 6020 lettings rentalIncome: Option[IndexedSeq[IncomeRecord]] = None, - rentalIncomeIndex: Int = 0 + rentalIncomeIndex: Int = 0, + rentalIncomeMax: Option[MaxOfLettings] = None ) object AboutFranchisesOrLettings { @@ -60,7 +61,8 @@ object AboutFranchisesOrLettings { (__ \ "cateringOrFranchiseFee").readNullable[AnswersYesNo] and (__ \ "lettings").readNullable[IndexedSeq[LettingPartOfProperty]] and (__ \ "rentalIncome").readNullable[IndexedSeq[IncomeRecord]] and - (__ \ "rentalIncomeIndex").read[Int] + (__ \ "rentalIncomeIndex").read[Int] and + (__ \ "rentalIncomeMax").readNullable[MaxOfLettings] )(AboutFranchisesOrLettings.apply) implicit val format: Format[AboutFranchisesOrLettings] = diff --git a/app/views/maxOfLettingsReached.scala.html b/app/views/maxOfLettingsReached.scala.html index ccc4cf239..1fba54e24 100644 --- a/app/views/maxOfLettingsReached.scala.html +++ b/app/views/maxOfLettingsReached.scala.html @@ -32,13 +32,16 @@ @sectionName = @{ source match { - case "connection" => messages("label.section.connectionToTheProperty") - case "lettings" => messages("label.section.aboutTheLettings") - case _ => messages("label.section.aboutTheFranchiseConcessions") + case "connection" => messages("label.section.connectionToTheProperty") + case "lettings" => messages("label.section.aboutTheLettings") + case "rentalIncome" => messages("label.section.aboutTheConcessionsFranchisesLettings") + case _ => messages("label.section.aboutTheFranchiseConcessions") } } + @sectionHeading = @{ source match { + case "rentalIncome" => messages("maxOf5Lettings.rentalIncome.heading") case "franchiseCatering" => forType match { case FOR6010 | FOR6011 => messages(s"maxOf5Lettings.businessOrFranchise.heading") @@ -50,8 +53,25 @@ } } +@confirm = @{ + source match { + case "rentalIncome" => messages("maxOf5Lettings.rentalIncome.confirm", sectionContent) + case _ => messages("maxOf5Lettings.confirm") + + } +} + +@link = @{ + source match { + case "rentalIncome" => messages("maxOf5Lettings.rentalIncome.link") + case _ => messages("maxOf5Lettings.confirm") + + } +} + @sectionContent = @{ source match { + case "rentalIncome" => messages("maxOf5Lettings.rentalIncome.content") case "franchiseCatering" => forType match { case FOR6010 | FOR6011 => messages("maxOf5Lettings.businessOrFranchise.content") @@ -62,6 +82,9 @@ case _ => messages("maxOf5Lettings.content") } } + + + @forType = @{request.sessionData.forType} @@ -83,7 +106,7 @@ name = "maxOfLettings", items = Seq( CheckboxItem( - content = Text(messages("maxOf5Lettings.confirm")), + content = Text(confirm), value = "true", checked = form("maxOfLettings").value.contains("true"), ) @@ -91,9 +114,7 @@ ).withFormField(form("maxOfLettings")) ) -

- @messages("maxOf5Lettings.link") -

+

@link



diff --git a/conf/messages b/conf/messages index 7ec6d704c..dde0252b9 100644 --- a/conf/messages +++ b/conf/messages @@ -3087,9 +3087,13 @@ maxOf5Lettings.businessOrConcession.heading = You have added the maximum of 5 se maxOf5Lettings.businessOrConcession.content = businesses or concessions maxOf5Lettings.concessionOrFranchise.heading = You have added the maximum of 5 separate concessions or franchises maxOf5Lettings.concessionOrFranchise.content = concessions or franchises -maxOf5Lettings.contact = If you have 6 or more {0} at your property, the VOA will contact you to collect information on the remaining lettings. +maxOf5Lettings.rentalIncome.heading = You have added the maximum of 5 sources of rental income +maxOf5Lettings.rentalIncome.content = sources of rental income +maxOf5Lettings.contact = If you have 6 or more {0}, the VOA will contact you to collect their information. +maxOf5Lettings.rentalIncome.confirm = I confirm that I understand the VOA will contact me regarding the remaining {0} maxOf5Lettings.confirm = I confirm that I understand the VOA will contact me regarding the remaining businesses. maxOf5Lettings.link = Check or update the 5 added businesses +maxOf5Lettings.rentalIncome.link = Check or update the 5 added sources of rental income maxOf5Lettings.error = Please confirm that you understand the VOA will contact you regarding the remaining letters # About franchise or lettings CYA diff --git a/conf/messages.cy b/conf/messages.cy index 5690121f3..7afef75b3 100644 --- a/conf/messages.cy +++ b/conf/messages.cy @@ -2794,6 +2794,12 @@ checkYourAnswersAdditionalInformation.heading = Gwiriwch eich atebion – gwybod label.furtherInformation = Rhagor o wybodaeth neu sylwadau key.additionalInformation = Gwybodaeth ychwanegol +#COMMERCIAL LETTING QUESTION +############################ +commercialLettingQuestion.heading = When did the property first become available for commercial letting? +commercialLettingQuestion.p = If you do not know the exact date provide an estimate +fieldName.commercialLettingQuestion = the {0} when property first become available for commercial letting + #TYPE OF RENEWABLES PLANT ################################# @@ -3006,6 +3012,7 @@ checkYourAnswersNotConnected.subheading2 = Eich manylion cyswllt # MAXIMUM OF 5 LETTINGS ################################## +################################## maxOf5Lettings.heading = You have added the maximum of 5 lettings maxOf5Lettings.content = lettings maxOf5Lettings.businessOrFranchise.heading = You have added the maximum of 5 separate businesses or franchises @@ -3014,9 +3021,13 @@ maxOf5Lettings.businessOrConcession.heading = You have added the maximum of 5 se maxOf5Lettings.businessOrConcession.content = businesses or concessions maxOf5Lettings.concessionOrFranchise.heading = You have added the maximum of 5 separate concessions or franchises maxOf5Lettings.concessionOrFranchise.content = concessions or franchises -maxOf5Lettings.contact = If you have 6 or more {0} at your property, the VOA will contact you to collect information on the remaining lettings. +maxOf5Lettings.rentalIncome.heading = You have added the maximum of 5 sources of rental income +maxOf5Lettings.rentalIncome.content = sources of rental income +maxOf5Lettings.contact = If you have 6 or more {0}, the VOA will contact you to collect their information. +maxOf5Lettings.rentalIncome.confirm = I confirm that I understand the VOA will contact me regarding the remaining {0} maxOf5Lettings.confirm = I confirm that I understand the VOA will contact me regarding the remaining businesses. maxOf5Lettings.link = Check or update the 5 added businesses +maxOf5Lettings.rentalIncome.link = Check or update the 5 added sources of rental income maxOf5Lettings.error = Please confirm that you understand the VOA will contact you regarding the remaining letters # About franchise or lettings CYA diff --git a/test/controllers/MaxOfLettingsReachedControllerSpec.scala b/test/controllers/MaxOfLettingsReachedControllerSpec.scala index 224124b29..97249c717 100644 --- a/test/controllers/MaxOfLettingsReachedControllerSpec.scala +++ b/test/controllers/MaxOfLettingsReachedControllerSpec.scala @@ -98,6 +98,10 @@ class MaxOfLettingsReachedControllerSpec extends TestBaseSpec with MaxOfLettings val result = maxOfLettingsReachedController.show("lettings")(fakeRequest) status(result) shouldBe OK } + "return 200 when no scr parameter equals rentalIncome" in { + val result = maxOfLettingsReachedController.show("rentalIncome")(fakeRequest) + status(result) shouldBe OK + } "return 200 when no scr parameter equals franchiseLetting" in { val result = maxOfLettingsReachedController.show("franchiseLetting")(fakeRequest) status(result) shouldBe OK @@ -132,6 +136,12 @@ class MaxOfLettingsReachedControllerSpec extends TestBaseSpec with MaxOfLettings mockAboutFranchisesOrLettingsNavigator ) + behave like updatingFranchiseOrLettings( + src = "rentalIncome", + maxOfLettingsReachedController, + mockAboutFranchisesOrLettingsNavigator + ) + "throw a BAD_REQUEST if an empty form is submitted" in { val res = maxOfLettingsReachedController.submit(None)( FakeRequest().withFormUrlEncodedBody(Seq.empty*) diff --git a/test/controllers/aboutfranchisesorlettings/RentalIncomeListControllerSpec.scala b/test/controllers/aboutfranchisesorlettings/RentalIncomeListControllerSpec.scala index 8ac549def..ea742845b 100644 --- a/test/controllers/aboutfranchisesorlettings/RentalIncomeListControllerSpec.scala +++ b/test/controllers/aboutfranchisesorlettings/RentalIncomeListControllerSpec.scala @@ -134,7 +134,7 @@ class RentalIncomeListControllerSpec extends TestBaseSpec { status(result) shouldBe SEE_OTHER redirectLocation(result) shouldBe Some( - controllers.routes.MaxOfLettingsReachedController.show(Some("lettings")).url + controllers.routes.MaxOfLettingsReachedController.show(Some("rentalIncome")).url ) } From 4286bf49240adcb5271ad9e314455e086f034cde Mon Sep 17 00:00:00 2001 From: MJANOWICZ Date: Fri, 1 Nov 2024 13:00:52 +0000 Subject: [PATCH 2/2] BST-111613 test case updated --- app/views/maxOfLettingsReached.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/maxOfLettingsReached.scala.html b/app/views/maxOfLettingsReached.scala.html index 1fba54e24..c84b2466a 100644 --- a/app/views/maxOfLettingsReached.scala.html +++ b/app/views/maxOfLettingsReached.scala.html @@ -64,7 +64,7 @@ @link = @{ source match { case "rentalIncome" => messages("maxOf5Lettings.rentalIncome.link") - case _ => messages("maxOf5Lettings.confirm") + case _ => messages("maxOf5Lettings.link") } }