Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MISUV-8687 Create new Reporting Frequency View #2620

Merged
merged 1 commit into from
Nov 8, 2024
Merged
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
58 changes: 42 additions & 16 deletions app/controllers/ReportingFrequencyPageController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,28 @@ import auth.authV2.AuthActions
import config.featureswitch.FeatureSwitching
import config.{AgentItvcErrorHandler, FrontendAppConfig, ItvcErrorHandler}
import controllers.agent.predicates.ClientConfirmedController
import models.ReportingFrequencyViewModel
import models.admin.ReportingFrequencyPage
import models.optout.{OptOutMultiYearViewModel, OptOutOneYearViewModel}
import play.api.i18n.I18nSupport
import play.api.mvc._
import services.DateService
import services.optIn.OptInService
import services.optout.OptOutService
import views.html.ReportingFrequencyView
import views.html.errorPages.templates.ErrorTemplate

import javax.inject.Inject
import scala.concurrent.ExecutionContext

// TODO: Needs view to be implemented
class ReportingFrequencyPageController @Inject()(
val optInService: OptInService,
optOutService: OptOutService,
val authorisedFunctions: FrontendAuthorisedFunctions,
val auth: AuthActions,
errorTemplate: ErrorTemplate
)
(
dateService: DateService,
errorTemplate: ErrorTemplate,
view: ReportingFrequencyView
)(
implicit val appConfig: FrontendAppConfig,
mcc: MessagesControllerComponents,
val ec: ExecutionContext,
Expand All @@ -48,18 +53,39 @@ class ReportingFrequencyPageController @Inject()(
extends ClientConfirmedController with FeatureSwitching with I18nSupport {

def show(): Action[AnyContent] =
auth.individualOrAgentWithClient { implicit user =>
if (isEnabled(ReportingFrequencyPage)) {
Ok("Reporting Frequency Page - Placeholder")
} else {
InternalServerError(
errorTemplate(
pageTitle = "standardError.heading",
heading = "standardError.heading",
message = "standardError.message",
isAgent = user.isAgent()
auth.individualOrAgentWithClient.async { implicit user =>

for {
(checks, optOutJourneyType) <- optOutService.nextUpdatesPageOptOutViewModels()
} yield {
if (isEnabled(ReportingFrequencyPage)) {

val optOutUrl: Option[String] =
optOutJourneyType.map {
case singleYearModel: OptOutOneYearViewModel =>
controllers.optOut.routes.ConfirmOptOutController.show(user.isAgent()).url
case multiYearModel: OptOutMultiYearViewModel =>
controllers.optOut.routes.OptOutChooseTaxYearController.show(user.isAgent()).url
}

Ok(view(
ReportingFrequencyViewModel(
isAgent = user.isAgent(),
currentTaxYear = dateService.getCurrentTaxYear,
nextTaxYear = dateService.getCurrentTaxYear.nextYear,
optOutJourneyUrl = optOutUrl
)
))
} else {
InternalServerError(
errorTemplate(
pageTitle = "standardError.heading",
heading = "standardError.heading",
message = "standardError.message",
isAgent = user.isAgent()
)
)
)
}
}
}
}
26 changes: 26 additions & 0 deletions app/models/ReportingFrequencyViewModel.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 models

import models.incomeSourceDetails.TaxYear

case class ReportingFrequencyViewModel(
isAgent: Boolean,
currentTaxYear: TaxYear,
nextTaxYear: TaxYear,
optOutJourneyUrl: Option[String]
)
2 changes: 1 addition & 1 deletion app/services/optout/OptOutService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class OptOutService @Inject()(itsaStatusUpdateConnector: ITSAStatusUpdateConnect
_ <- repository.initialiseOptOutJourney(proposition)
} yield (nextUpdatesQuarterlyReportingContentChecks(proposition), nextUpdatesOptOutViewModel(proposition))
}

private def nextUpdatesQuarterlyReportingContentChecks(oop: OptOutProposition) = {
val currentYearStatus = oop.currentTaxYear.status
val previousYearStatus = oop.previousTaxYear.status
Expand Down
68 changes: 68 additions & 0 deletions app/views/ReportingFrequencyView.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@*
* 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.optin.OptInCompletedViewModel
@import uk.gov.hmrc.govukfrontend.views.html.components._
@import views.html.components._
@import views.html.layouts.unifiedLayout
@import models.ReportingFrequencyViewModel

@this(
mainTemplate: unifiedLayout,
h1: h1,
h2: h2,
p: p,
linkComponent: linkComponent,
bulletList: bulletPointList,
govukTable: GovukTable,
govukInsetText : GovukInsetText
)

@(viewModel: ReportingFrequencyViewModel)(implicit messages: Messages, user: auth.MtdItUser[_])

@manageReportingFrequency = {

@h2(msg = "reporting.frequency.h2", optId = Some("manage-reporting-frequency-heading"))

@p(id=Some("change-reporting-frequency")){
@messages("reporting.frequency.manageReportingFrequency.p1")
}

@p(id=Some("what-you-can-do")){
@messages("reporting.frequency.manageReportingFrequency.p2")
}

<ul class="govuk-list govuk-list--bullet">
<li>
@linkComponent(controllers.optIn.routes.BeforeYouStartController.show(viewModel.isAgent).url, message = messages("reporting.frequency.manageReportingFrequency.b1.link", viewModel.currentTaxYear.startYear.toString, viewModel.currentTaxYear.endYear.toString))
</li>
@viewModel.optOutJourneyUrl.map{ url =>
<li>
@linkComponent(url, message = messages("reporting.frequency.manageReportingFrequency.b2.link", viewModel.nextTaxYear.startYear.toString, viewModel.nextTaxYear.endYear.toString))
</li>
}
</ul>
}

@mainTemplate(
pageTitle = messages("reporting.frequency.title"),
isAgent = viewModel.isAgent,
btaNavPartial = user.btaNavPartial
) {

@h1(msg = "reporting.frequency.h1", id = Some("reporting-frequency-heading"))
@manageReportingFrequency
}
36 changes: 36 additions & 0 deletions app/views/components/linkComponent.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@*
* 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.
*@

@this()

@(
url: String,
classes: String = "",
message: String,
id: Option[String] = None,
target: Option[String] = None,
ariaLabel: Option[String] = None,
role: Option[String] = None,
rel: Option[String] = None,
additionalOpenTabMessage: Option[String] = None
)(implicit messages: Messages)

<a href="@url" class="govuk-link govuk-body @classes" @id.map(id => s"id=$id") @if(rel.isDefined){rel="@rel.map(c=>s"$c")"} @target.map(target => s"target=$target") @role.map(role => s"role=$role")>
@message
@if(target == Some("_blank")){
@messages("pagehelp.opensInNewTabText")@additionalOpenTabMessage.map(message => message)
}
</a>
17 changes: 17 additions & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -2347,3 +2347,20 @@ optIn.confirmTaxYear.cancel = Cancel

optIn.confirmNextTaxYear.heading = Confirm and opt in from {0} to {1} tax year onwards
optIn.confirmNextTaxYear.desc = If you opt in for the next tax year, from {0} you will need to submit your quarterly updates through compatible software.


# Reporting Frequency Page

reporting.frequency.title = Your reporting frequency

reporting.frequency.h1 = Your reporting frequency
reporting.frequency.h2 = Manage your reporting frequency for all your businesses

reporting.frequency.manageReportingFrequency.p1 = If you are reporting annually or voluntarily reporting quarterly, you may be able to change your reporting frequency for specific tax years.
reporting.frequency.manageReportingFrequency.p2 = This is what you can do for all your businesses:
reporting.frequency.manageReportingFrequency.b1.link = Opt in to quarterly reporting for the {0} to {1} tax year
reporting.frequency.manageReportingFrequency.b2.link = Opt out of quarterly reporting and report annually from the {0} to {1} tax year onwards




12 changes: 11 additions & 1 deletion conf/messages.cy
Original file line number Diff line number Diff line change
Expand Up @@ -2281,4 +2281,14 @@ optIn.confirmTaxYear.confirmSaveBtn = Cadarnhau a chadw
optIn.confirmTaxYear.cancel = Canslo

optIn.confirmNextTaxYear.heading = Cadarnhau ac optio i mewn ar gyfer blwyddyn dreth {0} i {1} ymlaen
optIn.confirmNextTaxYear.desc = Os byddwch yn optio i mewn ar gyfer y flwyddyn dreth nesaf, o {0} ymlaen, bydd angen i chi gyflwyno’ch adroddiadau chwarterol drwy ddefnyddio meddalwedd sy’n cydweddu.
optIn.confirmNextTaxYear.desc = Os byddwch yn optio i mewn ar gyfer y flwyddyn dreth nesaf, o {0} ymlaen, bydd angen i chi gyflwyno’ch adroddiadau chwarterol drwy ddefnyddio meddalwedd sy’n cydweddu.

# Reporting Frequency Page

reporting.frequency.h2 = Rheoli amlder eich adroddiadau ar gyfer eich holl fusnesau

reporting.frequency.manageReportingFrequency.p1 = Os ydych yn adrodd yn flynyddol, neu’n adrodd yn chwarterol yn wirfoddol, mae’n bosibl y byddwch yn gallu newid amlder eich adroddiadau ar gyfer blynyddoedd treth penodol.
reporting.frequency.manageReportingFrequency.p2 = Yr hyn y gallwch ei wneud ar gyfer eich holl fusnesau:
reporting.frequency.manageReportingFrequency.b1.link = Optio i mewn i adrodd yn chwarterol ar gyfer blwyddyn dreth {0} i {1}
reporting.frequency.manageReportingFrequency.b2.link = Optio allan o adrodd yn chwarterol, a mynd ati i adrodd yn flynyddol o flwyddyn dreth {0} i {1} ymlaen

1 change: 1 addition & 0 deletions it/test/controllers/NextUpdatesControllerISpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class NextUpdatesControllerISpec extends ComponentSpecBase {
}

"the user has a Opt Out Feature Switch Enabled" in {

enable(OptOut)

val currentTaxYear = dateService.getCurrentTaxYearEnd
Expand Down
15 changes: 8 additions & 7 deletions it/test/controllers/ReportingFrequencyControllerISpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package controllers
import com.github.tomakehurst.wiremock.client.WireMock
import config.FrontendAppConfig
import config.featureswitch.FeatureSwitching
import helpers.servicemocks.{AuthStub, IncomeTaxViewChangeStub}
import helpers.servicemocks.{AuthStub, ITSAStatusDetailsStub, IncomeTaxViewChangeStub}
import models.admin.FeatureSwitchName.allFeatureSwitches
import models.admin.ReportingFrequencyPage
import models.admin.{OptOut, ReportingFrequencyPage}
import org.jsoup.Jsoup
import play.api.http.HeaderNames
import play.api.http.Status.{INTERNAL_SERVER_ERROR, OK}
Expand Down Expand Up @@ -61,11 +61,13 @@ class ReportingFrequencyControllerISpec extends ControllerISpecBase with Feature

"return the ReportingFrequency page, OK - 200" in {

AuthStub.stubAuthorised()
IncomeTaxViewChangeStub.stubGetIncomeSourceDetailsResponse(testMtditid)(OK, businessAndPropertyResponseWoMigration)

allFeatureSwitches.foreach(switch => disable(switch))
enable(ReportingFrequencyPage)
enable(OptOut)

AuthStub.stubAuthorised()
IncomeTaxViewChangeStub.stubGetIncomeSourceDetailsResponse(testMtditid)(OK, businessAndPropertyResponseWoMigration)
ITSAStatusDetailsStub.stubGetITSAStatusFutureYearsDetails(dateService.getCurrentTaxYearEnd)

val res =
httpClient
Expand All @@ -74,8 +76,7 @@ class ReportingFrequencyControllerISpec extends ControllerISpecBase with Feature
.execute[HttpResponse]

res.futureValue.status shouldBe OK
// Jsoup.parse(res.futureValue.body).title shouldBe "New page title" //TODO: change the test to look for the title of the new page when implemented
res.futureValue.body shouldBe "Reporting Frequency Page - Placeholder"
Jsoup.parse(res.futureValue.body).title shouldBe "Your reporting frequency - Manage your Income Tax updates - GOV.UK"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ object IncomeSourceIntegrationTestConstants {
)

val multipleBusinessesResponse: IncomeSourceDetailsResponse = IncomeSourceDetailsModel(
testNino,
testMtdItId,
nino = testNino,
mtdbsa = testMtdItId,
businesses = List(
business1,
business2
Expand Down
Loading