Skip to content

Commit

Permalink
Display msg for multiple abs amounts in view (#1153)
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WATER-4333

> Part of the work to replace the legacy view licence page

When we first built our version of the view licence page's summary tab, we applied the same logic when it came to a licence with multiple purposes: don't display abstraction amounts!

This is because the amounts could be different across the purposes and you can't just sum them. It is possible that the total amount of abstraction might be different on the licence when compared to the sum of its purposes (welcome to water abstraction!)

The old logic therefore hid the field. But we know anecdotally some users say you cannot see abstraction amounts in WRLS because of this behaviour.

So, in this change, when a licence has multiple purposes, we'll instead show a message and a link to the screen that shows the amounts for each purpose. Where a licence has one purpose, we'll continue to display the amounts.
  • Loading branch information
Cruikshanks authored Jul 2, 2024
1 parent 3f687db commit 306aeaa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
3 changes: 2 additions & 1 deletion app/presenters/licences/view-licence-summary.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function go (licence) {
licenceId: id,
monitoringStations: _monitoringStations(licenceGaugingStations),
purposes,
purposesCount: licenceVersionPurposes ? licenceVersionPurposes.length : 0,
region: region.displayName,
sourceOfSupply: points[0]?.point_source?.NAME ?? null,
startDate: formatLongDate(startDate)
Expand All @@ -58,7 +59,7 @@ function go (licence) {
function _abstractionAmounts (licenceVersionPurposes) {
const details = []

if (!licenceVersionPurposes) {
if (!licenceVersionPurposes || licenceVersionPurposes.length > 1) {
return details
}

Expand Down
17 changes: 11 additions & 6 deletions app/views/licences/tabs/summary.njk
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,20 @@
</div>
{% endif %}

{% if abstractionAmounts.length > 0 %}
{% if purposesCount > 0 %}
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">Abstraction amounts</dt>
<dd class="govuk-summary-list__value">
<ul class="govuk-list govuk-!-margin-bottom-0">
{% for quantity in abstractionAmounts %}
<li>{{ quantity }}</li>
{% endfor %}
</ul>
{% if purposesCount > 1 %}
<div>Multiple abstractions</div>
<a href="/licences/{{ documentId }}/purposes">View details of the amounts</a>
{% else %}
<ul class="govuk-list govuk-!-margin-bottom-0">
{% for quantity in abstractionAmounts %}
<li>{{ quantity }}</li>
{% endfor %}
</ul>
{% endif %}
</dd>
</div>
{% endif %}
Expand Down
18 changes: 11 additions & 7 deletions test/presenters/licences/view-licence-summary.presenter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ describe('View Licence Summary presenter', () => {
const result = ViewLicenceSummaryPresenter.go(licence)

expect(result).to.equal({
abstractionAmounts: [
'180000.00 cubic metres per year',
'720.00 cubic metres per day',
'144.00 cubic metres per hour',
'40.00 cubic metres per second'
],
abstractionAmounts: [],
abstractionConditions: ['Derogation clause', 'General conditions', 'Non standard quantities'],
abstractionPeriods: ['1 April to 31 October', '1 November to 31 March'],
abstractionPeriodsAndPurposesLinkText: 'View details of your purposes, periods and amounts',
Expand All @@ -51,6 +46,7 @@ describe('View Licence Summary presenter', () => {
caption: 'Purposes',
data: ['Spray Irrigation - Storage', 'Spray Irrigation - Direct']
},
purposesCount: 3,
region: 'Avalon',
sourceOfSupply: 'SURFACE WATER SOURCE OF SUPPLY',
startDate: '1 April 2019'
Expand All @@ -71,7 +67,7 @@ describe('View Licence Summary presenter', () => {
})
})

describe('when the there is at least one licence version purpose', () => {
describe('when the there is one licence version purpose', () => {
beforeEach(() => {
licence.licenceVersions[0].licenceVersionPurposes = [{
id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4',
Expand Down Expand Up @@ -152,6 +148,14 @@ describe('View Licence Summary presenter', () => {
})
})
})

describe('when the there are multiple licence version purposes', () => {
it('returns an empty array', () => {
const result = ViewLicenceSummaryPresenter.go(licence)

expect(result.abstractionAmounts).to.be.empty()
})
})
})

describe('the "abstractionConditions" property', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('View Licence Summary service', () => {
}],
licenceName: 'fake licence',
purposes: null,
purposesCount: 0,
region: 'Avalon',
sourceOfSupply: 'SURFACE WATER SOURCE OF SUPPLY',
startDate: '1 April 2019'
Expand Down

0 comments on commit 306aeaa

Please sign in to comment.