diff --git a/app/controllers/licences.controller.js b/app/controllers/licences.controller.js index 639deb98de..87ec725237 100644 --- a/app/controllers/licences.controller.js +++ b/app/controllers/licences.controller.js @@ -15,6 +15,7 @@ const ViewLicenceCommunicationsService = require('../services/licences/view-lice const ViewLicenceContactDetailsService = require('../services/licences/view-licence-contact-details.service.js') const ViewLicenceContactsService = require('../services/licences/view-licence-contacts.service.js') const ViewLicenceHistoryService = require('../services/licences/view-licence-history.service.js') +const ViewLicencePurposesService = require('../services/licences/view-licence-purposes.service.js') const ViewLicenceReturnsService = require('../services/licences/view-licence-returns.service.js') const ViewLicenceSetUpService = require('../services/licences/view-licence-set-up.service.js') const ViewLicenceSummaryService = require('../services/licences/view-licence-summary.service.js') @@ -122,6 +123,16 @@ async function viewLicenceContacts (request, h) { }) } +async function viewLicencePurposes (request, h) { + const { id: licenceId } = request.params + + const pageData = await ViewLicencePurposesService.go(licenceId) + + return h.view('licences/purposes.njk', { + ...pageData + }) +} + async function viewHistory (request, h) { const { params: { id }, auth } = request @@ -174,6 +185,7 @@ module.exports = { viewLicenceContacts, viewHistory, viewLicenceContactDetails, + viewLicencePurposes, viewReturns, viewSetUp, viewSummary diff --git a/app/presenters/licences/view-licence-purposes.presenter.js b/app/presenters/licences/view-licence-purposes.presenter.js new file mode 100644 index 0000000000..4933197bc1 --- /dev/null +++ b/app/presenters/licences/view-licence-purposes.presenter.js @@ -0,0 +1,83 @@ +'use strict' + +/** + * Formats the licence purposes data for the view licence purposes page + * @module ViewLicencePurposesPresenter + */ + +const { formatAbstractionPeriod } = require('../base.presenter.js') + +/** + * Formats the licence purposes data for the view licence purposes page + * + * @param {module:LicenceModel} licence - The licence and related licenceVersionPurposes data returned by + * `FetchLicencePurposesService` + * + * @returns {object} licence and licenceVersionPurposes data needed by the view template + */ +function go (licence) { + return { + id: licence.id, + licenceRef: licence.licenceRef, + licencePurposes: _formatLicencePurposes(licence.licenceVersions[0].licenceVersionPurposes), + pageTitle: 'Licence purpose details' + } +} + +function _formatLicencePurposes (licenceVersionPurposes) { + return licenceVersionPurposes.map((licenceVersionPurpose) => { + return { + abstractionAmounts: _formatAbstractionAmounts(licenceVersionPurpose), + abstractionPeriod: _abstractionPeriod(licenceVersionPurpose), + abstractionPoints: _formatAbstractionPoints(licenceVersionPurpose.points), + purposeDescription: licenceVersionPurpose.purpose.description ? licenceVersionPurpose.purpose.description : '' + } + }) +} + +function _abstractionPeriod (licenceVersionPurpose) { + const startDay = licenceVersionPurpose.abstractionPeriodStartDay + const startMonth = licenceVersionPurpose.abstractionPeriodStartMonth + const endDay = licenceVersionPurpose.abstractionPeriodEndDay + const endMonth = licenceVersionPurpose.abstractionPeriodEndMonth + + return formatAbstractionPeriod(startDay, startMonth, endDay, endMonth) +} + +function _formatAbstractionPoints (points) { + return points.map((point) => { + return point.$describe() + }) +} + +function _formatAbstractionAmounts (licenceVersionPurpose) { + const details = [] + + if (!licenceVersionPurpose) { + return details + } + + const { annualQuantity, dailyQuantity, hourlyQuantity, instantQuantity } = licenceVersionPurpose + + if (annualQuantity) { + details.push(`${parseFloat(annualQuantity).toFixed(2)} cubic metres per year`) + } + + if (dailyQuantity) { + details.push(`${parseFloat(dailyQuantity).toFixed(2)} cubic metres per day`) + } + + if (hourlyQuantity) { + details.push(`${parseFloat(hourlyQuantity).toFixed(2)} cubic metres per hour`) + } + + if (instantQuantity) { + details.push(`${parseFloat(instantQuantity).toFixed(2)} cubic metres per second (Instantaneous Quantity)`) + } + + return details +} + +module.exports = { + go +} diff --git a/app/routes/licence.routes.js b/app/routes/licence.routes.js index 005ae38ef6..303f0bde2e 100644 --- a/app/routes/licence.routes.js +++ b/app/routes/licence.routes.js @@ -42,6 +42,13 @@ const routes = [ } } }, + { + method: 'GET', + path: '/licences/{id}/purposes', + options: { + handler: LicencesController.viewLicencePurposes + } + }, { method: 'GET', path: '/licences/{id}/set-up', diff --git a/app/services/licences/fetch-licence-purposes.service.js b/app/services/licences/fetch-licence-purposes.service.js new file mode 100644 index 0000000000..aad1de2bb0 --- /dev/null +++ b/app/services/licences/fetch-licence-purposes.service.js @@ -0,0 +1,74 @@ +'use strict' + +/** + * Fetches the licence purposes needed for the view monitoring-station page + * @module FetchLicencePurposesService + */ + +const LicenceModel = require('../../models/licence.model.js') + +/** + * Fetches the licence purposes needed for the view monitoring-station page + * + * @param {string} licenceId - The UUID of the licence + * + * @returns {Promise} the licence and related licence purposes data needed for the view licence + * purposes page + */ +async function go (licenceId) { + return _fetchLicencePurposes(licenceId) +} + +async function _fetchLicencePurposes (licenceId) { + return LicenceModel.query() + .findById(licenceId) + .select([ + 'id', + 'licenceRef' + ]) + .modify('currentVersion') + .withGraphFetched('licenceVersions.licenceVersionPurposes') + .modifyGraph('licenceVersions.licenceVersionPurposes', (builder) => { + builder.select([ + 'abstractionPeriodStartDay', + 'abstractionPeriodStartMonth', + 'abstractionPeriodEndDay', + 'abstractionPeriodEndMonth', + 'annualQuantity', + 'dailyQuantity', + 'hourlyQuantity', + 'instantQuantity' + ]) + .orderBy('licenceVersionPurposes.createdAt', 'asc') + }) + .withGraphFetched('licenceVersions.licenceVersionPurposes.points') + .modifyGraph('licenceVersions.licenceVersionPurposes.points', (builder) => { + builder.select([ + 'points.description', + 'points.id', + 'points.ngr1', + 'points.ngr2', + 'points.ngr3', + 'points.ngr4' + ]) + .orderBy('points.externalId', 'asc') + }) + .withGraphFetched('licenceVersions.licenceVersionPurposes.points.source') + .modifyGraph('licenceVersions.licenceVersionPurposes.points.source', (builder) => { + builder.select([ + 'sources.description', + 'sources.id' + ]) + }) + .withGraphFetched('licenceVersions.licenceVersionPurposes.purpose') + .modifyGraph('licenceVersions.licenceVersionPurposes.purpose', (builder) => { + builder.select([ + 'id', + 'description' + ]) + }) +} + +module.exports = { + go +} diff --git a/app/services/licences/view-licence-purposes.service.js b/app/services/licences/view-licence-purposes.service.js new file mode 100644 index 0000000000..b1f830d698 --- /dev/null +++ b/app/services/licences/view-licence-purposes.service.js @@ -0,0 +1,30 @@ +'use strict' + +/** + * Orchestrates fetching and presenting the data needed for the licence purposes page + * @module ViewLicencePurposesService + */ + +const FetchLicencePurposesService = require('../licences/fetch-licence-purposes.service.js') +const ViewLicencePurposesPresenter = require('../../presenters/licences/view-licence-purposes.presenter.js') + +/** + * Orchestrates fetching and presenting the data needed for the licence purposes page + * + * @param {string} licenceId - The UUID of the licence + * + * @returns {Promise} an object representing the `pageData` needed by the licence purposes template + */ +async function go (licenceId) { + const licencePurposes = await FetchLicencePurposesService.go(licenceId) + + const pageData = ViewLicencePurposesPresenter.go(licencePurposes) + + return { + ...pageData + } +} + +module.exports = { + go +} diff --git a/app/views/licences/purposes.njk b/app/views/licences/purposes.njk new file mode 100644 index 0000000000..2494b9561b --- /dev/null +++ b/app/views/licences/purposes.njk @@ -0,0 +1,105 @@ +{% extends 'layout.njk' %} +{% from "govuk/components/back-link/macro.njk" import govukBackLink %} +{% from "govuk/components/details/macro.njk" import govukDetails %} +{% from "govuk/components/table/macro.njk" import govukTable %} + +{% macro abstractionPointCell(array, purposeDescription) %} + {% set abstractionPoints %} + {% for item in array %} + {% if loop.last %} +
{{ item }}
+ {% else %} +
{{ item }}
+
+ {% endif %} + {% endfor %} + {% endset %} + + {% if array.length > 5 %} + {{ govukDetails({ + summaryText: "View your " + array.length + " abstraction points for " + purposeDescription | lower, + html: abstractionPoints | safe, + classes: "govuk-!-margin-bottom-0" + }) }} + {% else %} + {{ abstractionPoints | safe }} + {% endif %} +{% endmacro %} + +{% block breadcrumbs %} + {{ govukBackLink({ + text: 'Go back to summary', + href: '/system/licences/' + id + '/summary' + }) }} +{% endblock %} + +{% block content %} +

+ Licence {{ licenceRef }} + {{ pageTitle }} +

+ + {% for licencePurpose in licencePurposes %} + {# Set an easier to use index. #} + {% set rowIndex = loop.index0 %} + + {% set tableRows = [] %} + + {# Abstraction points cell #} + {% if licencePurpose.abstractionPoints.length > 1 %} + {% set abstractionPointRowTitle = 'Abstraction points' %} + {% else %} + {% set abstractionPointRowTitle = 'Abstraction point' %} + {% endif %} + + {% set abstractionPointsRow = [ + { + text: abstractionPointRowTitle, + attributes: { 'data-test': 'abstraction-point-title-' + rowIndex }, + classes: "govuk-!-width-one-third" + }, + { + html: abstractionPointCell(licencePurpose.abstractionPoints, licencePurpose.purposeDescription), + attributes: { 'data-test': 'abstraction-points-' + rowIndex } + } + ] %} + + {% set tableRows = (tableRows.push(abstractionPointsRow), tableRows) %} + + {# Period of abstraction cell #} + {% set abstractionPeriodRow = [ + { + text: 'Period of abstraction', + attributes: { 'data-test': 'abstraction-period-title-' + rowIndex } + }, + { + text: licencePurpose.abstractionPeriod, + attributes: { 'data-test': 'abstraction-period-' + rowIndex } + } + ] %} + + {% set tableRows = (tableRows.push(abstractionPeriodRow), tableRows) %} + + {# Abstraction amount cell #} + {% for abstractionAmount in licencePurpose.abstractionAmounts %} + {% set abstractionPeriodRow = [ + { + text: 'Abstraction amount', + attributes: { 'data-test': 'abstraction-amount-title-' + rowIndex } + }, + { + text: abstractionAmount, + attributes: { 'data-test': 'abstraction-amount-' + rowIndex } + } + ] %} + + {% set tableRows = (tableRows.push(abstractionPeriodRow), tableRows) %} + {% endfor %} + + {{ govukTable({ + caption: licencePurpose.purposeDescription, + captionClasses: "govuk-table__caption--m govuk-!-padding-bottom-3 govuk-!-margin-bottom-0 govuk-section-break govuk-section-break--visible", + rows: tableRows + }) }} + {% endfor %} +{% endblock %} diff --git a/test/controllers/licences.controller.test.js b/test/controllers/licences.controller.test.js index 3803892f1a..8c5188079e 100644 --- a/test/controllers/licences.controller.test.js +++ b/test/controllers/licences.controller.test.js @@ -23,6 +23,7 @@ const ViewLicenceCommunicationsService = require('../../app/services/licences/vi const ViewLicenceContactsService = require('../../app/services/licences/view-licence-contacts.service.js') const ViewLicenceContactDetailsService = require('../../app/services/licences/view-licence-contact-details.service.js') const ViewLicenceHistoryService = require('../../app/services/licences/view-licence-history.service.js') +const ViewLicencePurposesService = require('../../app/services/licences/view-licence-purposes.service.js') const ViewLicenceReturnsService = require('../../app/services/licences/view-licence-returns.service.js') const ViewLicenceSetUpService = require('../../app/services/licences/view-licence-set-up.service.js') const ViewLicenceSummaryService = require('../../app/services/licences/view-licence-summary.service.js') @@ -248,6 +249,34 @@ describe('Licences controller', () => { }) }) + describe('/licences/{id}/purposes', () => { + describe('GET', () => { + beforeEach(async () => { + options = { + method: 'GET', + url: '/licences/7861814c-ca19-43f2-be11-3c612f0d744b/purposes', + auth: { + strategy: 'session', + credentials: { scope: [] } + } + } + }) + + describe('when a request is valid', () => { + beforeEach(async () => { + Sinon.stub(ViewLicencePurposesService, 'go').resolves(_viewLicencePurposes()) + }) + + it('returns the page successfully', async () => { + const response = await server.inject(options) + + expect(response.statusCode).to.equal(200) + expect(response.payload).to.contain('Licence purpose details') + }) + }) + }) + }) + describe('/licences/{id}/returns-required', () => { describe('GET', () => { const session = { id: '1c265420-6a5e-4a4c-94e4-196d7799ed01' } @@ -590,6 +619,28 @@ function _viewLicenceContactDetails () { } } +function _viewLicencePurposes () { + return { + id: '5ca7bf18-d433-491c-ac83-483f67ee7d93', + licenceRef: '01/140/R01', + licencePurposes: [ + { + abstractionAmounts: [ + '165000.00 cubic metres per year', + '10920.00 cubic metres per day', + '455.00 cubic metres per hour' + ], + abstractionPeriod: '1 November to 31 March', + abstractionPoints: [ + 'At National Grid Reference TQ 78392 78004 (LIPWELL STREAM POINT A)' + ], + purposeDescription: 'Transfer Between Sources (Pre Water Act 2003)' + } + ], + pageTitle: 'Licence purpose details' + } +} + function _viewLicenceReturns () { const commonLicenceData = _viewLicence() diff --git a/test/presenters/licences/view-licence-purposes.presenter.test.js b/test/presenters/licences/view-licence-purposes.presenter.test.js new file mode 100644 index 0000000000..00e51c5634 --- /dev/null +++ b/test/presenters/licences/view-licence-purposes.presenter.test.js @@ -0,0 +1,176 @@ +'use strict' + +// Test framework dependencies +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') + +const { describe, it, beforeEach } = exports.lab = Lab.script() +const { expect } = Code + +// Test helpers +const LicenceModel = require('../../../app/models/licence.model.js') + +// Thing under test +const ViewLicencePurposePresenter = require('../../../app/presenters/licences/view-licence-purposes.presenter.js') + +describe('View Licence Purpose presenter', () => { + let licence + + beforeEach(() => { + licence = _testLicence() + }) + + describe('when provided with populated licence purposes', () => { + it('returns the expected licence purpose details', () => { + const result = ViewLicencePurposePresenter.go(licence) + + expect(result).to.equal({ + id: '761bc44f-80d5-49ae-ab46-0a90495417b5', + licencePurposes: [ + { + 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 (Instantaneous Quantity)' + ], + abstractionPeriod: '1 April to 31 October', + abstractionPoints: [ + 'At National Grid Reference TL 23198 88603' + ], + purposeDescription: 'Spray Irrigation - Storage' + } + ], + licenceRef: '01/123', + pageTitle: 'Licence purpose details' + }) + }) + }) + + describe('the "licencePurposes" property', () => { + describe('the "abstractionAmounts" property', () => { + describe('when the licence does not have populated annual, daily, hourly and per second abstraction quantity fields', () => { + beforeEach(() => { + licence.licenceVersions[0].licenceVersionPurposes[0].annualQuantity = null + licence.licenceVersions[0].licenceVersionPurposes[0].dailyQuantity = null + licence.licenceVersions[0].licenceVersionPurposes[0].hourlyQuantity = null + licence.licenceVersions[0].licenceVersionPurposes[0].instantQuantity = null + }) + + it('returns an empty array', () => { + const result = ViewLicencePurposePresenter.go(licence) + + expect(result.licencePurposes[0].abstractionAmounts).to.equal([]) + }) + }) + + describe('when the licence has a related licenceVersionPurpose with populated annual, daily, hourly and per second abstraction quantity fields', () => { + it('returns an array of abstraction amounts for each populated time frame', () => { + const result = ViewLicencePurposePresenter.go(licence) + + expect(result.licencePurposes[0].abstractionAmounts).to.equal([ + '180000.00 cubic metres per year', + '720.00 cubic metres per day', + '144.00 cubic metres per hour', + '40.00 cubic metres per second (Instantaneous Quantity)' + ]) + }) + }) + }) + + describe('the "abstractionPeriod" property', () => { + describe('when the licence has a related licenceVersionPurpose with populated abstraction period fields', () => { + it('returns the licenceVersionPurposes abstraction period', () => { + const result = ViewLicencePurposePresenter.go(licence) + + expect(result.licencePurposes[0].abstractionPeriod).to.equal('1 April to 31 October') + }) + }) + }) + + describe('the "abstractionPoints" property', () => { + describe('when the licence does not have related points', () => { + beforeEach(() => { + licence.licenceVersions[0].licenceVersionPurposes[0].points = [] + }) + + it('returns an empty array for the abstraction points', () => { + const result = ViewLicencePurposePresenter.go(licence) + + expect(result.licencePurposes[0].abstractionPoints).to.equal([]) + }) + }) + + describe('when the licence has related points', () => { + it('returns the related points, formatted as an array of strings', () => { + const result = ViewLicencePurposePresenter.go(licence) + + expect(result.licencePurposes[0].abstractionPoints).to.equal(['At National Grid Reference TL 23198 88603']) + }) + }) + }) + + describe('the "purposeDescription"', () => { + describe('when the licence does not have a related purpose description', () => { + beforeEach(() => { + licence.licenceVersions[0].licenceVersionPurposes[0].purpose.description = null + }) + + it('returns the an empty array', () => { + const result = ViewLicencePurposePresenter.go(licence) + + expect(result.licencePurposes[0].purposeDescription).equal('') + }) + }) + + describe('when the licence has a related purpose with a populated description field', () => { + it('returns the purpose description', () => { + const result = ViewLicencePurposePresenter.go(licence) + + expect(result.licencePurposes[0].purposeDescription).equal('Spray Irrigation - Storage') + }) + }) + }) + }) +}) + +function _testLicence () { + return LicenceModel.fromJson({ + id: '761bc44f-80d5-49ae-ab46-0a90495417b5', + licenceRef: '01/123', + licenceVersions: [{ + createdAt: new Date('2022-06-05'), + id: '4c42fd78-6e68-4eaa-9c88-781c323a5a38', + reason: 'new-licence', + status: 'current', + startDate: new Date('2022-04-01'), + licenceVersionPurposes: [{ + id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 10, + annualQuantity: 180000, + dailyQuantity: 720, + hourlyQuantity: 144, + instantQuantity: 40, + purpose: { + id: '0316229a-e76d-4785-bc2c-65075a1a8f50', + description: 'Spray Irrigation - Storage' + }, + points: [{ + id: 'ab80acd6-7c2a-4f51-87f5-2c397829a0bb', + description: null, + ngr1: 'TL 23198 88603', + ngr2: null, + ngr3: null, + ngr4: null, + source: { + id: 'b0b12db5-e95c-44a7-8008-2389fdbba9db', + description: 'SURFACE WATER SOURCE OF SUPPLY' + } + }] + }] + }] + }) +} diff --git a/test/services/licences/fetch-licence-purposes.service.test.js b/test/services/licences/fetch-licence-purposes.service.test.js new file mode 100644 index 0000000000..695ce09881 --- /dev/null +++ b/test/services/licences/fetch-licence-purposes.service.test.js @@ -0,0 +1,95 @@ +'use strict' + +// Test framework dependencies +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') + +const { describe, it, before } = exports.lab = Lab.script() +const { expect } = Code + +// Test helpers +const LicenceHelper = require('../../support/helpers/licence.helper.js') +const LicenceVersionHelper = require('../../support/helpers/licence-version.helper.js') +const LicenceVersionPurposeHelper = require('../../support/helpers/licence-version-purpose.helper.js') +const LicenceVersionPurposePointHelper = require('../../support/helpers/licence-version-purpose-point.helper.js') +const PointHelper = require('../../support/helpers/point.helper.js') +const PurposeHelper = require('../../support/helpers/purpose.helper.js') +const SourceHelper = require('../../support/helpers/source.helper.js') + +// Thing under test +const FetchLicencePurposesService = require('../../../app/services/licences/fetch-licence-purposes.service.js') + +describe('Fetch Licence Purposes service', () => { + let licence + let licenceVersion + let licenceVersionPurpose + let point + let purpose + let source + + describe('when the licence has licence versions, licence version purposes, points, purposes, and sources', () => { + before(async () => { + licence = await LicenceHelper.add() + + licenceVersion = await LicenceVersionHelper.add({ licenceId: licence.id }) + + purpose = await PurposeHelper.select() + + licenceVersionPurpose = await LicenceVersionPurposeHelper.add({ + licenceVersionId: licenceVersion.id, + purposeId: purpose.id + }) + + source = await SourceHelper.select() + point = await PointHelper.add({ sourceId: source.id }) + + await LicenceVersionPurposePointHelper.add({ + licenceVersionPurposeId: licenceVersionPurpose.id, + pointId: point.id + }) + }) + + it('returns the matching licence versions, licence version purposes, points, purposes, and sources', async () => { + const result = await FetchLicencePurposesService.go(licence.id) + + expect(result).to.equal({ + id: licence.id, + licenceRef: licence.licenceRef, + licenceVersions: [ + { + id: licenceVersion.id, + startDate: licenceVersion.startDate, + status: 'current', + licenceVersionPurposes: [{ + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3, + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 1, + annualQuantity: null, + dailyQuantity: null, + hourlyQuantity: null, + instantQuantity: null, + points: [ + { + description: point.description, + id: point.id, + ngr1: point.ngr1, + ngr2: null, + ngr3: null, + ngr4: null, + source: { + description: source.description, + id: source.id + } + } + ], + purpose: { + description: purpose.description, + id: purpose.id + } + }] + }] + }) + }) + }) +}) diff --git a/test/services/licences/view-licence-purposes.service.test.js b/test/services/licences/view-licence-purposes.service.test.js new file mode 100644 index 0000000000..a2eb9a0bdd --- /dev/null +++ b/test/services/licences/view-licence-purposes.service.test.js @@ -0,0 +1,92 @@ +'use strict' + +// Test framework dependencies +const Lab = require('@hapi/lab') +const Code = require('@hapi/code') +const Sinon = require('sinon') + +const { describe, it, beforeEach } = exports.lab = Lab.script() +const { expect } = Code + +// Test helpers +const LicenceModel = require('../../../app/models/licence.model.js') + +// Things we need to stub +const FetchLicencePurposesService = require('../../../app/services/licences/fetch-licence-purposes.service.js') + +// Thing under test +const ViewLicencePurposesService = require('../../../app/services/licences/view-licence-purposes.service.js') + +describe('View Licence Purposes service', () => { + beforeEach(() => { + Sinon.stub(FetchLicencePurposesService, 'go').returns(_testFetchLicencePurposes()) + }) + + describe('when a licence with a matching ID exists', () => { + it('correctly presents the data', async () => { + const result = await ViewLicencePurposesService.go('761bc44f-80d5-49ae-ab46-0a90495417b5') + + expect(result).to.equal({ + id: '761bc44f-80d5-49ae-ab46-0a90495417b5', + licencePurposes: [ + { + 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 (Instantaneous Quantity)' + ], + abstractionPeriod: '1 April to 31 October', + abstractionPoints: [ + 'At National Grid Reference TL 23198 88603' + ], + purposeDescription: 'Spray Irrigation - Storage' + } + ], + licenceRef: '01/123', + pageTitle: 'Licence purpose details' + }) + }) + }) +}) + +function _testFetchLicencePurposes () { + return LicenceModel.fromJson({ + id: '761bc44f-80d5-49ae-ab46-0a90495417b5', + licenceRef: '01/123', + licenceVersions: [{ + createdAt: new Date('2022-06-05'), + id: '4c42fd78-6e68-4eaa-9c88-781c323a5a38', + reason: 'new-licence', + status: 'current', + startDate: new Date('2022-04-01'), + licenceVersionPurposes: [{ + id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 10, + annualQuantity: 180000, + dailyQuantity: 720, + hourlyQuantity: 144, + instantQuantity: 40, + purpose: { + id: '0316229a-e76d-4785-bc2c-65075a1a8f50', + description: 'Spray Irrigation - Storage' + }, + points: [{ + id: 'ab80acd6-7c2a-4f51-87f5-2c397829a0bb', + description: null, + ngr1: 'TL 23198 88603', + ngr2: null, + ngr3: null, + ngr4: null, + source: { + id: 'b0b12db5-e95c-44a7-8008-2389fdbba9db', + description: 'SURFACE WATER SOURCE OF SUPPLY' + } + }] + }] + }] + }) +}