From 3c0fa85265c4f826e431db3fd0653d9ac6002394 Mon Sep 17 00:00:00 2001 From: unakb Date: Mon, 9 Dec 2024 15:24:06 +0000 Subject: [PATCH] chore(j-s): Add more info to new indictment robot emails --- .../src/app/modules/case/internalCase.service.ts | 1 + .../deliverIndictmentInfoToCourt.spec.ts | 6 +++++- .../backend/src/app/modules/court/court.service.ts | 12 +++++++++--- .../app/modules/court/test/createCourtCase.spec.ts | 8 ++++---- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts index a969cf40351b..729645bb5f82 100644 --- a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts @@ -606,6 +606,7 @@ export class InternalCaseService { ? { name: theCase.prosecutor.name, nationalId: theCase.prosecutor.nationalId, + email: theCase.prosecutor.email, } : undefined, ) diff --git a/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentInfoToCourt.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentInfoToCourt.spec.ts index 3236f05eb4de..c7b01baee552 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentInfoToCourt.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentInfoToCourt.spec.ts @@ -54,7 +54,11 @@ describe('InternalCaseController - Deliver indictment info to court', () => { { eventType: EventType.INDICTMENT_CONFIRMED, created: indictmentDate }, ], defendants: [{ name: 'Test Ákærði', nationalId: '1234567890' }], - prosecutor: { name: 'Test Sækjandi', nationalId: '0101010101' }, + prosecutor: { + name: 'Test Sækjandi', + nationalId: '0101010101', + email: 'prosecutor@omnitrix.is', + }, } as Case let mockCourtService: CourtService diff --git a/apps/judicial-system/backend/src/app/modules/court/court.service.ts b/apps/judicial-system/backend/src/app/modules/court/court.service.ts index 7113dd6769b0..df13b35a90be 100644 --- a/apps/judicial-system/backend/src/app/modules/court/court.service.ts +++ b/apps/judicial-system/backend/src/app/modules/court/court.service.ts @@ -336,6 +336,9 @@ export class CourtService { ) const isIndictment = isIndictmentCase(type) + const policeCaseNumber = policeCaseNumbers[0] + ? policeCaseNumbers[0].replace(/-/g, '') + : '' return await this.courtClientService.createCase(courtId, { caseType: isIndictment ? 'S - Ákærumál' : 'R - Rannsóknarmál', @@ -344,7 +347,7 @@ export class CourtService { receivalDate: formatISO(receivalDate, { representation: 'date' }), basedOn: isIndictment ? 'Sakamál' : 'Rannsóknarhagsmunir', // TODO: pass in all policeCaseNumbers when CourtService supports it - sourceNumber: policeCaseNumbers[0] ? policeCaseNumbers[0] : '', + sourceNumber: policeCaseNumber, }) } catch (reason) { if (reason instanceof ServiceUnavailableException) { @@ -569,14 +572,17 @@ export class CourtService { policeCaseNumber?: string, subtypes?: string[], defendants?: { name?: string; nationalId?: string }[], - prosecutor?: { name?: string; nationalId?: string }, + prosecutor?: { name?: string; nationalId?: string; email?: string }, ): Promise { try { const subject = `${courtName} - ${courtCaseNumber} - upplýsingar` + + const sanitizedPoliceCaseNumber = policeCaseNumber?.replace(/-/g, '') + const content = JSON.stringify({ receivedByCourtDate, indictmentDate, - policeCaseNumber, + sanitizedPoliceCaseNumber, subtypes, defendants, prosecutor, diff --git a/apps/judicial-system/backend/src/app/modules/court/test/createCourtCase.spec.ts b/apps/judicial-system/backend/src/app/modules/court/test/createCourtCase.spec.ts index a32798d80b4e..5b98cb354570 100644 --- a/apps/judicial-system/backend/src/app/modules/court/test/createCourtCase.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/court/test/createCourtCase.spec.ts @@ -105,7 +105,7 @@ describe('CourtService - Create court case', () => { status: 'Skráð', receivalDate: formatISO(receivalDate, { representation: 'date' }), basedOn: 'Rannsóknarhagsmunir', - sourceNumber: policeCaseNumbers[0], + sourceNumber: policeCaseNumbers[0].replace(/-/g, ''), }, ) }) @@ -146,7 +146,7 @@ describe('CourtService - Create court case', () => { status: 'Skráð', receivalDate: formatISO(receivalDate, { representation: 'date' }), basedOn: 'Sakamál', - sourceNumber: policeCaseNumbers[0], + sourceNumber: policeCaseNumbers[0].replace(/-/g, ''), }, ) }) @@ -183,7 +183,7 @@ describe('CourtService - Create court case', () => { status: 'Skráð', receivalDate: formatISO(receivalDate, { representation: 'date' }), basedOn: 'Rannsóknarhagsmunir', - sourceNumber: policeCaseNumbers[0], + sourceNumber: policeCaseNumbers[0].replace(/-/g, ''), }) }) }) @@ -218,7 +218,7 @@ describe('CourtService - Create court case', () => { status: 'Skráð', receivalDate: formatISO(receivalDate, { representation: 'date' }), basedOn: 'Rannsóknarhagsmunir', - sourceNumber: policeCaseNumbers[0], + sourceNumber: policeCaseNumbers[0].replace(/-/g, ''), }) }) })