diff --git a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventDetailsGenerator.kt b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventDetailsGenerator.kt index 56a9aea4e1..f1d4806411 100644 --- a/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventDetailsGenerator.kt +++ b/projects/approved-premises-and-delius/src/dev/kotlin/uk/gov/justice/digital/hmpps/data/generator/EventDetailsGenerator.kt @@ -60,7 +60,8 @@ object EventDetailsGenerator { bookedBy = bookedBy, eventNumber = "23", arrivalOn = LocalDate.now(), - departureOn = LocalDate.now() + departureOn = LocalDate.now(), + submittedAt = ZonedDateTime.now().minusDays(2) ) ) diff --git a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-booking-made.json b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-booking-made.json index 742a83114c..6efd09cd6f 100644 --- a/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-booking-made.json +++ b/projects/approved-premises-and-delius/src/dev/resources/simulations/__files/approved-premises-booking-made.json @@ -38,6 +38,7 @@ "forenames": "Key", "surname": "Worker", "username": "KeyWorkerNPS" - } + }, + "submittedAt": "2022-11-28T14:51:30" } } \ No newline at end of file diff --git a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt index f4d56198e6..d7d70a5be6 100644 --- a/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt +++ b/projects/approved-premises-and-delius/src/integrationTest/kotlin/uk/gov/justice/digital/hmpps/MessagingIntegrationTest.kt @@ -161,9 +161,10 @@ internal class MessagingIntegrationTest { assertThat(contact.eventId, equalTo(PersonGenerator.EVENT.id)) val referrals = referralRepository.findAll() - .filter { it.personId == contact.person.id && it.createdByUserId == UserGenerator.AUDIT_USER.id && it.referralDate == contact.date } + .filter { it.personId == contact.person.id && it.createdByUserId == UserGenerator.AUDIT_USER.id && it.eventId == contact.eventId } assertThat(referrals.size, equalTo(1)) val referral = referrals.first() + assertThat(referral.referralDate, equalTo(LocalDate.parse("2022-11-28"))) assertThat(referral.activeArsonRiskId, equalTo(ReferenceDataGenerator.YN_UNKNOWN.id)) assertThat(referral.disabilityIssuesId, equalTo(ReferenceDataGenerator.YN_UNKNOWN.id)) assertThat(referral.singleRoomId, equalTo(ReferenceDataGenerator.YN_UNKNOWN.id)) diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremises/EventDetails.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremises/EventDetails.kt index e042ac949a..ed5cbb2556 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremises/EventDetails.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/integrations/approvedpremises/EventDetails.kt @@ -99,7 +99,8 @@ data class BookingMade( val bookedBy: BookedBy, val premises: Premises, val arrivalOn: LocalDate, - val departureOn: LocalDate + val departureOn: LocalDate, + val submittedAt: ZonedDateTime? ) { val bookingMadeAt: ZonedDateTime = createdAt.truncatedTo(ChronoUnit.SECONDS) } diff --git a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferralService.kt b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferralService.kt index 43a1fd0762..4f26d0df81 100644 --- a/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferralService.kt +++ b/projects/approved-premises-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferralService.kt @@ -230,7 +230,7 @@ class ReferralService( personId = person.id, eventId = event.id, approvedPremisesId = ap.id, - referralDate = bookingMadeAt.toLocalDate(), + referralDate = submittedAt?.toLocalDate() ?: bookingMadeAt.toLocalDate(), referralDateTypeId = checkNotNull( referenceDataRepository.findByCodeAndDatasetCode( "CRC",