Skip to content

Commit

Permalink
PI-2583 Prioritise "first release date" over "auto-conditional releas…
Browse files Browse the repository at this point in the history
…e date" (#4306)
  • Loading branch information
marcus-bcl authored Oct 11, 2024
1 parent e7e74da commit 0ae1e62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CustodyDateUpdateService(
?.takeIf { featureFlags.enabled("suspension-date-if-reset") }
?.takeIf { it.type.determinateSentence }
?.let {
val startDate = sentenceDetail.conditionalReleaseDate ?: it.event.firstReleaseDate ?: return null
val startDate = it.event.firstReleaseDate ?: sentenceDetail.conditionalReleaseDate ?: return null
val endDate = sentenceDetail.sentenceExpiryDate ?: return null
return if (startDate < endDate) startDate.plusDays(DAYS.between(startDate, endDate) * 2 / 3) else null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ internal class CustodyDateUpdateServiceTest {
}

@Test
fun `two-thirds point uses event first release date if no conditional release date is available`() {
fun `two-thirds point uses event first release date if present`() {
whenever(featureFlags.enabled("suspension-date-if-reset")).thenReturn(true)
val event = generateEvent(firstReleaseDate = LocalDate.of(2025, 1, 1))
val disposal = generateDisposal(event)
val custody = generateCustodialSentence(disposal = disposal, bookingRef = "ABC")

val suspensionDateIfReset = custodyDateUpdateService.suspensionDateIfReset(
SentenceDetail(
conditionalReleaseDate = null,
conditionalReleaseDate = LocalDate.of(2026, 1, 1),
sentenceExpiryDate = LocalDate.of(2026, 1, 1)
), custody
)
Expand Down

0 comments on commit 0ae1e62

Please sign in to comment.