Skip to content

Commit

Permalink
Merge pull request #111 from hmrc/MTDSA-1469
Browse files Browse the repository at this point in the history
MTDSA-1469 Add VRN_NOT_FOUND error to View VAT Returns
  • Loading branch information
jonathanleather authored Apr 16, 2018
2 parents ccf62e9 + 55b3416 commit dfdc578
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/uk/gov/hmrc/vatapi/models/des/DesError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ object DesErrorCode extends Enumeration {
INVALID_IDNUMBER,
INVALID_DATETO,
INVALID_DATEFROM,
NOT_FOUND
NOT_FOUND,
VRN_NOT_FOUND
= Value

implicit val format: Format[DesErrorCode] = EnumJson.enumFormat(DesErrorCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import play.api.mvc.Result
import play.api.mvc.Results.{BadRequest, InternalServerError}
import uk.gov.hmrc.http.HttpResponse
import uk.gov.hmrc.vatapi.httpparsers.NRSData
import uk.gov.hmrc.vatapi.models.des.DesErrorCode.{DATE_RANGE_TOO_LARGE, DUPLICATE_SUBMISSION, INVALID_ARN, INVALID_PAYLOAD, INVALID_PERIODKEY, INVALID_VRN}
import uk.gov.hmrc.vatapi.models.des.DesErrorCode._
import uk.gov.hmrc.vatapi.models.{DesTransformError, DesTransformValidator, Errors, VatReturn, des}
import uk.gov.hmrc.vatapi.resources.VatReturnsResource.Forbidden

Expand Down Expand Up @@ -51,6 +51,7 @@ case class VatReturnResponse(underlying: HttpResponse) extends Response {
case 400 if errorCodeIsOneOf(INVALID_PERIODKEY) => BadRequest(toJson(Errors.InvalidPeriodKey))
case 400 if errorCodeIsOneOf(DUPLICATE_SUBMISSION) => Forbidden(toJson(Errors.businessError(Errors.DuplicateVatSubmission)))
case 403 if errorCodeIsOneOf(DATE_RANGE_TOO_LARGE) => Forbidden(toJson(Errors.businessError(Errors.DateRangeTooLarge)))
case 403 if errorCodeIsOneOf(VRN_NOT_FOUND) => InternalServerError(toJson(Errors.InternalServerError))
}
}

Expand Down
11 changes: 11 additions & 0 deletions func/uk/gov/hmrc/vatapi/resources/ValueAddedTaxReturnsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ class ValueAddedTaxReturnsSpec extends BaseFunctionalSpec {
.bodyHasPath("\\errors(0)\\code", "DATE_RANGE_TOO_LARGE")
}

"return internal server error (500) if the vat returns with DES vrn not found error" in {
given()
.userIsFullyAuthorisedForTheResource
.des().vatReturns.expectVatReturnRetrieveToFail(vrn, "VRN_NOT_FOUND")
.when()
.get(s"/$vrn/returns/0001")
.thenAssertThat()
.statusIs(500)
.bodyHasPath("\\code", "INTERNAL_SERVER_ERROR")
}

"return bad request (400) if the periodKey is invalid" in {
given()
.userIsFullyAuthorisedForTheResource
Expand Down

0 comments on commit dfdc578

Please sign in to comment.