Skip to content

Commit

Permalink
PI-2774 Remove user check when looking up residences (#4593)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-bcl authored Jan 28, 2025
1 parent 89962ee commit 1260578
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class MoveOnCategory(

interface ResidenceRepository : JpaRepository<Residence, Long> {
fun findByReferralId(referralId: Long): Residence?
fun findByReferralIdAndCreatedByUserId(referralId: Long, createdByUserId: Long): Residence?
}

interface MoveOnCategoryRepository : JpaRepository<MoveOnCategory, Long> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import uk.gov.justice.digital.hmpps.integrations.delius.team.getUnallocatedTeam
import uk.gov.justice.digital.hmpps.model.ApReferral
import uk.gov.justice.digital.hmpps.model.ExistingReferrals
import uk.gov.justice.digital.hmpps.model.ReferralDetail
import uk.gov.justice.digital.hmpps.security.ServiceContext
import java.time.ZonedDateTime

@Transactional
Expand Down Expand Up @@ -187,14 +186,12 @@ class ReferralService(
}

fun personDeparted(person: Person, details: PersonDeparted) {
val serviceUserId = ServiceContext.servicePrincipal()!!.userId
val externalReference = EXT_REF_BOOKING_PREFIX + details.bookingId
val referral = getReferral(person, externalReference)
val residence = residenceRepository.findByReferralIdAndCreatedByUserId(referral.id, serviceUserId)
?: throw IgnorableMessageException(
"Residence not found",
mapOf("crn" to person.crn, "externalReference" to externalReference)
)
val residence = residenceRepository.findByReferralId(referral.id) ?: throw IgnorableMessageException(
"Residence not found",
mapOf("crn" to person.crn, "externalReference" to externalReference)
)
residence.departureDate = details.departedAt
residence.departureReasonId = referenceDataRepository.findByCodeAndDatasetCode(
details.legacyReasonCode,
Expand Down

0 comments on commit 1260578

Please sign in to comment.