Skip to content

Commit

Permalink
Merge pull request #16 from hmrc/ADR-798
Browse files Browse the repository at this point in the history
ADR-798 Duty Suspended Received
  • Loading branch information
sini-george authored Dec 13, 2023
2 parents e9c358d + 7652e92 commit dcb993a
Show file tree
Hide file tree
Showing 11 changed files with 513 additions and 0 deletions.
72 changes: 72 additions & 0 deletions app/controllers/DeclareDutySuspendedReceivedController.scala
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))
)
}
}
37 changes: 37 additions & 0 deletions app/forms/DeclareDutySuspendedReceivedFormProvider.scala
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")
)
)
}
1 change: 1 addition & 0 deletions app/navigation/Navigator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Navigator @Inject() () {
case DraughtReliefQuestionPage => _ => routes.SmallProducerReliefQuestionController.onPageLoad(NormalMode)
case DeclareDutySuspendedDeliveriesOutsideUkPage =>
_ => routes.DutySuspendedDeliveriesController.onPageLoad(NormalMode)
case DutySuspendedDeliveriesPage => _ => routes.DeclareDutySuspendedReceivedController.onPageLoad(NormalMode)
case _ =>
_ => routes.IndexController.onPageLoad

Expand Down
26 changes: 26 additions & 0 deletions app/pages/DeclareDutySuspendedReceivedPage.scala
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"
}
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"))
)
)
}
}
71 changes: 71 additions & 0 deletions app/views/DeclareDutySuspendedReceivedView.scala.html
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"))
)
}
}
5 changes: 5 additions & 0 deletions conf/app.routes
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ POST /declareDutySuspendedDeliveriesOutsideUk controllers
GET /changeDeclareDutySuspendedDeliveriesOutsideUk controllers.DeclareDutySuspendedDeliveriesOutsideUkController.onPageLoad(mode: Mode = CheckMode)
POST /changeDeclareDutySuspendedDeliveriesOutsideUk controllers.DeclareDutySuspendedDeliveriesOutsideUkController.onSubmit(mode: Mode = CheckMode)

GET /declareDutySuspendedReceived controllers.DeclareDutySuspendedReceivedController.onPageLoad(mode: Mode = NormalMode)
POST /declareDutySuspendedReceived controllers.DeclareDutySuspendedReceivedController.onSubmit(mode: Mode = NormalMode)
GET /changeDeclareDutySuspendedReceived controllers.DeclareDutySuspendedReceivedController.onPageLoad(mode: Mode = CheckMode)
POST /changeDeclareDutySuspendedReceived controllers.DeclareDutySuspendedReceivedController.onSubmit(mode: Mode = CheckMode)

GET /dutySuspendedDeliveries controllers.DutySuspendedDeliveriesController.onPageLoad(mode: Mode = NormalMode)
POST /dutySuspendedDeliveries controllers.DutySuspendedDeliveriesController.onSubmit(mode: Mode = NormalMode)
GET /dutySuspendedDeliveries controllers.DutySuspendedDeliveriesController.onPageLoad(mode: Mode = CheckMode)
Expand Down
17 changes: 17 additions & 0 deletions conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ declareDutySuspendedDeliveriesOutsideUk.inputSuffix = litres
declareDutySuspendedDeliveriesOutsideUk.p1 = This includes to sites in EU countries, sites in countries outside of the EU and ship stores. This will not change your duty calculation.
declareDutySuspendedDeliveriesOutsideUk.hint = Give your answers in litres, to 2 decimal places.

declareDutySuspendedReceived.title = How much have you received duty suspended?
declareDutySuspendedReceived.heading = How much have you received duty suspended?
declareDutySuspendedReceived.checkYourAnswersLabel = DeclareDutySuspendedReceived
declareDutySuspendedReceived.error.nonNumeric = How much you have received duty suspended must be a number
declareDutySuspendedReceived.error.required = Enter how much you have received duty suspended
declareDutySuspendedReceived.error.twoDecimalPlaces = How much you have received duty suspended must be a number to 2 decimal places
declareDutySuspendedReceived.inputSuffix = litres
declareDutySuspendedReceived.change.hidden = DeclareDutySuspendedReceived
declareDutySuspendedReceived.hint = Give your answers in litres, to 2 decimal places.
declareDutySuspendedReceived.error.minimumRequired = How much you have received duty suspended must be 0.00 or more
declareDutySuspendedReceived.error.maximumRequired = How much you have received duty suspended must be 999999999.99 or less
declareDutySuspendedReceived.p1 = For example, because:
declareDutySuspendedReceived.p2 = This will not change your duty calculation.
declareDutySuspendedReceived.para.list.1 = you received it from a UK site that is registered to send it duty suspended
declareDutySuspendedReceived.para.list.2 = the beer is imported and all duties have already been paid

dutySuspendedDeliveries.title = How much have you delivered duty suspended within the UK?
dutySuspendedDeliveries.heading = How much have you delivered duty suspended within the UK?
dutySuspendedDeliveries.p1 = For example, to UK sites that are registered to hold it duty suspended. This will not change your duty calculation.
Expand All @@ -134,3 +150,4 @@ dutySuspendedDeliveries.error.minimumRequired = How much you have delivered duty
dutySuspendedDeliveries.error.maximumRequired = How much you have delivered duty suspended must be 999999999.99 or less
dutySuspendedDeliveries.error.twoDecimalPlaces = How much you have delivered duty suspended must be a number to 2 decimal places
dutySuspendedDeliveries.change.hidden = Duty Suspended Deliveries

Loading

0 comments on commit dcb993a

Please sign in to comment.