Skip to content

Commit

Permalink
ADR-1061 All css classes and business constant values to be put in Co…
Browse files Browse the repository at this point in the history
…nstants file (#205)

* ADR-1061 constants refactor

* ADR-1061 Various fixes

* ADR-1227 Fix test data

* ADR-1061 Fix link CSS
  • Loading branch information
davidfes authored Nov 14, 2024
1 parent ba5e666 commit 397d181
Show file tree
Hide file tree
Showing 97 changed files with 742 additions and 482 deletions.
152 changes: 140 additions & 12 deletions app/config/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,42 @@ package config
import java.time.Month._

object Constants {
val adrReturnCreatedDetails: String = "return-created-details"
val periodKeySessionKey: String = "period-key"
val maximumDecimalPlaces: Int = 2
val volumeAndDutyMinimumValue: BigDecimal = BigDecimal(0.01)
val volumeMaximumValue: BigDecimal = BigDecimal(999999999.99)
val lpaMaximumDecimalPlaces: Int = 4
val lpaMinimumValue: BigDecimal = BigDecimal(0.0001)
val lpaMaximumValue: BigDecimal = BigDecimal(999999999.9999)
val dutyMinimumValue: BigDecimal = BigDecimal(0.00)
val dutyMaximumValue: BigDecimal = BigDecimal(999999999.99)
val dutyDueMaximumValue: BigDecimal = BigDecimal(99999999999.99)
val adrReturnCreatedDetails: String = "return-created-details"
val periodKeySessionKey: String = "period-key"
val pastPaymentsSessionKey: String = "past-payment-amount"

val maximumDecimalPlaces: Int = 2
val volumeMinimumValueIncZero: BigDecimal = BigDecimal(0.00)
val volumeMinimumValue: BigDecimal = BigDecimal(0.01)
val volumeMaximumValue: BigDecimal = BigDecimal(999999999.99)
val quantityMinimumValueIncZero: BigDecimal = BigDecimal(0.00)
val quantityMinimumValue: BigDecimal = BigDecimal(0.01)
val quantityMaximumValue: BigDecimal = BigDecimal(999999999.99)
val dutySuspendedVolumeMinimumValue: BigDecimal = BigDecimal(-999999999.99)
val dutySuspendedVolumeMaximumValue: BigDecimal = BigDecimal(999999999.99)
val lpaMaximumDecimalPlaces: Int = 4
val lpaMinimumValue: BigDecimal = BigDecimal(0.0001)
val lpaMaximumValue: BigDecimal = BigDecimal(999999999.9999)
val dutySuspendedLpaMinimumValue: BigDecimal = BigDecimal(-999999999.9999)
val dutySuspendedLpaMaximumValue: BigDecimal = BigDecimal(999999999.9999)
val dutyMaximumDecimalPlaces: Int = 2
val dutyMinimumValue: BigDecimal = BigDecimal(0.00)
val dutyMaximumValue: BigDecimal = BigDecimal(999999999.99)
val spoiltDutyMinimumValue: BigDecimal = BigDecimal(0.01)
val spoiltDutyMaximumValue: BigDecimal = BigDecimal(99999999999.99)

val overUnderDeclarationThreshold: BigDecimal = BigDecimal(1000) // When a reason is required
val overUnderDeclarationReasonLength: Int = 250

val adjustmentTooEarlyMonth: Int = 7 // Only dates afterward we allow to be adjusted via the service
val adjustmentTooEarlyYear: Int = 2023

val minTaxType = 100 // Although the boundaries will not be valid codes
val maxTaxType = 999

val otherIngredientsUsedMaxLength = 120
val otherMaltedGrainsTypeMaxLength = 120
val otherSpiritsProducedMaxLength = 150

val rowsPerPage = 15

Expand Down Expand Up @@ -62,5 +87,108 @@ object Constants {

val quarterlySpiritsMonths = Set(JANUARY, APRIL, JULY, OCTOBER)

val pastPaymentsSessionKey: String = "past-payment-amount"
object Format {
val numeric = "numeric"
}

object Css {
val bodyCssClass = "govuk-body"

val hintCssClass = "govuk-hint"

val linkNoVisitedStateCssClass = "govuk-link govuk-link--no-visited-state"

val sectionBreakCssClass = "govuk-section-break"
val sectionBreakLCssClass = "govuk-section-break--l"
val sectionBreakVisibleCssClass = "govuk-section-break--visible"

val fullWidthCssClass = "govuk-!-width-full"
val oneQuarterCssClass = "govuk-!-width-one-quarter"
val oneHalfCssClass = "govuk-!-width-one-half"
val threeQuartersCssClass = "govuk-!-width-three-quarters"
val oneThirdCssClass = "govuk-!-width-one-third"
val twoThirdsCssClass = "govuk-!-width-two-thirds"

val textAlignRightCssClass = "text-align-right"
val textAlignRightWrapCssClass = "text-align-right-wrap"

val boldFontCssClass = "govuk-!-font-weight-bold"

val lightBlueTagCssClass = "govuk-tag--light-blue"
val blueTagCssClass = "govuk-tag--blue"
val greenTagCssClass = "govuk-tag--green"
val redTagCssClass = "govuk-tag--red"
val yellowTagCssClass = "govuk-tag--yellow"
val greyTagCssClass = "govuk-tag--grey"
val turquoiseCssClass = "govuk-tag--turquoise"
val purpleCssClass = "govuk-tag--purple"
val pinkCssClass = "govuk-tag--pink"
val orangeCssClass = "govuk-tag--orange"

val headingXLCssClass = "govuk-heading-xl"
val headingLCssClass = "govuk-heading-l"
val headingMCssClass = "govuk-heading-m"
val headingSCssClass = "govuk-heading-s"

val labelXLCssClass = "govuk-label--xl"
val labelLCssClass = "govuk-label--l"
val labelMCssClass = "govuk-label--m"
val labelSCssClass = "govuk-label--s"

val hmrcCaptionXLCssClass = "hmrc-caption-xl"
val captionXLCssClass = "govuk-caption-xl"

val fieldsetLegendXLCssClass = "govuk-fieldset__legend--xl"
val fieldsetLegendLCssClass = "govuk-fieldset__legend--l"
val fieldsetLegendMCssClass = "govuk-fieldset__legend--m"
val fieldsetLegendSCssClass = "govuk-fieldset__legend--s"

val tableCaptionMCssClass = "govuk-table__caption--m"
val tableCaptionLCssClass = "govuk-table__caption--l"

val gridRowCssClass = "govuk-grid-row"
val gridColumnOneThird = "govuk-grid-column-one-third"
val gridColumnTwoThirds = "govuk-grid-column-two-thirds"
val gridColumnFullCssClass = "govuk-grid-column-full"

val numericCellClass = "govuk-table__cell--numeric"

val summaryListNoBorderCssClass = "govuk-summary-list--no-border"
val summaryListRowNoBorderCssClass = "govuk-summary-list__row--no-border"
val summaryListKeyCssClass = "govuk-summary-list__key"
val summaryListValueCssClass = "govuk-summary-list__value"
val summaryListActionsCssClass = "govuk-summary-list__actions"
val summaryListActionsListCssClass = "govuk-summary-list__actions-list"
val summaryListActionsListItemCssClass = "govuk-summary-list__actions-list-item"

val marginTop0CssClass = "govuk-!-margin-top-0"
val marginTop8CssClass = "govuk-!-margin-top-8"
val marginBottom0CssClass = "govuk-!-margin-bottom-0"

val paddingBottomCssClass = "govuk-body govuk-!-padding-bottom-3"

val inputWidth2CssClass = "govuk-input--width-2"
val inputWidth3CssClass = "govuk-input--width-3"
val inputWidth4CssClass = "govuk-input--width-4"
val inputWidth5CssClass = "govuk-input--width-5"
val inputWidth10CssClass = "govuk-input--width-10"
val inputWidth20CssClass = "govuk-input--width-20"
val inputWidth30CssClass = "govuk-input--width-30"

val secondaryButtonCssClass = "govuk-button--secondary"
val warningButtonCssClass = "govuk-button--warning"

val inlineRadiosCssClass = "govuk-radios--inline"

val numberListCssClass = "govuk-list govuk-list--number"
val bulletListCssClass = "govuk-list govuk-list--bullet"

val visuallyHiddenCssClass = "govuk-visually-hidden"

val inputErrorCssClass = "govuk-input--error"

val jsVisibleCssClass = "hmrc-!-js-visible"

val displayNonePrintCssClass = "govuk-!-display-none-print"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package forms.adjustment

import config.Constants
import forms.mappings.Mappings

import javax.inject.Inject
import play.api.data.Form

Expand All @@ -29,6 +31,6 @@ class AdjustmentRepackagedTaxTypeFormProvider @Inject() extends Mappings {
"adjustmentRepackagedTaxType.error.invalid",
"adjustmentRepackagedTaxType.error.invalid"
)
.verifying(inRange(100, 999, "adjustmentRepackagedTaxType.error.invalid"))
.verifying(inRange(Constants.minTaxType, Constants.maxTaxType, "adjustmentRepackagedTaxType.error.invalid"))
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@

package forms.adjustment

import config.Constants
import forms.mappings.Mappings

import javax.inject.Inject
import play.api.data.Form

class AdjustmentSmallProducerReliefDutyRateFormProvider @Inject() extends Mappings {

def apply(): Form[BigDecimal] =
Form(
"adjustment-small-producer-relief-duty-rate-input" -> bigDecimal(
2,
Constants.dutyMaximumDecimalPlaces,
"adjustmentSmallProducerReliefDutyRate.error.required",
"adjustmentSmallProducerReliefDutyRate.error.nonNumeric",
"adjustmentSmallProducerReliefDutyRate.error.decimalPlaces"
)
.verifying(minimumValue(BigDecimal(0.00), "adjustmentSmallProducerReliefDutyRate.error.minimumRequired"))
.verifying(
maximumValue(BigDecimal(999999999.99), "adjustmentSmallProducerReliefDutyRate.error.maximumRequired")
minimumValue(Constants.dutyMinimumValue, "adjustmentSmallProducerReliefDutyRate.error.minimumRequired")
)
.verifying(
maximumValue(Constants.dutyMaximumValue, "adjustmentSmallProducerReliefDutyRate.error.maximumRequired")
)
)
}
4 changes: 3 additions & 1 deletion app/forms/adjustment/AdjustmentTaxTypeFormProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package forms.adjustment

import config.Constants
import forms.mappings.Mappings

import javax.inject.Inject
import play.api.data.Form

Expand All @@ -29,6 +31,6 @@ class AdjustmentTaxTypeFormProvider @Inject() extends Mappings {
"adjustmentTaxType.error.invalid",
"adjustmentTaxType.error.invalid"
)
.verifying(inRange(100, 999, "adjustmentTaxType.error.invalid"))
.verifying(inRange(Constants.minTaxType, Constants.maxTaxType, "adjustmentTaxType.error.invalid"))
)
}
8 changes: 2 additions & 6 deletions app/forms/adjustment/OverDeclarationReasonFormProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package forms.adjustment

import forms.adjustment.OverDeclarationReasonFormProvider.overDeclarationReasonLength
import config.Constants

import javax.inject.Inject
import forms.mappings.Mappings
Expand All @@ -27,10 +27,6 @@ class OverDeclarationReasonFormProvider @Inject() extends Mappings {
def apply(): Form[String] =
Form(
"over-declaration-reason-input" -> text("overDeclarationReason.error.required")
.verifying(maxLength(overDeclarationReasonLength, "overDeclarationReason.error.length"))
.verifying(maxLength(Constants.overUnderDeclarationReasonLength, "overDeclarationReason.error.length"))
)
}

object OverDeclarationReasonFormProvider {
val overDeclarationReasonLength = 250
}
8 changes: 2 additions & 6 deletions app/forms/adjustment/UnderDeclarationReasonFormProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package forms.adjustment

import forms.adjustment.UnderDeclarationReasonFormProvider.underDeclarationReasonLength
import config.Constants

import javax.inject.Inject
import forms.mappings.Mappings
Expand All @@ -27,10 +27,6 @@ class UnderDeclarationReasonFormProvider @Inject() extends Mappings {
def apply(): Form[String] =
Form(
"under-declaration-reason-input" -> text("underDeclarationReason.error.required")
.verifying(maxLength(underDeclarationReasonLength, "underDeclarationReason.error.length"))
.verifying(maxLength(Constants.overUnderDeclarationReasonLength, "underDeclarationReason.error.length"))
)
}

object UnderDeclarationReasonFormProvider {
val underDeclarationReasonLength = 250
}
7 changes: 6 additions & 1 deletion app/forms/adjustment/WhenDidYouPayDutyFormProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package forms.adjustment

import config.Constants

import javax.inject.Inject
import forms.mappings.Mappings
import play.api.data.Form
Expand All @@ -31,6 +33,9 @@ class WhenDidYouPayDutyFormProvider @Inject() extends Mappings {
"whenDidYouPayDuty.date.error.invalidYear"
)
.verifying("whenDidYouPayDuty.date.error.invalid.future", value => value.isBefore(YearMonth.now()))
.verifying("whenDidYouPayDuty.date.error.invalid.past", value => value.isAfter(YearMonth.of(2023, 7)))
.verifying(
"whenDidYouPayDuty.date.error.invalid.past",
value => value.isAfter(YearMonth.of(Constants.adjustmentTooEarlyYear, Constants.adjustmentTooEarlyMonth))
)
)
}
25 changes: 17 additions & 8 deletions app/forms/dutySuspended/DutySuspendedBeerFormProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,42 @@

package forms.dutySuspended

import javax.inject.Inject
import config.Constants

import javax.inject.Inject
import forms.mappings.Mappings
import play.api.data.Form
import play.api.data.Forms._
import models.dutySuspended.DutySuspendedBeer

class DutySuspendedBeerFormProvider @Inject() extends Mappings {

def apply(): Form[DutySuspendedBeer] = Form(
mapping(
"totalBeer" -> bigDecimal(
2,
Constants.maximumDecimalPlaces,
"dutySuspendedBeer.error.totalBeer.required",
"dutySuspendedBeer.error.totalBeer.nonNumeric",
"dutySuspendedBeer.error.totalBeer.decimalPlaces"
).verifying(minimumValue(BigDecimal(-999999999.99), "dutySuspendedBeer.error.totalBeer.minimumRequired"))
.verifying(maximumValue(BigDecimal(999999999.99), "dutySuspendedBeer.error.totalBeer.maximumRequired")),
).verifying(
minimumValue(Constants.dutySuspendedVolumeMinimumValue, "dutySuspendedBeer.error.totalBeer.minimumRequired")
).verifying(
maximumValue(Constants.dutySuspendedVolumeMaximumValue, "dutySuspendedBeer.error.totalBeer.maximumRequired")
),
"pureAlcoholInBeer" -> bigDecimal(
4,
Constants.lpaMaximumDecimalPlaces,
"dutySuspendedBeer.error.pureAlcoholInBeer.required",
"dutySuspendedBeer.error.pureAlcoholInBeer.nonNumeric",
"dutySuspendedBeer.error.pureAlcoholInBeer.decimalPlaces"
).verifying(
minimumValue(BigDecimal(-999999999.9999), "dutySuspendedBeer.error.pureAlcoholInBeer.minimumRequired")
minimumValue(
Constants.dutySuspendedLpaMinimumValue,
"dutySuspendedBeer.error.pureAlcoholInBeer.minimumRequired"
)
).verifying(
maximumValue(BigDecimal(999999999.9999), "dutySuspendedBeer.error.pureAlcoholInBeer.maximumRequired")
maximumValue(
Constants.dutySuspendedLpaMaximumValue,
"dutySuspendedBeer.error.pureAlcoholInBeer.maximumRequired"
)
)
)(DutySuspendedBeer.apply)(DutySuspendedBeer.unapply)
)
Expand Down
25 changes: 17 additions & 8 deletions app/forms/dutySuspended/DutySuspendedCiderFormProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,42 @@

package forms.dutySuspended

import javax.inject.Inject
import config.Constants

import javax.inject.Inject
import forms.mappings.Mappings
import play.api.data.Form
import play.api.data.Forms._
import models.dutySuspended.DutySuspendedCider

class DutySuspendedCiderFormProvider @Inject() extends Mappings {

def apply(): Form[DutySuspendedCider] = Form(
mapping(
"totalCider" -> bigDecimal(
2,
Constants.maximumDecimalPlaces,
"dutySuspendedCider.error.totalCider.required",
"dutySuspendedCider.error.totalCider.nonNumeric",
"dutySuspendedCider.error.totalCider.decimalPlaces"
).verifying(minimumValue(BigDecimal(-999999999.99), "dutySuspendedCider.error.totalCider.minimumRequired"))
.verifying(maximumValue(BigDecimal(999999999.99), "dutySuspendedCider.error.totalCider.maximumRequired")),
).verifying(
minimumValue(Constants.dutySuspendedVolumeMinimumValue, "dutySuspendedCider.error.totalCider.minimumRequired")
).verifying(
maximumValue(Constants.dutySuspendedVolumeMaximumValue, "dutySuspendedCider.error.totalCider.maximumRequired")
),
"pureAlcoholInCider" -> bigDecimal(
4,
Constants.lpaMaximumDecimalPlaces,
"dutySuspendedCider.error.pureAlcoholInCider.required",
"dutySuspendedCider.error.pureAlcoholInCider.nonNumeric",
"dutySuspendedCider.error.pureAlcoholInCider.decimalPlaces"
).verifying(
minimumValue(BigDecimal(-999999999.9999), "dutySuspendedCider.error.pureAlcoholInCider.minimumRequired")
minimumValue(
Constants.dutySuspendedLpaMinimumValue,
"dutySuspendedCider.error.pureAlcoholInCider.minimumRequired"
)
).verifying(
maximumValue(BigDecimal(999999999.9999), "dutySuspendedCider.error.pureAlcoholInCider.maximumRequired")
maximumValue(
Constants.dutySuspendedLpaMaximumValue,
"dutySuspendedCider.error.pureAlcoholInCider.maximumRequired"
)
)
)(DutySuspendedCider.apply)(DutySuspendedCider.unapply)
)
Expand Down
Loading

0 comments on commit 397d181

Please sign in to comment.