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

feat(j-s): Civil Demands #16010

Merged
merged 6 commits into from
Sep 16, 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 @@ -6,12 +6,7 @@ import { Inject, Injectable } from '@nestjs/common'
import { type ConfigType } from '@island.is/nest/config'
import { ProblemError } from '@island.is/nest/problem'

import {
CommentType,
DateType,
type User,
UserRole,
} from '@island.is/judicial-system/types'
import { DateType, type User, UserRole } from '@island.is/judicial-system/types'

import {
Case,
Expand Down Expand Up @@ -144,7 +139,6 @@ export class BackendService extends DataSource<{ req: Request }> {
private caseTransformer<Case>(data: unknown): Case {
const theCase = data as Case & {
dateLogs?: { dateType: DateType; date: string }[]
explanatoryComments?: { commentType: CommentType; comment: string }[]
}

return {
Expand All @@ -155,11 +149,6 @@ export class BackendService extends DataSource<{ req: Request }> {
courtDate: theCase.dateLogs?.find(
(dateLog) => dateLog.dateType === DateType.COURT_DATE,
),
postponedIndefinitelyExplanation: theCase.explanatoryComments?.find(
(comment) =>
comment.commentType ===
CommentType.POSTPONED_INDEFINITELY_EXPLANATION,
)?.comment,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,4 +506,9 @@ export class UpdateCaseInput {
@IsOptional()
@Field(() => ID, { nullable: true })
readonly mergeCaseId?: string

@Allow()
@IsOptional()
@Field(() => String, { nullable: true })
readonly civilDemands?: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,7 @@ export class Case {

@Field(() => [Case], { nullable: true })
readonly mergedCases?: Case[]

@Field(() => String, { nullable: true })
readonly civilDemands?: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict'
gudjong marked this conversation as resolved.
Show resolved Hide resolved

module.exports = {
async up(queryInterface) {
return queryInterface.sequelize.transaction(async (transaction) =>
queryInterface
.renameTable('explanatory_comment', 'case_string', {
transaction,
})
.then(() =>
Promise.all([
queryInterface.renameColumn(
'case_string',
'comment_type',
'string_type',
{ transaction },
),
queryInterface.renameColumn('case_string', 'comment', 'value', {
transaction,
}),
]),
),
)
},

async down(queryInterface) {
return queryInterface.sequelize.transaction(async (transaction) =>
queryInterface
.renameTable('case_string', 'explanatory_comment', {
transaction,
})
.then(() =>
Promise.all([
queryInterface.renameColumn(
'explanatory_comment',
'string_type',
'comment_type',
{ transaction },
),
queryInterface.renameColumn(
'explanatory_comment',
'value',
'comment',
{ transaction },
),
]),
),
)
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { formatDate, lowercase } from '@island.is/judicial-system/formatters'
import { nowFactory } from '../factories'
import { indictment } from '../messages'
import { Case } from '../modules/case'
import { CaseString } from '../modules/case/models/caseString.model'
import {
addEmptyLines,
addGiganticHeading,
Expand Down Expand Up @@ -69,18 +70,15 @@ export const createIndictment = async (

doc.on('data', (chunk) => sinc.push(chunk))

const title = formatMessage(indictment.title)
const heading = formatMessage(indictment.heading)

setTitle(doc, title)
setTitle(doc, formatMessage(indictment.title))

if (confirmation) {
addIndictmentConfirmation(doc, confirmation)
}

addEmptyLines(doc, 6, doc.page.margins.left)

addGiganticHeading(doc, heading, 'Times-Roman')
addGiganticHeading(doc, formatMessage(indictment.heading), 'Times-Roman')
addNormalPlusText(doc, ' ')
setLineCap(2)
addNormalPlusText(doc, theCase.indictmentIntroduction ?? '')
Expand All @@ -103,6 +101,15 @@ export const createIndictment = async (

addEmptyLines(doc, 2)
addNormalPlusJustifiedText(doc, theCase.demands ?? '')

const civilDemands = CaseString.civilDemands(theCase.caseStrings)

if (civilDemands) {
addEmptyLines(doc, 2)
addNormalPlusText(doc, formatMessage(indictment.civilDemandsHeading))
addNormalPlusJustifiedText(doc, civilDemands)
}

addEmptyLines(doc, 2)
addNormalPlusCenteredText(
doc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ export const indictment = defineMessages({
defaultMessage: 'ÁKÆRA',
description: 'Notaður sem heading á ákæru PDF',
},
civilDemandsHeading: {
id: 'judicial.system.backend:pdf.indictment.civil_demands_heading',
defaultMessage: 'Einkaréttarkrafa:',
description: 'Notaður sem titill á einkaréttarkröfu í ákæru PDF',
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ import {
prosecutorUpdateRule,
publicProsecutorStaffUpdateRule,
} from './guards/rolesRules'
import {
CaseInterceptor,
CasesInterceptor,
} from './interceptors/case.interceptor'
import { CaseListInterceptor } from './interceptors/caseList.interceptor'
import { CompletedAppealAccessedInterceptor } from './interceptors/completedAppealAccessed.interceptor'
import { Case } from './models/case.model'
Expand Down Expand Up @@ -140,6 +144,7 @@ export class CaseController {

@UseGuards(JwtAuthGuard, RolesGuard)
@RolesRules(prosecutorRule, prosecutorRepresentativeRule)
@UseInterceptors(CaseInterceptor)
@Post('case')
@ApiCreatedResponse({ type: Case, description: 'Creates a new case' })
async create(
Expand Down Expand Up @@ -167,6 +172,7 @@ export class CaseController {
courtOfAppealsAssistantUpdateRule,
publicProsecutorStaffUpdateRule,
)
@UseInterceptors(CaseInterceptor)
@Patch('case/:caseId')
@ApiOkResponse({ type: Case, description: 'Updates an existing case' })
async update(
Expand Down Expand Up @@ -284,6 +290,7 @@ export class CaseController {
courtOfAppealsRegistrarTransitionRule,
courtOfAppealsAssistantTransitionRule,
)
@UseInterceptors(CaseInterceptor)
@Patch('case/:caseId/state')
@ApiOkResponse({
type: Case,
Expand Down Expand Up @@ -438,13 +445,13 @@ export class CaseController {
prisonSystemStaffRule,
defenderRule,
)
@UseInterceptors(CaseListInterceptor)
@Get('cases')
@ApiOkResponse({
type: Case,
isArray: true,
description: 'Gets all existing cases',
})
@UseInterceptors(CaseListInterceptor)
getAll(@CurrentHttpUser() user: User): Promise<Case[]> {
this.logger.debug('Getting all cases')

Expand All @@ -463,9 +470,9 @@ export class CaseController {
courtOfAppealsRegistrarRule,
courtOfAppealsAssistantRule,
)
@UseInterceptors(CompletedAppealAccessedInterceptor, CaseInterceptor)
@Get('case/:caseId')
@ApiOkResponse({ type: Case, description: 'Gets an existing case' })
@UseInterceptors(CompletedAppealAccessedInterceptor)
getById(@Param('caseId') caseId: string, @CurrentCase() theCase: Case): Case {
this.logger.debug(`Getting case ${caseId} by id`)

Expand All @@ -478,6 +485,7 @@ export class CaseController {
districtCourtRegistrarRule,
districtCourtAssistantRule,
)
@UseInterceptors(CasesInterceptor)
@Get('case/:caseId/connectedCases')
@ApiOkResponse({ type: [Case], description: 'Gets all connected cases' })
async getConnectedCases(
Expand Down Expand Up @@ -872,6 +880,7 @@ export class CaseController {
CaseReadGuard,
)
@RolesRules(prosecutorRule)
@UseInterceptors(CaseInterceptor)
@Post('case/:caseId/extend')
@ApiCreatedResponse({
type: Case,
Expand Down Expand Up @@ -901,6 +910,7 @@ export class CaseController {
districtCourtRegistrarRule,
districtCourtAssistantRule,
)
@UseInterceptors(CaseInterceptor)
@Post('case/:caseId/court')
@ApiCreatedResponse({
type: Case,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
} from '../index'
import { Case } from './models/case.model'
import { CaseArchive } from './models/caseArchive.model'
import { CaseString } from './models/caseString.model'
import { DateLog } from './models/dateLog.model'
import { ExplanatoryComment } from './models/explanatoryComment.model'
import { CaseController } from './case.controller'
import { CaseService } from './case.service'
import { InternalCaseController } from './internalCase.controller'
Expand All @@ -43,12 +43,7 @@ import { PdfService } from './pdf.service'
forwardRef(() => EventModule),
forwardRef(() => PoliceModule),
forwardRef(() => EventLogModule),
SequelizeModule.forFeature([
Case,
CaseArchive,
DateLog,
ExplanatoryComment,
]),
SequelizeModule.forFeature([Case, CaseArchive, DateLog, CaseString]),
],
providers: [
CaseService,
Expand Down
Loading
Loading