-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MCSC-298 Create AA Scheme Details/PIA Placeholder Screens
- Loading branch information
Dan Corbin
authored
Jun 13, 2023
1 parent
0e18df3
commit cc4b3be
Showing
80 changed files
with
4,240 additions
and
241 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
app/controllers/annualallowance/taxyear/AddAnotherSchemeController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package controllers.annualallowance.taxyear | ||
|
||
import controllers.actions._ | ||
import forms.annualallowance.taxyear.AddAnotherSchemeFormProvider | ||
import models.{Mode, Period, SchemeIndex} | ||
import pages.annualallowance.taxyear.AddAnotherSchemePage | ||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import repositories.SessionRepository | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController | ||
import views.html.annualallowance.taxyear.AddAnotherSchemeView | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class AddAnotherSchemeController @Inject() ( | ||
override val messagesApi: MessagesApi, | ||
sessionRepository: SessionRepository, | ||
identify: IdentifierAction, | ||
getData: DataRetrievalAction, | ||
requireData: DataRequiredAction, | ||
formProvider: AddAnotherSchemeFormProvider, | ||
val controllerComponents: MessagesControllerComponents, | ||
view: AddAnotherSchemeView | ||
)(implicit ec: ExecutionContext) | ||
extends FrontendBaseController | ||
with I18nSupport { | ||
|
||
val form = formProvider() | ||
|
||
def onPageLoad(mode: Mode, period: Period, schemeIndex: SchemeIndex): Action[AnyContent] = | ||
(identify andThen getData andThen requireData) { implicit request => | ||
val preparedForm = request.userAnswers.get(AddAnotherSchemePage(period, schemeIndex)) match { | ||
case None => form | ||
case Some(value) => form.fill(value) | ||
} | ||
|
||
Ok(view(preparedForm, mode, period, schemeIndex)) | ||
} | ||
|
||
def onSubmit(mode: Mode, period: Period, schemeIndex: SchemeIndex): Action[AnyContent] = | ||
(identify andThen getData andThen requireData).async { implicit request => | ||
form | ||
.bindFromRequest() | ||
.fold( | ||
formWithErrors => Future.successful(BadRequest(view(formWithErrors, mode, period, schemeIndex))), | ||
value => | ||
for { | ||
updatedAnswers <- | ||
Future.fromTry(request.userAnswers.set(AddAnotherSchemePage(period, schemeIndex), value)) | ||
_ <- sessionRepository.set(updatedAnswers) | ||
} yield Redirect(AddAnotherSchemePage(period, schemeIndex).navigate(mode, updatedAnswers)) | ||
) | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
app/controllers/annualallowance/taxyear/CheckYourAAPeriodAnswersController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package controllers.annualallowance.taxyear | ||
|
||
import com.google.inject.Inject | ||
import controllers.actions.{DataRequiredAction, DataRetrievalAction, IdentifierAction} | ||
import models.{Period, SchemeIndex} | ||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController | ||
import viewmodels.checkAnswers.annualallowance.taxyear.{PayAChargeSummary, PensionSchemeDetailsSummary, PensionSchemeInputAmountsSummary} | ||
import viewmodels.govuk.summarylist._ | ||
import views.html.CheckYourAnswersView | ||
|
||
class CheckYourAAPeriodAnswersController @Inject() ( | ||
override val messagesApi: MessagesApi, | ||
identify: IdentifierAction, | ||
getData: DataRetrievalAction, | ||
requireData: DataRequiredAction, | ||
val controllerComponents: MessagesControllerComponents, | ||
view: CheckYourAnswersView | ||
) extends FrontendBaseController | ||
with I18nSupport { | ||
|
||
def onPageLoad(period: Period): Action[AnyContent] = (identify andThen getData andThen requireData) { | ||
implicit request => | ||
val schemeIndices = 0.to(4).map(i => SchemeIndex(i)) | ||
|
||
val rows: Seq[Option[SummaryListRow]] = schemeIndices.flatMap(index => | ||
Seq( | ||
PensionSchemeDetailsSummary.row(request.userAnswers, period, index), | ||
PensionSchemeInputAmountsSummary.row(request.userAnswers, period, index), | ||
PayAChargeSummary.row(request.userAnswers, period, index) | ||
) | ||
) | ||
|
||
Ok( | ||
view( | ||
s"checkYourAnswers.aa.period.subHeading.$period", | ||
controllers.routes.TaskListController.onPageLoad, | ||
SummaryListViewModel(rows.flatten) | ||
) | ||
) | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
app/controllers/annualallowance/taxyear/MemberMoreThanOnePensionController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package controllers.annualallowance.taxyear | ||
|
||
import controllers.actions._ | ||
import forms.annualallowance.taxyear.MemberMoreThanOnePensionFormProvider | ||
import models.{Mode, Period} | ||
import pages.annualallowance.taxyear.MemberMoreThanOnePensionPage | ||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import repositories.SessionRepository | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController | ||
import views.html.annualallowance.taxyear.MemberMoreThanOnePensionView | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class MemberMoreThanOnePensionController @Inject() ( | ||
override val messagesApi: MessagesApi, | ||
sessionRepository: SessionRepository, | ||
identify: IdentifierAction, | ||
getData: DataRetrievalAction, | ||
requireData: DataRequiredAction, | ||
formProvider: MemberMoreThanOnePensionFormProvider, | ||
val controllerComponents: MessagesControllerComponents, | ||
view: MemberMoreThanOnePensionView | ||
)(implicit ec: ExecutionContext) | ||
extends FrontendBaseController | ||
with I18nSupport { | ||
|
||
val form = formProvider() | ||
|
||
def onPageLoad(mode: Mode, period: Period): Action[AnyContent] = (identify andThen getData andThen requireData) { | ||
implicit request => | ||
if (period.isAAPeriod) { | ||
val preparedForm = request.userAnswers.get(MemberMoreThanOnePensionPage(period)) match { | ||
case None => form | ||
case Some(value) => form.fill(value) | ||
} | ||
|
||
Ok(view(preparedForm, mode, period)) | ||
} else BadRequest(view(form.withGlobalError("error.invalid_aa_period"), mode, period)) | ||
} | ||
|
||
def onSubmit(mode: Mode, period: Period): Action[AnyContent] = (identify andThen getData andThen requireData).async { | ||
implicit request => | ||
if (period.isAAPeriod) { | ||
form | ||
.bindFromRequest() | ||
.fold( | ||
formWithErrors => Future.successful(BadRequest(view(formWithErrors, mode, period))), | ||
value => | ||
for { | ||
updatedAnswers <- Future.fromTry(request.userAnswers.set(MemberMoreThanOnePensionPage(period), value)) | ||
_ <- sessionRepository.set(updatedAnswers) | ||
} yield Redirect(MemberMoreThanOnePensionPage(period).navigate(mode, updatedAnswers)) | ||
) | ||
} else Future.successful(BadRequest(view(form.withGlobalError("error.invalid_aa_period"), mode, period))) | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
app/controllers/annualallowance/taxyear/PayAChargeController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package controllers.annualallowance.taxyear | ||
|
||
import controllers.actions._ | ||
import forms.annualallowance.taxyear.PayAChargeFormProvider | ||
import models.{Mode, Period, SchemeIndex} | ||
import pages.annualallowance.taxyear.PayAChargePage | ||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import repositories.SessionRepository | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController | ||
import views.html.annualallowance.taxyear.PayAChargeView | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class PayAChargeController @Inject() ( | ||
override val messagesApi: MessagesApi, | ||
sessionRepository: SessionRepository, | ||
identify: IdentifierAction, | ||
getData: DataRetrievalAction, | ||
requireData: DataRequiredAction, | ||
formProvider: PayAChargeFormProvider, | ||
val controllerComponents: MessagesControllerComponents, | ||
view: PayAChargeView | ||
)(implicit ec: ExecutionContext) | ||
extends FrontendBaseController | ||
with I18nSupport { | ||
|
||
val form = formProvider() | ||
|
||
def onPageLoad(mode: Mode, period: Period, schemeIndex: SchemeIndex): Action[AnyContent] = | ||
(identify andThen getData andThen requireData) { implicit request => | ||
val preparedForm = request.userAnswers.get(PayAChargePage(period, schemeIndex)) match { | ||
case None => form | ||
case Some(value) => form.fill(value) | ||
} | ||
|
||
Ok(view(preparedForm, mode, period, schemeIndex)) | ||
} | ||
|
||
def onSubmit(mode: Mode, period: Period, schemeIndex: SchemeIndex): Action[AnyContent] = | ||
(identify andThen getData andThen requireData).async { implicit request => | ||
form | ||
.bindFromRequest() | ||
.fold( | ||
formWithErrors => Future.successful(BadRequest(view(formWithErrors, mode, period, schemeIndex))), | ||
value => | ||
for { | ||
updatedAnswers <- Future.fromTry(request.userAnswers.set(PayAChargePage(period, schemeIndex), value)) | ||
_ <- sessionRepository.set(updatedAnswers) | ||
} yield Redirect(PayAChargePage(period, schemeIndex).navigate(mode, updatedAnswers)) | ||
) | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
app/controllers/annualallowance/taxyear/PensionSchemeDetailsController.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package controllers.annualallowance.taxyear | ||
|
||
import controllers.actions._ | ||
import forms.annualallowance.taxyear.PensionSchemeDetailsFormProvider | ||
import models.{Mode, Period, SchemeIndex} | ||
import pages.annualallowance.taxyear.PensionSchemeDetailsPage | ||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import repositories.SessionRepository | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController | ||
import views.html.annualallowance.taxyear.PensionSchemeDetailsView | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class PensionSchemeDetailsController @Inject() ( | ||
override val messagesApi: MessagesApi, | ||
sessionRepository: SessionRepository, | ||
identify: IdentifierAction, | ||
getData: DataRetrievalAction, | ||
requireData: DataRequiredAction, | ||
formProvider: PensionSchemeDetailsFormProvider, | ||
val controllerComponents: MessagesControllerComponents, | ||
view: PensionSchemeDetailsView | ||
)(implicit ec: ExecutionContext) | ||
extends FrontendBaseController | ||
with I18nSupport { | ||
|
||
val form = formProvider() | ||
|
||
def onPageLoad(mode: Mode, period: Period, schemeIndex: SchemeIndex): Action[AnyContent] = | ||
(identify andThen getData andThen requireData) { implicit request => | ||
val preparedForm = request.userAnswers.get(PensionSchemeDetailsPage(period, schemeIndex)) match { | ||
case None => form | ||
case Some(value) => form.fill(value) | ||
} | ||
|
||
Ok(view(preparedForm, mode, period, schemeIndex)) | ||
} | ||
|
||
def onSubmit(mode: Mode, period: Period, schemeIndex: SchemeIndex): Action[AnyContent] = | ||
(identify andThen getData andThen requireData).async { implicit request => | ||
form | ||
.bindFromRequest() | ||
.fold( | ||
formWithErrors => Future.successful(BadRequest(view(formWithErrors, mode, period, schemeIndex))), | ||
value => | ||
for { | ||
updatedAnswers <- | ||
Future.fromTry(request.userAnswers.set(PensionSchemeDetailsPage(period, schemeIndex), value)) | ||
_ <- sessionRepository.set(updatedAnswers) | ||
} yield Redirect(PensionSchemeDetailsPage(period, schemeIndex).navigate(mode, updatedAnswers)) | ||
) | ||
} | ||
} |
Oops, something went wrong.