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

Feature/pi 1998 mas sentence card #35

Merged
merged 3 commits into from
Apr 3, 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
6 changes: 6 additions & 0 deletions integration_tests/e2e/sentence.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ context('Sentence', () => {
page.getCardHeader('offence').should('have.length', 2)
page.getCardHeader('conviction').should('contain.text', 'Conviction')
page.getCardHeader('conviction').should('have.length', 2)
page.getCardHeader('sentence').should('contain.text', 'Sentence')
page.getCardHeader('sentence').should('have.length', 2)

page.getRowDataIndex('offence', 'mainOffence', 'Value', 0).should('contain.text', 'Murder (3 count)')
page.getRowDataIndex('offence', 'mainOffence', 'Value', 1).should('contain.text', 'Another Murder (1 count)')
Expand All @@ -33,5 +35,9 @@ context('Sentence', () => {
page.getRowDataIndex('conviction', 'sentencingCourt', 'Value', 0).should('contain.text', 'Hull Court')
page.getRowDataIndex('conviction', 'responsibleCourt', 'Value', 0).should('contain.text', 'Birmingham Court')
page.getRowDataIndex('conviction', 'convictionDate', 'Value', 0).should('contain.text', 'Hull Court')

page.getRowDataIndex('sentence', 'orderDescription', 'Value', 0).should('contain.text', 'Default Sentence Type')
page.getRowDataIndex('sentence', 'orderStartDate', 'Value', 0).should('contain.text', '19 March 2024')
page.getRowDataIndex('sentence', 'orderEndDate', 'Value', 0).should('contain.text', '19 March 2025')
})
})
21 changes: 21 additions & 0 deletions server/data/model/sentenceDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
export interface SentenceDetails {
crn: string
sentences: Sentence[]
order: Order
requirements: Requirement[]
}

export interface Sentence {
Expand All @@ -28,3 +30,22 @@ export interface Offence {
code: string
description: string
}

export interface Order {
description: string
length: string
startDate: string
}

export interface Requirement {
description: string
codeDescription: string
length: string
rar: Rar
}

export interface Rar {
completed: string
scheduled: string
totalDays: string
}
66 changes: 65 additions & 1 deletion server/views/pages/sentence.njk
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,35 @@
{% endfor %}
{% endset %}

{% set hasRequirements = sentence.requirements and sentence.requirements.length > 0 %}
{% set requirements %}
{% for requirement in sentence.requirements %}
{% set requirementHtml %}
{{ govukSummaryList({
rows: [
{
key: { text: 'Length' },
value: { text: requirement.rar.totalDays + ' days'}
},
{
key: { text: 'Progress' },
value: { text: requirement.rar.completed + ' days'}
},
{
key: { text: 'Progress' },
value: { text: requirement.notes}
}
]
}) }}
{% endset %}
{{ govukDetails({
classes: 'govuk-!-margin-bottom-1',
summaryText: requirement.rar.totalDays + ' days RAR, ' + requirement.rar.completed + ' completed',
html: requirementHtml
}) }}
{% endfor %}
{% endset %}

{% set offence %}
{{ govukSummaryList({
rows: [
Expand Down Expand Up @@ -105,7 +134,7 @@
},
{
key: { text: "Conviction date" },
value: { html: '<span data-qa="convictionDateValue">' + sentence.conviction.convictionDate | nl2br if sentence.conviction.responsibleCourt | dateWithYear else 'No conviction date' + '</span>'}
value: { html: '<span data-qa="convictionDateValue">' + sentence.conviction.convictionDate | dateWithYear | nl2br if sentence.conviction.convictionDate else 'No conviction date' + '</span>'}
},
{
key: { text: "Additional sentences" },
Expand All @@ -115,6 +144,34 @@
}) }}
{% endset %}

{% set sentence %}
{{ govukSummaryList({
rows: [
{
key: { text: "Order" },
value: { html: '<span data-qa="orderDescriptionValue">' + sentence.order.description | nl2br if sentence.order.description else 'No order details' + '</span>' }
},
{
key: { text: "Start date" },
value: { html: '<span data-qa="orderStartDateValue">' + sentence.order.startDate | dateWithYear | nl2br if sentence.order.startDate else 'No start date details' + '</span>' }
},
{
key: { text: "End date" },
value: { html: '<span data-qa="orderEndDateValue">' + sentence.order.endDate | dateWithYear | nl2br if sentence.order.endDate else 'No end date details' + '</span>' }
},
{
key: { text: "Time elapsed" },
value: { html: '<span data-qa="orderTimeElapsedValue">' + sentence.order.startDate | monthsOrDaysElapsed + ' (of ' + sentence.order.length + ' months)' | nl2br if sentence.order.startDate else 'No details' + '</span>' }
},
{
key: { text: "Requirements" },
value: { html: '<span data-qa="requirementsValue">' + requirements if hasRequirements else 'No requirements' + '</span>'}
}
]
}) }}
{% endset %}


{{ appSummaryCard({
attributes: {'data-qa': 'offenceCard'},
titleText: 'Offence',
Expand All @@ -128,6 +185,13 @@
classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title',
html: conviction
}) }}

{{ appSummaryCard({
attributes: {'data-qa': 'sentenceCard'},
titleText: 'Sentence',
classes: 'govuk-!-margin-bottom-6 app-summary-card--large-title',
html: sentence
}) }}
{%- endfor %}
{% endblock %}

Expand Down
24 changes: 22 additions & 2 deletions wiremock/mappings/X000001-sentence.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,26 @@
"description": "Disqualified from Driving"
}
]
}
},
"order": {
"description": "Default Sentence Type",
"length": 12,
"endDate": "2025-03-19",
"startDate": "2024-03-19"
},
"requirements": [
{
"description": "Main",
"codeDescription": "High Intensity",
"length": 12,
"notes": "my notes",
"rar": {
"completed": 1,
"scheduled": 0,
"totalDays": 1
}
}
]
},
{
"offenceDetails": {
Expand All @@ -59,7 +78,8 @@
},
"conviction": {
"additionalSentences": []
}
},
"requirements": []
}
]
},
Expand Down