-
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 #16 from hmrc/ADR-798
ADR-798 Duty Suspended Received
- Loading branch information
Showing
11 changed files
with
513 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
app/controllers/DeclareDutySuspendedReceivedController.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,72 @@ | ||
/* | ||
* 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 | ||
|
||
import connectors.CacheConnector | ||
import controllers.actions._ | ||
import forms.DeclareDutySuspendedReceivedFormProvider | ||
import javax.inject.Inject | ||
import models.Mode | ||
import navigation.Navigator | ||
import pages.DeclareDutySuspendedReceivedPage | ||
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.DeclareDutySuspendedReceivedView | ||
|
||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class DeclareDutySuspendedReceivedController @Inject() ( | ||
override val messagesApi: MessagesApi, | ||
cacheConnector: CacheConnector, | ||
navigator: Navigator, | ||
identify: IdentifierAction, | ||
getData: DataRetrievalAction, | ||
requireData: DataRequiredAction, | ||
formProvider: DeclareDutySuspendedReceivedFormProvider, | ||
val controllerComponents: MessagesControllerComponents, | ||
view: DeclareDutySuspendedReceivedView | ||
)(implicit ec: ExecutionContext) | ||
extends FrontendBaseController | ||
with I18nSupport { | ||
|
||
val form = formProvider() | ||
|
||
def onPageLoad(mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData) { implicit request => | ||
val preparedForm = request.userAnswers.get(DeclareDutySuspendedReceivedPage) match { | ||
case None => form | ||
case Some(value) => form.fill(value) | ||
} | ||
|
||
Ok(view(preparedForm, mode)) | ||
} | ||
|
||
def onSubmit(mode: Mode): Action[AnyContent] = (identify andThen getData andThen requireData).async { | ||
implicit request => | ||
form | ||
.bindFromRequest() | ||
.fold( | ||
formWithErrors => Future.successful(BadRequest(view(formWithErrors, mode))), | ||
value => | ||
for { | ||
updatedAnswers <- | ||
Future.fromTry(request.userAnswers.set(DeclareDutySuspendedReceivedPage, value)) | ||
_ <- cacheConnector.set(updatedAnswers) | ||
} yield Redirect(navigator.nextPage(DeclareDutySuspendedReceivedPage, mode, updatedAnswers)) | ||
) | ||
} | ||
} |
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 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 forms | ||
|
||
import forms.mappings.Mappings | ||
import javax.inject.Inject | ||
import play.api.data.Form | ||
|
||
class DeclareDutySuspendedReceivedFormProvider @Inject() extends Mappings { | ||
|
||
def apply(): Form[BigDecimal] = | ||
Form( | ||
"declare-duty-suspended-received-input" -> bigDecimal( | ||
"declareDutySuspendedReceived.error.required", | ||
"declareDutySuspendedReceived.error.nonNumeric", | ||
"declareDutySuspendedReceived.error.twoDecimalPlaces" | ||
) | ||
.verifying(minimumValue(BigDecimal(0.00), "declareDutySuspendedReceived.error.minimumRequired")) | ||
.verifying( | ||
maximumValue(BigDecimal(999999999.99), "declareDutySuspendedReceived.error.maximumRequired") | ||
) | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 pages | ||
|
||
import play.api.libs.json.JsPath | ||
|
||
case object DeclareDutySuspendedReceivedPage extends QuestionPage[BigDecimal] { | ||
|
||
override def path: JsPath = JsPath \ toString | ||
|
||
override def toString: String = "declareDutySuspendedReceived" | ||
} |
40 changes: 40 additions & 0 deletions
40
app/viewmodels/checkAnswers/DeclareDutySuspendedReceivedSummary.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,40 @@ | ||
/* | ||
* 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 viewmodels.checkAnswers | ||
|
||
import controllers.routes | ||
import models.{CheckMode, UserAnswers} | ||
import pages.DeclareDutySuspendedReceivedPage | ||
import play.api.i18n.Messages | ||
import uk.gov.hmrc.govukfrontend.views.viewmodels.summarylist.SummaryListRow | ||
import viewmodels.govuk.summarylist._ | ||
import viewmodels.implicits._ | ||
|
||
object DeclareDutySuspendedReceivedSummary { | ||
|
||
def row(answers: UserAnswers)(implicit messages: Messages): Option[SummaryListRow] = | ||
answers.get(DeclareDutySuspendedReceivedPage).map { answer => | ||
SummaryListRowViewModel( | ||
key = "declareDutySuspendedReceived.checkYourAnswersLabel", | ||
value = ValueViewModel(answer.toString), | ||
actions = Seq( | ||
ActionItemViewModel("site.change", routes.DeclareDutySuspendedReceivedController.onPageLoad(CheckMode).url) | ||
.withVisuallyHiddenText(messages("declareDutySuspendedReceived.change.hidden")) | ||
) | ||
) | ||
} | ||
} |
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. | ||
*@ | ||
|
||
@import viewmodels.InputWidth._ | ||
@import components.{Link, SectionHeading, PageHeading} | ||
@import uk.gov.hmrc.govukfrontend.views.viewmodels.content.Empty | ||
|
||
@this( | ||
layout: templates.Layout, | ||
formHelper: FormWithCSRF, | ||
govukErrorSummary: GovukErrorSummary, | ||
govukInput: GovukInput, | ||
govukButton: GovukButton, | ||
sectionHeading: SectionHeading, | ||
pageHeading: PageHeading | ||
) | ||
|
||
@(form: Form[_], mode: Mode)(implicit request: Request[_], messages: Messages) | ||
|
||
@layout(pageTitle = title(form, messages("declareDutySuspendedReceived.title"))) { | ||
|
||
@formHelper(action = routes.DeclareDutySuspendedReceivedController.onSubmit(mode), Symbol("autoComplete") -> "off") { | ||
|
||
@if(form.errors.nonEmpty) { | ||
@govukErrorSummary(ErrorSummaryViewModel(form)) | ||
} | ||
|
||
@sectionHeading( | ||
id = "declare-duty-suspended-received-section", | ||
text = messages("section.alcoholDutyReturn"), | ||
) | ||
|
||
@pageHeading(messages("declareDutySuspendedReceived.heading")) | ||
|
||
<p class="govuk-body">@messages("declareDutySuspendedReceived.p1")</p> | ||
<ul class="govuk-list govuk-list--bullet"> | ||
<li>@messages("declareDutySuspendedReceived.para.list.1")</li> | ||
<li>@messages("declareDutySuspendedReceived.para.list.2")</li> | ||
</ul> | ||
<p class="govuk-body">@messages("declareDutySuspendedReceived.p2")</p> | ||
|
||
@govukInput( | ||
InputViewModel( | ||
field = form("declare-duty-suspended-received-input"), | ||
label = LabelViewModel(messages("declareDutySuspendedReceived.heading")).asVisuallyHidden(), | ||
) | ||
.asNumeric() | ||
.withWidth(Fixed10) | ||
.withSuffix(PrefixOrSuffix(content = messages("declareDutySuspendedReceived.inputSuffix"))) | ||
.withHint(Hint(content = messages("declareDutySuspendedReceived.hint"))) | ||
|
||
) | ||
|
||
@govukButton( | ||
ButtonViewModel("saveAndContinueButton", messages("site.saveAndContinue")) | ||
) | ||
} | ||
} |
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.