Skip to content

Commit

Permalink
PI-2035: Fix null start time
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcphee77 committed Mar 28, 2024
1 parent 7e81b71 commit 216882e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 216882e

Please sign in to comment.