Skip to content

Commit

Permalink
chore(j-s): Add institution addresses to db (#15886)
Browse files Browse the repository at this point in the history
* chore(j-s): Add institution addresses to db

* chore(j-s): Use institution from db for subpoena

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
unakb and kodiakhq[bot] authored Sep 4, 2024
1 parent 42fef4d commit 2af2801
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict'

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('institution', 'address', {
type: Sequelize.STRING,
allowNull: true,
})

const institutionsToUpdate = [
{
name: 'Héraðsdómur Reykjavíkur',
address: 'Dómhúsið við Lækjartorg, Reykjavík',
},
{ name: 'Héraðsdómur Reykjaness', address: 'Fjarðargata 9, Hafnarfirði' },
{
name: 'Héraðsdómur Vesturlands',
address: 'Bjarnarbraut 8, Borgarnesi',
},
{ name: 'Héraðsdómur Vestfjarða', address: 'Hafnarstræti 9, Ísafirði' },
{
name: 'Héraðsdómur Norðurlands vestra',
address: 'Skagfirðingabraut 21, Sauðárkróki',
},
{
name: 'Héraðsdómur Norðurlands eystra',
address: 'Hafnarstræti 107, 4. hæð, Akureyri',
},
{ name: 'Héraðsdómur Austurlands', address: 'Lyngás 15, Egilsstöðum' },
{ name: 'Héraðsdómur Suðurlands', address: 'Austurvegur 4, Selfossi' },
]

await queryInterface.sequelize.transaction(async (transaction) => {
for (const institution of institutionsToUpdate) {
await queryInterface.bulkUpdate(
'institution',
{ address: institution.address },
{ name: institution.name },
{ transaction },
)
}
})
},

down: async (queryInterface) => {
await queryInterface.removeColumn('institution', 'address')
},
}
24 changes: 1 addition & 23 deletions apps/judicial-system/backend/src/app/formatters/subpoenaPdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@ import {
setTitle,
} from './pdfHelpers'

type DistrictCourts =
| 'Héraðsdómur Reykjavíkur'
| 'Héraðsdómur Reykjaness'
| 'Héraðsdómur Vesturlands'
| 'Héraðsdómur Vestfjarða'
| 'Héraðsdómur Norðurlands vestra'
| 'Héraðsdómur Norðurlands eystra'
| 'Héraðsdómur Austurlands'
| 'Héraðsdómur Suðurlands'

// TODO: Move to databas
const DistrictCourtLocation: Record<DistrictCourts, string> = {
'Héraðsdómur Reykjavíkur': 'Dómhúsið við Lækjartorg, Reykjavík',
'Héraðsdómur Reykjaness': 'Fjarðargata 9, Hafnarfirði',
'Héraðsdómur Vesturlands': 'Bjarnarbraut 8, Borgarnesi',
'Héraðsdómur Vestfjarða': 'Hafnarstræti 9, Ísafirði',
'Héraðsdómur Norðurlands vestra': 'Skagfirðingabraut 21, Sauðárkróki',
'Héraðsdómur Norðurlands eystra': 'Hafnarstræti 107, 4. hæð, Akureyri',
'Héraðsdómur Austurlands': 'Lyngás 15, Egilsstöðum',
'Héraðsdómur Suðurlands': 'Austurvegur 4, Selfossi',
}

export const createSubpoena = (
theCase: Case,
defendant: Defendant,
Expand Down Expand Up @@ -86,7 +64,7 @@ export const createSubpoena = (
if (theCase.court?.name) {
addNormalText(
doc,
DistrictCourtLocation[theCase.court.name as DistrictCourts],
theCase.court.address || 'Ekki skráð', // the latter shouldn't happen, if it does we have an problem with the court data
'Times-Roman',
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ export class Institution extends Model {
@Column({ type: DataType.STRING, allowNull: true })
@ApiPropertyOptional({ type: String })
nationalId?: string

@Column({ type: DataType.STRING, allowNull: true })
@ApiPropertyOptional({ type: String })
address?: string
}

0 comments on commit 2af2801

Please sign in to comment.