Skip to content

Commit

Permalink
Merge pull request #1064 from hmrc/BST-111613
Browse files Browse the repository at this point in the history
BST-111613 Max of rentalIncome updated
  • Loading branch information
tumakha authored Nov 1, 2024
2 parents df313db + 4286bf4 commit cb1e852
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 26 deletions.
17 changes: 10 additions & 7 deletions app/controllers/MaxOfLettingsReachedController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,32 +145,32 @@ 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 =>
controllers.aboutfranchisesorlettings.routes.AddAnotherCateringOperationController
.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 _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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] =
Expand Down
35 changes: 28 additions & 7 deletions app/views/maxOfLettingsReached.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.link")

}
}

@sectionContent = @{
source match {
case "rentalIncome" => messages("maxOf5Lettings.rentalIncome.content")
case "franchiseCatering" =>
forType match {
case FOR6010 | FOR6011 => messages("maxOf5Lettings.businessOrFranchise.content")
Expand All @@ -62,6 +82,9 @@
case _ => messages("maxOf5Lettings.content")
}
}



@forType = @{request.sessionData.forType}


Expand All @@ -83,17 +106,15 @@
name = "maxOfLettings",
items = Seq(
CheckboxItem(
content = Text(messages("maxOf5Lettings.confirm")),
content = Text(confirm),
value = "true",
checked = form("maxOfLettings").value.contains("true"),
)
)
).withFormField(form("maxOfLettings"))
)

<p class="govuk-body">
<a href="@backLink" class="govuk-link">@messages("maxOf5Lettings.link")</a>
</p>
<p class="govuk-body"><a href="@backLink" class="govuk-link">@link</a></p>

<br>
<br>
Expand Down
6 changes: 5 additions & 1 deletion conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion conf/messages.cy
Original file line number Diff line number Diff line change
Expand Up @@ -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
#################################
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/controllers/MaxOfLettingsReachedControllerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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*)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}

Expand Down

0 comments on commit cb1e852

Please sign in to comment.