diff --git a/apps/judicial-system/api/infra/judicial-system-api.ts b/apps/judicial-system/api/infra/judicial-system-api.ts index 8f5cabe11e2c..efe736fa005b 100644 --- a/apps/judicial-system/api/infra/judicial-system-api.ts +++ b/apps/judicial-system/api/infra/judicial-system-api.ts @@ -47,8 +47,8 @@ export const serviceSetup = (services: { }, HIDDEN_FEATURES: { dev: '', - staging: 'MULTIPLE_INDICTMENT_SUBTYPES', - prod: 'MULTIPLE_INDICTMENT_SUBTYPES', + staging: '', + prod: '', }, }) .secrets({ diff --git a/apps/judicial-system/backend/migrations/20241211095654-update-defendant.js b/apps/judicial-system/backend/migrations/20241211095654-update-defendant.js index f8d0249598cc..191abac0f30e 100644 --- a/apps/judicial-system/backend/migrations/20241211095654-update-defendant.js +++ b/apps/judicial-system/backend/migrations/20241211095654-update-defendant.js @@ -16,7 +16,7 @@ module.exports = { ]), ) }, - async down(queryInterface, Sequelize) { + async down(queryInterface) { return queryInterface.sequelize.transaction((t) => queryInterface.removeColumn('defendant', 'punishment_type', { transaction: t, diff --git a/apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts b/apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts index d9c944f392b4..390f959b9b77 100644 --- a/apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts +++ b/apps/judicial-system/backend/src/app/formatters/confirmedPdf.ts @@ -12,14 +12,12 @@ import { import { PDFKitCoatOfArms } from './PDFKitCoatOfArms' type ConfirmableCaseFileCategories = - | CaseFileCategory.INDICTMENT | CaseFileCategory.RULING | CaseFileCategory.COURT_RECORD // Colors const lightGray = rgb(0.9804, 0.9804, 0.9804) const darkGray = rgb(0.7961, 0.7961, 0.7961) -const gold = rgb(0.6784, 0.6392, 0.451) const white = rgb(1, 1, 1) // Spacing @@ -29,175 +27,6 @@ const coatOfArmsWidth = calculatePt(105) const confirmedByHeight = calculatePt(50) const titleX = coatOfArmsX + coatOfArmsWidth + calculatePt(8) -const createIndictmentConfirmation = async ( - confirmation: Confirmation, - pdfDoc: PDFDocument, -) => { - const pages = pdfDoc.getPages() - const doc = pages[0] - - const shadowHeight = calculatePt(90) - const { width, height } = doc.getSize() - const titleHeight = calculatePt(32) - const titleWidth = width - coatOfArmsWidth - 2 * coatOfArmsX - const confirmedByWidth = calculatePt(258) - const institutionWidth = confirmedByWidth + calculatePt(48) - - // Draw the shadow - doc.drawRectangle({ - x: pageMargin, - y: height - shadowHeight - pageMargin, - width: doc.getWidth() - 2 * pageMargin - calculatePt(16), - height: shadowHeight, - color: lightGray, - }) - - // Draw the box around the coat of arms - doc.drawRectangle({ - x: coatOfArmsX, - y: height - shadowHeight - pageMargin + calculatePt(8), - width: coatOfArmsWidth, - height: shadowHeight, - color: rgb(1, 1, 1), - borderColor: darkGray, - borderWidth: 1, - }) - - PDFKitCoatOfArms(doc, height) - - doc.drawRectangle({ - x: coatOfArmsX + coatOfArmsWidth, - y: height - pageMargin - titleHeight + calculatePt(8), - width: titleWidth, - height: titleHeight, - color: lightGray, - borderColor: darkGray, - borderWidth: 1, - }) - - const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman) - const timesRomanBoldFont = await pdfDoc.embedFont( - StandardFonts.TimesRomanBold, - ) - doc.drawText('Réttarvörslugátt', { - x: titleX, - y: height - pageMargin - titleHeight + calculatePt(20), - size: calculatePt(smallFontSize), - font: timesRomanBoldFont, - }) - - doc.drawText('Skjal samþykkt rafrænt', { - x: 158, - y: height - pageMargin - titleHeight + calculatePt(20), - size: calculatePt(smallFontSize), - font: timesRomanFont, - }) - - doc.drawSvgPath( - 'M0.763563 11.8047H7.57201C7.85402 11.8047 8.08264 11.5761 8.08264 11.2941V5.50692C8.08264 5.22492 7.85402 4.99629 7.57201 4.99629H7.06138V3.46439C7.06138 1.86887 5.76331 0.570801 4.16779 0.570801C2.57226 0.570801 1.2742 1.86887 1.2742 3.46439V4.99629H0.763563C0.481557 4.99629 0.25293 5.22492 0.25293 5.50692V11.2941C0.25293 11.5761 0.481557 11.8047 0.763563 11.8047ZM5.61394 8.03817L4.16714 9.48496C4.06743 9.58467 3.93674 9.63455 3.80609 9.63455C3.67543 9.63455 3.54471 9.58467 3.44504 9.48496L2.72164 8.76157C2.52222 8.56215 2.52222 8.23888 2.72164 8.03943C2.92102 7.84001 3.24436 7.84001 3.44378 8.03943L3.80612 8.40174L4.89187 7.31603C5.09125 7.11661 5.41458 7.11661 5.614 7.31603C5.81339 7.51549 5.81339 7.83875 5.61394 8.03817ZM2.29546 3.46439C2.29546 2.43199 3.13539 1.59207 4.16779 1.59207C5.20019 1.59207 6.04011 2.43199 6.04011 3.46439V4.99629H2.29546V3.46439Z', - { - color: gold, - x: width - 38, - y: height - pageMargin - titleHeight + calculatePt(33), - }, - ) - - // Draw the "Confirmed by" box - doc.drawRectangle({ - x: coatOfArmsX + coatOfArmsWidth, - y: height - pageMargin - titleHeight - confirmedByHeight, - width: confirmedByWidth, - height: shadowHeight - titleHeight, - color: white, - borderColor: darkGray, - borderWidth: 1, - }) - - doc.drawText('Staðfestingaraðili', { - x: titleX, - y: height - pageMargin - titleHeight - calculatePt(15), - size: calculatePt(smallFontSize), - font: timesRomanBoldFont, - }) - - if (confirmation?.actor) { - timesRomanFont.widthOfTextAtSize( - `${confirmation.actor}${ - confirmation.title ? `, ${lowercase(confirmation.title)}` : '' - }`, - calculatePt(smallFontSize), - ) - drawTextWithEllipsisPDFKit( - doc, - `${confirmation.actor}${ - confirmation.title ? `, ${lowercase(confirmation.title)}` : '' - }`, - { type: timesRomanFont, size: calculatePt(smallFontSize) }, - titleX, - height - pageMargin - titleHeight - calculatePt(29), - confirmedByWidth - 16, - ) - } - - // Draw the "Institution" box - doc.drawRectangle({ - x: coatOfArmsX + coatOfArmsWidth + confirmedByWidth, - y: height - pageMargin - titleHeight - confirmedByHeight, - width: institutionWidth, - height: shadowHeight - titleHeight, - color: white, - borderColor: darkGray, - borderWidth: 1, - }) - - doc.drawText('Embætti', { - x: titleX + confirmedByWidth, - y: height - pageMargin - titleHeight - calculatePt(15), - size: calculatePt(smallFontSize), - font: timesRomanBoldFont, - }) - - if (confirmation?.institution) { - doc.drawText(confirmation.institution, { - x: titleX + confirmedByWidth, - y: height - pageMargin - titleHeight - calculatePt(29), - font: timesRomanFont, - size: calculatePt(smallFontSize), - }) - } - - // Draw the "Indictment date" box - doc.drawRectangle({ - x: width - 90, - y: height - pageMargin - titleHeight - confirmedByHeight, - width: 70, - height: shadowHeight - titleHeight, - color: white, - borderColor: darkGray, - borderWidth: 1, - }) - - doc.drawText('Útgáfa ákæru', { - x: width - 72, - y: height - pageMargin - titleHeight - calculatePt(15), - size: calculatePt(smallFontSize), - font: timesRomanBoldFont, - }) - - if (confirmation?.date) { - const dateFormattedDate = formatDate(confirmation.date) - - if (dateFormattedDate) { - doc.drawText(dateFormattedDate, { - x: width - 62, - y: height - pageMargin - titleHeight - calculatePt(29), - font: timesRomanFont, - size: calculatePt(smallFontSize), - }) - } - } -} - const createRulingConfirmation = async ( confirmation: Confirmation, pdfDoc: PDFDocument, @@ -443,9 +272,6 @@ export const createConfirmedPdf = async ( const pdfDoc = await PDFDocument.load(pdf) switch (fileType) { - case CaseFileCategory.INDICTMENT: - await createIndictmentConfirmation(confirmation, pdfDoc) - break case CaseFileCategory.RULING: { await createRulingConfirmation(confirmation, pdfDoc) break diff --git a/apps/judicial-system/backend/src/app/modules/case/case.service.ts b/apps/judicial-system/backend/src/app/modules/case/case.service.ts index f84660b9b797..0f1fcbe5e108 100644 --- a/apps/judicial-system/backend/src/app/modules/case/case.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/case.service.ts @@ -47,7 +47,6 @@ import { isIndictmentCase, isInvestigationCase, isRequestCase, - isTrafficViolationCase, notificationTypes, StringType, stringTypes, @@ -388,7 +387,6 @@ export const include: Includeable[] = [ state: { [Op.not]: CaseFileState.DELETED }, category: { [Op.in]: [ - CaseFileCategory.INDICTMENT, CaseFileCategory.COURT_RECORD, CaseFileCategory.CRIMINAL_RECORD, CaseFileCategory.COST_BREAKDOWN, @@ -819,22 +817,13 @@ export class CaseService { }), ) - const caseFilesCategories = isTrafficViolationCase(theCase) - ? [ - CaseFileCategory.CRIMINAL_RECORD, - CaseFileCategory.COST_BREAKDOWN, - CaseFileCategory.CASE_FILE, - CaseFileCategory.PROSECUTOR_CASE_FILE, - CaseFileCategory.DEFENDANT_CASE_FILE, - ] - : [ - CaseFileCategory.INDICTMENT, - CaseFileCategory.CRIMINAL_RECORD, - CaseFileCategory.COST_BREAKDOWN, - CaseFileCategory.CASE_FILE, - CaseFileCategory.PROSECUTOR_CASE_FILE, - CaseFileCategory.DEFENDANT_CASE_FILE, - ] + const caseFilesCategories = [ + CaseFileCategory.CRIMINAL_RECORD, + CaseFileCategory.COST_BREAKDOWN, + CaseFileCategory.CASE_FILE, + CaseFileCategory.PROSECUTOR_CASE_FILE, + CaseFileCategory.DEFENDANT_CASE_FILE, + ] const deliverCaseFileToCourtMessages = theCase.caseFiles @@ -856,13 +845,11 @@ export class CaseService { deliverCaseFileToCourtMessages, ) - if (isTrafficViolationCase(theCase)) { - messages.push({ - type: MessageType.DELIVERY_TO_COURT_INDICTMENT, - user, - caseId: theCase.id, - }) - } + messages.push({ + type: MessageType.DELIVERY_TO_COURT_INDICTMENT, + user, + caseId: theCase.id, + }) if (theCase.state === CaseState.WAITING_FOR_CANCELLATION) { messages.push({ @@ -1854,10 +1841,6 @@ export class CaseService { ): Promise { const receivingCase = update.courtCaseNumber && theCase.state === CaseState.SUBMITTED - const returningIndictmentCase = - isIndictmentCase(theCase.type) && - update.state === CaseState.DRAFT && - theCase.state === CaseState.RECEIVED const completingIndictmentCaseWithoutRuling = isIndictmentCase(theCase.type) && update.state === CaseState.COMPLETED && @@ -1916,13 +1899,6 @@ export class CaseService { await this.fileService.resetCaseFileStates(theCase.id, transaction) } - if (returningIndictmentCase) { - await this.fileService.resetIndictmentCaseFileHashes( - theCase.id, - transaction, - ) - } - // Remove uploaded ruling files if an indictment case is completed without a ruling if (completingIndictmentCaseWithoutRuling && theCase.caseFiles) { await Promise.all( 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 6270725b5314..56d1ca11eacc 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 @@ -32,7 +32,6 @@ import { isProsecutionUser, isRequestCase, isRestrictionCase, - isTrafficViolationCase, NotificationType, restrictionCases, type User as TUser, @@ -1051,39 +1050,14 @@ export class InternalCaseService { user: TUser, ): Promise { try { - let policeDocuments: PoliceDocument[] + const file = await this.pdfService.getIndictmentPdf(theCase) - if (isTrafficViolationCase(theCase)) { - const file = await this.pdfService.getIndictmentPdf(theCase) - - policeDocuments = [ - { - type: PoliceDocumentType.RVAS, - courtDocument: Base64.btoa(file.toString('binary')), - }, - ] - } else { - policeDocuments = await Promise.all( - theCase.caseFiles - ?.filter( - (caseFile) => - caseFile.category === CaseFileCategory.INDICTMENT && - caseFile.key, - ) - .map(async (caseFile) => { - // TODO: Tolerate failure, but log error - const file = await this.fileService.getCaseFileFromS3( - theCase, - caseFile, - ) - - return { - type: PoliceDocumentType.RVAS, - courtDocument: Base64.btoa(file.toString('binary')), - } - }) ?? [], - ) - } + const policeDocuments = [ + { + type: PoliceDocumentType.RVAS, + courtDocument: Base64.btoa(file.toString('binary')), + }, + ] const delivered = await this.deliverCaseToPoliceWithFiles( theCase, diff --git a/apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts b/apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts index 4f1cb4a8a1de..4fae33bdf0f1 100644 --- a/apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/limitedAccessCase.service.ts @@ -228,7 +228,6 @@ export const include: Includeable[] = [ CaseFileCategory.APPEAL_RULING, CaseFileCategory.APPEAL_COURT_RECORD, CaseFileCategory.COURT_RECORD, - CaseFileCategory.INDICTMENT, CaseFileCategory.CRIMINAL_RECORD, CaseFileCategory.COST_BREAKDOWN, CaseFileCategory.CASE_FILE, @@ -277,7 +276,6 @@ export const include: Includeable[] = [ state: { [Op.not]: CaseFileState.DELETED }, category: { [Op.in]: [ - CaseFileCategory.INDICTMENT, CaseFileCategory.COURT_RECORD, CaseFileCategory.CRIMINAL_RECORD, CaseFileCategory.COST_BREAKDOWN, diff --git a/apps/judicial-system/backend/src/app/modules/case/models/case.model.ts b/apps/judicial-system/backend/src/app/modules/case/models/case.model.ts index e8c0f6494573..1c0af5c4e3c0 100644 --- a/apps/judicial-system/backend/src/app/modules/case/models/case.model.ts +++ b/apps/judicial-system/backend/src/app/modules/case/models/case.model.ts @@ -742,7 +742,7 @@ export class Case extends Model { crimeScenes?: CrimeSceneMap /********** - * The introduction to a traffic violation case + * The introduction to a indictment case **********/ @Column({ type: DataType.TEXT, allowNull: true }) @ApiPropertyOptional({ type: String }) @@ -1029,7 +1029,6 @@ export class Case extends Model { /********** * The md5 hash of the confirmed generated indictment - * Only used for traffic violation cases **********/ @Column({ type: DataType.STRING, allowNull: true }) @ApiPropertyOptional({ type: String }) diff --git a/apps/judicial-system/backend/src/app/modules/case/pdf.service.ts b/apps/judicial-system/backend/src/app/modules/case/pdf.service.ts index 721c79cbf394..c59e7f9feeb6 100644 --- a/apps/judicial-system/backend/src/app/modules/case/pdf.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/pdf.service.ts @@ -1,7 +1,6 @@ import CryptoJS from 'crypto-js' import { - BadRequestException, forwardRef, Inject, Injectable, @@ -17,7 +16,6 @@ import { CaseFileCategory, EventType, hasIndictmentCaseBeenSubmittedToCourt, - isTrafficViolationCase, SubpoenaType, type User as TUser, } from '@island.is/judicial-system/types' @@ -205,12 +203,6 @@ export class PdfService { } async getIndictmentPdf(theCase: Case): Promise { - if (!isTrafficViolationCase(theCase)) { - throw new BadRequestException( - `Case ${theCase.id} is not a traffic violation case`, - ) - } - let confirmation: Confirmation | undefined = undefined if (hasIndictmentCaseBeenSubmittedToCourt(theCase.state)) { diff --git a/apps/judicial-system/backend/src/app/modules/case/test/caseController/createCourtCase.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/caseController/createCourtCase.spec.ts index b1daaac68f15..97be863b28c4 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/caseController/createCourtCase.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/caseController/createCourtCase.spec.ts @@ -294,7 +294,6 @@ describe('CaseController - Create court case', () => { const caseId = uuid() const policeCaseNumber1 = uuid() const policeCaseNumber2 = uuid() - const indictmentId = uuid() const criminalRecordId = uuid() const costBreakdownId = uuid() const uncategorisedId = uuid() @@ -306,12 +305,6 @@ describe('CaseController - Create court case', () => { type: CaseType.INDICTMENT, policeCaseNumbers: [policeCaseNumber1, policeCaseNumber2], caseFiles: [ - { - id: indictmentId, - key: uuid(), - state: CaseFileState.STORED_IN_RVG, - category: CaseFileCategory.INDICTMENT, - }, { id: criminalRecordId, key: uuid(), @@ -365,25 +358,24 @@ describe('CaseController - Create court case', () => { type: MessageType.DELIVERY_TO_COURT_CASE_FILE, user, caseId, - elementId: indictmentId, + elementId: criminalRecordId, }, { type: MessageType.DELIVERY_TO_COURT_CASE_FILE, user, caseId, - elementId: criminalRecordId, + elementId: costBreakdownId, }, { type: MessageType.DELIVERY_TO_COURT_CASE_FILE, user, caseId, - elementId: costBreakdownId, + elementId: uncategorisedId, }, { - type: MessageType.DELIVERY_TO_COURT_CASE_FILE, + type: MessageType.DELIVERY_TO_COURT_INDICTMENT, user, caseId, - elementId: uncategorisedId, }, ]) }) diff --git a/apps/judicial-system/backend/src/app/modules/case/test/caseController/update.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/caseController/update.spec.ts index 51d7fd6c5d6e..9e4621e97d68 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/caseController/update.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/caseController/update.spec.ts @@ -406,7 +406,6 @@ describe('CaseController - Update', () => { const caseToUpdate = { courtCaseNumber } const policeCaseNumber1 = uuid() const policeCaseNumber2 = uuid() - const indictmentId = uuid() const criminalRecordId = uuid() const costBreakdownId = uuid() const uncategorisedId = uuid() @@ -415,12 +414,6 @@ describe('CaseController - Update', () => { type, policeCaseNumbers: [policeCaseNumber1, policeCaseNumber2], caseFiles: [ - { - id: indictmentId, - key: uuid(), - state: CaseFileState.STORED_IN_RVG, - category: CaseFileCategory.INDICTMENT, - }, { id: criminalRecordId, key: uuid(), @@ -474,25 +467,24 @@ describe('CaseController - Update', () => { type: MessageType.DELIVERY_TO_COURT_CASE_FILE, user, caseId, - elementId: indictmentId, + elementId: criminalRecordId, }, { type: MessageType.DELIVERY_TO_COURT_CASE_FILE, user, caseId, - elementId: criminalRecordId, + elementId: costBreakdownId, }, { type: MessageType.DELIVERY_TO_COURT_CASE_FILE, user, caseId, - elementId: costBreakdownId, + elementId: uncategorisedId, }, { - type: MessageType.DELIVERY_TO_COURT_CASE_FILE, + type: MessageType.DELIVERY_TO_COURT_INDICTMENT, user, caseId, - elementId: uncategorisedId, }, ]) }) diff --git a/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentToPolice.spec.ts b/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentToPolice.spec.ts index a9bf45ec1fb2..757d3ca7ea18 100644 --- a/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentToPolice.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/case/test/internalCaseController/deliverIndictmentToPolice.spec.ts @@ -2,7 +2,6 @@ import { Base64 } from 'js-base64' import { uuid } from 'uuidv4' import { - CaseFileCategory, CaseOrigin, CaseState, CaseType, @@ -74,70 +73,6 @@ describe('InternalCaseController - Deliver indictment to police', () => { } }) - describe('deliver indictment case files to police', () => { - const caseId = uuid() - const caseType = CaseType.INDICTMENT - const caseState = CaseState.WAITING_FOR_CONFIRMATION - const policeCaseNumber = uuid() - const courtCaseNumber = uuid() - const defendantNationalId = '0123456789' - const indictmentKey = uuid() - const indictmentPdf = 'test indictment' - const caseFile = { - id: uuid(), - key: indictmentKey, - category: CaseFileCategory.INDICTMENT, - } - const theCase = { - id: caseId, - origin: CaseOrigin.LOKE, - type: caseType, - state: caseState, - policeCaseNumbers: [policeCaseNumber], - courtCaseNumber, - defendants: [{ nationalId: defendantNationalId }], - caseFiles: [caseFile], - } as Case - - let then: Then - - beforeEach(async () => { - const mockGetCaseFileFromS3 = - mockFileService.getCaseFileFromS3 as jest.Mock - mockGetCaseFileFromS3.mockResolvedValueOnce(indictmentPdf) - const mockUpdatePoliceCase = - mockPoliceService.updatePoliceCase as jest.Mock - mockUpdatePoliceCase.mockResolvedValueOnce(true) - - then = await givenWhenThen(caseId, theCase) - }) - - it('should update the police case', async () => { - expect(mockFileService.getCaseFileFromS3).toHaveBeenCalledWith( - theCase, - caseFile, - ) - expect(mockPoliceService.updatePoliceCase).toHaveBeenCalledWith( - user, - caseId, - caseType, - caseState, - policeCaseNumber, - courtCaseNumber, - defendantNationalId, - date, - '', - [ - { - type: PoliceDocumentType.RVAS, - courtDocument: Base64.btoa(indictmentPdf), - }, - ], - ) - expect(then.result.delivered).toEqual(true) - }) - }) - describe('deliver generated indictment pdf to police', () => { const caseId = uuid() const caseType = CaseType.INDICTMENT diff --git a/apps/judicial-system/backend/src/app/modules/file/file.service.ts b/apps/judicial-system/backend/src/app/modules/file/file.service.ts index f41f53135036..be1680ecc86b 100644 --- a/apps/judicial-system/backend/src/app/modules/file/file.service.ts +++ b/apps/judicial-system/backend/src/app/modules/file/file.service.ts @@ -22,7 +22,6 @@ import { CaseFileCategory, CaseFileState, EventType, - hasIndictmentCaseBeenSubmittedToCourt, isCompletedCase, isIndictmentCase, } from '@island.is/judicial-system/types' @@ -107,24 +106,6 @@ export class FileService { return true } - if ( - isIndictmentCase(theCase.type) && - file.category === CaseFileCategory.INDICTMENT - ) { - // The file may have been confirmed - return this.awsS3Service - .deleteConfirmedIndictmentCaseObject(theCase.type, file.key) - .catch((reason) => { - // Tolerate failure, but log what happened - this.logger.error( - `Could not delete confirmed file ${file.id} of case ${file.caseId} from AWS S3`, - { reason }, - ) - - return false - }) - } - return this.awsS3Service .deleteObject(theCase.type, file.key) .catch((reason) => { @@ -142,9 +123,6 @@ export class FileService { let courtDocumentFolder: CourtDocumentFolder switch (file.category) { - case CaseFileCategory.INDICTMENT: - courtDocumentFolder = CourtDocumentFolder.INDICTMENT_DOCUMENTS - break case CaseFileCategory.COURT_RECORD: case CaseFileCategory.RULING: courtDocumentFolder = CourtDocumentFolder.COURT_DOCUMENTS @@ -177,6 +155,14 @@ export class FileService { file: CaseFile, pdf: Buffer, ): Promise { + if ( + !theCase.rulingDate || + (file.category !== CaseFileCategory.RULING && + file.category !== CaseFileCategory.COURT_RECORD) + ) { + return undefined + } + const confirmationEvent = theCase.eventLogs?.find( (event) => event.eventType === EventType.INDICTMENT_CONFIRMED, ) @@ -185,40 +171,16 @@ export class FileService { return undefined } - return this.userService - .findByNationalId(confirmationEvent.nationalId) - .then((user) => { - if (file.category === CaseFileCategory.INDICTMENT) { - return createConfirmedPdf( - { - actor: user.name, - title: user.title, - institution: user.institution?.name ?? '', - date: confirmationEvent.created, - }, - pdf, - CaseFileCategory.INDICTMENT, - ) - } - - if ( - (file.category === CaseFileCategory.RULING || - file.category === CaseFileCategory.COURT_RECORD) && - isCompletedCase(theCase.state) && - theCase.rulingDate - ) { - return createConfirmedPdf( - { - actor: theCase.judge?.name ?? '', - title: theCase.judge?.title, - institution: theCase.judge?.institution?.name ?? '', - date: theCase.rulingDate, - }, - pdf, - file.category, - ) - } - }) + return createConfirmedPdf( + { + actor: theCase.judge?.name ?? '', + title: theCase.judge?.title, + institution: theCase.judge?.institution?.name ?? '', + date: theCase.rulingDate, + }, + pdf, + file.category, + ) .then((confirmedPdf) => { if (!confirmedPdf) { throw new Error('Failed to create confirmed PDF') @@ -248,14 +210,6 @@ export class FileService { return false } - // Only indictments that have been submitted to court can be confirmed - if ( - file.category === CaseFileCategory.INDICTMENT && - hasIndictmentCaseBeenSubmittedToCourt(theCase.state) - ) { - return true - } - // Rulings and court records are only confirmed when a case is completed if ( (file.category === CaseFileCategory.RULING || @@ -572,13 +526,6 @@ export class FileService { ) } - resetIndictmentCaseFileHashes(caseId: string, transaction: Transaction) { - return this.fileModel.update( - { hash: null }, - { where: { caseId, category: CaseFileCategory.INDICTMENT }, transaction }, - ) - } - async deliverCaseFileToCourtOfAppeals( theCase: Case, file: CaseFile, diff --git a/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts b/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts index b6656ac08470..0de7a2d7a6f1 100644 --- a/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts +++ b/apps/judicial-system/backend/src/app/modules/file/guards/caseFileCategory.ts @@ -32,7 +32,6 @@ const defenderDefaultCaseFileCategoriesForIndictmentCases = [ const defenderCaseFileCategoriesForIndictmentCases = defenderDefaultCaseFileCategoriesForIndictmentCases.concat( - CaseFileCategory.INDICTMENT, CaseFileCategory.CRIMINAL_RECORD, CaseFileCategory.COST_BREAKDOWN, CaseFileCategory.CASE_FILE, diff --git a/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts b/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts index f333b338737f..bc472456ac25 100644 --- a/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/file/guards/test/limitedAccessViewCaseFileGuard.spec.ts @@ -156,7 +156,6 @@ describe('Limited Access View Case File Guard', () => { const allowedCaseFileCategories = [ CaseFileCategory.COURT_RECORD, CaseFileCategory.RULING, - CaseFileCategory.INDICTMENT, CaseFileCategory.CRIMINAL_RECORD, CaseFileCategory.COST_BREAKDOWN, CaseFileCategory.CASE_FILE, diff --git a/apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts b/apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts index 5285a7aa0a70..61fab9e181c2 100644 --- a/apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts +++ b/apps/judicial-system/backend/src/app/modules/file/limitedAccessFile.controller.ts @@ -37,11 +37,7 @@ import { LimitedAccessCaseExistsGuard, } from '../case' import { MergedCaseExistsGuard } from '../case/guards/mergedCaseExists.guard' -import { - CivilClaimant, - CivilClaimantExistsGuard, - CurrentCivilClaimant, -} from '../defendant' +import { CivilClaimantExistsGuard } from '../defendant' import { CreateFileDto } from './dto/createFile.dto' import { CreatePresignedPostDto } from './dto/createPresignedPost.dto' import { CurrentCaseFile } from './guards/caseFile.decorator' diff --git a/apps/judicial-system/backend/src/app/modules/file/test/fileController/uploadCaseFileToCourt.spec.ts b/apps/judicial-system/backend/src/app/modules/file/test/fileController/uploadCaseFileToCourt.spec.ts index 28e9c5a0c35c..b2bd7e2301a4 100644 --- a/apps/judicial-system/backend/src/app/modules/file/test/fileController/uploadCaseFileToCourt.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/file/test/fileController/uploadCaseFileToCourt.spec.ts @@ -159,7 +159,6 @@ describe('FileController - Upload case file to court', () => { caseFileCategory | courtDocumentFolder ${CaseFileCategory.COURT_RECORD} | ${CourtDocumentFolder.COURT_DOCUMENTS} ${CaseFileCategory.RULING} | ${CourtDocumentFolder.COURT_DOCUMENTS} - ${CaseFileCategory.INDICTMENT} | ${CourtDocumentFolder.INDICTMENT_DOCUMENTS} ${CaseFileCategory.CRIMINAL_RECORD} | ${CourtDocumentFolder.CASE_DOCUMENTS} ${CaseFileCategory.COST_BREAKDOWN} | ${CourtDocumentFolder.CASE_DOCUMENTS} ${CaseFileCategory.CASE_FILE} | ${CourtDocumentFolder.CASE_DOCUMENTS} diff --git a/apps/judicial-system/backend/src/app/modules/file/test/internalFileController/deliverCaseFileToCourt.spec.ts b/apps/judicial-system/backend/src/app/modules/file/test/internalFileController/deliverCaseFileToCourt.spec.ts index 5f056138589d..1c78a71b1047 100644 --- a/apps/judicial-system/backend/src/app/modules/file/test/internalFileController/deliverCaseFileToCourt.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/file/test/internalFileController/deliverCaseFileToCourt.spec.ts @@ -140,7 +140,6 @@ describe('InternalFileController - Deliver case file to court', () => { caseFileCategory | courtDocumentFolder ${CaseFileCategory.COURT_RECORD} | ${CourtDocumentFolder.COURT_DOCUMENTS} ${CaseFileCategory.RULING} | ${CourtDocumentFolder.COURT_DOCUMENTS} - ${CaseFileCategory.INDICTMENT} | ${CourtDocumentFolder.INDICTMENT_DOCUMENTS} ${CaseFileCategory.CRIMINAL_RECORD} | ${CourtDocumentFolder.CASE_DOCUMENTS} ${CaseFileCategory.COST_BREAKDOWN} | ${CourtDocumentFolder.CASE_DOCUMENTS} ${CaseFileCategory.CASE_FILE} | ${CourtDocumentFolder.CASE_DOCUMENTS} diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.module.ts b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.module.ts index 05be74045e18..06634dee2f5d 100644 --- a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.module.ts +++ b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.module.ts @@ -8,7 +8,6 @@ import { CourtModule } from '../court/court.module' import { DefendantModule } from '../defendant/defendant.module' import { Defendant } from '../defendant/models/defendant.model' import { EventModule } from '../event/event.module' -import { FileModule } from '../file/file.module' import { PoliceModule } from '../police/police.module' import { Subpoena } from './models/subpoena.model' import { InternalSubpoenaController } from './internalSubpoena.controller' @@ -20,7 +19,6 @@ import { SubpoenaService } from './subpoena.service' imports: [ forwardRef(() => CaseModule), forwardRef(() => PoliceModule), - forwardRef(() => FileModule), forwardRef(() => MessageModule), forwardRef(() => EventModule), forwardRef(() => DefendantModule), diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts index 673973d5cc10..6993a5d67f05 100644 --- a/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts +++ b/apps/judicial-system/backend/src/app/modules/subpoena/subpoena.service.ts @@ -20,10 +20,8 @@ import { MessageType, } from '@island.is/judicial-system/message' import { - CaseFileCategory, isFailedServiceStatus, isSuccessfulServiceStatus, - isTrafficViolationCase, ServiceStatus, SubpoenaNotificationType, type User as TUser, @@ -35,7 +33,6 @@ import { CourtDocumentFolder, CourtService } from '../court' import { DefendantService } from '../defendant/defendant.service' import { Defendant } from '../defendant/models/defendant.model' import { EventService } from '../event' -import { FileService } from '../file' import { PoliceService, SubpoenaInfo } from '../police' import { User } from '../user' import { UpdateSubpoenaDto } from './dto/updateSubpoena.dto' @@ -90,8 +87,6 @@ export class SubpoenaService { private readonly messageService: MessageService, @Inject(forwardRef(() => PoliceService)) private readonly policeService: PoliceService, - @Inject(forwardRef(() => FileService)) - private readonly fileService: FileService, private readonly eventService: EventService, private readonly defendantService: DefendantService, private readonly courtService: CourtService, @@ -292,27 +287,6 @@ export class SubpoenaService { }) } - async getIndictmentPdf(theCase: Case): Promise { - if (isTrafficViolationCase(theCase)) { - return await this.pdfService.getIndictmentPdf(theCase) - } - - const indictmentCaseFile = theCase.caseFiles?.find( - (caseFile) => - caseFile.category === CaseFileCategory.INDICTMENT && caseFile.key, - ) - - if (!indictmentCaseFile) { - // This shouldn't ever happen - this.logger.error( - `No indictment found for case ${theCase.id} so cannot deliver subpoena to police`, - ) - throw new Error(`No indictment found for case ${theCase.id}`) - } - - return await this.fileService.getCaseFileFromS3(theCase, indictmentCaseFile) - } - async deliverSubpoenaToPolice( theCase: Case, defendant: Defendant, @@ -326,7 +300,7 @@ export class SubpoenaService { subpoena, ) - const indictmentPdf = await this.getIndictmentPdf(theCase) + const indictmentPdf = await this.pdfService.getIndictmentPdf(theCase) const createdSubpoena = await this.policeService.createSubpoena( theCase, diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/test/createTestingSubpoenaModule.ts b/apps/judicial-system/backend/src/app/modules/subpoena/test/createTestingSubpoenaModule.ts index c4982ece5817..af80ec74850e 100644 --- a/apps/judicial-system/backend/src/app/modules/subpoena/test/createTestingSubpoenaModule.ts +++ b/apps/judicial-system/backend/src/app/modules/subpoena/test/createTestingSubpoenaModule.ts @@ -16,7 +16,6 @@ import { CaseService, PdfService } from '../../case' import { CourtService } from '../../court' import { Defendant, DefendantService } from '../../defendant' import { EventService } from '../../event' -import { FileService } from '../../file' import { PoliceService } from '../../police' import { UserService } from '../../user' import { InternalSubpoenaController } from '../internalSubpoena.controller' @@ -30,7 +29,6 @@ jest.mock('../../user/user.service') jest.mock('../../case/case.service') jest.mock('../../case/pdf.service') jest.mock('../../police/police.service') -jest.mock('../../file/file.service') jest.mock('../../event/event.service') jest.mock('../../defendant/defendant.service') jest.mock('../../court/court.service') @@ -50,7 +48,6 @@ export const createTestingSubpoenaModule = async () => { CaseService, PdfService, PoliceService, - FileService, EventService, DefendantService, CourtService, @@ -95,8 +92,6 @@ export const createTestingSubpoenaModule = async () => { const policeService = subpoenaModule.get(PoliceService) - const fileService = subpoenaModule.get(FileService) - const courtService = subpoenaModule.get(CourtService) const subpoenaModel = await subpoenaModule.resolve( @@ -122,7 +117,6 @@ export const createTestingSubpoenaModule = async () => { userService, pdfService, policeService, - fileService, courtService, subpoenaModel, subpoenaService, diff --git a/apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaToPolice.spec.ts b/apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaToPolice.spec.ts index ff02a709d797..c2c523ce3da8 100644 --- a/apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaToPolice.spec.ts +++ b/apps/judicial-system/backend/src/app/modules/subpoena/test/internalSubpoenaController/deliverSubpoenaToPolice.spec.ts @@ -59,13 +59,12 @@ describe('InternalSubpoenaController - Deliver subpoena to police', () => { describe('subpoena delivered to police', () => { const subpoenaPdf = uuid() - let then: Then beforeEach(async () => { const mockGetSubpoenaPdf = mockPdfService.getSubpoenaPdf as jest.Mock mockGetSubpoenaPdf.mockResolvedValue(subpoenaPdf) - then = await givenWhenThen() + await givenWhenThen() }) it('should call deliverSubpoenaToPolice', () => { diff --git a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx index 752011aac971..af794c72c5b6 100644 --- a/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx +++ b/apps/judicial-system/web/src/components/IndictmentCaseFilesList/IndictmentCaseFilesList.tsx @@ -5,7 +5,6 @@ import { AnimatePresence } from 'framer-motion' import { Box, Text } from '@island.is/island-ui/core' import { formatDate } from '@island.is/judicial-system/formatters' import { - Feature, isCompletedCase, isDefenceUser, isDistrictCourtUser, @@ -14,10 +13,8 @@ import { isPublicProsecutor, isPublicProsecutorUser, isSuccessfulServiceStatus, - isTrafficViolationCase, } from '@island.is/judicial-system/types' import { - FeatureContext, FileNotFoundModal, PdfButton, SectionHeading, @@ -108,7 +105,6 @@ const useFilteredCaseFiles = (caseFiles?: CaseFile[] | null) => { } return { - indictments: filterByCategories(CaseFileCategory.INDICTMENT), criminalRecords: filterByCategories(CaseFileCategory.CRIMINAL_RECORD), costBreakdowns: filterByCategories(CaseFileCategory.COST_BREAKDOWN), others: filterByCategories(CaseFileCategory.CASE_FILE), @@ -158,16 +154,11 @@ const IndictmentCaseFilesList: FC = ({ }) => { const { formatMessage } = useIntl() const { user, limitedAccess } = useContext(UserContext) - const { features } = useContext(FeatureContext) const { onOpen, fileNotFound, dismissFileNotFound } = useFileList({ caseId: workingCase.id, connectedCaseParentId, }) - const showTrafficViolationCaseFiles = - features.includes(Feature.MULTIPLE_INDICTMENT_SUBTYPES) || - isTrafficViolationCase(workingCase) - const showSubpoenaPdf = displayGeneratedPDFs && workingCase.defendants?.some( @@ -182,12 +173,7 @@ const IndictmentCaseFilesList: FC = ({ {displayHeading && ( )} - - {showTrafficViolationCaseFiles && displayGeneratedPDFs && ( + {displayGeneratedPDFs && ( {formatMessage(caseFiles.indictmentSection)} @@ -196,7 +182,7 @@ const IndictmentCaseFilesList: FC = ({ diff --git a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/CaseFiles/CaseFiles.strings.ts b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/CaseFiles/CaseFiles.strings.ts index 13050303164b..dd7dd3d921d2 100644 --- a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/CaseFiles/CaseFiles.strings.ts +++ b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/CaseFiles/CaseFiles.strings.ts @@ -53,9 +53,9 @@ export const caseFiles = defineMessages({ description: 'Titill á Tilkynning til sakaskrár hluta á dómskjalaskjá í ákærum.', }, - trafficViolationIndictmentTitle: { - id: 'judicial.system.core:indictments.case_files.traffic_violation_indictment_title', + indictmentTitle: { + id: 'judicial.system.core:indictments.case_files.indictment_title', defaultMessage: 'Ákæra.pdf', - description: 'Titill á ákæru pdf fyrir umferðalagabrot.', + description: 'Titill á ákæru pdf fyrir ákæru.', }, }) diff --git a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/CaseFiles/CaseFiles.tsx b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/CaseFiles/CaseFiles.tsx index e10112fd8b4e..bc76c7fd1cb2 100644 --- a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/CaseFiles/CaseFiles.tsx +++ b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/CaseFiles/CaseFiles.tsx @@ -5,13 +5,8 @@ import router from 'next/router' import { Box, InputFileUpload } from '@island.is/island-ui/core' import { fileExtensionWhitelist } from '@island.is/island-ui/core/types' import * as constants from '@island.is/judicial-system/consts' -import { - Feature, - isTrafficViolationCase, -} from '@island.is/judicial-system/types' import { titles } from '@island.is/judicial-system-web/messages' import { - FeatureContext, FormContentContainer, FormContext, FormFooter, @@ -33,7 +28,6 @@ import * as strings from './CaseFiles.strings' const CaseFiles = () => { const { workingCase, isLoadingWorkingCase, caseNotFound } = useContext(FormContext) - const { features } = useContext(FeatureContext) const { formatMessage } = useIntl() const { uploadFiles, @@ -46,18 +40,7 @@ const CaseFiles = () => { workingCase.id, ) - const isTrafficViolationCaseCheck = - features.includes(Feature.MULTIPLE_INDICTMENT_SUBTYPES) || - isTrafficViolationCase(workingCase) - - const stepIsValid = - (isTrafficViolationCaseCheck || - uploadFiles.some( - (file) => - file.category === CaseFileCategory.INDICTMENT && - file.status === 'done', - )) && - allFilesDoneOrError + const stepIsValid = allFilesDoneOrError const handleNavigationTo = useCallback( (destination: string) => router.push(`${destination}/${workingCase.id}`), [workingCase.id], @@ -77,32 +60,6 @@ const CaseFiles = () => { {formatMessage(strings.caseFiles.heading)} - {!isTrafficViolationCaseCheck && ( - - - file.category === CaseFileCategory.INDICTMENT, - )} - accept={Object.values(fileExtensionWhitelist)} - header={formatMessage(strings.caseFiles.inputFieldLabel)} - buttonLabel={formatMessage(strings.caseFiles.buttonLabel)} - onChange={(files) => - handleUpload( - addUploadFiles(files, { - category: CaseFileCategory.INDICTMENT, - }), - updateUploadFile, - ) - } - onRemove={(file) => handleRemove(file, removeUploadFile)} - onRetry={(file) => handleRetry(file, updateUploadFile)} - /> - - )} { { /> {workingCase.hasCivilClaims && ( - + @@ -203,24 +155,18 @@ const CaseFiles = () => { /> )} - {isTrafficViolationCaseCheck && ( - - - - )} + + + handleNavigationTo(constants.INDICTMENTS_OVERVIEW_ROUTE) } diff --git a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Defendant/PoliceCaseInfo/PoliceCaseInfo.tsx b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Defendant/PoliceCaseInfo/PoliceCaseInfo.tsx index 0cb222be97c0..7601b4e95d23 100644 --- a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Defendant/PoliceCaseInfo/PoliceCaseInfo.tsx +++ b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Defendant/PoliceCaseInfo/PoliceCaseInfo.tsx @@ -71,7 +71,6 @@ export const PoliceCaseInfo: FC = ({ updatePoliceCase, policeCaseNumberImmutable = false, updateIndictmentCount, - indictmentCount, }) => { const { formatMessage } = useIntl() diff --git a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/Indictment.tsx b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/Indictment.tsx index a49b674b112d..d3d91a6e1ef5 100644 --- a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/Indictment.tsx +++ b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Indictment/Indictment.tsx @@ -40,7 +40,7 @@ import { useIndictmentCounts, useOnceOn, } from '@island.is/judicial-system-web/src/utils/hooks' -import { isTrafficViolationStepValidIndictments } from '@island.is/judicial-system-web/src/utils/validate' +import { isIndictmentStepValid } from '@island.is/judicial-system-web/src/utils/validate' import { usePoliceCaseInfoQuery } from '../Defendant/policeCaseInfo.generated' import { IndictmentCount } from './IndictmentCount' @@ -115,7 +115,7 @@ const Indictment = () => { }, }) - const stepIsValid = isTrafficViolationStepValidIndictments(workingCase) + const stepIsValid = isIndictmentStepValid(workingCase) const handleNavigationTo = useCallback( (destination: string) => router.push(`${destination}/${workingCase.id}`), diff --git a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx index 4ab0cce0a431..36556ce43092 100644 --- a/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx +++ b/apps/judicial-system/web/src/routes/Prosecutor/Indictments/Processing/Processing.tsx @@ -10,15 +10,10 @@ import { Text, } from '@island.is/island-ui/core' import * as constants from '@island.is/judicial-system/consts' -import { - Feature, - isTrafficViolationCase, -} from '@island.is/judicial-system/types' import { core, titles } from '@island.is/judicial-system-web/messages' import { BlueBox, CommentsInput, - FeatureContext, FormContentContainer, FormContext, FormFooter, @@ -69,7 +64,6 @@ const Processing: FC = () => { isCaseUpToDate, refreshCase, } = useContext(FormContext) - const { features } = useContext(FeatureContext) const { updateCase, transitionCase, setAndSendCaseToServer } = useCase() const { formatMessage } = useIntl() const { setAndSendDefendantToServer } = useDefendants() @@ -82,10 +76,6 @@ const Processing: FC = () => { } = useCivilClaimants() const router = useRouter() - // TODO: currently for e2e tests, this is failing locally due to this feature flag - const isTrafficViolationCaseCheck = - features.includes(Feature.MULTIPLE_INDICTMENT_SUBTYPES) || - isTrafficViolationCase(workingCase) const [civilClaimantNationalIdUpdate, setCivilClaimantNationalIdUpdate] = useState<{ nationalId: string | null; civilClaimantId: string }>() const [hasCivilClaimantChoice, setHasCivilClaimantChoice] = @@ -693,13 +683,7 @@ const Processing: FC = () => { nextButtonIcon="arrowForward" previousUrl={`${constants.INDICTMENTS_CASE_FILE_ROUTE}/${workingCase.id}`} nextIsDisabled={!stepIsValid} - onNextButtonClick={() => - handleNavigationTo( - isTrafficViolationCaseCheck - ? constants.INDICTMENTS_TRAFFIC_VIOLATION_ROUTE - : constants.INDICTMENTS_CASE_FILES_ROUTE, - ) - } + nextUrl={constants.INDICTMENTS_INDICTMENT_ROUTE} /> diff --git a/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx b/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx index 29cdaa3286de..eba84c6b13f3 100644 --- a/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx +++ b/apps/judicial-system/web/src/routes/Shared/Cases/ActiveCases.tsx @@ -17,10 +17,7 @@ import { DefendantInfo, } from '@island.is/judicial-system-web/src/components/Table' import Table from '@island.is/judicial-system-web/src/components/Table/Table' -import { - CaseListEntry, - Defendant, -} from '@island.is/judicial-system-web/src/graphql/schema' +import { CaseListEntry } from '@island.is/judicial-system-web/src/graphql/schema' interface Props { cases: CaseListEntry[] diff --git a/apps/judicial-system/web/src/utils/formHelper.ts b/apps/judicial-system/web/src/utils/formHelper.ts index 69a1f1eeb1ba..5d1b73f97de5 100644 --- a/apps/judicial-system/web/src/utils/formHelper.ts +++ b/apps/judicial-system/web/src/utils/formHelper.ts @@ -173,7 +173,7 @@ export type stepValidationsType = { [constants.INVESTIGATION_CASE_POLICE_CONFIRMATION_ROUTE]: () => boolean [constants.INDICTMENTS_CASE_FILE_ROUTE]: () => boolean [constants.INDICTMENTS_PROCESSING_ROUTE]: (theCase: Case) => boolean - [constants.INDICTMENTS_TRAFFIC_VIOLATION_ROUTE]: (theCase: Case) => boolean + [constants.INDICTMENTS_INDICTMENT_ROUTE]: (theCase: Case) => boolean [constants.INDICTMENTS_CASE_FILES_ROUTE]: (theCase: Case) => boolean [constants.RESTRICTION_CASE_RECEPTION_AND_ASSIGNMENT_ROUTE]: ( theCase: Case, @@ -255,10 +255,9 @@ export const stepValidations = (): stepValidationsType => { [constants.INDICTMENTS_CASE_FILE_ROUTE]: () => true, [constants.INDICTMENTS_PROCESSING_ROUTE]: (theCase: Case) => validations.isProcessingStepValidIndictments(theCase), - [constants.INDICTMENTS_TRAFFIC_VIOLATION_ROUTE]: (theCase: Case) => - validations.isTrafficViolationStepValidIndictments(theCase), - [constants.INDICTMENTS_CASE_FILES_ROUTE]: (theCase) => - validations.isCaseFilesStepValidIndictments(theCase), + [constants.INDICTMENTS_INDICTMENT_ROUTE]: (theCase: Case) => + validations.isIndictmentStepValid(theCase), + [constants.INDICTMENTS_CASE_FILES_ROUTE]: () => true, [constants.INDICTMENTS_SUMMARY_ROUTE]: () => true, [constants.RESTRICTION_CASE_RECEPTION_AND_ASSIGNMENT_ROUTE]: ( theCase: Case, diff --git a/apps/judicial-system/web/src/utils/hooks/useCaseList/index.tsx b/apps/judicial-system/web/src/utils/hooks/useCaseList/index.tsx index 6629594f8d5f..d6a9cbd03e2e 100644 --- a/apps/judicial-system/web/src/utils/hooks/useCaseList/index.tsx +++ b/apps/judicial-system/web/src/utils/hooks/useCaseList/index.tsx @@ -10,7 +10,6 @@ import { DEFENDER_ROUTE, } from '@island.is/judicial-system/consts' import { - Feature, isCompletedCase, isCourtOfAppealsUser, isDefenceUser, @@ -20,11 +19,9 @@ import { isPublicProsecutorUser, isRequestCase, isRestrictionCase, - isTrafficViolationCase, } from '@island.is/judicial-system/types' import { errors } from '@island.is/judicial-system-web/messages' import { - FeatureContext, FormContext, UserContext, } from '@island.is/judicial-system-web/src/components' @@ -42,7 +39,6 @@ const useCaseList = () => { >([null, false]) const { user, limitedAccess } = useContext(UserContext) const { getCase } = useContext(FormContext) - const { features } = useContext(FeatureContext) const { formatMessage } = useIntl() const { isTransitioningCase, isSendingNotification } = useCase() const router = useRouter() @@ -50,9 +46,6 @@ const useCaseList = () => { const openCase = useCallback( (caseToOpen: Case, openCaseInNewTab?: boolean) => { let routeTo = null - const isTrafficViolation = - features.includes(Feature.MULTIPLE_INDICTMENT_SUBTYPES) || - isTrafficViolationCase(caseToOpen) if (isDefenceUser(user)) { if (isRequestCase(caseToOpen.type)) { @@ -129,7 +122,7 @@ const useCaseList = () => { : constants.CLOSED_INDICTMENT_OVERVIEW_ROUTE } else { routeTo = findFirstInvalidStep( - constants.prosecutorIndictmentRoutes(isTrafficViolation), + constants.prosecutorIndictmentRoutes, caseToOpen, ) } @@ -142,7 +135,7 @@ const useCaseList = () => { router.push(`${routeTo}/${caseToOpen.id}`) } }, - [router, user, features], + [router, user], ) const handleOpenCase = useCallback( diff --git a/apps/judicial-system/web/src/utils/hooks/useSections/index.ts b/apps/judicial-system/web/src/utils/hooks/useSections/index.ts index 350595015b5f..17b76a2bf529 100644 --- a/apps/judicial-system/web/src/utils/hooks/useSections/index.ts +++ b/apps/judicial-system/web/src/utils/hooks/useSections/index.ts @@ -1,4 +1,3 @@ -import { useContext } from 'react' import { useIntl } from 'react-intl' import { useRouter } from 'next/router' @@ -8,7 +7,6 @@ import { getAppealResultTextByValue, } from '@island.is/judicial-system/formatters' import { - Feature, isCompletedCase, isCourtOfAppealsUser, isDefenceUser, @@ -17,10 +15,8 @@ import { isInvestigationCase, isProsecutionUser, isRestrictionCase, - isTrafficViolationCase, } from '@island.is/judicial-system/types' import { core, sections } from '@island.is/judicial-system-web/messages' -import { FeatureContext } from '@island.is/judicial-system-web/src/components' import { RouteSection } from '@island.is/judicial-system-web/src/components/PageLayout/PageLayout' import { formatCaseResult } from '@island.is/judicial-system-web/src/components/PageLayout/utils' import { @@ -63,7 +59,6 @@ const useSections = ( ) => { const { formatMessage } = useIntl() const router = useRouter() - const { features } = useContext(FeatureContext) const isActive = (pathname: string) => router.pathname.replace(/\/\[\w+\]/g, '') === pathname @@ -406,9 +401,6 @@ const useSections = ( state === CaseState.RECEIVED || state === CaseState.WAITING_FOR_CANCELLATION || router.pathname === `${constants.INDICTMENTS_ADD_FILES_ROUTE}/[id]` - const isTrafficViolation = - features.includes(Feature.MULTIPLE_INDICTMENT_SUBTYPES) || - isTrafficViolationCase(workingCase) return { name: formatMessage(sections.indictmentCaseProsecutorSection.title), @@ -505,39 +497,31 @@ const useSections = ( ) : undefined, }, - ...(isTrafficViolation - ? [ - { - name: formatMessage( - sections.indictmentCaseProsecutorSection.indictment, - ), - href: `${constants.INDICTMENTS_TRAFFIC_VIOLATION_ROUTE}/${id}`, - isActive: isActive( - constants.INDICTMENTS_TRAFFIC_VIOLATION_ROUTE, - ), - onClick: - !isActive( - constants.INDICTMENTS_TRAFFIC_VIOLATION_ROUTE, - ) && - validateFormStepper( - isValid, - [ - constants.INDICTMENTS_DEFENDANT_ROUTE, - constants.INDICTMENTS_POLICE_CASE_FILES_ROUTE, - constants.INDICTMENTS_CASE_FILE_ROUTE, - constants.INDICTMENTS_PROCESSING_ROUTE, - ], - workingCase, - ) && - onNavigationTo - ? async () => - await onNavigationTo( - constants.INDICTMENTS_TRAFFIC_VIOLATION_ROUTE, - ) - : undefined, - }, - ] - : []), + { + name: formatMessage( + sections.indictmentCaseProsecutorSection.indictment, + ), + href: `${constants.INDICTMENTS_INDICTMENT_ROUTE}/${id}`, + isActive: isActive(constants.INDICTMENTS_INDICTMENT_ROUTE), + onClick: + !isActive(constants.INDICTMENTS_INDICTMENT_ROUTE) && + validateFormStepper( + isValid, + [ + constants.INDICTMENTS_DEFENDANT_ROUTE, + constants.INDICTMENTS_POLICE_CASE_FILES_ROUTE, + constants.INDICTMENTS_CASE_FILE_ROUTE, + constants.INDICTMENTS_PROCESSING_ROUTE, + ], + workingCase, + ) && + onNavigationTo + ? async () => + await onNavigationTo( + constants.INDICTMENTS_INDICTMENT_ROUTE, + ) + : undefined, + }, { name: capitalize( formatMessage( diff --git a/apps/judicial-system/web/src/utils/validate.ts b/apps/judicial-system/web/src/utils/validate.ts index 0b84f181100c..f53773ba08a3 100644 --- a/apps/judicial-system/web/src/utils/validate.ts +++ b/apps/judicial-system/web/src/utils/validate.ts @@ -289,9 +289,7 @@ export const isProcessingStepValidIndictments = ( ) } -export const isTrafficViolationStepValidIndictments = ( - workingCase: Case, -): boolean => { +export const isIndictmentStepValid = (workingCase: Case): boolean => { const hasValidDemands = Boolean( workingCase.demands && (!workingCase.hasCivilClaims || workingCase.civilDemands), @@ -615,12 +613,3 @@ export const isCourtOfAppealWithdrawnCaseStepValid = ( [workingCase.appealCaseNumber, ['empty', 'appeal-case-number-format']], ]).isValid } - -export const isCaseFilesStepValidIndictments = (workingCase: Case): boolean => { - return Boolean( - isTrafficViolationCase(workingCase) || - workingCase.caseFiles?.some( - (file) => file.category === CaseFileCategory.INDICTMENT, - ), - ) -} diff --git a/charts/judicial-system/values.prod.yaml b/charts/judicial-system/values.prod.yaml index 5bb64cbc525e..76dc16ae71cb 100644 --- a/charts/judicial-system/values.prod.yaml +++ b/charts/judicial-system/values.prod.yaml @@ -30,7 +30,7 @@ judicial-system-api: BACKEND_URL: 'http://web-judicial-system-backend' CONTENTFUL_ENVIRONMENT: 'master' CONTENTFUL_HOST: 'cdn.contentful.com' - HIDDEN_FEATURES: 'MULTIPLE_INDICTMENT_SUBTYPES' + HIDDEN_FEATURES: '' IDENTITY_SERVER_ISSUER_URL: 'https://innskra.island.is' LOG_LEVEL: 'info' NODE_OPTIONS: '--max-old-space-size=460 -r dd-trace/init' diff --git a/charts/judicial-system/values.staging.yaml b/charts/judicial-system/values.staging.yaml index b0fcf242d102..18428d179bf4 100644 --- a/charts/judicial-system/values.staging.yaml +++ b/charts/judicial-system/values.staging.yaml @@ -30,7 +30,7 @@ judicial-system-api: BACKEND_URL: 'http://web-judicial-system-backend' CONTENTFUL_ENVIRONMENT: 'test' CONTENTFUL_HOST: 'cdn.contentful.com' - HIDDEN_FEATURES: 'MULTIPLE_INDICTMENT_SUBTYPES' + HIDDEN_FEATURES: '' IDENTITY_SERVER_ISSUER_URL: 'https://identity-server.staging01.devland.is' LOG_LEVEL: 'info' NODE_OPTIONS: '--max-old-space-size=460 -r dd-trace/init' diff --git a/charts/services/judicial-system-api/values.prod.yaml b/charts/services/judicial-system-api/values.prod.yaml index 05f04f9d7278..2143dcd8565b 100644 --- a/charts/services/judicial-system-api/values.prod.yaml +++ b/charts/services/judicial-system-api/values.prod.yaml @@ -30,7 +30,7 @@ env: BACKEND_URL: 'http://web-judicial-system-backend' CONTENTFUL_ENVIRONMENT: 'master' CONTENTFUL_HOST: 'cdn.contentful.com' - HIDDEN_FEATURES: 'MULTIPLE_INDICTMENT_SUBTYPES' + HIDDEN_FEATURES: '' IDENTITY_SERVER_ISSUER_URL: 'https://innskra.island.is' LOG_LEVEL: 'info' NODE_OPTIONS: '--max-old-space-size=460 -r dd-trace/init' diff --git a/charts/services/judicial-system-api/values.staging.yaml b/charts/services/judicial-system-api/values.staging.yaml index 8ec818a14e50..6ba09a9624d6 100644 --- a/charts/services/judicial-system-api/values.staging.yaml +++ b/charts/services/judicial-system-api/values.staging.yaml @@ -30,7 +30,7 @@ env: BACKEND_URL: 'http://web-judicial-system-backend' CONTENTFUL_ENVIRONMENT: 'test' CONTENTFUL_HOST: 'cdn.contentful.com' - HIDDEN_FEATURES: 'MULTIPLE_INDICTMENT_SUBTYPES' + HIDDEN_FEATURES: '' IDENTITY_SERVER_ISSUER_URL: 'https://identity-server.staging01.devland.is' LOG_LEVEL: 'info' NODE_OPTIONS: '--max-old-space-size=460 -r dd-trace/init' diff --git a/libs/judicial-system/consts/src/lib/consts.ts b/libs/judicial-system/consts/src/lib/consts.ts index 90c4c60196a0..f13bde76f864 100644 --- a/libs/judicial-system/consts/src/lib/consts.ts +++ b/libs/judicial-system/consts/src/lib/consts.ts @@ -188,7 +188,7 @@ export const INDICTMENTS_DEFENDANT_ROUTE = '/akaera/akaerdi' export const INDICTMENTS_POLICE_CASE_FILES_ROUTE = '/akaera/malsgogn' export const INDICTMENTS_CASE_FILE_ROUTE = '/akaera/skjalaskra' export const INDICTMENTS_PROCESSING_ROUTE = '/akaera/malsmedferd' -export const INDICTMENTS_TRAFFIC_VIOLATION_ROUTE = '/akaera/akaera' +export const INDICTMENTS_INDICTMENT_ROUTE = '/akaera/akaera' export const INDICTMENTS_CASE_FILES_ROUTE = '/akaera/domskjol' export const INDICTMENTS_OVERVIEW_ROUTE = '/akaera/stadfesta' export const CLOSED_INDICTMENT_OVERVIEW_ROUTE = '/akaera/yfirlit' @@ -225,12 +225,12 @@ export const prosecutorInvestigationCasesRoutes = [ INVESTIGATION_CASE_POLICE_CONFIRMATION_ROUTE, ] -export const prosecutorIndictmentRoutes = (isTrafficViolation: boolean) => [ +export const prosecutorIndictmentRoutes = [ INDICTMENTS_DEFENDANT_ROUTE, INDICTMENTS_POLICE_CASE_FILES_ROUTE, INDICTMENTS_CASE_FILE_ROUTE, INDICTMENTS_PROCESSING_ROUTE, - ...(isTrafficViolation ? [INDICTMENTS_TRAFFIC_VIOLATION_ROUTE] : []), + INDICTMENTS_INDICTMENT_ROUTE, INDICTMENTS_CASE_FILES_ROUTE, INDICTMENTS_OVERVIEW_ROUTE, ] diff --git a/libs/judicial-system/types/src/lib/case.ts b/libs/judicial-system/types/src/lib/case.ts index 25beea51adcf..a6761b6af97b 100644 --- a/libs/judicial-system/types/src/lib/case.ts +++ b/libs/judicial-system/types/src/lib/case.ts @@ -376,13 +376,7 @@ export const isTrafficViolationCase = (theCase: { indictmentSubtypes?: IndictmentSubtypeMap caseFiles?: { category?: CaseFileCategory | null }[] | null }): boolean => { - if ( - theCase.type !== CaseType.INDICTMENT || - !theCase.indictmentSubtypes || - theCase.caseFiles?.some( - (file) => file.category === CaseFileCategory.INDICTMENT, - ) - ) { + if (theCase.type !== CaseType.INDICTMENT || !theCase.indictmentSubtypes) { return false } diff --git a/libs/judicial-system/types/src/lib/feature.ts b/libs/judicial-system/types/src/lib/feature.ts index dd8f5e437a8f..742e56c2f145 100644 --- a/libs/judicial-system/types/src/lib/feature.ts +++ b/libs/judicial-system/types/src/lib/feature.ts @@ -1,4 +1,3 @@ export enum Feature { NONE = 'NONE', // must be at least one - MULTIPLE_INDICTMENT_SUBTYPES = 'MULTIPLE_INDICTMENT_SUBTYPES', } diff --git a/libs/judicial-system/types/src/lib/file.ts b/libs/judicial-system/types/src/lib/file.ts index 17b320bdfb52..6940ccb395db 100644 --- a/libs/judicial-system/types/src/lib/file.ts +++ b/libs/judicial-system/types/src/lib/file.ts @@ -7,7 +7,6 @@ export enum CaseFileState { export enum CaseFileCategory { COURT_RECORD = 'COURT_RECORD', RULING = 'RULING', - INDICTMENT = 'INDICTMENT', CRIMINAL_RECORD = 'CRIMINAL_RECORD', CRIMINAL_RECORD_UPDATE = 'CRIMINAL_RECORD_UPDATE', COST_BREAKDOWN = 'COST_BREAKDOWN',