Skip to content

Commit

Permalink
ADR-1265 hidden text changes for adjustment screens (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
sini-george authored Oct 17, 2024
1 parent 87145b5 commit 7f0674a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,21 @@ object AdjustmentListSummaryHelper {
messages: Messages
): Seq[TableRowViewModel] =
adjustmentEntries.zipWithIndex.map { case (adjustmentEntry, index) =>
val adjustmentIndex = (pageNumber - 1) * rowsPerPage + index
val adjustmentType = adjustmentEntry.adjustmentType.getOrElse(
val adjustmentIndex = (pageNumber - 1) * rowsPerPage + index
val adjustmentType = adjustmentEntry.adjustmentType.getOrElse(
throw new RuntimeException("Couldn't fetch adjustment type value from cache")
)
val dutyValue = if (adjustmentEntry.newDuty.isDefined) {
val adjustmentTypeLabel = messages(s"adjustmentType.checkYourAnswersLabel.$adjustmentType")
val dutyValue = if (adjustmentEntry.newDuty.isDefined) {
adjustmentEntry.newDuty
} else {
adjustmentEntry.duty
}
val formattedDutyValue =
Money.format(dutyValue.getOrElse(throw new RuntimeException("Couldn't fetch duty value from cache")))
TableRowViewModel(
cells = Seq(
TableRow(Text(messages(s"adjustmentType.checkYourAnswersLabel.$adjustmentType"))),
TableRow(Text(adjustmentTypeLabel)),
TableRow(
Text(
rateBandRecap(
Expand All @@ -83,22 +86,28 @@ object AdjustmentListSummaryHelper {
)
),
TableRow(
content = Text(
Money.format(dutyValue.getOrElse(throw new RuntimeException("Couldn't fetch duty value from cache")))
),
content = Text(formattedDutyValue),
classes = Constants.textAlignRightCssClass
)
),
actions = Seq(
TableRowActionViewModel(
label = messages("site.change"),
href = controllers.adjustment.routes.CheckYourAnswersController.onPageLoad(Some(adjustmentIndex)),
visuallyHiddenText = Some(messages("adjustmentEntryList.change.hidden"))
visuallyHiddenText = Some(
messages(
"adjustmentEntryList.change.hidden",
adjustmentTypeLabel,
formattedDutyValue
)
)
),
TableRowActionViewModel(
label = messages("site.remove"),
href = controllers.adjustment.routes.DeleteAdjustmentController.onPageLoad(adjustmentIndex),
visuallyHiddenText = Some(messages("adjustmentEntryList.remove.hidden"))
visuallyHiddenText = Some(
messages("adjustmentEntryList.remove.hidden", adjustmentTypeLabel, formattedDutyValue)
)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@ import viewmodels.returns.RateBandHelper.rateBandRecap
object AdjustmentTaxTypeSummary {

def row(adjustmentEntry: AdjustmentEntry)(implicit messages: Messages): Option[SummaryListRow] = {
val adjustmentType = adjustmentEntry.adjustmentType.getOrElse(
val adjustmentType = adjustmentEntry.adjustmentType.getOrElse(
throw new RuntimeException("Couldn't fetch adjustment type value from cache")
)
val label = if (adjustmentType.equals(RepackagedDraughtProducts)) {
"adjustmentTaxType.repackaged.checkYourAnswersLabel"
} else { "adjustmentTaxType.checkYourAnswersLabel" }
val (label, hiddenText) = if (adjustmentType.equals(RepackagedDraughtProducts)) {
("adjustmentTaxType.repackaged.checkYourAnswersLabel", "adjustmentTaxType.repackaged.change.hidden")
} else {
("adjustmentTaxType.checkYourAnswersLabel", "adjustmentTaxType.change.hidden")
}
adjustmentEntry.rateBand.map { rateBand =>
SummaryListRowViewModel(
key = label,
value = ValueViewModel(rateBandRecap(rateBand)),
actions = Seq(
ActionItemViewModel("site.change", routes.AdjustmentTaxTypeController.onPageLoad(CheckMode).url)
.withVisuallyHiddenText(messages("adjustmentTaxType.change.hidden"))
.withVisuallyHiddenText(messages(hiddenText))
)
)
}
Expand Down
1 change: 0 additions & 1 deletion app/viewmodels/returns/ReturnPeriodViewModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package viewmodels.returns

import models.ReturnPeriod

import java.time.LocalDate
import java.time.format.DateTimeFormatter

case class ReturnPeriodViewModel(fromDate: String, toDate: String, returnDueDate: String)
Expand Down
17 changes: 9 additions & 8 deletions conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ adjustmentType.repackaged-draught-products = Repackaged draught products
adjustmentType.repackaged-draught-products.hint = You have paid duty on alcohol at the reduced rate (draught relief) and have now repackaged it so it is no longer eligible for the reduced rate.
adjustmentType.checkYourAnswersLabel = Adjustment
adjustmentType.error.required = Select the type of adjustment you need to make
adjustmentType.change.hidden = what type of adjustment do you need to make
adjustmentType.change.hidden = adjustment
adjustmentType.checkYourAnswersLabel.over-declaration = Over-declared
adjustmentType.checkYourAnswersLabel.under-declaration = Under-declared
adjustmentType.checkYourAnswersLabel.spoilt = Spoilt
Expand All @@ -1204,7 +1204,7 @@ whenDidYouPayDuty.date.error.invalid.month = The date you paid duty must be a re
whenDidYouPayDuty.date.error.invalid.year = The date you paid duty must be a real date using numbers
whenDidYouPayDuty.date.error.invalid.past = The date must be after 31st July 2023
whenDidYouPayDuty.checkYourAnswersLabel = Original return period
whenDidYouPayDuty.change.hidden = when did you pay duty on this
whenDidYouPayDuty.change.hidden = original return period
whenDidYouPayDuty.date.error.invalidYear.year = Year must include 4 numbers

adjustmentTaxType.title = What is the tax type code for the alcohol you are adjusting?
Expand All @@ -1215,7 +1215,8 @@ adjustmentTaxType.checkYourAnswersLabel = Tax type
adjustmentTaxType.error.invalid = Enter a valid tax type code
adjustmentTaxType.error.required = Enter the tax type code
adjustmentTaxType.error.notDraught = Tax type code needs to be for draught products
adjustmentTaxType.change.hidden = what is the tax type code for the alcohol you are adjusting
adjustmentTaxType.repackaged.change.hidden = original tax type
adjustmentTaxType.change.hidden = tax type
adjustmentTaxType.repackaged.checkYourAnswersLabel = Original tax type
adjustmentTaxType.checkYourAnswersLabel.abv.interval.Core = Non-draught {0} between {1}% and {2}% ABV ({3})
adjustmentTaxType.checkYourAnswersLabel.abv.exceeding.max.Core = Non-draught {0} at or above {1}% ABV ({2})
Expand Down Expand Up @@ -1246,7 +1247,7 @@ adjustmentVolume.error.noValue.sprDutyRate = Enter your Small Producer Relief du
adjustmentVolume.error.minimumValue.sprDutyRate = Your Small Producer Relief duty rate must be £0.00 or more
adjustmentVolume.error.maximumValue.sprDutyRate = Your Small Producer Relief duty rate must be £99.99 million or less
adjustmentVolume.error.decimalPlaces.sprDutyRate = Your Small Producer Relief duty rate must be to 2 decimal places
adjustmentVolume.change.hidden = Adjustment Volume
adjustmentVolume.change.hidden = volume
adjustmentVolume.subHeading = {0} between {1}% and {2}% ABV (tax type code {3})
adjustmentVolume.totalLitresVolume.heading = Total litres of {0}
adjustmentVolume.totalLitresVolume.hint = In litres, up to 2 decimal places.
Expand All @@ -1263,7 +1264,7 @@ adjustmentRepackagedTaxType.error.invalid = Enter a valid tax type code
adjustmentRepackagedTaxType.error.required = Enter the new tax type code
adjustmentRepackagedTaxType.error.outOfRange = AdjustmentRepackagedTaxType must be between {0} and {1}
adjustmentRepackagedTaxType.error.nonDraught = Enter a valid non-draught tax type code
adjustmentRepackagedTaxType.change.hidden = what is the tax type code for the newly repackaged products
adjustmentRepackagedTaxType.change.hidden = new tax type
adjustmentRepackagedTaxType.hint = A non-draught 3 digit tax type code

adjustmentSmallProducerReliefDutyRate.title = What is your Small Producer Relief Duty rate for the newly repackaged products?
Expand All @@ -1275,7 +1276,7 @@ adjustmentSmallProducerReliefDutyRate.error.required = Enter your Small Producer
adjustmentSmallProducerReliefDutyRate.error.minimumRequired = Your Small Producer Relief duty rate must be £0.00 or more
adjustmentSmallProducerReliefDutyRate.error.maximumRequired = Your Small Producer Relief duty rate must be £99.99 million or less
adjustmentSmallProducerReliefDutyRate.error.decimalPlaces = Your Small Producer Relief duty rate must be to 2 decimal places
adjustmentSmallProducerReliefDutyRate.change.hidden = what is your Small Producer Relief duty rate for the newly repackaged products
adjustmentSmallProducerReliefDutyRate.change.hidden = SPR duty rate

adjustmentDutyDue.title = The duty value for this adjustment is {0}
adjustmentDutyDue.heading = The duty value for this adjustment is {0}
Expand Down Expand Up @@ -1306,8 +1307,8 @@ adjustmentEntryList.action = Action
adjustmentList.total = Total due
adjustmentList.question = Do you need to tell us about any other adjustments?
adjustmentList.error.required = Select yes if you have another adjustment to declare
adjustmentEntryList.change.hidden = this adjustment
adjustmentEntryList.remove.hidden = this adjustment
adjustmentEntryList.change.hidden = {0} adjustment with duty value {1}
adjustmentEntryList.remove.hidden = {0} adjustment with duty value {1}

deleteAdjustment.title = Remove this adjustment?
deleteAdjustment.heading = Remove this adjustment?
Expand Down
1 change: 0 additions & 1 deletion test/viewmodels/BeforeStartReturnViewModelSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import uk.gov.hmrc.govukfrontend.views.viewmodels.warningtext.WarningText
import viewmodels.returns.ReturnPeriodViewModel.viewDateFormatter

import java.time.LocalDate
import scala.language.postfixOps

class BeforeStartReturnViewModelSpec extends SpecBase {
"WarningTextViewModel" - {
Expand Down

0 comments on commit 7f0674a

Please sign in to comment.