Skip to content

Commit 10f58c9

Browse files
authored
[DTR-4543] CIS AMR Screen Ticket MRAR06 - What do you want to amend? (#183)
* [DTR-4543] Adding WhatDoYouWantToAmendStandard screen * [DTR-4543] Formatting fix * [DTR-4543] Resolving PR comment * [DTR-4543] fixing unit test
1 parent c5c3663 commit 10f58c9

12 files changed

Lines changed: 581 additions & 0 deletions
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2026 HM Revenue & Customs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package controllers.amend
18+
19+
import controllers.actions._
20+
import forms.amend.WhatDoYouWantToAmendStandardFormProvider
21+
import javax.inject.Inject
22+
import models.NormalMode
23+
import navigation.Navigator
24+
import pages.amend.WhatDoYouWantToAmendStandardPage
25+
import play.api.i18n.{I18nSupport, MessagesApi}
26+
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
27+
import repositories.SessionRepository
28+
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
29+
import views.html.amend.WhatDoYouWantToAmendStandardView
30+
31+
import scala.concurrent.{ExecutionContext, Future}
32+
33+
class WhatDoYouWantToAmendStandardController @Inject() (
34+
override val messagesApi: MessagesApi,
35+
sessionRepository: SessionRepository,
36+
navigator: Navigator,
37+
identify: IdentifierAction,
38+
getData: DataRetrievalAction,
39+
requireData: DataRequiredAction,
40+
formProvider: WhatDoYouWantToAmendStandardFormProvider,
41+
val controllerComponents: MessagesControllerComponents,
42+
view: WhatDoYouWantToAmendStandardView
43+
)(implicit ec: ExecutionContext)
44+
extends FrontendBaseController
45+
with I18nSupport {
46+
47+
val form = formProvider()
48+
49+
def onPageLoad(): Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request =>
50+
51+
val preparedForm = request.userAnswers.get(WhatDoYouWantToAmendStandardPage) match {
52+
case None => form
53+
case Some(value) => form.fill(value)
54+
}
55+
56+
Ok(view(preparedForm))
57+
}
58+
59+
def onSubmit(): Action[AnyContent] = (identify andThen getData andThen requireData).async { implicit request =>
60+
form
61+
.bindFromRequest()
62+
.fold(
63+
formWithErrors => Future.successful(BadRequest(view(formWithErrors))),
64+
value =>
65+
for {
66+
updatedAnswers <- Future.fromTry(request.userAnswers.set(WhatDoYouWantToAmendStandardPage, value))
67+
_ <- sessionRepository.set(updatedAnswers)
68+
} yield Redirect(navigator.nextPage(WhatDoYouWantToAmendStandardPage, NormalMode, updatedAnswers))
69+
)
70+
}
71+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2026 HM Revenue & Customs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package forms.amend
18+
19+
import javax.inject.Inject
20+
import forms.mappings.Mappings
21+
import play.api.data.Form
22+
import models.amend.WhatDoYouWantToAmendStandard
23+
24+
class WhatDoYouWantToAmendStandardFormProvider @Inject() extends Mappings {
25+
26+
def apply(): Form[WhatDoYouWantToAmendStandard] =
27+
Form(
28+
"value" -> enumerable[WhatDoYouWantToAmendStandard]("amend.whatDoYouWantToAmendStandard.error.required")
29+
)
30+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2026 HM Revenue & Customs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package models.amend
18+
19+
import models.{Enumerable, WithName}
20+
import play.api.i18n.Messages
21+
import uk.gov.hmrc.govukfrontend.views.Aliases.Text
22+
import uk.gov.hmrc.govukfrontend.views.viewmodels.radios.RadioItem
23+
24+
sealed trait WhatDoYouWantToAmendStandard
25+
26+
object WhatDoYouWantToAmendStandard extends Enumerable.Implicits {
27+
28+
case object AmendToNilReturn extends WithName("amendToNilReturn") with WhatDoYouWantToAmendStandard
29+
case object AmendPaymentOrSubcontractorDetails
30+
extends WithName("amendPaymentOrSubcontractorDetails")
31+
with WhatDoYouWantToAmendStandard
32+
33+
val values: Seq[WhatDoYouWantToAmendStandard] = Seq(
34+
AmendToNilReturn,
35+
AmendPaymentOrSubcontractorDetails
36+
)
37+
38+
def options(implicit messages: Messages): Seq[RadioItem] = values.zipWithIndex.map { case (value, index) =>
39+
RadioItem(
40+
content = Text(messages(s"amend.whatDoYouWantToAmendStandard.${value.toString}")),
41+
value = Some(value.toString),
42+
id = Some(s"value_$index")
43+
)
44+
}
45+
46+
implicit val enumerable: Enumerable[WhatDoYouWantToAmendStandard] =
47+
Enumerable(values.map(v => v.toString -> v): _*)
48+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2026 HM Revenue & Customs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package pages.amend
18+
19+
import models.amend.WhatDoYouWantToAmendStandard
20+
import pages.QuestionPage
21+
import play.api.libs.json.JsPath
22+
23+
case object WhatDoYouWantToAmendStandardPage extends QuestionPage[WhatDoYouWantToAmendStandard] {
24+
25+
override def path: JsPath = JsPath \ toString
26+
27+
override def toString: String = "whatDoYouWantToAmendStandard"
28+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@*
2+
* Copyright 2026 HM Revenue & Customs
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*@
16+
17+
@import models.amend.WhatDoYouWantToAmendStandard
18+
19+
@this(
20+
layout: templates.Layout,
21+
formHelper: FormWithCSRF,
22+
govukErrorSummary: GovukErrorSummary,
23+
govukRadios: GovukRadios,
24+
govukButton: GovukButton
25+
)
26+
27+
@(form: Form[_])(implicit request: Request[_], messages: Messages)
28+
29+
@layout(pageTitle = title(form, messages("amend.whatDoYouWantToAmendStandard.title"))) {
30+
31+
@formHelper(action = controllers.amend.routes.WhatDoYouWantToAmendStandardController.onSubmit(), Symbol("autoComplete") -> "off") {
32+
33+
@if(form.errors.nonEmpty) {
34+
@govukErrorSummary(ErrorSummaryViewModel(form, errorLinkOverrides = Map("value" -> "value_0")))
35+
}
36+
37+
@govukRadios(
38+
RadiosViewModel(
39+
field = form("value"),
40+
legend = LegendViewModel(messages("amend.whatDoYouWantToAmendStandard.heading")).asPageHeading(),
41+
items = WhatDoYouWantToAmendStandard.options
42+
)
43+
)
44+
45+
@govukButton(
46+
ButtonViewModel(messages("site.continue"))
47+
)
48+
}
49+
}

conf/app.routes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,6 @@ POST /amend-monthly-return/what-do-you-want-to-amend-nil
173173

174174
GET /manage-cis-return/amend-monthly-return/confirm-amendment controllers.amend.ConfirmAmendmentController.onPageLoad()
175175
POST /manage-cis-return/amend-monthly-return/confirm-amendment controllers.amend.ConfirmAmendmentController.onSubmit()
176+
177+
GET /amend-monthly-return/what-do-you-want-to-amend-standard controllers.amend.WhatDoYouWantToAmendStandardController.onPageLoad()
178+
POST /amend-monthly-return/what-do-you-want-to-amend-standard controllers.amend.WhatDoYouWantToAmendStandardController.onSubmit()

conf/messages.en

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,3 +551,9 @@ whatDoYouWantToAmendNil.heading = What do you want to amend?
551551
whatDoYouWantToAmendNil.amendNilReturn = I want to amend this nil return
552552
whatDoYouWantToAmendNil.addPaymentOrSubcontractorDetails = I want to add payment or subcontractor details on this return
553553
whatDoYouWantToAmendNil.error.required = Select the type of amendment you want to make
554+
555+
amend.whatDoYouWantToAmendStandard.title = What do you want to amend?
556+
amend.whatDoYouWantToAmendStandard.heading = What do you want to amend?
557+
amend.whatDoYouWantToAmendStandard.amendToNilReturn = I want to amend this standard return to a nil return
558+
amend.whatDoYouWantToAmendStandard.amendPaymentOrSubcontractorDetails = I want to amend payment or subcontractor details on this return
559+
amend.whatDoYouWantToAmendStandard.error.required = Select the type of amendment you want to make

test-utils/generators/ModelGenerators.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package generators
1818

1919
import models.amend.WhatDoYouWantToAmendNil
20+
import models.amend.WhatDoYouWantToAmendStandard
2021
import models.monthlyreturns.{Declaration, InactivityRequest}
2122
import org.scalacheck.{Arbitrary, Gen}
2223

@@ -27,6 +28,11 @@ trait ModelGenerators {
2728
Gen.oneOf(WhatDoYouWantToAmendNil.values.toSeq)
2829
}
2930

31+
implicit lazy val arbitraryWhatDoYouWantToAmendStandard: Arbitrary[WhatDoYouWantToAmendStandard] =
32+
Arbitrary {
33+
Gen.oneOf(WhatDoYouWantToAmendStandard.values.toSeq)
34+
}
35+
3036
implicit lazy val arbitraryVerifySubcontractors: Arbitrary[Boolean] =
3137
Arbitrary {
3238
Gen.oneOf(true, false)

0 commit comments

Comments
 (0)