Skip to content

Commit

Permalink
Merge pull request #184 from hmrc/DLS-3692
Browse files Browse the repository at this point in the history
  • Loading branch information
lutnos authored Feb 19, 2021
2 parents d15e40e + 09d3287 commit aef577e
Show file tree
Hide file tree
Showing 34 changed files with 53 additions and 60 deletions.
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/helptosavestub/config/AppConfig.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down Expand Up @@ -28,37 +28,31 @@ trait BankDetailsBehaviour {
val allowedSeparators: Set[Char] = Set(' ', '-', '–', '−', '—')

def getBankProfile(bankDetails: BankDetails): Profile = {
val accountNumberWithSortCodeIsValid =
if (bankDetails.accountNumber.startsWith("9")) {
Some(false)
} else if (bankDetails.accountNumber.startsWith("5")) {
None
} else if (!validateSortCode(bankDetails.sortCode)) {
Some(false)
} else if (!validateAccountNumber(bankDetails.accountNumber)) {
Some(false)
} else {
Some(true)
}
val accountNumberWithSortCodeIsValid = bankDetails match {
case BankDetails(_, accountNumber) if accountNumber.startsWith("9") => Some(false)
case BankDetails(_, accountNumber) if accountNumber.startsWith("5") => None
case BankDetails(sortCode, _) if !validateSortCode(sortCode) => Some(false)
case BankDetails(_, accountNumber) if !validateAccountNumber(accountNumber) => Some(false)
case _ => Some(true)
}

val sortCodeIsPresentOnEISCD =
if (bankDetails.sortCode.startsWith("9")) {
"no"
} else if (bankDetails.sortCode.startsWith("5")) {
"whoopsie"
} else {
"yes"
bankDetails match {
case BankDetails(_, accountNumber) if accountNumber.startsWith("9") => "no"
case BankDetails(_, accountNumber) if accountNumber.startsWith("5") => "whoopsie"
case _ => "yes"
}

val barsResponse =
accountNumberWithSortCodeIsValid.map(a BARSResponse(a, sortCodeIsPresentOnEISCD))

if (bankDetails.accountNumber.startsWith("707")) {
Profile(barsResponse, CreateAccountResponse(Left(NSIErrorResponse.incorrectAccountNumber)))
} else if (bankDetails.sortCode.startsWith("70-3")) {
Profile(barsResponse, CreateAccountResponse(Left(NSIErrorResponse.incorrectSortCode)))
} else {
Profile(barsResponse, CreateAccountResponse(Right(())))
bankDetails match {
case BankDetails(_, accountNumber) if accountNumber.startsWith("707") =>
Profile(barsResponse, CreateAccountResponse(Left(NSIErrorResponse.incorrectAccountNumber)))
case BankDetails(sortCode, _) if sortCode.startsWith("70-3") =>
Profile(barsResponse, CreateAccountResponse(Left(NSIErrorResponse.incorrectSortCode)))
case _ =>
Profile(barsResponse, CreateAccountResponse(Right(())))
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand All @@ -24,7 +24,6 @@ import cats.data.Validated.{Invalid, Valid}
import cats.data.{Validated, ValidatedNel}
import cats.instances.string._
import cats.syntax.apply._
import cats.syntax.either._
import cats.syntax.eq._
import com.google.inject.{Inject, Singleton}
import org.scalacheck.Gen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/helptosavestub/controllers/package.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/helptosavestub/models/BankDetails.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/helptosavestub/models/NSIPayload.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/helptosavestub/util/Delays.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/helptosavestub/util/ErrorJson.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/helptosavestub/util/Logging.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
2 changes: 1 addition & 1 deletion app/uk/gov/hmrc/helptosavestub/util/package.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
2 changes: 1 addition & 1 deletion conf/application.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 HM Revenue & Customs
# Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down
4 changes: 2 additions & 2 deletions test/uk/gov/hmrc/helptosavestub/util/DelaysSpec.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand All @@ -24,7 +24,7 @@ import org.scalatest.matchers.should.Matchers

import uk.gov.hmrc.helptosavestub.util.Delays.DelayConfig

import scala.concurrent.{Await, ExecutionContext, Future, TimeoutException}
import scala.concurrent.{Await, Future, TimeoutException}
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._

Expand Down
2 changes: 1 addition & 1 deletion test/uk/gov/hmrc/helptosavestub/util/UnitSpec.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 HM Revenue & Customs
* Copyright 2021 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.
Expand Down

0 comments on commit aef577e

Please sign in to comment.