Skip to content

Commit

Permalink
[MTDSA-1171] [CK] Change met to status and update documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandrashekhar Korivi authored and Chandrashekhar Korivi committed Oct 26, 2017
1 parent 77e3512 commit 424e7fd
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions app/uk/gov/hmrc/vatapi/models/Obligations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object Obligations {
implicit val writes: Writes[Obligations] = Json.writes[Obligations]
}

case class Obligation(start: LocalDate, end: LocalDate, due: LocalDate, met: Boolean, periodKey : String, received : Option[LocalDate] = None)
case class Obligation(start: LocalDate, end: LocalDate, due: LocalDate, status: String, periodKey : String, received : Option[LocalDate] = None)

object Obligation {
implicit val jodaDateWrites: Writes[LocalDate] = new Writes[LocalDate] {
Expand All @@ -41,7 +41,7 @@ object Obligation {
start = LocalDate.parse(desObligation.inboundCorrespondenceFromDate),
end = LocalDate.parse(desObligation.inboundCorrespondenceToDate),
due = LocalDate.parse(desObligation.inboundCorrespondenceDueDate),
met = desObligation.isFulfilled,
status = desObligation.status,
periodKey = desObligation.periodKey,
received = desObligation.inboundCorrespondenceDateReceived.map(LocalDate.parse))
) match {
Expand Down
4 changes: 1 addition & 3 deletions app/uk/gov/hmrc/vatapi/models/des/Obligations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ case class ObligationDetail(status: String,
inboundCorrespondenceToDate: String,
inboundCorrespondenceDateReceived: Option[String],
inboundCorrespondenceDueDate: String,
periodKey: String) {
def isFulfilled: Boolean = status == "F"
}
periodKey: String)

object ObligationDetail {
implicit val reads: Reads[ObligationDetail] = Json.reads[ObligationDetail]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ObligationsResourceSpec extends BaseFunctionalSpec {
.get(s"/$vrn/obligations?from=2017-01-01&to=2017-08-31&status=A")
.thenAssertThat()
.statusIs(200)
.bodyIsLike(Jsons.Obligations(firstMet = true).toString)
.bodyIsLike(Jsons.Obligations(firstMet = "F").toString)
}

}
Expand Down
8 changes: 4 additions & 4 deletions public/api/conf/1.0/application.raml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ traits:
type: string
example: "123456789"
/obligations:
displayName: Retrieve all VAT obligations.
description: Retrieve all VAT obligations.
displayName: Retrieve VAT obligations.
description: Retrieve VAT obligations.
get:
displayName: Retrieve all VAT obligations.
description: Retrieve all VAT obligations.
displayName: Retrieve VAT obligations.
description: Retrieve VAT obligations.
(annotations.sandboxData): !include scenarios/vat-obligation-scenarios.md
is: [headers.acceptHeader, contentType, testScenarioHeader]
(annotations.scope): "read:vat"
Expand Down
8 changes: 4 additions & 4 deletions public/api/conf/1.0/examples/Obligations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
"start": "2017-04-06",
"end": "2017-07-05",
"due": "2017-08-05",
"met": true,
"status": "F",
"received": "2017-08-05",
"periodKey": "#001"
},
{
"start": "2017-07-06",
"end": "2017-10-05",
"due": "2017-11-05",
"met": false,
"status": "O",
"periodKey": "#002"
},
{
"start": "2017-10-06",
"end": "2018-01-05",
"due": "2018-02-05",
"met": false,
"status": "O",
"periodKey": "#003"
},
{
"start": "2018-01-06",
"end": "2018-04-05",
"due": "2018-05-06",
"met": true,
"status": "O",
"received": "2018-05-06",
"periodKey": "#004"
}
Expand Down
14 changes: 7 additions & 7 deletions public/api/conf/1.0/schemas/Obligation.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"description": "The due date for this obligation period",
"$ref": "FullDate.json"
},
"met": {
"title": "Met",
"description": "True if this obligation period has been met; false otherwise",
"type": "boolean",
"example": "true or false"
"status": {
"title": "Status",
"description": "Status of the obligation (O = Open, F = Fulfilled)",
"type": "string",
"example": "F"
},
"received": {
"title": "Received Date",
"description": "The obligation received date",
"description": "The obligation received date, is returned when status is (F = Fulfilled)",
"$ref": "FullDate.json"
},
"periodKey": {
Expand All @@ -41,7 +41,7 @@
"start",
"end",
"due",
"met",
"status",
"periodKey"
],
"additionalProperties": false
Expand Down
16 changes: 8 additions & 8 deletions test/uk/gov/hmrc/vatapi/resources/Jsons.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,40 +114,40 @@ object Jsons {
}

object Obligations {
def apply(firstMet: Boolean = false,
secondMet: Boolean = false,
thirdMet: Boolean = false,
fourthMet: Boolean = false): JsValue = {
def apply(firstMet: String = "F",
secondMet: String = "O",
thirdMet: String = "O",
fourthMet: String = "O"): JsValue = {
Json.parse(s"""
|{
| "obligations": [
| {
| "start": "2017-04-06",
| "end": "2017-07-05",
| "due": "2017-08-05",
| "met": $firstMet,
| "status": "$firstMet",
| "received": "2017-08-01",
| "periodKey": "#001"
| },
| {
| "start": "2017-07-06",
| "end": "2017-10-05",
| "due": "2017-11-05",
| "met": $secondMet,
| "status": "$secondMet",
| "periodKey": "#002"
| },
| {
| "start": "2017-10-06",
| "end": "2018-01-05",
| "due": "2018-02-05",
| "met": $thirdMet,
| "status": "$thirdMet",
| "periodKey": "#003"
| },
| {
| "start": "2018-01-06",
| "end": "2018-04-05",
| "due": "2018-05-06",
| "met": $fourthMet,
| "status": "$fourthMet",
| "periodKey": "#004"
| }
| ]
Expand Down

0 comments on commit 424e7fd

Please sign in to comment.