Skip to content

Commit

Permalink
PI-2521: Fix null institutions (#4228)
Browse files Browse the repository at this point in the history
PI-2521: Fix null institions
  • Loading branch information
pmcphee77 authored Sep 13, 2024
1 parent c4d1c06 commit d56f86b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ object SentenceGenerator {
disposal: Disposal,
custodialStatus: ReferenceData,
prisonerNumber: String,
institution: Institution,
institution: Institution?,
id: Long = IdGenerator.getAndIncrement()
) = Custody(disposal, custodialStatus, prisonerNumber = prisonerNumber, institution = institution, id = id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ data class AdditionalSentence(

data class Custody(
val bookingNumber: String?,
val institution: Institution,
val institution: Institution?,
val keyDates: CustodyRelatedKeyDates,
val status: KeyValue,
val sentenceStartDate: LocalDate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ interface EventRepository : JpaRepository<Event, Long> {
@Query(
"""
select
case when d.disposal_id is null and ca.outcome_code = '101' then 1 else 0 end as awaitingPsr
sum(case when d.disposal_id is null and ca.outcome_code = '101' then 1 else 0 end) as awaitingPsr
from event e
left join disposal d on d.event_id = e.event_id and d.soft_deleted = 0
left join (select distinct ca.event_id, oc.code_value as outcome_code
left join (select ca.event_id, oc.code_value as outcome_code
from court_appearance ca
join r_standard_reference_list oc on ca.outcome_id = oc.standard_reference_list_id) ca
on ca.event_id = e.event_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class Custody(
JoinColumn(name = "institution_id", referencedColumnName = "institution_id"),
JoinColumn(name = "establishment", referencedColumnName = "establishment")
)
val institution: Institution,
val institution: Institution? = null,

@OneToMany(mappedBy = "custody")
val keyDates: List<KeyDate> = listOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ConvictionService(
inBreach,
failureToComplyCount,
breachEnd,
eventRepository.awaitingPSR(id) == 1,
eventRepository.awaitingPSR(id) > 0,
convictionDate,
referralDate,
toOffences(),
Expand Down Expand Up @@ -194,7 +194,7 @@ class ConvictionService(
fun CustodyEntity.toCustody(): Custody =
Custody(
prisonerNumber,
institution.toInstitution(),
institution?.toInstitution(),
populateKeyDates(keyDates),
KeyValue(status.code, status.description),
disposal.startDate
Expand Down

0 comments on commit d56f86b

Please sign in to comment.