From 5fe9f7aaccdb606448d0ee4805600fdae6fe6a88 Mon Sep 17 00:00:00 2001 From: popey2700 Date: Thu, 4 Jul 2024 12:08:55 +0100 Subject: [PATCH 1/2] Update jsonInclude SentenceKeyDate --- .../hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt index 8ddd1f1f2..af4356a4a 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt @@ -3,9 +3,9 @@ package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps import com.fasterxml.jackson.annotation.JsonInclude import java.time.LocalDate -@JsonInclude(JsonInclude.Include.NON_NULL) data class SentenceKeyDate( val date: LocalDate? = null, val overrideDate: LocalDate? = null, + @JsonInclude(JsonInclude.Include.NON_NULL) val calculatedDate: LocalDate? = null, ) From 3ca20d77fe3fdbf82df939409737c6608d73a785 Mon Sep 17 00:00:00 2001 From: popey2700 Date: Thu, 4 Jul 2024 16:30:18 +0100 Subject: [PATCH 2/2] Update sentence key dates and adjustments model --- .../hmpps/LatestSentenceKeyDatesAndAdjustments.kt | 10 +++++----- .../models/hmpps/SentenceKeyDate.kt | 4 ---- .../models/hmpps/SentenceKeyDateWithCalculatedDate.kt | 9 +++++++++ .../models/hmpps/SentenceKeyDates.kt | 10 +++++----- .../models/nomis/NomisSentenceKeyDates.kt | 11 ++++++----- ...estSentenceKeyDatesAndAdjustmentsControllerTest.kt | 11 ++++++----- ...tenceKeyDatesAndAdjustmentsForPersonServiceTest.kt | 11 ++++++----- 7 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDateWithCalculatedDate.kt diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/LatestSentenceKeyDatesAndAdjustments.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/LatestSentenceKeyDatesAndAdjustments.kt index 565e1fc34..971a27f5c 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/LatestSentenceKeyDatesAndAdjustments.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/LatestSentenceKeyDatesAndAdjustments.kt @@ -7,14 +7,14 @@ data class LatestSentenceKeyDatesAndAdjustments( val automaticRelease: SentenceKeyDate? = null, val conditionalRelease: SentenceKeyDate? = null, val dtoPostRecallRelease: SentenceKeyDate? = null, - val earlyTerm: SentenceKeyDate? = null, + val earlyTerm: SentenceKeyDateWithCalculatedDate? = null, val homeDetentionCurfew: HomeDetentionCurfewDate? = null, - val lateTerm: SentenceKeyDate? = null, - val licenceExpiry: SentenceKeyDate? = null, - val midTerm: SentenceKeyDate? = null, + val lateTerm: SentenceKeyDateWithCalculatedDate? = null, + val licenceExpiry: SentenceKeyDateWithCalculatedDate? = null, + val midTerm: SentenceKeyDateWithCalculatedDate? = null, val nonDto: NonDtoDate? = null, val nonParole: SentenceKeyDate? = null, - val paroleEligibility: SentenceKeyDate? = null, + val paroleEligibility: SentenceKeyDateWithCalculatedDate? = null, val postRecallRelease: SentenceKeyDate? = null, val release: ReleaseDate? = null, val sentence: SentenceDate? = null, diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt index af4356a4a..67b136c81 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDate.kt @@ -1,11 +1,7 @@ package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps - -import com.fasterxml.jackson.annotation.JsonInclude import java.time.LocalDate data class SentenceKeyDate( val date: LocalDate? = null, val overrideDate: LocalDate? = null, - @JsonInclude(JsonInclude.Include.NON_NULL) - val calculatedDate: LocalDate? = null, ) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDateWithCalculatedDate.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDateWithCalculatedDate.kt new file mode 100644 index 000000000..0e21909f3 --- /dev/null +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDateWithCalculatedDate.kt @@ -0,0 +1,9 @@ +package uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps + +import java.time.LocalDate + +data class SentenceKeyDateWithCalculatedDate( + val date: LocalDate? = null, + val overrideDate: LocalDate? = null, + val calculatedDate: LocalDate? = null, +) diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDates.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDates.kt index 87c51d729..fbc09d413 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDates.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/hmpps/SentenceKeyDates.kt @@ -6,14 +6,14 @@ data class SentenceKeyDates( val automaticRelease: SentenceKeyDate = SentenceKeyDate(), val conditionalRelease: SentenceKeyDate = SentenceKeyDate(), val dtoPostRecallRelease: SentenceKeyDate = SentenceKeyDate(), - val earlyTerm: SentenceKeyDate = SentenceKeyDate(), + val earlyTerm: SentenceKeyDateWithCalculatedDate = SentenceKeyDateWithCalculatedDate(), val homeDetentionCurfew: HomeDetentionCurfewDate = HomeDetentionCurfewDate(), - val lateTerm: SentenceKeyDate = SentenceKeyDate(), - val licenceExpiry: SentenceKeyDate = SentenceKeyDate(), - val midTerm: SentenceKeyDate = SentenceKeyDate(), + val lateTerm: SentenceKeyDateWithCalculatedDate = SentenceKeyDateWithCalculatedDate(), + val licenceExpiry: SentenceKeyDateWithCalculatedDate = SentenceKeyDateWithCalculatedDate(), + val midTerm: SentenceKeyDateWithCalculatedDate = SentenceKeyDateWithCalculatedDate(), val nonDto: NonDtoDate = NonDtoDate(), val nonParole: SentenceKeyDate = SentenceKeyDate(), - val paroleEligibility: SentenceKeyDate = SentenceKeyDate(), + val paroleEligibility: SentenceKeyDateWithCalculatedDate = SentenceKeyDateWithCalculatedDate(), val postRecallRelease: SentenceKeyDate = SentenceKeyDate(), val release: ReleaseDate = ReleaseDate(), val sentence: SentenceDate = SentenceDate(), diff --git a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/NomisSentenceKeyDates.kt b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/NomisSentenceKeyDates.kt index 2e7209fdf..c9e8246f1 100644 --- a/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/NomisSentenceKeyDates.kt +++ b/src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/models/nomis/NomisSentenceKeyDates.kt @@ -5,6 +5,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.NonDtoDate import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.ReleaseDate import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceDate import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceKeyDate +import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceKeyDateWithCalculatedDate import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceKeyDates import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.TopupSupervision import java.time.LocalDate @@ -64,7 +65,7 @@ data class NomisSentenceKeyDates( automaticRelease = SentenceKeyDate(date = this.automaticReleaseDate, overrideDate = this.automaticReleaseOverrideDate), conditionalRelease = SentenceKeyDate(date = this.conditionalReleaseDate, overrideDate = this.conditionalReleaseOverrideDate), dtoPostRecallRelease = SentenceKeyDate(date = this.dtoPostRecallReleaseDate, overrideDate = this.dtoPostRecallReleaseDateOverride), - earlyTerm = SentenceKeyDate(date = this.earlyTermDate, overrideDate = this.etdOverrideDate, calculatedDate = this.etdCalculatedDate), + earlyTerm = SentenceKeyDateWithCalculatedDate(date = this.earlyTermDate, overrideDate = this.etdOverrideDate, calculatedDate = this.etdCalculatedDate), homeDetentionCurfew = HomeDetentionCurfewDate( actualDate = this.homeDetentionCurfewActualDate, @@ -73,18 +74,18 @@ data class NomisSentenceKeyDates( eligibilityOverrideDate = this.homeDetentionCurfewEligibilityOverrideDate, endDate = this.homeDetentionCurfewEndDate, ), - lateTerm = SentenceKeyDate(date = this.lateTermDate, overrideDate = this.ltdOverrideDate, calculatedDate = this.ltdCalculatedDate), + lateTerm = SentenceKeyDateWithCalculatedDate(date = this.lateTermDate, overrideDate = this.ltdOverrideDate, calculatedDate = this.ltdCalculatedDate), licenceExpiry = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = this.licenceExpiryDate, overrideDate = this.licenceExpiryOverrideDate, calculatedDate = this.licenceExpiryCalculatedDate, ), - midTerm = SentenceKeyDate(date = this.midTermDate, overrideDate = this.mtdOverrideDate, calculatedDate = this.mtdCalculatedDate), + midTerm = SentenceKeyDateWithCalculatedDate(date = this.midTermDate, overrideDate = this.mtdOverrideDate, calculatedDate = this.mtdCalculatedDate), nonDto = NonDtoDate(date = this.nonDtoReleaseDate, releaseDateType = this.nonDtoReleaseDateType), nonParole = SentenceKeyDate(date = this.nonParoleDate, overrideDate = this.nonParoleOverrideDate), paroleEligibility = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = this.paroleEligibilityDate, overrideDate = this.paroleEligibilityOverrideDate, calculatedDate = this.paroleEligibilityCalculatedDate, diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/LatestSentenceKeyDatesAndAdjustmentsControllerTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/LatestSentenceKeyDatesAndAdjustmentsControllerTest.kt index 0ba65ddd0..41221d25c 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/LatestSentenceKeyDatesAndAdjustmentsControllerTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/controllers/v1/person/sentences/LatestSentenceKeyDatesAndAdjustmentsControllerTest.kt @@ -26,6 +26,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceAdjustment import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceDate import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceKeyDate +import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceKeyDateWithCalculatedDate import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.TopupSupervision import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApiError @@ -73,7 +74,7 @@ internal class LatestSentenceKeyDatesAndAdjustmentsControllerTest( conditionalRelease = SentenceKeyDate(date = LocalDate.parse("2023-05-01"), overrideDate = LocalDate.parse("2023-05-01")), dtoPostRecallRelease = SentenceKeyDate(date = LocalDate.parse("2024-01-02"), overrideDate = LocalDate.parse("2024-01-02")), earlyTerm = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2021-11-02"), overrideDate = LocalDate.parse("2021-11-02"), calculatedDate = LocalDate.parse("2021-11-02"), @@ -87,19 +88,19 @@ internal class LatestSentenceKeyDatesAndAdjustmentsControllerTest( endDate = LocalDate.parse("2022-04-01"), ), lateTerm = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2022-01-01"), overrideDate = LocalDate.parse("2022-01-01"), calculatedDate = LocalDate.parse("2022-01-01"), ), licenceExpiry = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2025-02-01"), overrideDate = LocalDate.parse("2025-02-01"), calculatedDate = LocalDate.parse("2025-02-01"), ), midTerm = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2024-02-01"), overrideDate = LocalDate.parse("2024-02-01"), calculatedDate = LocalDate.parse("2024-02-01"), @@ -107,7 +108,7 @@ internal class LatestSentenceKeyDatesAndAdjustmentsControllerTest( nonDto = NonDtoDate(date = LocalDate.parse("2024-02-01"), releaseDateType = "CRD"), nonParole = SentenceKeyDate(date = LocalDate.parse("2026-11-02"), overrideDate = LocalDate.parse("2026-11-02")), paroleEligibility = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2027-02-01"), overrideDate = LocalDate.parse("2027-02-01"), calculatedDate = LocalDate.parse("2027-02-01"), diff --git a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest.kt b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest.kt index 65f305331..fa3bbc986 100644 --- a/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest.kt +++ b/src/test/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest.kt @@ -22,6 +22,7 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceAdjustment import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceDate import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceKeyDate +import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceKeyDateWithCalculatedDate import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.SentenceKeyDates import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.TopupSupervision import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi @@ -62,7 +63,7 @@ internal class GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest( conditionalRelease = SentenceKeyDate(date = LocalDate.parse("2023-12-02"), overrideDate = LocalDate.parse("2023-12-02")), dtoPostRecallRelease = SentenceKeyDate(date = LocalDate.parse("2024-01-02"), overrideDate = LocalDate.parse("2024-01-02")), earlyTerm = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2021-11-02"), overrideDate = LocalDate.parse("2021-11-02"), calculatedDate = LocalDate.parse("2021-11-02"), @@ -76,19 +77,19 @@ internal class GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest( endDate = LocalDate.parse("2022-04-01"), ), lateTerm = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2022-01-01"), overrideDate = LocalDate.parse("2022-01-01"), calculatedDate = LocalDate.parse("2022-01-01"), ), licenceExpiry = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2025-02-01"), overrideDate = LocalDate.parse("2025-02-01"), calculatedDate = LocalDate.parse("2025-02-01"), ), midTerm = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2024-02-01"), overrideDate = LocalDate.parse("2024-02-01"), calculatedDate = LocalDate.parse("2024-02-01"), @@ -96,7 +97,7 @@ internal class GetLatestSentenceKeyDatesAndAdjustmentsForPersonServiceTest( nonDto = NonDtoDate(date = LocalDate.parse("2024-02-01"), releaseDateType = "CRD"), nonParole = SentenceKeyDate(date = LocalDate.parse("2026-11-02"), overrideDate = LocalDate.parse("2026-11-02")), paroleEligibility = - SentenceKeyDate( + SentenceKeyDateWithCalculatedDate( date = LocalDate.parse("2027-02-01"), overrideDate = LocalDate.parse("2027-02-01"), calculatedDate = LocalDate.parse("2027-02-01"),