Skip to content

Commit

Permalink
Merge pull request #1100 from hmrc/BST-112376
Browse files Browse the repository at this point in the history
BST-112376 - Added/Updated pay capital sum details page
  • Loading branch information
Stephen-Goddard authored Nov 28, 2024
2 parents 163f740 + f4cc5f2 commit 15a82cf
Show file tree
Hide file tree
Showing 15 changed files with 441 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ class LegalOrPlanningRestrictionsController @Inject() (
case Some(AnswerYes) => aboutYourLeaseOrTenure.routes.CapitalSumDescriptionController.show().url
case _ => aboutYourLeaseOrTenure.routes.PayACapitalSumController.show().url
}
case FOR6048 =>
request.sessionData.aboutLeaseOrAgreementPartTwo
.flatMap(_.payACapitalSumDetails)
.map(_.capitalSumOrPremium) match {
case Some(AnswerYes) => aboutYourLeaseOrTenure.routes.PayACapitalSumAmountDetailsController.show().url
case _ => aboutYourLeaseOrTenure.routes.PayACapitalSumController.show().url
}
case _ => aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show().url
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Copyright 2024 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package controllers.aboutYourLeaseOrTenure

import actions.{SessionRequest, WithSessionRefiner}
import controllers.FORDataCaptureController
import form.aboutYourLeaseOrTenure.PayACapitalSumAmountDetailsForm.payACapitalSumAmountDetailsForm
import form.aboutYourLeaseOrTenure.PayACapitalSumDetailsForm.payACapitalSumDetailsForm
import models.Session
import models.submissions.aboutYourLeaseOrTenure.AboutLeaseOrAgreementPartTwo.updateAboutLeaseOrAgreementPartTwo
import models.submissions.aboutYourLeaseOrTenure.{PayACapitalSumAmountDetails, PayACapitalSumInformationDetails}
import navigation.AboutYourLeaseOrTenureNavigator
import navigation.identifiers.{PayCapitalSumAmountDetailsId, PayCapitalSumDetailsId}
import play.api.Logging
import play.api.i18n.I18nSupport
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents, Request}
import repositories.SessionRepo
import views.html.aboutYourLeaseOrTenure.{payACapitalSumAmountDetails, payACapitalSumDetails}

import javax.inject.{Inject, Named, Singleton}
import scala.concurrent.Future

@Singleton
class PayACapitalSumAmountDetailsController @Inject() (
mcc: MessagesControllerComponents,
navigator: AboutYourLeaseOrTenureNavigator,
payACapitalSumAmountDetailsView: payACapitalSumAmountDetails,
withSessionRefiner: WithSessionRefiner,
@Named("session") val session: SessionRepo
) extends FORDataCaptureController(mcc)
with I18nSupport
with Logging {

def show: Action[AnyContent] = (Action andThen withSessionRefiner).async { implicit request =>
Future.successful(
Ok(
payACapitalSumAmountDetailsView(
request.sessionData.aboutLeaseOrAgreementPartTwo.flatMap(_.payACapitalSumAmountDetails) match {
case Some(data) => payACapitalSumAmountDetailsForm.fill(data)
case _ => payACapitalSumAmountDetailsForm
},
getBackLink(request.sessionData),
request.sessionData.toSummary
)
)
)
}

def submit = (Action andThen withSessionRefiner).async { implicit request =>
continueOrSaveAsDraft[PayACapitalSumAmountDetails](
payACapitalSumAmountDetailsForm,
formWithErrors =>
BadRequest(
payACapitalSumAmountDetailsView(
formWithErrors,
getBackLink(request.sessionData),
request.sessionData.toSummary
)
),
data => {
val updatedData = updateAboutLeaseOrAgreementPartTwo(_.copy(payACapitalSumAmountDetails = Some(data)))
session.saveOrUpdate(updatedData)
Redirect(navigator.nextPage(PayCapitalSumAmountDetailsId, updatedData).apply(updatedData))
}
)
}

private def getBackLink(answers: Session)(implicit request: Request[AnyContent]): String =
navigator.from match {
case "TL" => controllers.routes.TaskListController.show().url + "#pay-a-capital-sum-details"
case _ =>
answers.aboutLeaseOrAgreementPartTwo.flatMap(
_.payACapitalSumDetails.map(_.capitalSumOrPremium.name)
) match {
case Some("yes") =>
controllers.aboutYourLeaseOrTenure.routes.PayACapitalSumController.show().url
case Some("no") => controllers.aboutYourLeaseOrTenure.routes.TenantsAdditionsDisregardedController.show().url
case _ =>
logger.warn(s"Back link for pay capital sum page reached with unknown tenants additions disregarded value")
controllers.routes.TaskListController.show().url
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package form.aboutYourLeaseOrTenure

import form.DateMappings.requiredDateMapping
import form.MappingSupport.currencyMapping
import models.submissions.aboutYourLeaseOrTenure.{PayACapitalSumAmountDetails, PayACapitalSumInformationDetails}
import play.api.data.Form
import play.api.data.Forms.{mapping, optional}
import play.api.i18n.Messages

object PayACapitalSumAmountDetailsForm {
def payACapitalSumAmountDetailsForm(implicit messages: Messages): Form[PayACapitalSumAmountDetails] =
Form(
mapping(
"capitalSumPaidDetails" -> currencyMapping(".capitalSumPaidDetails")
)(PayACapitalSumAmountDetails.apply)(o => Some(o.capitalSumPaidAmountDetails))
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ case class AboutLeaseOrAgreementPartTwo(
tenantsAdditionsDisregardedDetails: Option[TenantsAdditionsDisregardedDetails] = None,
payACapitalSumDetails: Option[PayACapitalSumDetails] = None,
payACapitalSumInformationDetails: Option[PayACapitalSumInformationDetails] = None, // Added Feb 2024 - 6030 Journey
payACapitalSumAmountDetails: Option[PayACapitalSumAmountDetails] = None, // Added Nov 2024 - 6048 Journey
capitalSumDescription: Option[CapitalSumDescription] = None, // 6020
paymentWhenLeaseIsGrantedDetails: Option[PaymentWhenLeaseIsGrantedDetails] = None,
tenancyLeaseAgreementExpire: Option[TenancyLeaseAgreementExpire] = None,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2023 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package models.submissions.aboutYourLeaseOrTenure

import play.api.libs.json.{Json, OFormat}

import java.time.LocalDate

case class PayACapitalSumAmountDetails(
capitalSumPaidAmountDetails: BigDecimal
)

object PayACapitalSumAmountDetails {
implicit val format: OFormat[PayACapitalSumAmountDetails] = Json.format
}
25 changes: 22 additions & 3 deletions app/navigation/AboutYourLeaseOrTenureNavigator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,31 @@ class AboutYourLeaseOrTenureNavigator @Inject() (audit: Audit) extends Navigator
case FOR6030 => controllers.aboutYourLeaseOrTenure.routes.PayACapitalSumDetailsController.show()
case FOR6045 | FOR6046 =>
controllers.aboutYourLeaseOrTenure.routes.CapitalSumDescriptionController.show()
case FOR6048 => controllers.aboutYourLeaseOrTenure.routes.PayACapitalSumAmountDetailsController.show()
case _ => controllers.aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show()
}
case _ =>
answers.forType match {
case FOR6020 | FOR6045 | FOR6046 =>
case FOR6020 | FOR6045 | FOR6046 | FOR6048 =>
controllers.aboutYourLeaseOrTenure.routes.LegalOrPlanningRestrictionsController.show()
case _ => controllers.aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show()
}
}

private def payCapitalSumDetailsRouting: Session => Call = answers =>
answers.aboutLeaseOrAgreementPartTwo.flatMap(
_.payACapitalSumDetails.map(_.capitalSumOrPremium.name)
) match {
case Some("yes") =>
answers.forType match {
case FOR6048 => controllers.aboutYourLeaseOrTenure.routes.LegalOrPlanningRestrictionsController.show()
case _ => aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show()
}
case _ =>
answers.forType match {
case FOR6048 =>
controllers.aboutYourLeaseOrTenure.routes.LegalOrPlanningRestrictionsController.show()
case _ => controllers.aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show()
case _ => controllers.aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show()
}
}

Expand Down Expand Up @@ -577,7 +595,8 @@ class AboutYourLeaseOrTenureNavigator @Inject() (audit: Audit) extends Navigator
IsGivenRentFreePeriodId -> isGivenRentFreePeriodIdRouting,
RentFreePeriodDetailsId -> (_ => aboutYourLeaseOrTenure.routes.PayACapitalSumController.show()),
PayCapitalSumId -> payCapitalSumRouting,
PayCapitalSumDetailsId -> (_ => aboutYourLeaseOrTenure.routes.PaymentWhenLeaseIsGrantedController.show()),
PayCapitalSumAmountDetailsId -> payCapitalSumDetailsRouting,
PayCapitalSumDetailsId -> payCapitalSumDetailsRouting,
PayWhenLeaseGrantedId -> (_ => aboutYourLeaseOrTenure.routes.LegalOrPlanningRestrictionsController.show()),
LegalOrPlanningRestrictionId -> legalOrPlanningRestrictionRouting,
LegalOrPlanningRestrictionDetailsId -> (_ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ case object TenantsAdditionsDisregardedDetailsId extends Identifier {

case object PayCapitalSumId extends Identifier { override def toString: String = "payCapitalSumPage" }
case object PayCapitalSumDetailsId extends Identifier { override def toString: String = "payCapitalSumDetailsPage" }
case object PayCapitalSumAmountDetailsId extends Identifier {
override def toString: String = "payCapitalSumAmountDetailsPage"
}

case object PayWhenLeaseGrantedId extends Identifier { override def toString: String = "payWhenLeaseGrantedPage" }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
@*
* Copyright 2024 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*@

@import models.ForType.*
@import models.submissions.aboutYourLeaseOrTenure.PayACapitalSumInformationDetails
@import uk.gov.hmrc.govukfrontend.views.viewmodels.content.Text
@import uk.gov.hmrc.govukfrontend.views.html.components.implicits._
@import uk.gov.hmrc.govukfrontend.views.html.components.GovukButton
@import uk.gov.hmrc.govukfrontend.views.html.components.FormWithCSRF
@import uk.gov.hmrc.hmrcfrontend.views.Aliases.CurrencyInput
@import uk.gov.hmrc.govukfrontend.views.html.components.GovukDateInput
@import uk.gov.hmrc.govukfrontend.views.Aliases.Label
@import uk.gov.hmrc.hmrcfrontend.views.html.components.HmrcCurrencyInput
@import uk.gov.hmrc.govukfrontend.views.Aliases.Hint
@import actions.SessionRequest
@import models.submissions.aboutYourLeaseOrTenure.PayACapitalSumAmountDetails

@import models.pages.Summary

@this(layout: Layout,
govukButton: GovukButton,
govukDateInput: GovukDateInput,
hmrcCurrencyInput : HmrcCurrencyInput,
formWithCSRF: FormWithCSRF
)


@(theForm: Form[PayACapitalSumAmountDetails], backLink: String, summary: Summary)(implicit request: SessionRequest[?], messages: Messages)


@layout(
pageHeading = messages("capitalSumPaidDetails6048.heading"),
showH1 = false,
showSection = true,
summary = Some(summary),
sectionName = messages("label.section.aboutYourLeaseOrTenure"),
backLinkUrl = backLink,
theForm = theForm
) {


@formWithCSRF(action = controllers.aboutYourLeaseOrTenure.routes.PayACapitalSumAmountDetailsController.submit()) {

@hmrcCurrencyInput(
CurrencyInput(
id = "capitalSumPaidDetails",
name = "capitalSumPaidDetails",
value = theForm("capitalSumPaidDetails").value,
classes = "govuk-input--width-10",
label = Label(
content = Text(messages("capitalSumPaidDetails6048.heading")),
classes = "govuk-label--l govuk-fieldset__legend govuk-fieldset__legend--l",
isPageHeading = true
),
autocomplete = Some("off"),
errorMessage = theForm.errors.asTextErrorMessageForField("capitalSumPaidDetails"),
hint = Some(Hint(content = Text(messages("hint.currentAnnualRent"))))

)
)

@includes.continueSaveAsDraftButtons(govukButton)


}
}



3 changes: 3 additions & 0 deletions conf/leaseOrTenure.routes
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ POST /pay-a-capital-sum controll
GET /pay-a-capital-sum-details controllers.aboutYourLeaseOrTenure.PayACapitalSumDetailsController.show()
POST /pay-a-capital-sum-details controllers.aboutYourLeaseOrTenure.PayACapitalSumDetailsController.submit()

GET /pay-a-capital-sum-amount-details controllers.aboutYourLeaseOrTenure.PayACapitalSumAmountDetailsController.show()
POST /pay-a-capital-sum-amount-details controllers.aboutYourLeaseOrTenure.PayACapitalSumAmountDetailsController.submit()

GET /receive-payment-when-lease-granted controllers.aboutYourLeaseOrTenure.PaymentWhenLeaseIsGrantedController.show()
POST /receive-payment-when-lease-granted controllers.aboutYourLeaseOrTenure.PaymentWhenLeaseIsGrantedController.submit()

Expand Down
1 change: 1 addition & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@ error.payACapitalSum.missing = Select yes if you paid a capital sum or premium f
# PAY A CAPITAL SUM DETAILS
##################
capitalSumPaidDetails.heading = Provide details of the capital sum paid
capitalSumPaidDetails6048.heading = What was the capital sum or premium paid for the lease or agreement?
capitalSumPaidDetails.p1 = You do not have to provide details if the rent has been reviewed since the payment was made.
label.capitalSumPaidDetails = How much did you pay for your lease or agreement?
label.capitalSumPaidDetailsDateInput = When was this sum paid?
Expand Down
1 change: 1 addition & 0 deletions conf/messages.cy
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ error.payACapitalSum.missing = Dewiswch ‘do’ os gwnaethoch dalu swm cyfalaf
# PAY A CAPITAL SUM DETAILS
##################
capitalSumPaidDetails.heading = Provide details of the capital sum paid
capitalSumPaidDetails6048.heading = What was the capital sum or premium paid for the lease or agreement?
capitalSumPaidDetails.p1 = You do not have to provide details if the rent has been reviewed since the payment was made.
label.capitalSumPaidDetails = How much did you pay for your lease or agreement?
label.capitalSumPaidDetailsDateInput = When was this sum paid?
Expand Down
Loading

0 comments on commit 15a82cf

Please sign in to comment.