Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PI-2774 Remove user check when looking up residences #4593

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading