From 17a936b05ce7c7ca62fa3f1b3761c7859dad1624 Mon Sep 17 00:00:00 2001 From: Paul Hodgson Date: Mon, 28 Sep 2020 16:20:33 +0100 Subject: [PATCH] [PH][MIBM-77] correct copy on check-your-answers --- .../testonly/TestOnlyController.scala | 4 ++-- .../model/declaration/Declaration.scala | 24 ++++++++++++------- .../views/CheckYourAnswersPage.scala.html | 15 ++++++++---- conf/messages | 2 +- .../CoreTestData.scala | 6 ++--- .../CheckYourAnswersControllerSpec.scala | 15 +++++++----- 6 files changed, 41 insertions(+), 25 deletions(-) diff --git a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/testonly/TestOnlyController.scala b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/testonly/TestOnlyController.scala index 420bce886..572b37339 100644 --- a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/testonly/TestOnlyController.scala +++ b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/controllers/testonly/TestOnlyController.scala @@ -49,12 +49,12 @@ class TestOnlyController @Inject()(mcc: MessagesControllerComponents, GoodsEntry( "wine", Some("France"), - Some(PriceOfGoods(CurrencyAmount(BigDecimal(100.00)), "EUR")), + Some(PriceOfGoods(CurrencyAmount(BigDecimal(100.00)), Currency("Euros", "EUR"))), Some(CurrencyAmount(BigDecimal(10.00)))), GoodsEntry( "cheese", Some("France"), - Some(PriceOfGoods(CurrencyAmount(BigDecimal(200.00)), "EUR")), + Some(PriceOfGoods(CurrencyAmount(BigDecimal(200.00)), Currency("Euros", "EUR"))), Some(CurrencyAmount(BigDecimal(20.00))))), maybeName = Some(Name("Terry", "Test")), maybeAddress = Some(Address("1 Terry Terrace", "Terry Town", "T11 11T")), diff --git a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/model/declaration/Declaration.scala b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/model/declaration/Declaration.scala index 242dc0557..f809775c8 100644 --- a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/model/declaration/Declaration.scala +++ b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/model/declaration/Declaration.scala @@ -17,6 +17,7 @@ package uk.gov.hmrc.merchandiseinbaggagefrontend.model.declaration import java.time.LocalDate +import java.time.format.DateTimeFormatter import java.util.UUID.randomUUID import play.api.libs.json.{Format, Json, OFormat} @@ -38,8 +39,16 @@ object CurrencyAmount { implicit val format: OFormat[CurrencyAmount] = Json.format[CurrencyAmount] } -case class PriceOfGoods(amount: CurrencyAmount, currency: String) { - override val toString = s"$amount $currency" +case class Currency(name: String, code: String) { + override val toString = s"$name ($code)" +} + +object Currency { + implicit val format: OFormat[Currency] = Json.format[Currency] +} + +case class PriceOfGoods(amount: CurrencyAmount, currency: Currency) { + override val toString = s"$amount, $currency" } object PriceOfGoods { @@ -68,12 +77,7 @@ case class Address(maybeLine1: Option[String], maybeTown: Option[String] = None, maybeCounty: Option[String] = None, postCode: String) { - - override val toString: String = { - def lineString(maybeLine: Option[String]) = maybeLine.fold("")(line => s"$line, ") - - s"${lineString(maybeLine1)}${lineString(maybeLine2)}${lineString(maybeTown)}${lineString(maybeCounty)}$postCode" - } + val populatedAddressLines: Seq[String] = Seq(maybeLine1, maybeLine2, maybeTown, maybeCounty).flatten } object Address { @@ -90,7 +94,9 @@ object Eori { implicit val format: OFormat[Eori] = Json.format[Eori] } -case class JourneyDetails(placeOfArrival: String, dateOfArrival: LocalDate) +case class JourneyDetails(placeOfArrival: String, dateOfArrival: LocalDate) { + val formattedDateOfArrival: String = DateTimeFormatter.ofPattern("dd MMM yyyy").format(dateOfArrival) +} object JourneyDetails { implicit val format: OFormat[JourneyDetails] = Json.format[JourneyDetails] diff --git a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/views/CheckYourAnswersPage.scala.html b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/views/CheckYourAnswersPage.scala.html index ce141b702..98e13d1f2 100644 --- a/app/uk/gov/hmrc/merchandiseinbaggagefrontend/views/CheckYourAnswersPage.scala.html +++ b/app/uk/gov/hmrc/merchandiseinbaggagefrontend/views/CheckYourAnswersPage.scala.html @@ -42,7 +42,7 @@

@messages("checkYourAnswers.detail
@messages("checkYourAnswers.detailsOfTheGoods.taxDue")
-
@goods.taxDue
+
£@goods.taxDue
} @@ -56,7 +56,14 @@

@messages("checkYourAnswers.person
@messages("checkYourAnswers.personalDetails.address")
-
@declaration.address
+
+ @for(addressLine <- declaration.address.populatedAddressLines) { + @addressLine +
+ } + + @declaration.address.postCode +
@messages("checkYourAnswers.personalDetails.eori")
@@ -73,13 +80,13 @@

@messages("checkYourAnswers.journe

@messages("checkYourAnswers.journeyDetails.dateOfArrival")
-
@declaration.journeyDetails.dateOfArrival
+
@declaration.journeyDetails.formattedDateOfArrival

@messages("checkYourAnswers.sendDeclaration")

-

@messages("checkYourAnswers.sendDeclaration.acknowledgement")

+

@messages("checkYourAnswers.sendDeclaration.acknowledgement")