-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from hmrc/VEIOSS-569
VEIOSS-569 | Correction Check Your Answers needs adding to Returns
- Loading branch information
Showing
13 changed files
with
469 additions
and
2 deletions.
There are no files selected for viewing
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
100 changes: 100 additions & 0 deletions
100
app/controllers/corrections/CheckVatPayableAmountController.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,100 @@ | ||
/* | ||
* 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.corrections | ||
|
||
import controllers.actions._ | ||
import models.Index | ||
import models.corrections.CorrectionToCountry | ||
import pages.Waypoints | ||
import pages.corrections.{CorrectionCountryPage, CorrectionReturnPeriodPage} | ||
import play.api.i18n.{I18nSupport, MessagesApi} | ||
import play.api.mvc.{Action, AnyContent, MessagesControllerComponents} | ||
import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController | ||
import utils.CompletionChecks | ||
import utils.FutureSyntax.FutureOps | ||
import viewmodels.checkAnswers.corrections.{CountryVatCorrectionSummary, NewVatTotalSummary, PreviousVatTotalSummary} | ||
import viewmodels.govuk.summarylist._ | ||
import views.html.corrections.CheckVatPayableAmountView | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.ExecutionContext | ||
|
||
class CheckVatPayableAmountController @Inject()( | ||
override val messagesApi: MessagesApi, | ||
cc: AuthenticatedControllerComponents, | ||
view: CheckVatPayableAmountView | ||
)(implicit ec: ExecutionContext) extends FrontendBaseController with CompletionChecks with I18nSupport with CorrectionBaseController { | ||
|
||
protected val controllerComponents: MessagesControllerComponents = cc | ||
|
||
def onPageLoad(waypoints: Waypoints, periodIndex: Index, countryIndex: Index): Action[AnyContent] = cc.authAndGetDataAndCorrectionEligible().async { | ||
implicit request => | ||
|
||
val period = request.userAnswers.period | ||
val correctionPeriod = request.userAnswers.get(CorrectionReturnPeriodPage(periodIndex)) | ||
val selectedCountry = request.userAnswers.get(CorrectionCountryPage(periodIndex, countryIndex)) | ||
|
||
(correctionPeriod, selectedCountry) match { | ||
case (Some(correctionPeriod), Some(country)) => | ||
getPreviouslyDeclaredCorrectionAnswers(waypoints, periodIndex, countryIndex) { originalAmount => | ||
|
||
val summaryList = SummaryListViewModel( | ||
rows = Seq( | ||
Some(PreviousVatTotalSummary.row(originalAmount.amount)), | ||
CountryVatCorrectionSummary.row(request.userAnswers, waypoints, periodIndex, countryIndex), | ||
NewVatTotalSummary.row(request.userAnswers, periodIndex, countryIndex, originalAmount.amount) | ||
).flatten | ||
) | ||
|
||
withCompleteDataAsync[CorrectionToCountry]( | ||
periodIndex, | ||
data = getIncompleteCorrections _, | ||
onFailure = (_: Seq[CorrectionToCountry]) => { | ||
Ok(view( | ||
waypoints, | ||
period, | ||
summaryList, | ||
country, | ||
correctionPeriod, | ||
periodIndex, | ||
countryIndex, | ||
countryCorrectionComplete = false | ||
)).toFuture | ||
}) { | ||
Ok(view(waypoints, period, summaryList, country, correctionPeriod, periodIndex, countryIndex, countryCorrectionComplete = true)).toFuture | ||
} | ||
} | ||
case _ => | ||
Redirect(controllers.routes.JourneyRecoveryController.onPageLoad()).toFuture | ||
} | ||
} | ||
|
||
def onSubmit(waypoints: Waypoints, periodIndex: Index, countryIndex: Index, incompletePromptShown: Boolean): Action[AnyContent] = | ||
cc.authAndGetDataAndCorrectionEligible() { | ||
implicit request => | ||
val incomplete = getIncompleteCorrectionsToCountry(periodIndex, countryIndex) | ||
if(incomplete.isEmpty) { | ||
Redirect(controllers.corrections.routes.CorrectionListCountriesController.onPageLoad(waypoints, periodIndex)) | ||
} else { | ||
if(incompletePromptShown) { | ||
Redirect(routes.CorrectionCountryController.onPageLoad(waypoints, periodIndex, countryIndex)) | ||
} else { | ||
Redirect(routes.CheckVatPayableAmountController.onPageLoad(waypoints, periodIndex, countryIndex)) | ||
} | ||
} | ||
} | ||
} |
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,28 @@ | ||
/* | ||
* 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 pages.corrections | ||
|
||
import models.Index | ||
import pages.{Page, Waypoints} | ||
import play.api.mvc.Call | ||
|
||
case class CheckVatPayableAmountPage(periodIndex: Index, countryIndex: Index) extends Page { | ||
|
||
override def route(waypoints: Waypoints): Call = | ||
controllers.corrections.routes.CheckVatPayableAmountController.onPageLoad(waypoints, periodIndex, countryIndex) | ||
|
||
} |
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
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
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
52 changes: 52 additions & 0 deletions
52
app/viewmodels/checkAnswers/corrections/CountryVatCorrectionSummary.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,52 @@ | ||
/* | ||
* 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 viewmodels.checkAnswers.corrections | ||
|
||
import models.{Index, UserAnswers} | ||
import pages.Waypoints | ||
import pages.corrections.VatAmountCorrectionCountryPage | ||
import play.api.i18n.Messages | ||
import play.twirl.api.Html | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.content.HtmlContent | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow | ||
import viewmodels.govuk.all.currencyFormat | ||
import viewmodels.govuk.summarylist._ | ||
import viewmodels.implicits._ | ||
|
||
object CountryVatCorrectionSummary { | ||
|
||
def row(answers: UserAnswers, waypoints: Waypoints, periodIndex: Index, countryIndex: Index)(implicit messages: Messages): Option[SummaryListRow] = { | ||
answers.get(VatAmountCorrectionCountryPage(periodIndex, countryIndex)).map { | ||
answer => | ||
|
||
SummaryListRowViewModel( | ||
key = "vatAmountCorrectionCountry.checkYourAnswersLabel", | ||
value = ValueViewModel(HtmlContent(Html(currencyFormat(answer)))), | ||
actions = Seq( | ||
ActionItemViewModel( | ||
"site.change", | ||
controllers.corrections.routes.VatAmountCorrectionCountryController.onPageLoad( | ||
waypoints, periodIndex, countryIndex | ||
).url | ||
).withVisuallyHiddenText(messages("vatAmountCorrectionCountry.change.hidden")) | ||
.withAttribute(("id", "change-correction-amount")) | ||
) | ||
) | ||
} | ||
|
||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
app/viewmodels/checkAnswers/corrections/NewVatTotalSummary.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,43 @@ | ||
/* | ||
* 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 viewmodels.checkAnswers.corrections | ||
|
||
import models.{Index, UserAnswers} | ||
import pages.corrections.VatAmountCorrectionCountryPage | ||
import play.api.i18n.Messages | ||
import play.twirl.api.Html | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.content.HtmlContent | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow | ||
import viewmodels.govuk.all.currencyFormat | ||
import viewmodels.govuk.summarylist._ | ||
import viewmodels.implicits._ | ||
|
||
object NewVatTotalSummary { | ||
|
||
def row(answers: UserAnswers, periodIndex: Index, countryIndex: Index, originalAmount: BigDecimal)(implicit messages: Messages): Option[SummaryListRow] = { | ||
answers.get(VatAmountCorrectionCountryPage(periodIndex, countryIndex)).map { | ||
answer => | ||
|
||
SummaryListRowViewModel( | ||
key = "checkVatPayableAmount.newVatTotal.checkYourAnswersLabel", | ||
value = ValueViewModel(HtmlContent(Html(currencyFormat(answer + originalAmount)))), | ||
actions = Seq.empty | ||
) | ||
} | ||
|
||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
app/viewmodels/checkAnswers/corrections/PreviousVatTotalSummary.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,37 @@ | ||
/* | ||
* 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 viewmodels.checkAnswers.corrections | ||
|
||
|
||
import play.api.i18n.Messages | ||
import play.twirl.api.Html | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.content.HtmlContent | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow | ||
import viewmodels.govuk.all.currencyFormat | ||
import viewmodels.govuk.summarylist._ | ||
import viewmodels.implicits._ | ||
|
||
object PreviousVatTotalSummary { | ||
|
||
def row(originalAmount: BigDecimal)(implicit messages: Messages): SummaryListRow = | ||
|
||
SummaryListRowViewModel( | ||
key = "checkVatPayableAmount.previousVatTotal.checkYourAnswersLabel", | ||
value = ValueViewModel(HtmlContent(Html(currencyFormat(originalAmount)))), | ||
actions = Seq.empty | ||
) | ||
} |
73 changes: 73 additions & 0 deletions
73
app/views/corrections/CheckVatPayableAmountView.scala.html
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,73 @@ | ||
@* | ||
* 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. | ||
*@ | ||
|
||
@this( | ||
layout: templates.Layout, | ||
govukSummaryList: GovukSummaryList, | ||
govukButton: GovukButton, | ||
formHelper: FormWithCSRF, | ||
govukWarningText: GovukWarningText, | ||
button: ButtonGroup | ||
) | ||
|
||
@( | ||
waypoints: Waypoints, | ||
period: Period, | ||
summaryList: SummaryList, | ||
country: Country, | ||
correctionPeriod: Period, | ||
periodIndex: Index, | ||
countryIndex: Index, | ||
countryCorrectionComplete: Boolean | ||
)(implicit request: Request[_], messages: Messages) | ||
|
||
@layout(pageTitle = titleNoForm(messages("checkVatPayableAmount.title"))) { | ||
|
||
<header class="hmrc-page-heading"> | ||
<p class="govuk-caption-l hmrc-caption-l">@messages("checkVatPayableAmount.caption", correctionPeriod.displayText, country.name)</p> | ||
<h1 class="govuk-heading-l">@messages("checkVatPayableAmount.heading")</h1> | ||
</header> | ||
|
||
@if(!countryCorrectionComplete) { | ||
@govukWarningText(WarningText( | ||
iconFallbackText = Option(messages("site.warning")), | ||
content = Text(messages("error.missing_answers")) | ||
)) | ||
} | ||
|
||
@govukSummaryList(summaryList) | ||
|
||
@if(countryCorrectionComplete) { | ||
@formHelper(action = controllers.corrections.routes.CheckVatPayableAmountController.onSubmit(waypoints, periodIndex, countryIndex, false)) { | ||
|
||
<p class="govuk-!-margin-bottom-9" style="margin-top:50px;"> | ||
<div class="govuk-button-group"> | ||
@button("site.continue", controllers.corrections.routes.CheckVatPayableAmountController.onPageLoad(waypoints, periodIndex, countryIndex).url, period, waypoints | ||
) | ||
</div> | ||
</p> | ||
} | ||
} else { | ||
<h2 class="govuk-heading-m push--top">@messages("error.missing_answers_header")</h2> | ||
<p class="govuk-body">@messages("error.missing_answers_prompt", country.name)</p> | ||
|
||
@formHelper(action = controllers.corrections.routes.CheckVatPayableAmountController.onSubmit(waypoints, periodIndex, countryIndex, true)) { | ||
@govukButton( | ||
ButtonViewModel(messages("error.resolve_missing_answers")) | ||
) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.