From 7fd2031942bad89320b5933a0b3c033ae8c082d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Mili=C4=87?= Date: Tue, 31 Dec 2024 21:03:20 +0100 Subject: [PATCH] bugfix/Fix end month/year range bug at endpoint getCounterpartyLimitStatus --- .../scala/code/api/v5_1_0/APIMethods510.scala | 16 ++++++++++++++-- .../code/api/v5_1_0/CounterpartyLimitTest.scala | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala index 384c569775..3534aa3af2 100644 --- a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala +++ b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala @@ -3601,10 +3601,22 @@ trait APIMethods510 { // Convert LocalDate to Date zoneId: ZoneId = ZoneId.systemDefault() firstCurrentMonthDate: Date = Date.from(firstDayOfMonth.atStartOfDay(zoneId).toInstant) - lastCurrentMonthDate: Date = Date.from(lastDayOfMonth.atStartOfDay(zoneId).toInstant) + // Adjust to include 23:59:59.999 + lastCurrentMonthDate: Date = Date.from( + lastDayOfMonth + .atTime(23, 59, 59, 999000000) + .atZone(zoneId) + .toInstant + ) firstCurrentYearDate: Date = Date.from(firstDayOfYear.atStartOfDay(zoneId).toInstant) - lastCurrentYearDate: Date = Date.from(lastDayOfYear.atStartOfDay(zoneId).toInstant) + // Adjust to include 23:59:59.999 + lastCurrentYearDate: Date = Date.from( + lastDayOfYear + .atTime(23, 59, 59, 999000000) + .atZone(zoneId) + .toInstant + ) defaultFromDate: Date = theEpochTime defaultToDate: Date = APIUtil.ToDateInFuture diff --git a/obp-api/src/test/scala/code/api/v5_1_0/CounterpartyLimitTest.scala b/obp-api/src/test/scala/code/api/v5_1_0/CounterpartyLimitTest.scala index 6033c5d51c..6f78fbe235 100644 --- a/obp-api/src/test/scala/code/api/v5_1_0/CounterpartyLimitTest.scala +++ b/obp-api/src/test/scala/code/api/v5_1_0/CounterpartyLimitTest.scala @@ -392,7 +392,7 @@ class CounterpartyLimitTest extends V510ServerSetup { response4.body.extract[ErrorMessage].message contains(CounterpartyLimitValidationError) shouldBe (true) response4.body.extract[ErrorMessage].message contains("max_number_of_transactions") shouldBe(true) - val requestLimitStatus = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId / "views" / ownerView /"counterparties" / counterparty.counterpartyId /"limit-status").POST <@ (user1) + val requestLimitStatus = (v5_1_0_Request / "banks" / bankId / "accounts" / accountId / "views" / ownerView /"counterparties" / counterparty.counterpartyId /"limit-status").GET <@ (user1) val responseLimitStatus = makeGetRequest(requestLimitStatus) responseLimitStatus.code shouldBe (200) responseLimitStatus.body.extract[CounterpartyLimitStatusV510].status.currency_status shouldBe("EUR")