Skip to content

Commit

Permalink
Man 28 sentence license condition notes (#175)
Browse files Browse the repository at this point in the history
* MAN-28 - add licence conditions details to sentance page

* MAN-28 - add licence conditions details to sentance page

* MAN-28 - add licence conditions details to sentance page

* MAN-28 - add licence conditions details to sentance page

* MAN-28 - update after api refactor

* MAN-28 - update after api refactor

* MAN-28 - update after api refactor
  • Loading branch information
achimber-moj authored Oct 17, 2024
1 parent 4918ea8 commit 4a2758e
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 73 deletions.
15 changes: 15 additions & 0 deletions server/data/model/sentenceDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface Sentence {
requirements: Requirement[]
courtDocuments: CourtDocument[]
unpaidWorkProgress: string
licenceConditions: LicenceCondition[]
}
export interface OffenceDetails {
mainOffence: Offence
Expand Down Expand Up @@ -67,6 +68,20 @@ export interface CourtDocument {
documentName: string
}

export interface LicenceCondition {
mainDescription: string
subTypeDescription: string
imposedReleasedDate: string
actualStartDate: string
notes: LicenceConditionNote[]
}

export interface LicenceConditionNote {
createdBy: string
createdByDate: string
note: string
hasNotesBeenTruncated: boolean
}
export interface ProbationHistory {
numberOfTerminatedEvents: number
dateOfMostRecentTerminatedEvent: string
Expand Down
52 changes: 50 additions & 2 deletions server/views/pages/sentence.njk
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,50 @@
{% endfor %}
{% endset %}


{% set hasLicenceConditions = sentence.licenceConditions and sentence.licenceConditions.length > 0 %}

{% set notes = '' %}
{% set licenceConditions %}
{% for licenceCondition in sentence.licenceConditions %}
{% for lcNote in licenceCondition.notes %}
{% set notes %}
<p class="govuk-body">{{ lcNote.note }} </p><p class="govuk-body-s secondary-text">Comment added by {{ lcNote.createdBy }} on {{ lcNote.createdByDate | dateWithYear }}</p>
{% endset %}
{% else %}
{% set notes = 'No notes' %}
{% endfor %}
{% set licenceHtml %}
{{ govukSummaryList({
rows: [
{
key: { text: 'Subtype' },
value: { text: licenceCondition.subTypeDescription }
} if licenceCondition.subTypeDescription,
{
key: { text: 'Imposed (Release) date' },
value: { text: licenceCondition.imposedReleasedDate | dateWithYear }
},
{
key: { text: 'Actual Start date' },
value: { text: licenceCondition.actualStartDate | dateWithYear }
} if licenceCondition.actualStartDate,
{
key: { text: 'Notes' },
value: { html: notes }
} if licenceCondition.notes
]
}) }}
{% endset %}
{{ govukDetails({
classes: 'govuk-!-margin-bottom-1',
summaryText: licenceCondition.mainDescription,
html: licenceHtml
}) }}
{% endfor %}
{% endset %}


{% set hasRequirements = sentence.requirements and sentence.requirements.length > 0 %}
{% set requirements %}
{% for requirement in sentence.requirements %}
Expand Down Expand Up @@ -230,10 +274,14 @@
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: "Licence Conditions" },
value: { html: licenceConditions}
} if hasLicenceConditions,
{
key: { text: "Requirements" },
value: { html: '<span data-qa="requirementsValue">' + requirements if hasRequirements else 'No requirements' + '</span>'}
},
value: { html: '<span data-qa="requirementsValue">' + requirements + '</span>'}
} if hasRequirements,
{
key: { text: "Unpaid Work Progress" },
value: { html: '<span data-qa="unpaidWorkProgress">' + sentence.unpaidWorkProgress + '</span>' }
Expand Down
109 changes: 73 additions & 36 deletions wiremock/mappings/X000001-sentence.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,7 @@
"endDate": "2025-03-19",
"startDate": "2024-03-19"
},
"requirements": [
{
"code": "F",
"actualStartDate": "2024-04-12",
"description": "12 days RAR, 1 completed",
"length": 12,
"notes": "my notes",
"rar": {
"completed": 1,
"scheduled": 11,
"totalDays": 12
}
},
{
"code": "RM49",
"expectedStartDate": "2024-01-07",
"actualStartDate": "2024-01-12",
"expectedEndDate": "2024-03-10",
"actualEndDate": "2024-01-09",
"terminationReason": "Expired (Normal)",
"description": "Curfew (Electronic Monitored)",
"length": "10",
"lengthUnitValue": "Hours",
"notes": "curfew notes"
},
{
"code": "W",
"actualStartDate": "2015-05-22",
"description": "Unpaid Work - Regular",
"length": 100,
"lengthUnitValue": "Hours",
"notes": "unpaid work notes"
}
],
"requirements": [],
"courtDocuments": [
{
"id": "4d74f43c-5b42-4317-852e-56c7d29b610b",
Expand All @@ -105,7 +72,41 @@
"documentName": "Previous convictions"
}
],
"unpaidWorkProgress": "7 minutes completed (of 100 hours)"
"licenceConditions": [
{
"mainDescription": "Alcohol Monitoring (Electronic Monitoring)",
"subTypeDescription": "You must not drink any alcohol until [END DATE].",
"imposedReleasedDate": "2024-12-25",
"actualStartDate": "2024-12-26",
"notes": [
{
"createdBy": "Jon Jones",
"createdByDate": "2024-08-21",
"note": "You must not drink any alcohol until [END DATE]. You will need to wear an electronic tag all the time so we can check this",
"hasNotesBeenTruncated": true
}
]
},
{
"mainDescription": "Residence at a specific place",
"subTypeDescription": "Bespoke Condition (See Notes)",
"imposedReleasedDate": "2024-10-03",
"actualStartDate": "2023-11-15",
"notes": [
{
"createdBy": "Mark Smith",
"createdByDate": "2023-10-04",
"note": "James must reside at his parent's house in Scotland for the duration of his release on licence.",
"hasNotesBeenTruncated": false
}
]
},
{
"mainDescription": "Licence - Prohibited Activity",
"imposedReleasedDate": "2023-09-26",
"notes": []
}
]
},
{
"offenceDetails": {
Expand All @@ -127,7 +128,43 @@
"endDate": "2025-01-31",
"startDate": "2024-02-01"
},
"requirements": []
"requirements": [
{
"code": "F",
"actualStartDate": "2024-04-12",
"description": "12 days RAR, 1 completed",
"length": 12,
"notes": "my notes",
"rar": {
"completed": 1,
"scheduled": 11,
"totalDays": 12
}
},
{
"code": "RM49",
"expectedStartDate": "2024-01-07",
"actualStartDate": "2024-01-12",
"expectedEndDate": "2024-03-10",
"actualEndDate": "2024-01-09",
"terminationReason": "Expired (Normal)",
"description": "Curfew (Electronic Monitored)",
"length": "10",
"lengthUnitValue": "Hours",
"notes": "curfew notes"
},
{
"code": "W",
"actualStartDate": "2015-05-22",
"description": "Unpaid Work - Regular",
"length": 100,
"lengthUnitValue": "Hours",
"notes": "unpaid work notes"
}
],
"courtDocuments": [],
"unpaidWorkProgress": "3 minutes completed (of 12 hours)",
"licenceConditions": []
}
],
"probationHistory": {
Expand Down
38 changes: 3 additions & 35 deletions wiremock/mappings/X778160-sentence.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,40 +50,7 @@
"endDate": "2025-03-19",
"startDate": "2024-03-19"
},
"requirements": [
{
"code": "F",
"actualStartDate": "2024-04-12",
"description": "12 days RAR, 1 completed",
"length": 12,
"notes": "my notes",
"rar": {
"completed": 1,
"scheduled": 11,
"totalDays": 12
}
},
{
"code": "RM49",
"expectedStartDate": "2024-01-07",
"actualStartDate": "2024-01-12",
"expectedEndDate": "2024-03-10",
"actualEndDate": "2024-01-09",
"terminationReason": "Expired (Normal)",
"description": "Curfew (Electronic Monitored)",
"length": "10",
"lengthUnitValue": "Hours",
"notes": "curfew notes"
},
{
"code": "W",
"actualStartDate": "2015-05-22",
"description": "Unpaid Work - Regular",
"length": 100,
"lengthUnitValue": "Hours",
"notes": "unpaid work notes"
}
],
"requirements": [],
"courtDocuments": [
{
"id": "4d74f43c-5b42-4317-852e-56c7d29b610b",
Expand All @@ -101,7 +68,8 @@
"documentName": "Previous convictions"
}
],
"unpaidWorkProgress": "7 minutes completed (of 100 hours)"
"unpaidWorkProgress": "7 minutes completed (of 100 hours)",
"licenceConditions": []
}
],
"probationHistory": {
Expand Down

0 comments on commit 4a2758e

Please sign in to comment.