Skip to content

Commit

Permalink
PI-1985 - update custody status change date (#3426)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-britton-moj authored Mar 5, 2024
1 parent f5a0106 commit e48d010
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.wellknown.
import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.wellknown.ReleaseTypeCode
import uk.gov.justice.digital.hmpps.integrations.delius.release.entity.Release
import uk.gov.justice.digital.hmpps.set
import java.time.LocalDate
import java.time.ZonedDateTime

object EventGenerator {
Expand Down Expand Up @@ -53,7 +54,7 @@ object EventGenerator {
status = ReferenceDataGenerator.CUSTODIAL_STATUS[custodialStatusCode]!!,
institution = institution,
disposal = disposal,
statusChangeDate = ZonedDateTime.now().minusDays(1),
statusChangeDate = LocalDate.now().minusDays(1),
locationChangeDate = ZonedDateTime.now().minusDays(1)
)
disposal.custody = custody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PcstdIntegrationTest : PcstdIntegrationTestBase() {
val custody = getCustody(nomsNumber)
assertTrue(custody.isInCustody())
assertThat(custody.status.code, equalTo(CustodialStatusCode.IN_CUSTODY.code))
assertThat(custody.statusChangeDate, isCloseTo(notification.message.occurredAt))
assertThat(custody.statusChangeDate, equalTo(notification.message.occurredAt.toLocalDate()))
assertThat(custody.institution?.code, equalTo(InstitutionGenerator.DEFAULT.code))
assertThat(custody.locationChangeDate!!, isCloseTo(notification.message.occurredAt))

Expand Down Expand Up @@ -237,7 +237,7 @@ class PcstdIntegrationTest : PcstdIntegrationTestBase() {

val custody = getCustody(nomsNumber)
assertThat(custody.status.code, equalTo(CustodialStatusCode.IN_CUSTODY.code))
assertThat(custody.statusChangeDate, isCloseTo(notification.message.occurredAt))
assertThat(custody.statusChangeDate, equalTo(notification.message.occurredAt.toLocalDate()))
assertThat(custody.institution?.code, equalTo(InstitutionGenerator.DEFAULT.code))
assertThat(custody.locationChangeDate!!, isCloseTo(notification.message.occurredAt))

Expand Down Expand Up @@ -284,7 +284,7 @@ class PcstdIntegrationTest : PcstdIntegrationTestBase() {
assertThat(custody.institution?.code, equalTo(InstitutionCode.OTHER_SECURE_UNIT.code))
assertThat(custody.locationChangeDate!!, isCloseTo(notification.message.occurredAt))
assertThat(custody.status.code, equalTo(CustodialStatusCode.RECALLED.code))
assertThat(custody.statusChangeDate, isCloseTo(notification.message.occurredAt))
assertThat(custody.statusChangeDate, equalTo(notification.message.occurredAt.toLocalDate()))

verifyRecall(custody, notification.message.occurredAt, RecallReason.Code.TRANSFER_TO_SECURE_HOSPITAL)

Expand Down Expand Up @@ -538,7 +538,7 @@ class PcstdIntegrationTest : PcstdIntegrationTestBase() {
assertTrue(custody.isInCustody())
assertThat(custody.institution?.code, equalTo(ual.code))
assertThat(custody.status.code, equalTo(CustodialStatusCode.RECALLED.code))
assertThat(custody.statusChangeDate, isCloseTo(notification.message.occurredAt))
assertThat(custody.statusChangeDate, equalTo(notification.message.occurredAt.toLocalDate()))

verifyRecall(custody, notification.message.occurredAt, RecallReason.Code.NOTIFIED_BY_CUSTODIAL_ESTABLISHMENT)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.wellknown.
import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.wellknown.CAN_RELEASE_STATUSES
import uk.gov.justice.digital.hmpps.integrations.delius.referencedata.wellknown.CustodialStatusCode
import uk.gov.justice.digital.hmpps.integrations.delius.release.entity.Release
import java.time.LocalDate
import java.time.ZonedDateTime

@Entity
Expand Down Expand Up @@ -46,7 +47,7 @@ class Custody(
val disposal: Disposal,

@Column(nullable = false)
var statusChangeDate: ZonedDateTime,
var statusChangeDate: LocalDate,

@Column
var locationChangeDate: ZonedDateTime?,
Expand Down Expand Up @@ -108,7 +109,7 @@ class Custody(
null
} else {
this.status = status
this.statusChangeDate = dateTime
this.statusChangeDate = dateTime.toLocalDate()
CustodyHistory(
date = dateTime,
type = historyType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class UpdateLocationAction(
else -> null
}

return institution?.let { institution ->
custody.updateLocationAt(institution, prisonerMovement.occurredAt) {
return institution?.let { inst ->
custody.updateLocationAt(inst, prisonerMovement.occurredAt) {
referenceDataRepository.getCustodyEventType(CustodyEventTypeCode.LOCATION_CHANGE.code)
}?.let { history ->
custodyRepository.save(custody)
custodyHistoryRepository.save(history)
(pomInstitutionOverride ?: institution).probationArea?.let {
(pomInstitutionOverride ?: inst).probationArea?.let {
prisonManagerService.allocateToProbationArea(
custody.disposal,
it,
Expand Down

0 comments on commit e48d010

Please sign in to comment.