Repository: hmrc/customs-manage-authorities-frontend
Pull request #221: MMCA-5208 - Update customs-manage-authorities-frontend for DDA/NI logic
Author: login: magicaljellybeans
Created: 2025-03-06T11:23:09Z | Merged: 2025-03-07T19:04:23Z

- [x] Renaming of variables and methods to account for presence of EU EORIs (no logic change)
- [x] Refactor of accounts filtering to one place (no logic change)
- [x] Addition of tests for EU EORIs
- [x] ATs passing
- [x] Tickets to be created as mentioned in jira comments


Diff:
diff --git a/app/controllers/add/AccountsController.scala b/app/controllers/add/AccountsController.scala
index ec926ef5..3c8a91ba 100644
--- a/app/controllers/add/AccountsController.scala
+++ b/app/controllers/add/AccountsController.scala
@@ -31,8 +31,7 @@ import play.api.mvc.{Action, AnyContent, MessagesControllerComponents}
 import repositories.SessionRepository
 import services.AuthorisedAccountsService
 import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
-import utils.Constants.{CASH_ACCOUNT_TYPE, GENERAL_GUARANTEE_ACCOUNT_TYPE}
-import utils.StringUtils.{emptyString, gbEORIPrefix, nIEORIPrefix}
+import utils.StringUtils.emptyString
 import views.html.{AccountsView, NoAvailableAccountsView, ServiceUnavailableView}
 
 import javax.inject.Inject
@@ -67,31 +66,15 @@ class AccountsController @Inject() (
             .getAuthorisedAccounts(enteredEori.eori)
             .map { authorisedAccounts =>
               if (authorisedAccounts.availableAccounts.nonEmpty) {
-
-                if (enteredEori.eori.contains(gbEORIPrefix)) {
-                  Ok(
-                    view(
-                      populateForm(authorisedAccounts.availableAccounts.filter(x => !x.isNiAccount)),
-                      getGBAccounts(authorisedAccounts),
-                      mode,
-                      navigator
-                        .backLinkRoute(mode, controllers.add.routes.EoriDetailsCorrectController.onPageLoad(mode))
-                    )
-                  )
-                } else {
-                  Ok(
-                    view(
-                      populateForm(
-                        authorisedAccounts.availableAccounts
-                          .filter(isNIOrCashOrGeneralGuaranteeAccountType)
-                      ),
-                      getXIAccounts(authorisedAccounts),
-                      mode,
-                      navigator
-                        .backLinkRoute(mode, controllers.add.routes.EoriDetailsCorrectController.onPageLoad(mode))
-                    )
+                Ok(
+                  view(
+                    populateForm(authorisedAccounts.availableAccounts),
+                    authorisedAccounts,
+                    mode,
+                    navigator
+                      .backLinkRoute(mode, controllers.add.routes.EoriDetailsCorrectController.onPageLoad(mode))
                   )
-                }
+                )
               } else {
                 Ok(noAvailableAccounts(authorisedAccounts.enteredEori))
               }
@@ -116,7 +99,7 @@ class AccountsController @Inject() (
                     BadRequest(
                       view(
                         formWithErrors,
-                        filterAccounts(authorisedAccounts, enteredEori.eori),
+                        authorisedAccounts,
                         mode,
                         navigator
                           .backLinkRoute(mode, controllers.add.routes.EoriDetailsCorrectController.onPageLoad(mode))
@@ -124,8 +107,7 @@ class AccountsController @Inject() (
                     )
                   ),
                 value => {
-                  val selected =
-                    filterAccountsWithContext(enteredEori.eori, value, authorisedAccounts)
+                  val selected = selectAccounts(value, authorisedAccounts)
                   for {
                     updatedAnswers <- Future.fromTry(request.userAnswers.set(AccountsPage, selected))
                     _              <- sessionRepository.set(updatedAnswers)
@@ -136,47 +118,9 @@ class AccountsController @Inject() (
       }
   }
 
-  private def getAuthorisedAccountsList(accounts: AuthorisedAccounts, cdsAcc: Seq[CDSAccount]): AuthorisedAccounts =
-    AuthorisedAccounts(
-      accounts.alreadyAuthorisedAccounts,
-      cdsAcc,
-      accounts.closedAccounts,
-      accounts.pendingAccounts,
-      accounts.enteredEori
-    )
-
-  private def filterAccounts(authorisedAccounts: AuthorisedAccounts, eori: String) =
-    if (eori.startsWith(gbEORIPrefix)) {
-      getGBAccounts(authorisedAccounts)
-    } else {
-      getXIAccounts(authorisedAccounts)
-    }
-
-  private def getGBAccounts(authorisedAccounts: AuthorisedAccounts) =
-    getAuthorisedAccountsList(authorisedAccounts, authorisedAccounts.availableAccounts.filter(x => !x.isNiAccount))
-
-  private def getXIAccounts(authorisedAccounts: AuthorisedAccounts) =
-    getAuthorisedAccountsList(
-      authorisedAccounts,
-      authorisedAccounts.availableAccounts.filter(isNIOrCashOrGeneralGuaranteeAccountType)
-    )
-
-  private def filterAccountsWithContext(eori: String, value: List[String], authorisedAccounts: AuthorisedAccounts) = {
+  private def selectAccounts(value: List[String], authorisedAccounts: AuthorisedAccounts) = {
     val accountString = "account_"
-
-    if (eori.startsWith(nIEORIPrefix)) {
-      value.map(account =>
-        authorisedAccounts.availableAccounts.filter(isNIOrCashOrGeneralGuaranteeAccountType)(
-          account.replace(accountString, emptyString).toInt
-        )
-      )
-    } else {
-      value.map(account =>
-        authorisedAccounts.availableAccounts.filter(x => !x.isNiAccount)(
-          account.replace(accountString, emptyString).toInt
-        )
-      )
-    }
+    value.map(account => authorisedAccounts.availableAccounts(account.replace(accountString, emptyString).toInt))
   }
 
   private def populateForm(availableAccounts: Seq[CDSAccount])(implicit request: DataRequest[_]): Form[List[String]] =
@@ -188,9 +132,4 @@ class AccountsController @Inject() (
           .map { case (_, index) => s"account_$index" }
         form.fill(formValues)
     }
-
-  private def isNIOrCashOrGeneralGuaranteeAccountType(account: CDSAccount) =
-    account.isNiAccount ||
-      account.accountType.equals(CASH_ACCOUNT_TYPE) ||
-      account.accountType.equals(GENERAL_GUARANTEE_ACCOUNT_TYPE)
 }
diff --git a/app/controllers/add/AuthorisedUserController.scala b/app/controllers/add/AuthorisedUserController.scala
index 285815b5..f8902850 100644
--- a/app/controllers/add/AuthorisedUserController.scala
+++ b/app/controllers/add/AuthorisedUserController.scala
@@ -78,7 +78,7 @@ class AuthorisedUserController @Inject() (
       } yield result
     }
 
-  def doSubmission(userAnswers: UserAnswers, xiEori: String, gbEori: String)(implicit
+  private def doSubmission(userAnswers: UserAnswers, xiEori: String, eori: String)(implicit
     hc: HeaderCarrier
   ): Future[Result] =
     addAuthorityValidationService
@@ -87,10 +87,10 @@ class AuthorisedUserController @Inject() (
         Future.successful(errorPage("UserAnswers did not contain sufficient data to construct add authority request"))
       ) { payload =>
         val enteredEori = (userAnswers.data \ "eoriNumber" \ "eori").as[String]
-        val ownerEori   = if (enteredEori.startsWith(nIEORIPrefix)) xiEori else gbEori
+        val ownerEori   = if (enteredEori.startsWith(nIEORIPrefix)) xiEori else eori
 
         if (enteredEori.startsWith(nIEORIPrefix)) {
-          processPayloadForXIEori(userAnswers, xiEori, gbEori, payload)
+          processPayloadForXIEori(userAnswers, xiEori, eori, payload)
         } else {
           connector.grantAccountAuthorities(payload, ownerEori).map {
             case true  => Redirect(navigator.nextPage(AuthorisedUserPage, NormalMode, userAnswers))
diff --git a/app/controllers/edit/EditCheckYourAnswersController.scala b/app/controllers/edit/EditCheckYourAnswersController.scala
index 6073ded9..dba6f178 100644
--- a/app/controllers/edit/EditCheckYourAnswersController.scala
+++ b/app/controllers/edit/EditCheckYourAnswersController.scala
@@ -18,17 +18,17 @@ package controllers.edit
 
 import config.FrontendAppConfig
 import connectors.{CustomsDataStoreConnector, CustomsFinancialsConnector}
-import controllers.actions._
+import controllers.actions.*
 import controllers.grantAccountAuthRequestList
 import models.domain.AccountWithAuthoritiesWithId
 import models.requests.{AddAuthorityRequest, DataRequest, GrantAccountAuthorityRequest}
 import models.{ErrorResponse, MissingAccountError, MissingAuthorityError, NormalMode, UserAnswers}
 import navigation.Navigator
-import pages.edit._
+import pages.edit.*
 import play.api.Logging
-import play.api.i18n._
-import play.api.mvc._
-import services._
+import play.api.i18n.*
+import play.api.mvc.*
+import services.*
 import services.edit.EditAuthorityValidationService
 import uk.gov.hmrc.http.HeaderCarrier
 import uk.gov.hmrc.play.bootstrap.frontend.controller.FrontendBaseController
@@ -37,7 +37,7 @@ import viewmodels.CheckYourAnswersEditHelper
 import views.html.edit.EditCheckYourAnswersView
 
 import javax.inject.Inject
-import scala.concurrent._
+import scala.concurrent.*
 import scala.concurrent.duration.Duration
 
 class EditCheckYourAnswersController @Inject() (
@@ -109,15 +109,15 @@ class EditCheckYourAnswersController @Inject() (
     authorisedEori: String,
     account: AccountWithAuthoritiesWithId,
     xiEori: String,
-    gbEori: String
+    eori: String
   )(implicit hc: HeaderCarrier): Future[Result] = {
 
-    val ownerEori = if (authorisedEori.startsWith(nIEORIPrefix)) xiEori else gbEori
+    val ownerEori = if (authorisedEori.startsWith(nIEORIPrefix)) xiEori else eori
 
     editAuthorityValidationService.validate(userAnswers, accountId, authorityId, authorisedEori, account) match {
       case Right(payload) =>
         if (authorisedEori.startsWith(nIEORIPrefix)) {
-          processPayloadForXIEori(userAnswers, xiEori, gbEori, payload, accountId, authorityId)
+          processPayloadForXIEori(userAnswers, xiEori, eori, payload, accountId, authorityId)
         } else {
           connector.grantAccountAuthorities(payload, ownerEori).map {
             case true  =>
diff --git a/app/controllers/remove/RemoveCheckYourAnswers.scala b/app/controllers/remove/RemoveCheckYourAnswers.scala
index 9f13c804..1b953d92 100644
--- a/app/controllers/remove/RemoveCheckYourAnswers.scala
+++ b/app/controllers/remove/RemoveCheckYourAnswers.scala
@@ -112,10 +112,10 @@ class RemoveCheckYourAnswers @Inject() (
     accountId: String,
     authorityId: String,
     xiEori: String,
-    gbEori: String
+    eori: String
   )(implicit hc: HeaderCarrier): Future[Result] = {
 
-    val ownerEori = ownerEoriForAccountType(revokeRequest.accountType, revokeRequest.authorisedEori, xiEori, gbEori)
+    val ownerEori = ownerEoriForAccountType(revokeRequest.accountType, revokeRequest.authorisedEori, xiEori, eori)
 
     customsFinancialsConnector.revokeAccountAuthorities(revokeRequest, ownerEori).map {
       case true  => Redirect(routes.RemoveConfirmationController.onPageLoad(accountId, authorityId))
@@ -127,15 +127,15 @@ class RemoveCheckYourAnswers @Inject() (
     account: AccountType,
     authorisedEori: String,
     xiEori: String,
-    gbEori: String
+    eori: String
   ): String =
     if (authorisedEori.startsWith(nIEORIPrefix)) {
       account match {
-        case accn if accn == CdsCashAccount || accn == CdsGeneralGuaranteeAccount => gbEori
+        case accn if accn == CdsCashAccount || accn == CdsGeneralGuaranteeAccount => eori
         case _                                                                    => xiEori
       }
     } else {
-      gbEori
+      eori
     }
 
   private def errorPage(error: ErrorResponse): Result = {
diff --git a/app/models/AuthorisedAccounts.scala b/app/models/AuthorisedAccounts.scala
index 0d68bd9a..8c5d741c 100644
--- a/app/models/AuthorisedAccounts.scala
+++ b/app/models/AuthorisedAccounts.scala
@@ -17,6 +17,8 @@
 package models
 
 import models.domain.{CDSAccount, EORI}
+import utils.Constants.{CASH_ACCOUNT_TYPE, GENERAL_GUARANTEE_ACCOUNT_TYPE}
+import utils.StringUtils.gbEORIPrefix
 
 case class AuthorisedAccounts(
   alreadyAuthorisedAccounts: Seq[CDSAccount],
@@ -25,3 +27,38 @@ case class AuthorisedAccounts(
   pendingAccounts: Seq[CDSAccount],
   enteredEori: EORI
 )
+
+object AuthorisedAccounts {
+  def apply(
+    alreadyAuthorisedAccounts: Seq[CDSAccount],
+    availableAccounts: Seq[CDSAccount],
+    closedAccounts: Seq[CDSAccount],
+    pendingAccounts: Seq[CDSAccount],
+    enteredEori: EORI
+  ): AuthorisedAccounts = {
+
+    def isNIOrCashOrGeneralGuaranteeAccountType(account: CDSAccount) =
+      account.isNiAccount ||
+        account.accountType.equals(CASH_ACCOUNT_TYPE) ||
+        account.accountType.equals(GENERAL_GUARANTEE_ACCOUNT_TYPE)
+
+    enteredEori match {
+      case eori if eori.startsWith(gbEORIPrefix) =>
+        new AuthorisedAccounts(
+          alreadyAuthorisedAccounts,
+          availableAccounts.filter(!_.isNiAccount),
+          closedAccounts.filter(!_.isNiAccount),
+          pendingAccounts.filter(!_.isNiAccount),
+          enteredEori
+        )
+      case eori                                  =>
+        new AuthorisedAccounts(
+          alreadyAuthorisedAccounts,
+          availableAccounts.filter(isNIOrCashOrGeneralGuaranteeAccountType),
+          closedAccounts.filter(isNIOrCashOrGeneralGuaranteeAccountType),
+          pendingAccounts.filter(isNIOrCashOrGeneralGuaranteeAccountType),
+          enteredEori
+        )
+    }
+  }
+}
diff --git a/app/services/AuthorisedAccountsService.scala b/app/services/AuthorisedAccountsService.scala
index 58b1fcfe..509bc31b 100644
--- a/app/services/AuthorisedAccountsService.scala
+++ b/app/services/AuthorisedAccountsService.scala
@@ -17,10 +17,9 @@
 package services
 
 import models.AuthorisedAccounts
-import models.domain.{CDSAccount, EORI}
+import models.domain.EORI
 import models.requests.DataRequest
 import uk.gov.hmrc.http.HeaderCarrier
-import utils.StringUtils.gbEORIPrefix
 
 import javax.inject.Inject
 import scala.concurrent.{ExecutionContext, Future}
@@ -41,17 +40,9 @@ class AuthorisedAccountsService @Inject() (
       AuthorisedAccounts(
         accounts.alreadyAuthorised(availableAccountNumbers),
         accounts.canAuthoriseAccounts(availableAccountNumbers),
-        filterAccounts(enteredEori, accounts.closedAccounts),
-        filterAccounts(enteredEori, accounts.pendingAccounts),
+        accounts.closedAccounts,
+        accounts.pendingAccounts,
         enteredEori
       )
     }
-
-  def filterAccounts(enteredEori: EORI, accounts: Seq[CDSAccount]): Seq[CDSAccount] =
-    if (enteredEori.startsWith(gbEORIPrefix)) {
-      accounts.filter(!_.isNiAccount)
-    } else {
-      accounts.filter(_.isNiAccount)
-    }
-
 }
diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala
index 123d54f3..39b1c334 100644
--- a/project/AppDependencies.scala
+++ b/project/AppDependencies.scala
@@ -2,13 +2,13 @@ import sbt.*
 
 object AppDependencies {
 
-  private val bootstrapVersion = "9.5.0"
-  private val mongoVersion = "2.3.0"
+  private val bootstrapVersion = "9.10.0"
+  private val mongoVersion = "2.5.0"
 
   val compile: Seq[ModuleID] = Seq(
     play.sbt.PlayImport.ws,
     "uk.gov.hmrc" %% "bootstrap-frontend-play-30" % bootstrapVersion,
-    "uk.gov.hmrc" %% "play-frontend-hmrc-play-30" % "11.6.0",
+    "uk.gov.hmrc" %% "play-frontend-hmrc-play-30" % "11.11.0",
     "uk.gov.hmrc.mongo" %% "hmrc-mongo-play-30" % mongoVersion,
     "uk.gov.hmrc" %% "play-partials-play-30" % "10.0.0",
     "org.typelevel" %% "cats-core" % "2.10.0"
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 68be5614..e2f9cf8c 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -5,9 +5,9 @@ resolvers += "Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases
 
 addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.24.0")
 
-addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0")
+addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.6.0")
 
-addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.5")
+addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.6")
 
 addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0"
   exclude("org.scala-lang.modules", "scala-xml_2.12"))
diff --git a/test/controllers/AccountsControllerSpec.scala b/test/controllers/AccountsControllerSpec.scala
index 0906e5ea..8ebfd810 100644
--- a/test/controllers/AccountsControllerSpec.scala
+++ b/test/controllers/AccountsControllerSpec.scala
@@ -20,20 +20,21 @@ import base.SpecBase
 import config.FrontendAppConfig
 import forms.AccountsFormProvider
 import models.domain.{
-  AccountStatusClosed, AccountStatusOpen, CDSAccounts, CDSCashBalance, CashAccount, DutyDefermentAccount,
+  AccountStatusClosed, AccountStatusOpen, CDSAccount, CDSAccounts, CDSCashBalance, CashAccount, DutyDefermentAccount,
   DutyDefermentBalance, StandingAuthority
 }
 import models.{AuthorisedAccounts, CheckMode, CompanyDetails, InternalId, NormalMode, UserAnswers}
 import navigation.{FakeNavigator, Navigator}
+import org.mockito.ArgumentMatchers
 import org.mockito.ArgumentMatchers.any
-import org.mockito.Mockito.when
+import org.mockito.Mockito.{verify, when}
 import org.scalatestplus.mockito.MockitoSugar
 import pages.add.{AccountsPage, EoriNumberPage}
 import play.api.Application
 import play.api.data.Form
 import play.api.inject.bind
 import play.api.mvc.Call
-import play.api.test.Helpers._
+import play.api.test.Helpers.*
 import repositories.SessionRepository
 import services.{AccountsCacheService, AuthorisedAccountsService, AuthoritiesCacheService}
 import uk.gov.hmrc.http.InternalServerException
@@ -43,6 +44,7 @@ import views.html.{AccountsView, NoAvailableAccountsView, ServiceUnavailableView
 import java.time.LocalDate
 import scala.concurrent.Future
 
+// scalastyle:off file.size.limit
 class AccountsControllerSpec extends SpecBase with MockitoSugar {
   "Accounts Controller" must {
 
@@ -130,6 +132,62 @@ class AccountsControllerSpec extends SpecBase with MockitoSugar {
         }
       }
 
+      "user answers exists with EU EORI" in new Setup {
+        val application = applicationBuilder(userAnswers = Some(userAnswersCompanyDetailsEU))
+          .overrides(bind[AccountsCacheService].toInstance(mockAccountsCacheService))
+          .overrides(bind[AuthoritiesCacheService].toInstance(mockAuthoritiesCacheService))
+          .overrides(bind[AuthorisedAccountsService].toInstance(mockAuthorisedAccountService))
+          .build()
+
+        when(mockAccountsCacheService.retrieveAccounts(any[InternalId](), any())(any()))
+          .thenReturn(Future.successful(euAccounts))
+
+        when(mockAuthorisedAccountService.getAuthorisedAccounts(any())(any(), any()))
+          .thenReturn(
+            Future.successful(
+              AuthorisedAccounts(Seq.empty, euAuthorisedAccounts, euClosedAccount, Seq.empty, "DE123456789012")
+            )
+          )
+
+        running(application) {
+
+          val request   = fakeRequest(GET, accountsRoute)
+          val result    = route(application, request).value
+          val view      = application.injector.instanceOf[AccountsView]
+          val appConfig = application.injector.instanceOf[FrontendAppConfig]
+
+          status(result) mustEqual OK
+
+          contentAsString(result) mustEqual
+            view(
+              form,
+              AuthorisedAccounts(
+                Seq.empty,
+                Seq(
+                  DutyDefermentAccount(
+                    "123",
+                    "DE123456789012",
+                    AccountStatusOpen,
+                    DutyDefermentBalance(
+                      Some(bigDecimal100),
+                      Some(bigDecimal100),
+                      Some(bigDecimal100),
+                      Some(bigDecimal100)
+                    ),
+                    isNiAccount = true
+                  ),
+                  CashAccount("12345", "DE123456789012", AccountStatusOpen, CDSCashBalance(Some(bigDecimal100)))
+                ),
+                Seq(euClosedAccount.head),
+                Seq.empty,
+                "DE9876543210000"
+              ),
+              NormalMode,
+              backLinkRoute
+            )(request, messages(application), appConfig).toString
+        }
+      }
+
       "user answers exists with XI" in new Setup {
         val application = applicationBuilder(userAnswers = Some(userAnswersCompanyDetailsXI))
           .overrides(bind[AccountsCacheService].toInstance(mockAccountsCacheService))
@@ -328,6 +386,7 @@ class AccountsControllerSpec extends SpecBase with MockitoSugar {
           status(result) mustEqual SEE_OTHER
 
           redirectLocation(result).value mustEqual onwardRoute.url
+          verify(mockSessionRepository).set(ArgumentMatchers.eq(userAnswersOnSubmission))
         }
       }
 
@@ -358,6 +417,7 @@ class AccountsControllerSpec extends SpecBase with MockitoSugar {
 
           redirectLocation(result).value mustEqual
             controllers.add.routes.AuthorityStartController.onPageLoad(NormalMode).url
+          verify(mockSessionRepository).set(ArgumentMatchers.eq(userAnswersOnSubmission))
         }
       }
 
@@ -414,6 +474,47 @@ class AccountsControllerSpec extends SpecBase with MockitoSugar {
           status(result) mustEqual SEE_OTHER
           redirectLocation(result).value mustEqual
             controllers.add.routes.AuthorityStartController.onPageLoad(NormalMode).url
+          verify(mockSessionRepository).set(ArgumentMatchers.eq(userAnswersOnSubmissionXI))
+        }
+      }
+
+      "user answers exists in NormalMode with EU EORI" in new Setup {
+
+        val mockSessionRepository: SessionRepository = mock[SessionRepository]
+
+        when(mockSessionRepository.set(any())) thenReturn Future.successful(true)
+
+        val application: Application =
+          applicationBuilder(userAnswers = Some(userAnswersCompanyDetailsEU))
+            .overrides(
+              bind[Navigator].toInstance(new FakeNavigator(authStartNormalModeRoute)),
+              bind[SessionRepository].toInstance(mockSessionRepository),
+              bind[AccountsCacheService].toInstance(mockAccountsCacheService),
+              bind[AuthoritiesCacheService].toInstance(mockAuthoritiesCacheService),
+              bind[AuthorisedAccountsService].toInstance(mockAuthorisedAccountService)
+            )
+            .build()
+
+        when(mockAccountsCacheService.retrieveAccounts(any[InternalId](), any())(any()))
+          .thenReturn(Future.successful(euAccounts))
+
+        when(mockAuthorisedAccountService.getAuthorisedAccounts(any())(any(), any()))
+          .thenReturn(
+            Future.successful(
+              AuthorisedAccounts(Seq.empty, euAuthorisedAccounts, euClosedAccount, Seq.empty, "DE123456789012")
+            )
+          )
+
+        running(application) {
+          val request = fakeRequest(POST, accountsSubmitRouteInNormalMode)
+            .withFormUrlEncodedBody(("value[0]", answer.head))
+
+          val result = route(application, request).value
+
+          status(result) mustEqual SEE_OTHER
+          redirectLocation(result).value mustEqual
+            controllers.add.routes.AuthorityStartController.onPageLoad(NormalMode).url
+          verify(mockSessionRepository).set(ArgumentMatchers.eq(userAnswersOnSubmissionEU))
         }
       }
 
@@ -444,6 +545,7 @@ class AccountsControllerSpec extends SpecBase with MockitoSugar {
 
           redirectLocation(result).value mustEqual
             controllers.add.routes.AuthorityStartController.onPageLoad(CheckMode).url
+          verify(mockSessionRepository).set(ArgumentMatchers.eq(userAnswersOnSubmission))
         }
       }
 
@@ -544,6 +646,69 @@ class AccountsControllerSpec extends SpecBase with MockitoSugar {
           )(request, messages(application), appConfig).toString
       }
     }
+
+    "return a Bad Request and errors when invalid data is submitted with an EU EORI" in new Setup {
+      val application: Application = applicationBuilder(userAnswers = Some(userAnswersCompanyDetailsEU))
+        .overrides(
+          bind[AccountsCacheService].toInstance(mockAccountsCacheService),
+          bind[AuthoritiesCacheService].toInstance(mockAuthoritiesCacheService),
+          bind[AuthorisedAccountsService].toInstance(mockAuthorisedAccountService)
+        )
+        .build()
+
+      when(mockAccountsCacheService.retrieveAccounts(any[InternalId](), any())(any()))
+        .thenReturn(Future.successful(euAccounts))
+
+      when(mockAuthorisedAccountService.getAuthorisedAccounts(any())(any(), any()))
+        .thenReturn(
+          Future.successful(
+            AuthorisedAccounts(Seq.empty, euAuthorisedAccounts, euClosedAccount, Seq.empty, "DE123456789012")
+          )
+        )
+
+      running(application) {
+
+        val request = fakeRequest(POST, accountsRoute)
+          .withFormUrlEncodedBody(("value", "invalid value"))
+
+        val boundForm = form.bind(Map("value" -> "invalid value"))
+
+        val view      = application.injector.instanceOf[AccountsView]
+        val appConfig = application.injector.instanceOf[FrontendAppConfig]
+
+        val result = route(application, request).value
+
+        status(result) mustEqual BAD_REQUEST
+
+        contentAsString(result) mustEqual
+          view(
+            boundForm,
+            AuthorisedAccounts(
+              Seq.empty,
+              Seq(
+                DutyDefermentAccount(
+                  "123",
+                  "DE123456789012",
+                  AccountStatusOpen,
+                  DutyDefermentBalance(
+                    Some(bigDecimal100),
+                    Some(bigDecimal100),
+                    Some(bigDecimal100),
+                    Some(bigDecimal100)
+                  ),
+                  isNiAccount = true
+                ),
+                CashAccount("12345", "DE123456789012", AccountStatusOpen, CDSCashBalance(Some(bigDecimal100)))
+              ),
+              Seq(euClosedAccount.head),
+              Seq.empty,
+              "DE9876543210000"
+            ),
+            NormalMode,
+            backLinkRoute
+          )(request, messages(application), appConfig).toString
+      }
+    }
   }
 
   trait Setup {
@@ -565,20 +730,52 @@ class AccountsControllerSpec extends SpecBase with MockitoSugar {
     val formProvider             = new AccountsFormProvider()
     val form: Form[List[String]] = formProvider()
 
+    val answerAccounts: List[CashAccount] =
+      List(CashAccount("12345", "GB123456789012", AccountStatusOpen, CDSCashBalance(Some(bigDecimal100))))
+
     val userAnswersCompanyDetails: UserAnswers =
       emptyUserAnswers.set(EoriNumberPage, CompanyDetails("GB9876543210000", Some("name"))).success.value
 
+    val userAnswersOnSubmission: UserAnswers =
+      userAnswersCompanyDetails.set(AccountsPage, answerAccounts).success.value
+
     val userAnswersCompanyDetailsXI: UserAnswers =
       emptyUserAnswers.set(EoriNumberPage, CompanyDetails("XI9876543210000", Some("name"))).success.value
 
+    val userAnswersOnSubmissionXI: UserAnswers =
+      userAnswersCompanyDetailsXI
+        .set(
+          AccountsPage,
+          List(CashAccount("12345", "GB123456789012", AccountStatusOpen, CDSCashBalance(Some(bigDecimal100))))
+        )
+        .success
+        .value
+
+    val userAnswersCompanyDetailsEU: UserAnswers =
+      emptyUserAnswers.set(EoriNumberPage, CompanyDetails("DE9876543210000", Some("name"))).success.value
+
+    val userAnswersOnSubmissionEU: UserAnswers =
+      userAnswersCompanyDetailsEU
+        .set(
+          AccountsPage,
+          List(
+            DutyDefermentAccount(
+              "123",
+              "DE123456789012",
+              AccountStatusOpen,
+              DutyDefermentBalance(Some(bigDecimal100), Some(bigDecimal100), Some(bigDecimal100), Some(bigDecimal100)),
+              isNiAccount = true
+            )
+          )
+        )
+        .success
+        .value
+
     val standingAuthority: StandingAuthority =
       StandingAuthority("EORI", LocalDate.parse("2020-03-01"), Some(LocalDate.parse("2020-04-01")), viewBalance = false)
 
     val answer: List[String] = List("account_0")
 
-    val answerAccounts: List[CashAccount] =
-      List(CashAccount("12345", "GB123456789012", AccountStatusOpen, CDSCashBalance(Some(bigDecimal100))))
-
     val accounts: CDSAccounts =
       CDSAccounts(
         "GB123456789012",
@@ -595,14 +792,51 @@ class AccountsControllerSpec extends SpecBase with MockitoSugar {
         )
       )
 
+    val euAccounts: CDSAccounts =
+      CDSAccounts(
+        "DE123456789012",
+        List(
+          DutyDefermentAccount(
+            "123",
+            "DE123456789012",
+            AccountStatusOpen,
+            DutyDefermentBalance(Some(bigDecimal100), Some(bigDecimal100), Some(bigDecimal100), Some(bigDecimal100)),
+            isNiAccount = true
+          ),
+          DutyDefermentAccount(
+            "123",
+            "DE123456789012",
+            AccountStatusOpen,
+            DutyDefermentBalance(Some(bigDecimal100), Some(bigDecimal100), Some(bigDecimal100), Some(bigDecimal100))
+          ),
+          CashAccount("12345", "DE123456789012", AccountStatusOpen, CDSCashBalance(Some(bigDecimal100))),
+          CashAccount("23456", "DE123456789012", AccountStatusClosed, CDSCashBalance(Some(bigDecimal100)))
+        )
+      )
+
     val authorisedAccounts: List[CashAccount] = List(
       CashAccount("12345", "GB123456789012", AccountStatusOpen, CDSCashBalance(Some(amount100)))
     )
 
+    val euAuthorisedAccounts: List[CDSAccount] = List(
+      DutyDefermentAccount(
+        "123",
+        "DE123456789012",
+        AccountStatusOpen,
+        DutyDefermentBalance(Some(bigDecimal100), Some(bigDecimal100), Some(bigDecimal100), Some(bigDecimal100)),
+        isNiAccount = true
+      ),
+      CashAccount("12345", "DE123456789012", AccountStatusOpen, CDSCashBalance(Some(amount100)))
+    )
+
     private val closedAccount = List(
       CashAccount("23456", "GB123456789012", AccountStatusClosed, CDSCashBalance(Some(amount100)))
     )
 
+    val euClosedAccount = List(
+      CashAccount("23456", "DE123456789012", AccountStatusClosed, CDSCashBalance(Some(amount100)))
+    )
+
     val closedAccountXI: List[DutyDefermentAccount] =
       List(
         DutyDefermentAccount(
diff --git a/test/controllers/add/AuthorisedUserControllerSpec.scala b/test/controllers/add/AuthorisedUserControllerSpec.scala
index c8b63ff3..2c3b3c74 100644
--- a/test/controllers/add/AuthorisedUserControllerSpec.scala
+++ b/test/controllers/add/AuthorisedUserControllerSpec.scala
@@ -164,6 +164,31 @@ class AuthorisedUserControllerSpec extends SpecBase with MockitoSugar {
         }
       }
 
+    "redirect to next page for valid data when user has selected cash,guarantee and DD accounts " +
+      "and input EORI is EU EORI" in new SetUp {
+        val userAnswers: UserAnswers = userAnswersTodayToIndefiniteWithEuEori
+          .set(AccountsPage, List(cashAccount, generalGuarantee, dutyDeferment))
+          .success
+          .value
+
+        val app: Application = applicationWithUserAnswersAndEori(userAnswers, euEori, Some(mockDataStoreConnector))
+
+        when(mockValidator.validate(userAnswers))
+          .thenReturn(Some((accountsWithDDCashAndGuarantee, standingAuthority, authorisedUser)))
+        when(mockDataStoreConnector.getXiEori(any)(any)).thenReturn(Future.successful(None))
+
+        when(mockConnector.grantAccountAuthorities(any, ArgumentMatchers.eq(euEori))(any))
+          .thenReturn(Future.successful(true))
+
+        running(app) {
+          val request = fakeRequest(POST, onSubmitRoute)
+          val result  = route(app, request).value
+
+          status(result) mustEqual SEE_OTHER
+          verify(mockConnector, Mockito.times(1)).grantAccountAuthorities(any, any)(any)
+        }
+      }
+
     "redirect to error page for valid data when user has selected cash,guarantee and DD accounts " +
       "and input EORI is XI EORI but grant authority calls fail" in new SetUp {
         val userAnswers: UserAnswers = userAnswersTodayToIndefiniteWithXIEori
@@ -280,6 +305,7 @@ class AuthorisedUserControllerSpec extends SpecBase with MockitoSugar {
 
     val gbEori                 = "GB123456789012"
     val xiEori                 = "XI9876543210000"
+    val euEori                 = "DE9876543210000"
     val accountsString: String =
       AccountWithAuthorities(CdsCashAccount, "12345", Some(AccountStatusOpen), Seq.empty).toString
     val accounts: Accounts     = Accounts(Some(accountsString), Seq.empty, None)
@@ -327,6 +353,27 @@ class AuthorisedUserControllerSpec extends SpecBase with MockitoSugar {
         .success
         .value
 
+    val userAnswersTodayToIndefiniteWithEuEori: UserAnswers =
+      UserAnswers("id")
+        .set(AccountsPage, selectedAccounts)
+        .success
+        .value
+        .set(EoriNumberPage, CompanyDetails(gbEori, Some("companyName")))
+        .success
+        .value
+        .set(AuthorityStartPage, AuthorityStart.Today)(AuthorityStart.writes)
+        .success
+        .value
+        .set(EoriDetailsCorrectPage, EoriDetailsCorrect.Yes)(EoriDetailsCorrect.writes)
+        .success
+        .value
+        .set(ShowBalancePage, ShowBalance.Yes)(ShowBalance.writes)
+        .success
+        .value
+        .set(AuthorityDetailsPage, AuthorisedUser(emptyString, emptyString))
+        .success
+        .value
+
     val userAnswersTodayToIndefiniteWithXIEori: UserAnswers =
       UserAnswers("id")
         .set(AccountsPage, selectedAccounts)
diff --git a/test/controllers/edit/EditCheckYourAnswersControllerSpec.scala b/test/controllers/edit/EditCheckYourAnswersControllerSpec.scala
index 2b6f7460..c139bd49 100644
--- a/test/controllers/edit/EditCheckYourAnswersControllerSpec.scala
+++ b/test/controllers/edit/EditCheckYourAnswersControllerSpec.scala
@@ -47,6 +47,7 @@ import views.html.edit.EditCheckYourAnswersView
 import java.time.{LocalDate, LocalDateTime}
 import scala.concurrent.Future
 
+// scalastyle:off file.size.limit
 class EditCheckYourAnswersControllerSpec extends SpecBase with MockitoSugar {
   "onPageLoad" must {
     "return OK and the correct view for a GET" in new Setup {
@@ -474,6 +475,61 @@ class EditCheckYourAnswersControllerSpec extends SpecBase with MockitoSugar {
         }
       }
 
+    "Redirect to next page for valid data when user has selected cash, guarantee and DD accounts is submitted " +
+      "and authorised EORI is EU EORI" in new Setup {
+
+        val application: Application = applicationBuilder(Some(userAnswers), euEori)
+          .overrides(
+            inject.bind[CustomsFinancialsConnector].toInstance(mockConnector),
+            inject.bind[CustomsDataStoreConnector].toInstance(mockDataStoreConnector),
+            inject.bind[CheckYourAnswersValidationService].toInstance(mockValidator),
+            inject.bind[VerifyAccountNumbersAction].toInstance(new FakeVerifyAccountNumbersAction(userAnswers)),
+            inject.bind[AuthoritiesRepository].toInstance(mockAuthoritiesRepo),
+            inject.bind[EditAuthorityValidationService].toInstance(mockEditAuthorityValidationService),
+            inject.bind[AuthoritiesCacheService].toInstance(mockAuthCacheService)
+          )
+          .configure(Map("features.edit-journey" -> true))
+          .build()
+
+        when(mockDataStoreConnector.getCompanyName(anyString())(any()))
+          .thenReturn(Future.successful(Some("This business has not consented to their name being shared.")))
+
+        when(mockAuthoritiesRepo.get(any())).thenReturn(Future.successful(Some(authoritiesWithId)))
+        when(mockConnector.retrieveAccountAuthorities(any)(any)).thenReturn(
+          Future.successful(Seq(accWithAuthorities1))
+        )
+        when(mockAuthCacheService.retrieveAuthorities(any, any)(any)).thenReturn(
+          Future.successful(authoritiesWithId)
+        )
+        when(mockAuthCacheService.getAccountAndAuthority(any(), any(), any())(any()))
+          .thenReturn(Future.successful(Right(AccountAndAuthority(accountsWithAuthoritiesWithId, standingAuthority))))
+
+        when(mockDataStoreConnector.getXiEori(any)(any)).thenReturn(Future.successful(None))
+
+        val accounts: Accounts = Accounts(
+          Some(AccountWithAuthorities(CdsCashAccount, "12345", Some(AccountStatusOpen), Seq.empty)),
+          Seq("123456"),
+          Some("123456")
+        )
+
+        when(mockEditAuthorityValidationService.validate(any, any, any, any, any)).thenReturn(
+          Right(
+            AddAuthorityRequest(accounts, standingAuthority, AuthorisedUser("someName", "someRole"), editRequest = true)
+          )
+        )
+
+        when(mockConnector.grantAccountAuthorities(any, ArgumentMatchers.eq(euEori))(any))
+          .thenReturn(Future.successful(true))
+
+        running(application) {
+          val request = fakeRequest(POST, onSubmitRoute)
+          val result  = route(application, request).value
+
+          status(result) mustEqual SEE_OTHER
+          verify(mockConnector, Mockito.times(1)).grantAccountAuthorities(any, any)(any)
+        }
+      }
+
     "Redirect to next page when valid data is submitted for AccountAuthority with XI Eori " +
       "as authorised EORI " in new Setup {
 
@@ -711,6 +767,7 @@ class EditCheckYourAnswersControllerSpec extends SpecBase with MockitoSugar {
     private val authId    = "b"
 
     val gbEori = "GB123456789012"
+    val euEori = "DE123456789012"
 
     def onwardRoute: Call = Call("GET", "/foo")
 
diff --git a/test/controllers/remove/RemoveCheckYourAnswersControllerSpec.scala b/test/controllers/remove/RemoveCheckYourAnswersControllerSpec.scala
index 375642ea..e2cf07b5 100644
--- a/test/controllers/remove/RemoveCheckYourAnswersControllerSpec.scala
+++ b/test/controllers/remove/RemoveCheckYourAnswersControllerSpec.scala
@@ -186,6 +186,33 @@ class RemoveCheckYourAnswersControllerSpec extends SpecBase with MockitoSugar {
       }
     }
 
+    "redirect to confirmation page when successful and authorised EORI is EU" in new Setup {
+      private val userAnswers = emptyUserAnswers.set(RemoveAuthorisedUserPage("a", "b"), authUser).get
+
+      val app: Application =
+        applicationWithUserAnswersAndEori(
+          userAnswers,
+          euEori,
+          financialConnector = Some(mockCustomsFinancialsConnector)
+        )
+
+      when(mockAuthoritiesCacheService.getAccountAndAuthority(any(), any(), any())(any()))
+        .thenReturn(Future.successful(Right(AccountAndAuthority(accountsWithAuthoritiesWithId, standingAuthority))))
+
+      when(mockCustomsFinancialsConnector.revokeAccountAuthorities(any(), any())(any()))
+        .thenReturn(Future.successful(true))
+
+      running(app) {
+        val result = route(app, postRequest).value
+
+        status(result) mustBe SEE_OTHER
+        redirectLocation(result).value mustBe
+          controllers.remove.routes.RemoveConfirmationController.onPageLoad("a", "b").url
+        verify(mockCustomsFinancialsConnector, Mockito.times(1))
+          .revokeAccountAuthorities(any(), ArgumentMatchers.eq(euEori))(any)
+      }
+    }
+
     "redirect to confirmation page and use GB Eori as ownerEori when authorisedEori is XI Eori " +
       "and account type is CdsCashAccount" in new Setup {
         val userAnswers: UserAnswers =
@@ -301,6 +328,7 @@ class RemoveCheckYourAnswersControllerSpec extends SpecBase with MockitoSugar {
 
     val gbEori                   = "GB123456789012"
     val xiEori                   = "XI123456789012"
+    val euEori                   = "DE123456789012"
     val authUser: AuthorisedUser = AuthorisedUser("test", "test")
 
     val standingAuthority: StandingAuthority           = StandingAuthority("EORI", startDate, Some(endDate), viewBalance = false)
diff --git a/test/models/AuthorisedAccountsSpec.scala b/test/models/AuthorisedAccountsSpec.scala
new file mode 100644
index 00000000..31496a63
--- /dev/null
+++ b/test/models/AuthorisedAccountsSpec.scala
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2025 HM Revenue & Customs
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package models
+
+import base.SpecBase
+import models.domain.{
+  AccountStatusOpen, CDSCashBalance, CashAccount, DutyDefermentAccount, DutyDefermentBalance, GeneralGuaranteeAccount
+}
+
+class AuthorisedAccountsSpec extends SpecBase {
+
+  "AuthorisedAccounts.apply" when {
+
+    "the EORI starts with GB" should {
+      "exclude NI accounts from available, closed, and pending" in new Setup {
+        val result = AuthorisedAccounts(input, input, input, input, "GB123456789012")
+
+        result.alreadyAuthorisedAccounts mustBe input
+        result.availableAccounts must contain theSameElementsAs Seq(ddGb, cash, guar)
+        result.closedAccounts    must contain theSameElementsAs Seq(ddGb, cash, guar)
+        result.pendingAccounts   must contain theSameElementsAs Seq(ddGb, cash, guar)
+      }
+    }
+
+    "the EORI does not start with GB" should {
+      "keep only NI, cash, or general guarantee accounts" in new Setup {
+        val result = AuthorisedAccounts(input, input, input, input, "XI123456789012")
+
+        result.alreadyAuthorisedAccounts mustBe input
+        result.availableAccounts must contain theSameElementsAs Seq(ddNi, cash, guar)
+        result.closedAccounts    must contain theSameElementsAs Seq(ddNi, cash, guar)
+        result.pendingAccounts   must contain theSameElementsAs Seq(ddNi, cash, guar)
+      }
+    }
+  }
+
+  trait Setup {
+    val ddNi  =
+      DutyDefermentAccount("DD", "owner", AccountStatusOpen, DutyDefermentBalance(None, None, None, None), true)
+    val ddGb  = DutyDefermentAccount("DD", "owner", AccountStatusOpen, DutyDefermentBalance(None, None, None, None))
+    val cash  = CashAccount("CASH", "owner", AccountStatusOpen, CDSCashBalance(None))
+    val guar  = GeneralGuaranteeAccount("GUA", "owner", AccountStatusOpen, None)
+    val input = Seq(ddNi, ddGb, cash, guar)
+  }
+}
diff --git a/test/services/AuthorisedAccountsServiceSpec.scala b/test/services/AuthorisedAccountsServiceSpec.scala
index cd8c7c93..ed2d5639 100644
--- a/test/services/AuthorisedAccountsServiceSpec.scala
+++ b/test/services/AuthorisedAccountsServiceSpec.scala
@@ -35,8 +35,8 @@ import uk.gov.hmrc.auth.core.retrieve.{Credentials, Name}
 import uk.gov.hmrc.http.HeaderCarrier
 import utils.StringUtils.emptyString
 
-import scala.concurrent.ExecutionContext.Implicits.global
 import java.time.LocalDate
+import scala.concurrent.ExecutionContext.Implicits.global
 import scala.concurrent.Future
 
 class AuthorisedAccountsServiceSpec extends SpecBase {
@@ -47,38 +47,19 @@ class AuthorisedAccountsServiceSpec extends SpecBase {
 
       when(mockAuthCacheService.retrieveAuthorities(any, any)(any)).thenReturn(Future.successful(authoritiesWithId))
 
-      when(mockAccCacheService.retrieveAccounts(any, any)(any)).thenReturn(
-        Future.successful(accounts)
-      )
+      when(mockAccCacheService.retrieveAccounts(any, any)(any)).thenReturn(Future.successful(accounts))
 
-      authorisedAccountsService.getAuthorisedAccounts(gbEori)(dataRequest(userAnswers, gbEori), hc).map { authAcc =>
+      authorisedAccountsService.getAuthorisedAccounts(eori)(dataRequest(userAnswers, eori), hc).map { authAcc =>
         authAcc mustBe authAccounts
       }
     }
   }
 
-  "filterAccounts" should {
-    "return correct CDSAccount for GB Eori" in new Setup {
-      authorisedAccountsService.filterAccounts(gbEori, cdsAccounts) mustBe Seq(cashAccount)
-    }
-
-    "return correct CDSAccount for XI Eori" in new Setup {
-      authorisedAccountsService.filterAccounts(xiEori, cdsAccounts) mustBe Seq(cashAccoiuntForNI)
-    }
-  }
-
   trait Setup {
-    val xiEori = "XI098765432109"
-    val gbEori = "GB098765432109"
+    val eori = "GB098765432109"
 
-    val cashAccount: CashAccount =
+    val cashAccount: CashAccount       =
       CashAccount("12345", "GB123456789012", AccountStatusOpen, CDSCashBalance(Some(100.00)))
-
-    val cashAccoiuntForNI: CashAccount =
-      CashAccount("54321", "GB098765432109", AccountStatusOpen, CDSCashBalance(Some(100.00)), isNiAccount = true)
-
-    val cdsAccounts: Seq[CashAccount] = Seq(cashAccount, cashAccoiuntForNI)
-
     val openCashAccount: CashAccount   =
       CashAccount("23456", "GB123456789012", AccountStatusClosed, CDSCashBalance(Some(100.00)))
     val closedCashAccount: CashAccount =
@@ -93,9 +74,7 @@ class AuthorisedAccountsServiceSpec extends SpecBase {
       AccountWithAuthoritiesWithId(CdsCashAccount, "12345", Some(AccountStatusOpen), Map("b" -> standingAuthority))
 
     val authoritiesWithId: AuthoritiesWithId = AuthoritiesWithId(
-      Map(
-        "a" -> accountsWithAuthoritiesWithId
-      )
+      Map("a" -> accountsWithAuthoritiesWithId)
     )
 
     val authAccounts: AuthorisedAccounts = AuthorisedAccounts(


Reviews:
user: login: jamie2210
body: LGTM
state: DISMISSED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T10:54:09Z
user: login: Matthew-George-Tyler
state: DISMISSED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T11:18:57Z
user: login: magicaljellybeans
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T11:26:50Z
user: login: tyagikumarvineet
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T18:31:58Z
user: login: tyagikumarvineet
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-03-07T18:59:04Z

Review comments:
diff_hunk: @@ -47,6 +47,7 @@ import views.html.edit.EditCheckYourAnswersView
 import java.time.{LocalDate, LocalDateTime}
 import scala.concurrent.Future
 
+// scalastyle:off file.size.limit
 class EditCheckYourAnswersControllerSpec extends SpecBase with MockitoSugar {
path: test/controllers/edit/EditCheckYourAnswersControllerSpec.scala
user: login: Matthew-George-Tyler
body: Can we remove unused code.
created_at: 2025-03-06T16:16:27Z
author_association: CONTRIBUTOR
diff_hunk: @@ -47,6 +47,7 @@ import views.html.edit.EditCheckYourAnswersView
 import java.time.{LocalDate, LocalDateTime}
 import scala.concurrent.Future
 
+// scalastyle:off file.size.limit
 class EditCheckYourAnswersControllerSpec extends SpecBase with MockitoSugar {
path: test/controllers/edit/EditCheckYourAnswersControllerSpec.scala
user: login: magicaljellybeans
body: I can't really see any tbh - file could probably be refactored to be shorter but fact is between our code style and number of custom application definitions/when clauses, it's just a long file.
created_at: 2025-03-07T11:26:50Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,57 @@
+/*
+ * Copyright 2025 HM Revenue & Customs
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package models
+
+import base.SpecBase
+import models.domain.{
+  AccountStatusOpen, CDSCashBalance, CashAccount, DutyDefermentAccount, DutyDefermentBalance, GeneralGuaranteeAccount
+}
+
+class AuthorisedAccountsSpec extends SpecBase {
+
+  "AuthorisedAccounts.apply" when {
+
+    "the EORI starts with GB" should {
+      "exclude NI accounts from available, closed, and pending" in new Setup {
+        val result = AuthorisedAccounts(input, input, input, input, "GB123456789012")
+        result.alreadyAuthorisedAccounts mustBe input
path: test/models/AuthorisedAccountsSpec.scala
user: login: tyagikumarvineet
body: Better to give a line break before this line to distinguish between result and the assertions to make it more readable. 
Same comment for line 41 
created_at: 2025-03-07T18:30:03Z
author_association: CONTRIBUTOR

PR comments:
user: login: platops-pr-bot
created_at: 2025-03-06T11:27:21Z
body: - `uk.gov.hmrc.sbt-distributables` can be updated to `2.6.0` in [project/plugins.sbt](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/plugins.sbt#L8)
- uk.gov.hmrc:bootstrap-frontend-play-30 can be updated from 9.5.0 to 9.10.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).
- uk.gov.hmrc:play-frontend-hmrc-play-30 can be updated from 11.6.0 to 11.11.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).
- uk.gov.hmrc.mongo:hmrc-mongo-play-30 can be updated from 2.3.0 to 2.5.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).
- uk.gov.hmrc:bootstrap-test-play-30 can be updated from 9.5.0 to 9.10.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).
- There is a bobby warning (builds will be prevented after 30 Jun 2025) - see the pr builder for details
- There is a bobby warning (builds will be prevented after 14 Jul 2025) - see the pr builder for details
author_association: NONE
user: login: platops-pr-bot
created_at: 2025-03-06T15:14:58Z
body: - ~~`uk.gov.hmrc.sbt-distributables` can be updated to `2.6.0` in [project/plugins.sbt](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/plugins.sbt#L8)~~
- ~~uk.gov.hmrc:bootstrap-frontend-play-30 can be updated from 9.5.0 to 9.10.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).~~
- ~~uk.gov.hmrc:play-frontend-hmrc-play-30 can be updated from 11.6.0 to 11.11.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).~~
- ~~uk.gov.hmrc.mongo:hmrc-mongo-play-30 can be updated from 2.3.0 to 2.5.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).~~
- ~~uk.gov.hmrc:bootstrap-test-play-30 can be updated from 9.5.0 to 9.10.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).~~
- ~~There is a bobby warning (builds will be prevented after 14 Jul 2025) - see the pr builder for details~~
- `uk.gov.hmrc.http-verbs-play-30` can be removed - it is already provided by `uk.gov.hmrc.bootstrap-test-play-30`
- Runtime issues may occur. Change `org.playframework:sbt-plugin` to `3.0.6` in [project/plugins.sbt](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/plugins.sbt#L10) - to match what `uk.gov.hmrc.bootstrap-frontend-play-30` uses
- There is a bobby warning (builds will be prevented after 30 Jun 2025) - see the pr builder for details
author_association: NONE
user: login: platops-pr-bot
created_at: 2025-03-06T15:24:12Z
body: - ~~`uk.gov.hmrc.sbt-distributables` can be updated to `2.6.0` in [project/plugins.sbt](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/plugins.sbt#L8)~~
- ~~uk.gov.hmrc:bootstrap-frontend-play-30 can be updated from 9.5.0 to 9.10.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).~~
- ~~uk.gov.hmrc:play-frontend-hmrc-play-30 can be updated from 11.6.0 to 11.11.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).~~
- ~~uk.gov.hmrc.mongo:hmrc-mongo-play-30 can be updated from 2.3.0 to 2.5.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).~~
- ~~uk.gov.hmrc:bootstrap-test-play-30 can be updated from 9.5.0 to 9.10.0 in [project/AppDependencies.scala](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/AppDependencies.scala#L1).~~
- ~~There is a bobby warning (builds will be prevented after 14 Jul 2025) - see the pr builder for details~~
- ~~Runtime issues may occur. Change `org.playframework:sbt-plugin` to `3.0.6` in [project/plugins.sbt](https://github.com/hmrc/customs-manage-authorities-frontend/blob/MMCA-5208/project/plugins.sbt#L10) - to match what `uk.gov.hmrc.bootstrap-frontend-play-30` uses~~
- `uk.gov.hmrc.http-verbs-play-30` can be removed - it is already provided by `uk.gov.hmrc.bootstrap-test-play-30`
- There is a bobby warning (builds will be prevented after 30 Jun 2025) - see the pr builder for details
author_association: NONE