Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions app/controllers/amend/WhatDoYouWantToAmendStandardController.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2026 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.amend

import controllers.actions._
import forms.amend.WhatDoYouWantToAmendStandardFormProvider
import javax.inject.Inject
import models.NormalMode
import navigation.Navigator
import pages.amend.WhatDoYouWantToAmendStandardPage
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import repositories.SessionRepository
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
import views.html.amend.WhatDoYouWantToAmendStandardView

import scala.concurrent.{ExecutionContext, Future}

class WhatDoYouWantToAmendStandardController @Inject() (
override val messagesApi: MessagesApi,
sessionRepository: SessionRepository,
navigator: Navigator,
identify: IdentifierAction,
getData: DataRetrievalAction,
requireData: DataRequiredAction,
formProvider: WhatDoYouWantToAmendStandardFormProvider,
val controllerComponents: MessagesControllerComponents,
view: WhatDoYouWantToAmendStandardView
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {

val form = formProvider()

def onPageLoad(): Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request =>

val preparedForm = request.userAnswers.get(WhatDoYouWantToAmendStandardPage) match {
case None => form
case Some(value) => form.fill(value)
}

Ok(view(preparedForm))
}

def onSubmit(): Action[AnyContent] = (identify andThen getData andThen requireData).async { implicit request =>
form
.bindFromRequest()
.fold(
formWithErrors => Future.successful(BadRequest(view(formWithErrors))),
value =>
for {
updatedAnswers <- Future.fromTry(request.userAnswers.set(WhatDoYouWantToAmendStandardPage, value))
_ <- sessionRepository.set(updatedAnswers)
} yield Redirect(navigator.nextPage(WhatDoYouWantToAmendStandardPage, NormalMode, updatedAnswers))
)
}
}
30 changes: 30 additions & 0 deletions app/forms/amend/WhatDoYouWantToAmendStandardFormProvider.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2026 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 forms.amend

import javax.inject.Inject
import forms.mappings.Mappings
import play.api.data.Form
import models.amend.WhatDoYouWantToAmendStandard

class WhatDoYouWantToAmendStandardFormProvider @Inject() extends Mappings {

def apply(): Form[WhatDoYouWantToAmendStandard] =
Form(
"value" -> enumerable[WhatDoYouWantToAmendStandard]("amend.whatDoYouWantToAmendStandard.error.required")
)
}
48 changes: 48 additions & 0 deletions app/models/amend/WhatDoYouWantToAmendStandard.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2026 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.amend

import models.{Enumerable, WithName}
import play.api.i18n.Messages
import uk.gov.hmrc.govukfrontend.views.Aliases.Text
import uk.gov.hmrc.govukfrontend.views.viewmodels.radios.RadioItem

sealed trait WhatDoYouWantToAmendStandard

object WhatDoYouWantToAmendStandard extends Enumerable.Implicits {

case object AmendToNilReturn extends WithName("amendToNilReturn") with WhatDoYouWantToAmendStandard
case object AmendPaymentOrSubcontractorDetails
extends WithName("amendPaymentOrSubcontractorDetails")
with WhatDoYouWantToAmendStandard

val values: Seq[WhatDoYouWantToAmendStandard] = Seq(
AmendToNilReturn,
AmendPaymentOrSubcontractorDetails
)

def options(implicit messages: Messages): Seq[RadioItem] = values.zipWithIndex.map { case (value, index) =>
RadioItem(
content = Text(messages(s"amend.whatDoYouWantToAmendStandard.${value.toString}")),
value = Some(value.toString),
id = Some(s"value_$index")
)
}

implicit val enumerable: Enumerable[WhatDoYouWantToAmendStandard] =
Enumerable(values.map(v => v.toString -> v): _*)
}
28 changes: 28 additions & 0 deletions app/pages/amend/WhatDoYouWantToAmendStandardPage.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2026 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 pages.amend

import models.amend.WhatDoYouWantToAmendStandard
import pages.QuestionPage
import play.api.libs.json.JsPath

case object WhatDoYouWantToAmendStandardPage extends QuestionPage[WhatDoYouWantToAmendStandard] {

override def path: JsPath = JsPath \ toString

override def toString: String = "whatDoYouWantToAmendStandard"
}
49 changes: 49 additions & 0 deletions app/views/amend/WhatDoYouWantToAmendStandardView.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@*
* Copyright 2026 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.amend.WhatDoYouWantToAmendStandard

@this(
layout: templates.Layout,
formHelper: FormWithCSRF,
govukErrorSummary: GovukErrorSummary,
govukRadios: GovukRadios,
govukButton: GovukButton
)

@(form: Form[_])(implicit request: Request[_], messages: Messages)

@layout(pageTitle = title(form, messages("amend.whatDoYouWantToAmendStandard.title"))) {

@formHelper(action = controllers.amend.routes.WhatDoYouWantToAmendStandardController.onSubmit(), Symbol("autoComplete") -> "off") {

@if(form.errors.nonEmpty) {
@govukErrorSummary(ErrorSummaryViewModel(form, errorLinkOverrides = Map("value" -> "value_0")))
}

@govukRadios(
RadiosViewModel(
field = form("value"),
legend = LegendViewModel(messages("amend.whatDoYouWantToAmendStandard.heading")).asPageHeading(),
items = WhatDoYouWantToAmendStandard.options
)
)

@govukButton(
ButtonViewModel(messages("site.continue"))
)
}
}
2 changes: 2 additions & 0 deletions conf/app.routes
Comment thread
jassalrichy marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,5 @@ GET /amend-monthly-return/which-subcontractors-to-add controll
POST /amend-monthly-return/which-subcontractors-to-add controllers.amend.WhichSubcontractorsToAddController.onSubmit(mode: Mode = NormalMode)
GET /amend-monthly-return/change-which-subcontractors-to-add controllers.amend.WhichSubcontractorsToAddController.onPageLoad(mode: Mode = CheckMode)
POST /amend-monthly-return/change-which-subcontractors-to-add controllers.amend.WhichSubcontractorsToAddController.onSubmit(mode: Mode = CheckMode)
GET /amend-monthly-return/what-do-you-want-to-amend-standard controllers.amend.WhatDoYouWantToAmendStandardController.onPageLoad()
POST /amend-monthly-return/what-do-you-want-to-amend-standard controllers.amend.WhatDoYouWantToAmendStandardController.onSubmit()
5 changes: 5 additions & 0 deletions conf/messages.en
Comment thread
jassalrichy marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,8 @@ amend.whichSubcontractorsToAdd.heading = Which subcontractor do you want to add
amend.whichSubcontractorsToAdd.checkYourAnswersLabel = Which subcontractor do you want to add to this return?
amend.whichSubcontractorsToAdd.error.required = Select a subcontractor
amend.whichSubcontractorsToAdd.change.hidden = which subcontractor do you want to add to this return?
amend.whatDoYouWantToAmendStandard.title = What do you want to amend?
amend.whatDoYouWantToAmendStandard.heading = What do you want to amend?
amend.whatDoYouWantToAmendStandard.amendToNilReturn = I want to amend this standard return to a nil return
amend.whatDoYouWantToAmendStandard.amendPaymentOrSubcontractorDetails = I want to amend payment or subcontractor details on this return
amend.whatDoYouWantToAmendStandard.error.required = Select the type of amendment you want to make
6 changes: 6 additions & 0 deletions test-utils/generators/ModelGenerators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

package generators

import models.amend.WhatDoYouWantToAmendStandard
import models.monthlyreturns.{Declaration, InactivityRequest}
import org.scalacheck.{Arbitrary, Gen}

trait ModelGenerators {

implicit lazy val arbitraryWhatDoYouWantToAmendStandard: Arbitrary[WhatDoYouWantToAmendStandard] =
Arbitrary {
Gen.oneOf(WhatDoYouWantToAmendStandard.values.toSeq)
}

implicit lazy val arbitraryVerifySubcontractors: Arbitrary[Boolean] =
Arbitrary {
Gen.oneOf(true, false)
Expand Down
Loading