Skip to content

Commit

Permalink
MAN-28 - add new attribute to response
Browse files Browse the repository at this point in the history
  • Loading branch information
achimber-moj committed Oct 16, 2024
1 parent 25840f4 commit 9a2f401
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9a2f401

Please sign in to comment.