diff --git a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt index 679e325ee6..38dce639fe 100644 --- a/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt +++ b/projects/manage-supervision-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/ContactGenerator.kt @@ -41,7 +41,8 @@ object ContactGenerator { APPT_CT_1, ZonedDateTime.of(LocalDateTime.now().minusDays(1), ZoneId.of("Europe/London")), attended = false, - action = BREACH_ENFORCEMENT_ACTION + action = BREACH_ENFORCEMENT_ACTION, + startTime = null ) val PREVIOUS_APPT_CONTACT = generateContact( OVERVIEW, @@ -51,7 +52,7 @@ object ContactGenerator { val FIRST_NON_APPT_CONTACT = generateContact( OVERVIEW, OTHER_CT, - ZonedDateTime.of(LocalDateTime.now().plusHours(1), ZoneId.of("Europe/London")) + ZonedDateTime.of(LocalDateTime.now().plusHours(1), ZoneId.of("Europe/London")), ) val FIRST_APPT_CONTACT = generateContact( OVERVIEW, @@ -118,13 +119,14 @@ object ContactGenerator { sensitive: Boolean? = null, requirement: Requirement? = null, notes: String? = null, - action: EnforcementAction? = null + action: EnforcementAction? = null, + startTime: ZonedDateTime? = ZonedDateTime.of(LocalDate.EPOCH, startDateTime.toLocalTime(), startDateTime.zone) ) = Contact( id = IdGenerator.getAndIncrement(), personId = person.id, type = contactType, date = startDateTime.toLocalDate(), - startTime = ZonedDateTime.of(LocalDate.EPOCH, startDateTime.toLocalTime(), startDateTime.zone), + startTime = startTime, rarActivity = rarActivity, attended = attended, sensitive = sensitive, diff --git a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt index 09a850dfab..81ab290b3c 100644 --- a/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt +++ b/projects/manage-supervision-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/delius/overview/entity/Contact.kt @@ -91,7 +91,10 @@ class Contact( @Column(name = "soft_deleted", columnDefinition = "NUMBER", nullable = false) val softDeleted: Boolean = false ) { - fun startDateTime(): ZonedDateTime = ZonedDateTime.of(date, startTime?.toLocalTime(), EuropeLondon) + fun startDateTime(): ZonedDateTime = + if (startTime != null) ZonedDateTime.of(date, startTime.toLocalTime(), EuropeLondon) else + ZonedDateTime.of(date, date.atStartOfDay().toLocalTime(), EuropeLondon) + fun endDateTime(): ZonedDateTime? = if (endTime != null) ZonedDateTime.of(date, endTime.toLocalTime(), EuropeLondon) else null