Skip to content

Commit

Permalink
Merge pull request #353 from hmrc/SASS-9257
Browse files Browse the repository at this point in the history
Rentals & RaR - Adjustments: PIA - Create 'Your Property Income Allow…
  • Loading branch information
cmantzoukashmrc authored Sep 6, 2024
2 parents 530d7fe + bd6d02b commit c83e0aa
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AdjustmentsCheckYourAnswersController @Inject() (
rows = Seq(
BalancingChargeSummary.row(taxYear, request.userAnswers, Rentals),
PrivateUseAdjustmentSummary.row(taxYear, request.userAnswers, Rentals),
PropertyIncomeAllowanceSummary.row(taxYear, request.userAnswers),
PropertyIncomeAllowanceSummary.row(taxYear, request.userAnswers, Rentals),
RenovationAllowanceBalancingChargeSummary.row(taxYear, request.userAnswers, Rentals),
ResidentialFinanceCostSummary.row(taxYear, request.userAnswers, Rentals),
UnusedResidentialFinanceCostSummary.row(taxYear, request.userAnswers)
Expand Down
20 changes: 10 additions & 10 deletions app/controllers/adjustments/PropertyIncomeAllowanceController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package controllers.adjustments
import controllers.actions._
import forms.adjustments.PropertyIncomeAllowanceFormProvider
import models.TotalIncomeUtils.{incomeAndBalancingChargeCombined, maxAllowedPIA}
import models.{Mode, Rentals}
import models.{Mode, PropertyType, Rentals}
import navigation.Navigator
import pages.adjustments.PropertyIncomeAllowancePage
import play.api.i18n.{I18nSupport, MessagesApi}
Expand All @@ -44,36 +44,36 @@ class PropertyIncomeAllowanceController @Inject() (
)(implicit ec: ExecutionContext)
extends FrontendBaseController with I18nSupport {

def onPageLoad(taxYear: Int, mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData) {
def onPageLoad(taxYear: Int, mode: Mode, propertyType: PropertyType): Action[AnyContent] = (identify andThen getData andThen requireData) {
implicit request =>
val combinedAmount = incomeAndBalancingChargeCombined(request.userAnswers, Rentals)
val combinedAmount = incomeAndBalancingChargeCombined(request.userAnswers, propertyType)
val form = formProvider(request.user.isAgentMessageKey, combinedAmount)
val preparedForm = request.userAnswers.get(PropertyIncomeAllowancePage) match {
val preparedForm = request.userAnswers.get(PropertyIncomeAllowancePage(propertyType)) match {
case None => form
case Some(value) => form.fill(value)
}
Ok(view(preparedForm, mode, taxYear, request.user.isAgentMessageKey, maxAllowedPIA(combinedAmount)))
Ok(view(preparedForm, mode, taxYear, request.user.isAgentMessageKey, maxAllowedPIA(combinedAmount), propertyType))
}

def onSubmit(taxYear: Int, mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData).async {
def onSubmit(taxYear: Int, mode: Mode, propertyType: PropertyType): Action[AnyContent] = (identify andThen getData andThen requireData).async {
implicit request =>
val combinedAllowance = incomeAndBalancingChargeCombined(request.userAnswers, Rentals)
val combinedAllowance = incomeAndBalancingChargeCombined(request.userAnswers, propertyType)
val form = formProvider(request.user.isAgentMessageKey, combinedAllowance)
form
.bindFromRequest()
.fold(
formWithErrors =>
Future.successful(
BadRequest(
view(formWithErrors, mode, taxYear, request.user.isAgentMessageKey, maxAllowedPIA(combinedAllowance))
view(formWithErrors, mode, taxYear, request.user.isAgentMessageKey, maxAllowedPIA(combinedAllowance), propertyType)
)
),
value =>
for {
updatedAnswers <- Future.fromTry(request.userAnswers.set(PropertyIncomeAllowancePage, value))
updatedAnswers <- Future.fromTry(request.userAnswers.set(PropertyIncomeAllowancePage(propertyType), value))
_ <- sessionRepository.set(updatedAnswers)
} yield Redirect(
navigator.nextPage(PropertyIncomeAllowancePage, taxYear, mode, request.userAnswers, updatedAnswers)
navigator.nextPage(PropertyIncomeAllowancePage(propertyType), taxYear, mode, request.userAnswers, updatedAnswers)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ object PropertyPeriodSessionRecoveryExtensions {
for {
ua1 <- userAnswers.set(BalancingChargePage(Rentals), adjustments.balancingCharge)
ua2 <- ua1.set(PrivateUseAdjustmentPage(Rentals), adjustments.privateUseAdjustment)
ua3 <- ua2.set(PropertyIncomeAllowancePage, adjustments.propertyIncomeAllowance)
ua3 <- ua2.set(PropertyIncomeAllowancePage(Rentals), adjustments.propertyIncomeAllowance)
ua2 <- ua1.set(PrivateUseAdjustmentPage(Rentals), adjustments.privateUseAdjustment)
ua3 <- ua2.set(PropertyIncomeAllowancePage(Rentals), adjustments.propertyIncomeAllowance)
ua4 <- ua3.set(RenovationAllowanceBalancingChargePage(Rentals), adjustments.renovationAllowanceBalancingCharge)
ua5 <- ua4.set(ResidentialFinanceCostPage(Rentals), adjustments.residentialFinanceCost)
ua6 <- ua5.set(UnusedResidentialFinanceCostPage, adjustments.unusedResidentialFinanceCost)
Expand Down
8 changes: 4 additions & 4 deletions app/navigation/Navigator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ class Navigator @Inject() () {
case PrivateUseAdjustmentPage(Rentals) =>
taxYear => _ => _ => BalancingChargeController.onPageLoad(taxYear, NormalMode, Rentals)
case BalancingChargePage(Rentals) =>
taxYear => _ => _ => PropertyIncomeAllowanceController.onPageLoad(taxYear, NormalMode)
case PropertyIncomeAllowancePage =>
taxYear => _ => _ => PropertyIncomeAllowanceController.onPageLoad(taxYear, NormalMode, Rentals)
case PropertyIncomeAllowancePage(Rentals) =>
taxYear => _ => _ => RenovationAllowanceBalancingChargeController.onPageLoad(taxYear, NormalMode, Rentals)
case RenovationAllowanceBalancingChargePage(Rentals) =>
taxYear => _ => _ => ResidentialFinanceCostController.onPageLoad(taxYear, NormalMode, Rentals)
Expand Down Expand Up @@ -485,7 +485,7 @@ class Navigator @Inject() () {
controllers.rentalsandrentaroom.expenses.routes.RentalsAndRaRExpensesCheckYourAnswersController
.onPageLoad(taxYear)
// Adjustments
case PrivateUseAdjustmentPage(Rentals) | PropertyIncomeAllowancePage | RenovationAllowanceBalancingChargePage(
case PrivateUseAdjustmentPage(Rentals) | PropertyIncomeAllowancePage(Rentals) | RenovationAllowanceBalancingChargePage(
Rentals
) | ResidentialFinanceCostPage(Rentals) | UnusedResidentialFinanceCostPage =>
taxYear => _ => _ => AdjustmentsCheckYourAnswersController.onPageLoad(taxYear)
Expand Down Expand Up @@ -831,7 +831,7 @@ class Navigator @Inject() () {
if current.balancingChargeYesNo == previous.balancingChargeYesNo &&
current.balancingChargeAmount == previous.balancingChargeAmount =>
AdjustmentsCheckYourAnswersController.onPageLoad(taxYear)
case _ => PropertyIncomeAllowanceController.onPageLoad(taxYear, CheckMode)
case _ => PropertyIncomeAllowanceController.onPageLoad(taxYear, CheckMode, Rentals)
}

private def totalIncomeNavigationNormalMode(taxYear: Int, userAnswers: UserAnswers): Call =
Expand Down
6 changes: 3 additions & 3 deletions app/pages/adjustments/PropertyIncomeAllowancePage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

package pages.adjustments

import models.Rentals
import models.{PropertyType, Rentals}
import pages.PageConstants.adjustmentsPath
import pages.QuestionPage
import play.api.libs.json.JsPath

case object PropertyIncomeAllowancePage extends QuestionPage[BigDecimal] {
case class PropertyIncomeAllowancePage(propertyType: PropertyType) extends QuestionPage[BigDecimal] {

override def path: JsPath = JsPath \ adjustmentsPath(Rentals) \ toString
override def path: JsPath = JsPath \ adjustmentsPath(propertyType) \ toString

override def toString: String = "propertyIncomeAllowance"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package viewmodels.checkAnswers.adjustments

import controllers.adjustments.routes
import models.{CheckMode, UserAnswers}
import models.{CheckMode, PropertyType, UserAnswers}
import pages.adjustments.PropertyIncomeAllowancePage
import play.api.i18n.Messages
import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow
Expand All @@ -27,15 +27,15 @@ import viewmodels.implicits._

object PropertyIncomeAllowanceSummary {

def row(taxYear: Int, answers: UserAnswers)(implicit messages: Messages): Option[SummaryListRow] =
answers.get(PropertyIncomeAllowancePage).map {
def row(taxYear: Int, answers: UserAnswers, propertyType: PropertyType)(implicit messages: Messages): Option[SummaryListRow] =
answers.get(PropertyIncomeAllowancePage(propertyType)).map {
answer =>

SummaryListRowViewModel(
key = KeyViewModel("propertyIncomeAllowance.checkYourAnswersLabel").withCssClass(keyCssClass),
value = ValueViewModel(bigDecimalCurrency(answer)).withCssClass(valueCssClass),
actions = Seq(
ActionItemViewModel("site.change", routes.PropertyIncomeAllowanceController.onPageLoad(taxYear, CheckMode).url)
ActionItemViewModel("site.change", routes.PropertyIncomeAllowanceController.onPageLoad(taxYear, CheckMode, propertyType).url)
.withVisuallyHiddenText(messages("propertyIncomeAllowance.change.hidden"))
)
)
Expand Down
6 changes: 3 additions & 3 deletions app/views/adjustments/PropertyIncomeAllowanceView.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
govukButton: GovukButton
)

@(form: Form[_], mode: Mode, taxYear: Int, individualOrAgent: String, maxPIA: BigDecimal)(implicit request: Request[_], messages: Messages)
@(form: Form[_], mode: Mode, taxYear: Int, individualOrAgent: String, maxPIA: BigDecimal, propertyType: PropertyType)(implicit request: Request[_], messages: Messages)

@layout(pageTitle = title(form, messages(s"propertyIncomeAllowance.title.$individualOrAgent"))) {

<h1 class="govuk-heading-l">@messages(s"propertyIncomeAllowance.heading.$individualOrAgent")</h1>

@formHelper(action = routes.PropertyIncomeAllowanceController.onSubmit(taxYear, mode), Symbol("autoComplete") -> "off") {
@formHelper(action = routes.PropertyIncomeAllowanceController.onSubmit(taxYear, mode, propertyType), Symbol("autoComplete") -> "off") {

@if(form.errors.nonEmpty) {
@govukErrorSummary(ErrorSummaryViewModel(form))
}

<p class="govuk-body">@messages(s"propertyIncomeAllowance.details.content1.$individualOrAgent", maxPIA)</p>
<p class="govuk-body">@messages(s"propertyIncomeAllowance.details.content2.$individualOrAgent")</p>
<p class="govuk-body">@messages(s"propertyIncomeAllowance.details.content2.$individualOrAgent", maxPIA)</p>
<p class="govuk-body">@messages("propertyIncomeAllowance.details.content3")
<a href="@messages("propertyIncomeAllowance.details.content3.link.href")" class="govuk-link" target="_blank" rel="noreferrer noopener">
@messages("propertyIncomeAllowance.details.content3.link.text")
Expand Down
14 changes: 10 additions & 4 deletions conf/app.routes
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ POST /:taxYear/rentals/adjustments/balancing-charge
GET /:taxYear/rentals/adjustments/change-balancing-charge controllers.adjustments.BalancingChargeController.onPageLoad(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = Rentals)
POST /:taxYear/rentals/adjustments/change-balancing-charge controllers.adjustments.BalancingChargeController.onSubmit(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = Rentals)

GET /:taxYear/rentals/adjustments/property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onPageLoad(taxYear: Int, mode: Mode = NormalMode)
POST /:taxYear/rentals/adjustments/property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onSubmit(taxYear: Int, mode: Mode = NormalMode)
GET /:taxYear/rentals/adjustments/change-property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onPageLoad(taxYear: Int, mode: Mode = CheckMode)
POST /:taxYear/rentals/adjustments/change-property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onSubmit(taxYear: Int, mode: Mode = CheckMode)
GET /:taxYear/rentals/adjustments/property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onPageLoad(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = Rentals)
POST /:taxYear/rentals/adjustments/property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onSubmit(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = Rentals)
GET /:taxYear/rentals/adjustments/change-property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onPageLoad(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = Rentals)
POST /:taxYear/rentals/adjustments/change-property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onSubmit(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = Rentals)

GET /:taxYear/rentals/adjustments/renovation-allowance-balancing-charge controllers.adjustments.RenovationAllowanceBalancingChargeController.onPageLoad(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = Rentals)
POST /:taxYear/rentals/adjustments/renovation-allowance-balancing-charge controllers.adjustments.RenovationAllowanceBalancingChargeController.onSubmit(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = Rentals)
Expand Down Expand Up @@ -729,6 +729,11 @@ POST /:taxYear/rentals-rent-a-room/adjustments/residential-finance-cost
GET /:taxYear/rentals-rent-a-room/adjustments/change-residential-finance-cost controllers.adjustments.ResidentialFinanceCostController.onPageLoad(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = RentalsRentARoom)
POST /:taxYear/rentals-rent-a-room/adjustments/change-residential-finance-cost controllers.adjustments.ResidentialFinanceCostController.onSubmit(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = RentalsRentARoom)

GET /:taxYear/rentals-rent-a-room/adjustments/property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onPageLoad(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = RentalsRentARoom)
POST /:taxYear/rentals-rent-a-room/adjustments/property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onSubmit(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = RentalsRentARoom)
GET /:taxYear/rentals-rent-a-room/adjustments/change-property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onPageLoad(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = RentalsRentARoom)
POST /:taxYear/rentals-rent-a-room/adjustments/change-property-income-allowance controllers.adjustments.PropertyIncomeAllowanceController.onSubmit(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = RentalsRentARoom)

GET /:taxYear/rentals-rent-a-room/adjustments/balancing-charge controllers.adjustments.BalancingChargeController.onPageLoad(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = RentalsRentARoom)
POST /:taxYear/rentals-rent-a-room/adjustments/balancing-charge controllers.adjustments.BalancingChargeController.onSubmit(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = RentalsRentARoom)
GET /:taxYear/rentals-rent-a-room/adjustments/change-balancing-charge controllers.adjustments.BalancingChargeController.onPageLoad(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = RentalsRentARoom)
Expand All @@ -738,3 +743,4 @@ GET /:taxYear/rentals-rent-a-room/adjustments/private-use-adjustment
POST /:taxYear/rentals-rent-a-room/adjustments/private-use-adjustment controllers.adjustments.PrivateUseAdjustmentController.onSubmit(taxYear: Int, mode: Mode = NormalMode, propertyType: PropertyType = RentalsRentARoom)
GET /:taxYear/rentals-rent-a-room/adjustments/change-private-use-adjustment controllers.adjustments.PrivateUseAdjustmentController.onPageLoad(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = RentalsRentARoom)
POST /:taxYear/rentals-rent-a-room/adjustments/change-private-use-adjustment controllers.adjustments.PrivateUseAdjustmentController.onSubmit(taxYear: Int, mode: Mode = CheckMode, propertyType: PropertyType = RentalsRentARoom)

20 changes: 10 additions & 10 deletions conf/messages.cy
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,16 @@ unusedResidentialFinanceCost.input.legend = Faint o gostau preswyl sydd heb eu d
unusedResidentialFinanceCost.checkYourAnswersLabel = Costau ariannol preswyl sydd heb eu defnyddio a ddygwyd ymlaen
unusedResidentialFinanceCost.change.hidden = Costau ariannol preswyl sydd heb eu defnyddio a ddygwyd ymlaen

propertyIncomeAllowance.title.individual = Faint o Lwfans Incwm o Eiddo (PIA) hoffech hawlio?
propertyIncomeAllowance.title.agent = Faint o Lwfans Incwm o Eiddo (PIA) hoffai eich cleient hawlio?
propertyIncomeAllowance.heading.individual = Faint o Lwfans Incwm o Eiddo (PIA) hoffech hawlio?
propertyIncomeAllowance.heading.agent = Faint o Lwfans Incwm o Eiddo (PIA) hoffai eich cleient hawlio?
propertyIncomeAllowance.input.heading.individual = Nodwch eich cyfran chi o’r PIA ar gyfer yr eiddo hwn
propertyIncomeAllowance.input.heading.agent = Nodwch gyfran eich cleient o’r PIA ar gyfer yr eiddo hwn
propertyIncomeAllowance.details.content1.individual = Gallwch hawlio hyd at o lwfans incwm o eiddo ar draws eich holl eiddo. Os ydych yn berchen ar eiddo ar y cyd â rhywun arall, gall y ddau ohonoch hawlio’r lwfans.
propertyIncomeAllowance.details.content1.agent = Gall eich cleient hawlio’r holl lwfans incwm o eiddo hyd at (Income plus balancing charge) ar draws pob un o’i eiddo. Os yw’n berchen ar eiddo ar y cyd â rhywun arall, gall y ddau ohonynt hawlio’r lwfans o (Income plus balancing charge).
propertyIncomeAllowance.details.content2.individual = Os bydd angen i chi dalu tâl mantoli, mae’n rhaid i chi ychwanegu’r ffigur hwn at y swm rydych yn ei hawlio ar gyfer lwfans incwm o eiddo. Ni all y ffigur at ei gilydd fynd y tu hwnt.
propertyIncomeAllowance.details.content2.agent = Os oes angen iddo dalu tâl mantoli, mae’n rhaid i chi ychwanegu’r ffigur hwn at y swm rydych yn ei hawlio ar gyfer lwfans incwm o eiddo. Ni all y ffigur at ei gilydd fynd y tu hwnt i gyfanswm o (Income plus balancing charge).
propertyIncomeAllowance.title.individual = *Missing Welsh*
propertyIncomeAllowance.title.agent = *Missing Welsh*
propertyIncomeAllowance.heading.individual = *Missing Welsh*
propertyIncomeAllowance.heading.agent = *Missing Welsh*
propertyIncomeAllowance.input.heading.individual = *Missing Welsh*
propertyIncomeAllowance.input.heading.agent = *Missing Welsh*
propertyIncomeAllowance.details.content1.individual = *Missing Welsh*
propertyIncomeAllowance.details.content1.agent = *Missing Welsh*
propertyIncomeAllowance.details.content2.individual = *Missing Welsh*
propertyIncomeAllowance.details.content2.agent = *Missing Welsh*
propertyIncomeAllowance.details.content3 = Darllenwch ragor am
propertyIncomeAllowance.details.content3.link.text = lwfans incwm o eiddo, ar GOV.UK (yn agor tab newydd)

Expand Down
Loading

0 comments on commit c83e0aa

Please sign in to comment.