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-2231 Handle null withdrawalCode #3884

Merged
merged 1 commit into from
Jun 10, 2024
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 @@ -41,19 +41,19 @@ class ReferralEndSubmitted(

Success(
ReferralEnded,
mapOf(
listOfNotNull(
"crn" to event.personReference.findCrn()!!,
"referralUrn" to event.referralUrn(),
"endDate" to sentReferral.endDate.toString(),
"endType" to termination.endType.toString(),
"withdrawalCode" to termination.withdrawalCode
)
termination.withdrawalCode?.let { "withdrawalCode" to it }
).toMap()
)
}
}

fun HmppsDomainEvent.deliveryState() = additionalInformation["deliveryState"] as String
fun HmppsDomainEvent.withdrawalCode() = additionalInformation["withdrawalCode"] as String
fun HmppsDomainEvent.withdrawalCode() = (additionalInformation["withdrawalCode"] as String?)?.takeIf { it.isNotEmpty() }
fun HmppsDomainEvent.referralUrn() = additionalInformation["referralURN"] as String
fun HmppsDomainEvent.referralUiUrl() = additionalInformation["referralProbationUserURL"] as String

Expand Down Expand Up @@ -107,7 +107,7 @@ data class NsiTermination(
val startDate: ZonedDateTime,
val endDate: ZonedDateTime,
val endType: ReferralEndType,
val withdrawalCode: String,
val withdrawalCode: String?,
val notes: String,
val notificationDateTime: ZonedDateTime?,
val notificationNotes: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ class NsiService(
fun terminateNsi(termination: NsiTermination) = audit(MANAGE_NSI) { audit ->
val nsi = findNsi(termination)
val status = nsiStatusRepository.getByCode(END.value)
val outcomeCode = termination.withdrawalCode
.takeIf { it.isNotEmpty() && featureFlags.enabled("referral-withdrawal-reason") }
val outcomeCode = termination.withdrawalCode.takeIf { featureFlags.enabled("referral-withdrawal-reason") }
?: termination.endType.outcome
val outcome = nsiOutcomeRepository.nsiOutcome(outcomeCode)

Expand Down