Informatievlaanderen / GIPOD

Generiek Informatie Platform Openbaar Domein
MIT License
9 stars 2 forks source link

PATCH to GroundWork validation #268

Closed langens-jonathan closed 3 years ago

langens-jonathan commented 3 years ago

Describe the bug We make a PATCH request to update the period of a GroundWork (today around 8:55). The Request we make is: PATCH to ../groundworks/8698557 body: {"items":[{"key":"Period","value":{"start":"2021-02-08T00:00Z","end":"2021-04-30T00:00Z","duration":null}},{"key":"EstimatedDurationDays","value":82}]}

This fails with the following response message: {"type":"https://httpstatuses.com/400","title":"One or more validation errors occurred.","status":400,"detail":"Please refer to the errors property for additional details.","errors":[{"type":"urn:be.vlaanderen.gipod.errors:InvalidGroundworkPeriodAndEstimatedDurationCombinationException","title":"Groundwork period GroundworkPeriod: {\"Start\":\"2021-02-08T00:00:00Z\",\"End\":\"2021-04-30T00:00:00Z\",\"Duration\":null} is invalid in combination with estimated duration estimatedDuration: {\"Days\":82}.\n ","detail":"Groundwork period GroundworkPeriod: {\"Start\":\"2021-02-08T00:00:00Z\",\"End\":\"2021-04-30T00:00:00Z\",\"Duration\":null} is invalid in combination with estimated duration estimatedDuration: {\"Days\":82}.\n "}]}

Expected behavior The response that this GW was modified.

Additional context We did make a similar call today (around 13:02): PATCH .../groundworks/9179442 body: {"items":[{"key":"Period","value":{"start":"2021-02-08T00:00Z","end":"2021-02-10T00:00Z","duration":null}},{"key":"EstimatedDurationDays","value":2}]} This call was successfull

AIV-Bert commented 3 years ago

Between 08/02/21 00:00 and 10/02/21 00:00 --> 48 hours = 2 days. => EstimatedDurationDays 2 is valid

Between 08/02/21 00:00 and 30/04/21 00:00 --> 81 days. => EstimatedDurationDays 82 is NOT valid