Skip to content

Commit 8498d17

Browse files
[PIL-2822] - update repayment and btn confirmation pages to show updated info for agent views (#641)
Key Changes: - Updated messages.en - pass in accountingperiodenddate and company name from controllers to view - add new extension method for datetimeutils which will format to follow mural example - add and refactor unit tests
1 parent 991892b commit 8498d17

13 files changed

+184
-70
lines changed

app/controllers/btn/BTNConfirmationController.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ import config.FrontendAppConfig
2020
import controllers.actions.*
2121
import controllers.filteredAccountingPeriodDetails
2222
import models.requests.ObligationsAndSubmissionsSuccessDataRequest
23-
import pages.{BTNChooseAccountingPeriodPage, BtnConfirmationPage}
23+
import pages.{BTNChooseAccountingPeriodPage, BtnConfirmationPage, PlrReferencePage}
2424
import play.api.i18n.I18nSupport
2525
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
2626
import repositories.SessionRepository
2727
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
28+
import utils.DateTimeUtils.toDateAtTimeFormat
2829
import views.html.btn.BTNConfirmationView
2930

3031
import java.time.LocalDate
@@ -47,7 +48,9 @@ class BTNConfirmationController @Inject() (
4748
given ObligationsAndSubmissionsSuccessDataRequest[AnyContent] = request
4849
sessionRepository.get(request.userId).map {
4950
case Some(userAnswers) =>
50-
val accountingPeriodStartDate: LocalDate = request.subscriptionLocalData.subAccountingPeriod.startDate
51+
val accountingPeriodStartDate: LocalDate = request.subscriptionLocalData.subAccountingPeriod.startDate
52+
val accountingPeriodEndDate: LocalDate = request.subscriptionLocalData.subAccountingPeriod.endDate
53+
val plrRef: Option[String] = userAnswers.get(PlrReferencePage)
5154

5255
userAnswers.get(BtnConfirmationPage).fold(Redirect(controllers.routes.JourneyRecoveryController.onPageLoad())) { submittedAt =>
5356
val showUnderEnquiryWarning = userAnswers
@@ -63,8 +66,10 @@ class BTNConfirmationController @Inject() (
6366
Ok(
6467
view(
6568
request.subscriptionLocalData.organisationName,
66-
submittedAt,
69+
plrRef,
70+
submittedAt.toDateAtTimeFormat,
6771
accountingPeriodStartDate,
72+
accountingPeriodEndDate,
6873
request.isAgent,
6974
showUnderEnquiryWarning
7075
)

app/controllers/repayments/RepaymentConfirmationController.scala

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,40 @@ import models.UserAnswers
2222
import pages.*
2323
import play.api.i18n.I18nSupport
2424
import play.api.mvc.*
25+
import services.SubscriptionService
2526
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
2627
import views.html.repayments.RepaymentsConfirmationView
2728

2829
import javax.inject.{Inject, Named}
30+
import scala.concurrent.{ExecutionContext, Future}
2931

3032
class RepaymentConfirmationController @Inject() (
3133
val controllerComponents: MessagesControllerComponents,
3234
@Named("EnrolmentIdentifier") identify: IdentifierAction,
35+
val subscriptionService: SubscriptionService,
3336
view: RepaymentsConfirmationView,
3437
getSessionData: SessionDataRetrievalAction,
3538
requireSessionData: SessionDataRequiredAction
36-
)(using appConfig: FrontendAppConfig)
39+
)(using appConfig: FrontendAppConfig, executionContext: ExecutionContext)
3740
extends FrontendBaseController
3841
with I18nSupport {
3942

4043
def onPageLoad(): Action[AnyContent] =
41-
(identify andThen getSessionData andThen requireSessionData) { request =>
44+
(identify andThen getSessionData andThen requireSessionData).async { request =>
4245
given Request[AnyContent] = request
4346
given userAnswers: UserAnswers = request.userAnswers
4447
(for {
4548
confirmationTimestamp <- userAnswers.get(RepaymentConfirmationPage)
4649
completionStatus <- userAnswers.get(RepaymentCompletionStatus) if completionStatus
47-
} yield Ok(view(confirmationTimestamp)))
48-
.getOrElse(Redirect(controllers.routes.JourneyRecoveryController.onPageLoad()))
50+
plrRef <- userAnswers.get(PlrReferencePage)
51+
} yield subscriptionService.maybeReadSubscription(plrRef).map {
52+
case Some(subscription) =>
53+
val orgName = subscription.upeDetails.organisationName
54+
Ok(view(confirmationTimestamp, plrRef, orgName, request.request.isAgent))
55+
case None =>
56+
Redirect(controllers.routes.JourneyRecoveryController.onPageLoad())
57+
}).getOrElse(
58+
Future.successful(Redirect(controllers.routes.JourneyRecoveryController.onPageLoad()))
59+
)
4960
}
5061
}

app/controllers/repayments/RepaymentsCheckYourAnswersController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class RepaymentsCheckYourAnswersController @Inject() (
110110
Future.fromTry(
111111
sessionData
112112
.set(RepaymentsStatusPage, updatedStatus)
113-
.flatMap(_.set(RepaymentConfirmationPage, ZonedDateTime.now(clock).toDateTimeGmtFormat))
113+
.flatMap(_.set(RepaymentConfirmationPage, ZonedDateTime.now(clock).toDateAtTimeFormat))
114114
)
115115
} else Future.successful(sessionData)
116116
updatedAnswers0 <-

app/pages/RepaymentConfirmationPage.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import play.api.libs.json.JsPath
2020

2121
case object RepaymentConfirmationPage extends QuestionPage[String] {
2222

23-
override def path: JsPath = JsPath \ toString
23+
override def path: JsPath = JsPath \ "repaymentConfirmationTimeStamp"
2424

25-
override def toString: String = "repaymentConfirmationTimeStamp"
2625
}

app/utils/DateTimeUtils.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,28 @@ package utils
1818

1919
import java.time.*
2020
import java.time.format.DateTimeFormatter
21+
import java.util.Locale
2122

2223
object DateTimeUtils {
2324

2425
private val gmtZoneId: ZoneId = ZoneId.of("GMT")
2526
val utcZoneId: ZoneId = ZoneId.of("UTC")
2627

2728
// Patterns
28-
private val datePattern: String = "d MMMM yyyy"
29-
private val dateTimePattern: String = "d MMMM yyyy, h:mma (zzz)"
30-
private val timePattern: String = "hh:mma (zzz)"
29+
private val datePattern: String = "d MMMM yyyy"
30+
private val dateTimePattern: String = "d MMMM yyyy, h:mma (zzz)"
31+
private val timePattern: String = "hh:mma (zzz)"
32+
private val dateAtTimePattern: String = "d MMMM yyyy 'at' h:mma"
3133

3234
// 3 December 2011
3335
private val dateFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern(datePattern)
3436

3537
// 3 December 2011, 10:15am (GMT)
3638
private val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern(dateTimePattern)
3739

40+
// 3 December 2011 at 10:15am
41+
private val dateAtTimeFormatter = DateTimeFormatter.ofPattern(dateAtTimePattern, Locale.UK)
42+
3843
// 10:15am (GMT)
3944
private val timeFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern(timePattern)
4045

@@ -55,6 +60,7 @@ object DateTimeUtils {
5560
def toDateFormat: String = zonedDateTime.withZoneSameLocal(gmtZoneId).format(dateFormatter)
5661
def toDateTimeGmtFormat: String = zonedDateTime.withZoneSameLocal(gmtZoneId).format(dateTimeFormatter)
5762
def toTimeGmtFormat: String = zonedDateTime.withZoneSameLocal(gmtZoneId).format(timeFormatter)
63+
def toDateAtTimeFormat: String = zonedDateTime.withZoneSameLocal(gmtZoneId).format(dateAtTimeFormatter)
5864
}
5965

6066
private val fixedNow: Instant = Instant.now()

app/views/btn/BTNConfirmationView.scala.html

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,41 @@
3333
formHelper: FormWithCSRF
3434
)
3535

36-
@(companyName: Option[String], submissionDate: ZonedDateTime, accountingPeriodStartDate: LocalDate, isAgent: Boolean, showUnderEnquiryWarning: Boolean)(implicit request: Request[_], appConfig: FrontendAppConfig, messages: Messages)
36+
@(companyName: Option[String], plrRef: Option[String], submissionDate: String, accountingPeriodStartDate: LocalDate, accountingPeriodEndDate: LocalDate, isAgent: Boolean, showUnderEnquiryWarning: Boolean)(implicit request: Request[_], appConfig: FrontendAppConfig, messages: Messages)
3737

3838
@layout(pageTitle = titleNoForm(messages("btn.confirmation.title")), showBackLink = false, bannerUrl = Some(routes.HomepageController.onPageLoad().url)) {
39-
39+
@if(isAgent) {
40+
<div class="govuk-hint govuk-!-margin-top-0">
41+
<span><strong>@{messages("homepage.group")}:</strong> @companyName</span>
42+
<span><strong>@{messages("homepage.id")}:</strong> @plrRef</span>
43+
</div>
44+
}
4045
@govukPanel(Panel(
4146
title = Text(messages("btn.confirmation.heading")),
4247
content = HtmlContent(""),
4348
attributes = Map("id" -> "plr2-banner")
4449
))
4550

4651
@if(isAgent && companyName.isDefined) {
47-
@p(messages("btn.confirmation.agent.p1", companyName.get, submissionDate.toDateFormat))
52+
<p class="govuk-body">
53+
@messages("btn.confirmation.agent.p1")<br>
54+
@messages("btn.confirmation.agent.p1.dateTime", submissionDate)
55+
</p>
4856
} else {
49-
@p(messages("btn.confirmation.group.p1", submissionDate.toDateFormat))
57+
@p(messages("btn.confirmation.group.p1", submissionDate))
58+
}
59+
60+
@if(isAgent) {
61+
<p class="govuk-body">
62+
@messages("repayments.confirmation.p1") <span class="govuk-body">@companyName</span><br>
63+
@messages("repayments.confirmation.p2") <span class="govuk-body">@plrRef</span>
64+
</p>
5065
}
5166

52-
@p(messages("btn.confirmation.p2", accountingPeriodStartDate.toDateFormat))
67+
<p class="govuk-body">
68+
@messages("btn.confirmation.p2")<br>
69+
@messages("btn.confirmation.p2.dates", accountingPeriodStartDate.toDateFormat, accountingPeriodEndDate.toDateFormat)
70+
</p>
5371

5472
@if(showUnderEnquiryWarning) {
5573
@govukInsetText(InsetText(content = Text(messages("btn.confirmation.underEnquiry.insetText"))))

app/views/repayments/RepaymentsConfirmationView.scala.html

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
heading: heading
3131
)
3232

33-
@(currentDate: String)(implicit request: Request[_], appConfig: FrontendAppConfig, messages: Messages)
33+
@(currentDate: String, plrRef: String, orgName: String, isAgent: Boolean)(implicit request: Request[_], appConfig: FrontendAppConfig, messages: Messages)
3434

3535
@layout(
3636
pageTitle = titleNoForm(messages("repayments.confirmation.title")),
@@ -40,15 +40,28 @@
4040
authorised = false,
4141
bannerUrl = Some(routes.HomepageController.onPageLoad().url)
4242
) {
43-
43+
@if(isAgent) {
44+
<div class="govuk-hint govuk-!-margin-top-0">
45+
<span><strong>@{messages("homepage.group")}:</strong> @orgName</span>
46+
<span><strong>@{messages("homepage.id")}:</strong> @plrRef</span>
47+
</div>
48+
}
4449
@govukPanel(Panel(
4550
title = Text(messages("repayments.confirmation.bannerText"))
4651
))
4752

4853
<p class="govuk-body">
49-
@messages("repayments.confirmation.message") <span class="govuk-body govuk-!-font-weight-bold">@currentDate</span>.
54+
<span>@messages("repayments.confirmation.message")</span><br>
55+
<span>@messages("repayments.confirmation.message.time", currentDate)</span>
5056
</p>
5157

58+
@if(isAgent) {
59+
<p class="govuk-body">
60+
@messages("repayments.confirmation.p1") <span class="govuk-body">@orgName</span><br>
61+
@messages("repayments.confirmation.p2") <span class="govuk-body">@plrRef</span>
62+
</p>
63+
}
64+
5265
@printLink(messages("site.print"))
5366

5467
@h2(messages("repayments.confirmation.heading"))

conf/messages.en

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,10 @@ repaymentsPhoneDetails.change.hidden = the phone number
14371437

14381438
repayments.confirmation.title = Repayment request submitted
14391439
repayments.confirmation.bannerText = Repayment request submitted
1440-
repayments.confirmation.message = You have successfully submitted your repayment request on
1440+
repayments.confirmation.message = You have submitted a repayment request on:
1441+
repayments.confirmation.message.time = {0}
1442+
repayments.confirmation.p1 = This is for group:
1443+
repayments.confirmation.p2 = Pillar 2 ID:
14411444
repayments.confirmation.heading = What happens next
14421445
repayments.confirmation.paragraph = We may need more information to complete the repayment. If we do, we’ll contact the relevant person or team from the information you provided.
14431446
repayments.confirmation.back = Back to group homepage
@@ -1705,12 +1708,14 @@ btn.cya.p3 = By submitting these details, you are confirming that the informatio
17051708
btn.confirmation.title = Below-Threshold Notification successful
17061709
btn.confirmation.heading = Below-Threshold Notification successful
17071710
btn.confirmation.group.p1 = You have submitted a Below-Threshold Notification on {0}.
1708-
btn.confirmation.agent.p1 = You have submitted a Below-Threshold Notification for {0} on {1}.
1709-
btn.confirmation.p2 = This is effective from the start of the accounting period you selected, {0}.
1711+
btn.confirmation.agent.p1 = You have submitted a Below-Threshold Notification on:
1712+
btn.confirmation.agent.p1.dateTime = {0}.
1713+
btn.confirmation.p2 = Effective from the start of the accounting period you selected:
1714+
btn.confirmation.p2.dates = {0} - {1}
17101715
btn.confirmation.underEnquiry.insetText = This submission will not apply to any accounting period under enquiry.
17111716
btn.confirmation.subheading = What happens next
1712-
btn.confirmation.group.p3 = The Below-Threshold Notification satisfies the group’s obligation to submit a UK Tax Return for the current and future accounting periods. HMRC will not expect to receive an information return while the group remains below-threshold.
1713-
btn.confirmation.group.p4 = The group must submit a UK Tax Return if your group meets the threshold conditions in the future.
1717+
btn.confirmation.group.p3 = HMRC has removed the group’s obligation to submit a UK Tax Return for the current accounting period, and future accounting periods.
1718+
btn.confirmation.group.p4 = If the group becomes liable for a UK Tax Return in the future, you must let HMRC know by submitting a UK Tax Return to remove the Below-Threshold Notification from the group’s account.
17141719
btn.confirmation.p5.group.link = Back to group’s homepage
17151720

17161721
btn.error.title = Sorry, there is a problem with the service

test/controllers/btn/BTNConfirmationControllerSpec.scala

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ import play.api.mvc.{MessagesControllerComponents, PlayBodyParsers}
2929
import play.api.test.FakeRequest
3030
import play.api.test.Helpers.*
3131
import repositories.SessionRepository
32+
import utils.DateTimeUtils
3233
import views.html.btn.BTNConfirmationView
3334

3435
import java.time.{LocalDate, ZonedDateTime}
3536
import scala.concurrent.Future
3637

3738
class BTNConfirmationControllerSpec extends SpecBase {
3839

39-
val submittedAt: ZonedDateTime = ZonedDateTime.now()
40-
val accountingPeriodStart = someSubscriptionLocalData.subAccountingPeriod.startDate
40+
val submittedAtZonedDateTime: ZonedDateTime = ZonedDateTime.of(2024, 11, 10, 10, 0, 0, 0, DateTimeUtils.utcZoneId)
41+
val submittedAt: String = "10 November 2024 at 10:00am"
42+
private val accountingPeriodStart = someSubscriptionLocalData.subAccountingPeriod.startDate
43+
private val accountingPeriodEnd = someSubscriptionLocalData.subAccountingPeriod.endDate
4144

4245
val btnConfirmationView: BTNConfirmationView = app.injector.instanceOf[BTNConfirmationView]
4346

@@ -78,16 +81,18 @@ class BTNConfirmationControllerSpec extends SpecBase {
7881

7982
"return OK and the correct view for a GET" in new BTNConfirmationControllerTestCase {
8083

81-
override def userAnswers: UserAnswers => Option[UserAnswers] = _.setOrException(BtnConfirmationPage, submittedAt).some
84+
override def userAnswers: UserAnswers => Option[UserAnswers] = _.setOrException(BtnConfirmationPage, submittedAtZonedDateTime).some
8285

8386
val result: Future[Result] = controller.onPageLoad(request)
8487

8588
status(result) mustEqual OK
8689

8790
contentAsString(result) mustEqual btnConfirmationView(
8891
Some("OrgName"),
92+
Some("somePillar2Id"),
8993
submittedAt,
9094
accountingPeriodStart,
95+
accountingPeriodEnd,
9196
isAgent = false,
9297
showUnderEnquiryWarning = false
9398
)(
@@ -108,7 +113,7 @@ class BTNConfirmationControllerSpec extends SpecBase {
108113
)
109114

110115
override def userAnswers: UserAnswers => Option[UserAnswers] =
111-
_.setOrException(BTNChooseAccountingPeriodPage, chosenPeriod).setOrException(BtnConfirmationPage, submittedAt).some
116+
_.setOrException(BTNChooseAccountingPeriodPage, chosenPeriod).setOrException(BtnConfirmationPage, submittedAtZonedDateTime).some
112117

113118
override def obligationsData: ObligationsAndSubmissionsSuccess = ObligationsAndSubmissionsSuccess(
114119
processingDate = ZonedDateTime.now(),
@@ -121,8 +126,10 @@ class BTNConfirmationControllerSpec extends SpecBase {
121126

122127
contentAsString(result) mustEqual btnConfirmationView(
123128
Some("OrgName"),
129+
Some("somePillar2Id"),
124130
submittedAt,
125131
accountingPeriodStart,
132+
accountingPeriodEnd,
126133
isAgent = false,
127134
showUnderEnquiryWarning = true
128135
)(
@@ -150,7 +157,7 @@ class BTNConfirmationControllerSpec extends SpecBase {
150157
)
151158

152159
override def userAnswers: UserAnswers => Option[UserAnswers] =
153-
_.setOrException(BTNChooseAccountingPeriodPage, chosenPeriod).setOrException(BtnConfirmationPage, submittedAt).some
160+
_.setOrException(BTNChooseAccountingPeriodPage, chosenPeriod).setOrException(BtnConfirmationPage, submittedAtZonedDateTime).some
154161

155162
override def obligationsData: ObligationsAndSubmissionsSuccess = ObligationsAndSubmissionsSuccess(
156163
processingDate = ZonedDateTime.now(),
@@ -163,8 +170,10 @@ class BTNConfirmationControllerSpec extends SpecBase {
163170

164171
contentAsString(result) mustEqual btnConfirmationView(
165172
Some("OrgName"),
173+
Some("somePillar2Id"),
166174
submittedAt,
167175
accountingPeriodStart,
176+
accountingPeriodEnd,
168177
isAgent = false,
169178
showUnderEnquiryWarning = true
170179
)(
@@ -192,7 +201,7 @@ class BTNConfirmationControllerSpec extends SpecBase {
192201
)
193202

194203
override def userAnswers: UserAnswers => Option[UserAnswers] =
195-
_.setOrException(BTNChooseAccountingPeriodPage, chosenPeriod).setOrException(BtnConfirmationPage, submittedAt).some
204+
_.setOrException(BTNChooseAccountingPeriodPage, chosenPeriod).setOrException(BtnConfirmationPage, submittedAtZonedDateTime).some
196205

197206
override def obligationsData: ObligationsAndSubmissionsSuccess = ObligationsAndSubmissionsSuccess(
198207
processingDate = ZonedDateTime.now(),
@@ -205,8 +214,10 @@ class BTNConfirmationControllerSpec extends SpecBase {
205214

206215
contentAsString(result) mustEqual btnConfirmationView(
207216
Some("OrgName"),
217+
Some("somePillar2Id"),
208218
submittedAt,
209219
accountingPeriodStart,
220+
accountingPeriodEnd,
210221
isAgent = false,
211222
showUnderEnquiryWarning = false
212223
)(

0 commit comments

Comments
 (0)