Skip to content

Commit 3585326

Browse files
DTR-3154 company added (#83)
* DTR-3154 company added
1 parent 69feb37 commit 3585326

File tree

6 files changed

+291
-0
lines changed

6 files changed

+291
-0
lines changed
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 controllers.add.company
18+
19+
import config.FrontendAppConfig
20+
import controllers.actions.*
21+
import pages.add.company.CompanyNamePage
22+
import play.api.i18n.{I18nSupport, MessagesApi}
23+
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
24+
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
25+
import views.html.add.company.CompanyAddedView
26+
27+
import javax.inject.Inject
28+
29+
class CompanyAddedController @Inject() (
30+
override val messagesApi: MessagesApi,
31+
identify: IdentifierAction,
32+
getData: DataRetrievalAction,
33+
requireData: DataRequiredAction,
34+
val controllerComponents: MessagesControllerComponents,
35+
view: CompanyAddedView
36+
)(implicit appConfig: FrontendAppConfig)
37+
extends FrontendBaseController
38+
with I18nSupport {
39+
40+
def onPageLoad: Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request =>
41+
request.userAnswers
42+
.get(CompanyNamePage)
43+
.map { companyName =>
44+
Ok(view(companyName))
45+
}
46+
.getOrElse(Redirect(controllers.routes.JourneyRecoveryController.onPageLoad()))
47+
}
48+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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 views.html.components._
18+
@import config.FrontendAppConfig
19+
20+
@this(
21+
layout: templates.Layout,
22+
govukPanel: GovukPanel,
23+
govukButton: GovukButton,
24+
h2:H2,
25+
paragraph: Paragraph,
26+
bulletList: BulletList,
27+
link: Link,
28+
)
29+
30+
@(companyName: String)(implicit request: Request[_], appConfig: FrontendAppConfig, messages: Messages)
31+
32+
@layout(
33+
pageTitle = titleNoForm(messages("companyAdded.title")), showBackLink = false
34+
) {
35+
36+
@govukPanel(Panel(
37+
title = messages("companyAdded.heading"),
38+
))
39+
40+
@paragraph(messages("companyAdded.p1", companyName))
41+
42+
@h2(messages("companyAdded.nextSteps.h2"))
43+
44+
@paragraph(messages("companyAdded.nextSteps.p1"))
45+
46+
@paragraph(messages("companyAdded.nextSteps.p2"))
47+
48+
@bulletList(Seq(
49+
messages("companyAdded.nextSteps.list.l1"),
50+
messages("companyAdded.nextSteps.list.l2"),
51+
messages("companyAdded.nextSteps.list.l3")
52+
))
53+
54+
@link(
55+
linkTextKey = "companyAdded.nextSteps.link",
56+
linkUrl = "#"
57+
)
58+
59+
@h2(messages("companyAdded.helpAndSupport.h2"))
60+
61+
@link(
62+
linkTextKey = "companyAdded.helpAndSupport.p1.link",
63+
linkUrl = appConfig.govUkCISGuidanceUrl,
64+
hasFullStop = true,
65+
prefixTextKey = "companyAdded.helpAndSupport.p1",
66+
isNewTab = false
67+
)
68+
}

conf/app.routes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,5 @@ GET /add/partnership/mobile-number controllers.add.
271271
POST /add/partnership/mobile-number controllers.add.partnership.PartnershipMobileNumberController.onSubmit(mode: Mode = NormalMode)
272272
GET /add/partnership/change-mobile-number controllers.add.partnership.PartnershipMobileNumberController.onPageLoad(mode: Mode = CheckMode)
273273
POST /add/partnership/change-mobile-number controllers.add.partnership.PartnershipMobileNumberController.onSubmit(mode: Mode = CheckMode)
274+
275+
GET /add/company/subcontractor-added controllers.add.company.CompanyAddedController.onPageLoad()

conf/messages.en

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,3 +610,17 @@ partnershipMobileNumber.error.length = Enter a valid mobile number, like 07700 9
610610
partnershipMobileNumber.error.invalid = Enter a valid mobile number, like 07700 900 982 or +44 7700 900 999
611611
partnershipMobileNumber.checkYourAnswersLabel = Mobile number
612612
partnershipMobileNumber.change.hidden = mobile number
613+
614+
companyAdded.title = Company subcontractor added
615+
companyAdded.heading = Subcontractor added
616+
companyAdded.p1 = You can now find {0} on your list of subcontractors.
617+
companyAdded.nextSteps.h2 = Next steps
618+
companyAdded.nextSteps.p1 = Before you can make any payments to this subcontractor, you will need to verify them.
619+
companyAdded.nextSteps.p2 = Once they’re verified with HMRC, you will be able to:
620+
companyAdded.nextSteps.list.l1 = make CIS deductions at the correct rate
621+
companyAdded.nextSteps.list.l2 = include them on a monthly return
622+
companyAdded.nextSteps.list.l3 = provide them with payment and deduction statements
623+
companyAdded.nextSteps.link = Manage your subcontractors
624+
companyAdded.helpAndSupport.h2 = Help and support
625+
companyAdded.helpAndSupport.p1 = If you need help with the Construction Industry Scheme (CIS) and what it means for you,
626+
companyAdded.helpAndSupport.p1.link = guidance is available on GOV.UK
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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.add.company
18+
19+
import base.SpecBase
20+
import controllers.routes
21+
import models.UserAnswers
22+
import pages.add.company.CompanyNamePage
23+
import play.api.test.FakeRequest
24+
import play.api.test.Helpers.*
25+
import views.html.add.company.CompanyAddedView
26+
27+
class CompanyAddedControllerSpec extends SpecBase {
28+
29+
private val companyName = "Test Company"
30+
31+
private lazy val companyAddedRoute =
32+
controllers.add.company.routes.CompanyAddedController.onPageLoad().url
33+
34+
private def uaWithName: UserAnswers =
35+
emptyUserAnswers.set(CompanyNamePage, companyName).success.value
36+
37+
"CompanyAddedController" - {
38+
39+
"must return OK and the correct view for a GET" in {
40+
41+
val application = applicationBuilder(userAnswers = Some(uaWithName)).build()
42+
43+
running(application) {
44+
val request = FakeRequest(GET, companyAddedRoute)
45+
46+
val result = route(application, request).value
47+
48+
val view = application.injector.instanceOf[CompanyAddedView]
49+
50+
status(result) mustEqual OK
51+
contentAsString(result) mustEqual view(companyName)(request, applicationConfig, messages(application)).toString
52+
}
53+
}
54+
55+
"must redirect to Journey Recovery for a GET if no existing data is found" in {
56+
57+
val application = applicationBuilder(userAnswers = None).build()
58+
59+
running(application) {
60+
val request = FakeRequest(GET, companyAddedRoute)
61+
62+
val result = route(application, request).value
63+
64+
status(result) mustEqual SEE_OTHER
65+
redirectLocation(result).value mustEqual routes.JourneyRecoveryController.onPageLoad().url
66+
}
67+
}
68+
69+
"must redirect to JourneyRecovery if company name is missing for a GET" in {
70+
71+
val application = applicationBuilder(userAnswers = Some(emptyUserAnswers)).build()
72+
73+
running(application) {
74+
val request = FakeRequest(GET, companyAddedRoute)
75+
val result = route(application, request).value
76+
77+
status(result) mustEqual SEE_OTHER
78+
redirectLocation(result).value mustEqual controllers.routes.JourneyRecoveryController
79+
.onPageLoad()
80+
.url
81+
}
82+
}
83+
}
84+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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 views.add.company
18+
19+
class CompanyAddedViewSpec {
20+
21+
import org.jsoup.nodes.Document
22+
import org.scalatest.matchers.must.Matchers
23+
import org.scalatest.wordspec.AnyWordSpec
24+
import org.scalatestplus.play.guice.GuiceOneAppPerSuite
25+
import play.api.i18n.Messages
26+
import config.FrontendAppConfig
27+
import play.api.mvc.Request
28+
import play.api.test.FakeRequest
29+
import play.twirl.api.HtmlFormat
30+
import views.html.add.company.CompanyAddedView
31+
32+
class CompanyAddedViewSpec extends AnyWordSpec with Matchers with GuiceOneAppPerSuite {
33+
34+
"CompanyAddedView" should {
35+
36+
"render the page with the correct main content" in new Setup {
37+
38+
given FrontendAppConfig = app.injector.instanceOf[FrontendAppConfig]
39+
private val companyName = "Test Company"
40+
41+
val html: HtmlFormat.Appendable = view(companyName)
42+
val doc: Document = org.jsoup.Jsoup.parse(html.toString())
43+
44+
doc.title must include(messages("companyAdded.title"))
45+
doc.select("h1").text must include(messages("companyAdded.heading"))
46+
47+
doc.select("p").text must include(messages("companyAdded.p1", companyName))
48+
49+
doc.select("h2").text must include(messages("companyAdded.nextSteps.h2"))
50+
doc.select("p").text must include(messages("companyAdded.nextSteps.p1"))
51+
doc.select("p").text must include(messages("companyAdded.nextSteps.p2"))
52+
doc.select("li").text must include(messages("companyAdded.nextSteps.list.l1"))
53+
doc.select("li").text must include(messages("companyAdded.nextSteps.list.l2"))
54+
doc.select("li").text must include(messages("companyAdded.nextSteps.list.l3"))
55+
doc.getElementsByClass("govuk-link").text must include(messages("companyAdded.nextSteps.link"))
56+
57+
doc.select("h2").text must include(messages("companyAdded.helpAndSupport.h2"))
58+
doc.select("p").text must include(messages("companyAdded.helpAndSupport.p1"))
59+
doc.getElementsByClass("govuk-link").text must include(messages("companyAdded.helpAndSupport.p1.link"))
60+
}
61+
}
62+
63+
trait Setup {
64+
implicit val request: Request[_] = FakeRequest()
65+
implicit val messages: Messages =
66+
play.api.i18n.MessagesImpl(
67+
play.api.i18n.Lang.defaultLang,
68+
app.injector.instanceOf[play.api.i18n.MessagesApi]
69+
)
70+
71+
val view: CompanyAddedView =
72+
app.injector.instanceOf[CompanyAddedView]
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)