diff --git a/app/viewmodels/returns/ViewReturnViewModel.scala b/app/viewmodels/returns/ViewReturnViewModel.scala index 25121c85..b40ada75 100644 --- a/app/viewmodels/returns/ViewReturnViewModel.scala +++ b/app/viewmodels/returns/ViewReturnViewModel.scala @@ -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( diff --git a/conf/messages.en b/conf/messages.en index 5e193bbf..2c81baf8 100644 --- a/conf/messages.en +++ b/conf/messages.en @@ -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 diff --git a/test/viewmodels/returns/ViewReturnViewModelSpec.scala b/test/viewmodels/returns/ViewReturnViewModelSpec.scala index 3512aa93..7fd258c7 100644 --- a/test/viewmodels/returns/ViewReturnViewModelSpec.scala +++ b/test/viewmodels/returns/ViewReturnViewModelSpec.scala @@ -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( @@ -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 {