Skip to content

Commit

Permalink
PI-1690 use submitted date for referral date (#2755)
Browse files Browse the repository at this point in the history
* PI-1690 use submitted date for referral date

* PI-1690 allow submitted at to be nullable for when not provided - ie booking made without application
  • Loading branch information
anthony-britton-moj authored Nov 28, 2023
1 parent 6f9dca0 commit 50d1a3b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ object EventDetailsGenerator {
bookedBy = bookedBy,
eventNumber = "23",
arrivalOn = LocalDate.now(),
departureOn = LocalDate.now()
departureOn = LocalDate.now(),
submittedAt = ZonedDateTime.now().minusDays(2)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"forenames": "Key",
"surname": "Worker",
"username": "KeyWorkerNPS"
}
},
"submittedAt": "2022-11-28T14:51:30"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 50d1a3b

Please sign in to comment.