Skip to content

Commit

Permalink
Dc 6593 (#1171)
Browse files Browse the repository at this point in the history
* DC-6593: compile for scala 3

* DC-6593: scala 3 update

* DC-6593: pr bot comments
  • Loading branch information
ardwalker authored Aug 1, 2024
1 parent 841822d commit 103c623
Show file tree
Hide file tree
Showing 59 changed files with 155 additions and 189 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ precompiled
/.project
project/project
project/target
project/metals.sbt
/RUNNING_PID
server.pid
/.settings
Expand Down
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version = 3.8.1
runner.dialect = scala213
runner.dialect = scala3
style = defaultWithAlign
maxColumn = 120
lineEndings = unix
Expand Down
3 changes: 2 additions & 1 deletion app/preview/views/error_template.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*@

@import play.api.mvc.RequestHeader
@this()

@(pageTitle: String, heading: String, message: String)(implicit request: Request[_], messages: Messages)
@(pageTitle: String, heading: String, message: String)(implicit request: RequestHeader, messages: Messages)

<html>
<title>@pageTitle</title>
Expand Down
11 changes: 7 additions & 4 deletions app/uk/gov/hmrc/hmrcemailrenderer/config/ErrorHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ import play.twirl.api.Html
import uk.gov.hmrc.play.bootstrap.frontend.http.FrontendErrorHandler
import preview.views.html.error_template
import com.google.inject.{ Inject, Singleton }
import scala.concurrent.{ ExecutionContext, Future }
import play.api.mvc.RequestHeader

@Singleton
class ErrorHandler @Inject() (
val messagesApi: MessagesApi,
view: error_template
) extends FrontendErrorHandler with I18nSupport {
)(implicit val ec: ExecutionContext)
extends FrontendErrorHandler with I18nSupport {

override def standardErrorTemplate(pageTitle: String, heading: String, message: String)(implicit
rh: Request[_]
): Html =
view(pageTitle, heading, message)
rh: RequestHeader
): Future[Html] =
Future.successful(view(pageTitle, heading, message)(rh, messagesApi.preferred(rh)))
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,26 @@ import com.google.inject.{ Inject, Singleton }
import play.api.libs.json.{ Json, OFormat }
import uk.gov.hmrc.crypto.{ ApplicationCrypto, PlainText }
import uk.gov.hmrc.hmrcemailrenderer.model.Language
import uk.gov.hmrc.http.{ HeaderCarrier, HttpClient }
import uk.gov.hmrc.http.HeaderCarrier
import uk.gov.hmrc.http.client.HttpClientV2
import uk.gov.hmrc.play.bootstrap.config.ServicesConfig
import uk.gov.hmrc.http.HttpReads.Implicits._

import scala.concurrent.{ ExecutionContext, Future }
import java.net.URI
@Singleton
class PreferencesConnector @Inject() (servicesConfig: ServicesConfig, http: HttpClient, crypto: ApplicationCrypto) {
class PreferencesConnector @Inject() (servicesConfig: ServicesConfig, http: HttpClientV2, crypto: ApplicationCrypto) {

object LanguagePreference {
implicit val format: OFormat[LanguagePreference] = Json.format[LanguagePreference]
}

def languageByEmail(emailAddress: String)(implicit hc: HeaderCarrier, ec: ExecutionContext): Future[Language] = {
val encryptedEmail = new String(crypto.QueryParameterCrypto.encrypt(PlainText(emailAddress)).toBase64)
val url = servicesConfig.baseUrl("preferences") + s"/preferences/language/$encryptedEmail"
http.GET[Language](url)
val url = new URI(servicesConfig.baseUrl("preferences") + s"/preferences/language/$encryptedEmail").toURL
http
.get(url)
.execute[Language]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class TemplateRenderer @Inject() (
}

private def render(
template: Map[String, String] => Format[_]#Appendable,
template: Map[String, String] => Format[?]#Appendable,
params: Map[String, String]
): Either[ErrorMessage, String] =
Try(template(params)) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Add clients to use access groups", isWelsh=false) {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName()</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">You have turned on access groups in your agent services account.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Our system cannot find any clients linked to this account. You need to add clients before you can use access groups.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Ychwanegu cleientiaid i ddefnyddio grwpiau mynediad", isWelsh=true) {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Annwyl @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Annwyl @agencyName()</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Rydych wedi galluogi grwpiau mynediad yn eich cyfrif gwasanaethau asiant.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Ni all ein system ddod o hyd i unrhyw gleientiaid sy’n gysylltiedig â’r cyfrif hwn. Mae angen i chi ychwanegu cleientiaid cyn y gallwch ddefnyddio grwpiau mynediad.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, title = "Agent interested in private beta") {


<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Agent Reference Number: @arn</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Number of clients: @numClients </p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Contact name: @contactName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Contact email address: @contactEmail</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Contact telephone number: @telephone_number</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Agent Reference Number: @arn()</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Number of clients: @numClients() </p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Contact name: @contactName()</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Contact email address: @contactEmail()</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0;">Contact telephone number: @telephone_number()</p>
<p style="font-size: 19px; line-height: 1.315789474; margin-bottom: 20px;">
This agent is interested in joining the private beta of Granular Permissions for agent services accounts.
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "You can start using access groups", isWelsh=false) {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName()</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">You have turned on access groups in your agent services account and your client details have now been processed. We could not retrieve all your client references, but you can enter these manually. To do this, select ‘Manage clients’ under ‘Manage account’.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">To create access groups, sign in to your agent services account and select 'Manage account'.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Gallwch ddechrau defnyddio grwpiau mynediad", isWelsh=true) {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Annwyl @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Annwyl @agencyName()</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Rydych wedi galluogi grwpiau mynediad yn eich cyfrif gwasanaethau asiant ac mae manylion eich cleientiaid bellach wedi’u prosesu.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Mae unrhyw grwpiau mynediad a grëwyd gan eich sefydliad yn y gorffennol wedi’u hadfer.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Agent services account created") {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName()</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">You have created an HMRC agent services account for @agencyName.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Your account reference number is <strong>@arn</strong></p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">You have created an HMRC agent services account for @agencyName().</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Your account reference number is <strong>@arn()</strong></p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Make sure you have this with you if you contact us about your agent services account.</p>

<h2>What you can do next</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Cyfrif gwasanaethau asiant wedi’i greu", isWelsh=true) {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Annwyl @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Annwyl @agencyName()</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Rydych wedi creu cyfrif gwasanaethau asiant CThEF ar gyfer @agencyName.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Cyfeirnod eich cyfrif yw <strong>@arn</strong></p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Rydych wedi creu cyfrif gwasanaethau asiant CThEF ar gyfer @agencyName().</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Cyfeirnod eich cyfrif yw <strong>@arn()</strong></p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Gwnewch yn siŵr bod gennych chi hyn os ydych yn cysylltu â ni ynglŷn â’ch cyfrif gwasanaethau asiant.</p>

<h2>Yr hyn y gallwch ei wneud nesaf</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Your client accepted your authorisation request") {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Your client @clientName has authorised you to @service</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName()</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Your client @clientName()< has authorised you to @service()</p>
@if(!params("additionalInfo").asInstanceOf[String].isEmpty) { <p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 30px 0;">@{params("additionalInfo")}</p> } else {}
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 30px 0;">Do not reply to this email.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 30px 0;">From HMRC Agent Services Team</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Your authorisation request expired without being accepted") {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName()</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">
Your authorisation request to your client @clientName has expired because they did not respond by @expiryDate.
Your authorisation request to your client @clientName() has expired because they did not respond by @expiryDate().
</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">
@clientName did not accept your request to @service
@clientName() did not accept your request to @service()
</p>

<h2>What you can do next</h2>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 30px 0;">
If you still want @clientName to authorise you, sign in to your HMRC agent services account and start a new authorisation request.</p>
If you still want @clientName() to authorise you, sign in to your HMRC agent services account and start a new authorisation request.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 30px 0;">Do not reply to this email.</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 30px 0;">From HMRC Agent Services Team</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Your authorisation request was declined") {

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName</p>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">Dear @agencyName()</p>

<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 15px 0;">
Your client @clientName has declined your request to @service</p>
Your client @clientName() has declined your request to @service()</p>

<h2>What you can do next</h2>
<p style="font-size: 19px; line-height: 1.315789474; margin: 0 0 30px 0;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<p style="font-size: 19px; margin: 0 0 30px;">Agent Reference Number: @params("arn")</p>
<p style="font-size: 19px; margin: 0 0 30px;">Unique Taxpayer Reference: @params("utr")</p>
<p style="font-size: 19px; margin: 0 0 30px;">Agent name: @params("agencyName")</p>
<p style="font-size: 19px; margin: 0 0 15px;">Check@{if(failedChecks.length > 1) "s" else ""} failed: </p>
<p style="font-size: 19px; margin: 0 0 15px;">Check@{if(failedChecks().length > 1) "s" else ""} failed: </p>
<ul style="font-size: 19px; margin: 0 0 30px;">
@for(failedCheck <- failedChecks){ <li>@failedCheck</li> }
@for(failedCheck <- failedChecks()){ <li>@failedCheck</li> }
</ul>
<p style="font-size: 19px; margin: 0 0 30px;">Date and time of check: @params("dateTime")</p>
<p style="margin: 0 0 30px; font-size: 19px;">From HMRC Agent Services team</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Agent entity check failure report
Agent reference number: @params("arn")
Unique Taxpayer Reference: @params("utr")
Agent name: @params("agencyName")
Check@{if(failedChecks.length > 1) "s" else ""} failed: @params("failedChecks")
Check@{if(failedChecks().length > 1) "s" else ""} failed: @params("failedChecks")
Date / time of check: @params("dateTime")

From HMRC Agent Services Team
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Your import charge reimbursement claim submission"){

<p style="margin: 0 0 30px; font-size: 19px;">Dear @name</p>
<p style="margin: 0 0 30px; font-size: 19px;">Dear @name()</p>

<p style="margin:0 0 30px; font-size: 19px;">This confirms you have applied to claim for reimbursement on import charges such as Customs Duties, Excise Duties, Countervailing Duties and VAT.</p>

<p style="margin: 0 0 30px; font-size: 19px;">Your claim reference number is: <strong>@reference</strong></p>
<p style="margin: 0 0 30px; font-size: 19px;">Your claim reference number is: <strong>@reference()</strong></p>

<p style="margin: 0 0 30px; font-size: 19px;">Your claim amount is: <strong>£@claimAmount</strong></p>
<p style="margin: 0 0 30px; font-size: 19px;">Your claim amount is: <strong>£@claimAmount()</strong></p>

<h2>What happens next </h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

@uk.gov.hmrc.hmrcemailrenderer.templates.helpers.html.template_main(params, "Eich hawliad am ad-daliad o ffioedd mewnforio"){

<p style="margin: 0 0 30px; font-size: 19px;">Annwyl @name</p>
<p style="margin: 0 0 30px; font-size: 19px;">Annwyl @name()</p>

<p style="margin:0 0 30px; font-size: 19px;">Mae hyn yn cadarnhau eich bod wedi gwneud cais i hawlio ad-daliad ar gyfer ffioedd mewnforio megis Tollau Tramor, Tollau Ecséis, Tollau Gwrthbwyso a TAW.</p>

<p style="margin: 0 0 30px; font-size: 19px;">Cyfeirnod eich hawliad yw: <strong>@reference</strong></p>
<p style="margin: 0 0 30px; font-size: 19px;">Cyfeirnod eich hawliad yw: <strong>@reference()</strong></p>

<p style="margin: 0 0 30px; font-size: 19px;">Swm eich hawliad yw: <strong>£@claimAmount</strong></p>
<p style="margin: 0 0 30px; font-size: 19px;">Swm eich hawliad yw: <strong>£@claimAmount()</strong></p>

<h2>Yr hyn sy’n digwydd nesaf</h2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@(params: Map[String, Any])
@grid = @{
val warnings = Stream.from(0).takeWhile(i => params.get(s"clientId_$i").isDefined).toList
val warnings = LazyList.from(0).takeWhile(i => params.get(s"clientId_$i").isDefined).toList
warnings.map { i =>
val clientId = params(s"clientId_$i")
val notificationTotal = params(s"notificationTotal_$i")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@(params: Map[String, Any])
@grid = @{
val warnings = Stream.from(0).takeWhile(i => params.get(s"clientId_$i").isDefined).toList
val warnings = LazyList.from(0).takeWhile(i => params.get(s"clientId_$i").isDefined).toList
warnings.map { i =>
val clientId = params(s"clientId_$i")
val notificationTotal = params(s"notificationTotal_$i")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@(params: Map[String, Any])

@goodsGrid = @{
val goods = Stream.from(0).takeWhile(i => params.contains(s"goodsCategory_$i")).toList
val goods = LazyList.from(0).takeWhile(i => params.contains(s"goodsCategory_$i")).toList
goods.map { i =>
val category = params(s"goodsCategory_$i")
val country = params(s"goodsDestination_$i")
Expand All @@ -40,7 +40,7 @@ <h2>What you need to do next</h2>

<h2>Date of declaration</h2>

<p style="margin: 0 0 30px; font-size: 19px;">@{params("dateOfDeclaration") + "." }</p>
<p style="margin: 0 0 30px; font-size: 19px;">@{params("dateOfDeclaration").toString}.</p>

<h2>Details of the goods</h2>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@(params: Map[String, Any])You added goods to your declaration
@goodsGrid = @{
val goods = Stream.from(0).takeWhile(i => params.get(s"goodsCategory_$i").isDefined).toList
val goods = LazyList.from(0).takeWhile(i => params.get(s"goodsCategory_$i").isDefined).toList
goods.map { i =>
val category = params(s"goodsCategory_$i")
val country = params(s"goodsDestination_$i")
Expand All @@ -20,7 +20,7 @@ Take this updated declaration and the purchase receipts for the goods with you w

Date of declaration

@{params("dateOfDeclaration") + "." }
@{params("dateOfDeclaration").toString}.

Details of the goods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@(params: Map[String, Any])

@goodsGrid = @{
val goods = Stream.from(0).takeWhile(i => params.contains(s"goodsCategory_$i")).toList
val goods = LazyList.from(0).takeWhile(i => params.contains(s"goodsCategory_$i")).toList
goods.map { i =>
val category = params(s"goodsCategory_$i")
val country = params(s"goodsDestination_$i")
Expand All @@ -40,7 +40,7 @@ <h2>Yr hyn y mae angen i chi ei wneud nesaf</h2>

<h2>Dyddiad y datganiad</h2>

<p style="margin: 0 0 30px; font-size: 19px;">@{params("dateOfDeclaration") + "." }</p>
<p style="margin: 0 0 30px; font-size: 19px;">@{params("dateOfDeclaration").toString}.</p>

<h2>Manylion y nwyddau</h2>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@(params: Map[String, Any])Rydych wedi ychwanegu nwyddau at eich datganiad
@goodsGrid = @{
val goods = Stream.from(0).takeWhile(i => params.get(s"goodsCategory_$i").isDefined).toList
val goods = LazyList.from(0).takeWhile(i => params.get(s"goodsCategory_$i").isDefined).toList
goods.map { i =>
val category = params(s"goodsCategory_$i")
val country = params(s"goodsDestination_$i")
Expand All @@ -20,7 +20,7 @@ Ewch â’r datganiad wedi’i ddiweddaru hwn a’r derbyniadau prynu ar gyfer y

Dyddiad y datganiad

@{params("dateOfDeclaration") + "." }
@{params("dateOfDeclaration").toString}.

Manylion y nwyddau

Expand Down
Loading

0 comments on commit 103c623

Please sign in to comment.