Skip to content

Commit

Permalink
ADR-1466: Spoilt duty rate displayed as NA on view specific return (#214
Browse files Browse the repository at this point in the history
)

* ADR-1466 spoilt duty rate displayed as NA on view specific return

* ADR-1466 adds a test

* ADR-1466 updated not applicable content

* ADR-1466 updated tests

* ADR-1466 content updated to not applicable
  • Loading branch information
sini-george authored Nov 26, 2024
1 parent ceed575 commit a258b77
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
30 changes: 16 additions & 14 deletions app/viewmodels/returns/ViewReturnViewModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -189,30 +189,32 @@ class ViewReturnViewModel @Inject() (appConfig: FrontendAppConfig) {
ratePeriodsAndTaxCodesToRateBands: Map[(YearMonth, String), RateBand]
)(implicit messages: Messages): Seq[TableRowViewModel] =
returnAdjustments.map { returnAdjustmentsRow =>
val maybeRatePeriod = ReturnPeriod.fromPeriodKey(returnAdjustmentsRow.returnPeriodAffected).map(_.period)
val taxType = returnAdjustmentsRow.taxType
val description = if (returnAdjustmentsRow.adjustmentTypeKey.equals(ReturnAdjustments.spoiltKey)) {
appConfig.getRegimeNameByTaxTypeCode(taxType) match {
case Some(regime) => messages(s"alcoholType.$regime")
case _ => taxType
}
val maybeRatePeriod = ReturnPeriod.fromPeriodKey(returnAdjustmentsRow.returnPeriodAffected).map(_.period)
val taxType = returnAdjustmentsRow.taxType
val (description, dutyRate) = if (returnAdjustmentsRow.adjustmentTypeKey.equals(ReturnAdjustments.spoiltKey)) {
(
appConfig.getRegimeNameByTaxTypeCode(taxType) match {
case Some(regime) => messages(s"alcoholType.$regime")
case _ => taxType
},
messages("viewReturn.notApplicable")
)
} else {
getDescriptionOrFallbackToTaxTypeCode(ratePeriodsAndTaxCodesToRateBands, maybeRatePeriod, taxType)
(
getDescriptionOrFallbackToTaxTypeCode(ratePeriodsAndTaxCodesToRateBands, maybeRatePeriod, taxType),
Money.format(returnAdjustmentsRow.dutyRate)
)
}
TableRowViewModel(
cells = Seq(
TableRow(content = Text(messages(s"viewReturn.adjustments.type.${returnAdjustmentsRow.adjustmentTypeKey}"))),
TableRow(content =
Text(
description
)
),
TableRow(content = Text(description)),
TableRow(
content = Text(messages("site.4DP", returnAdjustmentsRow.litresOfPureAlcohol)),
classes = s"${Css.textAlignRightCssClass} ${Css.numericCellClass}"
),
TableRow(
content = Text(Money.format(returnAdjustmentsRow.dutyRate)),
content = Text(dutyRate),
classes = s"${Css.textAlignRightCssClass} ${Css.numericCellClass}"
),
TableRow(
Expand Down
1 change: 1 addition & 0 deletions conf/messages.en
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ viewReturn.table.dutyValue.legend = Duty value
viewReturn.table.dutyDue.legend = Duty value
viewReturn.table.typesOfSpirits.legend = Types of spirits produced
viewReturn.printYourReturn = Print your return
viewReturn.notApplicable = not applicable

viewPastPayments.heading = Alcohol Duty payments
viewPastPayments.title = Alcohol Duty payments
Expand Down
5 changes: 4 additions & 1 deletion test/viewmodels/returns/ViewReturnViewModelSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ class ViewReturnViewModelSpec extends SpecBase {

adjustmentsViewModel.rows.head.cells(1).content mustBe Text("321")
adjustmentsViewModel.rows(3).cells(1).content mustBe Text("Non-draught beer between 1% and 2% ABV (125)")
adjustmentsViewModel.rows(3).cells(3).content mustBe Text("£21.01")
}

"should return a model with data when a spoilt adjustment declared" in new SetUp {
"should return a model with data when a spoilt adjustment declared where Description is the regime name and duty rate is NA" in new SetUp {
when(appConfig.getRegimeNameByTaxTypeCode("333")).thenReturn(Some("Wine"))
val returnDetailWithSpoilt = returnWithSpoiltAdjustment(periodKey, Instant.now(clock))
val adjustmentsViewModel = viewModel.createAdjustmentsViewModel(
Expand All @@ -85,7 +86,9 @@ class ViewReturnViewModelSpec extends SpecBase {
s"$minus${messages("site.currency.2DP", returnDetailWithSpoilt.adjustments.total.abs)}"
)
adjustmentsViewModel.rows.head.cells(1).content mustBe Text("123")
adjustmentsViewModel.rows.head.cells(3).content mustBe Text("not applicable")
adjustmentsViewModel.rows(1).cells(1).content mustBe Text("Wine")
adjustmentsViewModel.rows(1).cells(3).content mustBe Text("not applicable")
}

"should return a model with no entries when a nil return" in new SetUp {
Expand Down

0 comments on commit a258b77

Please sign in to comment.