-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1100 from hmrc/BST-112376
BST-112376 - Added/Updated pay capital sum details page
- Loading branch information
Showing
15 changed files
with
441 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
app/controllers/aboutYourLeaseOrTenure/PayACapitalSumAmountDetailsController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/form/aboutYourLeaseOrTenure/PayACapitalSumAmountDetailsForm.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/models/submissions/aboutYourLeaseOrTenure/PayACapitalSumAmountDetails.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
app/views/aboutYourLeaseOrTenure/payACapitalSumAmountDetails.scala.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.