From 9a2f401a788ef22be2eadeb2fd6ea9ca4a40da86 Mon Sep 17 00:00:00 2001 From: Amardeep Chimber Date: Wed, 16 Oct 2024 22:13:13 +0100 Subject: [PATCH] MAN-28 - add new attribute to response --- .../uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt | 2 ++ .../digital/hmpps/api/model/sentence/LicenceCondition.kt | 2 +- .../uk/gov/justice/digital/hmpps/service/SentenceService.kt | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt index d8ee1401fa..fc217a29db 100644 --- a/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt +++ b/projects/manage-supervision-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/SentenceIntegrationTest.kt @@ -125,6 +125,7 @@ class SentenceIntegrationTest { listOf( LicenceConditionNote( "Comment added by CVL Service", + LocalDate.of(2024, 4, 22), """ Licence Condition created automatically from the Create and Vary a licence system of Allow person(s) as designated by your supervising officer to install an electronic monitoring tag on you and access to install any associated equipment in your property, and for the purpose of ensuring that equipment is functioning correctly. You must not damage or tamper with these devices and ensure that the tag is charged, and report to your supervising officer and the EM provider immediately if the tag or the associated equipment are not working correctly. This will be for the purpose of monitoring your alcohol abstinence licence condition(s) unless otherwise authorised by your supervising officer. @@ -133,6 +134,7 @@ class SentenceIntegrationTest { ), LicenceConditionNote( "Comment added by Joe Root", + LocalDate.of(2024, 4, 23), """ You must not drink any alcohol until Wednesday 7th August 2024 unless your probation officer says you can. You will need to wear an electronic tag all the time so diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/sentence/LicenceCondition.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/sentence/LicenceCondition.kt index 54affee7a5..9b4606662d 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/sentence/LicenceCondition.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/api/model/sentence/LicenceCondition.kt @@ -12,7 +12,7 @@ data class LicenceCondition( data class LicenceConditionNote( val createdBy: String? = null, -// val createdByDate: String? = null, + val createdByDate: LocalDate? = null, val note: String, val hasNotesBeenTruncated: Boolean? = null ) diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/SentenceService.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/SentenceService.kt index e315557c25..adeb7138b8 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/SentenceService.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/SentenceService.kt @@ -13,6 +13,7 @@ import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.* import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.LicenceCondition as EntityLicenceCondition import java.time.Duration import java.time.LocalDate +import java.time.format.DateTimeFormatter import kotlin.time.toKotlinDuration import uk.gov.justice.digital.hmpps.integrations.delius.sentence.entity.AdditionalSentence as ExtraSentence @@ -98,9 +99,12 @@ class SentenceService( ).find(note)?.value val noteText = addedBy?.let { note.removePrefix(addedBy) } ?: note + val createdBy = addedBy?.removeSuffix(System.lineSeparator())?.reversed()?.substring(23)?.reversed() + val dateCreatedBy = addedBy?.removeSuffix(System.lineSeparator())?.reversed()?.substring(9,19)?.reversed() LicenceConditionNote( - addedBy?.removeSuffix(System.lineSeparator())?.reversed()?.substring(23)?.reversed(), + createdBy, + dateCreatedBy?.let { LocalDate.parse(it, DateTimeFormatter.ofPattern("d/MM/yyyy")) }, noteText.removeSuffix(System.lineSeparator()), note.let { n -> when {