Skip to content

Commit 88358d9

Browse files
Chandrashekhar KoriviChandrashekhar Korivi
authored andcommitted
[MTDSA-1171] [CK] Remove vat context, add periodKey, change metDate to received.
1 parent 702c27f commit 88358d9

File tree

9 files changed

+57
-48
lines changed

9 files changed

+57
-48
lines changed

app/uk/gov/hmrc/vatapi/models/Obligations.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object Obligations {
2828
implicit val writes: Writes[Obligations] = Json.writes[Obligations]
2929
}
3030

31-
case class Obligation(start: LocalDate, end: LocalDate, due: LocalDate, met: Boolean, metDate : Option[LocalDate] = None)
31+
case class Obligation(start: LocalDate, end: LocalDate, due: LocalDate, met: Boolean, periodKey : String, received : Option[LocalDate] = None)
3232

3333
object Obligation {
3434
implicit val jodaDateWrites: Writes[LocalDate] = new Writes[LocalDate] {
@@ -42,7 +42,8 @@ object Obligation {
4242
end = LocalDate.parse(desObligation.inboundCorrespondenceToDate),
4343
due = LocalDate.parse(desObligation.inboundCorrespondenceDueDate),
4444
met = desObligation.isFulfilled,
45-
metDate = desObligation.inboundCorrespondenceDateReceived.map(LocalDate.parse))
45+
periodKey = desObligation.periodKey,
46+
received = desObligation.inboundCorrespondenceDateReceived.map(LocalDate.parse))
4647
) match {
4748
case Success(obj) => Right(obj)
4849
case Failure(ex) => Left(InvalidDateError(s"Unable to parse the date from des response $ex"))

conf/live.routes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# microservice specific routes
22

33
# Obligations
4-
GET /vat/:vrn/obligations uk.gov.hmrc.vatapi.resources.ObligationsResource.retrieveObligations(vrn: uk.gov.hmrc.domain.Vrn, queryParams: uk.gov.hmrc.vatapi.models.ObligationsQueryParams)
4+
GET /:vrn/obligations uk.gov.hmrc.vatapi.resources.ObligationsResource.retrieveObligations(vrn: uk.gov.hmrc.domain.Vrn, queryParams: uk.gov.hmrc.vatapi.models.ObligationsQueryParams)

func/uk/gov/hmrc/vatapi/resources/DesJsons.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,28 @@ object DesJsons {
8181
| "inboundCorrespondenceToDate": "2017-07-05",
8282
| "inboundCorrespondenceDateReceived": "2017-08-01",
8383
| "inboundCorrespondenceDueDate": "2017-08-05",
84-
| "periodKey": "004"
84+
| "periodKey": "#001"
8585
| },
8686
| {
8787
| "status": "O",
8888
| "inboundCorrespondenceFromDate": "2017-07-06",
8989
| "inboundCorrespondenceToDate": "2017-10-05",
9090
| "inboundCorrespondenceDueDate": "2017-11-05",
91-
| "periodKey": "004"
91+
| "periodKey": "#002"
9292
| },
9393
| {
9494
| "status": "O",
9595
| "inboundCorrespondenceFromDate": "2017-10-06",
9696
| "inboundCorrespondenceToDate": "2018-01-05",
9797
| "inboundCorrespondenceDueDate": "2018-02-05",
98-
| "periodKey": "004"
98+
| "periodKey": "#003"
9999
| },
100100
| {
101101
| "status": "O",
102102
| "inboundCorrespondenceFromDate": "2018-01-06",
103103
| "inboundCorrespondenceToDate": "2018-04-05",
104104
| "inboundCorrespondenceDueDate": "2018-05-06",
105-
| "periodKey": "004"
105+
| "periodKey": "#004"
106106
| }
107107
| ]
108108
| },

func/uk/gov/hmrc/vatapi/resources/ObligationsResourceSpec.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,64 +8,64 @@ class ObligationsResourceSpec extends BaseFunctionalSpec {
88

99
"return code 400 when vrn is invalid" in {
1010
when()
11-
.get(s"/vat/abc/obligations?from=2017-01-01&to=2017-03-31&status=A")
11+
.get(s"/abc/obligations?from=2017-01-01&to=2017-03-31&status=A")
1212
.thenAssertThat()
1313
.statusIs(400)
1414
.isBadRequest("VRN_INVALID")
1515
}
1616

1717
"return code 400 when from is missing" in {
1818
when()
19-
.get(s"/vat/$vrn/obligations?to=2017-03-31&status=A")
19+
.get(s"/$vrn/obligations?to=2017-03-31&status=A")
2020
.thenAssertThat()
2121
.statusIs(400)
2222
}
2323

2424
"return code 400 when from is invalid" in {
2525
when()
26-
.get(s"/vat/$vrn/obligations?from=abc&to=2017-03-31&status=A")
26+
.get(s"/$vrn/obligations?from=abc&to=2017-03-31&status=A")
2727
.thenAssertThat()
2828
.statusIs(400)
2929
}
3030

3131
"return code 400 when to is missing" in {
3232
when()
33-
.get(s"/vat/$vrn/obligations?from=2017-01-01&status=A")
33+
.get(s"/$vrn/obligations?from=2017-01-01&status=A")
3434
.thenAssertThat()
3535
.statusIs(400)
3636
}
3737

3838
"return code 400 when to is invalid" in {
3939
when()
40-
.get(s"/vat/$vrn/obligations?from=2017-01-01&to=abc&status=A")
40+
.get(s"/$vrn/obligations?from=2017-01-01&to=abc&status=A")
4141
.thenAssertThat()
4242
.statusIs(400)
4343
}
4444

4545
"return code 400 when status is missing" in {
4646
when()
47-
.get(s"/vat/$vrn/obligations?from=2017-01-01&to=2017-03-31")
47+
.get(s"/$vrn/obligations?from=2017-01-01&to=2017-03-31")
4848
.thenAssertThat()
4949
.statusIs(400)
5050
}
5151

5252
"return code 400 when status is invalid" in {
5353
when()
54-
.get(s"/vat/$vrn/obligations?from=2017-01-01&to=2017-03-31&status=X")
54+
.get(s"/$vrn/obligations?from=2017-01-01&to=2017-03-31&status=X")
5555
.thenAssertThat()
5656
.statusIs(400)
5757
}
5858

5959
"return code 400 when from is after to" in {
6060
when()
61-
.get(s"/vat/$vrn/obligations?from=2017-04-01&to=2017-03-31&status=A")
61+
.get(s"/$vrn/obligations?from=2017-04-01&to=2017-03-31&status=A")
6262
.thenAssertThat()
6363
.statusIs(400)
6464
}
6565

6666
"return code 400 when date range between from and to is more than 366 days" in {
6767
when()
68-
.get(s"/vat/$vrn/obligations?from=2017-01-01&to=2018-01-02&status=A")
68+
.get(s"/$vrn/obligations?from=2017-01-01&to=2018-01-02&status=A")
6969
.thenAssertThat()
7070
.statusIs(400)
7171
}
@@ -74,7 +74,7 @@ class ObligationsResourceSpec extends BaseFunctionalSpec {
7474
given()
7575
.des().obligations.obligationNotFoundFor(vrn)
7676
.when()
77-
.get(s"/vat/$vrn/obligations?from=2017-01-01&to=2017-08-31&status=A")
77+
.get(s"/$vrn/obligations?from=2017-01-01&to=2017-08-31&status=A")
7878
.thenAssertThat()
7979
.statusIs(404)
8080
}
@@ -83,7 +83,7 @@ class ObligationsResourceSpec extends BaseFunctionalSpec {
8383
given()
8484
.des().obligations.returnObligationsFor(vrn)
8585
.when()
86-
.get(s"/vat/$vrn/obligations?from=2017-01-01&to=2017-08-31&status=A")
86+
.get(s"/$vrn/obligations?from=2017-01-01&to=2017-08-31&status=A")
8787
.thenAssertThat()
8888
.statusIs(200)
8989
.bodyIsLike(Jsons.Obligations(firstMet = true).toString)

public/api/conf/0.1/application.raml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,13 @@ traits:
3838
description: Vat registration number.
3939
type: string
4040
example: "123456789"
41-
/periods/{periodKey}:
42-
description: Submit VAT return for period.
43-
uriParameters:
44-
periodKey:
45-
description: Identifier for the period of the VAT return
46-
type: string
47-
example: "#001"
48-
post:
49-
description: Submit VAT return for period.
50-
body:
51-
application/json:
52-
type: !include schemas/submitVatReturn.json
53-
example: !include examples/vatReturn.json
54-
responses:
55-
200:
56-
headers:
57-
X-CorrelationId:
58-
example: 5968c22d620000620096db5f
59-
description: Unique id for operation tracking
6041
/obligations:
6142
displayName: Retrieve all VAT obligations
6243
description: Retrieve all VAT obligations
6344
(annotations.sandboxData): !include scenarios/vat-obligation-scenarios.md
6445
is: [contentType, testScenarioHeader]
46+
(annotations.scope): "read:vat"
47+
securedBy: [ sec.oauth_2_0: { scopes: [ "read:vat" ] } ]
6548
get:
6649
description: Retrieve all VAT obligations.
6750
queryParameters:
@@ -76,7 +59,7 @@ traits:
7659
example: 2017-01-25
7760
required: true
7861
status:
79-
description: Which obligation statuses to return (O=Open,C=Closed,A=All)
62+
description: Which obligation statuses to return (O=Open, F=Fulfilled, A=All)
8063
type: string
8164
example: A
8265
required: true
@@ -115,3 +98,24 @@ traits:
11598
description: Invalid status
11699
value:
117100
code: INVALID_STATUS
101+
/periods/{periodKey}:
102+
description: Submit VAT return for period.
103+
(annotations.scope): "write:vat"
104+
securedBy: [ sec.oauth_2_0: { scopes: [ "write:vat" ] } ]
105+
uriParameters:
106+
periodKey:
107+
description: Identifier for the period of the VAT return
108+
type: string
109+
example: "#001"
110+
post:
111+
description: Submit VAT return for period.
112+
body:
113+
application/json:
114+
type: !include schemas/submitVatReturn.json
115+
example: !include examples/vatReturn.json
116+
responses:
117+
200:
118+
headers:
119+
X-CorrelationId:
120+
example: 5968c22d620000620096db5f
121+
description: Unique id for operation tracking

public/api/conf/0.1/examples/Obligations.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"end": "2017-07-05",
66
"due": "2017-08-05",
77
"met": true,
8-
"metDate": "2017-08-05",
8+
"received": "2017-08-05",
99
"periodKey": "#001"
1010
},
1111
{
@@ -27,7 +27,7 @@
2727
"end": "2018-04-05",
2828
"due": "2018-05-06",
2929
"met": true,
30-
"metDate": "2018-05-06",
30+
"received": "2018-05-06",
3131
"periodKey": "#004"
3232
}
3333
]

public/api/conf/0.1/schemas/Obligation.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
"type": "boolean",
2626
"example": "true or false"
2727
},
28-
"metDate": {
29-
"title": "Met Date",
30-
"description": "The obligation met date",
28+
"received": {
29+
"title": "Received Date",
30+
"description": "The obligation received date",
3131
"$ref": "FullDate.json"
3232
},
3333
"periodKey": {

test/uk/gov/hmrc/vatapi/resources/Jsons.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,25 +126,29 @@ object Jsons {
126126
| "end": "2017-07-05",
127127
| "due": "2017-08-05",
128128
| "met": $firstMet,
129-
| "metDate": "2017-08-01"
129+
| "received": "2017-08-01",
130+
| "periodKey": "#001"
130131
| },
131132
| {
132133
| "start": "2017-07-06",
133134
| "end": "2017-10-05",
134135
| "due": "2017-11-05",
135-
| "met": $secondMet
136+
| "met": $secondMet,
137+
| "periodKey": "#002"
136138
| },
137139
| {
138140
| "start": "2017-10-06",
139141
| "end": "2018-01-05",
140142
| "due": "2018-02-05",
141-
| "met": $thirdMet
143+
| "met": $thirdMet,
144+
| "periodKey": "#003"
142145
| },
143146
| {
144147
| "start": "2018-01-06",
145148
| "end": "2018-04-05",
146149
| "due": "2018-05-06",
147-
| "met": $fourthMet
150+
| "met": $fourthMet,
151+
| "periodKey": "#004"
148152
| }
149153
| ]
150154
|}

test/uk/gov/hmrc/vatapi/resources/wrappers/ObligationsResponseSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class ObligationsResponseSpec extends UnitSpec {
168168
val response = ObligationsResponse(HttpResponse(200, Some(obligationJson)))
169169

170170
val obligations = response.obligations
171-
obligations.right.get.get.obligations.find(o => o.metDate.get == new LocalDate("2017-04-25")) shouldBe defined
171+
obligations.right.get.get.obligations.find(o => o.received.get == new LocalDate("2017-04-25")) shouldBe defined
172172
}
173173
}
174174
}

0 commit comments

Comments
 (0)