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

chore(j-s): add police case numbers to revoke indictment notification email #17385

Merged
merged 12 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -839,7 +839,7 @@ export const notifications = {
body: {
id: 'judicial.system.backend:notifications.court_revoked_indictment_email.body',
defaultMessage:
'{prosecutorsOffice} hefur afturkallað ákæru {courtCaseNumber, select, NONE {í máli sem ekki hefur enn fengið málsnúmer} other {í máli {courtCaseNumber}}}.',
'{prosecutorsOffice} hefur afturkallað ákæru í máli {courtCaseNumber, select, NONE {{policeCaseNumbers}} other {{courtCaseNumber}}}.',
description: 'Texti í pósti til dómstóls þegar ákæra er afturkölluð',
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ export class CaseService {
type: MessageType.DELIVERY_TO_COURT_INDICTMENT_CANCELLATION_NOTICE,
user,
caseId: theCase.id,
// Q: Why do we have to pass this flag? Why can't we rely on the court case numbers not being defined on the case object?
unakb marked this conversation as resolved.
Show resolved Hide resolved
body: { withCourtCaseNumber: false },
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,23 +672,26 @@ export class InternalCaseService {
): Promise<DeliverResponse> {
await this.refreshFormatMessage()

const courtCaseNumber =
thorhildurt marked this conversation as resolved.
Show resolved Hide resolved
(withCourtCaseNumber && theCase.courtCaseNumber) || 'NONE'
const policeCaseNumbers = theCase.policeCaseNumbers.join(', ')

return this.courtService
.updateIndictmentCaseWithCancellationNotice(
user,
theCase.id,
theCase.court?.name,
theCase.courtCaseNumber,
this.formatMessage(notifications.courtRevokedIndictmentEmail.subject, {
courtCaseNumber:
(withCourtCaseNumber && theCase.courtCaseNumber) || 'NONE',
courtCaseNumber,
}),
stripHtmlTags(
`${this.formatMessage(
notifications.courtRevokedIndictmentEmail.body,
{
prosecutorsOffice: theCase.creatingProsecutor?.institution?.name,
courtCaseNumber:
(withCourtCaseNumber && theCase.courtCaseNumber) || 'NONE',
courtCaseNumber,
policeCaseNumbers,
},
)} ${this.formatMessage(notifications.emailTail)}`,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,18 @@ describe('InternalCaseController - Deliver indictment cancellation notice to cou
const courtName = uuid()
const courtCaseNumber = uuid()
const prosecutorsOffice = uuid()
const policeCase1 = '007-2022-01'
const policeCase2 = '007-2022-02'

const policeCaseNumbers = [policeCase1, policeCase2]

const theCase = {
id: caseId,
type: CaseType.INDICTMENT,
creatingProsecutor: { institution: { name: prosecutorsOffice } },
court: { name: courtName },
courtCaseNumber,
policeCaseNumbers,
} as Case

let mockCourtService: CourtService
Expand Down Expand Up @@ -88,7 +93,7 @@ describe('InternalCaseController - Deliver indictment cancellation notice to cou
})
})

describe('deliver cancellation notice without court case number', () => {
describe('deliver cancellation notice with police case numbers', () => {
let then: Then

beforeAll(async () => {
Expand All @@ -104,7 +109,7 @@ describe('InternalCaseController - Deliver indictment cancellation notice to cou
courtName,
courtCaseNumber,
'Ákæra afturkölluð',
`${prosecutorsOffice} hefur afturkallað ákæru í máli sem ekki hefur enn fengið málsnúmer. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
`${prosecutorsOffice} hefur afturkallað ákæru í máli ${policeCase1}, ${policeCase2}. Hægt er að nálgast yfirlitssíðu málsins á rettarvorslugatt.island.is.`,
)

expect(then.result).toEqual({ delivered: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1439,24 +1439,28 @@ export class CaseNotificationService extends BaseNotificationService {
recipientName?: string,
recipientEmail?: string,
): Promise<Recipient> {
const courtCaseNumber = theCase.courtCaseNumber ?? 'NONE'
const policeCaseNumbers = theCase.policeCaseNumbers.join(', ')

const subject = this.formatMessage(
notifications.courtRevokedIndictmentEmail.subject,
{
courtCaseNumber: theCase.courtCaseNumber ?? 'NONE',
courtCaseNumber,
},
)
const body = this.formatMessage(
notifications.courtRevokedIndictmentEmail.body,
{
prosecutorsOffice: theCase.creatingProsecutor?.institution?.name,
courtCaseNumber: theCase.courtCaseNumber ?? 'NONE',
courtCaseNumber,
policeCaseNumbers,
},
)

return this.sendEmail(subject, body, recipientName, recipientEmail)
}

private async sendRevodeNotificationsForIndictmentCase(
private async sendRevokeNotificationsForIndictmentCase(
theCase: Case,
): Promise<DeliverResponse> {
const promises: Promise<Recipient>[] = []
Expand Down Expand Up @@ -1534,7 +1538,7 @@ export class CaseNotificationService extends BaseNotificationService {
if (isRequestCase(theCase.type)) {
return this.sendRevokedNotificationsForRequestCase(theCase)
} else {
return this.sendRevodeNotificationsForIndictmentCase(theCase)
return this.sendRevokeNotificationsForIndictmentCase(theCase)
}
}
//#endregion
Expand Down
Loading