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): Enable public prosecutors to properly handle fines #17023

Merged
merged 51 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0cd31c1
Checkpoint
oddsson Nov 5, 2024
e6b57b3
Merge branch 'main' of github.com:island-is/island.is into j-s/servic…
oddsson Nov 5, 2024
96aa96f
Refactor AlertMessage
oddsson Nov 5, 2024
d717322
Format date
oddsson Nov 6, 2024
80e2958
Cleanup
oddsson Nov 6, 2024
4c4c23e
Cleanup
oddsson Nov 6, 2024
f18cda6
Merge branch 'main' of github.com:island-is/island.is into j-s/servic…
oddsson Nov 6, 2024
f657160
Merge branch 'main' of github.com:island-is/island.is into j-s/servic…
oddsson Nov 7, 2024
04020c2
Merge branch 'j-s/service-announcement-defenders' of github.com:islan…
oddsson Nov 7, 2024
d98dbd0
Merge
oddsson Nov 7, 2024
d55a4a2
Merge branch 'main' of github.com:island-is/island.is into j-s/servic…
oddsson Nov 8, 2024
2deeef3
Add key
oddsson Nov 8, 2024
a0133c1
Refactor
oddsson Nov 8, 2024
9079a4c
Remove console.log
oddsson Nov 8, 2024
db83d4b
Merge branch 'main' of github.com:island-is/island.is into j-s/servic…
oddsson Nov 8, 2024
ae44420
Merge branch 'main' into j-s/service-announcement-defenders
kodiakhq[bot] Nov 8, 2024
b329584
Merge branch 'main' into j-s/service-announcement-defenders
gudjong Nov 8, 2024
76e228d
Merge branch 'main' of github.com:island-is/island.is
oddsson Nov 12, 2024
25d6e4b
Merge branch 'main' of github.com:island-is/island.is
oddsson Nov 18, 2024
19136d2
Merge
oddsson Nov 18, 2024
c520d1d
Merge
oddsson Nov 18, 2024
253d172
Merge branch 'main' of github.com:island-is/island.is
oddsson Nov 19, 2024
a318d19
Merge branch 'main' of github.com:island-is/island.is
oddsson Nov 19, 2024
7b47677
Merge branch 'main' of github.com:island-is/island.is
oddsson Nov 25, 2024
f0280c3
Add new BlueBox for FINES
oddsson Nov 25, 2024
08fe59d
Move code around
oddsson Nov 25, 2024
8b751ab
Add tests
oddsson Nov 25, 2024
4c98dfa
Merge branch 'main' of github.com:island-is/island.is into j-s/fine-r…
oddsson Nov 26, 2024
a70c87e
Fix tests
oddsson Nov 26, 2024
2b3c9df
Show appeal deadline in BlueBoxWithDate
oddsson Nov 26, 2024
626d3cb
Swap out words based on whether or not there is a fine
oddsson Nov 26, 2024
db41295
Swap out words based on whether or not there is a fine
oddsson Nov 26, 2024
c1cfe16
Show FINES to prison admins
oddsson Nov 26, 2024
dc3ea44
Revert island-ui changes
oddsson Nov 26, 2024
3784117
Cleanup
oddsson Nov 26, 2024
03d94ac
Cleanup
oddsson Nov 26, 2024
a5f776c
Merge branch 'main' of github.com:island-is/island.is into j-s/fine-r…
oddsson Nov 26, 2024
dcd0fa5
Fix tests
oddsson Nov 26, 2024
f619af5
Fix tests
oddsson Nov 26, 2024
c9ea77a
Add tests
oddsson Nov 26, 2024
c044079
Fix lint
oddsson Nov 26, 2024
1494993
Checkpoint
oddsson Nov 26, 2024
4c9aa5b
Fix dates
oddsson Nov 26, 2024
0a2483f
Fix dates
oddsson Nov 26, 2024
c594dbd
Fix texts
oddsson Nov 26, 2024
baf4a14
Add tests
oddsson Nov 26, 2024
1be9e83
Refactoring
oddsson Nov 26, 2024
d08d360
Refactoring
oddsson Nov 26, 2024
bf5a448
Merge branch 'main' into j-s/fine-refactoring
kodiakhq[bot] Nov 26, 2024
7bf1164
Use constants
oddsson Nov 26, 2024
38ae47e
Merge branch 'j-s/fine-refactoring' of github.com:island-is/island.is…
oddsson Nov 26, 2024
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 @@ -731,6 +731,30 @@ describe('getIndictmentInfo', () => {
indictmentVerdictAppealDeadlineExpired: false,
})
})

it('should return correct indictment info when the indictment ruling decision is FINE', () => {
const rulingDate = new Date().toISOString()
const defendants = [
{
serviceRequirement: ServiceRequirement.NOT_REQUIRED,
verdictViewDate: undefined,
} as Defendant,
]

const indictmentInfo = getIndictmentInfo(
CaseIndictmentRulingDecision.FINE,
rulingDate,
defendants,
)

expect(indictmentInfo).toEqual({
indictmentAppealDeadline: new Date(
new Date(rulingDate).setDate(new Date(rulingDate).getDate() + 3),
).toISOString(),
indictmentVerdictViewedByAll: true,
indictmentVerdictAppealDeadlineExpired: false,
})
})
})

describe('getIndictmentDefendantsInfo', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
CaseAppealDecision,
CaseIndictmentRulingDecision,
EventType,
FINE_APPEAL_WINDOW_DAYS,
getIndictmentVerdictAppealDeadlineStatus,
getStatementDeadline,
isRequestCase,
Expand Down Expand Up @@ -151,20 +152,26 @@ export const getIndictmentInfo = (
eventLog?: EventLog[],
): IndictmentInfo => {
const indictmentInfo: IndictmentInfo = {}
const isFine = rulingDecision === CaseIndictmentRulingDecision.FINE

if (!rulingDate) {
return indictmentInfo
}

const theRulingDate = new Date(rulingDate)
indictmentInfo.indictmentAppealDeadline = new Date(
theRulingDate.getTime() + getDays(VERDICT_APPEAL_WINDOW_DAYS),
theRulingDate.getTime() +
getDays(
rulingDecision === CaseIndictmentRulingDecision.FINE
? FINE_APPEAL_WINDOW_DAYS
: VERDICT_APPEAL_WINDOW_DAYS,
),
).toISOString()

const verdictInfo = defendants?.map<[boolean, Date | undefined]>(
(defendant) => [
rulingDecision === CaseIndictmentRulingDecision.RULING,
defendant.serviceRequirement === ServiceRequirement.NOT_REQUIRED
rulingDecision === CaseIndictmentRulingDecision.RULING || isFine,
defendant.serviceRequirement === ServiceRequirement.NOT_REQUIRED || isFine
? new Date()
: defendant.verdictViewDate
? new Date(defendant.verdictViewDate)
Expand All @@ -173,7 +180,7 @@ export const getIndictmentInfo = (
)

const [indictmentVerdictViewedByAll, indictmentVerdictAppealDeadlineExpired] =
getIndictmentVerdictAppealDeadlineStatus(verdictInfo)
getIndictmentVerdictAppealDeadlineStatus(verdictInfo, isFine)
indictmentInfo.indictmentVerdictViewedByAll = indictmentVerdictViewedByAll
indictmentInfo.indictmentVerdictAppealDeadlineExpired =
indictmentVerdictAppealDeadlineExpired
Expand All @@ -189,14 +196,19 @@ export const getIndictmentDefendantsInfo = (theCase: Case) => {
return theCase.defendants?.map((defendant) => {
const serviceRequired =
defendant.serviceRequirement === ServiceRequirement.REQUIRED
const isFine =
theCase.indictmentRulingDecision === CaseIndictmentRulingDecision.FINE

const { verdictViewDate } = defendant

const baseDate = serviceRequired ? verdictViewDate : theCase.rulingDate

const verdictAppealDeadline = baseDate
? new Date(
new Date(baseDate).getTime() + getDays(VERDICT_APPEAL_WINDOW_DAYS),
new Date(baseDate).getTime() +
getDays(
isFine ? FINE_APPEAL_WINDOW_DAYS : VERDICT_APPEAL_WINDOW_DAYS,
),
).toISOString()
: undefined

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ const canPrisonAdminUserAccessCase = (

// Check case indictment ruling decision access
if (
theCase.indictmentRulingDecision !== CaseIndictmentRulingDecision.RULING
theCase.indictmentRulingDecision !==
CaseIndictmentRulingDecision.RULING &&
theCase.indictmentRulingDecision !== CaseIndictmentRulingDecision.FINE
) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,12 @@ const getPrisonAdminUserCasesQueryFilter = (): WhereOptions => {
{
type: indictmentCases,
state: CaseState.COMPLETED,
indictment_ruling_decision: CaseIndictmentRulingDecision.RULING,
indictment_ruling_decision: {
[Op.or]: [
CaseIndictmentRulingDecision.RULING,
CaseIndictmentRulingDecision.FINE,
],
},
oddsson marked this conversation as resolved.
Show resolved Hide resolved
indictment_review_decision: IndictmentCaseReviewDecision.ACCEPT,
id: {
[Op.in]: Sequelize.literal(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,12 @@ describe('getCasesQueryFilter', () => {
{
type: indictmentCases,
state: CaseState.COMPLETED,
indictment_ruling_decision: CaseIndictmentRulingDecision.RULING,
indictment_ruling_decision: {
[Op.or]: [
CaseIndictmentRulingDecision.RULING,
CaseIndictmentRulingDecision.FINE,
],
},
indictment_review_decision: IndictmentCaseReviewDecision.ACCEPT,
id: {
[Op.in]: Sequelize.literal(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ describe.each(prisonSystemRoles)('prison admin user %s', (role) => {
(state) => {
const accessibleCaseIndictmentRulingDecisions = [
CaseIndictmentRulingDecision.RULING,
CaseIndictmentRulingDecision.FINE,
]

describe.each(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import faker from 'faker'
import { render, screen } from '@testing-library/react'

import {
CaseIndictmentRulingDecision,
CaseType,
Defendant,
} from '../../graphql/schema'
import { mockCase } from '../../utils/mocks'
import {
ApolloProviderWrapper,
FormContextWrapper,
IntlProviderWrapper,
} from '../../utils/testHelpers'
import BlueBoxWithDate from './BlueBoxWithDate'

jest.mock('next/router', () => ({
useRouter() {
return {
pathname: '',
query: {
id: 'test_id',
},
}
},
}))

describe('BlueBoxWithDate', () => {
const name = faker.name.firstName()
const rulingDate = new Date().toISOString()

const mockDefendant: Defendant = {
name,
id: faker.datatype.uuid(),
}

it('renders correctly when ruling decision is FINE', () => {
render(
<IntlProviderWrapper>
<ApolloProviderWrapper>
<FormContextWrapper
theCase={{
...mockCase(CaseType.INDICTMENT),
indictmentRulingDecision: CaseIndictmentRulingDecision.FINE,
defendants: [mockDefendant],
rulingDate,
}}
>
<BlueBoxWithDate defendant={mockDefendant} />
</FormContextWrapper>
</ApolloProviderWrapper>
</IntlProviderWrapper>,
)

expect(screen.getByText('Viðurlagaákvörðun')).toBeInTheDocument()
expect(screen.getByText(name)).toBeInTheDocument()
})
oddsson marked this conversation as resolved.
Show resolved Hide resolved

it('renders correctly when ruling decision is FINE', () => {
render(
<IntlProviderWrapper>
<ApolloProviderWrapper>
<FormContextWrapper
theCase={{
...mockCase(CaseType.INDICTMENT),
indictmentRulingDecision: CaseIndictmentRulingDecision.RULING,
defendants: [mockDefendant],
rulingDate,
}}
>
<BlueBoxWithDate defendant={mockDefendant} />
</FormContextWrapper>
</ApolloProviderWrapper>
</IntlProviderWrapper>,
)

expect(screen.getByText('Birting dóms')).toBeInTheDocument()
expect(screen.getByText(name)).toBeInTheDocument()
})
oddsson marked this conversation as resolved.
Show resolved Hide resolved
})
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,17 @@ export const strings = defineMessages({
description:
'Notaður sem texti í valmynd fyrir aðgerðina að senda mál til fullnustu',
},
indictmentRulingDecisionFine: {
id: 'judicial.system.core:blue_box_with_date.indictment_ruling_decision_fine',
defaultMessage: 'Viðurlagaákvörðun',
description:
'Notaður sem titill í svæði þar sem kærufrestur viðurlagaákvörðunar er tekinn fram',
},
fineAppealDeadline: {
id: 'judicial.system.core:blue_box_with_date.fine_appeal_deadline',
defaultMessage:
'Kærufrestur Ríkissaksóknara {appealDeadlineIsInThePast, select, true {er} other {var}} til {appealDeadline}',
description:
'Notaður sem titill í svæði þar sem kærufrestur viðurlagaákvörðunar er tekinn fram',
},
})
Loading
Loading