Skip to content

Commit

Permalink
MCSC-1205 New page to address bookmarking issue on calc results page (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelAAbbott authored Dec 16, 2024
1 parent 235e0b1 commit 74f5a90
Show file tree
Hide file tree
Showing 17 changed files with 715 additions and 154 deletions.
14 changes: 8 additions & 6 deletions app/config/FrontendAppConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class FrontendAppConfig @Inject() (configuration: Configuration) {
s"$contactHost/contact/beta-feedback?service=$contactFormServiceIdentifier&backUrl=$safeBackUrl"
}

val baseUrl: String = configuration.get[String]("urls.base")
val loginUrl: String = configuration.get[String]("urls.login")
val loginContinueUrl: String = configuration.get[String]("urls.loginContinue")
val signOutUrl: String = configuration.get[String]("urls.signOut")
val submitFrontend: String = configuration.get[String]("urls.submitFrontend")
val redirectToStartPage: String = configuration.get[String]("urls.redirectToStartPage")
val baseUrl: String = configuration.get[String]("urls.base")
val loginUrl: String = configuration.get[String]("urls.login")
val loginContinueUrl: String = configuration.get[String]("urls.loginContinue")
val signOutUrl: String = configuration.get[String]("urls.signOut")
val submitFrontend: String = configuration.get[String]("urls.submitFrontend")
val redirectToStartPage: String = configuration.get[String]("urls.redirectToStartPage")
val redirectToOutstandingTasksPage: String = configuration.get[String]("urls.redirectToOutstandingTasksPage")
val redirectToTaskListPage: String = configuration.get[String]("urls.redirectToTaskListPage")

val confidenceUpliftUrl: String = configuration.get[String]("urls.confidenceUplift")
val upliftCompletionUrl = configuration.get[String]("urls.upliftCompletion")
Expand Down
1 change: 1 addition & 0 deletions app/config/Module.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Module extends AbstractModule {
bind(classOf[DataRetrievalAction]).to(classOf[DataRetrievalActionImpl]).asEagerSingleton()
bind(classOf[DataRequiredAction]).to(classOf[DataRequiredActionImpl]).asEagerSingleton()
bind(classOf[IdentifierAction]).to(classOf[OptionalAuthIdentifierAction]).asEagerSingleton()
bind(classOf[RequireTasksCompletedAction]).to(classOf[RequireTasksCompletedActionImpl]).asEagerSingleton()
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone.withZone(ZoneOffset.UTC))
bind(classOf[Encrypter]).toProvider(classOf[CryptoProvider])
bind(classOf[Decrypter]).toProvider(classOf[CryptoProvider])
Expand Down
62 changes: 33 additions & 29 deletions app/controllers/CalculationReviewController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CalculationReviewController @Inject() (
identify: IdentifierAction,
getData: DataRetrievalAction,
requireData: DataRequiredAction,
requireTasksCompleted: RequireTasksCompletedAction,
val controllerComponents: MessagesControllerComponents,
view: CalculationReviewView,
calculationResultService: CalculationResultService,
Expand All @@ -49,39 +50,42 @@ class CalculationReviewController @Inject() (

val form = Form("_" -> ignored(()))

def onPageLoad: Action[AnyContent] = (identify andThen getData andThen requireData).async { implicit request =>
calculationResultService.sendRequest(request.userAnswers).map { calculationResponse =>
val includeCompensation2015: Boolean = calculationResponse.totalAmounts.outDatesCompensation > 0
val isInCredit: Boolean = calculationResponse.totalAmounts.inDatesCredit > 0
val isInDebit: Boolean = calculationResponse.totalAmounts.inDatesDebit > 0
val isUserAuthenticated: Boolean = request.userAnswers.authenticated
val isLTACompleteWithoutKickout = LTASection.status(request.userAnswers) == SectionStatus.Completed && !LTASection
.kickoutHasBeenReached(request.userAnswers)
val hasInDates: Boolean = calculationResponse.inDates.isDefinedAt(0)
Ok(
view(
form,
calculationResultService.calculationReviewViewModel(calculationResponse),
includeCompensation2015,
isInCredit,
isInDebit,
isUserAuthenticated,
isLTACompleteWithoutKickout,
hasInDates
def onPageLoad: Action[AnyContent] =
(identify andThen getData andThen requireData andThen requireTasksCompleted).async { implicit request =>
calculationResultService.sendRequest(request.userAnswers).map { calculationResponse =>
val includeCompensation2015: Boolean = calculationResponse.totalAmounts.outDatesCompensation > 0
val isInCredit: Boolean = calculationResponse.totalAmounts.inDatesCredit > 0
val isInDebit: Boolean = calculationResponse.totalAmounts.inDatesDebit > 0
val isUserAuthenticated: Boolean = request.userAnswers.authenticated
val isLTACompleteWithoutKickout =
LTASection.status(request.userAnswers) == SectionStatus.Completed && !LTASection
.kickoutHasBeenReached(request.userAnswers)
val hasInDates: Boolean = calculationResponse.inDates.isDefinedAt(0)
Ok(
view(
form,
calculationResultService.calculationReviewViewModel(calculationResponse),
includeCompensation2015,
isInCredit,
isInDebit,
isUserAuthenticated,
isLTACompleteWithoutKickout,
hasInDates
)
)
)
}
}
}

def onSubmit(): Action[AnyContent] = (identify andThen getData andThen requireData).async { implicit request =>
calculationResultService.submitUserAnswersAndCalculation(request.userAnswers, request.userId).map {
submissionResponse: SubmissionResponse =>
submissionResponse match {
case submission.Success(uniqueId) => Redirect(submitFrontendLandingPageUrl(uniqueId))
case submission.Failure(_) => Redirect(routes.JourneyRecoveryController.onPageLoad())
}
def onSubmit(): Action[AnyContent] =
(identify andThen getData andThen requireData andThen requireTasksCompleted).async { implicit request =>
calculationResultService.submitUserAnswersAndCalculation(request.userAnswers, request.userId).map {
submissionResponse: SubmissionResponse =>
submissionResponse match {
case submission.Success(uniqueId) => Redirect(submitFrontendLandingPageUrl(uniqueId))
case submission.Failure(_) => Redirect(routes.JourneyRecoveryController.onPageLoad())
}
}
}
}

private def submitFrontendLandingPageUrl(uniqueId: String) =
s"${config.submitFrontend}/landing-page?submissionUniqueId=$uniqueId"
Expand Down
74 changes: 41 additions & 33 deletions app/controllers/CalculationReviewIndividualAAController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@
package controllers

import config.FrontendAppConfig
import controllers.actions._
import controllers.actions.{IsRevelantPeriodAction, _}
import models.CalculationResults.IndividualAASummaryModel
import models.Period
import models.{Period, UserAnswers}
import models.tasklist.sections.AASection
import pages.annualallowance.preaaquestions.StopPayingPublicPensionPage
import play.api.data.Form
import play.api.data.Forms.ignored
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import services.CalculationResultService
import services.{CalculationResultService, PeriodService, TaskListService}
import uk.gov.hmrc.http.HeaderCarrier
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
import uk.gov.hmrc.play.http.HeaderCarrierConverter
import views.html.CalculationReviewIndividualAAView

import java.time.LocalDate
import javax.inject.Inject
import scala.concurrent.{ExecutionContext, Future}

Expand All @@ -41,45 +44,50 @@ class CalculationReviewIndividualAAController @Inject() (
val controllerComponents: MessagesControllerComponents,
view: CalculationReviewIndividualAAView,
calculationResultService: CalculationResultService,
requireTasksCompleted: RequireTasksCompletedAction,
isRelevantPeriod: IsRevelantPeriodAction,
config: FrontendAppConfig
)(implicit ec: ExecutionContext)
extends FrontendBaseController
with I18nSupport {

val form = Form("_" -> ignored(()))

def onPageLoad(period: Period): Action[AnyContent] = (identify andThen getData andThen requireData).async {
implicit request =>
implicit val hc: HeaderCarrier = HeaderCarrierConverter.fromRequestAndSession(request, request.session)
def onPageLoad(period: Period): Action[AnyContent] =
(identify andThen getData andThen requireData andThen requireTasksCompleted andThen isRelevantPeriod(period))
.async { implicit request =>
implicit val hc: HeaderCarrier = HeaderCarrierConverter.fromRequestAndSession(request, request.session)

calculationResultService.sendRequest(request.userAnswers).flatMap { calculationResponse =>
val allYears: Seq[IndividualAASummaryModel] =
calculationResultService.individualAASummaryModel(calculationResponse)
val individualYear: IndividualAASummaryModel = allYears.find(year => year.period == period).get
calculationResultService
.calculationReviewIndividualAAViewModel(calculationResponse, Some(period.toString()), request.userAnswers)
.map { calculationReviewIndividualAAViewModel =>
val isInCredit: Boolean = calculationResponse.totalAmounts.inDatesCredit > 0
val isInDebit: Boolean = calculationResponse.totalAmounts.inDatesDebit > 0
val outDates: List[Period] = List(Period._2016, Period._2017, Period._2018, Period._2019)
val isOutDate: Boolean = outDates.contains(individualYear.period)
Ok(
view(
form,
period.toString(),
calculationReviewIndividualAAViewModel,
isInCredit,
isInDebit,
individualYear,
isOutDate,
routes.CalculationReviewController.onPageLoad()
calculationResultService.sendRequest(request.userAnswers).flatMap { calculationResponse =>
val allYears: Seq[IndividualAASummaryModel] =
calculationResultService.individualAASummaryModel(calculationResponse)
val individualYear: IndividualAASummaryModel = allYears.find(year => year.period == period).get
calculationResultService
.calculationReviewIndividualAAViewModel(calculationResponse, Some(period.toString()), request.userAnswers)
.map { calculationReviewIndividualAAViewModel =>
val isInCredit: Boolean = calculationResponse.totalAmounts.inDatesCredit > 0
val isInDebit: Boolean = calculationResponse.totalAmounts.inDatesDebit > 0
val outDates: List[Period] = List(Period._2016, Period._2017, Period._2018, Period._2019)
val isOutDate: Boolean = outDates.contains(individualYear.period)
Ok(
view(
form,
period.toString(),
calculationReviewIndividualAAViewModel,
isInCredit,
isInDebit,
individualYear,
isOutDate,
routes.CalculationReviewController.onPageLoad()
)
)
)
}
}
}
}
}

def onSubmit(): Action[AnyContent] = (identify andThen getData andThen requireData).async { implicit request =>
Future.successful(Redirect(routes.CalculationReviewController.onPageLoad()))
}
def onSubmit(period: Period): Action[AnyContent] =
(identify andThen getData andThen requireData andThen requireTasksCompleted andThen isRelevantPeriod(period))
.async { implicit request =>
Future.successful(Redirect(routes.CalculationReviewController.onPageLoad()))
}
}
39 changes: 39 additions & 0 deletions app/controllers/OutstandingTasksController.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 controllers

import controllers.actions._
import javax.inject.Inject
import play.api.i18n.{I18nSupport, MessagesApi}
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
import views.html.OutstandingTasksView

class OutstandingTasksController @Inject() (
override val messagesApi: MessagesApi,
identify: IdentifierAction,
getData: DataRetrievalAction,
requireData: DataRequiredAction,
val controllerComponents: MessagesControllerComponents,
view: OutstandingTasksView
) extends FrontendBaseController
with I18nSupport {

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

0 comments on commit 74f5a90

Please sign in to comment.