diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index bd63584d70..0000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,97 +0,0 @@ -'use strict' - -module.exports = { - extends: 'standard', // Maintain Standard.js rules - ignorePatterns: ['docs/*'], - overrides: [ - { - files: ['*.controller.js', '*.seed.js'], - rules: { - 'jsdoc/require-jsdoc': 'off' - } - } - ], - parserOptions: { - sourceType: 'script' - }, - plugins: [ - '@stylistic/js', - 'jsdoc' - ], - rules: { - '@stylistic/js/arrow-parens': ['error', 'always'], - '@stylistic/js/implicit-arrow-linebreak': ['off'], - '@stylistic/js/max-len': ['error', { - code: 120, - ignoreStrings: true, - ignoreTemplateLiterals: true, - ignoreUrls: true - }], - '@stylistic/js/padding-line-between-statements': [ - 'error', - { blankLine: 'always', prev: '*', next: 'block' }, - { blankLine: 'always', prev: '*', next: 'return' }, - { blankLine: 'always', prev: 'block', next: '*' }, - { blankLine: 'always', prev: 'block', next: 'function' }, - { blankLine: 'always', prev: 'function', next: '*' }, - // blank lines after every sequence of variable declarations - { blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' }, - { blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] }, - // blank lines after all directive prologues e.g. 'use strict' - { blankLine: 'always', prev: 'directive', next: '*' }, - { blankLine: 'any', prev: 'directive', next: 'directive' } - ], - 'arrow-body-style': ['error', 'always'], - 'import/extensions': ['error', 'always'], - strict: ['error', 'global'], - 'jsdoc/require-jsdoc': ['error', { - publicOnly: true - }], - 'jsdoc/require-description': 'error', - 'jsdoc/require-param': ['error', { - exemptedBy: ['private'] - }], - 'jsdoc/require-returns': ['error', { - publicOnly: true - }], - 'jsdoc/check-tag-names': 'error', - 'jsdoc/check-alignment': 'error', - 'jsdoc/newline-after-description': 'off', // does not work with 'use strict' - 'jsdoc/check-indentation': 'error', - 'jsdoc/lines-before-block': 'error', - 'jsdoc/check-types': 'error', - 'jsdoc/require-hyphen-before-param-description': 'error' - }, - settings: { - jsdoc: { - mode: 'jsdoc', - ignorePrivate: true - } - } -} - -/* - -This is the code to enforce agreed conventions - -npm packages needed - - "eslint-plugin-require-sort": "^1.3.0", - "eslint-plugin-sort-keys": "^2.3.5", - -module.exports = { - extends: 'standard', // Maintain Standard.js rules - // ignorePatterns: ['test/*'], // we can ignore patterns to allow to gradually enforce lints - plugins: ['sort-keys', 'require-sort'], - rules: { - 'func-style': ['error', 'declaration'], - 'max-len': ['error', { - code: 120 - }], - 'require-sort/require-sort': 'error', - 'sort-keys': [ - 'error', 'asc', { caseSensitive: false } - ] - } -} - -*/ diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 49a505fb37..6d9aa5b2a1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,14 +3,14 @@ version: 2 updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 - versioning-strategy: lockfile-only -- package-ecosystem: "github-actions" - # Workflow files stored in the default location of `.github/workflows` - directory: "/" - schedule: - interval: "daily" + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + open-pull-requests-limit: 10 + versioning-strategy: lockfile-only + - package-ecosystem: 'github-actions' + # Workflow files stored in the default location of `.github/workflows` + directory: '/' + schedule: + interval: 'daily' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb240fc4fd..200bf1775c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonarcloud analysis + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonarcloud analysis # Before we do anything, check we haven't accidentally left any `describe.only()` or `it.only(` statements in the # tests @@ -85,7 +85,7 @@ jobs: - name: Install Node uses: actions/setup-node@v4 with: - node-version-file: ".nvmrc" + node-version-file: '.nvmrc' # Speeds up workflows by reading the node modules from cache. Obviously you need to run it at least once, and the # cache will be updated should the package-lock.json file change diff --git a/.jsdoc.js b/.jsdoc.js index 5fe797d705..582b64f4cd 100644 --- a/.jsdoc.js +++ b/.jsdoc.js @@ -1,4 +1,3 @@ - 'use strict' module.exports = { diff --git a/.labrc.js b/.labrc.js index 78bb21ba9e..51224466e6 100644 --- a/.labrc.js +++ b/.labrc.js @@ -11,13 +11,40 @@ module.exports = { // of globals to ignore to be a single comma-delimited string; for ease of management we define them in an array then // join them. globals: [ - '__extends', '__assign', '__rest', '__decorate', '__param', '__metadata', '__awaiter', '__generator', - '__exportStar', '__createBinding', '__values', '__read', '__spread', '__spreadArrays', '__spreadArray', '__await', - '__asyncGenerator', '__asyncDelegator', '__asyncValues', '__makeTemplateObject', '__importStar', '__importDefault', - '__classPrivateFieldGet', '__classPrivateFieldSet', '__esDecorate', '__runInitializers', '__propKey', - '__setFunctionName', '__classPrivateFieldIn', '__addDisposableResource', '__disposeResources', + '__extends', + '__assign', + '__rest', + '__decorate', + '__param', + '__metadata', + '__awaiter', + '__generator', + '__exportStar', + '__createBinding', + '__values', + '__read', + '__spread', + '__spreadArrays', + '__spreadArray', + '__await', + '__asyncGenerator', + '__asyncDelegator', + '__asyncValues', + '__makeTemplateObject', + '__importStar', + '__importDefault', + '__classPrivateFieldGet', + '__classPrivateFieldSet', + '__esDecorate', + '__runInitializers', + '__propKey', + '__setFunctionName', + '__classPrivateFieldIn', + '__addDisposableResource', + '__disposeResources', // We also ignore globals exposed by global-agent: - 'GLOBAL_AGENT', 'ROARR', + 'GLOBAL_AGENT', + 'ROARR', // GlobalNotifier is added by us a global in a server plugin. It's how we make logging available anywhere in the app // whilst avoiding having to pass it around 'GlobalNotifier', diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..e83a20677a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "none", + "printWidth": 120 +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ce2e2d1ad..2053072b46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Exclude VOID returns from two-part tariff billing [`#1419`](https://github.com/DEFRA/water-abstraction-system/pull/1419) - 2PT use full authorised volume rather than Nil [`#1404`](https://github.com/DEFRA/water-abstraction-system/pull/1404) - Bump @aws-sdk/client-s3 from 3.670.0 to 3.673.0 [`#1417`](https://github.com/DEFRA/water-abstraction-system/pull/1417) -- Rename gauging stations to monitoring stations [`#1415`](https://github.com/DEFRA/water-abstraction-system/pull/1415) +- Rename gauging stations to monitoring stations [`#1415`](https://github.com/DEFRA/water-abstraction-system/pull/1415) - Fix auth scope on view monitoring station route [`#1413`](https://github.com/DEFRA/water-abstraction-system/pull/1413) - Import licence document for a licence [`#1392`](https://github.com/DEFRA/water-abstraction-system/pull/1392) - Bump eslint-plugin-jsdoc from 50.3.2 to 50.4.1 [`#1411`](https://github.com/DEFRA/water-abstraction-system/pull/1411) @@ -339,10 +339,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Add 'currentVersion' modifier to LicenceModel [`#1133`](https://github.com/DEFRA/water-abstraction-system/pull/1133) - Fix returns requirement button text [`#1134`](https://github.com/DEFRA/water-abstraction-system/pull/1134) - Feature-requirements-for-returns-view-page [`#1118`](https://github.com/DEFRA/water-abstraction-system/pull/1118) -- Add orderBy to data fetched for two-part tariff review [`#1131`](https://github.com/DEFRA/water-abstraction-system/pull/1131) +- Add orderBy to data fetched for two-part tariff review [`#1131`](https://github.com/DEFRA/water-abstraction-system/pull/1131) - Add new two-part tariff generate bill run endpoint [`#1123`](https://github.com/DEFRA/water-abstraction-system/pull/1123) - Add created_by to return versions and link models [`#1126`](https://github.com/DEFRA/water-abstraction-system/pull/1126) -- Update two-part tariff review pages to add Cypress data test attributes [`#1128`](https://github.com/DEFRA/water-abstraction-system/pull/1128) +- Update two-part tariff review pages to add Cypress data test attributes [`#1128`](https://github.com/DEFRA/water-abstraction-system/pull/1128) - Fix Ret. Req. logic to determine cycle for 2PT [`#1124`](https://github.com/DEFRA/water-abstraction-system/pull/1124) - Bump joi from 17.13.1 to 17.13.3 [`#1127`](https://github.com/DEFRA/water-abstraction-system/pull/1127) - Update validation msg for ret. req. copy existing [`#1125`](https://github.com/DEFRA/water-abstraction-system/pull/1125) @@ -433,7 +433,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Select additional submission options page [`#988`](https://github.com/DEFRA/water-abstraction-system/pull/988) - Refactor purposes page to use purpose ids as values [`#1025`](https://github.com/DEFRA/water-abstraction-system/pull/1025) - Bump sass from 1.77.1 to 1.77.2 [`#1030`](https://github.com/DEFRA/water-abstraction-system/pull/1030) -- Add sentence case function & rename capitalize [`#1029`](https://github.com/DEFRA/water-abstraction-system/pull/1029) +- Add sentence case function & rename capitalize [`#1029`](https://github.com/DEFRA/water-abstraction-system/pull/1029) - Fix QA issues found with the review adjustment factors validation [`#1027`](https://github.com/DEFRA/water-abstraction-system/pull/1027) - Refactor to use computed error message [`#1026`](https://github.com/DEFRA/water-abstraction-system/pull/1026) - Remove returns requirements button on check page [`#1021`](https://github.com/DEFRA/water-abstraction-system/pull/1021) @@ -672,7 +672,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Add legacy create bill run request [`#800`](https://github.com/DEFRA/water-abstraction-system/pull/800) - Return instead of await requests [`#799`](https://github.com/DEFRA/water-abstraction-system/pull/799) - Move legacy refresh requests to module [`#798`](https://github.com/DEFRA/water-abstraction-system/pull/798) -- Migrate Charging Module services to *.request.js [`#797`](https://github.com/DEFRA/water-abstraction-system/pull/797) +- Migrate Charging Module services to \*.request.js [`#797`](https://github.com/DEFRA/water-abstraction-system/pull/797) - Add defra-user-id header to legacy requests [`#796`](https://github.com/DEFRA/water-abstraction-system/pull/796) - Move non-model helpers out of helpers [`#795`](https://github.com/DEFRA/water-abstraction-system/pull/795) - Move currentFinancialYear() from test [`#794`](https://github.com/DEFRA/water-abstraction-system/pull/794) @@ -723,7 +723,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Move SendTransactions to root with refactoring [`#745`](https://github.com/DEFRA/water-abstraction-system/pull/745) - Remove Landing Page From System [`#747`](https://github.com/DEFRA/water-abstraction-system/pull/747) - Fix & tidy test DB legacy migrations [`#725`](https://github.com/DEFRA/water-abstraction-system/pull/725) -- Returns required - Select an existing return requirement from basic page [`#746`](https://github.com/DEFRA/water-abstraction-system/pull/746) +- Returns required - Select an existing return requirement from basic page [`#746`](https://github.com/DEFRA/water-abstraction-system/pull/746) - Bump dotenv from 16.4.4 to 16.4.5 [`#744`](https://github.com/DEFRA/water-abstraction-system/pull/744) - Determine match and allocate issues and status [`875f478`](https://github.com/DEFRA/water-abstraction-system/commit/875f4780b35ba4007d0d7a9c370c8329e0832488) @@ -886,7 +886,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Bump @aws-sdk/client-s3 from 3.472.0 to 3.473.0 [`#588`](https://github.com/DEFRA/water-abstraction-system/pull/588) - Add new page for add a note [`#587`](https://github.com/DEFRA/water-abstraction-system/pull/587) - Requirement approval page [`#585`](https://github.com/DEFRA/water-abstraction-system/pull/585) -- Add check your answers page for return required journey [`#584`](https://github.com/DEFRA/water-abstraction-system/pull/584) +- Add check your answers page for return required journey [`#584`](https://github.com/DEFRA/water-abstraction-system/pull/584) - Create `fetch-licences` service [`#577`](https://github.com/DEFRA/water-abstraction-system/pull/577) - Add check your answers page (return requirements) [`#579`](https://github.com/DEFRA/water-abstraction-system/pull/579) - Bump @aws-sdk/client-s3 from 3.470.0 to 3.472.0 [`#583`](https://github.com/DEFRA/water-abstraction-system/pull/583) diff --git a/README.md b/README.md index ff40cce6b4..16c8c8d5ef 100644 --- a/README.md +++ b/README.md @@ -12,28 +12,17 @@ This API provides an interface for calculating charges, queuing transactions and Make sure you already have: -- [Node.js v16.*](https://nodejs.org/en/) -- [PostgreSQL v12](https://www.postgresql.org/) +- [Node.js v20.\*](https://nodejs.org/en/) +- [PostgreSQL v14](https://www.postgresql.org/) -## Installation +## Running locally -First clone the repository and then drop into your new local repo: - -```bash -git clone https://github.com/DEFRA/water-abstraction-system.git && cd water-abstraction-system -``` - -Create the databases: - -```bash -npm run create-db -npm run create-test-db -``` - -Our preference is to run the database and API within Docker, so [install Docker](https://docs.docker.com/get-docker/) if you don't already have it. +This is one of a number of apps that make up the Water Resource Licencing service. Because of the service's complex infrastructure there is a separate project available that will build a fully working WRLS environment, using [Docker](https://docs.docker.com/get-docker/). We recommend reaching out to the [Water Abstraction team](https://github.com/orgs/DEFRA/teams/water-abstraction) and requesting access to **wal-dev-environment** if you need to get this project up and running. ## Configuration +> This is automatically setup when running locally using **wal-dev-environment** + Any configuration is expected to be driven by environment variables when the service is run in production as per [12 factor app](https://12factor.net/config). However when running locally in development mode or in test it makes use of the [Dotenv](https://github.com/motdotla/dotenv) package. This is a shim that will load values stored in a `.env` file into the environment which the service will then pick up as though they were there all along. @@ -48,6 +37,8 @@ If you have an idea you'd like to contribute please log an issue. All contributions should be submitted via a pull request. +The code style is dictated by [Prettier](https://prettier.io/), and we follow [StandardJS](https://standardjs.com/) code rules as implemented by [neostandard](https://github.com/neostandard/neostandard). This is all managed through [ESLint](https://eslint.org/) so should play nice with all IDE's. + ## License THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at: diff --git a/app/controllers/bill-licences.controller.js b/app/controllers/bill-licences.controller.js index 1e381f229c..ed2f4c89e5 100644 --- a/app/controllers/bill-licences.controller.js +++ b/app/controllers/bill-licences.controller.js @@ -11,7 +11,7 @@ const RemoveBillLicenceService = require('../services/bill-licences/remove-bill- const SubmitRemoveBillLicenceService = require('../services/bill-licences/submit-remove-bill-licence.service.js') const ViewBillLicenceService = require('../services/bill-licences/view-bill-licence.service.js') -async function remove (request, h) { +async function remove(request, h) { const { id } = request.params const pageData = await RemoveBillLicenceService.go(id) @@ -22,7 +22,7 @@ async function remove (request, h) { }) } -async function submitRemove (request, h) { +async function submitRemove(request, h) { const { id } = request.params try { @@ -34,7 +34,7 @@ async function submitRemove (request, h) { } } -async function view (request, h) { +async function view(request, h) { const { id } = request.params const pageData = await ViewBillLicenceService.go(id) diff --git a/app/controllers/bill-runs-review.controller.js b/app/controllers/bill-runs-review.controller.js index ecc06fa0f8..5291a38aab 100644 --- a/app/controllers/bill-runs-review.controller.js +++ b/app/controllers/bill-runs-review.controller.js @@ -21,7 +21,7 @@ const SubmitRemoveService = require('../services/bill-runs/review/submit-remove. const SubmitReviewBillRunService = require('../services/bill-runs/review/submit-review-bill-run.service.js') const SubmitReviewLicenceService = require('../services/bill-runs/review/submit-review-licence.service.js') -async function authorised (request, h) { +async function authorised(request, h) { const { reviewChargeReferenceId } = request.params const pageData = await AuthorisedService.go(reviewChargeReferenceId) @@ -32,7 +32,7 @@ async function authorised (request, h) { }) } -async function edit (request, h) { +async function edit(request, h) { const { elementIndex, reviewChargeElementId } = request.params const pageData = await EditService.go(reviewChargeElementId, elementIndex) @@ -43,7 +43,7 @@ async function edit (request, h) { }) } -async function factors (request, h) { +async function factors(request, h) { const { reviewChargeReferenceId } = request.params const pageData = await FactorsService.go(reviewChargeReferenceId) @@ -54,7 +54,7 @@ async function factors (request, h) { }) } -async function preview (request, h) { +async function preview(request, h) { const { reviewChargeReferenceId } = request.params await PreviewService.go(reviewChargeReferenceId, request.yar) @@ -62,7 +62,7 @@ async function preview (request, h) { return h.redirect(`/system/bill-runs/review/charge-reference/${reviewChargeReferenceId}`) } -async function remove (request, h) { +async function remove(request, h) { const { reviewLicenceId } = request.params const pageData = await RemoveService.go(reviewLicenceId) @@ -73,7 +73,7 @@ async function remove (request, h) { }) } -async function reviewBillRun (request, h) { +async function reviewBillRun(request, h) { const { billRunId } = request.params const { page } = request.query @@ -85,7 +85,7 @@ async function reviewBillRun (request, h) { }) } -async function reviewChargeElement (request, h) { +async function reviewChargeElement(request, h) { const { elementIndex, reviewChargeElementId } = request.params const pageData = await ReviewChargeElementService.go(reviewChargeElementId, elementIndex, request.yar) @@ -96,7 +96,7 @@ async function reviewChargeElement (request, h) { }) } -async function reviewChargeReference (request, h) { +async function reviewChargeReference(request, h) { const { reviewChargeReferenceId } = request.params const pageData = await ReviewChargeReferenceService.go(reviewChargeReferenceId, request.yar) @@ -107,7 +107,7 @@ async function reviewChargeReference (request, h) { }) } -async function reviewLicence (request, h) { +async function reviewLicence(request, h) { const { reviewLicenceId } = request.params const pageData = await ReviewLicenceService.go(reviewLicenceId, request.yar) @@ -118,7 +118,7 @@ async function reviewLicence (request, h) { }) } -async function submitAuthorised (request, h) { +async function submitAuthorised(request, h) { const { reviewChargeReferenceId } = request.params const pageData = await SubmitAuthorisedService.go(reviewChargeReferenceId, request.yar, request.payload) @@ -132,12 +132,10 @@ async function submitAuthorised (request, h) { return h.redirect(`/system/bill-runs/review/charge-reference/${reviewChargeReferenceId}`) } -async function submitEdit (request, h) { +async function submitEdit(request, h) { const { elementIndex, reviewChargeElementId } = request.params - const pageData = await SubmitEditService.go( - reviewChargeElementId, elementIndex, request.yar, request.payload - ) + const pageData = await SubmitEditService.go(reviewChargeElementId, elementIndex, request.yar, request.payload) if (pageData.error) { return h.view('bill-runs/review/edit.njk', { @@ -149,7 +147,7 @@ async function submitEdit (request, h) { return h.redirect(`/system/bill-runs/review/charge-element/${reviewChargeElementId}/${elementIndex}`) } -async function submitFactors (request, h) { +async function submitFactors(request, h) { const { reviewChargeReferenceId } = request.params const pageData = await SubmitFactorsService.go(reviewChargeReferenceId, request.yar, request.payload) @@ -163,7 +161,7 @@ async function submitFactors (request, h) { return h.redirect(`/system/bill-runs/review/charge-reference/${reviewChargeReferenceId}`) } -async function submitRemove (request, h) { +async function submitRemove(request, h) { const { reviewLicenceId } = request.params const result = await SubmitRemoveService.go(reviewLicenceId, request.yar) @@ -175,7 +173,7 @@ async function submitRemove (request, h) { return h.redirect(`/system/bill-runs/review/${result.billRunId}`) } -async function submitReviewBillRun (request, h) { +async function submitReviewBillRun(request, h) { const { billRunId } = request.params await SubmitReviewBillRunService.go(billRunId, request.payload, request.yar) @@ -183,7 +181,7 @@ async function submitReviewBillRun (request, h) { return h.redirect(`/system/bill-runs/review/${billRunId}`) } -async function submitReviewLicence (request, h) { +async function submitReviewLicence(request, h) { const { reviewLicenceId } = request.params await SubmitReviewLicenceService.go(reviewLicenceId, request.yar, request.payload) diff --git a/app/controllers/bill-runs-setup.controller.js b/app/controllers/bill-runs-setup.controller.js index 16df181180..ad1f74acfa 100644 --- a/app/controllers/bill-runs-setup.controller.js +++ b/app/controllers/bill-runs-setup.controller.js @@ -20,7 +20,7 @@ const SubmitYearService = require('../services/bill-runs/setup/submit-year.servi const TypeService = require('../services/bill-runs/setup/type.service.js') const YearService = require('../services/bill-runs/setup/year.service.js') -async function create (request, h) { +async function create(request, h) { const { sessionId } = request.params const results = await ExistsService.go(sessionId) @@ -45,7 +45,7 @@ async function create (request, h) { } } -async function noLicences (request, h) { +async function noLicences(request, h) { const { sessionId } = request.params const regionName = await NoLicencesService.go(sessionId) @@ -57,7 +57,7 @@ async function noLicences (request, h) { }) } -async function region (request, h) { +async function region(request, h) { const { sessionId } = request.params const pageData = await RegionService.go(sessionId) @@ -69,7 +69,7 @@ async function region (request, h) { }) } -async function season (request, h) { +async function season(request, h) { const { sessionId } = request.params const pageData = await SeasonService.go(sessionId) @@ -81,13 +81,13 @@ async function season (request, h) { }) } -async function setup (_request, h) { +async function setup(_request, h) { const session = await InitiateSessionService.go() return h.redirect(`/system/bill-runs/setup/${session.id}/type`) } -async function submitRegion (request, h) { +async function submitRegion(request, h) { const { sessionId } = request.params const pageData = await SubmitRegionService.go(sessionId, request.payload) @@ -107,7 +107,7 @@ async function submitRegion (request, h) { return h.redirect(`/system/bill-runs/setup/${sessionId}/year`) } -async function submitSeason (request, h) { +async function submitSeason(request, h) { const { sessionId } = request.params const pageData = await SubmitSeasonService.go(sessionId, request.payload) @@ -123,7 +123,7 @@ async function submitSeason (request, h) { return h.redirect(`/system/bill-runs/setup/${sessionId}/create`) } -async function submitType (request, h) { +async function submitType(request, h) { const { sessionId } = request.params const pageData = await SubmitTypeService.go(sessionId, request.payload) @@ -139,7 +139,7 @@ async function submitType (request, h) { return h.redirect(`/system/bill-runs/setup/${sessionId}/region`) } -async function submitYear (request, h) { +async function submitYear(request, h) { const { sessionId } = request.params const pageData = await SubmitYearService.go(sessionId, request.payload) @@ -165,7 +165,7 @@ async function submitYear (request, h) { return h.redirect(`/system/bill-runs/setup/${sessionId}/season`) } -async function type (request, h) { +async function type(request, h) { const { sessionId } = request.params const pageData = await TypeService.go(sessionId) @@ -177,7 +177,7 @@ async function type (request, h) { }) } -async function year (request, h) { +async function year(request, h) { const { sessionId } = request.params const pageData = await YearService.go(sessionId) diff --git a/app/controllers/bill-runs.controller.js b/app/controllers/bill-runs.controller.js index 07bb9c7c43..89d7971074 100644 --- a/app/controllers/bill-runs.controller.js +++ b/app/controllers/bill-runs.controller.js @@ -15,7 +15,7 @@ const ViewBillRunService = require('../services/bill-runs/view-bill-run.service. const ViewCancelBillRunService = require('../services/bill-runs/cancel/view-cancel-bill-run.service.js') const ViewSendBillRunService = require('../services/bill-runs/send/view-send-bill-run.service.js') -async function cancel (request, h) { +async function cancel(request, h) { const { id } = request.params const pageData = await ViewCancelBillRunService.go(id) @@ -27,7 +27,7 @@ async function cancel (request, h) { }) } -async function index (request, h) { +async function index(request, h) { const { page } = request.query const pageData = await IndexBillRunsService.go(page) @@ -38,7 +38,7 @@ async function index (request, h) { }) } -async function send (request, h) { +async function send(request, h) { const { id } = request.params const pageData = await ViewSendBillRunService.go(id) @@ -50,7 +50,7 @@ async function send (request, h) { }) } -async function submitCancel (request, h) { +async function submitCancel(request, h) { const { id } = request.params // NOTE: What we are awaiting here is for the SubmitCancelBillRunService to update the status of the bill run to @@ -60,7 +60,7 @@ async function submitCancel (request, h) { return h.redirect('/system/bill-runs') } -async function submitSend (request, h) { +async function submitSend(request, h) { const { id } = request.params // NOTE: What we are awaiting here is for the SubmitSendBillRunService to update the status of the bill run to @@ -71,7 +71,7 @@ async function submitSend (request, h) { return h.redirect(`/billing/batch/${id}/processing`) } -async function twoPartTariff (request, h) { +async function twoPartTariff(request, h) { const { id } = request.params try { @@ -86,7 +86,7 @@ async function twoPartTariff (request, h) { } } -async function view (request, h) { +async function view(request, h) { const { id } = request.params const pageData = await ViewBillRunService.go(id) diff --git a/app/controllers/billing-accounts.controller.js b/app/controllers/billing-accounts.controller.js index 30896a9c8c..f7c1a41060 100644 --- a/app/controllers/billing-accounts.controller.js +++ b/app/controllers/billing-accounts.controller.js @@ -10,7 +10,7 @@ const Boom = require('@hapi/boom') const ChangeAddressService = require('../services/billing-accounts/change-address.service.js') const ChangeAddressValidator = require('../validators/change-address.validator.js') -async function changeAddress (request, h) { +async function changeAddress(request, h) { const validatedData = ChangeAddressValidator.go(request.payload) if (validatedData.error) { @@ -19,18 +19,13 @@ async function changeAddress (request, h) { const { address, agentCompany, contact } = validatedData.value - const result = await ChangeAddressService.go( - request.params.billingAccountId, - address, - agentCompany, - contact - ) + const result = await ChangeAddressService.go(request.params.billingAccountId, address, agentCompany, contact) return h.response(result).code(201) } // Takes an error from a validator and returns a suitable Boom error -function _formattedValidationError (error) { +function _formattedValidationError(error) { return Boom.badRequest(error.details[0].message) } diff --git a/app/controllers/bills.controller.js b/app/controllers/bills.controller.js index 9e2bd29f6a..80dbc9ad41 100644 --- a/app/controllers/bills.controller.js +++ b/app/controllers/bills.controller.js @@ -11,7 +11,7 @@ const RemoveBillService = require('../services/bills/remove-bill.service.js') const SubmitRemoveBillService = require('../services/bills/submit-remove-bill.service.js') const ViewBillService = require('../services/bills/view-bill.service.js') -async function remove (request, h) { +async function remove(request, h) { const { id } = request.params const pageData = await RemoveBillService.go(id) @@ -22,7 +22,7 @@ async function remove (request, h) { }) } -async function submitRemove (request, h) { +async function submitRemove(request, h) { const { id } = request.params try { @@ -34,7 +34,7 @@ async function submitRemove (request, h) { } } -async function view (request, h) { +async function view(request, h) { const { id } = request.params const pageData = await ViewBillService.go(id) @@ -48,7 +48,7 @@ async function view (request, h) { }) } -function _determineView (pageData) { +function _determineView(pageData) { if (pageData.billLicences) { return 'bills/view-multi-licence.njk' } diff --git a/app/controllers/check.controller.js b/app/controllers/check.controller.js index 0b14af4bb4..41a8c05b5f 100644 --- a/app/controllers/check.controller.js +++ b/app/controllers/check.controller.js @@ -22,7 +22,7 @@ const NO_CONTENT_STATUS_CODE = 204 * * @returns {Promise} - A promise that resolves to an HTTP response object with a 204 status code */ -async function flagForBilling (request, h) { +async function flagForBilling(request, h) { const { licenceId, expiredDate, lapsedDate, revokedDate } = request.payload const transformedLicence = { @@ -44,7 +44,7 @@ async function flagForBilling (request, h) { * * @returns {Promise} - A promise that resolves to an HTTP response object with a 204 status code */ -async function returnLogsForLicence (_request, h) { +async function returnLogsForLicence(_request, h) { let licenceReference if (h.request.payload !== null && h.request.payload.licenceReference) { diff --git a/app/controllers/data.controller.js b/app/controllers/data.controller.js index c26fe2d5bf..267d3e8bcb 100644 --- a/app/controllers/data.controller.js +++ b/app/controllers/data.controller.js @@ -10,26 +10,26 @@ const SeedService = require('../services/data/seed/seed.service.js') const SubmitDeduplicateService = require('../services/data/deduplicate/submit-deduplicate.service.js') const TearDownService = require('../services/data/tear-down/tear-down.service.js') -async function deduplicate (_request, h) { +async function deduplicate(_request, h) { return h.view('data/deduplicate.njk', { pageTitle: 'De-duplicate a licence', activeNavBar: 'search' }) } -async function load (request, h) { +async function load(request, h) { const result = await LoadService.go(request.payload) return h.response(result).code(200) } -async function seed (_request, h) { +async function seed(_request, h) { await SeedService.go() return h.response().code(204) } -async function submitDeduplicate (request, h) { +async function submitDeduplicate(request, h) { const pageData = await SubmitDeduplicateService.go(request.payload) if (pageData.error) { @@ -43,7 +43,7 @@ async function submitDeduplicate (request, h) { return h.redirect(`/licences?query=${pageData.licenceRef}`) } -async function tearDown (_request, h) { +async function tearDown(_request, h) { await TearDownService.go() return h.response().code(204) diff --git a/app/controllers/health.controller.js b/app/controllers/health.controller.js index 97d3fe5481..543987135a 100644 --- a/app/controllers/health.controller.js +++ b/app/controllers/health.controller.js @@ -8,7 +8,7 @@ const DatabaseHealthCheckService = require('../services/health/database-health-check.service.js') const InfoService = require('../services/health/info.service.js') -async function airbrake (request, _h) { +async function airbrake(request, _h) { // First section tests connecting to Airbrake through a manual notification request.server.app.airbrake.notify({ message: 'Airbrake manual health check', @@ -24,13 +24,13 @@ async function airbrake (request, _h) { throw new Error('Airbrake automatic health check error') } -async function database (_request, h) { +async function database(_request, h) { const result = await DatabaseHealthCheckService.go() return h.response(result).code(200) } -async function info (_request, h) { +async function info(_request, h) { const pageData = await InfoService.go() return h.view('info.njk', { diff --git a/app/controllers/import.controller.js b/app/controllers/import.controller.js index 6067fbb014..0abd666aae 100644 --- a/app/controllers/import.controller.js +++ b/app/controllers/import.controller.js @@ -12,7 +12,7 @@ const ImportLegacyProcessLicenceService = require('../services/import/legacy/pro * * @module ImportController */ -async function licenceLegacy (request, h) { +async function licenceLegacy(request, h) { const { licenceRef } = request.payload if (FeatureFlags.enableSystemImportLegacyLicence) { diff --git a/app/controllers/jobs.controller.js b/app/controllers/jobs.controller.js index 6a1f59fa36..94df311ba1 100644 --- a/app/controllers/jobs.controller.js +++ b/app/controllers/jobs.controller.js @@ -23,31 +23,31 @@ const notFoundStatusCode = 404 * * @returns {Promise} - A promise that resolves to an HTTP response object with a 204 status code */ -async function exportDb (_request, h) { +async function exportDb(_request, h) { ExportService.go() return h.response().code(redirectStatusCode) } -async function licenceUpdates (_request, h) { +async function licenceUpdates(_request, h) { ProcessLicenceUpdates.go() return h.response().code(redirectStatusCode) } -async function sessionCleanup (_request, h) { +async function sessionCleanup(_request, h) { ProcessSessionStorageCleanupService.go() return h.response().code(redirectStatusCode) } -async function timeLimited (_request, h) { +async function timeLimited(_request, h) { ProcessTimeLimitedLicencesService.go() return h.response().code(redirectStatusCode) } -async function returnLogs (request, h) { +async function returnLogs(request, h) { const { cycle } = request.params if (!['summer', 'all-year'].includes(cycle)) { diff --git a/app/controllers/licences.controller.js b/app/controllers/licences.controller.js index 2b41cc3cad..678baffe5f 100644 --- a/app/controllers/licences.controller.js +++ b/app/controllers/licences.controller.js @@ -23,7 +23,7 @@ const ViewLicenceSummaryService = require('../services/licences/view-licence-sum const ViewLicencePage = 'licences/view.njk' -async function markedForSupplementaryBilling (request, h) { +async function markedForSupplementaryBilling(request, h) { const { id: licenceId } = request.params const pageData = await MarkedForSupplementaryBillingService.go(licenceId) @@ -35,7 +35,7 @@ async function markedForSupplementaryBilling (request, h) { }) } -async function markForSupplementaryBilling (request, h) { +async function markForSupplementaryBilling(request, h) { const { id: licenceId } = request.params const pageData = await MarkForSupplementaryBillingService.go(licenceId) @@ -47,7 +47,7 @@ async function markForSupplementaryBilling (request, h) { }) } -async function noReturnsRequired (request, h) { +async function noReturnsRequired(request, h) { const { id } = request.params const session = await InitiateSessionService.go(id, 'no-returns-required') @@ -55,7 +55,7 @@ async function noReturnsRequired (request, h) { return h.redirect(`/system/return-versions/setup/${session.id}/start-date`) } -async function returnsRequired (request, h) { +async function returnsRequired(request, h) { const { id } = request.params const session = await InitiateSessionService.go(id, 'returns-required') @@ -63,13 +63,14 @@ async function returnsRequired (request, h) { return h.redirect(`/system/return-versions/setup/${session.id}/start-date`) } -async function submitMarkForSupplementaryBilling (request, h) { +async function submitMarkForSupplementaryBilling(request, h) { const { id: licenceId } = request.params const pageData = await SubmitMarkForSupplementaryBillingService.go( licenceId, request.payload, - request.auth.credentials.user) + request.auth.credentials.user + ) if (pageData.error) { return h.view('licences/mark-for-supplementary-billing.njk', pageData) @@ -78,14 +79,18 @@ async function submitMarkForSupplementaryBilling (request, h) { return h.redirect(`/system/licences/${licenceId}/marked-for-supplementary-billing`) } -async function supplementary (request, h) { +async function supplementary(request, h) { await LicenceSupplementaryProcessBillingFlagService.go(request.payload) return h.response().code(204) } -async function viewBills (request, h) { - const { params: { id }, auth, query: { page = 1 } } = request +async function viewBills(request, h) { + const { + params: { id }, + auth, + query: { page = 1 } + } = request const pageData = await ViewLicenceBillsService.go(id, auth, page) @@ -94,8 +99,12 @@ async function viewBills (request, h) { }) } -async function viewCommunications (request, h) { - const { params: { id }, auth, query: { page = 1 } } = request +async function viewCommunications(request, h) { + const { + params: { id }, + auth, + query: { page = 1 } + } = request const pageData = await ViewLicenceCommunicationsService.go(id, auth, page) @@ -104,7 +113,7 @@ async function viewCommunications (request, h) { }) } -async function viewLicenceContactDetails (request, h) { +async function viewLicenceContactDetails(request, h) { const { id } = request.params const pageData = await ViewLicenceContactDetailsService.go(id) @@ -114,8 +123,11 @@ async function viewLicenceContactDetails (request, h) { }) } -async function viewLicenceContacts (request, h) { - const { params: { id }, auth } = request +async function viewLicenceContacts(request, h) { + const { + params: { id }, + auth + } = request const pageData = await ViewLicenceContactsService.go(id, auth) @@ -124,7 +136,7 @@ async function viewLicenceContacts (request, h) { }) } -async function viewLicencePoints (request, h) { +async function viewLicencePoints(request, h) { const { id: licenceId } = request.params const pageData = await ViewLicencePointsService.go(licenceId) @@ -134,7 +146,7 @@ async function viewLicencePoints (request, h) { }) } -async function viewLicencePurposes (request, h) { +async function viewLicencePurposes(request, h) { const { id: licenceId } = request.params const pageData = await ViewLicencePurposesService.go(licenceId) @@ -144,8 +156,11 @@ async function viewLicencePurposes (request, h) { }) } -async function viewHistory (request, h) { - const { params: { id }, auth } = request +async function viewHistory(request, h) { + const { + params: { id }, + auth + } = request const pageData = await ViewLicenceHistoryService.go(id, auth) @@ -154,8 +169,12 @@ async function viewHistory (request, h) { }) } -async function viewReturns (request, h) { - const { params: { id }, auth, query: { page = 1 } } = request +async function viewReturns(request, h) { + const { + params: { id }, + auth, + query: { page = 1 } + } = request const pageData = await ViewLicenceReturnsService.go(id, auth, page) @@ -164,8 +183,11 @@ async function viewReturns (request, h) { }) } -async function viewSetUp (request, h) { - const { params: { id }, auth } = request +async function viewSetUp(request, h) { + const { + params: { id }, + auth + } = request const pageData = await ViewLicenceSetUpService.go(id, auth) @@ -174,8 +196,11 @@ async function viewSetUp (request, h) { }) } -async function viewSummary (request, h) { - const { params: { id }, auth } = request +async function viewSummary(request, h) { + const { + params: { id }, + auth + } = request const pageData = await ViewLicenceSummaryService.go(id, auth) diff --git a/app/controllers/monitoring-stations.controller.js b/app/controllers/monitoring-stations.controller.js index aae9ac0bbc..d4813e1853 100644 --- a/app/controllers/monitoring-stations.controller.js +++ b/app/controllers/monitoring-stations.controller.js @@ -7,8 +7,11 @@ const ViewService = require('../services/monitoring-stations/view.service.js') -async function view (request, h) { - const { auth, params: { monitoringStationId } } = request +async function view(request, h) { + const { + auth, + params: { monitoringStationId } + } = request const pageData = await ViewService.go(monitoringStationId, auth) diff --git a/app/controllers/return-versions-setup.controller.js b/app/controllers/return-versions-setup.controller.js index 7f00f41c24..8655cfe485 100644 --- a/app/controllers/return-versions-setup.controller.js +++ b/app/controllers/return-versions-setup.controller.js @@ -45,7 +45,7 @@ const SubmitReturnsCycleService = require('../services/return-versions/setup/sub const SubmitSiteDescriptionService = require('../services/return-versions/setup/submit-site-description.service.js') const SubmitStartDateService = require('../services/return-versions/setup/submit-start-date.service.js') -async function abstractionPeriod (request, h) { +async function abstractionPeriod(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await AbstractionPeriodService.go(sessionId, requirementIndex) @@ -55,7 +55,7 @@ async function abstractionPeriod (request, h) { }) } -async function add (request, h) { +async function add(request, h) { const { sessionId } = request.params const requirementIndex = await AddService.go(sessionId) @@ -63,7 +63,7 @@ async function add (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/purpose/${requirementIndex}`) } -async function additionalSubmissionOptions (request, h) { +async function additionalSubmissionOptions(request, h) { const { sessionId } = request.params const pageData = await AdditionalSubmissionOptionsService.go(sessionId) @@ -73,7 +73,7 @@ async function additionalSubmissionOptions (request, h) { }) } -async function agreementsExceptions (request, h) { +async function agreementsExceptions(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await AgreementsExceptionsService.go(sessionId, requirementIndex) @@ -83,7 +83,7 @@ async function agreementsExceptions (request, h) { }) } -async function approved (request, h) { +async function approved(request, h) { const { licenceId } = request.params return h.view('return-versions/setup/approved.njk', { @@ -93,7 +93,7 @@ async function approved (request, h) { }) } -async function cancel (request, h) { +async function cancel(request, h) { const { sessionId } = request.params const pageData = await CancelService.go(sessionId) @@ -102,7 +102,7 @@ async function cancel (request, h) { }) } -async function check (request, h) { +async function check(request, h) { const { sessionId } = request.params const pageData = await CheckService.go(sessionId, request.yar) @@ -111,7 +111,7 @@ async function check (request, h) { }) } -async function deleteNote (request, h) { +async function deleteNote(request, h) { const { sessionId } = request.params await DeleteNoteService.go(sessionId, request.yar) @@ -119,7 +119,7 @@ async function deleteNote (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/check`) } -async function existing (request, h) { +async function existing(request, h) { const { sessionId } = request.params const pageData = await ExistingService.go(sessionId) @@ -129,7 +129,7 @@ async function existing (request, h) { }) } -async function frequencyCollected (request, h) { +async function frequencyCollected(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await FrequencyCollectedService.go(sessionId, requirementIndex) @@ -139,7 +139,7 @@ async function frequencyCollected (request, h) { }) } -async function frequencyReported (request, h) { +async function frequencyReported(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await FrequencyReportedService.go(sessionId, requirementIndex) @@ -149,7 +149,7 @@ async function frequencyReported (request, h) { }) } -async function method (request, h) { +async function method(request, h) { const { sessionId } = request.params const pageData = await MethodService.go(sessionId) @@ -159,7 +159,7 @@ async function method (request, h) { }) } -async function noReturnsRequired (request, h) { +async function noReturnsRequired(request, h) { const { sessionId } = request.params const pageData = await NoReturnsRequiredService.go(sessionId) @@ -169,7 +169,7 @@ async function noReturnsRequired (request, h) { }) } -async function note (request, h) { +async function note(request, h) { const { sessionId } = request.params const pageData = await NoteService.go(sessionId) @@ -179,7 +179,7 @@ async function note (request, h) { }) } -async function points (request, h) { +async function points(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await PointsService.go(sessionId, requirementIndex) @@ -189,7 +189,7 @@ async function points (request, h) { }) } -async function purpose (request, h) { +async function purpose(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await SelectPurposeService.go(sessionId, requirementIndex) @@ -199,7 +199,7 @@ async function purpose (request, h) { }) } -async function reason (request, h) { +async function reason(request, h) { const { sessionId } = request.params const pageData = await SelectReasonService.go(sessionId) @@ -209,7 +209,7 @@ async function reason (request, h) { }) } -async function remove (request, h) { +async function remove(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await RemoveService.go(sessionId, requirementIndex) @@ -219,7 +219,7 @@ async function remove (request, h) { }) } -async function returnsCycle (request, h) { +async function returnsCycle(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await ReturnsCycleService.go(sessionId, requirementIndex) @@ -229,7 +229,7 @@ async function returnsCycle (request, h) { }) } -async function siteDescription (request, h) { +async function siteDescription(request, h) { const { requirementIndex, sessionId } = request.params const pageData = await SiteDescriptionService.go(sessionId, requirementIndex) @@ -239,7 +239,7 @@ async function siteDescription (request, h) { }) } -async function startDate (request, h) { +async function startDate(request, h) { const { sessionId } = request.params const pageData = await StartDateService.go(sessionId) @@ -249,8 +249,12 @@ async function startDate (request, h) { }) } -async function submitAbstractionPeriod (request, h) { - const { params: { requirementIndex, sessionId }, payload, yar } = request +async function submitAbstractionPeriod(request, h) { + const { + params: { requirementIndex, sessionId }, + payload, + yar + } = request const pageData = await SubmitAbstractionPeriod.go(sessionId, requirementIndex, payload, yar) @@ -265,8 +269,12 @@ async function submitAbstractionPeriod (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/returns-cycle/${requirementIndex}`) } -async function submitAgreementsExceptions (request, h) { - const { params: { requirementIndex, sessionId }, payload, yar } = request +async function submitAgreementsExceptions(request, h) { + const { + params: { requirementIndex, sessionId }, + payload, + yar + } = request const pageData = await SubmitAgreementsExceptions.go(sessionId, requirementIndex, payload, yar) @@ -277,8 +285,12 @@ async function submitAgreementsExceptions (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/check`) } -async function submitAdditionalSubmissionOptions (request, h) { - const { params: { sessionId }, payload, yar } = request +async function submitAdditionalSubmissionOptions(request, h) { + const { + params: { sessionId }, + payload, + yar + } = request const pageData = await SubmitAdditionalSubmissionOptionsService.go(sessionId, payload, yar) @@ -289,7 +301,7 @@ async function submitAdditionalSubmissionOptions (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/check`) } -async function submitCancel (request, h) { +async function submitCancel(request, h) { const { sessionId } = request.params const { licenceId } = request.payload @@ -302,7 +314,7 @@ async function submitCancel (request, h) { } } -async function submitCheck (request, h) { +async function submitCheck(request, h) { const { sessionId } = request.params const { id: userId } = request.auth.credentials.user @@ -311,8 +323,11 @@ async function submitCheck (request, h) { return h.redirect(`/system/return-versions/setup/${licenceId}/approved`) } -async function submitExisting (request, h) { - const { params: { sessionId }, payload } = request +async function submitExisting(request, h) { + const { + params: { sessionId }, + payload + } = request const pageData = await SubmitExistingService.go(sessionId, payload) @@ -323,8 +338,12 @@ async function submitExisting (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/check`) } -async function submitFrequencyCollected (request, h) { - const { params: { requirementIndex, sessionId }, payload, yar } = request +async function submitFrequencyCollected(request, h) { + const { + params: { requirementIndex, sessionId }, + payload, + yar + } = request const pageData = await SubmitFrequencyCollectedService.go(sessionId, requirementIndex, payload, yar) @@ -339,8 +358,12 @@ async function submitFrequencyCollected (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/frequency-reported/${requirementIndex}`) } -async function submitFrequencyReported (request, h) { - const { params: { requirementIndex, sessionId }, payload, yar } = request +async function submitFrequencyReported(request, h) { + const { + params: { requirementIndex, sessionId }, + payload, + yar + } = request const pageData = await SubmitFrequencyReportedService.go(sessionId, requirementIndex, payload, yar) @@ -355,7 +378,7 @@ async function submitFrequencyReported (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/agreements-exceptions/${requirementIndex}`) } -async function submitMethod (request, h) { +async function submitMethod(request, h) { const { sessionId } = request.params const pageData = await SubmitMethodService.go(sessionId, request.payload) @@ -367,8 +390,12 @@ async function submitMethod (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/${pageData.redirect}`) } -async function submitNoReturnsRequired (request, h) { - const { params: { sessionId }, payload, yar } = request +async function submitNoReturnsRequired(request, h) { + const { + params: { sessionId }, + payload, + yar + } = request const pageData = await SubmitNoReturnsRequiredService.go(sessionId, payload, yar) @@ -379,7 +406,7 @@ async function submitNoReturnsRequired (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/check`) } -async function submitNote (request, h) { +async function submitNote(request, h) { const { sessionId } = request.params const { user } = request.auth.credentials @@ -392,8 +419,12 @@ async function submitNote (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/check`) } -async function submitPoints (request, h) { - const { params: { requirementIndex, sessionId }, payload, yar } = request +async function submitPoints(request, h) { + const { + params: { requirementIndex, sessionId }, + payload, + yar + } = request const pageData = await SubmitPointsService.go(sessionId, requirementIndex, payload, yar) @@ -408,8 +439,12 @@ async function submitPoints (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/abstraction-period/${requirementIndex}`) } -async function submitPurpose (request, h) { - const { params: { requirementIndex, sessionId }, payload, yar } = request +async function submitPurpose(request, h) { + const { + params: { requirementIndex, sessionId }, + payload, + yar + } = request const pageData = await SubmitPurposeService.go(sessionId, requirementIndex, payload, yar) @@ -424,8 +459,12 @@ async function submitPurpose (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/points/${requirementIndex}`) } -async function submitReason (request, h) { - const { params: { sessionId }, payload, yar } = request +async function submitReason(request, h) { + const { + params: { sessionId }, + payload, + yar + } = request const pageData = await SubmitReasonService.go(sessionId, payload, yar) @@ -440,7 +479,7 @@ async function submitReason (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/method`) } -async function submitRemove (request, h) { +async function submitRemove(request, h) { const { requirementIndex, sessionId } = request.params await SubmitRemoveService.go(sessionId, requirementIndex, request.yar) @@ -448,8 +487,12 @@ async function submitRemove (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/check`) } -async function submitReturnsCycle (request, h) { - const { params: { requirementIndex, sessionId }, payload, yar } = request +async function submitReturnsCycle(request, h) { + const { + params: { requirementIndex, sessionId }, + payload, + yar + } = request const pageData = await SubmitReturnsCycleService.go(sessionId, requirementIndex, payload, yar) @@ -464,8 +507,12 @@ async function submitReturnsCycle (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/site-description/${requirementIndex}`) } -async function submitSiteDescription (request, h) { - const { params: { requirementIndex, sessionId }, payload, yar } = request +async function submitSiteDescription(request, h) { + const { + params: { requirementIndex, sessionId }, + payload, + yar + } = request const pageData = await SubmitSiteDescriptionService.go(sessionId, requirementIndex, payload, yar) @@ -480,8 +527,12 @@ async function submitSiteDescription (request, h) { return h.redirect(`/system/return-versions/setup/${sessionId}/frequency-collected/${requirementIndex}`) } -async function submitStartDate (request, h) { - const { params: { sessionId }, payload, yar } = request +async function submitStartDate(request, h) { + const { + params: { sessionId }, + payload, + yar + } = request const pageData = await SubmitStartDateService.go(sessionId, payload, yar) diff --git a/app/controllers/return-versions.controller.js b/app/controllers/return-versions.controller.js index 7fa6126529..8c2092afd3 100644 --- a/app/controllers/return-versions.controller.js +++ b/app/controllers/return-versions.controller.js @@ -7,7 +7,7 @@ const ViewService = require('../services/return-versions/view.service.js') -async function view (request, h) { +async function view(request, h) { const { id } = request.params const pageData = await ViewService.go(id) diff --git a/app/controllers/root.controller.js b/app/controllers/root.controller.js index 3d798309df..c5b08d64ae 100644 --- a/app/controllers/root.controller.js +++ b/app/controllers/root.controller.js @@ -5,7 +5,7 @@ * @module RootController */ -function index (_request, _h) { +function index(_request, _h) { return { status: 'alive' } } diff --git a/app/errors/bill-run.error.js b/app/errors/bill-run.error.js index 9f4a60a731..8b2311791f 100644 --- a/app/errors/bill-run.error.js +++ b/app/errors/bill-run.error.js @@ -1,7 +1,7 @@ 'use strict' class BillRunError extends Error { - constructor (error, code = null) { + constructor(error, code = null) { super(error) this.code = code diff --git a/app/errors/expanded.error.js b/app/errors/expanded.error.js index a60ccbc3d8..831bcc4086 100644 --- a/app/errors/expanded.error.js +++ b/app/errors/expanded.error.js @@ -8,7 +8,7 @@ class ExpandedError extends Error { * @param {string} message - Message that will be given to the error instance * @param {object} data - An object containing the additional data properties to be assigned to the error instance */ - constructor (message, data) { + constructor(message, data) { super(message) for (const [key, value] of Object.entries(data)) { diff --git a/app/errors/no-billing-periods.error.js b/app/errors/no-billing-periods.error.js index 6f085d88e1..b2543a7a9d 100644 --- a/app/errors/no-billing-periods.error.js +++ b/app/errors/no-billing-periods.error.js @@ -1,7 +1,7 @@ 'use strict' class NoBillingPeriodsError extends Error { - constructor (year = null) { + constructor(year = null) { super( "No billing periods could be determined. Perhaps you are trying to create a supplementary in an environment where the last annual doesn't exist or was in a PRESROC year." ) diff --git a/app/lib/base-notifier.lib.js b/app/lib/base-notifier.lib.js index d8e7700f5e..598a1202cd 100644 --- a/app/lib/base-notifier.lib.js +++ b/app/lib/base-notifier.lib.js @@ -30,7 +30,7 @@ const AirbrakeConfig = require('../../config/airbrake.config.js') * which our 'AirbrakePlugin` adds to Hapi. If 'null' the class will create a new instance instead. */ class BaseNotifierLib { - constructor (logger = null, notifier = null) { + constructor(logger = null, notifier = null) { this._logger = this._setLogger(logger) this._notifier = this._setNotifier(notifier) } @@ -44,7 +44,7 @@ class BaseNotifierLib { * @param {object} [data={}] - An object containing any values to be logged, for example, a bill run ID to be included * with the log message. Defaults to an empty object */ - omg (message, data = {}) { + omg(message, data = {}) { this._logger.info(this._formatLogPacket(data), message) } @@ -80,7 +80,7 @@ class BaseNotifierLib { * @param {Error} [error=null] - An instance of the error to be logged and sent to Errbit. If no error is provided one * will be created using `message` as the error message */ - omfg (message, data = {}, error = null) { + omfg(message, data = {}, error = null) { // This deals with anyone calling omfg() with `omfg('It broke', null, error)` which would cause things to break if (!data) { data = {} @@ -94,7 +94,8 @@ class BaseNotifierLib { this._logger.error(this._formatLogPacket(data, error), message) - this._notifier.notify(this._formatNotifyPacket(data, error, message)) + this._notifier + .notify(this._formatNotifyPacket(data, error, message)) // This section is a 'just in case' anything goes wrong when trying to send the notification to Errbit. It will // either fail (cannot connect) or blow up entirely. If it does we log the error directly (no calls to the // formatter) @@ -119,7 +120,7 @@ class BaseNotifierLib { * testing highlighted that should an error occur and we don't `flush()` Airbrake's queue, we never see them in * Errbit. So, we expose Airbrake's `flush()` using this method which notifiers that extend the base can make use of. */ - async flush () { + async flush() { await this._notifier.flush() } @@ -138,7 +139,7 @@ class BaseNotifierLib { * * @private */ - _formatLogPacket (data, error) { + _formatLogPacket(data, error) { const packet = { ...data } @@ -165,7 +166,7 @@ class BaseNotifierLib { * * @private */ - _formatNotifyPacket (data, error, message) { + _formatNotifyPacket(data, error, message) { return { error, session: { @@ -186,7 +187,7 @@ class BaseNotifierLib { * * @private */ - _setLogger (logger) { + _setLogger(logger) { if (logger) { return logger } @@ -205,7 +206,7 @@ class BaseNotifierLib { * * @private */ - _setNotifier (notifier) { + _setNotifier(notifier) { if (notifier) { return notifier } diff --git a/app/lib/boom-notifier.lib.js b/app/lib/boom-notifier.lib.js index e37c1d6458..a0728ef274 100644 --- a/app/lib/boom-notifier.lib.js +++ b/app/lib/boom-notifier.lib.js @@ -26,7 +26,7 @@ const RequestNotifierLib = require('./request-notifier.lib.js') * method so it throws an error after logging. */ class BoomNotifierLib extends RequestNotifierLib { - omfg (message, data = {}) { + omfg(message, data = {}) { super.omfg(message, data) throw Boom.badData(message, data) } diff --git a/app/lib/dates.lib.js b/app/lib/dates.lib.js index f723ff3d4b..f58901e46b 100644 --- a/app/lib/dates.lib.js +++ b/app/lib/dates.lib.js @@ -19,7 +19,7 @@ const lastDayOfFebruaryLeapYear = 29 * @param {string} date - The date in the format 01/01/2001 * @returns {string | null} - a date in the iso format 2001-01-01 */ -function formatStandardDateToISO (date) { +function formatStandardDateToISO(date) { if (date === 'null' || date === null) { return null } @@ -41,7 +41,7 @@ function formatStandardDateToISO (date) { * @param {Date} date - a date object to be formatted * @returns {Date} - the date formatted in YYYY-MM-DD. */ -function formatDateObjectToISO (date) { +function formatDateObjectToISO(date) { return date.toISOString().split('T')[0] } @@ -51,7 +51,7 @@ function formatDateObjectToISO (date) { * @param {dateString | undefined } dateString - The date in the iso format 2001-01-01 * @returns {boolean} */ -function isValidDate (dateString) { +function isValidDate(dateString) { if (!dateString) { return false } @@ -71,7 +71,7 @@ function isValidDate (dateString) { * @param {dateString} dateString - The date in the iso format 2001-01-01 * @returns {boolean} */ -function isISODateFormat (dateString) { +function isISODateFormat(dateString) { const isoDatePattern = /^\d{4}-\d{2}-\d{2}$/ return isoDatePattern.test(dateString) @@ -89,7 +89,7 @@ function isISODateFormat (dateString) { * * @private */ -function _isValidLeapYearDate (dateString) { +function _isValidLeapYearDate(dateString) { const [year, month, day] = dateString.split('-') if (_isLeapYear(year) === true && Number(month) === february && Number(day) > lastDayOfFebruaryLeapYear) { @@ -103,10 +103,10 @@ function _isValidLeapYearDate (dateString) { return true } -function _isLeapYear (year) { +function _isLeapYear(year) { const set400 = 400 - if ((year % 4 === 0 && year % 100 !== 0) || (year % set400 === 0)) { + if ((year % 4 === 0 && year % 100 !== 0) || year % set400 === 0) { return true } @@ -124,7 +124,7 @@ function _isLeapYear (year) { * * @private */ -function isQuarterlyReturnSubmissions (date) { +function isQuarterlyReturnSubmissions(date) { return new Date(date).getTime() >= new Date('2025-04-01').getTime() } diff --git a/app/lib/general.lib.js b/app/lib/general.lib.js index e4bd4d39a4..3711cf6aa3 100644 --- a/app/lib/general.lib.js +++ b/app/lib/general.lib.js @@ -29,7 +29,7 @@ const { randomUUID } = require('crypto') * @param {string} message - the message to log * @param {object} [data] - additional data to include with the log output */ -function calculateAndLogTimeTaken (startTime, message, data = {}) { +function calculateAndLogTimeTaken(startTime, message, data = {}) { const endTime = currentTimeInNanoseconds() const timeTakenNs = endTime - startTime const timeTakenMs = timeTakenNs / 1000000n @@ -64,7 +64,7 @@ function calculateAndLogTimeTaken (startTime, message, data = {}) { * * @returns {bigint} the current time in nanoseconds */ -function currentTimeInNanoseconds () { +function currentTimeInNanoseconds() { return process.hrtime.bigint() } @@ -76,7 +76,7 @@ function currentTimeInNanoseconds () { * * @returns {object} An object containing a `startDate` and `endDate` */ -function determineCurrentFinancialYear () { +function determineCurrentFinancialYear() { const currentDate = new Date() const currentYear = currentDate.getFullYear() @@ -108,7 +108,7 @@ function determineCurrentFinancialYear () { * @param {string} [text='Changes made'] - text for the notification * */ -function flashNotification (yar, title = 'Updated', text = 'Changes made') { +function flashNotification(yar, title = 'Updated', text = 'Changes made') { yar.flash('notification', { title, text @@ -131,7 +131,7 @@ function flashNotification (yar, title = 'Updated', text = 'Changes made') { * * @returns {string} a randomly generated UUID */ -function generateUUID () { +function generateUUID() { return randomUUID({ disableEntropyCache: true }) } @@ -164,7 +164,7 @@ function generateUUID () { * * @returns {boolean} Returns true if there _any_ check period overlaps with a reference period, else false */ -function periodsOverlap (referencePeriods, checkPeriods) { +function periodsOverlap(referencePeriods, checkPeriods) { for (const referencePeriod of referencePeriods) { const overLappingPeriods = checkPeriods.filter((checkPeriod) => { if (checkPeriod.startDate > referencePeriod.endDate || referencePeriod.startDate > checkPeriod.endDate) { @@ -193,7 +193,7 @@ function periodsOverlap (referencePeriods, checkPeriods) { * * @returns {string} The date now as an ISO string, for example `'2023-01-13T18:29:51.682Z'` */ -function timestampForPostgres () { +function timestampForPostgres() { return new Date().toISOString() } @@ -229,7 +229,7 @@ function timestampForPostgres () { * * @returns {boolean} true if a match else false */ -function transactionsMatch (left, right) { +function transactionsMatch(left, right) { // When we put together this matching logic our instincts were to try and do something 'better' than this long, // chained `&&` statement. But whatever we came up with was // @@ -238,7 +238,8 @@ function transactionsMatch (left, right) { // // We also believe this makes it easy to see what properties are being compared. Plus the moment something doesn't // match we bail. So, much as it feels 'wrong', we are sticking with it! - return left.chargeType === right.chargeType && + return ( + left.chargeType === right.chargeType && left.chargeCategoryCode === right.chargeCategoryCode && left.billableDays === right.billableDays && left.section126Factor === right.section126Factor && @@ -250,6 +251,7 @@ function transactionsMatch (left, right) { left.supportedSource === right.supportedSource && left.supportedSourceName === right.supportedSourceName && left.waterCompanyCharge === right.waterCompanyCharge + ) } module.exports = { diff --git a/app/lib/global-notifier.lib.js b/app/lib/global-notifier.lib.js index 73c082ce7b..fab6ab2bc4 100644 --- a/app/lib/global-notifier.lib.js +++ b/app/lib/global-notifier.lib.js @@ -13,7 +13,7 @@ const BaseNotifierLib = require('./base-notifier.lib.js') * Created for use with the `app/plugins/global-notifier.plugin.js`. */ class GlobalNotifierLib extends BaseNotifierLib { - constructor (logger, notifier) { + constructor(logger, notifier) { // This is here more to make it clear that we expect these args to be provided. BaseNotifierLib has the built-in // ability to instantiate them if not provided. But for our use case in global-notifier.plugin.js we want to ensure // we are using the existing instances. diff --git a/app/lib/legacy-db-snake-case-mappers.lib.js b/app/lib/legacy-db-snake-case-mappers.lib.js index d5f8bdbeb9..e287341bcb 100644 --- a/app/lib/legacy-db-snake-case-mappers.lib.js +++ b/app/lib/legacy-db-snake-case-mappers.lib.js @@ -34,7 +34,7 @@ const { camelCase, knexIdentifierMappers, snakeCase } = require('objection/lib/u * * @returns object containing Knex postProcessResponse() and wrapIdentifier() hooks */ -function legacyDbSnakeCaseMappers (opt = {}) { +function legacyDbSnakeCaseMappers(opt = {}) { return knexIdentifierMappers({ parse: (str) => { return _legacyCamelCase(str, opt) @@ -45,7 +45,7 @@ function legacyDbSnakeCaseMappers (opt = {}) { }) } -function _legacyCamelCase (str, { upperCase = false } = {}) { +function _legacyCamelCase(str, { upperCase = false } = {}) { if (str === 'crm_v2') { return str } @@ -53,13 +53,9 @@ function _legacyCamelCase (str, { upperCase = false } = {}) { return camelCase(str, { upperCase }) } -function _legacySnakeCase ( +function _legacySnakeCase( str, - { - upperCase = false, - underscoreBeforeDigits = false, - underscoreBetweenUppercaseLetters = false - } = {} + { upperCase = false, underscoreBeforeDigits = false, underscoreBetweenUppercaseLetters = false } = {} ) { if (str === 'crm_v2') { return str diff --git a/app/lib/request-notifier.lib.js b/app/lib/request-notifier.lib.js index 7c349c3345..939ff4f4be 100644 --- a/app/lib/request-notifier.lib.js +++ b/app/lib/request-notifier.lib.js @@ -31,7 +31,7 @@ class RequestNotifierLib extends BaseNotifierLib { * @param {object} notifier - An instance of the {@link https://github.com/airbrake/airbrake-js|airbrake-js} `notify()` * method which our 'AirbrakePlugin` adds to Hapi */ - constructor (id, logger, notifier) { + constructor(id, logger, notifier) { super(logger, notifier) this._id = id } @@ -57,7 +57,7 @@ class RequestNotifierLib extends BaseNotifierLib { * * @private */ - _formatLogPacket (data, error) { + _formatLogPacket(data, error) { const dataWithRequestId = { ...data, req: { @@ -82,7 +82,7 @@ class RequestNotifierLib extends BaseNotifierLib { * * @private */ - _formatNotifyPacket (data, error, message) { + _formatNotifyPacket(data, error, message) { const dataWithRequestId = { ...data, req: { diff --git a/app/lib/return-cycle-dates.lib.js b/app/lib/return-cycle-dates.lib.js index cc2a504190..f1f06f0ac1 100644 --- a/app/lib/return-cycle-dates.lib.js +++ b/app/lib/return-cycle-dates.lib.js @@ -14,7 +14,7 @@ const { returnCycleDates } = require('./static-lookups.lib.js') * @param {boolean} summer - true for summer, false for winter and all year. * @returns {string} - the due date of the next cycle as an ISO string. */ -function cycleDueDateAsISO (summer) { +function cycleDueDateAsISO(summer) { return formatDateObjectToISO(cycleDueDate(summer)) } @@ -24,7 +24,7 @@ function cycleDueDateAsISO (summer) { * @param {boolean} summer - true for summer, false for winter and all year. * @returns {Date} - the due date of the next cycle. */ -function cycleDueDate (summer) { +function cycleDueDate(summer) { const today = new Date() const year = today.getFullYear() const month = today.getMonth() @@ -57,7 +57,7 @@ function cycleDueDate (summer) { * @param {boolean} summer - true for summer, false for winter and all year. * @returns {string} - the due date of the next cycle. */ -function cycleDueDateByDate (date, summer) { +function cycleDueDateByDate(date, summer) { const year = date.getFullYear() const month = date.getMonth() @@ -88,7 +88,7 @@ function cycleDueDateByDate (date, summer) { * @param {boolean} summer - true for summer, false for winter and all year. * @returns {string} - the end date of the next cycle as an ISO string. */ -function cycleEndDateAsISO (summer) { +function cycleEndDateAsISO(summer) { return formatDateObjectToISO(cycleEndDate(summer)) } @@ -98,7 +98,7 @@ function cycleEndDateAsISO (summer) { * @param {boolean} summer - true for summer, false for winter and all year. * @returns {Date} - the end date of the next cycle. */ -function cycleEndDate (summer) { +function cycleEndDate(summer) { const today = new Date() const year = today.getFullYear() const month = today.getMonth() @@ -131,7 +131,7 @@ function cycleEndDate (summer) { * @param {boolean} summer - true for summer, false for winter and all year. * @returns {Date} - the start date of the next cycle. */ -function cycleEndDateByDate (date, summer) { +function cycleEndDateByDate(date, summer) { const year = date.getFullYear() const month = date.getMonth() @@ -162,7 +162,7 @@ function cycleEndDateByDate (date, summer) { * @param {boolean} summer - true for summer, false for winter and all year. * @returns {string} - the start date of the next cycle as an ISO string. */ -function cycleStartDateAsISO (summer) { +function cycleStartDateAsISO(summer) { return formatDateObjectToISO(cycleStartDate(summer)) } @@ -172,7 +172,7 @@ function cycleStartDateAsISO (summer) { * @param {boolean} summer - true for summer, false for winter and all year. * @returns {Date} - the start date of the next cycle. */ -function cycleStartDate (summer) { +function cycleStartDate(summer) { const today = new Date() const year = today.getFullYear() const month = today.getMonth() @@ -205,7 +205,7 @@ function cycleStartDate (summer) { * @param {boolean} summer - true for summer, false for winter and all year. * @returns {Date} - the start date of the next cycle. */ -function cycleStartDateByDate (date, summer) { +function cycleStartDateByDate(date, summer) { const year = date.getFullYear() const month = date.getMonth() diff --git a/app/lib/static-lookups.lib.js b/app/lib/static-lookups.lib.js index 01f34c14a9..a8086fb27e 100644 --- a/app/lib/static-lookups.lib.js +++ b/app/lib/static-lookups.lib.js @@ -1,27 +1,12 @@ 'use strict' -const billRunTypes = [ - 'annual', - 'supplementary', - 'two_part_tariff' -] +const billRunTypes = ['annual', 'supplementary', 'two_part_tariff'] -const companyTypes = [ - 'person', - 'organisation' -] +const companyTypes = ['person', 'organisation'] -const contactTypes = [ - 'person', - 'department' -] +const contactTypes = ['person', 'department'] -const organisationTypes = [ - 'individual', - 'limitedCompany', - 'limitedLiabilityPartnership', - 'publicLimitedCompany' -] +const organisationTypes = ['individual', 'limitedCompany', 'limitedLiabilityPartnership', 'publicLimitedCompany'] const returnCycleDates = { allYear: { @@ -60,7 +45,8 @@ const returnRequirementReasons = { 'new-special-agreement': 'New special agreement', 'returns-exception': 'Returns exception', 'succession-or-transfer-of-licence': 'Succession or transfer of licence', - 'succession-to-remainder-licence-or-licence-apportionment': 'Succession to remainder licence or licence apportionment', + 'succession-to-remainder-licence-or-licence-apportionment': + 'Succession to remainder licence or licence apportionment', 'temporary-trade': 'Temporary trade', 'transfer-and-now-chargeable': 'Licence transferred and now chargeable' } @@ -81,10 +67,7 @@ const naldRegions = { YO: 'Yorkshire' } -const sources = [ - 'nald', - 'wrls' -] +const sources = ['nald', 'wrls'] const twoPartTariffReviewIssues = { 'abs-outside-period': 'Abstraction outside period', diff --git a/app/models/address.model.js b/app/models/address.model.js index 556bd6a73f..3e8030ec7d 100644 --- a/app/models/address.model.js +++ b/app/models/address.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class AddressModel extends BaseModel { - static get tableName () { + static get tableName() { return 'addresses' } - static get relationMappings () { + static get relationMappings() { return { billingAccountAddresses: { relation: Model.HasManyRelation, diff --git a/app/models/base.model.js b/app/models/base.model.js index 860b23e69e..240d901f94 100644 --- a/app/models/base.model.js +++ b/app/models/base.model.js @@ -36,7 +36,7 @@ class BaseModel extends Model { * * @returns {string[]} An array of paths */ - static get modelPaths () { + static get modelPaths() { return [__dirname] } } diff --git a/app/models/bill-licence.model.js b/app/models/bill-licence.model.js index f49cd5ceb6..6a347c30bc 100644 --- a/app/models/bill-licence.model.js +++ b/app/models/bill-licence.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class BillLicenceModel extends BaseModel { - static get tableName () { + static get tableName() { return 'billLicences' } - static get relationMappings () { + static get relationMappings() { return { bill: { relation: Model.BelongsToOneRelation, diff --git a/app/models/bill-run-charge-version-year.model.js b/app/models/bill-run-charge-version-year.model.js index a1fe1bd43e..12e0ce523a 100644 --- a/app/models/bill-run-charge-version-year.model.js +++ b/app/models/bill-run-charge-version-year.model.js @@ -23,11 +23,11 @@ const BaseModel = require('./base.model.js') * Welcome to dealing with the legacy database schema! ¯\_(ツ)_/¯ */ class BillRunChargeVersionYearModel extends BaseModel { - static get tableName () { + static get tableName() { return 'billRunChargeVersionYears' } - static get relationMappings () { + static get relationMappings() { return { billRun: { relation: Model.BelongsToOneRelation, diff --git a/app/models/bill-run-volume.model.js b/app/models/bill-run-volume.model.js index f7cc5edff7..9dfbadf7d9 100644 --- a/app/models/bill-run-volume.model.js +++ b/app/models/bill-run-volume.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class BillRunVolumeModel extends BaseModel { - static get tableName () { + static get tableName() { return 'billRunVolumes' } - static get relationMappings () { + static get relationMappings() { return { billRun: { relation: Model.BelongsToOneRelation, @@ -36,7 +36,7 @@ class BillRunVolumeModel extends BaseModel { } // NOTE: When we checked the live data the only statuses we could find in use were; 10, 40, 50, 60, 70, 90 and 100 - static get twoPartTariffStatuses () { + static get twoPartTariffStatuses() { return { noReturnsSubmitted: 10, underQuery: 20, @@ -51,7 +51,7 @@ class BillRunVolumeModel extends BaseModel { } } - $twoPartTariffStatus () { + $twoPartTariffStatus() { const index = Object.values(BillRunVolumeModel.twoPartTariffStatuses).findIndex((value) => { return value === this.twoPartTariffStatus }) diff --git a/app/models/bill-run.model.js b/app/models/bill-run.model.js index c1dd698222..2177924ee5 100644 --- a/app/models/bill-run.model.js +++ b/app/models/bill-run.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class BillRunModel extends BaseModel { - static get tableName () { + static get tableName() { return 'billRuns' } - static get relationMappings () { + static get relationMappings() { return { billRunVolumes: { relation: Model.HasManyRelation, @@ -51,7 +51,7 @@ class BillRunModel extends BaseModel { } } - static get errorCodes () { + static get errorCodes() { return { failedToPopulateChargeVersions: 10, failedToProcessChargeVersions: 20, diff --git a/app/models/bill.model.js b/app/models/bill.model.js index a216775d26..3eedb166b7 100644 --- a/app/models/bill.model.js +++ b/app/models/bill.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class BillModel extends BaseModel { - static get tableName () { + static get tableName() { return 'bills' } - static get relationMappings () { + static get relationMappings() { return { billingAccount: { relation: Model.BelongsToOneRelation, diff --git a/app/models/billing-account-address.model.js b/app/models/billing-account-address.model.js index c1ded95753..af1b6ad2cf 100644 --- a/app/models/billing-account-address.model.js +++ b/app/models/billing-account-address.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class BillingAccountAddressModel extends BaseModel { - static get tableName () { + static get tableName() { return 'billingAccountAddresses' } - static get relationMappings () { + static get relationMappings() { return { address: { relation: Model.BelongsToOneRelation, diff --git a/app/models/billing-account.model.js b/app/models/billing-account.model.js index 0f0501e278..24b2b8dbab 100644 --- a/app/models/billing-account.model.js +++ b/app/models/billing-account.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class BillingAccountModel extends BaseModel { - static get tableName () { + static get tableName() { return 'billingAccounts' } - static get relationMappings () { + static get relationMappings() { return { billingAccountAddresses: { relation: Model.HasManyRelation, @@ -65,70 +65,54 @@ class BillingAccountModel extends BaseModel { * * @returns {object} */ - static get modifiers () { + static get modifiers() { return { // fetches all related records need to display contact name and address for the billing account - contactDetails (query) { + contactDetails(query) { query - .select([ - 'id', - 'accountNumber' - ]) + .select(['id', 'accountNumber']) .withGraphFetched('company') .modifyGraph('company', (builder) => { - builder.select([ - 'id', - 'name', - 'type' - ]) + builder.select(['id', 'name', 'type']) }) .withGraphFetched('billingAccountAddresses') // The current billing account address is denoted by the fact it is the only one with a null end date .modifyGraph('billingAccountAddresses', (builder) => { builder - .select([ - 'id' - ]) + .select(['id']) .whereNull('endDate') .withGraphFetched('address') .modifyGraph('address', (builder) => { - builder - .select([ - 'id', - 'address1', - 'address2', - 'address3', - 'address4', - 'address5', - 'address6', - 'postcode', - 'country' - ]) + builder.select([ + 'id', + 'address1', + 'address2', + 'address3', + 'address4', + 'address5', + 'address6', + 'postcode', + 'country' + ]) }) .withGraphFetched('company') .modifyGraph('company', (builder) => { - builder - .select([ - 'id', - 'name', - 'type' - ]) + builder.select(['id', 'name', 'type']) }) .withGraphFetched('contact') .modifyGraph('contact', (builder) => { - builder - .select([ - 'id', - 'contactType', - 'dataSource', - 'department', - 'firstName', - 'initials', - 'lastName', - 'middleInitials', - 'salutation', - 'suffix' - ]) + builder.select([ + 'id', + 'contactType', + 'dataSource', + 'department', + 'firstName', + 'initials', + 'lastName', + 'middleInitials', + 'salutation', + 'suffix' + ]) }) }) } @@ -148,7 +132,7 @@ class BillingAccountModel extends BaseModel { * * @returns {string|null} the account name to use for the billing account or null if it cannot be determined */ - $accountName () { + $accountName() { const currentBillingAccountAddress = this?.billingAccountAddresses?.[0] if (currentBillingAccountAddress?.company) { @@ -169,7 +153,7 @@ class BillingAccountModel extends BaseModel { * * @returns {string[]} the address lines to use for the billing account */ - $addressLines () { + $addressLines() { const currentBillingAccountAddress = this?.billingAccountAddresses?.[0] // Guard clause in case modifier has not been used @@ -205,7 +189,7 @@ class BillingAccountModel extends BaseModel { * * @returns {string|null} the contact name to use for the billing account or null if it cannot be determined */ - $contactName () { + $contactName() { const currentBillingAccountAddress = this?.billingAccountAddresses?.[0] if (currentBillingAccountAddress?.contact) { diff --git a/app/models/change-reason.model.js b/app/models/change-reason.model.js index 3264a2da85..cac920cc55 100644 --- a/app/models/change-reason.model.js +++ b/app/models/change-reason.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ChangeReasonModel extends BaseModel { - static get tableName () { + static get tableName() { return 'changeReasons' } - static get relationMappings () { + static get relationMappings() { return { chargeVersions: { relation: Model.HasManyRelation, diff --git a/app/models/charge-category.model.js b/app/models/charge-category.model.js index fbed6d8f99..29a9f6a846 100644 --- a/app/models/charge-category.model.js +++ b/app/models/charge-category.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ChargeCategoryModel extends BaseModel { - static get tableName () { + static get tableName() { return 'chargeCategories' } - static get relationMappings () { + static get relationMappings() { return { chargeReferences: { relation: Model.HasManyRelation, diff --git a/app/models/charge-element.model.js b/app/models/charge-element.model.js index dbbb519645..2bef1e6179 100644 --- a/app/models/charge-element.model.js +++ b/app/models/charge-element.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ChargeElementModel extends BaseModel { - static get tableName () { + static get tableName() { return 'chargeElements' } - static get relationMappings () { + static get relationMappings() { return { chargeReference: { relation: Model.BelongsToOneRelation, diff --git a/app/models/charge-reference.model.js b/app/models/charge-reference.model.js index c339210ea1..3c93472bf7 100644 --- a/app/models/charge-reference.model.js +++ b/app/models/charge-reference.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ChargeReferenceModel extends BaseModel { - static get tableName () { + static get tableName() { return 'chargeReferences' } - static get relationMappings () { + static get relationMappings() { return { billRunVolumes: { relation: Model.HasManyRelation, diff --git a/app/models/charge-version-note.model.js b/app/models/charge-version-note.model.js index 4747a89bd6..a4e2d889f6 100644 --- a/app/models/charge-version-note.model.js +++ b/app/models/charge-version-note.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ChargeVersionNote extends BaseModel { - static get tableName () { + static get tableName() { return 'chargeVersionNotes' } - static get relationMappings () { + static get relationMappings() { return { chargeVersion: { relation: Model.BelongsToOneRelation, diff --git a/app/models/charge-version.model.js b/app/models/charge-version.model.js index 21734a056c..32139f74e0 100644 --- a/app/models/charge-version.model.js +++ b/app/models/charge-version.model.js @@ -10,19 +10,16 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ChargeVersionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'chargeVersions' } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'approvedBy', - 'createdBy' - ] + static get jsonAttributes() { + return ['approvedBy', 'createdBy'] } - static get relationMappings () { + static get relationMappings() { return { billingAccount: { relation: Model.BelongsToOneRelation, @@ -104,40 +101,24 @@ class ChargeVersionModel extends BaseModel { * * @returns {object} */ - static get modifiers () { + static get modifiers() { return { // history modifier fetches all the related records needed to determine history properties, for example, created // at, and created by from the record, plus its note, change reason, and NALD mod logs (where they exist) - history (query) { + history(query) { query - .select([ - 'createdAt', - 'createdBy' - ]) + .select(['createdAt', 'createdBy']) .withGraphFetched('modLogs') .modifyGraph('modLogs', (builder) => { - builder.select([ - 'id', - 'naldDate', - 'note', - 'reasonDescription', - 'userId' - ]) - .orderBy('externalId', 'asc') + builder.select(['id', 'naldDate', 'note', 'reasonDescription', 'userId']).orderBy('externalId', 'asc') }) .withGraphFetched('changeReason') .modifyGraph('changeReason', (builder) => { - builder.select([ - 'id', - 'description' - ]) + builder.select(['id', 'description']) }) .withGraphFetched('chargeVersionNote') .modifyGraph('chargeVersionNote', (builder) => { - builder.select([ - 'id', - 'note' - ]) + builder.select(['id', 'note']) }) } } @@ -164,7 +145,7 @@ class ChargeVersionModel extends BaseModel { * * @returns {Date} the date the 'source' record was created */ - $createdAt () { + $createdAt() { const firstModLog = this._firstModLog() return firstModLog?.naldDate ?? this.createdAt @@ -194,7 +175,7 @@ class ChargeVersionModel extends BaseModel { * @returns {string} the user name of the user that created the 'source' record, else `null` if it cannot be * determined */ - $createdBy () { + $createdBy() { if (this.createdBy) { return this.createdBy.email } @@ -225,7 +206,7 @@ class ChargeVersionModel extends BaseModel { * * @returns {string[]} an array of all the notes in ascending date order taken from the record's history */ - $notes () { + $notes() { if (this.chargeVersionNote) { return [this.chargeVersionNote.note] } @@ -264,7 +245,7 @@ class ChargeVersionModel extends BaseModel { * * @returns {string} the reason the 'source' record was created, else `null` if it cannot be determined */ - $reason () { + $reason() { if (this.changeReason) { return this.changeReason.description } @@ -274,7 +255,7 @@ class ChargeVersionModel extends BaseModel { return firstModLog?.reasonDescription ?? null } - _firstModLog () { + _firstModLog() { if (this.modLogs.length > 0) { return this.modLogs[0] } diff --git a/app/models/company-address.model.js b/app/models/company-address.model.js index d20bad9574..a7eee1a393 100644 --- a/app/models/company-address.model.js +++ b/app/models/company-address.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class CompanyAddressModel extends BaseModel { - static get tableName () { + static get tableName() { return 'companyAddresses' } - static get relationMappings () { + static get relationMappings() { return { address: { relation: Model.BelongsToOneRelation, diff --git a/app/models/company-contact.model.js b/app/models/company-contact.model.js index 8b3a1fc17d..74edfaae3b 100644 --- a/app/models/company-contact.model.js +++ b/app/models/company-contact.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class CompanyContactModel extends BaseModel { - static get tableName () { + static get tableName() { return 'companyContacts' } - static get relationMappings () { + static get relationMappings() { return { company: { relation: Model.BelongsToOneRelation, diff --git a/app/models/company.model.js b/app/models/company.model.js index 036fadc7bd..7557d592bd 100644 --- a/app/models/company.model.js +++ b/app/models/company.model.js @@ -42,11 +42,11 @@ const BaseModel = require('./base.model.js') * */ class CompanyModel extends BaseModel { - static get tableName () { + static get tableName() { return 'companies' } - static get relationMappings () { + static get relationMappings() { return { billingAccountAddresses: { relation: Model.HasManyRelation, diff --git a/app/models/contact.model.js b/app/models/contact.model.js index 1dc336a429..ca40a348b7 100644 --- a/app/models/contact.model.js +++ b/app/models/contact.model.js @@ -37,11 +37,11 @@ const BaseModel = require('./base.model.js') * */ class ContactModel extends BaseModel { - static get tableName () { + static get tableName() { return 'contacts' } - static get relationMappings () { + static get relationMappings() { return { billingAccountAddresses: { relation: Model.HasManyRelation, @@ -83,7 +83,7 @@ class ContactModel extends BaseModel { * * @returns {string} The name for the contact derived from its various parts */ - $name () { + $name() { if (this.contactType === 'department') { return this.department } @@ -104,7 +104,7 @@ class ContactModel extends BaseModel { return onlyPopulatedNameParts.join(' ') } - _determineInitials () { + _determineInitials() { if (this.initials) { return this.initials } diff --git a/app/models/event.model.js b/app/models/event.model.js index becb893d1e..18e59dedf0 100644 --- a/app/models/event.model.js +++ b/app/models/event.model.js @@ -8,7 +8,7 @@ const BaseModel = require('./base.model.js') class EventModel extends BaseModel { - static get tableName () { + static get tableName() { return 'events' } } diff --git a/app/models/financial-agreement.model.js b/app/models/financial-agreement.model.js index dada0cd83e..35f4cc16a2 100644 --- a/app/models/financial-agreement.model.js +++ b/app/models/financial-agreement.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class FinancialAgreementModel extends BaseModel { - static get tableName () { + static get tableName() { return 'financialAgreements' } - static get relationMappings () { + static get relationMappings() { return { licenceAgreements: { relation: Model.HasManyRelation, diff --git a/app/models/group-role.model.js b/app/models/group-role.model.js index 91442bec6e..9da7345896 100644 --- a/app/models/group-role.model.js +++ b/app/models/group-role.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class GroupRoleModel extends BaseModel { - static get tableName () { + static get tableName() { return 'groupRoles' } - static get relationMappings () { + static get relationMappings() { return { role: { relation: Model.BelongsToOneRelation, diff --git a/app/models/group.model.js b/app/models/group.model.js index e541afc13d..d70827c673 100644 --- a/app/models/group.model.js +++ b/app/models/group.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class GroupModel extends BaseModel { - static get tableName () { + static get tableName() { return 'groups' } - static get relationMappings () { + static get relationMappings() { return { groupRoles: { relation: Model.HasManyRelation, diff --git a/app/models/licence-agreement.model.js b/app/models/licence-agreement.model.js index c73c54123e..255f27b840 100644 --- a/app/models/licence-agreement.model.js +++ b/app/models/licence-agreement.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceAgreementModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceAgreements' } - static get relationMappings () { + static get relationMappings() { return { financialAgreement: { relation: Model.HasOneRelation, diff --git a/app/models/licence-document-header.model.js b/app/models/licence-document-header.model.js index 67f9b3d49b..3dd32f08ee 100644 --- a/app/models/licence-document-header.model.js +++ b/app/models/licence-document-header.model.js @@ -32,18 +32,16 @@ const BaseModel = require('./base.model.js') * Welcome to dealing with the legacy database schema! ¯\_(ツ)_/¯ */ class LicenceDocumentHeaderModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceDocumentHeaders' } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'metadata' - ] + static get jsonAttributes() { + return ['metadata'] } - static get relationMappings () { + static get relationMappings() { return { licence: { relation: Model.BelongsToOneRelation, diff --git a/app/models/licence-document-role.model.js b/app/models/licence-document-role.model.js index 9c01e856d5..a6e129ba33 100644 --- a/app/models/licence-document-role.model.js +++ b/app/models/licence-document-role.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceDocumentRoleModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceDocumentRoles' } - static get relationMappings () { + static get relationMappings() { return { address: { relation: Model.BelongsToOneRelation, diff --git a/app/models/licence-document.model.js b/app/models/licence-document.model.js index ea47d5639a..587c16bef1 100644 --- a/app/models/licence-document.model.js +++ b/app/models/licence-document.model.js @@ -26,11 +26,11 @@ const BaseModel = require('./base.model.js') * called `licences`, nor can we think of a better name. So, LicenceDocument it is! ¯\_(ツ)_/¯ */ class LicenceDocumentModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceDocuments' } - static get relationMappings () { + static get relationMappings() { return { licence: { relation: Model.BelongsToOneRelation, diff --git a/app/models/licence-entity-role.model.js b/app/models/licence-entity-role.model.js index 3f25a44bac..ef422ca1f8 100644 --- a/app/models/licence-entity-role.model.js +++ b/app/models/licence-entity-role.model.js @@ -22,11 +22,11 @@ const BaseModel = require('./base.model.js') * From it we can identify the 'entity' which has the role of primary user. */ class LicenceEntityRoleModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceEntityRoles' } - static get relationMappings () { + static get relationMappings() { return { companyEntity: { relation: Model.BelongsToOneRelation, diff --git a/app/models/licence-entity.model.js b/app/models/licence-entity.model.js index 847109f3ac..d6f6c4090f 100644 --- a/app/models/licence-entity.model.js +++ b/app/models/licence-entity.model.js @@ -30,11 +30,11 @@ const BaseModel = require('./base.model.js') * - delete_me (no idea! But only one record has this type so it can be ignored) */ class LicenceEntityModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceEntities' } - static get relationMappings () { + static get relationMappings() { return { licenceEntityRoles: { relation: Model.HasManyRelation, diff --git a/app/models/licence-monitoring-station.model.js b/app/models/licence-monitoring-station.model.js index 1ea0e5c07b..3db5276932 100644 --- a/app/models/licence-monitoring-station.model.js +++ b/app/models/licence-monitoring-station.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceMonitoringStationModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceMonitoringStations' } - static get relationMappings () { + static get relationMappings() { return { monitoringStation: { relation: Model.BelongsToOneRelation, diff --git a/app/models/licence-role.model.js b/app/models/licence-role.model.js index acd572b3b9..c9eff95080 100644 --- a/app/models/licence-role.model.js +++ b/app/models/licence-role.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceRoleModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceRoles' } - static get relationMappings () { + static get relationMappings() { return { companyAddresses: { relation: Model.HasManyRelation, diff --git a/app/models/licence-supplementary-year.model.js b/app/models/licence-supplementary-year.model.js index f2265bbac0..3584a830f1 100644 --- a/app/models/licence-supplementary-year.model.js +++ b/app/models/licence-supplementary-year.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceSupplementaryYearModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceSupplementaryYears' } - static get relationMappings () { + static get relationMappings() { return { licence: { relation: Model.BelongsToOneRelation, diff --git a/app/models/licence-version-purpose-condition-type.model.js b/app/models/licence-version-purpose-condition-type.model.js index 8fec9b7f2a..d5bd0978d0 100644 --- a/app/models/licence-version-purpose-condition-type.model.js +++ b/app/models/licence-version-purpose-condition-type.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceVersionPurposeConditionTypeModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceVersionPurposeConditionTypes' } - static get relationMappings () { + static get relationMappings() { return { licenceVersionPurposeConditions: { relation: Model.HasManyRelation, diff --git a/app/models/licence-version-purpose-condition.model.js b/app/models/licence-version-purpose-condition.model.js index 52a3a4fdbb..0996c34a1e 100644 --- a/app/models/licence-version-purpose-condition.model.js +++ b/app/models/licence-version-purpose-condition.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceVersionPurposeConditionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceVersionPurposeConditions' } - static get relationMappings () { + static get relationMappings() { return { licenceMonitoringStations: { relation: Model.HasManyRelation, diff --git a/app/models/licence-version-purpose-point.model.js b/app/models/licence-version-purpose-point.model.js index f927199109..8a69fae2a8 100644 --- a/app/models/licence-version-purpose-point.model.js +++ b/app/models/licence-version-purpose-point.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceVersionPurposePointModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceVersionPurposePoints' } - static get relationMappings () { + static get relationMappings() { return { licenceVersionPurpose: { relation: Model.BelongsToOneRelation, diff --git a/app/models/licence-version-purpose.model.js b/app/models/licence-version-purpose.model.js index 4ac857da66..04ec28132a 100644 --- a/app/models/licence-version-purpose.model.js +++ b/app/models/licence-version-purpose.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceVersionPurposeModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceVersionPurposes' } - static get relationMappings () { + static get relationMappings() { return { licenceVersion: { relation: Model.BelongsToOneRelation, @@ -93,35 +93,24 @@ class LicenceVersionPurposeModel extends BaseModel { * * @returns {object} */ - static get modifiers () { + static get modifiers() { return { // allPurposes modifier fetches the purpose plus primary and secondary purposes. Built to support determining if // the overall purpose is electricity generation or spray irrigation with two-part tariff. These are needed to // determine what frequency returns should be collected and reported by the licensee - allPurposes (query) { + allPurposes(query) { query .withGraphFetched('purpose') .modifyGraph('purpose', (builder) => { - builder.select([ - 'id', - 'description', - 'legacyId', - 'twoPartTariff' - ]) + builder.select(['id', 'description', 'legacyId', 'twoPartTariff']) }) .withGraphFetched('primaryPurpose') .modifyGraph('primaryPurpose', (builder) => { - builder.select([ - 'id', - 'legacyId' - ]) + builder.select(['id', 'legacyId']) }) .withGraphFetched('secondaryPurpose') .modifyGraph('secondaryPurpose', (builder) => { - builder.select([ - 'id', - 'legacyId' - ]) + builder.select(['id', 'legacyId']) }) } } @@ -139,7 +128,7 @@ class LicenceVersionPurposeModel extends BaseModel { * * @returns {boolean} true if the overall purpose is electricity generation (P-ELC-240 or P-ELC-200) else false */ - $electricityGeneration () { + $electricityGeneration() { if (this.primaryPurpose.legacyId !== 'P') { return false } diff --git a/app/models/licence-version.model.js b/app/models/licence-version.model.js index 07d2de901f..590991394b 100644 --- a/app/models/licence-version.model.js +++ b/app/models/licence-version.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceVersionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licenceVersions' } - static get relationMappings () { + static get relationMappings() { return { licence: { relation: Model.BelongsToOneRelation, @@ -68,23 +68,16 @@ class LicenceVersionModel extends BaseModel { * * @returns {object} */ - static get modifiers () { + static get modifiers() { return { // history modifier fetches all the related records needed to determine history properties, for example, created // at, created by, and notes from the record and its NALD mod logs (where they exist) - history (query) { + history(query) { query .select(['createdAt']) .withGraphFetched('modLogs') .modifyGraph('modLogs', (builder) => { - builder.select([ - 'id', - 'naldDate', - 'note', - 'reasonDescription', - 'userId' - ]) - .orderBy('externalId', 'asc') + builder.select(['id', 'naldDate', 'note', 'reasonDescription', 'userId']).orderBy('externalId', 'asc') }) } } @@ -111,7 +104,7 @@ class LicenceVersionModel extends BaseModel { * * @returns {Date} the date the 'source' record was created */ - $createdAt () { + $createdAt() { const firstModLog = this._firstModLog() return firstModLog?.naldDate ?? this.createdAt @@ -141,7 +134,7 @@ class LicenceVersionModel extends BaseModel { * @returns {string} the user name of the user that created the 'source' record, else `null` if it cannot be * determined */ - $createdBy () { + $createdBy() { const firstModLog = this._firstModLog() return firstModLog?.userId ?? null @@ -162,7 +155,7 @@ class LicenceVersionModel extends BaseModel { * * @returns {string[]} an array of all the notes in ascending date order taken from the record's history */ - $notes () { + $notes() { const notes = [] for (const modLog of this.modLogs) { @@ -189,13 +182,13 @@ class LicenceVersionModel extends BaseModel { * * @returns {string} the reason the 'source' record was created, else `null` if it cannot be determined */ - $reason () { + $reason() { const firstModLog = this._firstModLog() return firstModLog?.reasonDescription ?? null } - _firstModLog () { + _firstModLog() { if (this.modLogs.length > 0) { return this.modLogs[0] } diff --git a/app/models/licence.model.js b/app/models/licence.model.js index 0d5a9ba98e..6b8204ffc6 100644 --- a/app/models/licence.model.js +++ b/app/models/licence.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class LicenceModel extends BaseModel { - static get tableName () { + static get tableName() { return 'licences' } - static get relationMappings () { + static get relationMappings() { return { billLicences: { relation: Model.HasManyRelation, @@ -152,50 +152,32 @@ class LicenceModel extends BaseModel { * * @returns {object} */ - static get modifiers () { + static get modifiers() { return { // currentVersion modifier fetches only the current licence version record for this licence - currentVersion (query) { - query - .withGraphFetched('licenceVersions') - .modifyGraph('licenceVersions', (builder) => { - builder - .select([ - 'id', - 'startDate', - 'status' - ]) - .where('status', 'current') - .orderBy('startDate', 'desc') - .limit(1) - }) + currentVersion(query) { + query.withGraphFetched('licenceVersions').modifyGraph('licenceVersions', (builder) => { + builder.select(['id', 'startDate', 'status']).where('status', 'current').orderBy('startDate', 'desc').limit(1) + }) }, // licenceHolder modifier fetches all the joined records needed to identify the licence holder - licenceHolder (query) { + licenceHolder(query) { query .withGraphFetched('licenceDocument') .modifyGraph('licenceDocument', (builder) => { - builder.select([ - 'id' - ]) + builder.select(['id']) }) .withGraphFetched('licenceDocument.licenceDocumentRoles') .modifyGraph('licenceDocument.licenceDocumentRoles', (builder) => { builder - .select([ - 'licenceDocumentRoles.id' - ]) + .select(['licenceDocumentRoles.id']) .innerJoinRelated('licenceRole') .where('licenceRole.name', 'licenceHolder') .orderBy('licenceDocumentRoles.startDate', 'desc') }) .withGraphFetched('licenceDocument.licenceDocumentRoles.company') .modifyGraph('licenceDocument.licenceDocumentRoles.company', (builder) => { - builder.select([ - 'id', - 'name', - 'type' - ]) + builder.select(['id', 'name', 'type']) }) .withGraphFetched('licenceDocument.licenceDocumentRoles.contact') .modifyGraph('licenceDocument.licenceDocumentRoles.contact', (builder) => { @@ -219,15 +201,10 @@ class LicenceModel extends BaseModel { // // The value itself is stored in `crm.document_header` not `water.licences` which is why we have to pull the // related record. - licenceName (query) { - query - .withGraphFetched('licenceDocumentHeader') - .modifyGraph('licenceDocumentHeader', (builder) => { - builder.select([ - 'id', - 'licenceName' - ]) - }) + licenceName(query) { + query.withGraphFetched('licenceDocumentHeader').modifyGraph('licenceDocumentHeader', (builder) => { + builder.select(['id', 'licenceName']) + }) }, // An external user with an account can register a licence via the external UI. The legacy service will generate a // letter with a code which gets sent to the licence's address. Once they receive it they can enter the code in @@ -244,36 +221,23 @@ class LicenceModel extends BaseModel { // We know, this is mad! It explains why even the previous team were trying to move away from this and had created // `crm_v2`. Unfortunately, this never got sorted so it remains the only means to get from a licence to the user // record which holds the ID of the primary user. - primaryUser (query) { + primaryUser(query) { query .withGraphFetched('licenceDocumentHeader') .modifyGraph('licenceDocumentHeader', (builder) => { - builder.select([ - 'id' - ]) + builder.select(['id']) }) .withGraphFetched('licenceDocumentHeader.licenceEntityRole') .modifyGraph('licenceDocumentHeader.licenceEntityRole', (builder) => { - builder - .select([ - 'id' - ]) - .where('role', 'primary_user') + builder.select(['id']).where('role', 'primary_user') }) .withGraphFetched('licenceDocumentHeader.licenceEntityRole.licenceEntity') .modifyGraph('licenceDocumentHeader.licenceEntityRole.licenceEntity', (builder) => { - builder - .select([ - 'id' - ]) + builder.select(['id']) }) .withGraphFetched('licenceDocumentHeader.licenceEntityRole.licenceEntity.user') .modifyGraph('licenceDocumentHeader.licenceEntityRole.licenceEntity.user', (builder) => { - builder - .select([ - 'id', - 'username' - ]) + builder.select(['id', 'username']) }) } } @@ -296,7 +260,7 @@ class LicenceModel extends BaseModel { * are none (we've found a couple of examples!). Else a `LicenceVersionModel` that is the 'current' version for this * licence */ - $currentVersion () { + $currentVersion() { if (!this.licenceVersions || this.licenceVersions.length === 0) { return null } @@ -328,7 +292,7 @@ class LicenceModel extends BaseModel { * @returns `null` if no 'end' dates are set else an object containing the date, priority and reason for either the * earliest or highest priority end date */ - $ends () { + $ends() { const endDates = [ { date: this.revokedDate, priority: 1, reason: 'revoked' }, { date: this.lapsedDate, priority: 2, reason: 'lapsed' }, @@ -386,7 +350,7 @@ class LicenceModel extends BaseModel { * @returns {(string|null)} `null` if this instance does not have the additional properties needed to determine the * licence holder else the licence holder's name */ - $licenceHolder () { + $licenceHolder() { // Extract the company and contact from the last licenceDocumentRole created. It is assumed that the // `licenceHolder` modifier has been used to get the additional records needed for this. It also ensures in the case // that there is more than one that they are ordered by their start date (DESC) @@ -421,7 +385,7 @@ class LicenceModel extends BaseModel { * @returns {(string|null)} the licence name set by the primary user for the licence if the licence has one and the * additional properties needed to to determine it have been set, else `null` */ - $licenceName () { + $licenceName() { const licenceName = this?.licenceDocumentHeader?.licenceName return licenceName || null @@ -442,7 +406,7 @@ class LicenceModel extends BaseModel { * @returns {(module:UserModel|null)} the primary user if the licence has one and the additional properties needed to * to determine it have been set, else `null` */ - $primaryUser () { + $primaryUser() { const primaryUser = this?.licenceDocumentHeader?.licenceEntityRole?.licenceEntity?.user return primaryUser || null diff --git a/app/models/mod-log.model.js b/app/models/mod-log.model.js index 04162f9dbc..c8790d235c 100644 --- a/app/models/mod-log.model.js +++ b/app/models/mod-log.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ModLogModel extends BaseModel { - static get tableName () { + static get tableName() { return 'modLogs' } - static get relationMappings () { + static get relationMappings() { return { chargeVersion: { relation: Model.BelongsToOneRelation, diff --git a/app/models/monitoring-station.model.js b/app/models/monitoring-station.model.js index 3876108c41..7db101b2db 100644 --- a/app/models/monitoring-station.model.js +++ b/app/models/monitoring-station.model.js @@ -10,18 +10,16 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class MonitoringStationModel extends BaseModel { - static get tableName () { + static get tableName() { return 'monitoringStations' } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'metadata' - ] + static get jsonAttributes() { + return ['metadata'] } - static get relationMappings () { + static get relationMappings() { return { licenceMonitoringStations: { relation: Model.HasManyRelation, diff --git a/app/models/permit-licence.model.js b/app/models/permit-licence.model.js index 7612e9776d..112cdce52c 100644 --- a/app/models/permit-licence.model.js +++ b/app/models/permit-licence.model.js @@ -10,18 +10,16 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class PermitLicenceModel extends BaseModel { - static get tableName () { + static get tableName() { return 'permitLicences' } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'licence_value_data' - ] + static get jsonAttributes() { + return ['licence_value_data'] } - static get relationMappings () { + static get relationMappings() { return { permitLicence: { relation: Model.HasOneRelation, diff --git a/app/models/point.model.js b/app/models/point.model.js index e053236c1e..a320281676 100644 --- a/app/models/point.model.js +++ b/app/models/point.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class PointModel extends BaseModel { - static get tableName () { + static get tableName() { return 'points' } - static get relationMappings () { + static get relationMappings() { return { licenceVersionPurposes: { relation: Model.ManyToManyRelation, @@ -66,7 +66,7 @@ class PointModel extends BaseModel { * * @returns {string} the description of this abstraction point */ - $describe () { + $describe() { let abstractionPoint // If ng4 is populated then we know this point is an 'area' diff --git a/app/models/primary-purpose.model.js b/app/models/primary-purpose.model.js index efbd3d61c3..3eff87c384 100644 --- a/app/models/primary-purpose.model.js +++ b/app/models/primary-purpose.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class PrimaryPurposeModel extends BaseModel { - static get tableName () { + static get tableName() { return 'primaryPurposes' } - static get relationMappings () { + static get relationMappings() { return { licenceVersionPurposes: { relation: Model.HasManyRelation, diff --git a/app/models/purpose.model.js b/app/models/purpose.model.js index de976e60f5..118ba92741 100644 --- a/app/models/purpose.model.js +++ b/app/models/purpose.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class PurposeModel extends BaseModel { - static get tableName () { + static get tableName() { return 'purposes' } - static get relationMappings () { + static get relationMappings() { return { chargeElements: { relation: Model.HasManyRelation, diff --git a/app/models/region.model.js b/app/models/region.model.js index d52282d2fa..5df38050eb 100644 --- a/app/models/region.model.js +++ b/app/models/region.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class RegionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'regions' } - static get relationMappings () { + static get relationMappings() { return { licences: { relation: Model.HasManyRelation, diff --git a/app/models/return-cycle.model.js b/app/models/return-cycle.model.js index d449d14cba..3d1c569df6 100644 --- a/app/models/return-cycle.model.js +++ b/app/models/return-cycle.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReturnCycleModel extends BaseModel { - static get tableName () { + static get tableName() { return 'returnCycles' } - static get relationMappings () { + static get relationMappings() { return { returnLogs: { relation: Model.HasManyRelation, diff --git a/app/models/return-log.model.js b/app/models/return-log.model.js index 812a6283a9..84cc068a3f 100644 --- a/app/models/return-log.model.js +++ b/app/models/return-log.model.js @@ -10,18 +10,16 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReturnLogModel extends BaseModel { - static get tableName () { + static get tableName() { return 'returnLogs' } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'metadata' - ] + static get jsonAttributes() { + return ['metadata'] } - static get relationMappings () { + static get relationMappings() { return { licence: { relation: Model.BelongsToOneRelation, diff --git a/app/models/return-requirement-point.model.js b/app/models/return-requirement-point.model.js index d3b0fd90a9..844c4e4b90 100644 --- a/app/models/return-requirement-point.model.js +++ b/app/models/return-requirement-point.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReturnRequirementPointModel extends BaseModel { - static get tableName () { + static get tableName() { return 'returnRequirementPoints' } - static get relationMappings () { + static get relationMappings() { return { point: { relation: Model.BelongsToOneRelation, diff --git a/app/models/return-requirement-purpose.model.js b/app/models/return-requirement-purpose.model.js index 5fdccfaa74..b37426733a 100644 --- a/app/models/return-requirement-purpose.model.js +++ b/app/models/return-requirement-purpose.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReturnRequirementPurposeModel extends BaseModel { - static get tableName () { + static get tableName() { return 'returnRequirementPurposes' } - static get relationMappings () { + static get relationMappings() { return { primaryPurpose: { relation: Model.BelongsToOneRelation, diff --git a/app/models/return-requirement.model.js b/app/models/return-requirement.model.js index 71ac8f4d0b..e9a41fdbb4 100644 --- a/app/models/return-requirement.model.js +++ b/app/models/return-requirement.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReturnRequirementModel extends BaseModel { - static get tableName () { + static get tableName() { return 'returnRequirements' } - static get relationMappings () { + static get relationMappings() { return { points: { relation: Model.ManyToManyRelation, diff --git a/app/models/return-submission-line.model.js b/app/models/return-submission-line.model.js index 93725d151c..c1adefcb31 100644 --- a/app/models/return-submission-line.model.js +++ b/app/models/return-submission-line.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReturnSubmissionLineModel extends BaseModel { - static get tableName () { + static get tableName() { return 'returnSubmissionLines' } - static get relationMappings () { + static get relationMappings() { return { returnSubmission: { relation: Model.BelongsToOneRelation, diff --git a/app/models/return-submission.model.js b/app/models/return-submission.model.js index e739422d58..11d1bf2311 100644 --- a/app/models/return-submission.model.js +++ b/app/models/return-submission.model.js @@ -10,18 +10,16 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReturnSubmissionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'returnSubmissions' } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'metadata' - ] + static get jsonAttributes() { + return ['metadata'] } - static get relationMappings () { + static get relationMappings() { return { returnLog: { relation: Model.BelongsToOneRelation, diff --git a/app/models/return-version.model.js b/app/models/return-version.model.js index aab0575fc7..a96a245a1c 100644 --- a/app/models/return-version.model.js +++ b/app/models/return-version.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReturnVersionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'returnVersions' } - static get relationMappings () { + static get relationMappings() { return { licence: { relation: Model.BelongsToOneRelation, @@ -65,35 +65,20 @@ class ReturnVersionModel extends BaseModel { * * @returns {object} an object defining modifier functions for this model */ - static get modifiers () { + static get modifiers() { return { // history modifier fetches all the related records needed to determine history properties, for example, created // at, created by, and notes from the record, its user, and its NALD mod logs (where they exist) - history (query) { + history(query) { query - .select([ - 'createdAt', - 'createdBy', - 'notes', - 'reason' - ]) + .select(['createdAt', 'createdBy', 'notes', 'reason']) .withGraphFetched('modLogs') .modifyGraph('modLogs', (builder) => { - builder.select([ - 'id', - 'naldDate', - 'note', - 'reasonDescription', - 'userId' - ]) - .orderBy('externalId', 'asc') + builder.select(['id', 'naldDate', 'note', 'reasonDescription', 'userId']).orderBy('externalId', 'asc') }) .withGraphFetched('user') .modifyGraph('user', (builder) => { - builder.select([ - 'id', - 'username' - ]) + builder.select(['id', 'username']) }) } } @@ -120,7 +105,7 @@ class ReturnVersionModel extends BaseModel { * * @returns {Date} the date the 'source' record was created */ - $createdAt () { + $createdAt() { const firstModLog = this._firstModLog() return firstModLog?.naldDate ?? this.createdAt @@ -150,7 +135,7 @@ class ReturnVersionModel extends BaseModel { * @returns {string} the user name of the user that created the 'source' record, else `null` if it cannot be * determined */ - $createdBy () { + $createdBy() { if (this.user) { return this.user.username } @@ -183,7 +168,7 @@ class ReturnVersionModel extends BaseModel { * * @returns {string[]} an array of all the notes in ascending date order taken from the record's history */ - $notes () { + $notes() { const notes = [] for (const modLog of this.modLogs) { @@ -222,7 +207,7 @@ class ReturnVersionModel extends BaseModel { * * @returns {string} the reason the 'source' record was created, else `null` if it cannot be determined */ - $reason () { + $reason() { if (this.reason) { return this.reason } @@ -232,7 +217,7 @@ class ReturnVersionModel extends BaseModel { return firstModLog?.reasonDescription ?? null } - _firstModLog () { + _firstModLog() { if (this.modLogs.length > 0) { return this.modLogs[0] } diff --git a/app/models/review-charge-element-return.model.js b/app/models/review-charge-element-return.model.js index 45e6170bc2..70a7cb494d 100644 --- a/app/models/review-charge-element-return.model.js +++ b/app/models/review-charge-element-return.model.js @@ -8,7 +8,7 @@ const BaseModel = require('./base.model.js') class ReviewChargeElementReturnModel extends BaseModel { - static get tableName () { + static get tableName() { return 'reviewChargeElementReturns' } } diff --git a/app/models/review-charge-element.model.js b/app/models/review-charge-element.model.js index 2064691d4a..8d4e7ed69e 100644 --- a/app/models/review-charge-element.model.js +++ b/app/models/review-charge-element.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReviewChargeElementModel extends BaseModel { - static get tableName () { + static get tableName() { return 'reviewChargeElements' } - static get relationMappings () { + static get relationMappings() { return { reviewChargeReference: { relation: Model.BelongsToOneRelation, diff --git a/app/models/review-charge-reference.model.js b/app/models/review-charge-reference.model.js index ab3666481b..cced57ae1f 100644 --- a/app/models/review-charge-reference.model.js +++ b/app/models/review-charge-reference.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReviewChargeReferenceModel extends BaseModel { - static get tableName () { + static get tableName() { return 'reviewChargeReferences' } - static get relationMappings () { + static get relationMappings() { return { reviewChargeVersion: { relation: Model.BelongsToOneRelation, diff --git a/app/models/review-charge-version.model.js b/app/models/review-charge-version.model.js index 1963a48ced..854a806a57 100644 --- a/app/models/review-charge-version.model.js +++ b/app/models/review-charge-version.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReviewChargeVersionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'reviewChargeVersions' } - static get relationMappings () { + static get relationMappings() { return { reviewLicence: { relation: Model.BelongsToOneRelation, diff --git a/app/models/review-licence.model.js b/app/models/review-licence.model.js index b7e3636573..dc7c111620 100644 --- a/app/models/review-licence.model.js +++ b/app/models/review-licence.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReviewLicenceModel extends BaseModel { - static get tableName () { + static get tableName() { return 'reviewLicences' } - static get relationMappings () { + static get relationMappings() { return { billRun: { relation: Model.BelongsToOneRelation, diff --git a/app/models/review-return.model.js b/app/models/review-return.model.js index c3b412d54c..c27d190f03 100644 --- a/app/models/review-return.model.js +++ b/app/models/review-return.model.js @@ -10,18 +10,16 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ReviewReturnModel extends BaseModel { - static get tableName () { + static get tableName() { return 'reviewReturns' } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'purposes' - ] + static get jsonAttributes() { + return ['purposes'] } - static get relationMappings () { + static get relationMappings() { return { reviewLicence: { relation: Model.BelongsToOneRelation, diff --git a/app/models/role.model.js b/app/models/role.model.js index a674c34f54..e1aaebefbd 100644 --- a/app/models/role.model.js +++ b/app/models/role.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class RoleModel extends BaseModel { - static get tableName () { + static get tableName() { return 'roles' } - static get relationMappings () { + static get relationMappings() { return { groupRoles: { relation: Model.HasManyRelation, diff --git a/app/models/scheduled-notification.model.js b/app/models/scheduled-notification.model.js index 7136be9f77..ae49b9cc30 100644 --- a/app/models/scheduled-notification.model.js +++ b/app/models/scheduled-notification.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class ScheduledNotificationModel extends BaseModel { - static get tableName () { + static get tableName() { return 'scheduledNotifications' } - static get relationMappings () { + static get relationMappings() { return { event: { relation: Model.HasOneRelation, diff --git a/app/models/secondary-purpose.model.js b/app/models/secondary-purpose.model.js index 0af4f34e22..3a910d011e 100644 --- a/app/models/secondary-purpose.model.js +++ b/app/models/secondary-purpose.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class SecondaryPurposeModel extends BaseModel { - static get tableName () { + static get tableName() { return 'secondaryPurposes' } - static get relationMappings () { + static get relationMappings() { return { licenceVersionPurposes: { relation: Model.HasManyRelation, diff --git a/app/models/session.model.js b/app/models/session.model.js index 6269d3696b..ab1f10962c 100644 --- a/app/models/session.model.js +++ b/app/models/session.model.js @@ -16,15 +16,13 @@ const BaseModel = require('./base.model.js') * > contains these properties they will override the existing properties of the session instance. */ class SessionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'sessions' } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'data' - ] + static get jsonAttributes() { + return ['data'] } /** @@ -46,7 +44,7 @@ class SessionModel extends BaseModel { * * @param {object} _queryContext - Objection.js query context which we do not use */ - $afterFind (_queryContext) { + $afterFind(_queryContext) { for (const [key, value] of Object.entries(this.data)) { this[key] = value } @@ -75,7 +73,7 @@ class SessionModel extends BaseModel { * * @returns {Promise} - the number of affected rows. In our case this will always be 1! */ - async $update () { + async $update() { const { id, createdAt, data, updatedAt, ...currentData } = this return this.$query().patch({ data: currentData }) diff --git a/app/models/source.model.js b/app/models/source.model.js index e83c2baf43..d0ee09f138 100644 --- a/app/models/source.model.js +++ b/app/models/source.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class SourceModel extends BaseModel { - static get tableName () { + static get tableName() { return 'sources' } - static get relationMappings () { + static get relationMappings() { return { points: { relation: Model.HasManyRelation, diff --git a/app/models/transaction.model.js b/app/models/transaction.model.js index 2a6917cb11..0f5d0e0080 100644 --- a/app/models/transaction.model.js +++ b/app/models/transaction.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class TransactionModel extends BaseModel { - static get tableName () { + static get tableName() { return 'transactions' } - static get relationMappings () { + static get relationMappings() { return { chargeReference: { relation: Model.BelongsToOneRelation, @@ -36,13 +36,8 @@ class TransactionModel extends BaseModel { } // Defining which fields contain json allows us to insert an object without needing to stringify it first - static get jsonAttributes () { - return [ - 'abstractionPeriod', - 'grossValuesCalculated', - 'metadata', - 'purposes' - ] + static get jsonAttributes() { + return ['abstractionPeriod', 'grossValuesCalculated', 'metadata', 'purposes'] } } diff --git a/app/models/user-group.model.js b/app/models/user-group.model.js index 3db595f527..5db34250ce 100644 --- a/app/models/user-group.model.js +++ b/app/models/user-group.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class UserGroupModel extends BaseModel { - static get tableName () { + static get tableName() { return 'userGroups' } - static get relationMappings () { + static get relationMappings() { return { group: { relation: Model.BelongsToOneRelation, diff --git a/app/models/user-role.model.js b/app/models/user-role.model.js index 5b29989bb2..70f4278df6 100644 --- a/app/models/user-role.model.js +++ b/app/models/user-role.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class UserRoleModel extends BaseModel { - static get tableName () { + static get tableName() { return 'userRoles' } - static get relationMappings () { + static get relationMappings() { return { role: { relation: Model.BelongsToOneRelation, diff --git a/app/models/user.model.js b/app/models/user.model.js index 1369048b65..8a15466b40 100644 --- a/app/models/user.model.js +++ b/app/models/user.model.js @@ -11,11 +11,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class UserModel extends BaseModel { - static get tableName () { + static get tableName() { return 'users' } - static get relationMappings () { + static get relationMappings() { return { chargeVersionNotes: { relation: Model.HasManyRelation, @@ -84,7 +84,7 @@ class UserModel extends BaseModel { } } - static generateHashedPassword (password) { + static generateHashedPassword(password) { // 10 is the number of salt rounds to perform to generate the salt. The legacy code uses // const salt = bcrypt.genSaltSync(10) to pre-generate the salt before passing it to hashSync(). But this is // intended for operations where you need to hash a large number of values. If you just pass in a number bcrypt will diff --git a/app/models/workflow.model.js b/app/models/workflow.model.js index 2c1b766445..b671cc9416 100644 --- a/app/models/workflow.model.js +++ b/app/models/workflow.model.js @@ -10,11 +10,11 @@ const { Model } = require('objection') const BaseModel = require('./base.model.js') class WorkflowModel extends BaseModel { - static get tableName () { + static get tableName() { return 'workflows' } - static get relationMappings () { + static get relationMappings() { return { licence: { relation: Model.BelongsToOneRelation, diff --git a/app/plugins/airbrake.plugin.js b/app/plugins/airbrake.plugin.js index 1a32ecca9f..905f3d3906 100644 --- a/app/plugins/airbrake.plugin.js +++ b/app/plugins/airbrake.plugin.js @@ -55,7 +55,7 @@ const AirbrakePlugin = { } } -function _notifierArgs () { +function _notifierArgs() { const args = { host: AirbrakeConfig.host, projectId: AirbrakeConfig.projectId, diff --git a/app/plugins/charging-module-token-cache.plugin.js b/app/plugins/charging-module-token-cache.plugin.js index ff36da6fda..89c496e039 100644 --- a/app/plugins/charging-module-token-cache.plugin.js +++ b/app/plugins/charging-module-token-cache.plugin.js @@ -18,27 +18,31 @@ const ChargingModuleTokenCachePlugin = { register: (server, _options) => { // `flags` is passed to our server method automatically by hapi. Overwriting `flags.ttl` in our method lets us // override the cache default expiry time - server.method('getChargingModuleToken', async (flags) => { - const token = await ChargingModuleTokenRequest.send() - - // If the token request was successful it returns an expiry time, so use this to set the cache expiry - // Otherwise, set the expiry time to 0 to avoid caching the unsuccessful attempt - flags.ttl = token.expiresIn ? _setExpiryTime(token.expiresIn) : 0 - - return token - }, { - cache: { - // Hapi requires us to set an expiry time here but we will always override it via `flags.ttl` - expiresIn: ONE_HOUR_IN_MS, - // Hapi requires us to set a timeout value here so we set it to error after one minute. In practice we would - // expect ChargingModuleTokenService to have returned an unsuccessful response which we would gracefully handle - generateTimeout: ONE_MINUTE_IN_MS + server.method( + 'getChargingModuleToken', + async (flags) => { + const token = await ChargingModuleTokenRequest.send() + + // If the token request was successful it returns an expiry time, so use this to set the cache expiry + // Otherwise, set the expiry time to 0 to avoid caching the unsuccessful attempt + flags.ttl = token.expiresIn ? _setExpiryTime(token.expiresIn) : 0 + + return token + }, + { + cache: { + // Hapi requires us to set an expiry time here but we will always override it via `flags.ttl` + expiresIn: ONE_HOUR_IN_MS, + // Hapi requires us to set a timeout value here so we set it to error after one minute. In practice we would + // expect ChargingModuleTokenService to have returned an unsuccessful response which we would gracefully handle + generateTimeout: ONE_MINUTE_IN_MS + } } - }) + ) } } -function _setExpiryTime (expiresIn) { +function _setExpiryTime(expiresIn) { // The expiry time comes to us in seconds so we need to convert it to milliseconds. We also set it to expire 1 minute // before the reported expiry time, to avoid cases where the token is retrieved from the cache but expires before the // request can be made diff --git a/app/plugins/hapi-pino.plugin.js b/app/plugins/hapi-pino.plugin.js index 51b5a5fcd1..78aa7007c1 100644 --- a/app/plugins/hapi-pino.plugin.js +++ b/app/plugins/hapi-pino.plugin.js @@ -25,7 +25,8 @@ const HapiPinoPlugin = () => { ...HapiPinoLogInTestService.go(LogConfig.logInTest), // When not in the production environment we want a 'pretty' version of the JSON to make it easier to grok what // has happened - transport: process.env.NODE_ENV !== 'production' ? { target: 'pino-pretty', options: { colorize: true } } : undefined, + transport: + process.env.NODE_ENV !== 'production' ? { target: 'pino-pretty', options: { colorize: true } } : undefined, // Redact Authorization headers, see https://getpino.io/#/docs/redaction redact: ['req.headers.authorization'], // Adding this here means it will be passed to HapiPinoIgnoreRequestService.go() within the `options` arg when diff --git a/app/plugins/views.plugin.js b/app/plugins/views.plugin.js index f0d93f66d0..96e9ea5cd9 100644 --- a/app/plugins/views.plugin.js +++ b/app/plugins/views.plugin.js @@ -61,7 +61,7 @@ const ViewsPlugin = { * @param {object} options - Vision's `config.compileOptions` property which we assign the Nunjucks Environment instance * to in `prepare()` below */ -function compile (template, options) { +function compile(template, options) { const compiledTemplate = Nunjucks.compile(template, options.environment) return (context) => { @@ -88,7 +88,7 @@ function compile (template, options) { * * @returns {object} the global context for all templates */ -function context (request) { +function context(request) { return { // `assetPath` is referred to in layout.njk as the path to get static assets like client-side javascript assetPath: '/assets', @@ -124,13 +124,10 @@ function context (request) { * * @returns the result of calling `next()` */ -function prepare (config, next) { +function prepare(config, next) { // Tell Nunjucks the paths to where your templates live. We _think_ Nunjucks searches in order of the paths provided. // So, search our templates first before searching in the govuk-frontend package for a template. - const paths = [ - path.join(config.relativeTo, config.path), - 'node_modules/govuk-frontend/' - ] + const paths = [path.join(config.relativeTo, config.path), 'node_modules/govuk-frontend/'] // configure() returns an instance of Nunjucks Environment class ( // see https://mozilla.github.io/nunjucks/api.html#environment) which is the central object for handling templates. @@ -157,7 +154,7 @@ function prepare (config, next) { * * @private */ -function _navigationLinks (auth) { +function _navigationLinks(auth) { if (!auth.isAuthenticated) { return [] } diff --git a/app/presenters/base.presenter.js b/app/presenters/base.presenter.js index 0f5bf59d31..98a3620d98 100644 --- a/app/presenters/base.presenter.js +++ b/app/presenters/base.presenter.js @@ -10,7 +10,7 @@ * * @returns {number} the value divided by 100 */ -function convertPenceToPounds (value) { +function convertPenceToPounds(value) { return value / 100 } @@ -28,7 +28,7 @@ function convertPenceToPounds (value) { * * @returns The bill run title to use in bill run pages */ -function generateBillRunTitle (regionName, batchType, scheme, summer) { +function generateBillRunTitle(regionName, batchType, scheme, summer) { const billRunType = formatBillRunType(batchType, scheme, summer) return `${titleCase(regionName)} ${billRunType.toLowerCase()}` @@ -42,7 +42,7 @@ function generateBillRunTitle (regionName, batchType, scheme, summer) { * * @returns {string} The abstraction date formatted as a 'DD MMMM' string */ -function formatAbstractionDate (abstractionDay, abstractionMonth) { +function formatAbstractionDate(abstractionDay, abstractionMonth) { // NOTE: Because of the unique qualities of Javascript, Year and Day are literal values, month is an index! So, // January is actually 0, February is 1 etc. This is why we are always deducting 1 from the months. const abstractionDate = new Date(1970, abstractionMonth - 1, abstractionDay) @@ -60,7 +60,7 @@ function formatAbstractionDate (abstractionDay, abstractionMonth) { * * @returns {string} The abstraction period formatted as a 'DD MMMM to DD MMMM' string */ -function formatAbstractionPeriod (startDay, startMonth, endDay, endMonth) { +function formatAbstractionPeriod(startDay, startMonth, endDay, endMonth) { const startDate = formatAbstractionDate(startDay, startMonth) const endDate = formatAbstractionDate(endDay, endMonth) @@ -76,7 +76,7 @@ function formatAbstractionPeriod (startDay, startMonth, endDay, endMonth) { * * @returns {string} The bill run type formatted for display */ -function formatBillRunType (batchType, scheme, summer) { +function formatBillRunType(batchType, scheme, summer) { if (batchType !== 'two_part_tariff') { return titleCase(batchType) } @@ -99,7 +99,7 @@ function formatBillRunType (batchType, scheme, summer) { * * @returns {string} The date formatted as a 'DD-MMM-YYYY' string */ -function formatChargingModuleDate (date) { +function formatChargingModuleDate(date) { // The output date format of methods such as toLocaleString() are based on the Unicode CLDR which is subject to // change and cannot be relied on to be consistent: https://github.com/nodejs/node/issues/42030. We therefore // generate the formatted date ourselves. @@ -121,7 +121,7 @@ function formatChargingModuleDate (date) { * * @returns {string} The scheme formatted for display */ -function formatChargeScheme (scheme) { +function formatChargeScheme(scheme) { if (scheme === 'sroc') { return 'Current' } @@ -138,7 +138,7 @@ function formatChargeScheme (scheme) { * * @returns {string} The financial year ending formatted for display */ -function formatFinancialYear (financialYearEnding) { +function formatFinancialYear(financialYearEnding) { return `${financialYearEnding - 1} to ${financialYearEnding}` } @@ -149,7 +149,7 @@ function formatFinancialYear (financialYearEnding) { * * @returns {string} The date formatted as a 'DD MMMM YYYY' string */ -function formatLongDate (date) { +function formatLongDate(date) { return date.toLocaleDateString('en-GB', { year: 'numeric', month: 'long', day: 'numeric' }) } @@ -160,11 +160,15 @@ function formatLongDate (date) { * * @returns {string} The date formatted as a 'DD MMMM YYYY at HH:MM:SS' string */ -function formatLongDateTime (date) { - return date.toLocaleDateString( - 'en-GB', - { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', second: '2-digit' } - ) +function formatLongDateTime(date) { + return date.toLocaleDateString('en-GB', { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit' + }) } /** @@ -184,7 +188,7 @@ function formatLongDateTime (date) { * * @returns {string} The value formatted as a money string with commas and currency symbol plus optional sign */ -function formatMoney (valueInPence, signed = false) { +function formatMoney(valueInPence, signed = false) { // NOTE: The legacy DB stores values signed (which you should never do!) We always abs the valueInPence for 2 reasons // // - in most cases we display credits as £127,768.05 credit @@ -205,7 +209,7 @@ function formatMoney (valueInPence, signed = false) { * * @returns {string} The value converted to pounds and formatted to two decimal places */ -function formatPounds (valueInPence) { +function formatPounds(valueInPence) { const valueInPounds = convertPenceToPounds(valueInPence) return valueInPounds.toFixed(2) @@ -219,10 +223,8 @@ function formatPounds (valueInPence) { * * @returns {string} The number padded with zeros to the specified length */ -function leftPadZeroes (number, length) { - return number - .toString() - .padStart(length, '0') +function leftPadZeroes(number, length) { + return number.toString().padStart(length, '0') } /** @@ -234,7 +236,7 @@ function leftPadZeroes (number, length) { * * @returns {string} The title cased string */ -function sentenceCase (value) { +function sentenceCase(value) { const sentence = value.toLowerCase() return sentence.charAt(0).toUpperCase() + sentence.slice(1) @@ -249,7 +251,7 @@ function sentenceCase (value) { * * @returns {string} The title cased string */ -function titleCase (value) { +function titleCase(value) { const words = value.split(' ') const titleCasedWords = [] diff --git a/app/presenters/bill-licences/remove-bill-licence.presenter.js b/app/presenters/bill-licences/remove-bill-licence.presenter.js index b308e5549a..bb6216ab56 100644 --- a/app/presenters/bill-licences/remove-bill-licence.presenter.js +++ b/app/presenters/bill-licences/remove-bill-licence.presenter.js @@ -21,18 +21,11 @@ const { * * @returns {object} - the prepared bill licence summary data to be passed to the confirm remove a bill licence page */ -function go (billLicence) { +function go(billLicence) { const { id: billLicenceId, bill, licenceRef, transactions } = billLicence - const { - billRunNumber, - billRunStatus, - billRunType, - chargeScheme, - dateCreated, - financialYear, - region - } = _billRunSummary(bill.billRun) + const { billRunNumber, billRunStatus, billRunType, chargeScheme, dateCreated, financialYear, region } = + _billRunSummary(bill.billRun) return { accountName: _accountName(bill.billingAccount), @@ -51,7 +44,7 @@ function go (billLicence) { } } -function _accountName (billingAccount) { +function _accountName(billingAccount) { const accountAddress = billingAccount.billingAccountAddresses[0] if (accountAddress.company) { @@ -61,17 +54,8 @@ function _accountName (billingAccount) { return billingAccount.company.name } -function _billRunSummary (billRun) { - const { - batchType, - billRunNumber, - createdAt, - region, - scheme, - status, - summer, - toFinancialYearEnding - } = billRun +function _billRunSummary(billRun) { + const { batchType, billRunNumber, createdAt, region, scheme, status, summer, toFinancialYearEnding } = billRun return { billRunNumber, @@ -84,11 +68,11 @@ function _billRunSummary (billRun) { } } -function _pageTitle (licenceRef) { +function _pageTitle(licenceRef) { return `You're about to remove ${licenceRef} from the bill run` } -function _total (transactions) { +function _total(transactions) { const transactionTotal = transactions.reduce((total, transaction) => { total += transaction.netAmount diff --git a/app/presenters/bill-licences/view-bill-licence.presenter.js b/app/presenters/bill-licences/view-bill-licence.presenter.js index 053fef5cc1..ab3c631619 100644 --- a/app/presenters/bill-licences/view-bill-licence.presenter.js +++ b/app/presenters/bill-licences/view-bill-licence.presenter.js @@ -19,7 +19,7 @@ const ViewStandardChargeTransactionPresenter = require('./view-standard-charge-t * @returns {object} a formatted representation of the bill licence and its transactions specifically for the * view bill-licence page */ -function go (billLicence) { +function go(billLicence) { const { id: billLicenceId, bill, licenceId, licenceRef, transactions } = billLicence const displayCreditDebitTotals = _displayCreditDebitTotals(bill.billRun) @@ -42,13 +42,13 @@ function go (billLicence) { } } -function _displayCreditDebitTotals (billRun) { +function _displayCreditDebitTotals(billRun) { const { batchType } = billRun return batchType === 'supplementary' } -function _removeLicenceLink (billRun, billLicenceId) { +function _removeLicenceLink(billRun, billLicenceId) { const { status } = billRun if (status !== 'ready') { @@ -58,7 +58,7 @@ function _removeLicenceLink (billRun, billLicenceId) { return `/system/bill-licences/${billLicenceId}/remove` } -function _tableCaption (transactions) { +function _tableCaption(transactions) { const numberOfTransactions = transactions.length if (numberOfTransactions === 1) { @@ -68,7 +68,7 @@ function _tableCaption (transactions) { return `${numberOfTransactions} transactions` } -function _totals (transactions) { +function _totals(transactions) { let creditTotal = 0 let debitTotal = 0 let total = 0 @@ -91,7 +91,7 @@ function _totals (transactions) { } } -function _transactions (transactions) { +function _transactions(transactions) { return transactions.map((transaction) => { const { chargeType } = transaction diff --git a/app/presenters/bill-licences/view-compensation-charge-transaction.presenter.js b/app/presenters/bill-licences/view-compensation-charge-transaction.presenter.js index 8774cf9e71..01b93b0981 100644 --- a/app/presenters/bill-licences/view-compensation-charge-transaction.presenter.js +++ b/app/presenters/bill-licences/view-compensation-charge-transaction.presenter.js @@ -17,7 +17,7 @@ const { formatLongDate, formatMoney } = require('../base.presenter.js') * * @returns {object} a formatted representation of the transaction specifically for the bill-licence page */ -function go (transaction) { +function go(transaction) { if (transaction.scheme === 'sroc') { return _srocContent(transaction) } @@ -25,7 +25,7 @@ function go (transaction) { return _presrocContent(transaction) } -function _agreement (section127Agreement) { +function _agreement(section127Agreement) { if (section127Agreement) { return 'Two-part tariff' } @@ -33,7 +33,7 @@ function _agreement (section127Agreement) { return null } -function _presrocContent (transaction) { +function _presrocContent(transaction) { const { authorisedDays, billableDays, @@ -58,17 +58,8 @@ function _presrocContent (transaction) { } } -function _srocContent (transaction) { - const { - authorisedDays, - billableDays, - chargeType, - endDate, - credit, - netAmount, - startDate, - volume - } = transaction +function _srocContent(transaction) { + const { authorisedDays, billableDays, chargeType, endDate, credit, netAmount, startDate, volume } = transaction return { billableDays: `${billableDays}/${authorisedDays}`, diff --git a/app/presenters/bill-licences/view-minimum-charge-transaction.presenter.js b/app/presenters/bill-licences/view-minimum-charge-transaction.presenter.js index 8a2e4bf63c..2cfb0b51cc 100644 --- a/app/presenters/bill-licences/view-minimum-charge-transaction.presenter.js +++ b/app/presenters/bill-licences/view-minimum-charge-transaction.presenter.js @@ -15,12 +15,8 @@ const { formatMoney } = require('../base.presenter.js') * * @returns {object} a formatted representation of the transaction specifically for the bill-licence page */ -function go (transaction) { - const { - chargeType, - credit, - netAmount - } = transaction +function go(transaction) { + const { chargeType, credit, netAmount } = transaction return { billableDays: '', diff --git a/app/presenters/bill-licences/view-standard-charge-transaction.presenter.js b/app/presenters/bill-licences/view-standard-charge-transaction.presenter.js index 2461302b01..4ba9dec8b0 100644 --- a/app/presenters/bill-licences/view-standard-charge-transaction.presenter.js +++ b/app/presenters/bill-licences/view-standard-charge-transaction.presenter.js @@ -23,7 +23,7 @@ const { * * @returns {object} a formatted representation of the transaction specifically for the bill-licence page */ -function go (transaction) { +function go(transaction) { if (transaction.scheme === 'sroc') { return _srocContent(transaction) } @@ -31,8 +31,11 @@ function go (transaction) { return _presrocContent(transaction) } -function _additionalCharges ( - waterCompanyCharge, waterCompanyChargeValue, supportedSourceChargeValue, supportedSourceName +function _additionalCharges( + waterCompanyCharge, + waterCompanyChargeValue, + supportedSourceChargeValue, + supportedSourceName ) { const charges = [] @@ -51,7 +54,7 @@ function _additionalCharges ( return charges.join(', ') } -function _adjustments ( +function _adjustments( adjustmentFactor, aggregateFactor, winterOnly, @@ -90,7 +93,7 @@ function _adjustments ( return adjustments.join(', ') } -function _agreement (section127Agreement) { +function _agreement(section127Agreement) { if (section127Agreement) { return 'Two-part tariff' } @@ -98,7 +101,7 @@ function _agreement (section127Agreement) { return null } -function _chargeElement (purpose, startDay, startMonth, endDay, endMonth, source, season, loss) { +function _chargeElement(purpose, startDay, startMonth, endDay, endMonth, source, season, loss) { return { purpose: purpose.description, abstractionPeriod: formatAbstractionPeriod(startDay, startMonth, endDay, endMonth), @@ -108,7 +111,7 @@ function _chargeElement (purpose, startDay, startMonth, endDay, endMonth, source } } -function _chargeElements (chargeElements) { +function _chargeElements(chargeElements) { return chargeElements.map((chargeElement) => { const { abstractionPeriodEndDay: endDay, @@ -127,11 +130,11 @@ function _chargeElements (chargeElements) { }) } -function _chargeReference (baselineCharge, chargeCategoryCode) { +function _chargeReference(baselineCharge, chargeCategoryCode) { return `${chargeCategoryCode} (£${formatPounds(baselineCharge)})` } -function _presrocContent (transaction) { +function _presrocContent(transaction) { const { authorisedDays, billableDays, @@ -175,7 +178,7 @@ function _presrocContent (transaction) { } } -function _srocContent (transaction) { +function _srocContent(transaction) { const { adjustmentFactor, aggregateFactor, @@ -211,7 +214,10 @@ function _srocContent (transaction) { return { additionalCharges: _additionalCharges( - waterCompanyCharge, waterCompanyChargeInPence, supportedSourceChargeInPence, supportedSourceName + waterCompanyCharge, + waterCompanyChargeInPence, + supportedSourceChargeInPence, + supportedSourceName ), adjustments: _adjustments( adjustmentFactor, diff --git a/app/presenters/bill-runs/create-bill-run-event.presenter.js b/app/presenters/bill-runs/create-bill-run-event.presenter.js index dfba7d1062..fff7b52bdc 100644 --- a/app/presenters/bill-runs/create-bill-run-event.presenter.js +++ b/app/presenters/bill-runs/create-bill-run-event.presenter.js @@ -12,7 +12,7 @@ * * @returns {object} - the formatted content */ -function go (billRun) { +function go(billRun) { const { batchType, creditNoteCount, diff --git a/app/presenters/bill-runs/create-bill-run.presenter.js b/app/presenters/bill-runs/create-bill-run.presenter.js index 9a9c9c5fc3..a6c26145d7 100644 --- a/app/presenters/bill-runs/create-bill-run.presenter.js +++ b/app/presenters/bill-runs/create-bill-run.presenter.js @@ -15,16 +15,8 @@ * * @returns {object} the formatted response */ -function go (billRun) { - const { - id: billingBatchId, - regionId: region, - scheme, - batchType, - status, - externalId, - errorCode - } = billRun +function go(billRun) { + const { id: billingBatchId, regionId: region, scheme, batchType, status, externalId, errorCode } = billRun return { billingBatchId, diff --git a/app/presenters/bill-runs/empty-bill-run-presenter.js b/app/presenters/bill-runs/empty-bill-run-presenter.js index 9a84531507..7a97dbcd81 100644 --- a/app/presenters/bill-runs/empty-bill-run-presenter.js +++ b/app/presenters/bill-runs/empty-bill-run-presenter.js @@ -21,18 +21,8 @@ const { * * @returns {object} - the prepared bill run data to be passed to the empty bill run page */ -function go (billRun) { - const { - batchType, - billRunNumber, - createdAt, - id, - region, - scheme, - status, - summer, - toFinancialYearEnding - } = billRun +function go(billRun) { + const { batchType, billRunNumber, createdAt, id, region, scheme, status, summer, toFinancialYearEnding } = billRun return { billRunId: id, diff --git a/app/presenters/bill-runs/errored-bill-run-presenter.js b/app/presenters/bill-runs/errored-bill-run-presenter.js index da38ac42ae..b9e1678d65 100644 --- a/app/presenters/bill-runs/errored-bill-run-presenter.js +++ b/app/presenters/bill-runs/errored-bill-run-presenter.js @@ -21,19 +21,9 @@ const { * * @returns {object} - the prepared bill run data to be passed to the errored bill run page */ -function go (billRun) { - const { - batchType, - billRunNumber, - createdAt, - errorCode, - id, - region, - scheme, - status, - summer, - toFinancialYearEnding - } = billRun +function go(billRun) { + const { batchType, billRunNumber, createdAt, errorCode, id, region, scheme, status, summer, toFinancialYearEnding } = + billRun return { billRunId: id, @@ -49,7 +39,7 @@ function go (billRun) { } } -function _errorMessage (errorCode) { +function _errorMessage(errorCode) { const errors = [ { code: 10, message: 'Error when populating the charge versions.' }, { code: 20, message: 'Error when processing the charge versions.' }, diff --git a/app/presenters/bill-runs/index-bill-runs.presenter.js b/app/presenters/bill-runs/index-bill-runs.presenter.js index 1dcd561ed2..813a608341 100644 --- a/app/presenters/bill-runs/index-bill-runs.presenter.js +++ b/app/presenters/bill-runs/index-bill-runs.presenter.js @@ -5,12 +5,7 @@ * @module IndexBillRunsPresenter */ -const { - formatBillRunType, - formatLongDate, - formatMoney, - titleCase -} = require('../base.presenter.js') +const { formatBillRunType, formatLongDate, formatMoney, titleCase } = require('../base.presenter.js') /** * Formats the summary data for each bill run for use in the /bill-runs page @@ -19,20 +14,9 @@ const { * * @returns {object[]} Each bill run summary formatted for use in the `index.njk` template for `/bill-runs` */ -function go (billRuns) { +function go(billRuns) { return billRuns.map((billRun) => { - const { - batchType, - billRunNumber, - createdAt, - id, - netTotal, - numberOfBills, - region, - scheme, - summer, - status - } = billRun + const { batchType, billRunNumber, createdAt, id, netTotal, numberOfBills, region, scheme, summer, status } = billRun return { id, @@ -49,7 +33,7 @@ function go (billRuns) { }) } -function _formatTotal (status, batchType, netTotal) { +function _formatTotal(status, batchType, netTotal) { if (status === 'review' && batchType === 'two_part_tariff') { return '' } @@ -57,7 +41,7 @@ function _formatTotal (status, batchType, netTotal) { return formatMoney(netTotal, true) } -function _link (billRunId, status, scheme) { +function _link(billRunId, status, scheme) { if (['cancel', 'processing', 'queued', 'sending'].includes(status)) { return null } diff --git a/app/presenters/bill-runs/review/authorised.presenter.js b/app/presenters/bill-runs/review/authorised.presenter.js index e3abf13869..d4b2e24f23 100644 --- a/app/presenters/bill-runs/review/authorised.presenter.js +++ b/app/presenters/bill-runs/review/authorised.presenter.js @@ -16,7 +16,7 @@ const { calculateTotalBillableReturns, formatChargePeriod } = require('./base-re * * @returns {object} page date needed for the review charge reference factors page */ -function go (reviewChargeReference) { +function go(reviewChargeReference) { const { amendedAuthorisedVolume, chargeReference, diff --git a/app/presenters/bill-runs/review/base-review.presenter.js b/app/presenters/bill-runs/review/base-review.presenter.js index b72507bc36..c7537efda7 100644 --- a/app/presenters/bill-runs/review/base-review.presenter.js +++ b/app/presenters/bill-runs/review/base-review.presenter.js @@ -12,7 +12,7 @@ const DetermineAbstractionPeriodService = require('../../../services/bill-runs/d * * @returns {string} the sum of allocated volume against all review charge elements without loss of precision */ -function calculateTotalBillableReturns (reviewChargeElements) { +function calculateTotalBillableReturns(reviewChargeElements) { return reviewChargeElements.reduce((total, reviewChargeElement) => { const { amendedAllocated } = reviewChargeElement @@ -27,7 +27,7 @@ function calculateTotalBillableReturns (reviewChargeElements) { * * @returns {string} the relative URL the view template should use to link to the return */ -function determineReturnLink (reviewReturn) { +function determineReturnLink(reviewReturn) { const { returnId, returnStatus } = reviewReturn if (['due', 'received'].includes(returnStatus)) { @@ -56,7 +56,7 @@ function determineReturnLink (reviewReturn) { * * @returns {string[]} the additional charges (if present) formatted as a string for display */ -function formatAdditionalCharges (chargeReference) { +function formatAdditionalCharges(chargeReference) { const { supportedSourceName, waterCompanyCharge } = chargeReference const additionalCharges = [] @@ -93,7 +93,7 @@ function formatAdditionalCharges (chargeReference) { * * @returns {string[]} the adjustments (if present) formatted as a string for display */ -function formatAdjustments (reviewChargeReference) { +function formatAdjustments(reviewChargeReference) { const adjustments = [] if (reviewChargeReference.abatementAgreement && reviewChargeReference.abatementAgreement !== 1) { @@ -123,7 +123,7 @@ function formatAdjustments (reviewChargeReference) { * * @returns {string} The review charge version's charge period formatted as a 'DD MMMM YYYY to DD MMMM YYYY' string */ -function formatChargePeriod (reviewChargeVersion) { +function formatChargePeriod(reviewChargeVersion) { const chargePeriod = _chargePeriod(reviewChargeVersion) return `${formatLongDate(chargePeriod.startDate)} to ${formatLongDate(chargePeriod.endDate)}` @@ -150,15 +150,11 @@ function formatChargePeriod (reviewChargeVersion) { * @returns {string[]} an array containing the review charge element's charge period(s) formatted as 'DD MMMM YYYY to DD * MMMM YYYY' */ -function formatChargePeriods (reviewChargeElement, chargePeriod = null) { +function formatChargePeriods(reviewChargeElement, chargePeriod = null) { const { chargeElement, reviewChargeReference } = reviewChargeElement - const { - abstractionPeriodStartDay, - abstractionPeriodStartMonth, - abstractionPeriodEndDay, - abstractionPeriodEndMonth - } = chargeElement + const { abstractionPeriodStartDay, abstractionPeriodStartMonth, abstractionPeriodEndDay, abstractionPeriodEndMonth } = + chargeElement if (!chargePeriod) { chargePeriod = _chargePeriod(reviewChargeReference.reviewChargeVersion) @@ -192,7 +188,7 @@ function formatChargePeriods (reviewChargeElement, chargePeriod = null) { * * @returns {string[]} the issues as a string array, else an empty array if issues is equal to '' */ -function formatIssues (issues) { +function formatIssues(issues) { if (issues === '') { return [] } @@ -214,7 +210,7 @@ function formatIssues (issues) { * * @returns {string} the return's status formatted for display */ -function formatReturnStatus (reviewReturn) { +function formatReturnStatus(reviewReturn) { const { returnStatus, underQuery } = reviewReturn if (returnStatus === 'due') { @@ -235,7 +231,7 @@ function formatReturnStatus (reviewReturn) { * * @returns the return's totals formatted for display */ -function formatReturnTotals (reviewReturn) { +function formatReturnTotals(reviewReturn) { const { allocated, quantity, returnStatus } = reviewReturn if (['due', 'received'].includes(returnStatus)) { @@ -245,7 +241,7 @@ function formatReturnTotals (reviewReturn) { return `${allocated} ML / ${quantity} ML` } -function _chargePeriod (reviewChargeVersion) { +function _chargePeriod(reviewChargeVersion) { const { chargePeriodStartDate, chargePeriodEndDate } = reviewChargeVersion return { startDate: chargePeriodStartDate, endDate: chargePeriodEndDate } diff --git a/app/presenters/bill-runs/review/edit.presenter.js b/app/presenters/bill-runs/review/edit.presenter.js index f3684a6dbc..bf4698572f 100644 --- a/app/presenters/bill-runs/review/edit.presenter.js +++ b/app/presenters/bill-runs/review/edit.presenter.js @@ -18,7 +18,7 @@ const { formatChargePeriod, formatChargePeriods } = require('./base-review.prese * * @returns {object} the prepared bill run and charge element data to be passed to the edit billable returns page */ -function go (reviewChargeElement, elementIndex) { +function go(reviewChargeElement, elementIndex) { const { amendedAllocated: billableReturns, chargeElement, @@ -47,7 +47,7 @@ function go (reviewChargeElement, elementIndex) { * * @private */ -function _authorisedQuantity (reviewChargeElement) { +function _authorisedQuantity(reviewChargeElement) { const { chargeElement, reviewChargeReference } = reviewChargeElement return Math.min(chargeElement.authorisedAnnualQuantity, reviewChargeReference.amendedAuthorisedVolume) diff --git a/app/presenters/bill-runs/review/factors.presenter.js b/app/presenters/bill-runs/review/factors.presenter.js index 5a560c9484..296d8c0de4 100644 --- a/app/presenters/bill-runs/review/factors.presenter.js +++ b/app/presenters/bill-runs/review/factors.presenter.js @@ -16,7 +16,7 @@ const { formatAdditionalCharges, formatChargePeriod, formatAdjustments } = requi * * @returns {object} page date needed for the review charge reference factors page */ -function go (reviewChargeReference) { +function go(reviewChargeReference) { const { amendedAggregate, amendedChargeAdjustment, diff --git a/app/presenters/bill-runs/review/remove.presenter.js b/app/presenters/bill-runs/review/remove.presenter.js index c44e9800bb..e723fa6f5b 100644 --- a/app/presenters/bill-runs/review/remove.presenter.js +++ b/app/presenters/bill-runs/review/remove.presenter.js @@ -15,7 +15,7 @@ const { formatFinancialYear, formatLongDate } = require('../../base.presenter.js * * @returns {object} page date needed for the remove review licence confirmation page */ -function go (reviewLicence) { +function go(reviewLicence) { const { billRun, id: reviewLicenceId, licenceRef } = reviewLicence const { billRunNumber, createdAt, region, status, toFinancialYearEnding } = billRun diff --git a/app/presenters/bill-runs/review/review-bill-run.presenter.js b/app/presenters/bill-runs/review/review-bill-run.presenter.js index 811da853dd..cd5592ec52 100644 --- a/app/presenters/bill-runs/review/review-bill-run.presenter.js +++ b/app/presenters/bill-runs/review/review-bill-run.presenter.js @@ -24,7 +24,7 @@ const { formatLongDate } = require('../../base.presenter.js') * * @returns {object} The prepared bill run,licence and filter data to be passed to the review page */ -function go (billRun, filterIssues, filterLicenceHolderNumber, filterLicenceStatus, filterProgress, licences) { +function go(billRun, filterIssues, filterLicenceHolderNumber, filterLicenceStatus, filterProgress, licences) { const preparedLicences = _prepareLicences(licences) const preparedBillRun = _prepareBillRun(billRun, preparedLicences) @@ -50,7 +50,7 @@ function go (billRun, filterIssues, filterLicenceHolderNumber, filterLicenceStat * * @private */ -function _prepareIssues (filterIssues) { +function _prepareIssues(filterIssues) { return { absOutsidePeriod: filterIssues.includes('abs-outside-period'), aggregateFactor: filterIssues.includes('aggregate-factor'), @@ -68,7 +68,7 @@ function _prepareIssues (filterIssues) { } } -function _prepareLicences (licences) { +function _prepareLicences(licences) { const preparedLicences = [] for (const licence of licences) { @@ -85,7 +85,7 @@ function _prepareLicences (licences) { return preparedLicences } -function _prepareBillRun (billRun, preparedLicences) { +function _prepareBillRun(billRun, preparedLicences) { return { billRunId: billRun.id, region: billRun.region.displayName, @@ -100,7 +100,7 @@ function _prepareBillRun (billRun, preparedLicences) { } } -function _prepareReviewMessage (numberOfLicencesToReview) { +function _prepareReviewMessage(numberOfLicencesToReview) { let numberOfLicences if (numberOfLicencesToReview === 0) { @@ -114,14 +114,14 @@ function _prepareReviewMessage (numberOfLicencesToReview) { return `You need to review ${numberOfLicences} with returns data issues. You can then continue and send the bill run.` } -function _financialYear (financialYearEnding) { +function _financialYear(financialYearEnding) { const startYear = financialYearEnding - 1 const endYear = financialYearEnding return `${startYear} to ${endYear}` } -function _getIssueOnLicence (issues) { +function _getIssueOnLicence(issues) { // if there is more than one issue the issues will be separated by a comma if (issues.includes(',')) { return 'Multiple Issues' diff --git a/app/presenters/bill-runs/review/review-charge-element.presenter.js b/app/presenters/bill-runs/review/review-charge-element.presenter.js index 7aad97b289..5c290b1519 100644 --- a/app/presenters/bill-runs/review/review-charge-element.presenter.js +++ b/app/presenters/bill-runs/review/review-charge-element.presenter.js @@ -25,7 +25,7 @@ const { * * @returns {object} page date needed for the review charge element page */ -function go (reviewChargeElement, elementIndex) { +function go(reviewChargeElement, elementIndex) { const { amendedAllocated: billableReturns, chargeElement, @@ -55,7 +55,7 @@ function go (reviewChargeElement, elementIndex) { } } -function _matchedReturns (reviewReturns) { +function _matchedReturns(reviewReturns) { return reviewReturns.map((reviewReturn) => { const { description, endDate, issues, purposes, returnLog, returnId, returnReference, startDate } = reviewReturn const { periodStartDay, periodStartMonth, periodEndDay, periodEndMonth } = returnLog diff --git a/app/presenters/bill-runs/review/review-charge-reference.presenter.js b/app/presenters/bill-runs/review/review-charge-reference.presenter.js index 42691310df..6eff192643 100644 --- a/app/presenters/bill-runs/review/review-charge-reference.presenter.js +++ b/app/presenters/bill-runs/review/review-charge-reference.presenter.js @@ -21,7 +21,7 @@ const { * * @returns {object} page date needed for the review charge reference page */ -function go (reviewChargeReference) { +function go(reviewChargeReference) { const { amendedAuthorisedVolume, chargeReference, @@ -49,13 +49,8 @@ function go (reviewChargeReference) { } } -function _factors (reviewChargeReference, canAmend) { - const { - aggregate, - amendedAggregate, - amendedChargeAdjustment, - chargeAdjustment - } = reviewChargeReference +function _factors(reviewChargeReference, canAmend) { + const { aggregate, amendedAggregate, amendedChargeAdjustment, chargeAdjustment } = reviewChargeReference const factors = [] @@ -67,10 +62,10 @@ function _factors (reviewChargeReference, canAmend) { return factors } -function _canAmend (reviewChargeReference) { +function _canAmend(reviewChargeReference) { const { aggregate, chargeAdjustment } = reviewChargeReference - return (aggregate !== 1 || chargeAdjustment !== 1) + return aggregate !== 1 || chargeAdjustment !== 1 } module.exports = { diff --git a/app/presenters/bill-runs/review/review-licence.presenter.js b/app/presenters/bill-runs/review/review-licence.presenter.js index bcd06cc9ae..3b51de5a78 100644 --- a/app/presenters/bill-runs/review/review-licence.presenter.js +++ b/app/presenters/bill-runs/review/review-licence.presenter.js @@ -24,7 +24,7 @@ const { * * @returns {object} page date needed for the review licence page */ -function go (reviewLicence) { +function go(reviewLicence) { const { billRun, id: reviewLicenceId, @@ -55,7 +55,7 @@ function go (reviewLicence) { } } -function _billingAccountDetails (billingAccount) { +function _billingAccountDetails(billingAccount) { return { billingAccountId: billingAccount.id, accountNumber: billingAccount.accountNumber, @@ -65,7 +65,7 @@ function _billingAccountDetails (billingAccount) { } } -function _chargeElements (reviewChargeElements, chargePeriod) { +function _chargeElements(reviewChargeElements, chargePeriod) { const numberOfElements = reviewChargeElements.length return reviewChargeElements.map((reviewChargeElement, index) => { @@ -86,7 +86,7 @@ function _chargeElements (reviewChargeElements, chargePeriod) { }) } -function _chargeElementReturnVolumes (reviewReturns) { +function _chargeElementReturnVolumes(reviewReturns) { return reviewReturns.map((reviewReturn) => { const { quantity, returnReference, returnStatus } = reviewReturn @@ -98,7 +98,7 @@ function _chargeElementReturnVolumes (reviewReturns) { }) } -function _chargeReferences (reviewChargeReferences, chargePeriod) { +function _chargeReferences(reviewChargeReferences, chargePeriod) { return reviewChargeReferences.map((reviewChargeReference) => { const { amendedAuthorisedVolume, chargeReference, reviewChargeElements, id } = reviewChargeReference const totalAllocated = calculateTotalBillableReturns(reviewChargeElements) @@ -115,7 +115,7 @@ function _chargeReferences (reviewChargeReferences, chargePeriod) { }) } -function _chargeReferenceLinkTitle (reviewChargeReference) { +function _chargeReferenceLinkTitle(reviewChargeReference) { const { aggregate, chargeAdjustment } = reviewChargeReference if (aggregate !== 1 || chargeAdjustment !== 1) { @@ -125,7 +125,7 @@ function _chargeReferenceLinkTitle (reviewChargeReference) { return 'View details' } -function _chargeVersionDescription (reviewChargeReferences) { +function _chargeVersionDescription(reviewChargeReferences) { const referenceCount = reviewChargeReferences.length const elementCount = reviewChargeReferences.reduce((total, reviewChargeReference) => { return total + reviewChargeReference.reviewChargeElements.length @@ -137,7 +137,7 @@ function _chargeVersionDescription (reviewChargeReferences) { return `${referenceCount} charge ${referenceText} with ${elementCount} two-part tariff charge ${elementText}` } -function _chargeVersions (reviewChargeVersions, toFinancialYearEnding) { +function _chargeVersions(reviewChargeVersions, toFinancialYearEnding) { return reviewChargeVersions.map((reviewChargeVersion) => { const { chargePeriodStartDate, chargePeriodEndDate, chargeVersion, reviewChargeReferences } = reviewChargeVersion const chargePeriod = { startDate: chargePeriodStartDate, endDate: chargePeriodEndDate } @@ -152,7 +152,7 @@ function _chargeVersions (reviewChargeVersions, toFinancialYearEnding) { }) } -function _elementsInReview (reviewChargeVersions) { +function _elementsInReview(reviewChargeVersions) { // If the licence we are reviewing is linked to at least one charge element (via charge version -> charge reference -> // charge element) that has a status of 'review' then the licence is said to have a status of 'REVIEW' return reviewChargeVersions.some((reviewChargeVersion) => { @@ -168,7 +168,7 @@ function _elementsInReview (reviewChargeVersions) { }) } -function _formatReviewReturns (reviewReturns) { +function _formatReviewReturns(reviewReturns) { const matchedReturns = [] const unmatchedReturns = [] diff --git a/app/presenters/bill-runs/setup/create.presenter.js b/app/presenters/bill-runs/setup/create.presenter.js index 4582a0ad94..089f1324f2 100644 --- a/app/presenters/bill-runs/setup/create.presenter.js +++ b/app/presenters/bill-runs/setup/create.presenter.js @@ -23,18 +23,8 @@ const LAST_PRESROC_YEAR = 2022 * * @returns {object} - The data formatted for the view template */ -function go (session, billRun) { - const { - batchType, - billRunNumber, - createdAt, - id, - region, - scheme, - status, - summer, - toFinancialYearEnding - } = billRun +function go(session, billRun) { + const { batchType, billRunNumber, createdAt, id, region, scheme, status, summer, toFinancialYearEnding } = billRun const billRunType = formatBillRunType(batchType, scheme, summer) @@ -53,7 +43,7 @@ function go (session, billRun) { } } -function _backLink (session) { +function _backLink(session) { const { type, year } = session if (!type.startsWith('two_part')) { @@ -67,7 +57,7 @@ function _backLink (session) { return `/system/bill-runs/setup/${session.id}/season` } -function _billRunLink (billRun) { +function _billRunLink(billRun) { const { id: billRunId, status, toFinancialYearEnding } = billRun if (status !== 'review') { @@ -81,7 +71,7 @@ function _billRunLink (billRun) { return `/billing/batch/${billRunId}/two-part-tariff-review` } -function _warningMessage (billRunType, status) { +function _warningMessage(billRunType, status) { if (billRunType === 'Supplementary') { return 'You need to confirm or cancel this bill run before you can create a new one' } diff --git a/app/presenters/bill-runs/setup/region.presenter.js b/app/presenters/bill-runs/setup/region.presenter.js index 0d53e1b81b..f2e6fddd21 100644 --- a/app/presenters/bill-runs/setup/region.presenter.js +++ b/app/presenters/bill-runs/setup/region.presenter.js @@ -13,7 +13,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, regions) { +function go(session, regions) { return { sessionId: session.id, regions, diff --git a/app/presenters/bill-runs/setup/season.presenter.js b/app/presenters/bill-runs/setup/season.presenter.js index aabd286979..05a0583799 100644 --- a/app/presenters/bill-runs/setup/season.presenter.js +++ b/app/presenters/bill-runs/setup/season.presenter.js @@ -12,7 +12,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session) { +function go(session) { return { sessionId: session.id, selectedSeason: session.season ? session.season : null diff --git a/app/presenters/bill-runs/setup/type.presenter.js b/app/presenters/bill-runs/setup/type.presenter.js index f5c6362cd9..5e8a1cb23f 100644 --- a/app/presenters/bill-runs/setup/type.presenter.js +++ b/app/presenters/bill-runs/setup/type.presenter.js @@ -12,7 +12,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session) { +function go(session) { return { sessionId: session.id, selectedType: session.type ? session.type : null diff --git a/app/presenters/bill-runs/setup/year.presenter.js b/app/presenters/bill-runs/setup/year.presenter.js index 19eb1cb7c3..a1c920ceeb 100644 --- a/app/presenters/bill-runs/setup/year.presenter.js +++ b/app/presenters/bill-runs/setup/year.presenter.js @@ -14,7 +14,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (licenceSupplementaryYears, session) { +function go(licenceSupplementaryYears, session) { const selectedYear = session.year ? session.year : null let financialYearsData = [] @@ -35,7 +35,7 @@ function go (licenceSupplementaryYears, session) { } } -function _financialYearsData (licenceSupplementaryYears, selectedYear) { +function _financialYearsData(licenceSupplementaryYears, selectedYear) { const financialYearsData = [] if (licenceSupplementaryYears.length > 0) { @@ -53,7 +53,7 @@ function _financialYearsData (licenceSupplementaryYears, selectedYear) { return financialYearsData } -function _tptAnnualFinancialYearsData (selectedYear) { +function _tptAnnualFinancialYearsData(selectedYear) { return [ { text: '2023 to 2024', value: 2024, checked: selectedYear === '2024' }, { text: '2022 to 2023', value: 2023, checked: selectedYear === '2023' }, diff --git a/app/presenters/bill-runs/view-bill-run.presenter.js b/app/presenters/bill-runs/view-bill-run.presenter.js index 4180ed0efa..0a82bd99ac 100644 --- a/app/presenters/bill-runs/view-bill-run.presenter.js +++ b/app/presenters/bill-runs/view-bill-run.presenter.js @@ -23,7 +23,7 @@ const { * * @returns {object} - the prepared bill run data to be passed to the view bill run page */ -function go (billRun, billSummaries) { +function go(billRun, billSummaries) { const { batchType, billRunNumber, @@ -65,7 +65,7 @@ function go (billRun, billSummaries) { } } -function _billsCount (creditsCount, debitsCount, billRunType, billSummaries) { +function _billsCount(creditsCount, debitsCount, billRunType, billSummaries) { const total = creditsCount + debitsCount // NOTE: A bill run wouldn't exist if there was just a single zero value bill on it. So, we can safely assume if the @@ -93,7 +93,7 @@ function _billsCount (creditsCount, debitsCount, billRunType, billSummaries) { return `${total} ${billRunType} bills and ${numberOfZeroValueBills} zero value bills` } -function _billRunTotal (valueInPence) { +function _billRunTotal(valueInPence) { const valueAsMoney = formatMoney(valueInPence) if (valueInPence < 0) { @@ -103,7 +103,7 @@ function _billRunTotal (valueInPence) { return valueAsMoney } -function _creditsCount (count) { +function _creditsCount(count) { if (count === 1) { return '1 credit note' } @@ -111,7 +111,7 @@ function _creditsCount (count) { return `${count} credit notes` } -function _debitsCount (count) { +function _debitsCount(count) { if (count === 1) { return '1 invoice' } @@ -119,7 +119,7 @@ function _debitsCount (count) { return `${count} invoices` } -function _displayCreditDebitTotals (billRun) { +function _displayCreditDebitTotals(billRun) { const { batchType } = billRun return batchType === 'supplementary' diff --git a/app/presenters/bill-runs/view-bill-summaries.presenter.js b/app/presenters/bill-runs/view-bill-summaries.presenter.js index 8b0fce30e6..e8cc13e0d4 100644 --- a/app/presenters/bill-runs/view-bill-summaries.presenter.js +++ b/app/presenters/bill-runs/view-bill-summaries.presenter.js @@ -16,7 +16,7 @@ const { formatMoney } = require('../base.presenter.js') * are water company bills, they are grouped under 'water-companies'. If there are other abstractor bills, they are * grouped under 'other-abstractors'. */ -function go (billSummaries) { +function go(billSummaries) { const waterCompanies = _waterCompanies(billSummaries) const otherAbstractors = _otherAbstractors(billSummaries) @@ -41,17 +41,9 @@ function go (billSummaries) { return billGroups } -function _bills (summaries) { +function _bills(summaries) { return summaries.map((summary) => { - const { - agentName, - allLicences, - id, - companyName, - financialYearEnding, - accountNumber, - netAmount - } = summary + const { agentName, allLicences, id, companyName, financialYearEnding, accountNumber, netAmount } = summary const licences = allLicences.split(',') @@ -67,7 +59,7 @@ function _bills (summaries) { }) } -function _billingContact (agentName, companyName) { +function _billingContact(agentName, companyName) { if (agentName) { return agentName } @@ -75,7 +67,7 @@ function _billingContact (agentName, companyName) { return companyName } -function _caption (bills, isWaterCompany) { +function _caption(bills, isWaterCompany) { const numberOfRows = bills.length if (numberOfRows === 1) { @@ -85,7 +77,7 @@ function _caption (bills, isWaterCompany) { return isWaterCompany ? `${numberOfRows} water companies` : `${numberOfRows} other abstractors` } -function _otherAbstractors (summaries) { +function _otherAbstractors(summaries) { const filteredSummaries = summaries.filter((summary) => { return !summary.waterCompany }) @@ -93,7 +85,7 @@ function _otherAbstractors (summaries) { return _bills(filteredSummaries) } -function _waterCompanies (summaries) { +function _waterCompanies(summaries) { const filteredSummaries = summaries.filter((summary) => { return summary.waterCompany }) diff --git a/app/presenters/bill-runs/view-cancel-bill-run.presenter.js b/app/presenters/bill-runs/view-cancel-bill-run.presenter.js index fdd4cec16f..0e3018e0a3 100644 --- a/app/presenters/bill-runs/view-cancel-bill-run.presenter.js +++ b/app/presenters/bill-runs/view-cancel-bill-run.presenter.js @@ -20,18 +20,8 @@ const { * * @returns {object} - the prepared bill run data to be passed to the cancel bill run confirmation page */ -function go (billRun) { - const { - batchType, - billRunNumber, - createdAt, - id, - region, - scheme, - status, - summer, - toFinancialYearEnding - } = billRun +function go(billRun) { + const { batchType, billRunNumber, createdAt, id, region, scheme, status, summer, toFinancialYearEnding } = billRun return { backLink: _backLink(id, scheme, status), @@ -46,7 +36,7 @@ function go (billRun) { } } -function _backLink (id, scheme, status) { +function _backLink(id, scheme, status) { if (status === 'review') { if (scheme === 'alcs') { return `/billing/batch/${id}/two-part-tariff-review` diff --git a/app/presenters/bill-runs/view-send-bill-run.presenter.js b/app/presenters/bill-runs/view-send-bill-run.presenter.js index 9ada0b3c64..e06180ceee 100644 --- a/app/presenters/bill-runs/view-send-bill-run.presenter.js +++ b/app/presenters/bill-runs/view-send-bill-run.presenter.js @@ -20,18 +20,8 @@ const { * * @returns {object} - the prepared bill run data to be passed to the send bill run confirmation page */ -function go (billRun) { - const { - batchType, - billRunNumber, - createdAt, - id, - region, - scheme, - status, - summer, - toFinancialYearEnding - } = billRun +function go(billRun) { + const { batchType, billRunNumber, createdAt, id, region, scheme, status, summer, toFinancialYearEnding } = billRun return { billRunId: id, diff --git a/app/presenters/bills/remove-bill.presenter.js b/app/presenters/bills/remove-bill.presenter.js index 704ec4e4ea..67fdc9cdb6 100644 --- a/app/presenters/bills/remove-bill.presenter.js +++ b/app/presenters/bills/remove-bill.presenter.js @@ -21,18 +21,11 @@ const { * * @returns {object} - the prepared bill summary data to be passed to the confirm remove a bill page */ -function go (bill) { +function go(bill) { const { id: billId, billingAccount, billLicences, billRun } = bill - const { - billRunNumber, - billRunStatus, - billRunType, - chargeScheme, - dateCreated, - financialYear, - region - } = _billRunSummary(billRun) + const { billRunNumber, billRunStatus, billRunType, chargeScheme, dateCreated, financialYear, region } = + _billRunSummary(billRun) const accountNumber = billingAccount.accountNumber const licences = _licences(billLicences) @@ -57,17 +50,8 @@ function go (bill) { } } -function _billRunSummary (billRun) { - const { - batchType, - billRunNumber, - createdAt, - region, - scheme, - status, - summer, - toFinancialYearEnding - } = billRun +function _billRunSummary(billRun) { + const { batchType, billRunNumber, createdAt, region, scheme, status, summer, toFinancialYearEnding } = billRun return { billRunNumber, @@ -80,7 +64,7 @@ function _billRunSummary (billRun) { } } -function _licences (billLicences) { +function _licences(billLicences) { const licenceReferences = billLicences.map((billLicence) => { return billLicence.licenceRef }) @@ -88,11 +72,11 @@ function _licences (billLicences) { return licenceReferences.join(', ') } -function _pageTitle (accountName) { +function _pageTitle(accountName) { return `You're about to remove the bill for ${accountName} from the bill run` } -function _supplementaryMessage (licencesText) { +function _supplementaryMessage(licencesText) { return `The ${licencesText.toLowerCase()} will go into the next supplementary bill run.` } diff --git a/app/presenters/bills/view-bill.presenter.js b/app/presenters/bills/view-bill.presenter.js index 3ec2547f6a..1f5466a01b 100644 --- a/app/presenters/bills/view-bill.presenter.js +++ b/app/presenters/bills/view-bill.presenter.js @@ -5,11 +5,7 @@ * @module ViewBillPresenter */ -const { - formatLongDate, - formatMoney, - titleCase -} = require('../base.presenter.js') +const { formatLongDate, formatMoney, titleCase } = require('../base.presenter.js') /** * Formats bill and billing account data ready for presenting in the single licence bill and multi licence bill pages @@ -19,7 +15,7 @@ const { * * @returns {object} page data formatted for the view template */ -function go (bill, billingAccount) { +function go(bill, billingAccount) { const { billRun } = bill const formattedBill = { @@ -51,7 +47,7 @@ function go (bill, billingAccount) { return formattedBill } -function _billRunType (billRun) { +function _billRunType(billRun) { const { batchType, summer, scheme } = billRun if (batchType !== 'two_part_tariff') { @@ -69,7 +65,7 @@ function _billRunType (billRun) { return 'Two-part tariff winter and all year' } -function _creditsTotal (bill, billRun) { +function _creditsTotal(bill, billRun) { const { creditNoteValue, netAmount } = bill const { source } = billRun @@ -84,7 +80,7 @@ function _creditsTotal (bill, billRun) { return '£0.00' } -function _debitsTotal (bill, billRun) { +function _debitsTotal(bill, billRun) { const { invoiceValue, netAmount } = bill const { source } = billRun @@ -99,19 +95,19 @@ function _debitsTotal (bill, billRun) { return '£0.00' } -function _displayCreditDebitTotals (billRun) { +function _displayCreditDebitTotals(billRun) { const { batchType } = billRun return batchType === 'supplementary' } -function _financialYear (bill) { +function _financialYear(bill) { const { financialYearEnding } = bill return `${financialYearEnding - 1} to ${financialYearEnding}` } -function _scheme (billRun) { +function _scheme(billRun) { if (billRun.scheme === 'sroc') { return 'Current' } @@ -119,7 +115,7 @@ function _scheme (billRun) { return 'Old' } -function _billTotal (valueInPence, credit) { +function _billTotal(valueInPence, credit) { const valueAsMoney = formatMoney(valueInPence) if (credit) { diff --git a/app/presenters/bills/view-licence-summaries.presenter.js b/app/presenters/bills/view-licence-summaries.presenter.js index dd5d9e02ca..0c58f7a9c1 100644 --- a/app/presenters/bills/view-licence-summaries.presenter.js +++ b/app/presenters/bills/view-licence-summaries.presenter.js @@ -14,7 +14,7 @@ const { formatMoney } = require('../base.presenter.js') * * @returns {object} a formatted representation of the bill's licence summaries */ -function go (licenceSummaries) { +function go(licenceSummaries) { const billLicences = _billLicences(licenceSummaries) const formattedBill = { @@ -25,7 +25,7 @@ function go (licenceSummaries) { return formattedBill } -function _billLicences (licenceSummaries) { +function _billLicences(licenceSummaries) { return licenceSummaries.map((licenceSummary) => { const { id, licenceRef: reference, total } = licenceSummary @@ -37,7 +37,7 @@ function _billLicences (licenceSummaries) { }) } -function _tableCaption (billLicences) { +function _tableCaption(billLicences) { const numberOfRows = billLicences.length if (numberOfRows === 1) { diff --git a/app/presenters/charging-module/create-customer-change.presenter.js b/app/presenters/charging-module/create-customer-change.presenter.js index 172c6cedd6..360e98ad91 100644 --- a/app/presenters/charging-module/create-customer-change.presenter.js +++ b/app/presenters/charging-module/create-customer-change.presenter.js @@ -54,7 +54,7 @@ * * @returns {object} the request data needed in the format required by the Charging Module */ -function go (billingAccount, address, company, contact) { +function go(billingAccount, address, company, contact) { const { accountNumber: customerReference } = billingAccount const region = customerReference.charAt(0) @@ -69,7 +69,7 @@ function go (billingAccount, address, company, contact) { } } -function _addressLine6 (address6, country) { +function _addressLine6(address6, country) { if (!address6 && !country) { return '' } @@ -85,7 +85,7 @@ function _addressLine6 (address6, country) { return country } -function _customerName (billingAccount, company) { +function _customerName(billingAccount, company) { if (company.name) { return company.name } @@ -93,7 +93,7 @@ function _customerName (billingAccount, company) { return billingAccount.company.name } -function _formattedAddress (address, contact) { +function _formattedAddress(address, contact) { const addressLines = [] const { address1, address2, address3, address4, address5, address6, country, postcode } = address @@ -149,13 +149,13 @@ function _formattedAddress (address, contact) { * * @private */ -function _truncate (stringToTruncate, maximumLength) { +function _truncate(stringToTruncate, maximumLength) { // Don't truncate if the string is equal to or less than maximum length if (stringToTruncate.length <= maximumLength) { return stringToTruncate } - const truncatedString = stringToTruncate.slice(0, (maximumLength - 3)) + const truncatedString = stringToTruncate.slice(0, maximumLength - 3) return `${truncatedString}...` } diff --git a/app/presenters/charging-module/create-transaction.presenter.js b/app/presenters/charging-module/create-transaction.presenter.js index a6ff43b41e..224b32dee8 100644 --- a/app/presenters/charging-module/create-transaction.presenter.js +++ b/app/presenters/charging-module/create-transaction.presenter.js @@ -12,7 +12,7 @@ const { formatChargingModuleDate } = require('../base.presenter.js') * * @returns {object} an object to be used as the body in a Charging Module POST transaction request */ -function go (transaction, accountNumber, licence) { +function go(transaction, accountNumber, licence) { const periodStart = formatChargingModuleDate(transaction.startDate) const periodEnd = formatChargingModuleDate(transaction.endDate) diff --git a/app/presenters/import/legacy/address.presenter.js b/app/presenters/import/legacy/address.presenter.js index 69b052c00f..e8d2336188 100644 --- a/app/presenters/import/legacy/address.presenter.js +++ b/app/presenters/import/legacy/address.presenter.js @@ -14,7 +14,7 @@ * @returns {object} the NALD company data transformed into the WRLS format for an address * ready for validation and persisting */ -function go (address, dataSource) { +function go(address, dataSource) { return { address1: address.address1, address2: address.address2, diff --git a/app/presenters/import/legacy/company-address.presenter.js b/app/presenters/import/legacy/company-address.presenter.js index c6100e9640..38121eb0fa 100644 --- a/app/presenters/import/legacy/company-address.presenter.js +++ b/app/presenters/import/legacy/company-address.presenter.js @@ -13,7 +13,7 @@ * @returns {object} the NALD company address data transformed into the WRLS format for a company address * ready for validation and persisting */ -function go (address) { +function go(address) { return { addressId: address.external_id, companyId: address.company_external_id, @@ -37,15 +37,12 @@ function go (address) { * @returns {date | null} the end date for a licence holder * @private */ -function _endDate (address) { - const endDates = [ - address.end_date, - address.lapsed_date, - address.expired_date, - address.revoked_date - ].filter((endDate) => { - return endDate - }) +function _endDate(address) { + const endDates = [address.end_date, address.lapsed_date, address.expired_date, address.revoked_date].filter( + (endDate) => { + return endDate + } + ) const oldestDate = new Date(Math.max(...endDates)) diff --git a/app/presenters/import/legacy/company-contact.presenter.js b/app/presenters/import/legacy/company-contact.presenter.js index 2e48d2b525..85322c5c22 100644 --- a/app/presenters/import/legacy/company-contact.presenter.js +++ b/app/presenters/import/legacy/company-contact.presenter.js @@ -17,7 +17,7 @@ * * @returns {object} the details needed to persist the company contact in WRLS */ -function go (contact) { +function go(contact) { return { externalId: contact.external_id, startDate: contact.start_date, diff --git a/app/presenters/import/legacy/company.presenter.js b/app/presenters/import/legacy/company.presenter.js index 50f143903c..94f11998cd 100644 --- a/app/presenters/import/legacy/company.presenter.js +++ b/app/presenters/import/legacy/company.presenter.js @@ -13,7 +13,7 @@ * @returns {object} the NALD company data transformed into the WRLS format for a company * ready for validation and persisting */ -function go (company) { +function go(company) { return { name: company.name, type: company.type, diff --git a/app/presenters/import/legacy/contact.presenter.js b/app/presenters/import/legacy/contact.presenter.js index 817b1b2218..462142402a 100644 --- a/app/presenters/import/legacy/contact.presenter.js +++ b/app/presenters/import/legacy/contact.presenter.js @@ -13,7 +13,7 @@ * @returns {object} the NALD contact data transformed into the WRLS format for a contact * ready for validation and persisting */ -function go (contact) { +function go(contact) { return { externalId: contact.external_id, salutation: contact.salutation, diff --git a/app/presenters/import/legacy/licence-document-role.presenter.js b/app/presenters/import/legacy/licence-document-role.presenter.js index 7a4fbc695f..c198dad00d 100644 --- a/app/presenters/import/legacy/licence-document-role.presenter.js +++ b/app/presenters/import/legacy/licence-document-role.presenter.js @@ -14,7 +14,7 @@ * @returns {object} the NALD licence data transformed into the WRLS licence document role format * ready for validation and persisting */ -function go (licenceDocumentRole, licenceRef) { +function go(licenceDocumentRole, licenceRef) { return { addressId: licenceDocumentRole.address_id, companyId: licenceDocumentRole.company_id, diff --git a/app/presenters/import/legacy/licence-document.presenter.js b/app/presenters/import/legacy/licence-document.presenter.js index 99f53a172b..5c40511bb7 100644 --- a/app/presenters/import/legacy/licence-document.presenter.js +++ b/app/presenters/import/legacy/licence-document.presenter.js @@ -13,7 +13,7 @@ * @returns {object} the NALD licence data transformed into the WRLS licence document format * ready for validation and persisting */ -function go (licenceDocument) { +function go(licenceDocument) { return { // Add an empty array property ready for when transforming and attaching licence document roles licenceDocumentRoles: [], diff --git a/app/presenters/import/legacy/licence-version-purpose-condition.presenter.js b/app/presenters/import/legacy/licence-version-purpose-condition.presenter.js index 62d0e5a294..5bc806337a 100644 --- a/app/presenters/import/legacy/licence-version-purpose-condition.presenter.js +++ b/app/presenters/import/legacy/licence-version-purpose-condition.presenter.js @@ -14,7 +14,7 @@ * @returns {object} the NALD licence version purpose conditions data transformed into the WRLS format ready for * validation and persisting */ -function go (licenceVersionPurposeCondition) { +function go(licenceVersionPurposeCondition) { return { param1: licenceVersionPurposeCondition.param1, param2: licenceVersionPurposeCondition.param2, diff --git a/app/presenters/import/legacy/licence-version-purpose.presenter.js b/app/presenters/import/legacy/licence-version-purpose.presenter.js index 51c8a071b9..5f7776062c 100644 --- a/app/presenters/import/legacy/licence-version-purpose.presenter.js +++ b/app/presenters/import/legacy/licence-version-purpose.presenter.js @@ -13,7 +13,7 @@ * @returns {object} the NALD licence version purpose data transformed into the WRLS format ready for validation and * persisting */ -function go (licenceVersionPurpose) { +function go(licenceVersionPurpose) { return { abstractionPeriodEndDay: licenceVersionPurpose.abstraction_period_end_day, abstractionPeriodEndMonth: licenceVersionPurpose.abstraction_period_end_month, diff --git a/app/presenters/import/legacy/licence-version.presenter.js b/app/presenters/import/legacy/licence-version.presenter.js index 90598f998c..b2f18edbb7 100644 --- a/app/presenters/import/legacy/licence-version.presenter.js +++ b/app/presenters/import/legacy/licence-version.presenter.js @@ -17,7 +17,7 @@ const NALD_STATUSES = { * * @returns {object} the NALD licence version data transformed into the WRLS format ready for validation and persisting */ -function go (licenceVersion) { +function go(licenceVersion) { return { endDate: licenceVersion.effective_end_date, externalId: licenceVersion.external_id, diff --git a/app/presenters/import/legacy/licence.presenter.js b/app/presenters/import/legacy/licence.presenter.js index d9d430a44f..6d91611f22 100644 --- a/app/presenters/import/legacy/licence.presenter.js +++ b/app/presenters/import/legacy/licence.presenter.js @@ -14,7 +14,7 @@ const { naldRegions } = require('../../../lib/static-lookups.lib.js') * * @returns {object} the NALD licence data transformed into the WRLS format ready for validation and persisting */ -function go (licence) { +function go(licence) { return { expiredDate: licence.expiry_date, lapsedDate: licence.lapsed_date, @@ -44,7 +44,7 @@ const _regions = (licence) => { return { historicalAreaCode, regionalChargeArea, standardUnitChargeCode, localEnvironmentAgencyPlanCode } } -function _startDate (licence) { +function _startDate(licence) { if (licence.original_effective_date) { return licence.original_effective_date } diff --git a/app/presenters/licences/customer-contacts.presenter.js b/app/presenters/licences/customer-contacts.presenter.js index 15e0fe6e8b..f221918e6f 100644 --- a/app/presenters/licences/customer-contacts.presenter.js +++ b/app/presenters/licences/customer-contacts.presenter.js @@ -15,19 +15,19 @@ const ContactModel = require('../../models/contact.model.js') * * @returns {object} The data formatted for the view template */ -function go (customerContacts) { +function go(customerContacts) { return { customerContacts: _customerContacts(customerContacts) } } -function _buildCustomerName (customer) { +function _buildCustomerName(customer) { const contact = ContactModel.fromJson(customer) return contact.$name() } -function _customerContacts (customerContacts) { +function _customerContacts(customerContacts) { return customerContacts.map((customer) => { return { email: customer.email, diff --git a/app/presenters/licences/licence-contacts.presenter.js b/app/presenters/licences/licence-contacts.presenter.js index 4cd34bd49c..93eeeec859 100644 --- a/app/presenters/licences/licence-contacts.presenter.js +++ b/app/presenters/licences/licence-contacts.presenter.js @@ -12,14 +12,14 @@ * * @returns {object} The data formatted for the view template */ -function go (contacts) { +function go(contacts) { return { customerId: _findCustomerId(contacts), licenceContacts: _licenceContacts(contacts) } } -function _findCustomerId (contacts) { +function _findCustomerId(contacts) { const customerContact = contacts.find((contact) => { return contact.communicationType === 'Licence Holder' }) @@ -31,7 +31,7 @@ function _findCustomerId (contacts) { return null } -function _licenceContactName (contact) { +function _licenceContactName(contact) { if (contact.contactId) { return `${contact.firstName || ''} ${contact.lastName}`.trim() } @@ -39,7 +39,7 @@ function _licenceContactName (contact) { return contact.companyName } -function _licenceContacts (contacts) { +function _licenceContacts(contacts) { return contacts.map((contact) => { return { address: { diff --git a/app/presenters/licences/supplementary/mark-for-supplementary-billing.presenter.js b/app/presenters/licences/supplementary/mark-for-supplementary-billing.presenter.js index 5961d97e6b..08bd421098 100644 --- a/app/presenters/licences/supplementary/mark-for-supplementary-billing.presenter.js +++ b/app/presenters/licences/supplementary/mark-for-supplementary-billing.presenter.js @@ -18,7 +18,7 @@ const PREVIOUS_SIX_YEARS = 6 * * @returns {object} - The data formatted for the view template */ -function go (licence) { +function go(licence) { return { licenceId: licence.id, licenceRef: licence.licenceRef, @@ -31,12 +31,12 @@ function go (licence) { * The financial year end is the end of March, so if the current month is April or later the end of the financial year * is the next calendar year. Otherwise it is the current year. */ -function _determineCurrentFinancialYearEnd () { +function _determineCurrentFinancialYearEnd() { const currentDate = new Date() const currentYear = currentDate.getFullYear() const currentMonth = currentDate.getMonth() - const currentFinancialYearEnd = (currentMonth >= APRIL) ? currentYear + 1 : currentYear + const currentFinancialYearEnd = currentMonth >= APRIL ? currentYear + 1 : currentYear return currentFinancialYearEnd } @@ -49,7 +49,7 @@ function _determineCurrentFinancialYearEnd () { * meaning that marking the licence for supplementary billing will apply to all previous years * covered by pre-SROC (up to six years). */ -function _yearsToDisplay () { +function _yearsToDisplay() { const currentFinancialYearEnd = _determineCurrentFinancialYearEnd() const lastSixFinancialYears = [] diff --git a/app/presenters/licences/view-licence-bills.presenter.js b/app/presenters/licences/view-licence-bills.presenter.js index 5601ee8c5a..671143ac4a 100644 --- a/app/presenters/licences/view-licence-bills.presenter.js +++ b/app/presenters/licences/view-licence-bills.presenter.js @@ -14,13 +14,13 @@ const { formatBillRunType, formatLongDate, formatMoney } = require('../base.pres * * @returns {object} The data formatted for the view template */ -function go (bills) { +function go(bills) { return { bills: _bills(bills) } } -function _bills (bills) { +function _bills(bills) { return bills.map((bill) => { const { accountNumber, @@ -47,7 +47,7 @@ function _bills (bills) { }) } -function _formatBillNumber (bill) { +function _formatBillNumber(bill) { if (bill.invoiceNumber) { return bill.invoiceNumber } diff --git a/app/presenters/licences/view-licence-communications.presenter.js b/app/presenters/licences/view-licence-communications.presenter.js index 43b5f4a07d..ec4761e665 100644 --- a/app/presenters/licences/view-licence-communications.presenter.js +++ b/app/presenters/licences/view-licence-communications.presenter.js @@ -14,13 +14,13 @@ const { formatLongDate, sentenceCase } = require('../base.presenter.js') * * @returns {object} The data formatted for the view template */ -function go (communications) { +function go(communications) { return { communications: _communications(communications) } } -function _communications (communications) { +function _communications(communications) { return communications.map((communication) => { return { id: communication.id, @@ -32,7 +32,7 @@ function _communications (communications) { }) } -function _type (communication) { +function _type(communication) { return { label: _typeLabel(communication), sentVia: `sent ${formatLongDate(new Date(communication.event.createdAt))} via ${communication.messageType}`, @@ -40,10 +40,12 @@ function _type (communication) { } } -function _typeLabel (communication) { +function _typeLabel(communication) { if (communication.event.metadata.name === 'Water abstraction alert') { - return `${sentenceCase(communication.event.metadata.options.sendingAlertType)}` + + return ( + `${sentenceCase(communication.event.metadata.options.sendingAlertType)}` + ` - ${communication.event.metadata.name}` + ) } return communication.event.metadata.name diff --git a/app/presenters/licences/view-licence-contact-details.presenter.js b/app/presenters/licences/view-licence-contact-details.presenter.js index 4af5d3c278..eab1792510 100644 --- a/app/presenters/licences/view-licence-contact-details.presenter.js +++ b/app/presenters/licences/view-licence-contact-details.presenter.js @@ -12,7 +12,7 @@ * * @returns {object} The data formatted for the view template */ -function go (licence) { +function go(licence) { const { id: licenceId, licenceDocumentHeader, licenceRef } = licence return { @@ -23,7 +23,7 @@ function go (licence) { } } -function _licenceContactAddress (contact) { +function _licenceContactAddress(contact) { const contactAddressFields = [ 'addressLine1', 'addressLine2', @@ -38,25 +38,23 @@ function _licenceContactAddress (contact) { // NOTE: Maps over the `contactAddressFields` array to create an array of values from the `contact` object. Each // `contactAddressField` corresponds to a property in the `contact` object, mapping and creating a contactAddress // array. The `filter(Boolean)` function then removes falsy values from the `contactAddress` array. - const contactAddress = contactAddressFields.map((contactAddressField) => { - return contact[contactAddressField] - }).filter(Boolean) + const contactAddress = contactAddressFields + .map((contactAddressField) => { + return contact[contactAddressField] + }) + .filter(Boolean) return contactAddress } -function _licenceContactName (contact) { +function _licenceContactName(contact) { if (contact.type === 'Person') { const { salutation, forename, initials, name } = contact // NOTE: Prioritise the initials and use the contact forename if initials is null const initialsOrForename = initials || forename - const nameComponents = [ - salutation, - initialsOrForename, - name - ] + const nameComponents = [salutation, initialsOrForename, name] const filteredNameComponents = nameComponents.filter((item) => { return item @@ -68,7 +66,7 @@ function _licenceContactName (contact) { return contact.name } -function _licenceContactDetails (licenceDocumentHeader) { +function _licenceContactDetails(licenceDocumentHeader) { const licenceContactDetailsData = licenceDocumentHeader.metadata.contacts const roles = ['Licence holder', 'Returns to', 'Licence contact'] diff --git a/app/presenters/licences/view-licence-history.presenter.js b/app/presenters/licences/view-licence-history.presenter.js index 356b9bc44e..46a95d1326 100644 --- a/app/presenters/licences/view-licence-history.presenter.js +++ b/app/presenters/licences/view-licence-history.presenter.js @@ -15,7 +15,7 @@ const { returnRequirementReasons } = require('../../lib/static-lookups.lib.js') * * @returns The data formatted and sorted for the view template */ -function go (licence) { +function go(licence) { const { id: licenceId, licenceRef } = licence const chargeVersionEntries = _chargeVersionEntries(licence) @@ -32,7 +32,7 @@ function go (licence) { } } -function _chargeVersionEntries (licence) { +function _chargeVersionEntries(licence) { const { chargeVersions, id } = licence return chargeVersions.map((chargeVersion) => { @@ -52,7 +52,7 @@ function _chargeVersionEntries (licence) { }) } -function _createdBy (entry) { +function _createdBy(entry) { const createdBy = entry.$createdBy() if (createdBy) { @@ -62,7 +62,7 @@ function _createdBy (entry) { return 'Migrated from NALD' } -function _licenceVersionEntries (licence) { +function _licenceVersionEntries(licence) { const { licenceVersions } = licence return licenceVersions.map((licenceVersion) => { @@ -82,7 +82,7 @@ function _licenceVersionEntries (licence) { }) } -function _returnVersionEntries (licence) { +function _returnVersionEntries(licence) { const { returnVersions } = licence return returnVersions.map((returnVersion) => { @@ -104,7 +104,7 @@ function _returnVersionEntries (licence) { }) } -function _sortEntries (chargeVersionEntries, licenceVersionEntries, returnVersionEntries) { +function _sortEntries(chargeVersionEntries, licenceVersionEntries, returnVersionEntries) { const joinedEntries = [...chargeVersionEntries, ...licenceVersionEntries, ...returnVersionEntries] return joinedEntries.sort((entryA, entryB) => { diff --git a/app/presenters/licences/view-licence-points.presenter.js b/app/presenters/licences/view-licence-points.presenter.js index d530270d17..3a73e55550 100644 --- a/app/presenters/licences/view-licence-points.presenter.js +++ b/app/presenters/licences/view-licence-points.presenter.js @@ -14,7 +14,7 @@ const PointModel = require('../../models/point.model.js') * * @returns {object} licence and points data needed by the view template */ -function go (data) { +function go(data) { const { licence, points } = data const licencePoints = _formatLicencePoints(points) @@ -27,7 +27,7 @@ function go (data) { } } -function _formatLicencePoints (points) { +function _formatLicencePoints(points) { return points.map((point) => { const pointInstance = PointModel.fromJson(point) diff --git a/app/presenters/licences/view-licence-purposes.presenter.js b/app/presenters/licences/view-licence-purposes.presenter.js index 94eda8bd87..ca65717180 100644 --- a/app/presenters/licences/view-licence-purposes.presenter.js +++ b/app/presenters/licences/view-licence-purposes.presenter.js @@ -15,7 +15,7 @@ const { formatAbstractionPeriod } = require('../base.presenter.js') * * @returns {object} licence and licenceVersionPurposes data needed by the view template */ -function go (licence) { +function go(licence) { return { id: licence.id, licencePurposes: _formatLicencePurposes(licence.licenceVersions[0].licenceVersionPurposes), @@ -24,7 +24,7 @@ function go (licence) { } } -function _abstractionPeriod (licenceVersionPurpose) { +function _abstractionPeriod(licenceVersionPurpose) { const { abstractionPeriodStartDay: startDay, abstractionPeriodStartMonth: startMonth, @@ -35,7 +35,7 @@ function _abstractionPeriod (licenceVersionPurpose) { return formatAbstractionPeriod(startDay, startMonth, endDay, endMonth) } -function _formatAbstractionAmounts (licenceVersionPurpose) { +function _formatAbstractionAmounts(licenceVersionPurpose) { const details = [] if (!licenceVersionPurpose) { @@ -63,7 +63,7 @@ function _formatAbstractionAmounts (licenceVersionPurpose) { return details } -function _formatAbstractionMethod (licenceVersionPurposePoints) { +function _formatAbstractionMethod(licenceVersionPurposePoints) { const abstractionMethods = licenceVersionPurposePoints.map((licenceVersionPurposePoint) => { return licenceVersionPurposePoint.abstractionMethod }) @@ -78,17 +78,20 @@ function _formatAbstractionMethod (licenceVersionPurposePoints) { return uniqueAbstractionMethods.join(' and ') } - return uniqueAbstractionMethods.slice(0, uniqueAbstractionMethods.length - 1) - .join(', ') + ', and ' + uniqueAbstractionMethods[uniqueAbstractionMethods.length - 1] + return ( + uniqueAbstractionMethods.slice(0, uniqueAbstractionMethods.length - 1).join(', ') + + ', and ' + + uniqueAbstractionMethods[uniqueAbstractionMethods.length - 1] + ) } -function _formatAbstractionPoints (points) { +function _formatAbstractionPoints(points) { return points.map((point) => { return point.$describe() }) } -function _formatLicencePurposes (licenceVersionPurposes) { +function _formatLicencePurposes(licenceVersionPurposes) { return licenceVersionPurposes.map((licenceVersionPurpose) => { const abstractionAmounts = _formatAbstractionAmounts(licenceVersionPurpose) const abstractionMethods = _formatAbstractionMethod(licenceVersionPurpose.licenceVersionPurposePoints) @@ -98,7 +101,10 @@ function _formatLicencePurposes (licenceVersionPurposes) { abstractionAmounts, abstractionAmountsTitle: abstractionAmounts.length > 1 ? 'Abstraction amounts' : 'Abstraction amount', abstractionMethods, - abstractionMethodsTitle: licenceVersionPurpose.licenceVersionPurposePoints.length > 1 ? 'Methods of abstraction' : 'Method of abstraction', + abstractionMethodsTitle: + licenceVersionPurpose.licenceVersionPurposePoints.length > 1 + ? 'Methods of abstraction' + : 'Method of abstraction', abstractionPeriod: _abstractionPeriod(licenceVersionPurpose), abstractionPoints, abstractionPointsTitle: abstractionPoints.length > 1 ? 'Abstraction points' : 'Abstraction point', diff --git a/app/presenters/licences/view-licence-returns.presenter.js b/app/presenters/licences/view-licence-returns.presenter.js index cefc193f3a..0aa85087e8 100644 --- a/app/presenters/licences/view-licence-returns.presenter.js +++ b/app/presenters/licences/view-licence-returns.presenter.js @@ -16,7 +16,7 @@ const { formatLongDate } = require('../base.presenter.js') * * @returns {object} The data formatted for the view template */ -function go (returnLogs, hasRequirements, auth) { +function go(returnLogs, hasRequirements, auth) { const canManageReturns = auth.credentials.scope.includes('returns') const returns = _returns(returnLogs, canManageReturns) @@ -28,7 +28,7 @@ function go (returnLogs, hasRequirements, auth) { } } -function _link (status, returnLogId, canManageReturns) { +function _link(status, returnLogId, canManageReturns) { if (['completed', 'void'].includes(status)) { return `/returns/return?id=${returnLogId}` } @@ -40,7 +40,7 @@ function _link (status, returnLogId, canManageReturns) { return null } -function _noReturnsMessage (hasReturns, hasRequirements) { +function _noReturnsMessage(hasReturns, hasRequirements) { if (!hasReturns && !hasRequirements) { return 'No requirements for returns have been set up for this licence.' } @@ -52,13 +52,13 @@ function _noReturnsMessage (hasReturns, hasRequirements) { return null } -function _purpose (purpose) { +function _purpose(purpose) { const [firstPurpose] = purpose return firstPurpose.alias ? firstPurpose.alias : firstPurpose.tertiary.description } -function _returns (returns, canManageReturns) { +function _returns(returns, canManageReturns) { return returns.map((returnLog) => { const { endDate, dueDate, id: returnLogId, metadata, returnReference, startDate, status } = returnLog @@ -75,7 +75,7 @@ function _returns (returns, canManageReturns) { }) } -function _status (returnLog) { +function _status(returnLog) { const { status, dueDate } = returnLog // If the return is completed we are required to display it as 'complete'. This also takes priority over the other diff --git a/app/presenters/licences/view-licence-set-up.presenter.js b/app/presenters/licences/view-licence-set-up.presenter.js index 9ca794eebf..f186a404e0 100644 --- a/app/presenters/licences/view-licence-set-up.presenter.js +++ b/app/presenters/licences/view-licence-set-up.presenter.js @@ -37,7 +37,7 @@ const AGREEMENTS = { * * @returns {object} The data formatted for the view template */ -function go (chargeVersions, workflows, agreements, returnVersions, auth, commonData) { +function go(chargeVersions, workflows, agreements, returnVersions, auth, commonData) { const enableRequirementsForReturns = FeatureFlagsConfig.enableRequirementsForReturns const enableTwoPartSupplementary = FeatureFlagsConfig.enableTwoPartTariffSupplementary @@ -54,7 +54,7 @@ function go (chargeVersions, workflows, agreements, returnVersions, auth, common } } -function _agreements (commonData, agreements, auth, enableTwoPartSupplementary) { +function _agreements(commonData, agreements, auth, enableTwoPartSupplementary) { return agreements.map((agreement) => { return { startDate: formatLongDate(agreement.startDate), @@ -66,7 +66,7 @@ function _agreements (commonData, agreements, auth, enableTwoPartSupplementary) }) } -function _agreementActionLinks (commonData, agreement, auth, enableTwoPartSupplementary) { +function _agreementActionLinks(commonData, agreement, auth, enableTwoPartSupplementary) { if (!auth.credentials.scope.includes(ROLES.manageAgreements)) { return [] } @@ -97,8 +97,12 @@ function _agreementActionLinks (commonData, agreement, auth, enableTwoPartSupple const is2PTAgreement = _financialAgreementCode(agreement) === 'S127' const isNotMarkedForSupplementaryBilling = commonData.includeInPresrocBilling === 'no' - if (hasNotEnded && is2PTAgreement && isNotMarkedForSupplementaryBilling && - auth.credentials.scope.includes(ROLES.billing)) { + if ( + hasNotEnded && + is2PTAgreement && + isNotMarkedForSupplementaryBilling && + auth.credentials.scope.includes(ROLES.billing) + ) { actionLinks.push({ text: 'Recalculate bills', link: `/licences/${commonData.licenceId}/mark-for-supplementary-billing` @@ -109,7 +113,7 @@ function _agreementActionLinks (commonData, agreement, auth, enableTwoPartSupple return actionLinks } -function _agreementLinks (auth, commonData) { +function _agreementLinks(auth, commonData) { if (auth.credentials.scope.includes(ROLES.manageAgreements) && !_endsSixYearsAgo(commonData.ends)) { return { setUpAgreement: `/licences/${commonData.licenceId}/agreements/select-type` @@ -119,7 +123,7 @@ function _agreementLinks (auth, commonData) { return {} } -function _chargeInformationLinks (auth, commonData) { +function _chargeInformationLinks(auth, commonData) { if (auth.credentials.scope.includes(ROLES.workflowEditor) && !_endsSixYearsAgo(commonData.ends)) { return { setupNewCharge: `/licences/${commonData.licenceId}/charge-information/create`, @@ -130,14 +134,11 @@ function _chargeInformationLinks (auth, commonData) { return {} } -function _chargeInformation (chargeVersions, workflows, auth) { - return [ - ..._workflows(workflows, auth), - ..._chargeVersions(chargeVersions) - ] +function _chargeInformation(chargeVersions, workflows, auth) { + return [..._workflows(workflows, auth), ..._chargeVersions(chargeVersions)] } -function _chargeVersions (chargeVersions) { +function _chargeVersions(chargeVersions) { return chargeVersions.map((chargeVersion) => { return { id: chargeVersion.id, @@ -155,7 +156,7 @@ function _chargeVersions (chargeVersions) { }) } -function _endsSixYearsAgo (endDate) { +function _endsSixYearsAgo(endDate) { if (!endDate) { return null } @@ -175,11 +176,11 @@ function _endsSixYearsAgo (endDate) { return endDate.date < sixYearsFromYesterday } -function _financialAgreementCode (agreement) { +function _financialAgreementCode(agreement) { return agreement.financialAgreement.code } -function _hasTwoPartTariffAgreement (agreements) { +function _hasTwoPartTariffAgreement(agreements) { return agreements.some((agreement) => { return agreement.financialAgreement.code === 'S127' }) @@ -193,7 +194,7 @@ function _hasTwoPartTariffAgreement (agreements) { * * @private */ -function _reason (returnVersion) { +function _reason(returnVersion) { const reason = returnVersion.$reason() const mappedReason = returnRequirementReasons[reason] @@ -204,8 +205,9 @@ function _reason (returnVersion) { return reason ?? '' } -function _recalculateBills (agreements, auth, commonData, enableTwoPartSupplementary) { - if (auth.credentials.scope.includes(ROLES.billing) && +function _recalculateBills(agreements, auth, commonData, enableTwoPartSupplementary) { + if ( + auth.credentials.scope.includes(ROLES.billing) && _hasTwoPartTariffAgreement(agreements) && enableTwoPartSupplementary ) { @@ -215,13 +217,15 @@ function _recalculateBills (agreements, auth, commonData, enableTwoPartSupplemen return {} } -function _returnVersions (returnVersions = [{}]) { +function _returnVersions(returnVersions = [{}]) { return returnVersions.map((returnVersion) => { return { - action: [{ - text: 'View', - link: `/system/return-versions/${returnVersion.id}` - }], + action: [ + { + text: 'View', + link: `/system/return-versions/${returnVersion.id}` + } + ], endDate: returnVersion.endDate ? formatLongDate(returnVersion.endDate) : '', reason: _reason(returnVersion), startDate: formatLongDate(returnVersion.startDate), @@ -230,7 +234,7 @@ function _returnVersions (returnVersions = [{}]) { }) } -function _returnVersionsLinks (commonData, enableRequirementsForReturns) { +function _returnVersionsLinks(commonData, enableRequirementsForReturns) { if (enableRequirementsForReturns) { return { returnsRequired: `/system/licences/${commonData.licenceId}/returns-required`, @@ -241,7 +245,7 @@ function _returnVersionsLinks (commonData, enableRequirementsForReturns) { return {} } -function _workflows (workflows, auth) { +function _workflows(workflows, auth) { return workflows.map((workflow) => { return { action: _workflowAction(workflow, auth), @@ -254,7 +258,7 @@ function _workflows (workflows, auth) { }) } -function _workflowAction (workflow, auth) { +function _workflowAction(workflow, auth) { if (workflow.status === 'to_setup' && auth.credentials.scope.includes(ROLES.workflowEditor)) { return _workflowActionEditor(workflow) } @@ -266,7 +270,7 @@ function _workflowAction (workflow, auth) { return [] } -function _workflowActionEditor (workflow) { +function _workflowActionEditor(workflow) { return [ { text: 'Set up', @@ -279,7 +283,7 @@ function _workflowActionEditor (workflow) { ] } -function _workflowActionReviewer (workflow) { +function _workflowActionReviewer(workflow) { return [ { text: 'Review', @@ -288,7 +292,7 @@ function _workflowActionReviewer (workflow) { ] } -function _workflowStartDate (workflow) { +function _workflowStartDate(workflow) { if (workflow.status === 'to_setup') { return '' } diff --git a/app/presenters/licences/view-licence-summary.presenter.js b/app/presenters/licences/view-licence-summary.presenter.js index 846caaa47b..b429f27d8a 100644 --- a/app/presenters/licences/view-licence-summary.presenter.js +++ b/app/presenters/licences/view-licence-summary.presenter.js @@ -16,15 +16,8 @@ const FeatureFlagsConfig = require('../../../config/feature-flags.config.js') * * @returns {object} The data formatted for the view template */ -function go (licence) { - const { - expiredDate, - id, - licenceDocumentHeader, - licenceMonitoringStations, - region, - startDate - } = licence +function go(licence) { + const { expiredDate, id, licenceDocumentHeader, licenceMonitoringStations, region, startDate } = licence const licenceVersionPurposes = _licenceVersionPurposes(licence) const purposes = _purposes(licenceVersionPurposes) @@ -61,7 +54,7 @@ function go (licence) { } } -function _abstractionAmounts (licenceVersionPurposes) { +function _abstractionAmounts(licenceVersionPurposes) { const details = [] if (!licenceVersionPurposes || licenceVersionPurposes.length > 1) { @@ -89,7 +82,7 @@ function _abstractionAmounts (licenceVersionPurposes) { return details } -function _abstractionConditions (licenceVersionPurposes) { +function _abstractionConditions(licenceVersionPurposes) { const allConditions = [] if (!licenceVersionPurposes) { @@ -112,7 +105,7 @@ function _abstractionConditions (licenceVersionPurposes) { return uniqueConditions.sort() } -function _abstractionPeriods (licenceVersionPurposes) { +function _abstractionPeriods(licenceVersionPurposes) { if (!licenceVersionPurposes) { return [] } @@ -129,7 +122,7 @@ function _abstractionPeriods (licenceVersionPurposes) { return uniqueAbstractionPeriods } -function _abstractionPeriodsAndPurposesLinkText (abstractionPeriods, purposes) { +function _abstractionPeriodsAndPurposesLinkText(abstractionPeriods, purposes) { let abstractionPeriodsAndPurposesLinkText = null if (abstractionPeriods.length > 0) { @@ -142,11 +135,11 @@ function _abstractionPeriodsAndPurposesLinkText (abstractionPeriods, purposes) { return abstractionPeriodsAndPurposesLinkText } -function _abstractionPeriodsCaption (abstractionPeriods) { +function _abstractionPeriodsCaption(abstractionPeriods) { return abstractionPeriods.length > 1 ? 'Periods of abstraction' : 'Period of abstraction' } -function _abstractionPoints (licenceVersionPurposes) { +function _abstractionPoints(licenceVersionPurposes) { if (!licenceVersionPurposes) { return [] } @@ -166,15 +159,17 @@ function _abstractionPoints (licenceVersionPurposes) { return uniqueAbstractionPoints.sort() } -function _abstractionPointsCaption (abstractionPoints) { +function _abstractionPointsCaption(abstractionPoints) { return abstractionPoints.length > 1 ? 'Points of abstraction' : 'Point of abstraction' } -function _abstractionPointsLinkText (abstractionPoints) { - return abstractionPoints.length > 1 ? 'View details of the abstraction points' : 'View details of the abstraction point' +function _abstractionPointsLinkText(abstractionPoints) { + return abstractionPoints.length > 1 + ? 'View details of the abstraction points' + : 'View details of the abstraction point' } -function _endDate (expiredDate) { +function _endDate(expiredDate) { if (!expiredDate || expiredDate < Date.now()) { return null } @@ -182,7 +177,7 @@ function _endDate (expiredDate) { return formatLongDate(expiredDate) } -function _licenceHolder (licence) { +function _licenceHolder(licence) { const licenceHolder = licence.$licenceHolder() if (!licenceHolder) { @@ -192,7 +187,7 @@ function _licenceHolder (licence) { return licenceHolder } -function _licenceVersionPurposes (licence) { +function _licenceVersionPurposes(licence) { const currentVersion = licence.$currentVersion() if (!currentVersion || currentVersion?.licenceVersionPurposes.length === 0) { @@ -202,7 +197,7 @@ function _licenceVersionPurposes (licence) { return currentVersion.licenceVersionPurposes } -function _monitoringStations (licenceMonitoringStations) { +function _monitoringStations(licenceMonitoringStations) { const monitoringStations = [] for (const licenceMonitoringStation of licenceMonitoringStations) { @@ -220,7 +215,7 @@ function _monitoringStations (licenceMonitoringStations) { return monitoringStations } -function _purposes (licenceVersionPurposes) { +function _purposes(licenceVersionPurposes) { if (!licenceVersionPurposes) { return null } @@ -237,7 +232,7 @@ function _purposes (licenceVersionPurposes) { } } -function _sourceOfSupply (licenceVersionPurposes) { +function _sourceOfSupply(licenceVersionPurposes) { if (!licenceVersionPurposes || licenceVersionPurposes[0].points.length === 0) { return null } diff --git a/app/presenters/licences/view-licence.presenter.js b/app/presenters/licences/view-licence.presenter.js index 77c2509391..e5f58f5c20 100644 --- a/app/presenters/licences/view-licence.presenter.js +++ b/app/presenters/licences/view-licence.presenter.js @@ -15,14 +15,8 @@ const { formatLongDate } = require('../base.presenter.js') * * @returns {object} The data formatted for the view template */ -function go (licence, auth) { - const { - id, - includeInPresrocBilling, - licenceDocumentHeader, - licenceRef, - workflows - } = licence +function go(licence, auth) { + const { id, includeInPresrocBilling, licenceDocumentHeader, licenceRef, workflows } = licence const primaryUser = licence.$primaryUser() const ends = licence.$ends() @@ -43,7 +37,7 @@ function go (licence, auth) { } } -function _licenceName (primaryUser, licence) { +function _licenceName(primaryUser, licence) { if (!primaryUser) { return 'Unregistered licence' } @@ -53,7 +47,7 @@ function _licenceName (primaryUser, licence) { return licenceName ?? null } -function _notification (licence) { +function _notification(licence) { const { includeInPresrocBilling, includeInSrocBilling, licenceSupplementaryYears } = licence const baseMessage = 'This licence has been marked for the next ' @@ -75,18 +69,23 @@ function _notification (licence) { return null } -function _roles (auth) { +function _roles(auth) { return auth.credentials.roles.map((role) => { return role.role }) } -function _tptNotification (baseMessage, includeInPresrocBilling, includeInSrocBilling) { +function _tptNotification(baseMessage, includeInPresrocBilling, includeInSrocBilling) { if (includeInPresrocBilling === 'yes' && includeInSrocBilling === true) { - return baseMessage + 'two-part tariff supplementary bill run and supplementary bill runs for the current and old charge schemes.' + return ( + baseMessage + + 'two-part tariff supplementary bill run and supplementary bill runs for the current and old charge schemes.' + ) } if (includeInPresrocBilling === 'yes') { - return baseMessage + 'two-part tariff supplementary bill run and the supplementary bill run for the old charge scheme.' + return ( + baseMessage + 'two-part tariff supplementary bill run and the supplementary bill run for the old charge scheme.' + ) } if (includeInSrocBilling === true) { @@ -96,7 +95,7 @@ function _tptNotification (baseMessage, includeInPresrocBilling, includeInSrocBi return baseMessage + 'two-part tariff supplementary bill run.' } -function _warning (ends) { +function _warning(ends) { const today = new Date() if (!ends || ends.date > today) { @@ -116,7 +115,7 @@ function _warning (ends) { return `This licence expired on ${formattedDate}` } -function _workflowWarning (workflows) { +function _workflowWarning(workflows) { return workflows.some((workflow) => { return workflow.status === 'to_setup' }) diff --git a/app/presenters/monitoring-stations/view.presenter.js b/app/presenters/monitoring-stations/view.presenter.js index c488d96498..57cc6957d3 100644 --- a/app/presenters/monitoring-stations/view.presenter.js +++ b/app/presenters/monitoring-stations/view.presenter.js @@ -29,7 +29,7 @@ const { formatAbstractionPeriod, formatLongDate, sentenceCase } = require('../ba * * @returns {object} page data needed by the view template */ -function go (monitoringStation, auth) { +function go(monitoringStation, auth) { const { id: monitoringStationId, gridReference, @@ -53,7 +53,7 @@ function go (monitoringStation, auth) { } } -function _abstractionPeriod (licenceMonitoringStation) { +function _abstractionPeriod(licenceMonitoringStation) { const { abstractionPeriodEndDay: stationEndDay, abstractionPeriodEndMonth: stationEndMonth, @@ -76,7 +76,7 @@ function _abstractionPeriod (licenceMonitoringStation) { return formatAbstractionPeriod(stationStartDay, stationStartMonth, stationEndDay, stationEndMonth) } -function _alert (status, statusUpdatedAt) { +function _alert(status, statusUpdatedAt) { if (!statusUpdatedAt) { return null } @@ -84,7 +84,7 @@ function _alert (status, statusUpdatedAt) { return sentenceCase(status) } -function _restriction (restrictionType) { +function _restriction(restrictionType) { if (restrictionType === 'stop_or_reduce') { return 'Stop or reduce' } @@ -115,7 +115,7 @@ function _restriction (restrictionType) { * * @private */ -function _restrictionHeading (licenceMonitoringStations) { +function _restrictionHeading(licenceMonitoringStations) { const containsFlow = licenceMonitoringStations.some((licenceMonitoringStation) => { return licenceMonitoringStation.measureType === 'flow' }) @@ -135,16 +135,10 @@ function _restrictionHeading (licenceMonitoringStations) { return 'Level restriction type and threshold' } -function _restrictions (licenceMonitoringStations) { +function _restrictions(licenceMonitoringStations) { return licenceMonitoringStations.map((licenceMonitoringStation) => { - const { - licence, - restrictionType, - status, - statusUpdatedAt, - thresholdUnit, - thresholdValue - } = licenceMonitoringStation + const { licence, restrictionType, status, statusUpdatedAt, thresholdUnit, thresholdValue } = + licenceMonitoringStation return { abstractionPeriod: _abstractionPeriod(licenceMonitoringStation), @@ -159,7 +153,7 @@ function _restrictions (licenceMonitoringStations) { }) } -function _restrictionCount (licenceId, licenceMonitoringStations) { +function _restrictionCount(licenceId, licenceMonitoringStations) { const count = licenceMonitoringStations.filter((licenceMonitoringStation) => { return licenceMonitoringStation.licenceId === licenceId }) @@ -167,7 +161,7 @@ function _restrictionCount (licenceId, licenceMonitoringStations) { return count.length } -function _pageTitle (riverName, stationName) { +function _pageTitle(riverName, stationName) { if (riverName) { return `${riverName} at ${stationName}` } diff --git a/app/presenters/paginator.presenter.js b/app/presenters/paginator.presenter.js index 1b940a9fa3..02dda68821 100644 --- a/app/presenters/paginator.presenter.js +++ b/app/presenters/paginator.presenter.js @@ -109,7 +109,7 @@ const COMPLEX_END_PAGINATOR = 'end' * @returns {object} if no pagination is needed just the `numberOfPages` is returned else a `component:` property is * also included that can be directly passed to the `govukPagination()` in the view. */ -function go (numberOfRecords, selectedPageNumber, path) { +function go(numberOfRecords, selectedPageNumber, path) { const numberOfPages = Math.ceil(numberOfRecords / DatabaseConfig.defaultPageSize) if (numberOfPages < 2) { @@ -124,7 +124,7 @@ function go (numberOfRecords, selectedPageNumber, path) { } } -function _component (selectedPageNumber, numberOfPages, path) { +function _component(selectedPageNumber, numberOfPages, path) { const items = _items(selectedPageNumber, numberOfPages, path) const component = { items } @@ -140,7 +140,7 @@ function _component (selectedPageNumber, numberOfPages, path) { return component } -function _complexPaginatorEnd (selectedPageNumber, numberOfPages, path) { +function _complexPaginatorEnd(selectedPageNumber, numberOfPages, path) { const items = [] items.push(_item(1, selectedPageNumber, path)) @@ -154,7 +154,7 @@ function _complexPaginatorEnd (selectedPageNumber, numberOfPages, path) { return items } -function _complexPaginatorMiddle (selectedPageNumber, numberOfPages, path) { +function _complexPaginatorMiddle(selectedPageNumber, numberOfPages, path) { const items = [] items.push(_item(1, selectedPageNumber, path)) @@ -168,7 +168,7 @@ function _complexPaginatorMiddle (selectedPageNumber, numberOfPages, path) { return items } -function _complexPaginatorStart (selectedPageNumber, numberOfPages, path) { +function _complexPaginatorStart(selectedPageNumber, numberOfPages, path) { const items = [] items.push(_item(1, selectedPageNumber, path)) @@ -182,7 +182,7 @@ function _complexPaginatorStart (selectedPageNumber, numberOfPages, path) { return items } -function _item (pageNumber, selectedPageNumber, path) { +function _item(pageNumber, selectedPageNumber, path) { return { number: pageNumber, visuallyHiddenText: `Page ${pageNumber}`, @@ -191,7 +191,7 @@ function _item (pageNumber, selectedPageNumber, path) { } } -function _items (selectedPageNumber, numberOfPages, path) { +function _items(selectedPageNumber, numberOfPages, path) { const paginatorType = _paginatorType(selectedPageNumber, numberOfPages) let items @@ -213,7 +213,7 @@ function _items (selectedPageNumber, numberOfPages, path) { return items } -function _paginatorType (selectedPageNumber, numberOfPages) { +function _paginatorType(selectedPageNumber, numberOfPages) { if (numberOfPages <= 7) { return SIMPLE_PAGINATOR } @@ -222,14 +222,14 @@ function _paginatorType (selectedPageNumber, numberOfPages) { return COMPLEX_START_PAGINATOR } - if (selectedPageNumber >= (numberOfPages - 3)) { + if (selectedPageNumber >= numberOfPages - 3) { return COMPLEX_END_PAGINATOR } return COMPLEX_MIDDLE_PAGINATOR } -function _simplePaginator (selectedPageNumber, numberOfPages, path) { +function _simplePaginator(selectedPageNumber, numberOfPages, path) { const items = [] for (let i = 1; i <= numberOfPages; i++) { diff --git a/app/presenters/return-versions/setup/abstraction-period.presenter.js b/app/presenters/return-versions/setup/abstraction-period.presenter.js index 2168046e70..6bc8ecaa8a 100644 --- a/app/presenters/return-versions/setup/abstraction-period.presenter.js +++ b/app/presenters/return-versions/setup/abstraction-period.presenter.js @@ -13,7 +13,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex) { +function go(session, requirementIndex) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -26,7 +26,7 @@ function go (session, requirementIndex) { } } -function _backLink (session, requirementIndex) { +function _backLink(session, requirementIndex) { const { checkPageVisited, id } = session if (checkPageVisited) { diff --git a/app/presenters/return-versions/setup/additional-submission-options.presenter.js b/app/presenters/return-versions/setup/additional-submission-options.presenter.js index d6fdfdfb02..1880f166ae 100644 --- a/app/presenters/return-versions/setup/additional-submission-options.presenter.js +++ b/app/presenters/return-versions/setup/additional-submission-options.presenter.js @@ -14,10 +14,14 @@ const { isQuarterlyReturnSubmissions } = require('../../../lib/dates.lib.js') * * @returns {object} - The data formatted for the view template */ -function go (session) { +function go(session) { const { - id: sessionId, licence: { id: licenceId, licenceRef }, - multipleUpload, noAdditionalOptions, returnVersionStartDate, quarterlyReturns + id: sessionId, + licence: { id: licenceId, licenceRef }, + multipleUpload, + noAdditionalOptions, + returnVersionStartDate, + quarterlyReturns } = session return { diff --git a/app/presenters/return-versions/setup/agreements-exceptions.presenter.js b/app/presenters/return-versions/setup/agreements-exceptions.presenter.js index db31218d27..98592ab13a 100644 --- a/app/presenters/return-versions/setup/agreements-exceptions.presenter.js +++ b/app/presenters/return-versions/setup/agreements-exceptions.presenter.js @@ -13,7 +13,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex) { +function go(session, requirementIndex) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -26,7 +26,7 @@ function go (session, requirementIndex) { } } -function _backLink (session, requirementIndex) { +function _backLink(session, requirementIndex) { const { checkPageVisited, id } = session if (checkPageVisited) { diff --git a/app/presenters/return-versions/setup/cancel.presenter.js b/app/presenters/return-versions/setup/cancel.presenter.js index 06f7ec6f1f..62c2a725ec 100644 --- a/app/presenters/return-versions/setup/cancel.presenter.js +++ b/app/presenters/return-versions/setup/cancel.presenter.js @@ -15,7 +15,7 @@ const { returnRequirementFrequencies, returnRequirementReasons } = require('../. * * @returns {object} - The data formatted for the view template */ -function go (session) { +function go(session) { const { id: sessionId, journey, licence, reason, requirements } = session return { @@ -29,7 +29,7 @@ function go (session) { } } -function _returnRequirements (journey, requirements) { +function _returnRequirements(journey, requirements) { if (journey === 'no-returns-required') { return null } @@ -42,7 +42,7 @@ function _returnRequirements (journey, requirements) { }) } -function _startDate (session) { +function _startDate(session) { const { licence, startDateOptions, startDateDay, startDateMonth, startDateYear } = session let date diff --git a/app/presenters/return-versions/setup/check/check.presenter.js b/app/presenters/return-versions/setup/check/check.presenter.js index 937fe856d5..82e5f0de1e 100644 --- a/app/presenters/return-versions/setup/check/check.presenter.js +++ b/app/presenters/return-versions/setup/check/check.presenter.js @@ -16,10 +16,16 @@ const { returnRequirementReasons } = require('../../../../lib/static-lookups.lib * * @returns {object} The data formatted for the view template */ -function go (session) { +function go(session) { const { - id: sessionId, journey, licence, multipleUpload, note, reason, - returnVersionStartDate, quarterlyReturns + id: sessionId, + journey, + licence, + multipleUpload, + note, + reason, + returnVersionStartDate, + quarterlyReturns } = session const returnsRequired = journey === 'returns-required' @@ -38,7 +44,7 @@ function go (session) { } } -function _note (note) { +function _note(note) { if (note?.content) { return { actions: [ @@ -49,15 +55,13 @@ function _note (note) { } } else { return { - actions: [ - { text: 'Add a note', href: 'note' } - ], + actions: [{ text: 'Add a note', href: 'note' }], text: 'No notes added' } } } -function _reasonLink (sessionId, returnsRequired) { +function _reasonLink(sessionId, returnsRequired) { if (returnsRequired) { return `/system/return-versions/setup/${sessionId}/reason` } @@ -65,7 +69,7 @@ function _reasonLink (sessionId, returnsRequired) { return `/system/return-versions/setup/${sessionId}/no-returns-required` } -function _startDate (session) { +function _startDate(session) { return formatLongDate(new Date(session.returnVersionStartDate)) } diff --git a/app/presenters/return-versions/setup/check/returns-requirements.presenter.js b/app/presenters/return-versions/setup/check/returns-requirements.presenter.js index 2dc49239df..8ec918b0ca 100644 --- a/app/presenters/return-versions/setup/check/returns-requirements.presenter.js +++ b/app/presenters/return-versions/setup/check/returns-requirements.presenter.js @@ -26,14 +26,14 @@ const AGREEMENTS_EXCEPTIONS = { * * @returns {object} returns requirement data needed by the view template */ -function go (requirements, points, journey) { +function go(requirements, points, journey) { return { returnsRequired: journey === 'returns-required', requirements: _requirements(requirements, points) } } -function _abstractionPeriod (abstractionPeriod) { +function _abstractionPeriod(abstractionPeriod) { const { 'start-abstraction-period-day': startDay, 'start-abstraction-period-month': startMonth, @@ -46,7 +46,7 @@ function _abstractionPeriod (abstractionPeriod) { return `From ${startDate} to ${endDate}` } -function _agreementsExceptions (agreementsExceptions) { +function _agreementsExceptions(agreementsExceptions) { const formattedExceptions = agreementsExceptions.map((exception) => { return AGREEMENTS_EXCEPTIONS[exception] }) @@ -59,11 +59,14 @@ function _agreementsExceptions (agreementsExceptions) { return formattedExceptions.join(' and ') } - return formattedExceptions.slice(0, formattedExceptions.length - 1) - .join(', ') + ', and ' + formattedExceptions[formattedExceptions.length - 1] + return ( + formattedExceptions.slice(0, formattedExceptions.length - 1).join(', ') + + ', and ' + + formattedExceptions[formattedExceptions.length - 1] + ) } -function _requirements (requirements, points) { +function _requirements(requirements, points) { const completedRequirements = [] for (const [index, requirement] of requirements.entries()) { @@ -79,7 +82,7 @@ function _requirements (requirements, points) { return completedRequirements } -function _mapPurposes (purposes) { +function _mapPurposes(purposes) { return purposes.map((purpose) => { if (purpose.alias) { return `${purpose.description} (${purpose.alias})` @@ -89,7 +92,7 @@ function _mapPurposes (purposes) { }) } -function _mapRequirement (requirement, index, points) { +function _mapRequirement(requirement, index, points) { return { abstractionPeriod: _abstractionPeriod(requirement.abstractionPeriod), agreementsExceptions: _agreementsExceptions(requirement.agreementsExceptions), @@ -103,7 +106,7 @@ function _mapRequirement (requirement, index, points) { } } -function _mapPoints (selectedPoints, points) { +function _mapPoints(selectedPoints, points) { return selectedPoints.map((selectedPoint) => { const matchedPoint = points.find((point) => { return point.id === selectedPoint diff --git a/app/presenters/return-versions/setup/existing.presenter.js b/app/presenters/return-versions/setup/existing.presenter.js index e0cb4edb32..c5d9a70331 100644 --- a/app/presenters/return-versions/setup/existing.presenter.js +++ b/app/presenters/return-versions/setup/existing.presenter.js @@ -15,7 +15,7 @@ const { returnRequirementReasons } = require('../../../lib/static-lookups.lib.js * * @returns {object} The data formatted for the view template */ -function go (session) { +function go(session) { const { id: sessionId, licence } = session return { @@ -26,7 +26,7 @@ function go (session) { } } -function _existingOptions (returnVersions) { +function _existingOptions(returnVersions) { return returnVersions.map((returnVersion) => { const { id, startDate } = returnVersion const reason = _reason(returnVersion) @@ -43,7 +43,7 @@ function _existingOptions (returnVersions) { }) } -function _reason (returnVersion) { +function _reason(returnVersion) { const { modLogs, reason } = returnVersion // The return version was created in WRLS or we were able to map the NALD reason during import diff --git a/app/presenters/return-versions/setup/frequency-collected.presenter.js b/app/presenters/return-versions/setup/frequency-collected.presenter.js index 64986724f5..dd1b33b1b8 100644 --- a/app/presenters/return-versions/setup/frequency-collected.presenter.js +++ b/app/presenters/return-versions/setup/frequency-collected.presenter.js @@ -13,7 +13,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex) { +function go(session, requirementIndex) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -26,7 +26,7 @@ function go (session, requirementIndex) { } } -function _backLink (session, requirementIndex) { +function _backLink(session, requirementIndex) { const { checkPageVisited, id } = session if (checkPageVisited) { diff --git a/app/presenters/return-versions/setup/frequency-reported.presenter.js b/app/presenters/return-versions/setup/frequency-reported.presenter.js index 130b31f7ad..969247b45a 100644 --- a/app/presenters/return-versions/setup/frequency-reported.presenter.js +++ b/app/presenters/return-versions/setup/frequency-reported.presenter.js @@ -13,7 +13,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex) { +function go(session, requirementIndex) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -26,7 +26,7 @@ function go (session, requirementIndex) { } } -function _backLink (session, requirementIndex) { +function _backLink(session, requirementIndex) { const { checkPageVisited, id } = session if (checkPageVisited) { diff --git a/app/presenters/return-versions/setup/method.presenter.js b/app/presenters/return-versions/setup/method.presenter.js index 8dc26c4d70..7ac671e6bb 100644 --- a/app/presenters/return-versions/setup/method.presenter.js +++ b/app/presenters/return-versions/setup/method.presenter.js @@ -12,7 +12,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session) { +function go(session) { const { id: sessionId, licence, method } = session return { diff --git a/app/presenters/return-versions/setup/no-returns-required.presenter.js b/app/presenters/return-versions/setup/no-returns-required.presenter.js index e44002eeae..809e7e6e55 100644 --- a/app/presenters/return-versions/setup/no-returns-required.presenter.js +++ b/app/presenters/return-versions/setup/no-returns-required.presenter.js @@ -12,7 +12,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session) { +function go(session) { const { id: sessionId, licence, reason } = session return { @@ -23,7 +23,7 @@ function go (session) { } } -function _backLink (session) { +function _backLink(session) { const { checkPageVisited, id } = session if (checkPageVisited) { diff --git a/app/presenters/return-versions/setup/note.presenter.js b/app/presenters/return-versions/setup/note.presenter.js index 6cc3544ef2..0ebbe125c7 100644 --- a/app/presenters/return-versions/setup/note.presenter.js +++ b/app/presenters/return-versions/setup/note.presenter.js @@ -12,7 +12,7 @@ * * @returns {object} The data formatted for the view template */ -function go (session) { +function go(session) { const { id: sessionId, licence, note } = session return { diff --git a/app/presenters/return-versions/setup/points.presenter.js b/app/presenters/return-versions/setup/points.presenter.js index c3ef68d3a3..2a1d575a56 100644 --- a/app/presenters/return-versions/setup/points.presenter.js +++ b/app/presenters/return-versions/setup/points.presenter.js @@ -15,7 +15,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex, points) { +function go(session, requirementIndex, points) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -29,7 +29,7 @@ function go (session, requirementIndex, points) { } } -function _backLink (session, requirementIndex) { +function _backLink(session, requirementIndex) { const { checkPageVisited, id } = session if (checkPageVisited) { @@ -39,7 +39,7 @@ function _backLink (session, requirementIndex) { return `/system/return-versions/setup/${id}/purpose/${requirementIndex}` } -function _licencePoints (points) { +function _licencePoints(points) { // First extract our points from the data, including generating the descriptions const licencePoints = points.map((point) => { return { diff --git a/app/presenters/return-versions/setup/purpose.presenter.js b/app/presenters/return-versions/setup/purpose.presenter.js index 0bdb208c22..a4857d153b 100644 --- a/app/presenters/return-versions/setup/purpose.presenter.js +++ b/app/presenters/return-versions/setup/purpose.presenter.js @@ -14,7 +14,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex, licencePurposes) { +function go(session, requirementIndex, licencePurposes) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -27,7 +27,7 @@ function go (session, requirementIndex, licencePurposes) { } } -function _backLink (session) { +function _backLink(session) { const { checkPageVisited, id, requirements } = session // NOTE: Purpose is the first page in the manual setup journey. So, when a user first comes through, we want to allow @@ -46,7 +46,7 @@ function _backLink (session) { return `/system/return-versions/setup/${id}/method` } -function _purposes (licencePurposes, requirementPurposes) { +function _purposes(licencePurposes, requirementPurposes) { return licencePurposes.map((licencePurpose) => { const matchedRequirementPurpose = requirementPurposes?.find((requirementPurpose) => { return requirementPurpose.id === licencePurpose.id diff --git a/app/presenters/return-versions/setup/reason.presenter.js b/app/presenters/return-versions/setup/reason.presenter.js index a6faa5a49e..9bf2cfaaa1 100644 --- a/app/presenters/return-versions/setup/reason.presenter.js +++ b/app/presenters/return-versions/setup/reason.presenter.js @@ -12,7 +12,7 @@ * * @returns {object} The data formatted for the view template */ -function go (session) { +function go(session) { const { id: sessionId, licence, reason } = session return { @@ -23,7 +23,7 @@ function go (session) { } } -function _backLink (session) { +function _backLink(session) { const { checkPageVisited, id } = session if (checkPageVisited) { diff --git a/app/presenters/return-versions/setup/remove.presenter.js b/app/presenters/return-versions/setup/remove.presenter.js index 17d72660b7..4c95786f55 100644 --- a/app/presenters/return-versions/setup/remove.presenter.js +++ b/app/presenters/return-versions/setup/remove.presenter.js @@ -16,7 +16,7 @@ const { returnRequirementFrequencies } = require('../../../lib/static-lookups.li * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex) { +function go(session, requirementIndex) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -30,20 +30,20 @@ function go (session, requirementIndex) { } } -function _backLink (session) { +function _backLink(session) { const { id } = session return `/system/return-versions/setup/${id}/check` } -function _formattedReturnRequirement (requirement) { +function _formattedReturnRequirement(requirement) { const { frequencyReported, returnsCycle, siteDescription } = requirement const cycle = returnsCycle === 'summer' ? 'Summer' : 'Winter and all year' return `${cycle} ${returnRequirementFrequencies[frequencyReported]} requirements for returns, ${siteDescription}.` } -function _startDate (session) { +function _startDate(session) { const selectedOption = session.startDateOptions let date diff --git a/app/presenters/return-versions/setup/returns-cycle.presenter.js b/app/presenters/return-versions/setup/returns-cycle.presenter.js index df66d459ca..40f92f95c4 100644 --- a/app/presenters/return-versions/setup/returns-cycle.presenter.js +++ b/app/presenters/return-versions/setup/returns-cycle.presenter.js @@ -13,7 +13,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex) { +function go(session, requirementIndex) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -26,7 +26,7 @@ function go (session, requirementIndex) { } } -function _backLink (session, requirementIndex) { +function _backLink(session, requirementIndex) { const { checkPageVisited, id } = session if (checkPageVisited) { diff --git a/app/presenters/return-versions/setup/site-description.presenter.js b/app/presenters/return-versions/setup/site-description.presenter.js index cb373eef61..d3d9af5e82 100644 --- a/app/presenters/return-versions/setup/site-description.presenter.js +++ b/app/presenters/return-versions/setup/site-description.presenter.js @@ -13,7 +13,7 @@ * * @returns {object} - The data formatted for the view template */ -function go (session, requirementIndex) { +function go(session, requirementIndex) { const { id: sessionId, licence, requirements } = session const requirement = requirements[requirementIndex] @@ -26,7 +26,7 @@ function go (session, requirementIndex) { } } -function _backLink (session, requirementIndex) { +function _backLink(session, requirementIndex) { const { checkPageVisited, id } = session if (checkPageVisited) { diff --git a/app/presenters/return-versions/setup/start-date.presenter.js b/app/presenters/return-versions/setup/start-date.presenter.js index 8bdefa13ed..ba229a7917 100644 --- a/app/presenters/return-versions/setup/start-date.presenter.js +++ b/app/presenters/return-versions/setup/start-date.presenter.js @@ -15,15 +15,8 @@ const { formatLongDate } = require('../../base.presenter.js') * * @returns {object} The data formatted for the view template */ -function go (session) { - const { - id: sessionId, - licence, - startDateOptions, - startDateDay, - startDateMonth, - startDateYear - } = session +function go(session) { + const { id: sessionId, licence, startDateOptions, startDateDay, startDateMonth, startDateYear } = session return { anotherStartDateDay: startDateDay ?? null, @@ -38,7 +31,7 @@ function go (session) { } } -function _backLink (session) { +function _backLink(session) { const { checkPageVisited, id, licence } = session if (checkPageVisited) { @@ -52,7 +45,7 @@ function _backLink (session) { } } -function _licenceVersionStartDate (licence) { +function _licenceVersionStartDate(licence) { const { currentVersionStartDate } = licence // NOTE: because the session data is stored in a JSONB field when we get the instance from the DB the date values are diff --git a/app/presenters/return-versions/view.presenter.js b/app/presenters/return-versions/view.presenter.js index 1384a49418..cf223b6145 100644 --- a/app/presenters/return-versions/view.presenter.js +++ b/app/presenters/return-versions/view.presenter.js @@ -18,9 +18,8 @@ const { returnRequirementReasons, returnRequirementFrequencies } = require('../. * * @returns {object} page data needed by the view template */ -function go (returnVersion) { - const { licence, multipleUpload, quarterlyReturns, returnRequirements, startDate, status } = - returnVersion +function go(returnVersion) { + const { licence, multipleUpload, quarterlyReturns, returnRequirements, startDate, status } = returnVersion return { createdBy: _createdBy(returnVersion), @@ -39,13 +38,9 @@ function go (returnVersion) { } } -function _abstractionPeriod (requirement) { - const { - abstractionPeriodStartDay, - abstractionPeriodStartMonth, - abstractionPeriodEndDay, - abstractionPeriodEndMonth - } = requirement +function _abstractionPeriod(requirement) { + const { abstractionPeriodStartDay, abstractionPeriodStartMonth, abstractionPeriodEndDay, abstractionPeriodEndMonth } = + requirement const startDate = formatAbstractionDate(abstractionPeriodStartDay, abstractionPeriodStartMonth) const endDate = formatAbstractionDate(abstractionPeriodEndDay, abstractionPeriodEndMonth) @@ -53,7 +48,7 @@ function _abstractionPeriod (requirement) { return `From ${startDate} to ${endDate}` } -function _agreementsExceptions (returnRequirement) { +function _agreementsExceptions(returnRequirement) { const agreementsExceptions = _buildAgreementExceptions(returnRequirement) if (agreementsExceptions.length === 1) { @@ -64,11 +59,14 @@ function _agreementsExceptions (returnRequirement) { return agreementsExceptions.join(' and ') } - return agreementsExceptions.slice(0, agreementsExceptions.length - 1) - .join(', ') + ', and ' + agreementsExceptions[agreementsExceptions.length - 1] + return ( + agreementsExceptions.slice(0, agreementsExceptions.length - 1).join(', ') + + ', and ' + + agreementsExceptions[agreementsExceptions.length - 1] + ) } -function _buildAgreementExceptions (returnRequirement) { +function _buildAgreementExceptions(returnRequirement) { const { fiftySixException, gravityFill, reabstraction, twoPartTariff } = returnRequirement const agreementsExceptions = [] @@ -95,7 +93,7 @@ function _buildAgreementExceptions (returnRequirement) { return agreementsExceptions } -function _createdBy (returnVersion) { +function _createdBy(returnVersion) { const createdBy = returnVersion.$createdBy() if (createdBy) { @@ -105,7 +103,7 @@ function _createdBy (returnVersion) { return 'Migrated from NALD' } -function _mapRequirement (requirement) { +function _mapRequirement(requirement) { return { abstractionPeriod: _abstractionPeriod(requirement), agreementsExceptions: _agreementsExceptions(requirement), @@ -120,7 +118,7 @@ function _mapRequirement (requirement) { } } -function _purposes (returnRequirementPurposes) { +function _purposes(returnRequirementPurposes) { return returnRequirementPurposes.map((returnRequirementPurpose) => { if (returnRequirementPurpose.alias) { return `${returnRequirementPurpose.purpose.description} (${returnRequirementPurpose.alias})` @@ -130,7 +128,7 @@ function _purposes (returnRequirementPurposes) { }) } -function _points (points) { +function _points(points) { return points.map((point) => { return point.$describe() }) @@ -144,7 +142,7 @@ function _points (points) { * * @private */ -function _reason (returnVersion) { +function _reason(returnVersion) { const reason = returnVersion.$reason() const mappedReason = returnRequirementReasons[reason] @@ -155,7 +153,7 @@ function _reason (returnVersion) { return reason ?? '' } -function _requirements (requirements) { +function _requirements(requirements) { return requirements.map((requirement) => { return _mapRequirement(requirement) }) diff --git a/app/requests/base.request.js b/app/requests/base.request.js index a6c1c46a08..d432ac0610 100644 --- a/app/requests/base.request.js +++ b/app/requests/base.request.js @@ -23,7 +23,7 @@ const requestConfig = require('../../config/request.config.js') * * @returns {object} default options to pass to Got when making a request */ -function defaultOptions () { +function defaultOptions() { return { // This uses the ternary operator to give either an `agent` object or an empty object, and the spread operator to // bring the result back into the top level of the `defaultOptions` object. @@ -61,9 +61,7 @@ function defaultOptions () { request: requestConfig.timeout }, hooks: { - beforeRetry: [ - _beforeRetryHook - ] + beforeRetry: [_beforeRetryHook] } } } @@ -78,7 +76,7 @@ function defaultOptions () { * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function deleteRequest (url, additionalOptions = {}) { +async function deleteRequest(url, additionalOptions = {}) { return _sendRequest('delete', url, additionalOptions) } @@ -103,7 +101,7 @@ async function deleteRequest (url, additionalOptions = {}) { * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function get (url, additionalOptions = {}) { +async function get(url, additionalOptions = {}) { return _sendRequest('get', url, additionalOptions) } @@ -128,7 +126,7 @@ async function get (url, additionalOptions = {}) { * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function patch (url, additionalOptions = {}) { +async function patch(url, additionalOptions = {}) { return _sendRequest('patch', url, additionalOptions) } @@ -153,15 +151,15 @@ async function patch (url, additionalOptions = {}) { * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function post (url, additionalOptions = {}) { +async function post(url, additionalOptions = {}) { return _sendRequest('post', url, additionalOptions) } -function _beforeRetryHook (error, retryCount) { +function _beforeRetryHook(error, retryCount) { global.GlobalNotifier.omg('Retrying HTTP request', { error, retryCount }) } -async function _importGot () { +async function _importGot() { // As of v12, the got dependency no longer supports CJS modules. This causes us a problem as we are locked into // using these for the time being. Some workarounds are provided here: // https://github.com/sindresorhus/got/issues/1789 We have gone the route of using await import('got'). We cannot do @@ -188,7 +186,7 @@ async function _importGot () { * * @private */ -function _logFailure (method, result, url, additionalOptions) { +function _logFailure(method, result, url, additionalOptions) { const data = { method, url, @@ -222,11 +220,11 @@ function _logFailure (method, result, url, additionalOptions) { * * @private */ -function _requestOptions (additionalOptions) { +function _requestOptions(additionalOptions) { return { ...defaultOptions(), ...additionalOptions } } -async function _sendRequest (method, url, additionalOptions) { +async function _sendRequest(method, url, additionalOptions) { const got = await _importGot() const result = { succeeded: false, diff --git a/app/requests/charging-module.request.js b/app/requests/charging-module.request.js index 3b88975e2c..7174adc9b2 100644 --- a/app/requests/charging-module.request.js +++ b/app/requests/charging-module.request.js @@ -19,7 +19,7 @@ const servicesConfig = require('../../config/services.config.js') * * @returns {Promise} An object representing the result of the request */ -async function deleteRequest (path) { +async function deleteRequest(path) { const result = await _sendRequest(path, BaseRequest.delete) return _parseResult(result) @@ -32,7 +32,7 @@ async function deleteRequest (path) { * * @returns {Promise} An object representing the result of the request */ -async function get (path) { +async function get(path) { const result = await _sendRequest(path, BaseRequest.get) return _parseResult(result) @@ -45,7 +45,7 @@ async function get (path) { * * @returns {Promise} An object representing the result of the request */ -async function patch (path) { +async function patch(path) { const result = await _sendRequest(path, BaseRequest.patch) return _parseResult(result) @@ -59,7 +59,7 @@ async function patch (path) { * * @returns {Promise} An object representing the result of the request */ -async function post (path, body = {}) { +async function post(path, body = {}) { const result = await _sendRequest(path, BaseRequest.post, body) return _parseResult(result) @@ -70,7 +70,7 @@ async function post (path, body = {}) { * * @private */ -async function _sendRequest (path, method, body) { +async function _sendRequest(path, method, body) { const authentication = await global.HapiServerMethods.getChargingModuleToken() const options = _requestOptions(authentication.accessToken, body) @@ -92,7 +92,7 @@ async function _sendRequest (path, method, body) { * * @private */ -function _requestOptions (accessToken, body) { +function _requestOptions(accessToken, body) { return { prefixUrl: servicesConfig.chargingModule.url, headers: { @@ -111,7 +111,7 @@ function _requestOptions (accessToken, body) { * * @private */ -function _parseResult (result) { +function _parseResult(result) { const { body, headers, statusCode } = result.response if (body) { diff --git a/app/requests/charging-module/calculate-charge.request.js b/app/requests/charging-module/calculate-charge.request.js index eb56ec10a0..52e72bb139 100644 --- a/app/requests/charging-module/calculate-charge.request.js +++ b/app/requests/charging-module/calculate-charge.request.js @@ -17,7 +17,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (transactionData) { +async function send(transactionData) { const path = 'v3/wrls/calculate-charge' return ChargingModuleRequest.post(path, transactionData) diff --git a/app/requests/charging-module/create-bill-run.request.js b/app/requests/charging-module/create-bill-run.request.js index 202ec9a4ea..7f395f98f2 100644 --- a/app/requests/charging-module/create-bill-run.request.js +++ b/app/requests/charging-module/create-bill-run.request.js @@ -19,7 +19,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (regionId, ruleset) { +async function send(regionId, ruleset) { const region = await _getChargeRegionId(regionId) const result = await ChargingModuleRequest.post('v3/wrls/bill-runs', { region, ruleset }) @@ -32,10 +32,8 @@ async function send (regionId, ruleset) { * * @private */ -async function _getChargeRegionId (regionId) { - const result = await RegionModel.query() - .findById(regionId) - .select('chargeRegionId') +async function _getChargeRegionId(regionId) { + const result = await RegionModel.query().findById(regionId).select('chargeRegionId') return result.chargeRegionId } diff --git a/app/requests/charging-module/create-customer-change.request.js b/app/requests/charging-module/create-customer-change.request.js index a4094bd5ff..3779be75df 100644 --- a/app/requests/charging-module/create-customer-change.request.js +++ b/app/requests/charging-module/create-customer-change.request.js @@ -17,7 +17,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (customerChangeData) { +async function send(customerChangeData) { const path = 'v3/wrls/customer-changes' return ChargingModuleRequest.post(path, customerChangeData) diff --git a/app/requests/charging-module/create-transaction.request.js b/app/requests/charging-module/create-transaction.request.js index af180d099f..64146c238c 100644 --- a/app/requests/charging-module/create-transaction.request.js +++ b/app/requests/charging-module/create-transaction.request.js @@ -18,7 +18,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId, transactionData) { +async function send(billRunId, transactionData) { const path = `v3/wrls/bill-runs/${billRunId}/transactions` return ChargingModuleRequest.post(path, transactionData) diff --git a/app/requests/charging-module/delete-bill-run.request.js b/app/requests/charging-module/delete-bill-run.request.js index 741f546121..18082cc754 100644 --- a/app/requests/charging-module/delete-bill-run.request.js +++ b/app/requests/charging-module/delete-bill-run.request.js @@ -17,7 +17,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId) { +async function send(billRunId) { const path = `v3/wrls/bill-runs/${billRunId}` return ChargingModuleRequest.delete(path) diff --git a/app/requests/charging-module/generate-bill-run.request.js b/app/requests/charging-module/generate-bill-run.request.js index 8740b4f71c..4444745e4f 100644 --- a/app/requests/charging-module/generate-bill-run.request.js +++ b/app/requests/charging-module/generate-bill-run.request.js @@ -17,7 +17,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId) { +async function send(billRunId) { const path = `v3/wrls/bill-runs/${billRunId}/generate` return ChargingModuleRequest.patch(path) diff --git a/app/requests/charging-module/reissue-bill.request.js b/app/requests/charging-module/reissue-bill.request.js index 3f97336bf0..0a19f08577 100644 --- a/app/requests/charging-module/reissue-bill.request.js +++ b/app/requests/charging-module/reissue-bill.request.js @@ -20,7 +20,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId, billId) { +async function send(billRunId, billId) { const path = `v3/wrls/bill-runs/${billRunId}/invoices/${billId}/rebill` return ChargingModuleRequest.patch(path) diff --git a/app/requests/charging-module/send-bill-run.request.js b/app/requests/charging-module/send-bill-run.request.js index ab3c831af6..9ad65f91f6 100644 --- a/app/requests/charging-module/send-bill-run.request.js +++ b/app/requests/charging-module/send-bill-run.request.js @@ -33,49 +33,50 @@ const WaitForStatusRequest = require('./wait-for-status.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId) { +async function send(billRunId) { await _approve(billRunId) await _send(billRunId) return _waitForSent(billRunId) } -async function _approve (billRunId) { +async function _approve(billRunId) { const path = `v3/wrls/bill-runs/${billRunId}/approve` const result = await ChargingModuleRequest.patch(path) if (!result.succeeded) { - const error = new ExpandedError( - 'Charging Module approve request failed', - { billRunExternalId: billRunId, responseBody: result.response.body } - ) + const error = new ExpandedError('Charging Module approve request failed', { + billRunExternalId: billRunId, + responseBody: result.response.body + }) throw error } } -async function _send (billRunId) { +async function _send(billRunId) { const path = `v3/wrls/bill-runs/${billRunId}/send` const result = await ChargingModuleRequest.patch(path) if (!result.succeeded) { - const error = new ExpandedError( - 'Charging Module send request failed', - { billRunExternalId: billRunId, responseBody: result.response.body } - ) + const error = new ExpandedError('Charging Module send request failed', { + billRunExternalId: billRunId, + responseBody: result.response.body + }) throw error } } -async function _waitForSent (billRunId) { +async function _waitForSent(billRunId) { const result = await WaitForStatusRequest.send(billRunId, ['billed', 'billing_not_required']) if (!result.succeeded) { - const error = new ExpandedError( - 'Charging Module wait request failed', - { billRunExternalId: billRunId, attempts: result.attempts, responseBody: result.response.body } - ) + const error = new ExpandedError('Charging Module wait request failed', { + billRunExternalId: billRunId, + attempts: result.attempts, + responseBody: result.response.body + }) throw error } diff --git a/app/requests/charging-module/token.request.js b/app/requests/charging-module/token.request.js index 9f9f13b094..0f0b5d1347 100644 --- a/app/requests/charging-module/token.request.js +++ b/app/requests/charging-module/token.request.js @@ -14,7 +14,7 @@ const servicesConfig = require('../../../config/services.config.js') * * @returns {Promise} An object containing the `accessToken:` to use in future Charging Module requests */ -async function send () { +async function send() { const url = new URL('/oauth2/token', servicesConfig.chargingModule.token.url) const result = await BaseRequest.post(url.href, _options()) @@ -22,7 +22,7 @@ async function send () { return _parseResult(result) } -function _options () { +function _options() { return { searchParams: { grant_type: 'client_credentials' @@ -34,7 +34,7 @@ function _options () { } } -function _encodeAuthorisation () { +function _encodeAuthorisation() { const keys = Buffer.from( `${servicesConfig.chargingModule.token.username}:${servicesConfig.chargingModule.token.password}` ) @@ -42,7 +42,7 @@ function _encodeAuthorisation () { return keys.toString('base64') } -function _parseResult (result) { +function _parseResult(result) { const authentication = { accessToken: null, expiresIn: null diff --git a/app/requests/charging-module/view-bill-run-status.request.js b/app/requests/charging-module/view-bill-run-status.request.js index 19f709e62c..924b960260 100644 --- a/app/requests/charging-module/view-bill-run-status.request.js +++ b/app/requests/charging-module/view-bill-run-status.request.js @@ -17,7 +17,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId) { +async function send(billRunId) { const path = `v3/wrls/bill-runs/${billRunId}/status` return ChargingModuleRequest.get(path) diff --git a/app/requests/charging-module/view-bill-run.request.js b/app/requests/charging-module/view-bill-run.request.js index fe5f38714e..5dcb9b9a73 100644 --- a/app/requests/charging-module/view-bill-run.request.js +++ b/app/requests/charging-module/view-bill-run.request.js @@ -17,7 +17,7 @@ const ChargingModuleRequest = require('../../requests/charging-module.request.js * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId) { +async function send(billRunId) { const path = `v3/wrls/bill-runs/${billRunId}` const result = await ChargingModuleRequest.get(path) diff --git a/app/requests/charging-module/view-bill.request.js b/app/requests/charging-module/view-bill.request.js index be7c6fe7fd..f67151c5c4 100644 --- a/app/requests/charging-module/view-bill.request.js +++ b/app/requests/charging-module/view-bill.request.js @@ -18,7 +18,7 @@ const ChargingModuleRequest = require('../charging-module.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId, billId) { +async function send(billRunId, billId) { const path = `v3/wrls/bill-runs/${billRunId}/invoices/${billId}` return ChargingModuleRequest.get(path) diff --git a/app/requests/charging-module/wait-for-status.request.js b/app/requests/charging-module/wait-for-status.request.js index 2293c67210..ad43b6d5da 100644 --- a/app/requests/charging-module/wait-for-status.request.js +++ b/app/requests/charging-module/wait-for-status.request.js @@ -45,7 +45,7 @@ const billingConfig = require('../../../config/billing.config.js') * * @returns {Promise} returns the results of the wait */ -async function send (billRunId, statusesToWaitFor, maximumAttempts = 120) { +async function send(billRunId, statusesToWaitFor, maximumAttempts = 120) { let attempts = 0 let status @@ -81,15 +81,15 @@ async function send (billRunId, statusesToWaitFor, maximumAttempts = 120) { * * @private */ -function _pause () { +function _pause() { return setTimeout(billingConfig.waitForStatusPauseInMs) } -function _requestFailed (billRunId, result) { - const error = new ExpandedError( - 'Charging Module wait for status request failed', - { billRunExternalId: billRunId, responseBody: result.response.body } - ) +function _requestFailed(billRunId, result) { + const error = new ExpandedError('Charging Module wait for status request failed', { + billRunExternalId: billRunId, + responseBody: result.response.body + }) throw error } diff --git a/app/requests/legacy.request.js b/app/requests/legacy.request.js index de539f6db2..70911be089 100644 --- a/app/requests/legacy.request.js +++ b/app/requests/legacy.request.js @@ -71,7 +71,7 @@ const services = { * * @returns {Promise} An object representing the result of the request */ -async function deleteRequest (serviceName, path, userId = null, apiRequest = true) { +async function deleteRequest(serviceName, path, userId = null, apiRequest = true) { return _sendRequest(BaseRequest.delete, serviceName, path, userId, apiRequest) } @@ -88,7 +88,7 @@ async function deleteRequest (serviceName, path, userId = null, apiRequest = tru * * @returns {Promise} An object representing the result of the request */ -async function get (serviceName, path, userId = null, apiRequest = true) { +async function get(serviceName, path, userId = null, apiRequest = true) { return _sendRequest(BaseRequest.get, serviceName, path, userId, apiRequest) } @@ -106,7 +106,7 @@ async function get (serviceName, path, userId = null, apiRequest = true) { * * @returns {Promise} An object representing the result of the request */ -async function post (serviceName, path, userId = null, apiRequest = true, body = {}) { +async function post(serviceName, path, userId = null, apiRequest = true, body = {}) { return _sendRequest(BaseRequest.post, serviceName, path, userId, apiRequest, body) } @@ -115,7 +115,7 @@ async function post (serviceName, path, userId = null, apiRequest = true, body = * * @private */ -async function _sendRequest (method, serviceName, path, userId, apiRequest, body) { +async function _sendRequest(method, serviceName, path, userId, apiRequest, body) { const service = _service(serviceName) const options = _requestOptions(service, userId, apiRequest, body) @@ -124,7 +124,7 @@ async function _sendRequest (method, serviceName, path, userId, apiRequest, body return _parseResult(result) } -function _service (serviceName) { +function _service(serviceName) { const service = services[serviceName.trim().toLowerCase()] if (!service) { @@ -147,7 +147,7 @@ function _service (serviceName) { * * @private */ -function _requestOptions (service, userId, apiRequest, body) { +function _requestOptions(service, userId, apiRequest, body) { const prefixUrl = apiRequest ? new URL(service.api, service.base).href : service.base const headers = { @@ -183,7 +183,7 @@ function _requestOptions (service, userId, apiRequest, body) { * * @private */ -function _parseResult (result) { +function _parseResult(result) { const { body, statusCode } = result.response if (body) { diff --git a/app/requests/legacy/create-bill-run.request.js b/app/requests/legacy/create-bill-run.request.js index ee55938a43..81a933a5c9 100644 --- a/app/requests/legacy/create-bill-run.request.js +++ b/app/requests/legacy/create-bill-run.request.js @@ -20,7 +20,7 @@ const LegacyRequest = require('../legacy.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (batchType, regionId, financialYearEnding, user, summer = false) { +async function send(batchType, regionId, financialYearEnding, user, summer = false) { const { id: userId, username: userEmail } = user const path = 'billing/batches' diff --git a/app/requests/legacy/delete-bill-licence.request.js b/app/requests/legacy/delete-bill-licence.request.js index 6bccf6b40e..0021e01713 100644 --- a/app/requests/legacy/delete-bill-licence.request.js +++ b/app/requests/legacy/delete-bill-licence.request.js @@ -24,7 +24,7 @@ const LegacyRequest = require('../legacy.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billLicenceId, user) { +async function send(billLicenceId, user) { const { id: userId } = user const path = `billing/invoice-licences/${billLicenceId}` diff --git a/app/requests/legacy/delete-bill.request.js b/app/requests/legacy/delete-bill.request.js index f7d9ec9bcf..7d105b2750 100644 --- a/app/requests/legacy/delete-bill.request.js +++ b/app/requests/legacy/delete-bill.request.js @@ -25,7 +25,7 @@ const LegacyRequest = require('../legacy.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId, billId, user) { +async function send(billRunId, billId, user) { const { id: userId } = user const path = `billing/batches/${billRunId}/invoices/${billId}` diff --git a/app/requests/legacy/refresh-bill-run.request.js b/app/requests/legacy/refresh-bill-run.request.js index f90b6ba10c..c5016845f1 100644 --- a/app/requests/legacy/refresh-bill-run.request.js +++ b/app/requests/legacy/refresh-bill-run.request.js @@ -21,7 +21,7 @@ const LegacyRequest = require('../legacy.request.js') * * @returns {Promise} The result of the request; whether it succeeded and the response or error returned */ -async function send (billRunId) { +async function send(billRunId) { const path = `billing/batches/${billRunId}/refresh` return LegacyRequest.post('water', path) diff --git a/app/routes/assets.routes.js b/app/routes/assets.routes.js index 215243dff7..d8587f84c4 100644 --- a/app/routes/assets.routes.js +++ b/app/routes/assets.routes.js @@ -13,17 +13,14 @@ const routes = [ }, auth: false } - }, { + }, + { method: 'GET', path: '/assets/{path*}', options: { handler: { directory: { - path: [ - 'app/public/static', - 'app/public/build', - 'node_modules/govuk-frontend/govuk/assets' - ] + path: ['app/public/static', 'app/public/build', 'node_modules/govuk-frontend/govuk/assets'] } }, app: { diff --git a/app/routes/return-versions-setup.routes.js b/app/routes/return-versions-setup.routes.js index 74b7896e4e..c65224cff4 100644 --- a/app/routes/return-versions-setup.routes.js +++ b/app/routes/return-versions-setup.routes.js @@ -38,7 +38,6 @@ const routes = [ } } } - }, { method: 'GET', @@ -459,7 +458,8 @@ const routes = [ } } } - }, { + }, + { method: 'POST', path: '/return-versions/setup/{sessionId}/start-date', options: { diff --git a/app/services/bill-licences/fetch-bill-licence-summary.service.js b/app/services/bill-licences/fetch-bill-licence-summary.service.js index d73208ad4e..e0cdc1f759 100644 --- a/app/services/bill-licences/fetch-bill-licence-summary.service.js +++ b/app/services/bill-licences/fetch-bill-licence-summary.service.js @@ -21,56 +21,34 @@ const BillLicenceModel = require('../../models/bill-licence.model.js') * @returns {Promise} the matching instance of BillLicenceModel plus the linked bill, billing account and bill * run. Also all transactions linked to the bill licence so we can work out the total for the licence */ -async function go (billLicenceId) { +async function go(billLicenceId) { return _fetchBillLicence(billLicenceId) } -async function _fetchBillLicence (billLicenceId) { +async function _fetchBillLicence(billLicenceId) { const results = await BillLicenceModel.query() .findById(billLicenceId) - .select([ - 'id', - 'licenceId', - 'licenceRef' - ]) + .select(['id', 'licenceId', 'licenceRef']) .withGraphFetched('bill') .modifyGraph('bill', (builder) => { - builder.select([ - 'id', - 'accountNumber' - ]) + builder.select(['id', 'accountNumber']) }) .withGraphFetched('bill.billingAccount') .modifyGraph('bill.billingAccount', (builder) => { - builder.select([ - 'id', - 'accountNumber' - ]) + builder.select(['id', 'accountNumber']) }) .withGraphFetched('bill.billingAccount.company') .modifyGraph('bill.billingAccount.company', (builder) => { - builder.select([ - 'id', - 'name', - 'type' - ]) + builder.select(['id', 'name', 'type']) }) .withGraphFetched('bill.billingAccount.billingAccountAddresses') // The current billing account address is denoted by the fact it is the only one with a null end date .modifyGraph('bill.billingAccount.billingAccountAddresses', (builder) => { - builder - .select([ - 'id' - ]) - .whereNull('endDate') + builder.select(['id']).whereNull('endDate') }) .withGraphFetched('bill.billingAccount.billingAccountAddresses.company') .modifyGraph('bill.billingAccount.billingAccountAddresses.company', (builder) => { - builder.select([ - 'id', - 'name', - 'type' - ]) + builder.select(['id', 'name', 'type']) }) .withGraphFetched('bill.billingAccount.billingAccountAddresses.contact') .modifyGraph('bill.billingAccount.billingAccountAddresses.contact', (builder) => { @@ -102,18 +80,11 @@ async function _fetchBillLicence (billLicenceId) { }) .withGraphFetched('bill.billRun.region') .modifyGraph('bill.billRun.region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) .withGraphFetched('transactions') .modifyGraph('transactions', (builder) => { - builder.select([ - 'id', - 'credit', - 'netAmount' - ]) + builder.select(['id', 'credit', 'netAmount']) }) return results diff --git a/app/services/bill-licences/fetch-bill-licence.service.js b/app/services/bill-licences/fetch-bill-licence.service.js index 08413d6305..61f4826a1f 100644 --- a/app/services/bill-licences/fetch-bill-licence.service.js +++ b/app/services/bill-licences/fetch-bill-licence.service.js @@ -19,70 +19,58 @@ const BillLicenceModel = require('../../models/bill-licence.model.js') * @returns {Promise} the matching instance of BillLicenceModel plus the linked bill and bill run. Also all * transactions linked to the bill licence and their linked charge reference details */ -async function go (id) { +async function go(id) { return _fetchBillLicence(id) } -async function _fetchBillLicence (id) { +async function _fetchBillLicence(id) { const results = await BillLicenceModel.query() .findById(id) - .select([ - 'id', - 'licenceId', - 'licenceRef' - ]) + .select(['id', 'licenceId', 'licenceRef']) .withGraphFetched('bill') .modifyGraph('bill', (builder) => { - builder.select([ - 'id', - 'accountNumber' - ]) + builder.select(['id', 'accountNumber']) }) .withGraphFetched('bill.billRun') .modifyGraph('bill.billRun', (builder) => { - builder.select([ - 'id', - 'batchType', - 'scheme', - 'source', - 'status' - ]) + builder.select(['id', 'batchType', 'scheme', 'source', 'status']) }) .withGraphFetched('transactions') .modifyGraph('transactions', (builder) => { - builder.select([ - 'id', - 'aggregateFactor', - 'adjustmentFactor', - 'authorisedDays', - 'billableDays', - 'chargeCategoryCode', - 'chargeCategoryDescription', - 'chargeType', - 'description', - 'endDate', - 'credit', - 'waterCompanyCharge', - 'winterOnly', - 'loss', - 'netAmount', - 'scheme', - 'season', - 'section126Factor', - 'section127Agreement', - 'section130Agreement', - 'source', - 'startDate', - 'supportedSourceName', - 'volume', - ref('grossValuesCalculated:baselineCharge').castInt().as('baselineCharge'), - ref('abstractionPeriod:startDay').castInt().as('abstractionPeriodStartDay'), - ref('abstractionPeriod:startMonth').castInt().as('abstractionPeriodStartMonth'), - ref('abstractionPeriod:endDay').castInt().as('abstractionPeriodEndDay'), - ref('abstractionPeriod:endMonth').castInt().as('abstractionPeriodEndMonth'), - ref('grossValuesCalculated:supportedSourceCharge').castInt().as('supportedSourceChargeValue'), - ref('grossValuesCalculated:waterCompanyCharge').castInt().as('waterCompanyChargeValue') - ]) + builder + .select([ + 'id', + 'aggregateFactor', + 'adjustmentFactor', + 'authorisedDays', + 'billableDays', + 'chargeCategoryCode', + 'chargeCategoryDescription', + 'chargeType', + 'description', + 'endDate', + 'credit', + 'waterCompanyCharge', + 'winterOnly', + 'loss', + 'netAmount', + 'scheme', + 'season', + 'section126Factor', + 'section127Agreement', + 'section130Agreement', + 'source', + 'startDate', + 'supportedSourceName', + 'volume', + ref('grossValuesCalculated:baselineCharge').castInt().as('baselineCharge'), + ref('abstractionPeriod:startDay').castInt().as('abstractionPeriodStartDay'), + ref('abstractionPeriod:startMonth').castInt().as('abstractionPeriodStartMonth'), + ref('abstractionPeriod:endDay').castInt().as('abstractionPeriodEndDay'), + ref('abstractionPeriod:endMonth').castInt().as('abstractionPeriodEndMonth'), + ref('grossValuesCalculated:supportedSourceCharge').castInt().as('supportedSourceChargeValue'), + ref('grossValuesCalculated:waterCompanyCharge').castInt().as('waterCompanyChargeValue') + ]) .orderBy([ { column: 'chargeCategoryCode', order: 'desc' }, { column: 'billableDays', order: 'desc' }, @@ -91,16 +79,11 @@ async function _fetchBillLicence (id) { }) .withGraphFetched('transactions.chargeReference') .modifyGraph('transactions.chargeReference', (builder) => { - builder.select([ - 'id' - ]) + builder.select(['id']) }) .withGraphFetched('transactions.chargeReference.purpose') .modifyGraph('transactions.chargeReference.purpose', (builder) => { - builder.select([ - 'id', - 'description' - ]) + builder.select(['id', 'description']) }) .withGraphFetched('transactions.chargeReference.chargeElements') .modifyGraph('transactions.chargeReference.chargeElements', (builder) => { @@ -115,10 +98,7 @@ async function _fetchBillLicence (id) { }) .withGraphFetched('transactions.chargeReference.chargeElements.purpose') .modifyGraph('transactions.chargeReference.chargeElements.purpose', (builder) => { - builder.select([ - 'id', - 'description' - ]) + builder.select(['id', 'description']) }) return results diff --git a/app/services/bill-licences/remove-bill-licence.service.js b/app/services/bill-licences/remove-bill-licence.service.js index 1172913827..b9fa917982 100644 --- a/app/services/bill-licences/remove-bill-licence.service.js +++ b/app/services/bill-licences/remove-bill-licence.service.js @@ -16,7 +16,7 @@ const RemoveBillLicencePresenter = require('../../presenters/bill-licences/remov * @returns {Promise} a formatted representation of the bill licence, its bill, billing account and the bill run * it is linked to for the remove bill licence page */ -async function go (billLicenceId) { +async function go(billLicenceId) { const billLicence = await FetchBillLicenceSummaryService.go(billLicenceId) return RemoveBillLicencePresenter.go(billLicence) diff --git a/app/services/bill-licences/submit-remove-bill-licence.service.js b/app/services/bill-licences/submit-remove-bill-licence.service.js index 3836d001fc..2bf3bcb7fc 100644 --- a/app/services/bill-licences/submit-remove-bill-licence.service.js +++ b/app/services/bill-licences/submit-remove-bill-licence.service.js @@ -16,7 +16,7 @@ const LegacyDeleteBillLicenceRequest = require('../../requests/legacy/delete-bil * * @returns {Promise} Returns the redirect path the controller needs */ -async function go (billLicenceId, user) { +async function go(billLicenceId, user) { const { bill } = await _fetchBillLicence(billLicenceId) await LegacyDeleteBillLicenceRequest.send(billLicenceId, user) @@ -24,18 +24,13 @@ async function go (billLicenceId, user) { return `/billing/batch/${bill.billRunId}/processing?invoiceId=${bill.id}` } -async function _fetchBillLicence (billLicenceId) { +async function _fetchBillLicence(billLicenceId) { return BillLicenceModel.query() .findById(billLicenceId) - .select([ - 'id' - ]) + .select(['id']) .withGraphFetched('bill') .modifyGraph('bill', (builder) => { - builder.select([ - 'id', - 'billRunId' - ]) + builder.select(['id', 'billRunId']) }) } diff --git a/app/services/bill-licences/view-bill-licence.service.js b/app/services/bill-licences/view-bill-licence.service.js index 57f8de3ab7..4d573503cd 100644 --- a/app/services/bill-licences/view-bill-licence.service.js +++ b/app/services/bill-licences/view-bill-licence.service.js @@ -16,7 +16,7 @@ const ViewBillLicencePresenter = require('../../presenters/bill-licences/view-bi * @returns {Promise} a formatted representation of the bill licence and its transactions for use in the bill * licence view page */ -async function go (id) { +async function go(id) { const billLicence = await FetchBillLicenceService.go(id) return ViewBillLicencePresenter.go(billLicence) diff --git a/app/services/bill-runs/annual/fetch-billing-accounts.service.js b/app/services/bill-runs/annual/fetch-billing-accounts.service.js index a07a44d740..4f3db18593 100644 --- a/app/services/bill-runs/annual/fetch-billing-accounts.service.js +++ b/app/services/bill-runs/annual/fetch-billing-accounts.service.js @@ -30,33 +30,27 @@ const Workflow = require('../../../models/workflow.model.js') * @returns {Promise} An array of `BillingAccountModel` to be billed and their relevant * licence, charge version, charge element etc records needed to generate the bill run */ -async function go (regionId, billingPeriod) { +async function go(regionId, billingPeriod) { const allBillingAccounts = await _fetchNew(regionId, billingPeriod) return allBillingAccounts } -async function _fetchNew (regionId, billingPeriod) { +async function _fetchNew(regionId, billingPeriod) { return BillingAccountModel.query() - .select([ - 'billingAccounts.id', - 'billingAccounts.accountNumber' - ]) + .select(['billingAccounts.id', 'billingAccounts.accountNumber']) .whereExists(_whereExistsClause(regionId, billingPeriod)) - .orderBy([ - { column: 'billingAccounts.accountNumber' } - ]) + .orderBy([{ column: 'billingAccounts.accountNumber' }]) .withGraphFetched('chargeVersions') .modifyGraph('chargeVersions', (builder) => { - builder - .select([ - 'chargeVersions.id', - 'chargeVersions.scheme', - 'chargeVersions.startDate', - 'chargeVersions.endDate', - 'chargeVersions.billingAccountId', - 'chargeVersions.status' - ]) + builder.select([ + 'chargeVersions.id', + 'chargeVersions.scheme', + 'chargeVersions.startDate', + 'chargeVersions.endDate', + 'chargeVersions.billingAccountId', + 'chargeVersions.status' + ]) _whereClauseForChargeVersions(builder, regionId, billingPeriod) @@ -81,37 +75,19 @@ async function _fetchNew (regionId, billingPeriod) { }) .withGraphFetched('chargeVersions.licence.region') .modifyGraph('chargeVersions.licence.region', (builder) => { - builder.select([ - 'id', - 'chargeRegionId' - ]) + builder.select(['id', 'chargeRegionId']) }) .withGraphFetched('chargeVersions.changeReason') .modifyGraph('chargeVersions.changeReason', (builder) => { - builder.select([ - 'id', - 'triggersMinimumCharge' - ]) + builder.select(['id', 'triggersMinimumCharge']) }) .withGraphFetched('chargeVersions.chargeReferences') .modifyGraph('chargeVersions.chargeReferences', (builder) => { - builder.select([ - 'id', - 'source', - 'loss', - 'volume', - 'adjustments', - 'additionalCharges', - 'description' - ]) + builder.select(['id', 'source', 'loss', 'volume', 'adjustments', 'additionalCharges', 'description']) }) .withGraphFetched('chargeVersions.chargeReferences.chargeCategory') .modifyGraph('chargeVersions.chargeReferences.chargeCategory', (builder) => { - builder.select([ - 'id', - 'reference', - 'shortDescription' - ]) + builder.select(['id', 'reference', 'shortDescription']) }) .withGraphFetched('chargeVersions.chargeReferences.chargeElements') .modifyGraph('chargeVersions.chargeReferences.chargeElements', (builder) => { @@ -141,7 +117,7 @@ async function _fetchNew (regionId, billingPeriod) { * * @private */ -function _whereClauseForChargeVersions (query, regionId, billingPeriod) { +function _whereClauseForChargeVersions(query, regionId, billingPeriod) { return query .innerJoinRelated('licence') .where('licence.regionId', regionId) @@ -149,24 +125,16 @@ function _whereClauseForChargeVersions (query, regionId, billingPeriod) { .where('chargeVersions.startDate', '<=', billingPeriod.endDate) .where('chargeVersions.status', 'current') .where((builder) => { - builder - .whereNull('chargeVersions.endDate') - .orWhere('chargeVersions.endDate', '>=', billingPeriod.startDate) + builder.whereNull('chargeVersions.endDate').orWhere('chargeVersions.endDate', '>=', billingPeriod.startDate) }) .where((builder) => { - builder - .whereNull('licence.expiredDate') - .orWhere('licence.expiredDate', '>=', billingPeriod.startDate) + builder.whereNull('licence.expiredDate').orWhere('licence.expiredDate', '>=', billingPeriod.startDate) }) .where((builder) => { - builder - .whereNull('licence.lapsedDate') - .orWhere('licence.lapsedDate', '>=', billingPeriod.startDate) + builder.whereNull('licence.lapsedDate').orWhere('licence.lapsedDate', '>=', billingPeriod.startDate) }) .where((builder) => { - builder - .whereNull('licence.revokedDate') - .orWhere('licence.revokedDate', '>=', billingPeriod.startDate) + builder.whereNull('licence.revokedDate').orWhere('licence.revokedDate', '>=', billingPeriod.startDate) }) .whereNotExists( Workflow.query() @@ -183,7 +151,7 @@ function _whereClauseForChargeVersions (query, regionId, billingPeriod) { * * @private */ -function _whereExistsClause (regionId, billingPeriod) { +function _whereExistsClause(regionId, billingPeriod) { let query = ChargeVersionModel.query().select(1) query = _whereClauseForChargeVersions(query, regionId, billingPeriod) diff --git a/app/services/bill-runs/annual/process-bill-run.service.js b/app/services/bill-runs/annual/process-bill-run.service.js index bddddb9e67..82331922be 100644 --- a/app/services/bill-runs/annual/process-bill-run.service.js +++ b/app/services/bill-runs/annual/process-bill-run.service.js @@ -36,7 +36,7 @@ const HandleErroredBillRunService = require('../handle-errored-bill-run.service. * @param {object[]} billingPeriods - An array of billing periods each containing a `startDate` and `endDate`. For * annual this will only ever contain a single period */ -async function go (billRun, billingPeriods) { +async function go(billRun, billingPeriods) { const { id: billRunId, batchType } = billRun const billingPeriod = billingPeriods[0] @@ -54,7 +54,7 @@ async function go (billRun, billingPeriods) { } } -async function _fetchBillingAccounts (billRun, billingPeriod) { +async function _fetchBillingAccounts(billRun, billingPeriod) { try { return await FetchBillingAccountsService.go(billRun.regionId, billingPeriod) } catch (error) { @@ -64,7 +64,7 @@ async function _fetchBillingAccounts (billRun, billingPeriod) { } } -async function _finaliseBillRun (billRun, billRunPopulated) { +async function _finaliseBillRun(billRun, billRunPopulated) { // If there are no bill licences then the bill run is considered empty. We just need to set the status to indicate // this in the UI if (!billRunPopulated) { @@ -80,7 +80,7 @@ async function _finaliseBillRun (billRun, billRunPopulated) { await LegacyRefreshBillRunRequest.send(billRun.id) } -async function _processBillingPeriod (billingPeriod, billRun) { +async function _processBillingPeriod(billingPeriod, billRun) { const billingAccounts = await _fetchBillingAccounts(billRun, billingPeriod) const billRunPopulated = await ProcessBillingPeriodService.go(billRun, billingPeriod, billingAccounts) @@ -88,10 +88,8 @@ async function _processBillingPeriod (billingPeriod, billRun) { await _finaliseBillRun(billRun, billRunPopulated) } -async function _updateStatus (billRunId, status) { - await BillRunModel.query() - .findById(billRunId) - .patch({ status }) +async function _updateStatus(billRunId, status) { + await BillRunModel.query().findById(billRunId).patch({ status }) } module.exports = { diff --git a/app/services/bill-runs/annual/process-billing-period.service.js b/app/services/bill-runs/annual/process-billing-period.service.js index 80fa6e5f4e..5282d4cdb8 100644 --- a/app/services/bill-runs/annual/process-billing-period.service.js +++ b/app/services/bill-runs/annual/process-billing-period.service.js @@ -27,7 +27,7 @@ const BillingConfig = require('../../../../config/billing.config.js') * * @returns {Promise} true if the bill run is not empty (there are transactions to bill) else false */ -async function go (billRun, billingPeriod, billingAccounts) { +async function go(billRun, billingPeriod, billingAccounts) { let billRunIsPopulated = false if (billingAccounts.length === 0) { @@ -91,7 +91,7 @@ async function go (billRun, billingPeriod, billingAccounts) { * * @private */ -async function _createBillLicencesAndTransactions (billId, billingAccount, billRunExternalId, billingPeriod) { +async function _createBillLicencesAndTransactions(billId, billingAccount, billRunExternalId, billingPeriod) { const allBillLicences = [] const transactions = [] @@ -122,7 +122,7 @@ async function _createBillLicencesAndTransactions (billId, billingAccount, billR * * @private */ -async function _createTransactions (billLicenceId, billingPeriod, chargeVersion, billRunExternalId, accountNumber) { +async function _createTransactions(billLicenceId, billingPeriod, chargeVersion, billRunExternalId, accountNumber) { const chargePeriod = DetermineChargePeriodService.go(chargeVersion, billingPeriod) if (!chargePeriod.startDate) { @@ -144,7 +144,7 @@ async function _createTransactions (billLicenceId, billingPeriod, chargeVersion, * * @private */ -function _extractBillableLicences (allBillLicences) { +function _extractBillableLicences(allBillLicences) { const billableBillLicences = [] allBillLicences.forEach((billLicence) => { @@ -184,7 +184,7 @@ function _extractBillableLicences (allBillLicences) { * * @private */ -function _findOrCreateBillLicence (billLicences, licence, billId) { +function _findOrCreateBillLicence(billLicences, licence, billId) { const { id: licenceId, licenceRef } = licence let billLicence = billLicences.find((existingBillLicence) => { @@ -221,7 +221,7 @@ function _findOrCreateBillLicence (billLicences, licence, billId) { * * @private */ -function _generateTransactionData (billLicenceId, billingPeriod, chargePeriod, chargeVersion) { +function _generateTransactionData(billLicenceId, billingPeriod, chargePeriod, chargeVersion) { try { const firstChargeOnNewLicence = DetermineMinimumChargeService.go(chargeVersion, chargePeriod) @@ -255,7 +255,7 @@ function _generateTransactionData (billLicenceId, billingPeriod, chargePeriod, c * * @private */ -async function _processBillingAccount (billingAccount, billRun, billingPeriod) { +async function _processBillingAccount(billingAccount, billRun, billingPeriod) { const { id: billingAccountId, accountNumber } = billingAccount const { id: billRunId, externalId: billRunExternalId } = billRun @@ -281,7 +281,7 @@ async function _processBillingAccount (billingAccount, billRun, billingPeriod) { return _persistBillData(bill, billLicences, transactions) } -async function _persistBillData (bill, billLicences, transactions) { +async function _persistBillData(bill, billLicences, transactions) { await BillModel.query().insert(bill) await BillLicenceModel.query().insert(billLicences) await TransactionModel.query().insert(transactions) diff --git a/app/services/bill-runs/calculate-authorised-and-billable-days.service.js b/app/services/bill-runs/calculate-authorised-and-billable-days.service.js index f903552060..cd59cfac38 100644 --- a/app/services/bill-runs/calculate-authorised-and-billable-days.service.js +++ b/app/services/bill-runs/calculate-authorised-and-billable-days.service.js @@ -56,7 +56,7 @@ const ONE_DAY_IN_MILLISECONDS = 24 * 60 * 60 * 1000 * * @returns {object} An object containing an `authorisedDays` and `billableDays` property */ -function go (chargePeriod, billingPeriod, chargeReference) { +function go(chargePeriod, billingPeriod, chargeReference) { const { chargeElements } = chargeReference const authorisedAbstractionPeriods = [] @@ -102,7 +102,7 @@ function go (chargePeriod, billingPeriod, chargeReference) { * * @private */ -function _calculateDays (abstractionOverlapPeriod) { +function _calculateDays(abstractionOverlapPeriod) { const difference = abstractionOverlapPeriod.endDate.getTime() - abstractionOverlapPeriod.startDate.getTime() // ceil() always rounds up, even if the result is 1.1 (rounds to 2). We add 1 to make the calculation inclusive of @@ -135,7 +135,7 @@ function _calculateDays (abstractionOverlapPeriod) { * * @private */ -function _calculateAbstractionOverlapPeriod (referencePeriod, abstractionPeriod) { +function _calculateAbstractionOverlapPeriod(referencePeriod, abstractionPeriod) { const latestStartDateTimestamp = Math.max(abstractionPeriod.startDate, referencePeriod.startDate) const earliestEndDateTimestamp = Math.min(abstractionPeriod.endDate, referencePeriod.endDate) @@ -145,7 +145,7 @@ function _calculateAbstractionOverlapPeriod (referencePeriod, abstractionPeriod) } } -function _consolidateAndCalculate (referencePeriod, abstractionsPeriods) { +function _consolidateAndCalculate(referencePeriod, abstractionsPeriods) { const consolidatedAbstractionPeriods = ConsolidateDateRangesService.go(abstractionsPeriods) const totalDays = consolidatedAbstractionPeriods.reduce((acc, abstractionPeriod) => { diff --git a/app/services/bill-runs/cancel/cancel-bill-run.service.js b/app/services/bill-runs/cancel/cancel-bill-run.service.js index bacefaf0cf..71d6f43111 100644 --- a/app/services/bill-runs/cancel/cancel-bill-run.service.js +++ b/app/services/bill-runs/cancel/cancel-bill-run.service.js @@ -23,7 +23,7 @@ const { timestampForPostgres } = require('../../../lib/general.lib.js') * * @returns {Promise} the bill run including its `externalId` and status */ -async function go (billRunId) { +async function go(billRunId) { const billRun = await _fetchBillRun(billRunId) const canBeDeleted = _canBeDeleted(billRun.status) @@ -49,7 +49,7 @@ async function go (billRunId) { * * @private */ -function _canBeDeleted (status) { +function _canBeDeleted(status) { const invalidStatusesForDeleting = ['sending', 'sent'] return !invalidStatusesForDeleting.includes(status) @@ -65,20 +65,12 @@ function _canBeDeleted (status) { * * @private */ -async function _fetchBillRun (id) { - return BillRunModel.query() - .findById(id) - .select([ - 'id', - 'externalId', - 'status' - ]) +async function _fetchBillRun(id) { + return BillRunModel.query().findById(id).select(['id', 'externalId', 'status']) } -async function _updateStatus (billRunId) { - return BillRunModel.query() - .findById(billRunId) - .patch({ status: 'cancel', updatedAt: timestampForPostgres() }) +async function _updateStatus(billRunId) { + return BillRunModel.query().findById(billRunId).patch({ status: 'cancel', updatedAt: timestampForPostgres() }) } module.exports = { diff --git a/app/services/bill-runs/cancel/delete-bill-run.service.js b/app/services/bill-runs/cancel/delete-bill-run.service.js index 8f7ddc48ff..9da1f13d78 100644 --- a/app/services/bill-runs/cancel/delete-bill-run.service.js +++ b/app/services/bill-runs/cancel/delete-bill-run.service.js @@ -32,7 +32,7 @@ const ReviewReturnModel = require('../../../models/review-return.model.js') * * @param {module:BillRunModule} billRun - The bill run to be deleted */ -async function go (billRun) { +async function go(billRun) { try { const startTime = process.hrtime.bigint() @@ -76,7 +76,7 @@ async function go (billRun) { * * @private */ -async function _deleteBillingRecords (billRunId) { +async function _deleteBillingRecords(billRunId) { // NOTE: This needs to run first but is also typically the one that takes the longest to complete. In production // deleting the transactions for an Anglian annual bill run can take more than 30 mins!! await _deleteBillRunTransactions(billRunId) @@ -93,17 +93,17 @@ async function _deleteBillingRecords (billRunId) { await BillRunModel.query().deleteById(billRunId) } -async function _deleteBills (billRunId) { +async function _deleteBills(billRunId) { return BillModel.query().delete().where('billRunId', billRunId) } -async function _deleteBillLicences (billRunId) { +async function _deleteBillLicences(billRunId) { return BillLicenceModel.query() .delete() .whereExists(BillLicenceModel.relatedQuery('bill').where('bill.billRunId', billRunId)) } -async function _deleteBillRunChargeVersionYears (billRunId) { +async function _deleteBillRunChargeVersionYears(billRunId) { return BillRunChargeVersionYearModel.query().delete().where('billRunId', billRunId) } @@ -113,8 +113,9 @@ async function _deleteBillRunChargeVersionYears (billRunId) { * * @private */ -async function _deleteBillRunTransactions (billRunId) { - return db.raw(` +async function _deleteBillRunTransactions(billRunId) { + return db.raw( + ` DELETE FROM water.billing_transactions WHERE billing_transaction_id IN ( SELECT bt.billing_transaction_id FROM water.billing_transactions bt INNER JOIN water.billing_invoice_licences bil ON bil.billing_invoice_licence_id = bt.billing_invoice_licence_id @@ -122,15 +123,16 @@ async function _deleteBillRunTransactions (billRunId) { WHERE bi.billing_batch_id = ? ); - `, billRunId + `, + billRunId ) } -async function _deleteBillRunVolumes (billRunId) { +async function _deleteBillRunVolumes(billRunId) { return BillRunVolumeModel.query().delete().where('billRunId', billRunId) } -async function _deleteChargeElements (billRunId) { +async function _deleteChargeElements(billRunId) { return db .del() .from('reviewChargeElements AS rce') @@ -147,12 +149,12 @@ async function _deleteChargeElements (billRunId) { * * @private */ -async function _deleteChargeElementsAndReferences (billRunId) { +async function _deleteChargeElementsAndReferences(billRunId) { await _deleteChargeElements(billRunId) await _deleteChargeReferences(billRunId) } -async function _deleteChargeElementReturns (billRunId) { +async function _deleteChargeElementReturns(billRunId) { return db .withSchema('water') .del() @@ -162,7 +164,7 @@ async function _deleteChargeElementReturns (billRunId) { .where('rl.billRunId', billRunId) } -async function _deleteChargeReferences (billRunId) { +async function _deleteChargeReferences(billRunId) { return db .withSchema('water') .del() @@ -172,14 +174,14 @@ async function _deleteChargeReferences (billRunId) { .where('rl.billRunId', billRunId) } -async function _deleteChargeVersions (billRunId) { +async function _deleteChargeVersions(billRunId) { return ReviewChargeVersionModel.query() .delete() .innerJoinRelated('reviewLicence') .where('reviewLicence.billRunId', billRunId) } -async function _deleteReturns (billRunId) { +async function _deleteReturns(billRunId) { return ReviewReturnModel.query() .delete() .innerJoinRelated('reviewLicence') @@ -192,7 +194,7 @@ async function _deleteReturns (billRunId) { * * @private */ -async function _deleteReviewResults (billRunId) { +async function _deleteReviewResults(billRunId) { // To help performance we allow both these processes to run in parallel. Because their where clause depends on // `review_charge_versions` and `review_returns` we have to wait for them to complete before we proceed. This is // the same for deleting the charge versions and returns. @@ -212,7 +214,7 @@ async function _deleteReviewResults (billRunId) { * * @private */ -function _logResult (startTime, billRun, results) { +function _logResult(startTime, billRun, results) { const firstError = results.find((result) => { return result.status === 'rejected' }) diff --git a/app/services/bill-runs/cancel/submit-cancel-bill-run.service.js b/app/services/bill-runs/cancel/submit-cancel-bill-run.service.js index 627ae0e9d1..7e7428e5c5 100644 --- a/app/services/bill-runs/cancel/submit-cancel-bill-run.service.js +++ b/app/services/bill-runs/cancel/submit-cancel-bill-run.service.js @@ -24,7 +24,7 @@ const DeleteBillRunService = require('./delete-bill-run.service.js') * * @param {string} billRunId - UUID of the bill run to be cancelled */ -async function go (billRunId) { +async function go(billRunId) { const billRun = await CancelBillBunService.go(billRunId) if (billRun.status === 'cancel') { diff --git a/app/services/bill-runs/cancel/view-cancel-bill-run.service.js b/app/services/bill-runs/cancel/view-cancel-bill-run.service.js index 5f1056c80f..010ead5b75 100644 --- a/app/services/bill-runs/cancel/view-cancel-bill-run.service.js +++ b/app/services/bill-runs/cancel/view-cancel-bill-run.service.js @@ -16,7 +16,7 @@ const ViewCancelBillRunPresenter = require('../../../presenters/bill-runs/view-c * @returns {Promise} an object representing the `pageData` needed by the cancel bill run template. It contains * details of the bill run. */ -async function go (id) { +async function go(id) { const billRun = await _fetchBillRun(id) const pageData = ViewCancelBillRunPresenter.go(billRun) @@ -24,25 +24,13 @@ async function go (id) { return pageData } -async function _fetchBillRun (id) { +async function _fetchBillRun(id) { return BillRunModel.query() .findById(id) - .select([ - 'id', - 'batchType', - 'billRunNumber', - 'createdAt', - 'scheme', - 'status', - 'summer', - 'toFinancialYearEnding' - ]) + .select(['id', 'batchType', 'billRunNumber', 'createdAt', 'scheme', 'status', 'summer', 'toFinancialYearEnding']) .withGraphFetched('region') .modifyGraph('region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) } diff --git a/app/services/bill-runs/check-busy-bill-runs.service.js b/app/services/bill-runs/check-busy-bill-runs.service.js index 8da7e42b30..fb2bce5b2e 100644 --- a/app/services/bill-runs/check-busy-bill-runs.service.js +++ b/app/services/bill-runs/check-busy-bill-runs.service.js @@ -15,7 +15,7 @@ const { db } = require('../../../db/db.js') * * @returns {Promise} the state of busy bill runs; 'cancelling', 'building', 'both', or 'none' */ -async function go () { +async function go() { const { building, cancelling } = await _fetch() if (building && cancelling) { @@ -33,10 +33,12 @@ async function go () { return 'none' } -async function _fetch () { +async function _fetch() { const results = await db.select( db.raw("EXISTS(SELECT 1 FROM public.bill_runs bb WHERE bb.status = 'cancel') AS cancelling"), - db.raw("EXISTS(SELECT 1 FROM public.bill_runs bb WHERE bb.status IN ('processing', 'queued', 'sending')) AS building") + db.raw( + "EXISTS(SELECT 1 FROM public.bill_runs bb WHERE bb.status IN ('processing', 'queued', 'sending')) AS building" + ) ) return results[0] diff --git a/app/services/bill-runs/consolidate-date-ranges.service.js b/app/services/bill-runs/consolidate-date-ranges.service.js index 018d3d722e..2eaf974cb3 100644 --- a/app/services/bill-runs/consolidate-date-ranges.service.js +++ b/app/services/bill-runs/consolidate-date-ranges.service.js @@ -58,7 +58,7 @@ * * @returns {object[]} An array of the consolidated date ranges */ -function go (dateRanges) { +function go(dateRanges) { // We sort the date ranges by start date from earliest to latest to make life easier when consolidating them const sortedDates = _sortDates(dateRanges) @@ -67,7 +67,7 @@ function go (dateRanges) { return consolidatedDateRanges } -function _sortDates (dateRanges) { +function _sortDates(dateRanges) { return dateRanges.sort((a, b) => { return a.startDate - b.startDate }) @@ -82,39 +82,41 @@ function _sortDates (dateRanges) { * * @private */ -function _consolidateDates (dateRanges) { +function _consolidateDates(dateRanges) { // We use reduce to build up an array of consolidated date ranges as we iterate over our initial dateRanges array. // Each time round we compare the current range from dateRanges with the one we previously added to our array of // consolidated ranges to see if it overlaps, which determines what we add to our ongoing array before we iterate // again over the next item in dateRanges - return dateRanges.reduce((acc, currentRange) => { - // If this is the first range then there's nothing else to check yet so simply add it to our ongoing acc array - if (acc.length === 0) { - return [currentRange] - } + return dateRanges.reduce( + (acc, currentRange) => { + // If this is the first range then there's nothing else to check yet so simply add it to our ongoing acc array + if (acc.length === 0) { + return [currentRange] + } - // Get the last date range we added to acc. We use pop (which removes it from the acc array) as we may end up - // replacing it entirely if the current date range overlaps it - const previousRange = acc.pop() + // Get the last date range we added to acc. We use pop (which removes it from the acc array) as we may end up + // replacing it entirely if the current date range overlaps it + const previousRange = acc.pop() - // If the current end date is before the previous end date then the current range is completely inside the previous - // one so we simply add the previous one back to our ongoing acc array - if (currentRange.endDate <= previousRange.endDate) { - return [...acc, previousRange] - } + // If the current end date is before the previous end date then the current range is completely inside the previous + // one so we simply add the previous one back to our ongoing acc array + if (currentRange.endDate <= previousRange.endDate) { + return [...acc, previousRange] + } - // If the current range's start date is on or earlier than the previous end date then the current range overlaps - // (starting the same day as the previous one ends counts as overlapping) so we add a new date range to our ongoing - // acc array, starting when the previous range starts and ending when the current range ends - if (currentRange.startDate <= previousRange.endDate) { - return [...acc, { startDate: previousRange.startDate, endDate: currentRange.endDate }] - } + // If the current range's start date is on or earlier than the previous end date then the current range overlaps + // (starting the same day as the previous one ends counts as overlapping) so we add a new date range to our ongoing + // acc array, starting when the previous range starts and ending when the current range ends + if (currentRange.startDate <= previousRange.endDate) { + return [...acc, { startDate: previousRange.startDate, endDate: currentRange.endDate }] + } - // If ranges don't overlap then simply add the previous _and_ current ranges to our ongoing acc array - return [...acc, previousRange, currentRange] - }, - // Start with an empty array - []) + // If ranges don't overlap then simply add the previous _and_ current ranges to our ongoing acc array + return [...acc, previousRange, currentRange] + }, + // Start with an empty array + [] + ) } module.exports = { diff --git a/app/services/bill-runs/create-bill-run-event.service.js b/app/services/bill-runs/create-bill-run-event.service.js index 2bfad98f4c..632a502ff4 100644 --- a/app/services/bill-runs/create-bill-run-event.service.js +++ b/app/services/bill-runs/create-bill-run-event.service.js @@ -17,7 +17,7 @@ const GeneralLib = require('../../lib/general.lib.js') * * @returns {Promise} The newly created event record */ -async function go (billRun, issuer) { +async function go(billRun, issuer) { // The legacy `water.events` table does not have a default set for its timestamp fields. So, we have to manually set // them when creating the record const timestamp = GeneralLib.timestampForPostgres() @@ -38,7 +38,7 @@ async function go (billRun, issuer) { return event } -function _metadata (billRun) { +function _metadata(billRun) { return CreateBillRunEventPresenter.go(billRun) } diff --git a/app/services/bill-runs/create-bill-run.service.js b/app/services/bill-runs/create-bill-run.service.js index 06fd86a3a7..92b859a946 100644 --- a/app/services/bill-runs/create-bill-run.service.js +++ b/app/services/bill-runs/create-bill-run.service.js @@ -23,7 +23,7 @@ const BillRunModel = require('../../models/bill-run.model.js') * * @returns {Promise} The newly created bill run instance with the `.region` property populated */ -async function go (regionId, financialYearEndings, options) { +async function go(regionId, financialYearEndings, options) { const { fromFinancialYearEnding, toFinancialYearEnding } = financialYearEndings const optionsData = _defaultOptions(options) @@ -40,7 +40,7 @@ async function go (regionId, financialYearEndings, options) { return billRun } -function _defaultOptions (option) { +function _defaultOptions(option) { const defaults = { batchType: 'supplementary', scheme: 'sroc', diff --git a/app/services/bill-runs/determine-abstraction-periods.service.js b/app/services/bill-runs/determine-abstraction-periods.service.js index b4cb1c2e7a..ce6be47b48 100644 --- a/app/services/bill-runs/determine-abstraction-periods.service.js +++ b/app/services/bill-runs/determine-abstraction-periods.service.js @@ -49,7 +49,7 @@ * * @returns {object[]} An array of abstraction periods each containing a start and end date */ -function go (referencePeriod, startDay, startMonth, endDay, endMonth) { +function go(referencePeriod, startDay, startMonth, endDay, endMonth) { const abstractionPeriodsWithYears = _determineYears(referencePeriod, startDay, startMonth, endDay, endMonth) return abstractionPeriodsWithYears.map((abstractionPeriod) => { @@ -57,11 +57,11 @@ function go (referencePeriod, startDay, startMonth, endDay, endMonth) { }) } -function _addOneYear (date) { +function _addOneYear(date) { return new Date(date.getFullYear() + 1, date.getMonth(), date.getDate()) } -function _calculateAbstractionOverlapPeriod (referencePeriod, abstractionPeriod) { +function _calculateAbstractionOverlapPeriod(referencePeriod, abstractionPeriod) { const latestStartDateTimestamp = Math.max(abstractionPeriod.startDate, referencePeriod.startDate) const earliestEndDateTimestamp = Math.min(abstractionPeriod.endDate, referencePeriod.endDate) @@ -71,7 +71,7 @@ function _calculateAbstractionOverlapPeriod (referencePeriod, abstractionPeriod) } } -function _determineYears (referencePeriod, startDay, startMonth, endDay, endMonth) { +function _determineYears(referencePeriod, startDay, startMonth, endDay, endMonth) { const periodStartYear = referencePeriod.startDate.getFullYear() // Reminder! Because of the unique qualities of Javascript, Year and Day are literal values, month is an index! So, @@ -104,15 +104,14 @@ function _determineYears (referencePeriod, startDay, startMonth, endDay, endMont }) } -function _isPeriodValid (referencePeriod, abstractionPeriod) { +function _isPeriodValid(referencePeriod, abstractionPeriod) { // If either period starts after the other ends then there is no intersection and `false` is returned return !( - abstractionPeriod.startDate > referencePeriod.endDate || - referencePeriod.startDate > abstractionPeriod.endDate + abstractionPeriod.startDate > referencePeriod.endDate || referencePeriod.startDate > abstractionPeriod.endDate ) } -function _subtractOneYear (date) { +function _subtractOneYear(date) { return new Date(date.getFullYear() - 1, date.getMonth(), date.getDate()) } diff --git a/app/services/bill-runs/determine-billing-periods.service.js b/app/services/bill-runs/determine-billing-periods.service.js index be763ee605..28f903d8d5 100644 --- a/app/services/bill-runs/determine-billing-periods.service.js +++ b/app/services/bill-runs/determine-billing-periods.service.js @@ -33,20 +33,20 @@ const SROC_FIRST_FIN_YEAR_END = 2023 * * @returns {object[]} An array of billing periods each containing a `startDate` and `endDate`. */ -function go (billRunType, financialYearEnding) { +function go(billRunType, financialYearEnding) { const financialYear = _financialYear(financialYearEnding) return _billingPeriods(billRunType, financialYear) } -function _addBillingPeriod (billingPeriods, startYear, endYear) { +function _addBillingPeriod(billingPeriods, startYear, endYear) { billingPeriods.push({ startDate: new Date(startYear, APRIL, 1), endDate: new Date(endYear, MARCH, 31) }) } -function _billingPeriods (billRunType, financialYear) { +function _billingPeriods(billRunType, financialYear) { const billingPeriods = [] const years = { startYear: financialYear.startDate.getFullYear(), endYear: financialYear.endDate.getFullYear() } @@ -62,7 +62,7 @@ function _billingPeriods (billRunType, financialYear) { // If years.endYear is 2029. So Math.max(2023, 2024) results in 2024 being the earliest year we go back to // It means we'll never pick a PRESROC for our billing periods. But also we are future proofed should we still be // here in 2029! - const earliestSrocFinYearEnd = Math.max(SROC_FIRST_FIN_YEAR_END, (years.endYear - NO_OF_YEARS_TO_LOOK_BACK)) + const earliestSrocFinYearEnd = Math.max(SROC_FIRST_FIN_YEAR_END, years.endYear - NO_OF_YEARS_TO_LOOK_BACK) while (earliestSrocFinYearEnd <= years.endYear) { _addBillingPeriod(billingPeriods, years.startYear, years.endYear) @@ -81,7 +81,7 @@ function _billingPeriods (billRunType, financialYear) { * * @private */ -function _financialYear (financialYearEnding) { +function _financialYear(financialYearEnding) { if (financialYearEnding) { return { startDate: new Date(financialYearEnding - 1, APRIL, 1), diff --git a/app/services/bill-runs/determine-blocking-bill-run.service.js b/app/services/bill-runs/determine-blocking-bill-run.service.js index 2c640c4702..a2d75d2a43 100644 --- a/app/services/bill-runs/determine-blocking-bill-run.service.js +++ b/app/services/bill-runs/determine-blocking-bill-run.service.js @@ -34,7 +34,7 @@ const FetchMatchingBillRunService = require('./fetch-matching-bill-run.service.j * instance will be returned. For supplementary 2 bill runs may be returned depending on whether there is both an SROC * and PRESROC match. */ -async function go (regionId, batchType, financialEndYear, season = null) { +async function go(regionId, batchType, financialEndYear, season = null) { const supplementary = batchType === 'supplementary' const matchingBillRuns = await _fetchMatchingBillRuns(regionId, batchType, financialEndYear, season) @@ -43,7 +43,7 @@ async function go (regionId, batchType, financialEndYear, season = null) { return _processFetchResults(matchingBillRuns, liveBillRuns, supplementary, financialEndYear) } -async function _fetchLiveBillRuns (matchingBillRuns, regionId, supplementary, financialEndYear) { +async function _fetchLiveBillRuns(matchingBillRuns, regionId, supplementary, financialEndYear) { // We don't need to check live bill runs if we already have a match for a non-supplementary bill run if (!supplementary && matchingBillRuns.length > 0) { return [] @@ -63,13 +63,13 @@ async function _fetchLiveBillRuns (matchingBillRuns, regionId, supplementary, fi return FetchLiveBillRunsService.go(regionId, financialEndYear, supplementary) } -async function _fetchMatchingBillRuns (regionId, batchType, financialEndYear, season) { +async function _fetchMatchingBillRuns(regionId, batchType, financialEndYear, season) { const summer = season === 'summer' return FetchMatchingBillRunService.go(regionId, batchType, financialEndYear, summer) } -function _processFetchResults (matchingBillRuns, liveBillRuns, supplementary, financialEndYear) { +function _processFetchResults(matchingBillRuns, liveBillRuns, supplementary, financialEndYear) { // First, a shortcut! If we have no results to process we have no results to return! if (matchingBillRuns.length === 0 && liveBillRuns.length === 0) { return [] @@ -82,7 +82,7 @@ function _processFetchResults (matchingBillRuns, liveBillRuns, supplementary, fi return _processSupplementaryResults(matchingBillRuns, liveBillRuns, financialEndYear) } -function _processNonSupplementaryResults (matchingBillRuns, liveBillRuns) { +function _processNonSupplementaryResults(matchingBillRuns, liveBillRuns) { // If there was a match we return that as the result to display to the user as it will be more applicable if (matchingBillRuns.length > 0) { return [matchingBillRuns[0]] @@ -92,7 +92,7 @@ function _processNonSupplementaryResults (matchingBillRuns, liveBillRuns) { return [liveBillRuns[0]] } -function _processSupplementaryResults (matchingBillRuns, liveBillRuns, financialEndYear) { +function _processSupplementaryResults(matchingBillRuns, liveBillRuns, financialEndYear) { // If we are here we are dealing with a supplementary. What we want to know when it comes to supplementary is // // - does it have any matches/live bill runs for the current financial year? diff --git a/app/services/bill-runs/determine-charge-period.service.js b/app/services/bill-runs/determine-charge-period.service.js index fc86b41a50..755d729354 100644 --- a/app/services/bill-runs/determine-charge-period.service.js +++ b/app/services/bill-runs/determine-charge-period.service.js @@ -59,7 +59,7 @@ * * @returns {object} The start and end date of the calculated charge period */ -function go (chargeVersion, billingPeriod) { +function go(chargeVersion, billingPeriod) { const latestStartDateTimestamp = Math.max( billingPeriod.startDate, chargeVersion.startDate, @@ -94,7 +94,7 @@ function go (chargeVersion, billingPeriod) { return chargePeriod } -function _periodIsIncompatible (chargePeriod, billingPeriod) { +function _periodIsIncompatible(chargePeriod, billingPeriod) { const startsAfterBillingPeriod = chargePeriod.startDate > billingPeriod.endDate const endsBeforeBillingPeriod = chargePeriod.endDate < billingPeriod.startDate const startsAfterItEnds = chargePeriod.startDate > chargePeriod.endDate diff --git a/app/services/bill-runs/determine-minimum-charge.service.js b/app/services/bill-runs/determine-minimum-charge.service.js index d96f3d56b4..b8b5b9d173 100644 --- a/app/services/bill-runs/determine-minimum-charge.service.js +++ b/app/services/bill-runs/determine-minimum-charge.service.js @@ -18,7 +18,7 @@ * * @returns {boolean} true if minimum charge applies else false */ -function go (chargeVersion, chargePeriod) { +function go(chargeVersion, chargePeriod) { const chargePeriodStartTimestamp = chargePeriod.startDate.getTime() const chargeVersionStartTimestamp = chargeVersion.startDate.getTime() diff --git a/app/services/bill-runs/fetch-bill-run.service.js b/app/services/bill-runs/fetch-bill-run.service.js index 4e67cb76fd..6e33c59c90 100644 --- a/app/services/bill-runs/fetch-bill-run.service.js +++ b/app/services/bill-runs/fetch-bill-run.service.js @@ -18,7 +18,7 @@ const { db } = require('../../../db/db.js') * @returns {Promise} the matching instance of BillRunModel plus a summary (Billing account number and contact, * licence, numbers, financial year and total net amount) for each bill linked to the bill run */ -async function go (id) { +async function go(id) { const billRun = await _fetchBillRun(id) const billSummaries = await _fetchBillSummaries(id) @@ -28,7 +28,7 @@ async function go (id) { } } -async function _fetchBillRun (id) { +async function _fetchBillRun(id) { const result = BillRunModel.query() .findById(id) .select([ @@ -51,10 +51,7 @@ async function _fetchBillRun (id) { ]) .withGraphFetched('region') .modifyGraph('region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) return result @@ -91,7 +88,7 @@ async function _fetchBillRun (id) { * * @private */ -async function _fetchBillSummaries (id) { +async function _fetchBillSummaries(id) { const results = await db .select( 'bi.id', @@ -111,18 +108,12 @@ async function _fetchBillSummaries (id) { .from('bills AS bi') .innerJoin('billing_accounts AS ia', 'ia.id', 'bi.billing_account_id') .innerJoin('companies AS c', 'c.id', 'ia.company_id') - .innerJoin( - 'billing_account_addresses AS iaa', - function () { - this.on('iaa.billing_account_id', '=', 'ia.id').andOnNull('iaa.end_date') - } - ) + .innerJoin('billing_account_addresses AS iaa', function () { + this.on('iaa.billing_account_id', '=', 'ia.id').andOnNull('iaa.end_date') + }) .leftJoin('companies AS ac', 'ac.id', 'iaa.company_id') .where('bi.bill_run_id', '=', id) - .orderBy([ - { column: 'bi.account_number' }, - { column: 'bi.financial_year_ending', order: 'desc' } - ]) + .orderBy([{ column: 'bi.account_number' }, { column: 'bi.financial_year_ending', order: 'desc' }]) return results } diff --git a/app/services/bill-runs/fetch-bill-runs.service.js b/app/services/bill-runs/fetch-bill-runs.service.js index 108d0e646a..6565c25796 100644 --- a/app/services/bill-runs/fetch-bill-runs.service.js +++ b/app/services/bill-runs/fetch-bill-runs.service.js @@ -25,11 +25,11 @@ const DatabaseConfig = require('../../../config/database.config.js') * * @returns {Promise} an array of bill runs that match the selected 'page in the data */ -async function go (page = 1) { +async function go(page = 1) { return _fetch(page) } -async function _fetch (page) { +async function _fetch(page) { return BillRunModel.query() .select([ 'billRuns.id', @@ -46,9 +46,7 @@ async function _fetch (page) { 'region.displayName AS region' ]) .innerJoinRelated('region') - .orderBy([ - { column: 'createdAt', order: 'desc' } - ]) + .orderBy([{ column: 'createdAt', order: 'desc' }]) .page(page - 1, DatabaseConfig.defaultPageSize) } diff --git a/app/services/bill-runs/fetch-live-bill-runs.service.js b/app/services/bill-runs/fetch-live-bill-runs.service.js index 5ac9479b73..171030412f 100644 --- a/app/services/bill-runs/fetch-live-bill-runs.service.js +++ b/app/services/bill-runs/fetch-live-bill-runs.service.js @@ -42,24 +42,15 @@ const LAST_PRESROC_YEAR = 2022 * * @returns {Promise} An array of `BillRunModel` which are live for the region and financial year specified */ -async function go (regionId, financialYearEnding, supplementary) { +async function go(regionId, financialYearEnding, supplementary) { const liveBillRuns = await _fetchLiveBillRuns(regionId) return _matchLiveBillRuns(liveBillRuns, financialYearEnding, supplementary) } -async function _fetchLiveBillRuns (regionId) { +async function _fetchLiveBillRuns(regionId) { return BillRunModel.query() - .select([ - 'id', - 'batchType', - 'billRunNumber', - 'createdAt', - 'scheme', - 'status', - 'summer', - 'toFinancialYearEnding' - ]) + .select(['id', 'batchType', 'billRunNumber', 'createdAt', 'scheme', 'status', 'summer', 'toFinancialYearEnding']) .where('regionId', regionId) .whereIn('status', ['queued', 'processing', 'ready', 'review']) .orderBy([ @@ -68,14 +59,11 @@ async function _fetchLiveBillRuns (regionId) { ]) .withGraphFetched('region') .modifyGraph('region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) } -function _matchLiveBillRuns (liveBillRuns, financialYearEnding, supplementary) { +function _matchLiveBillRuns(liveBillRuns, financialYearEnding, supplementary) { const matches = [] for (const liveBillRun of liveBillRuns) { diff --git a/app/services/bill-runs/fetch-matching-bill-run.service.js b/app/services/bill-runs/fetch-matching-bill-run.service.js index 230a915194..9dbb506f7c 100644 --- a/app/services/bill-runs/fetch-matching-bill-run.service.js +++ b/app/services/bill-runs/fetch-matching-bill-run.service.js @@ -39,18 +39,9 @@ const LAST_PRESROC_YEAR = 2022 * instance will be returned. For supplementary 2 bill runs may be returned depending on whether there is both an SROC * and PRESROC in progress. */ -async function go (regionId, batchType, financialYearEnding, summer = false) { +async function go(regionId, batchType, financialYearEnding, summer = false) { const baseQuery = BillRunModel.query() - .select([ - 'id', - 'batchType', - 'billRunNumber', - 'createdAt', - 'scheme', - 'status', - 'summer', - 'toFinancialYearEnding' - ]) + .select(['id', 'batchType', 'billRunNumber', 'createdAt', 'scheme', 'status', 'summer', 'toFinancialYearEnding']) .where('regionId', regionId) .where('batchType', batchType) @@ -59,19 +50,15 @@ async function go (regionId, batchType, financialYearEnding, summer = false) { return _fetch(baseQuery) } -function _applyAnnualWhereClauses (query, year) { - return query - .where('toFinancialYearEnding', year) - .whereNotIn('status', ['cancel', 'empty', 'error']) - .limit(1) +function _applyAnnualWhereClauses(query, year) { + return query.where('toFinancialYearEnding', year).whereNotIn('status', ['cancel', 'empty', 'error']).limit(1) } -function _applySupplementaryWhereClauses (query) { - return query - .whereNotIn('status', ['cancel', 'empty', 'error', 'sending', 'sent']) +function _applySupplementaryWhereClauses(query) { + return query.whereNotIn('status', ['cancel', 'empty', 'error', 'sending', 'sent']) } -function _applyTwoPartTariffWhereClauses (query, financialYearEnding, summer) { +function _applyTwoPartTariffWhereClauses(query, financialYearEnding, summer) { if (financialYearEnding <= LAST_PRESROC_YEAR) { query.where('summer', summer) } @@ -82,7 +69,7 @@ function _applyTwoPartTariffWhereClauses (query, financialYearEnding, summer) { .limit(1) } -function _applyWhereClauses (baseQuery, batchType, financialYearEnding, summer) { +function _applyWhereClauses(baseQuery, batchType, financialYearEnding, summer) { if (batchType === 'annual') { _applyAnnualWhereClauses(baseQuery, financialYearEnding) } else if (batchType === 'supplementary') { @@ -92,7 +79,7 @@ function _applyWhereClauses (baseQuery, batchType, financialYearEnding, summer) } } -async function _fetch (baseQuery) { +async function _fetch(baseQuery) { return baseQuery .orderBy([ { column: 'toFinancialYearEnding', order: 'desc' }, @@ -100,10 +87,7 @@ async function _fetch (baseQuery) { ]) .withGraphFetched('region') .modifyGraph('region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) } diff --git a/app/services/bill-runs/fetch-region.service.js b/app/services/bill-runs/fetch-region.service.js index bd0bfe90ec..afbf0948ab 100644 --- a/app/services/bill-runs/fetch-region.service.js +++ b/app/services/bill-runs/fetch-region.service.js @@ -18,16 +18,14 @@ const RegionModel = require('../../models/region.model.js') * * @returns {object} Instance of `RegionModel` with the matching NALD Region ID */ -async function go (naldRegionId) { +async function go(naldRegionId) { const region = await _fetch(naldRegionId) return region } -async function _fetch (naldRegionId) { - const result = await RegionModel.query() - .where('naldRegionId', naldRegionId) - .first() +async function _fetch(naldRegionId) { + const result = await RegionModel.query().where('naldRegionId', naldRegionId).first() return result } diff --git a/app/services/bill-runs/generate-transactions.service.js b/app/services/bill-runs/generate-transactions.service.js index 2513db48db..e143f14810 100644 --- a/app/services/bill-runs/generate-transactions.service.js +++ b/app/services/bill-runs/generate-transactions.service.js @@ -33,7 +33,7 @@ const CalculateAuthorisedAndBillableDaysServiceService = require('./calculate-au * * @returns {object[]} an array of 0, 1 or 2 transaction objects */ -function go (billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker) { +function go(billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker) { const { authorisedDays, billableDays } = CalculateAuthorisedAndBillableDaysServiceService.go( chargePeriod, billingPeriod, @@ -73,16 +73,17 @@ function go (billLicenceId, chargeReference, billingPeriod, chargePeriod, newLic * * @private */ -function _compensationTransaction (standardTransaction) { +function _compensationTransaction(standardTransaction) { return { ...standardTransaction, id: generateUUID(), chargeType: 'compensation', - description: 'Compensation charge: calculated from the charge reference, activity description and regional environmental improvement charge; excludes any supported source additional charge and two-part tariff charge agreement' + description: + 'Compensation charge: calculated from the charge reference, activity description and regional environmental improvement charge; excludes any supported source additional charge and two-part tariff charge agreement' } } -function _description (chargeReference) { +function _description(chargeReference) { // If the value is false, undefined, null or simply doesn't exist we return the standard description if (!chargeReference.adjustments.s127) { return `Water abstraction charge: ${chargeReference.description}` @@ -96,7 +97,7 @@ function _description (chargeReference) { * * @private */ -function _generateElements (chargeReference) { +function _generateElements(chargeReference) { const jsonChargeElements = chargeReference.chargeElements.map((chargeElement) => { return chargeElement.toJSON() }) @@ -109,7 +110,7 @@ function _generateElements (chargeReference) { * * @private */ -function _standardTransaction ( +function _standardTransaction( billLicenceId, authorisedDays, billableDays, diff --git a/app/services/bill-runs/handle-errored-bill-run.service.js b/app/services/bill-runs/handle-errored-bill-run.service.js index 9c259f7d04..3eedd88f78 100644 --- a/app/services/bill-runs/handle-errored-bill-run.service.js +++ b/app/services/bill-runs/handle-errored-bill-run.service.js @@ -19,7 +19,7 @@ const BillRunModel = require('../../models/bill-run.model.js') * @param {string} billRunId - UUID of the bill run to be marked with `error` status * @param {number} [errorCode] - Numeric error code as defined in BillRunModel. Defaults to `null` */ -async function go (billRunId, errorCode = null) { +async function go(billRunId, errorCode = null) { try { await _updateBillRun(billRunId, errorCode) } catch (error) { @@ -27,13 +27,11 @@ async function go (billRunId, errorCode = null) { } } -async function _updateBillRun (billRunId, errorCode) { - await BillRunModel.query() - .findById(billRunId) - .patch({ - status: 'error', - errorCode - }) +async function _updateBillRun(billRunId, errorCode) { + await BillRunModel.query().findById(billRunId).patch({ + status: 'error', + errorCode + }) } module.exports = { diff --git a/app/services/bill-runs/index-bill-runs.service.js b/app/services/bill-runs/index-bill-runs.service.js index c895bf10a8..cd79db6d12 100644 --- a/app/services/bill-runs/index-bill-runs.service.js +++ b/app/services/bill-runs/index-bill-runs.service.js @@ -19,7 +19,7 @@ const PaginatorPresenter = require('../../presenters/paginator.presenter.js') * summary details for each bill run for the page selected, the template's pagination control, the title and the * status of any busy bill runs */ -async function go (page) { +async function go(page) { const selectedPageNumber = _selectedPageNumber(page) // We expect the FetchBillRunsService to take longer to complete than CheckBusyBillRunsService. But running them @@ -43,7 +43,7 @@ async function go (page) { } } -function _pageTitle (numberOfPages, selectedPageNumber) { +function _pageTitle(numberOfPages, selectedPageNumber) { if (numberOfPages === 1) { return 'Bill runs' } @@ -51,7 +51,7 @@ function _pageTitle (numberOfPages, selectedPageNumber) { return `Bill runs (page ${selectedPageNumber} of ${numberOfPages})` } -function _selectedPageNumber (page) { +function _selectedPageNumber(page) { if (!page) { return 1 } diff --git a/app/services/bill-runs/initiate-bill-run.service.js b/app/services/bill-runs/initiate-bill-run.service.js index 1d3af761a1..9d16132c93 100644 --- a/app/services/bill-runs/initiate-bill-run.service.js +++ b/app/services/bill-runs/initiate-bill-run.service.js @@ -25,7 +25,7 @@ const ExpandedError = require('../../errors/expanded.error.js') * * @returns {Promise} The newly created bill run instance */ -async function go (financialYearEndings, regionId, batchType, userEmail) { +async function go(financialYearEndings, regionId, batchType, userEmail) { await _billRunBlocked(regionId, batchType, financialYearEndings.toFinancialYearEnding) const chargingModuleResult = await ChargingModuleCreateBillRunRequest.send(regionId, 'sroc') @@ -38,7 +38,7 @@ async function go (financialYearEndings, regionId, batchType, userEmail) { return billRun } -function _billRunOptions (chargingModuleResult, batchType) { +function _billRunOptions(chargingModuleResult, batchType) { const options = { batchType, scheme: 'sroc' @@ -57,7 +57,7 @@ function _billRunOptions (chargingModuleResult, batchType) { return options } -async function _billRunBlocked (regionId, batchType, financialEndYear) { +async function _billRunBlocked(regionId, batchType, financialEndYear) { const matchResults = await DetermineBlockingBillRunService.go(regionId, batchType, financialEndYear) // No matches so we can create the bill run diff --git a/app/services/bill-runs/match/allocate-returns-to-charge-element.service.js b/app/services/bill-runs/match/allocate-returns-to-charge-element.service.js index 15fd08a5c1..05020a7e82 100644 --- a/app/services/bill-runs/match/allocate-returns-to-charge-element.service.js +++ b/app/services/bill-runs/match/allocate-returns-to-charge-element.service.js @@ -21,7 +21,7 @@ const { periodsOverlap } = require('../../../lib/general.lib.js') * @param {module:ChargeVersionModel} chargePeriod - The charge period taken from the charge version * @param {module:ChargeReferenceModel} chargeReference - The charge reference the element belongs to */ -function go (chargeElement, matchingReturns, chargePeriod, chargeReference) { +function go(chargeElement, matchingReturns, chargePeriod, chargeReference) { _processCompletedReturns(chargeElement, matchingReturns, chargePeriod, chargeReference) const hasDueReturns = matchingReturns.some((matchedReturn) => { @@ -34,7 +34,7 @@ function go (chargeElement, matchingReturns, chargePeriod, chargeReference) { } } -function _allocateReturns (chargeElement, matchedReturn, chargePeriod, chargeReference, i, matchedLines) { +function _allocateReturns(chargeElement, matchedReturn, chargePeriod, chargeReference, i, matchedLines) { matchedLines.forEach((matchedLine) => { const chargeElementRemainingAllocation = Big(chargeElement.authorisedAnnualQuantity) .minus(chargeElement.allocatedQuantity) @@ -77,7 +77,7 @@ function _allocateReturns (chargeElement, matchedReturn, chargePeriod, chargeRef }) } -function _allocateDueReturns (chargeElement, matchedReturn, chargeReference, i) { +function _allocateDueReturns(chargeElement, matchedReturn, chargeReference, i) { const chargeElementRemainingAllocation = Big(chargeElement.authorisedAnnualQuantity) .minus(chargeElement.allocatedQuantity) .toNumber() @@ -104,7 +104,7 @@ function _allocateDueReturns (chargeElement, matchedReturn, chargeReference, i) } } -function _chargeDatesOverlap (matchedLine, chargePeriod) { +function _chargeDatesOverlap(matchedLine, chargePeriod) { const { startDate: chargePeriodStartDate, endDate: chargePeriodEndDate } = chargePeriod const { startDate: lineStartDate, endDate: lineEndDate } = matchedLine @@ -112,10 +112,10 @@ function _chargeDatesOverlap (matchedLine, chargePeriod) { return true } - return (lineStartDate < chargePeriodStartDate && lineEndDate > chargePeriodStartDate) + return lineStartDate < chargePeriodStartDate && lineEndDate > chargePeriodStartDate } -function _checkLineEndDate (lineEndDate, abstractionPeriods) { +function _checkLineEndDate(lineEndDate, abstractionPeriods) { // If the endDate of the return submission line is after the end date of the charge elements abstraction period then // we do not want to allocate this. Here we are creating an array of the abstraction periods endDates (since there // can be more than 1), then by doing Math.max we can compare the end of the abstraction period to the end date of @@ -129,7 +129,7 @@ function _checkLineEndDate (lineEndDate, abstractionPeriods) { return lineEndDate <= abstractionEndDate } -function _fullyAllocated (chargeElement, chargeReference) { +function _fullyAllocated(chargeElement, chargeReference) { // We can only allocate up to the authorised volume on the charge reference, even if there is charge elements // unallocated and returns to be allocated if (chargeReference.allocatedQuantity >= chargeReference.volume) { @@ -137,10 +137,10 @@ function _fullyAllocated (chargeElement, chargeReference) { } // Finally, we can only allocate to the charge element if there is unallocated volume left! - return (chargeElement.allocatedQuantity >= chargeElement.authorisedAnnualQuantity) + return chargeElement.allocatedQuantity >= chargeElement.authorisedAnnualQuantity } -function _matchLines (chargeElement, returnSubmissionLines) { +function _matchLines(chargeElement, returnSubmissionLines) { return returnSubmissionLines.filter((returnSubmissionLine) => { if (returnSubmissionLine.unallocated === 0) { return false @@ -157,7 +157,7 @@ function _matchLines (chargeElement, returnSubmissionLines) { * * @private */ -function _checkReturnForIssues (matchedReturn) { +function _checkReturnForIssues(matchedReturn) { if (matchedReturn.nilReturn) { return true } @@ -170,15 +170,17 @@ function _checkReturnForIssues (matchedReturn) { return true } - if (matchedReturn.returnSubmissions.length === 0 || - matchedReturn.returnSubmissions[0].returnSubmissionLines.length === 0) { + if ( + matchedReturn.returnSubmissions.length === 0 || + matchedReturn.returnSubmissions[0].returnSubmissionLines.length === 0 + ) { return true } return false } -function _processCompletedReturns (chargeElement, matchingReturns, chargePeriod, chargeReference) { +function _processCompletedReturns(chargeElement, matchingReturns, chargePeriod, chargeReference) { matchingReturns.forEach((matchedReturn, i) => { // We don't allocate returns with issues if (_checkReturnForIssues(matchedReturn)) { @@ -198,7 +200,7 @@ function _processCompletedReturns (chargeElement, matchingReturns, chargePeriod, }) } -function _processDueReturns (chargeElement, matchingReturns, chargeReference) { +function _processDueReturns(chargeElement, matchingReturns, chargeReference) { matchingReturns.forEach((matchedReturn, i) => { // We are only interested in due returns if (matchedReturn.status !== 'due') { diff --git a/app/services/bill-runs/match/determine-licence-issues.service.js b/app/services/bill-runs/match/determine-licence-issues.service.js index 5d425bab12..95d5986e82 100644 --- a/app/services/bill-runs/match/determine-licence-issues.service.js +++ b/app/services/bill-runs/match/determine-licence-issues.service.js @@ -25,7 +25,7 @@ const { twoPartTariffReviewIssues } = require('../../../lib/static-lookups.lib.j * * @param {module:LicenceModel} licence - The two-part tariff licence to determine issues for */ -function go (licence) { +function go(licence) { const { returnLogs: licenceReturnLogs, chargeVersions } = licence const allReturnIssues = _determineReturnLogsIssues(licenceReturnLogs, licence) @@ -35,7 +35,7 @@ function go (licence) { licence.issues = _licenceIssues(allElementIssues, allReturnIssues) } -function _determineChargeElementsIssues (chargeVersions, licenceReturnLogs) { +function _determineChargeElementsIssues(chargeVersions, licenceReturnLogs) { const allElementIssues = [] chargeVersions.forEach((chargeVersion) => { @@ -59,7 +59,7 @@ function _determineChargeElementsIssues (chargeVersions, licenceReturnLogs) { return allElementIssues } -function _determineLicenceStatus (allElementIssues, allReturnIssues) { +function _determineLicenceStatus(allElementIssues, allReturnIssues) { const allLicenceIssues = [...allElementIssues, ...allReturnIssues] const reviewStatuses = _getReviewStatuses() @@ -72,7 +72,7 @@ function _determineLicenceStatus (allElementIssues, allReturnIssues) { return hasReviewIssue ? 'review' : 'ready' } -function _determineReturnLogsIssues (returnLogs, licence) { +function _determineReturnLogsIssues(returnLogs, licence) { const allReturnsIssues = [] returnLogs.forEach((returnLog) => { @@ -85,7 +85,7 @@ function _determineReturnLogsIssues (returnLogs, licence) { return allReturnsIssues } -function _determineReturnSplitOverChargeReference (licence, returnLog) { +function _determineReturnSplitOverChargeReference(licence, returnLog) { let chargeReferenceCounter = 0 const { chargeVersions } = licence @@ -115,7 +115,7 @@ function _determineReturnSplitOverChargeReference (licence, returnLog) { return chargeReferenceCounter > 1 } -function _elementIssues (chargeReference, chargeElement, licenceReturnLogs, returnLogs) { +function _elementIssues(chargeReference, chargeElement, licenceReturnLogs, returnLogs) { let status = 'ready' const elementIssues = [] @@ -151,7 +151,7 @@ function _elementIssues (chargeReference, chargeElement, licenceReturnLogs, retu return { elementIssues, status } } -function _getMatchingReturns (returnLogs, licenceReturnLogs) { +function _getMatchingReturns(returnLogs, licenceReturnLogs) { const returnLogIds = returnLogs.map((returnLog) => { return returnLog.returnId }) @@ -171,7 +171,7 @@ function _getMatchingReturns (returnLogs, licenceReturnLogs) { * * @private */ -function _getReviewStatuses () { +function _getReviewStatuses() { // the keys for the issues that will put the licence into review status const reviewStatusKeys = [ 'aggregate-factor', @@ -189,7 +189,7 @@ function _getReviewStatuses () { return reviewStatuses } -function _licenceIssues (allElementIssues, allReturnIssues) { +function _licenceIssues(allElementIssues, allReturnIssues) { const allIssues = [...allElementIssues, ...allReturnIssues] const uniqueIssues = new Set(allIssues) @@ -200,7 +200,7 @@ function _licenceIssues (allElementIssues, allReturnIssues) { return [...uniqueIssues].sort() } -function _returnLogIssues (returnLog, licence) { +function _returnLogIssues(returnLog, licence) { const returnLogIssues = [] // Abstraction outside period issue @@ -250,7 +250,7 @@ function _returnLogIssues (returnLog, licence) { * * @private */ -function _returnsReceivedStatus (returnLogs, licenceReturnLogs) { +function _returnsReceivedStatus(returnLogs, licenceReturnLogs) { const matchingReturnLogs = _getMatchingReturns(returnLogs, licenceReturnLogs) const someReturnsNotReceived = matchingReturnLogs.some((matchingReturnLog) => { diff --git a/app/services/bill-runs/match/fetch-charge-versions.service.js b/app/services/bill-runs/match/fetch-charge-versions.service.js index 6bf36c315e..b953dabe6b 100644 --- a/app/services/bill-runs/match/fetch-charge-versions.service.js +++ b/app/services/bill-runs/match/fetch-charge-versions.service.js @@ -31,42 +31,29 @@ const Workflow = require('../../../models/workflow.model.js') * @returns {Promise} Contains an array of two-part tariff charge versions with linked licences, charge * references, charge elements and related purpose */ -async function go (regionId, billingPeriod) { +async function go(regionId, billingPeriod) { return _fetch(regionId, billingPeriod) } -async function _fetch (regionId, billingPeriod) { +async function _fetch(regionId, billingPeriod) { const chargeVersions = await ChargeVersionModel.query() - .select([ - 'chargeVersions.id', - 'chargeVersions.startDate', - 'chargeVersions.endDate', - 'chargeVersions.status' - ]) + .select(['chargeVersions.id', 'chargeVersions.startDate', 'chargeVersions.endDate', 'chargeVersions.status']) .innerJoinRelated('licence') .where('licence.regionId', regionId) .where('chargeVersions.scheme', 'sroc') .where('chargeVersions.startDate', '<=', billingPeriod.endDate) .where('chargeVersions.status', 'current') .where((builder) => { - builder - .whereNull('chargeVersions.endDate') - .orWhere('chargeVersions.endDate', '>=', billingPeriod.startDate) + builder.whereNull('chargeVersions.endDate').orWhere('chargeVersions.endDate', '>=', billingPeriod.startDate) }) .where((builder) => { - builder - .whereNull('licence.expiredDate') - .orWhere('licence.expiredDate', '>=', billingPeriod.startDate) + builder.whereNull('licence.expiredDate').orWhere('licence.expiredDate', '>=', billingPeriod.startDate) }) .where((builder) => { - builder - .whereNull('licence.lapsedDate') - .orWhere('licence.lapsedDate', '>=', billingPeriod.startDate) + builder.whereNull('licence.lapsedDate').orWhere('licence.lapsedDate', '>=', billingPeriod.startDate) }) .where((builder) => { - builder - .whereNull('licence.revokedDate') - .orWhere('licence.revokedDate', '>=', billingPeriod.startDate) + builder.whereNull('licence.revokedDate').orWhere('licence.revokedDate', '>=', billingPeriod.startDate) }) .whereNotExists( Workflow.query() @@ -86,20 +73,12 @@ async function _fetch (regionId, billingPeriod) { .orderBy('chargeVersions.licenceRef', 'asc') .withGraphFetched('changeReason') .modifyGraph('changeReason', (builder) => { - builder.select([ - 'description' - ]) + builder.select(['description']) }) .withGraphFetched('licence') .modifyGraph('licence', (builder) => { - builder.select([ - 'id', - 'licenceRef', - 'startDate', - 'expiredDate', - 'lapsedDate', - 'revokedDate' - ]) + builder + .select(['id', 'licenceRef', 'startDate', 'expiredDate', 'lapsedDate', 'revokedDate']) .modify('licenceHolder') }) .withGraphFetched('chargeReferences') @@ -120,12 +99,7 @@ async function _fetch (regionId, billingPeriod) { }) .withGraphFetched('chargeReferences.chargeCategory') .modifyGraph('chargeReferences.chargeCategory', (builder) => { - builder - .select([ - 'reference', - 'shortDescription', - 'subsistenceCharge' - ]) + builder.select(['reference', 'shortDescription', 'subsistenceCharge']) }) .withGraphFetched('chargeReferences.chargeElements') .modifyGraph('chargeReferences.chargeElements', (builder) => { @@ -144,12 +118,7 @@ async function _fetch (regionId, billingPeriod) { }) .withGraphFetched('chargeReferences.chargeElements.purpose') .modifyGraph('chargeReferences.chargeElements.purpose', (builder) => { - builder - .select([ - 'id', - 'legacyId', - 'description' - ]) + builder.select(['id', 'legacyId', 'description']) }) return chargeVersions diff --git a/app/services/bill-runs/match/fetch-licences.service.js b/app/services/bill-runs/match/fetch-licences.service.js index d00d42e037..8fb21f6903 100644 --- a/app/services/bill-runs/match/fetch-licences.service.js +++ b/app/services/bill-runs/match/fetch-licences.service.js @@ -17,7 +17,7 @@ const FetchChargeVersionsService = require('./fetch-charge-versions.service.js') * @returns {Promise} the licences to be matched, each containing an array of charge versions applicable for * two-part tariff */ -async function go (regionId, billingPeriod) { +async function go(regionId, billingPeriod) { const chargeVersions = await FetchChargeVersionsService.go(regionId, billingPeriod) const uniqueLicenceIds = _extractUniqueLicenceIds(chargeVersions) @@ -25,7 +25,7 @@ async function go (regionId, billingPeriod) { return _groupByLicence(chargeVersions, uniqueLicenceIds) } -function _extractUniqueLicenceIds (chargeVersions) { +function _extractUniqueLicenceIds(chargeVersions) { const allLicenceIds = chargeVersions.map((chargeVersion) => { return chargeVersion.licence.id }) @@ -33,7 +33,7 @@ function _extractUniqueLicenceIds (chargeVersions) { return [...new Set(allLicenceIds)] } -function _groupByLicence (chargeVersions, uniqueLicenceIds) { +function _groupByLicence(chargeVersions, uniqueLicenceIds) { // NOTE: We could have initialized licences as an empty array and pushed each new object. But for a big region // the number of licences we might be dealing will be in the hundreds, possibly thousands. In these cases we get a // performance bump if we create the array sized to our needs first, rather than asking Node to resize the array on diff --git a/app/services/bill-runs/match/fetch-return-logs-for-licence.service.js b/app/services/bill-runs/match/fetch-return-logs-for-licence.service.js index ee274d1425..4a527f21a5 100644 --- a/app/services/bill-runs/match/fetch-return-logs-for-licence.service.js +++ b/app/services/bill-runs/match/fetch-return-logs-for-licence.service.js @@ -18,11 +18,11 @@ const ReturnLogModel = require('../../../models/return-log.model.js') * @returns {Promise} Contains an array of `returnLogs` and the associated current `returnSubmissions`, and * `returnSubmissionLines` if they exist */ -async function go (licenceRef, billingPeriod) { +async function go(licenceRef, billingPeriod) { return _fetch(licenceRef, billingPeriod) } -async function _fetch (licenceRef, billingPeriod) { +async function _fetch(licenceRef, billingPeriod) { const returnLogs = await ReturnLogModel.query() .select([ 'id', @@ -52,22 +52,12 @@ async function _fetch (licenceRef, billingPeriod) { .orderBy('returnReference', 'ASC') .withGraphFetched('returnSubmissions') .modifyGraph('returnSubmissions', (builder) => { - builder - .select([ - 'id', - 'nilReturn' - ]) - .where('returnSubmissions.current', true) + builder.select(['id', 'nilReturn']).where('returnSubmissions.current', true) }) .withGraphFetched('returnSubmissions.returnSubmissionLines') .modifyGraph('returnSubmissions.returnSubmissionLines', (builder) => { builder - .select([ - 'id', - 'startDate', - 'endDate', - 'quantity' - ]) + .select(['id', 'startDate', 'endDate', 'quantity']) .where('returnSubmissionLines.quantity', '>', 0) .where('returnSubmissionLines.startDate', '<=', billingPeriod.endDate) .where('returnSubmissionLines.endDate', '>=', billingPeriod.startDate) diff --git a/app/services/bill-runs/match/match-and-allocate.service.js b/app/services/bill-runs/match/match-and-allocate.service.js index 83d6e21cf8..8754a9ff2a 100644 --- a/app/services/bill-runs/match/match-and-allocate.service.js +++ b/app/services/bill-runs/match/match-and-allocate.service.js @@ -28,7 +28,7 @@ const PrepareReturnLogsService = require('./prepare-return-logs.service.js') * * @returns {Promise} - True if there are any licences matched to returns, false otherwise */ -async function go (billRun, billingPeriod) { +async function go(billRun, billingPeriod) { const licences = await FetchLicencesService.go(billRun.regionId, billingPeriod) if (licences.length > 0) { @@ -38,7 +38,7 @@ async function go (billRun, billingPeriod) { return licences.length > 0 } -async function _process (licences, billingPeriod, billRun) { +async function _process(licences, billingPeriod, billRun) { for (const licence of licences) { await PrepareReturnLogsService.go(licence, billingPeriod) @@ -82,7 +82,7 @@ async function _process (licences, billingPeriod, billRun) { } } -function _useAuthorisedVolume (chargeReference) { +function _useAuthorisedVolume(chargeReference) { const { chargeElements } = chargeReference let availableQuantity = chargeReference.volume diff --git a/app/services/bill-runs/match/match-returns-to-charge-element.service.js b/app/services/bill-runs/match/match-returns-to-charge-element.service.js index a8523566cc..1ead437e6a 100644 --- a/app/services/bill-runs/match/match-returns-to-charge-element.service.js +++ b/app/services/bill-runs/match/match-returns-to-charge-element.service.js @@ -18,7 +18,7 @@ const { periodsOverlap } = require('../../../lib/general.lib.js') * * @returns {Promise} Return logs that matched the charge element */ -function go (chargeElement, returnLogs) { +function go(chargeElement, returnLogs) { const matchingReturns = _matchReturns(chargeElement, returnLogs) if (matchingReturns.length > 0) { @@ -28,7 +28,7 @@ function go (chargeElement, returnLogs) { return matchingReturns } -function _addMatchingReturnsToElement (matchingReturns, chargeElement) { +function _addMatchingReturnsToElement(matchingReturns, chargeElement) { matchingReturns.forEach((matchedReturn) => { const matchedReturnResult = { allocatedQuantity: 0, @@ -45,7 +45,7 @@ function _addMatchingReturnsToElement (matchingReturns, chargeElement) { * * @private */ -function _matchReturns (chargeElement, returnLogs) { +function _matchReturns(chargeElement, returnLogs) { const elementCode = chargeElement.purpose.legacyId const elementPeriods = chargeElement.abstractionPeriods diff --git a/app/services/bill-runs/match/persist-allocated-licence-to-results.service.js b/app/services/bill-runs/match/persist-allocated-licence-to-results.service.js index 1d462b02e0..9548804a04 100644 --- a/app/services/bill-runs/match/persist-allocated-licence-to-results.service.js +++ b/app/services/bill-runs/match/persist-allocated-licence-to-results.service.js @@ -27,7 +27,7 @@ const ReviewReturnModel = require('../../../models/review-return.model.js') * @param {module:LicenceModel} licence - the two-part tariff licence included in the bill run, along with their match * and allocation results */ -async function go (billRunId, licence) { +async function go(billRunId, licence) { const { chargeVersions, returnLogs } = licence const reviewLicenceId = await _persistLicenceData(licence, billRunId) @@ -50,7 +50,7 @@ async function go (billRunId, licence) { } } -async function _persistChargeElement (chargeElement, reviewReturnIds, reviewChargeReferenceId) { +async function _persistChargeElement(chargeElement, reviewReturnIds, reviewChargeReferenceId) { const reviewChargeElementId = await _persistReviewChargeElement(chargeElement, reviewChargeReferenceId) for (const returnLog of chargeElement.returnLogs) { @@ -67,7 +67,7 @@ async function _persistChargeElement (chargeElement, reviewReturnIds, reviewChar } } -async function _persistChargeElementsReturns (reviewChargeElementId, reviewReturnId) { +async function _persistChargeElementsReturns(reviewChargeElementId, reviewReturnId) { const data = { reviewChargeElementId, reviewReturnId @@ -76,7 +76,7 @@ async function _persistChargeElementsReturns (reviewChargeElementId, reviewRetur await ReviewChargeElementReturnModel.query().insert(data) } -async function _persistChargeReference (chargeReference, reviewChargeVersionId) { +async function _persistChargeReference(chargeReference, reviewChargeVersionId) { const data = { reviewChargeVersionId, chargeReferenceId: chargeReference.id, @@ -97,7 +97,7 @@ async function _persistChargeReference (chargeReference, reviewChargeVersionId) return reviewChargeReferenceId } -async function _persistChargeVersion (chargeVersion, reviewLicenceId) { +async function _persistChargeVersion(chargeVersion, reviewLicenceId) { const data = { reviewLicenceId, chargeVersionId: chargeVersion.id, @@ -111,7 +111,7 @@ async function _persistChargeVersion (chargeVersion, reviewLicenceId) { return reviewChargeVersionId } -async function _persistLicenceData (licence, billRunId) { +async function _persistLicenceData(licence, billRunId) { const data = { billRunId, licenceId: licence.id, @@ -126,7 +126,7 @@ async function _persistLicenceData (licence, billRunId) { return reviewLicenceId } -async function _persistReturnLogs (returnLogs, reviewLicenceId) { +async function _persistReturnLogs(returnLogs, reviewLicenceId) { const reviewReturnIds = [] for (const returnLog of returnLogs) { @@ -138,7 +138,7 @@ async function _persistReturnLogs (returnLogs, reviewLicenceId) { return reviewReturnIds } -async function _persistReviewChargeElement (chargeElement, reviewChargeReferenceId) { +async function _persistReviewChargeElement(chargeElement, reviewChargeReferenceId) { const data = { reviewChargeReferenceId, chargeElementId: chargeElement.id, @@ -154,7 +154,7 @@ async function _persistReviewChargeElement (chargeElement, reviewChargeReference return reviewChargeElementId } -async function _persistReviewReturn (returnLog, reviewLicenceId) { +async function _persistReviewReturn(returnLog, reviewLicenceId) { const data = { returnId: returnLog.id, reviewLicenceId, diff --git a/app/services/bill-runs/match/prepare-charge-version.service.js b/app/services/bill-runs/match/prepare-charge-version.service.js index 77595d68d7..7bbf1dd96a 100644 --- a/app/services/bill-runs/match/prepare-charge-version.service.js +++ b/app/services/bill-runs/match/prepare-charge-version.service.js @@ -26,7 +26,7 @@ const DetermineChargePeriodService = require('../determine-charge-period.service * @param {module:ChargeVersionModel} chargeVersion - The charge version to prepare * @param {object} billingPeriod - Object with a `startDate` and `endDate` property representing the period being billed */ -function go (chargeVersion, billingPeriod) { +function go(chargeVersion, billingPeriod) { const { chargeReferences } = chargeVersion _sortChargeReferencesBySubsistenceCharge(chargeReferences) @@ -39,7 +39,7 @@ function go (chargeVersion, billingPeriod) { }) } -function _prepareChargeElementsForMatching (chargeElements, chargePeriod) { +function _prepareChargeElementsForMatching(chargeElements, chargePeriod) { chargeElements.forEach((chargeElement) => { const { abstractionPeriodStartDay, @@ -62,7 +62,7 @@ function _prepareChargeElementsForMatching (chargeElements, chargePeriod) { }) } -function _sortChargeReferencesBySubsistenceCharge (chargeReferences) { +function _sortChargeReferencesBySubsistenceCharge(chargeReferences) { return chargeReferences.sort((firstChargeReference, secondChargeReference) => { const { subsistenceCharge: subsistenceChargeFirst } = firstChargeReference.chargeCategory const { subsistenceCharge: subsistenceChargeSecond } = secondChargeReference.chargeCategory diff --git a/app/services/bill-runs/match/prepare-return-logs.service.js b/app/services/bill-runs/match/prepare-return-logs.service.js index 4b813dd0e7..3c65b78441 100644 --- a/app/services/bill-runs/match/prepare-return-logs.service.js +++ b/app/services/bill-runs/match/prepare-return-logs.service.js @@ -21,23 +21,23 @@ const { periodsOverlap } = require('../../../lib/general.lib.js') * @param {module:LicenceModel} licence - An individual licence to prepare the return logs for * @param {object} billingPeriod - Object with a `startDate` and `endDate` property representing the period being billed */ -async function go (licence, billingPeriod) { +async function go(licence, billingPeriod) { await _prepareReturnLogs(licence, billingPeriod) } -function _abstractionOutsidePeriod (returnAbstractionPeriods, returnLine) { +function _abstractionOutsidePeriod(returnAbstractionPeriods, returnLine) { const { startDate, endDate } = returnLine return !periodsOverlap(returnAbstractionPeriods, [{ startDate, endDate }]) } -async function _prepareReturnLogs (licence, billingPeriod) { +async function _prepareReturnLogs(licence, billingPeriod) { licence.returnLogs = await FetchReturnLogsForLicenceService.go(licence.licenceRef, billingPeriod) _prepReturnsForMatching(licence.returnLogs, billingPeriod) } -function _prepReturnsForMatching (returnLogs, billingPeriod) { +function _prepReturnsForMatching(returnLogs, billingPeriod) { returnLogs.forEach((returnLog) => { const { periodStartDay, periodStartMonth, periodEndDay, periodEndMonth, returnSubmissions } = returnLog const abstractionPeriods = DetermineAbstractionPeriodService.go( diff --git a/app/services/bill-runs/reissue/fetch-bills-to-be-reissued.service.js b/app/services/bill-runs/reissue/fetch-bills-to-be-reissued.service.js index f3da7d0ed0..544e605dcf 100644 --- a/app/services/bill-runs/reissue/fetch-bills-to-be-reissued.service.js +++ b/app/services/bill-runs/reissue/fetch-bills-to-be-reissued.service.js @@ -14,7 +14,7 @@ const BillModel = require('../../../models/bill.model.js') * * @returns {Promise} An array of bills to be reissued */ -async function go (regionId) { +async function go(regionId) { try { const result = await BillModel.query() .select( @@ -31,10 +31,7 @@ async function go (regionId) { .where('billRun.scheme', 'sroc') .withGraphFetched('billLicences.transactions') .modifyGraph('billLicences', (builder) => { - builder.select( - 'licenceRef', - 'licenceId' - ) + builder.select('licenceRef', 'licenceId') }) return result @@ -42,11 +39,7 @@ async function go (regionId) { // If getting bills errors then we log the error and return an empty array; the db hasn't yet been modified at // this stage so we can simply move on to the next stage of processing the bill run. - global.GlobalNotifier.omfg( - 'Could not fetch reissue bills', - { region: regionId }, - error - ) + global.GlobalNotifier.omfg('Could not fetch reissue bills', { region: regionId }, error) return [] } diff --git a/app/services/bill-runs/reissue/reissue-bill.service.js b/app/services/bill-runs/reissue/reissue-bill.service.js index 451caa6138..6eed890b97 100644 --- a/app/services/bill-runs/reissue/reissue-bill.service.js +++ b/app/services/bill-runs/reissue/reissue-bill.service.js @@ -37,7 +37,7 @@ const { generateUUID } = require('../../../lib/general.lib.js') * @returns {Promise} an object that has been generated while reissuing the bill containing the following * properties: `bills`, `billLicences` and `transactions`. */ -async function go (sourceBill, reissueBillRun) { +async function go(sourceBill, reissueBillRun) { const dataToReturn = { bills: [], billLicences: [], @@ -46,10 +46,7 @@ async function go (sourceBill, reissueBillRun) { // When a reissue request is sent to the Charging Module, it creates 2 new invoices (one to cancel out the original // invoice and one to be the new version of it) and returns their IDs - const chargingModuleReissueInvoiceIds = await _sendReissueRequest( - reissueBillRun.externalId, - sourceBill.externalId - ) + const chargingModuleReissueInvoiceIds = await _sendReissueRequest(reissueBillRun.externalId, sourceBill.externalId) // We can't get the reissue bills right away as the CM might be busy reissuing so we wait until the status // indicated that it's ready for us to proceed @@ -57,17 +54,9 @@ async function go (sourceBill, reissueBillRun) { for (const chargingModuleReissueInvoiceId of chargingModuleReissueInvoiceIds) { // Because we only have the CM invoice's id we now need to fetch its details via the "view invoice" endpoint - const chargingModuleReissueInvoice = await _sendViewBillRequest( - reissueBillRun, - chargingModuleReissueInvoiceId - ) - - const reissueBill = _retrieveOrGenerateBill( - dataToReturn, - sourceBill, - reissueBillRun, - chargingModuleReissueInvoice - ) + const chargingModuleReissueInvoice = await _sendViewBillRequest(reissueBillRun, chargingModuleReissueInvoiceId) + + const reissueBill = _retrieveOrGenerateBill(dataToReturn, sourceBill, reissueBillRun, chargingModuleReissueInvoice) // The bill we want to reissue will have one or more bill licences on it which we need to re-create for (const sourceBillLicence of sourceBill.billLicences) { @@ -107,7 +96,7 @@ async function go (sourceBill, reissueBillRun) { return dataToReturn } -function _generateBill (billingAccountId, accountNumber, billRunId, financialYearEnding) { +function _generateBill(billingAccountId, accountNumber, billRunId, financialYearEnding) { return { id: generateUUID(), accountNumber, @@ -119,7 +108,7 @@ function _generateBill (billingAccountId, accountNumber, billRunId, financialYea } } -function _generateBillLicence (billId, licenceId, licenceRef) { +function _generateBillLicence(billId, licenceId, licenceRef) { return { id: generateUUID(), billId, @@ -138,7 +127,7 @@ function _generateBillLicence (billId, licenceId, licenceRef) { * * @private */ -async function _pauseUntilNotPending (billRunExternalId) { +async function _pauseUntilNotPending(billRunExternalId) { let status do { @@ -154,10 +143,10 @@ async function _pauseUntilNotPending (billRunExternalId) { const result = await ChargingModuleViewBillRunStatusRequest.send(billRunExternalId) if (!result.succeeded) { - const error = new ExpandedError( - 'Charging Module reissue request failed', - { billRunExternalId, responseBody: result.response.body } - ) + const error = new ExpandedError('Charging Module reissue request failed', { + billRunExternalId, + responseBody: result.response.body + }) throw error } @@ -171,7 +160,7 @@ async function _pauseUntilNotPending (billRunExternalId) { * * @private */ -function _generateTransaction (chargingModuleReissueTransaction, sourceTransaction, billLicenceId) { +function _generateTransaction(chargingModuleReissueTransaction, sourceTransaction, billLicenceId) { return { ...sourceTransaction, id: generateUUID(), @@ -192,7 +181,7 @@ function _generateTransaction (chargingModuleReissueTransaction, sourceTransacti * * @private */ -function _determineSignOfNetAmount (chargeValue, credit) { +function _determineSignOfNetAmount(chargeValue, credit) { return credit ? -chargeValue : chargeValue } @@ -201,11 +190,8 @@ function _determineSignOfNetAmount (chargeValue, credit) { * * @private */ -function _mapChargingModuleInvoice (chargingModuleInvoice) { - const chargingModuleRebilledTypes = new Map() - .set('C', 'reversal') - .set('R', 'rebill') - .set('O', null) +function _mapChargingModuleInvoice(chargingModuleInvoice) { + const chargingModuleRebilledTypes = new Map().set('C', 'reversal').set('R', 'rebill').set('O', null) return { externalId: chargingModuleInvoice.id, @@ -223,7 +209,7 @@ function _mapChargingModuleInvoice (chargingModuleInvoice) { * * @private */ -async function _markSourceBillAsRebilled (sourceBill) { +async function _markSourceBillAsRebilled(sourceBill) { await sourceBill.$query().patch({ rebillingState: 'rebilled', // If the source bill's originalBillId field is `null` then we update it with the bill's id; otherwise, we use its @@ -233,13 +219,13 @@ async function _markSourceBillAsRebilled (sourceBill) { }) } -function _retrieveChargingModuleTransaction (chargingModuleLicence, id) { +function _retrieveChargingModuleTransaction(chargingModuleLicence, id) { return chargingModuleLicence.transactions.find((transaction) => { return transaction.rebilledTransactionId === id }) } -function _retrieveChargingModuleLicence (chargingModuleInvoice, licenceRef) { +function _retrieveChargingModuleLicence(chargingModuleInvoice, licenceRef) { return chargingModuleInvoice.licences.find((licence) => { return licence.licenceNumber === licenceRef }) @@ -251,12 +237,11 @@ function _retrieveChargingModuleLicence (chargingModuleInvoice, licenceRef) { * * @private */ -function _retrieveOrGenerateBill (dataToReturn, sourceBill, reissueBillRun, chargingModuleReissueInvoice) { +function _retrieveOrGenerateBill(dataToReturn, sourceBill, reissueBillRun, chargingModuleReissueInvoice) { // Because we have nested iteration of source bill and Charging Module reissue invoice, we need to ensure we have // a bill for every combination of these, hence we search by both of their ids const existingBill = dataToReturn.bills.find((bill) => { - return bill.billingAccountId === sourceBill.billingAccountId && - bill.externalId === chargingModuleReissueInvoice.id + return bill.billingAccountId === sourceBill.billingAccountId && bill.externalId === chargingModuleReissueInvoice.id }) if (existingBill) { @@ -291,7 +276,7 @@ function _retrieveOrGenerateBill (dataToReturn, sourceBill, reissueBillRun, char * * @private */ -function _retrieveOrGenerateBillLicence (dataToReturn, sourceBill, billingId, sourceBillLicence) { +function _retrieveOrGenerateBillLicence(dataToReturn, sourceBill, billingId, sourceBillLicence) { const existingBillLicence = dataToReturn.billLicences.find((billLicence) => { return billLicence.billingAccountId === sourceBill.billingAccountId }) @@ -309,18 +294,15 @@ function _retrieveOrGenerateBillLicence (dataToReturn, sourceBill, billingId, so return newBillLicence } -async function _sendReissueRequest (billRunExternalId, billExternalId) { +async function _sendReissueRequest(billRunExternalId, billExternalId) { const result = await ChargingModuleReissueBillRequest.send(billRunExternalId, billExternalId) if (!result.succeeded) { - const error = new ExpandedError( - 'Charging Module reissue request failed', - { - billRunExternalId, - billExternalId, - responseBody: result.response.body - } - ) + const error = new ExpandedError('Charging Module reissue request failed', { + billRunExternalId, + billExternalId, + responseBody: result.response.body + }) throw error } @@ -331,18 +313,15 @@ async function _sendReissueRequest (billRunExternalId, billExternalId) { }) } -async function _sendViewBillRequest (billRun, reissueBillId) { +async function _sendViewBillRequest(billRun, reissueBillId) { const result = await ChargingModuleViewBillRequest.send(billRun.externalId, reissueBillId) if (!result.succeeded) { - const error = new ExpandedError( - 'Charging Module view bill request failed', - { - billRunExternalId: billRun.externalId, - reissueInvoiceExternalId: reissueBillId, - responseBody: result.response.body - } - ) + const error = new ExpandedError('Charging Module view bill request failed', { + billRunExternalId: billRun.externalId, + reissueInvoiceExternalId: reissueBillId, + responseBody: result.response.body + }) throw error } diff --git a/app/services/bill-runs/reissue/reissue-bills.service.js b/app/services/bill-runs/reissue/reissue-bills.service.js index 07e9c3ae8e..54f8fafc5e 100644 --- a/app/services/bill-runs/reissue/reissue-bills.service.js +++ b/app/services/bill-runs/reissue/reissue-bills.service.js @@ -24,7 +24,7 @@ const TransactionModel = require('../../../models/transaction.model.js') * * @returns {Promise} `true` if any bills were reissued; `false` if not */ -async function go (reissueBillRun) { +async function go(reissueBillRun) { const sourceBills = await FetchBillsToBeReissuedService.go(reissueBillRun.regionId) if (sourceBills.length === 0) { @@ -49,13 +49,13 @@ async function go (reissueBillRun) { } // Adds the data held in each key of `newData` to the corresponding keys in `dataToPersist` -function _addNewDataToDataToPersist (dataToPersist, newData) { +function _addNewDataToDataToPersist(dataToPersist, newData) { dataToPersist.bills.push(...newData.bills) dataToPersist.billLicences.push(...newData.billLicences) dataToPersist.transactions.push(...newData.transactions) } -async function _persistData (dataToPersist) { +async function _persistData(dataToPersist) { await BillModel.query().insert(dataToPersist.bills) await BillLicenceModel.query().insert(dataToPersist.billLicences) await TransactionModel.query().insert(dataToPersist.transactions) diff --git a/app/services/bill-runs/review/authorised.service.js b/app/services/bill-runs/review/authorised.service.js index c762837a17..744cfbcbc8 100644 --- a/app/services/bill-runs/review/authorised.service.js +++ b/app/services/bill-runs/review/authorised.service.js @@ -16,7 +16,7 @@ const FetchReviewChargeReferenceService = require('./fetch-review-charge-referen * * @returns {Promise} the 'pageData' needed to view the amend authorised volume page */ -async function go (reviewChargeReferenceId) { +async function go(reviewChargeReferenceId) { const reviewChargeReference = await FetchReviewChargeReferenceService.go(reviewChargeReferenceId) const pageData = AuthorisedPresenter.go(reviewChargeReference) diff --git a/app/services/bill-runs/review/edit.service.js b/app/services/bill-runs/review/edit.service.js index 6ee8b3b0da..0790707621 100644 --- a/app/services/bill-runs/review/edit.service.js +++ b/app/services/bill-runs/review/edit.service.js @@ -17,7 +17,7 @@ const FetchReviewChargeElementService = require('./fetch-review-charge-element.s * * @returns {Promise} the 'pageData' needed to view the edit billable return volumes page */ -async function go (reviewChargeElementId, elementIndex) { +async function go(reviewChargeElementId, elementIndex) { const reviewChargeElement = await FetchReviewChargeElementService.go(reviewChargeElementId) const pageData = EditPresenter.go(reviewChargeElement, elementIndex) diff --git a/app/services/bill-runs/review/factors.service.js b/app/services/bill-runs/review/factors.service.js index 6ff2d33a77..ad56a1796c 100644 --- a/app/services/bill-runs/review/factors.service.js +++ b/app/services/bill-runs/review/factors.service.js @@ -15,7 +15,7 @@ const FetchReviewChargeReferenceService = require('./fetch-review-charge-referen * * @returns {Promise} the 'pageData' needed for the review charge reference factors page */ -async function go (reviewChargeReferenceId) { +async function go(reviewChargeReferenceId) { const reviewChargeReference = await FetchReviewChargeReferenceService.go(reviewChargeReferenceId) const pageData = FactorsPresenter.go(reviewChargeReference) diff --git a/app/services/bill-runs/review/fetch-bill-run-licences.service.js b/app/services/bill-runs/review/fetch-bill-run-licences.service.js index 049f35bcf8..6ee7a9da61 100644 --- a/app/services/bill-runs/review/fetch-bill-run-licences.service.js +++ b/app/services/bill-runs/review/fetch-bill-run-licences.service.js @@ -32,7 +32,7 @@ const DatabaseConfig = require('../../../../config/database.config.js') * @returns {Promise} An object containing the billRun data and an array of licences for the bill run that match * the selected page in the data. Also included is any data that has been used to filter the results */ -async function go (id, filterIssues, filterLicenceHolderNumber, filterLicenceStatus, filterProgress, page) { +async function go(id, filterIssues, filterLicenceHolderNumber, filterLicenceStatus, filterProgress, page) { const billRun = await _fetchBillRun(id) const licences = await _fetchBillRunLicences( id, @@ -46,8 +46,12 @@ async function go (id, filterIssues, filterLicenceHolderNumber, filterLicenceSta return { billRun, licences } } -function _applyFilters ( - reviewLicenceQuery, filterIssues, filterLicenceHolderNumber, filterLicenceStatus, filterProgress +function _applyFilters( + reviewLicenceQuery, + filterIssues, + filterLicenceHolderNumber, + filterLicenceStatus, + filterProgress ) { if (filterIssues) { _filterIssues(filterIssues, reviewLicenceQuery) @@ -70,7 +74,7 @@ function _applyFilters ( } } -async function _fetchBillRun (id) { +async function _fetchBillRun(id) { return BillRunModel.query() .findById(id) .select('id', 'createdAt', 'status', 'toFinancialYearEnding', 'batchType') @@ -80,14 +84,20 @@ async function _fetchBillRun (id) { }) .withGraphFetched('reviewLicences') .modifyGraph('reviewLicences', (builder) => { - builder.count('licenceId as totalNumberOfLicences') + builder + .count('licenceId as totalNumberOfLicences') .count({ numberOfLicencesToReview: ReviewLicenceModel.raw("CASE WHEN status = 'review' THEN 1 END") }) .groupBy('billRunId') }) } -async function _fetchBillRunLicences ( - id, filterIssues, filterLicenceHolderNumber, filterLicenceStatus, filterProgress, page = 1 +async function _fetchBillRunLicences( + id, + filterIssues, + filterLicenceHolderNumber, + filterLicenceStatus, + filterProgress, + page = 1 ) { const reviewLicenceQuery = ReviewLicenceModel.query() .select('id', 'licenceId', 'licenceRef', 'licenceHolder', 'issues', 'progress', 'status') @@ -103,37 +113,38 @@ async function _fetchBillRunLicences ( return reviewLicenceQuery } -function _filterIssues (filterIssues, reviewLicenceQuery) { +function _filterIssues(filterIssues, reviewLicenceQuery) { // When only one issue is selected in the filter, a string is returned; otherwise, an array is returned. // The "no issues" filter can only be selected exclusively, so it will always be a string. if (typeof filterIssues === 'string') { - filterIssues === 'no-issues' ? _handleNoIssues(reviewLicenceQuery) : _handleSingleIssue(filterIssues, reviewLicenceQuery) + filterIssues === 'no-issues' + ? _handleNoIssues(reviewLicenceQuery) + : _handleSingleIssue(filterIssues, reviewLicenceQuery) } else { _handleMultipleIssues(filterIssues, reviewLicenceQuery) } } -function _handleMultipleIssues (filterIssues, reviewLicenceQuery) { +function _handleMultipleIssues(filterIssues, reviewLicenceQuery) { const lookupIssues = filterIssues.map((filterIssue) => { return twoPartTariffReviewIssues[filterIssue] }) // Construct a query that checks for multiple issues. There will always be at least two issues to check for. reviewLicenceQuery.where((builder) => { - builder - .whereLike('issues', `%${lookupIssues[0]}%`) + builder.whereLike('issues', `%${lookupIssues[0]}%`) for (let i = 1; i < lookupIssues.length; i++) { builder.orWhereLike('issues', `%${lookupIssues[i]}%`) } }) } -function _handleNoIssues (reviewLicenceQuery) { +function _handleNoIssues(reviewLicenceQuery) { // To search for no issues, check if the issues column is empty reviewLicenceQuery.where('issues', '') } -function _handleSingleIssue (filterIssues, reviewLicenceQuery) { +function _handleSingleIssue(filterIssues, reviewLicenceQuery) { const lookupIssue = twoPartTariffReviewIssues[filterIssues] reviewLicenceQuery.whereLike('issues', `%${lookupIssue}%`) diff --git a/app/services/bill-runs/review/fetch-remove-review-licence.service.js b/app/services/bill-runs/review/fetch-remove-review-licence.service.js index 21fe8d167a..3b9455aa03 100644 --- a/app/services/bill-runs/review/fetch-remove-review-licence.service.js +++ b/app/services/bill-runs/review/fetch-remove-review-licence.service.js @@ -15,34 +15,21 @@ const ReviewLicenceModel = require('../../../models/review-licence.model.js') * @returns {module:ReviewLicenceModel} the matching `ReviewLicenceModel` instance and related data needed for the * two-part tariff remove review licence page */ -async function go (reviewLicenceId) { +async function go(reviewLicenceId) { return _fetch(reviewLicenceId) } -async function _fetch (reviewLicenceId) { +async function _fetch(reviewLicenceId) { return ReviewLicenceModel.query() .findById(reviewLicenceId) - .select([ - 'id', - 'licenceId', - 'licenceRef' - ]) + .select(['id', 'licenceId', 'licenceRef']) .withGraphFetched('billRun') .modifyGraph('billRun', (billRunBuilder) => { billRunBuilder - .select([ - 'id', - 'billRunNumber', - 'createdAt', - 'status', - 'toFinancialYearEnding' - ]) + .select(['id', 'billRunNumber', 'createdAt', 'status', 'toFinancialYearEnding']) .withGraphFetched('region') .modifyGraph('region', (regionBuilder) => { - regionBuilder.select([ - 'id', - 'displayName' - ]) + regionBuilder.select(['id', 'displayName']) }) }) } diff --git a/app/services/bill-runs/review/fetch-review-charge-element.service.js b/app/services/bill-runs/review/fetch-review-charge-element.service.js index 547b5e435f..e973a39134 100644 --- a/app/services/bill-runs/review/fetch-review-charge-element.service.js +++ b/app/services/bill-runs/review/fetch-review-charge-element.service.js @@ -19,65 +19,45 @@ const ReviewChargeElementModel = require('../../../models/review-charge-element. * @returns {Promise} the matching `ReviewChargeElementModel` instance and related data needed for the * two-part tariff review charge element page */ -async function go (reviewChargeElementId) { +async function go(reviewChargeElementId) { return _fetch(reviewChargeElementId) } -async function _fetch (reviewChargeElementId) { +async function _fetch(reviewChargeElementId) { return ReviewChargeElementModel.query() .findById(reviewChargeElementId) - .select([ - 'id', - 'amendedAllocated', - 'issues', - 'status' - ]) + .select(['id', 'amendedAllocated', 'issues', 'status']) .withGraphFetched('chargeElement') .modifyGraph('chargeElement', (chargeElementBuilder) => { - chargeElementBuilder - .select([ - 'id', - 'abstractionPeriodStartDay', - 'abstractionPeriodStartMonth', - 'abstractionPeriodEndDay', - 'abstractionPeriodEndMonth', - 'authorisedAnnualQuantity', - 'description' - ]) + chargeElementBuilder.select([ + 'id', + 'abstractionPeriodStartDay', + 'abstractionPeriodStartMonth', + 'abstractionPeriodEndDay', + 'abstractionPeriodEndMonth', + 'authorisedAnnualQuantity', + 'description' + ]) }) .withGraphFetched('reviewChargeReference') .modifyGraph('reviewChargeReference', (reviewChargeReferenceBuilder) => { reviewChargeReferenceBuilder - .select([ - 'id', - 'amendedAuthorisedVolume' - ]) + .select(['id', 'amendedAuthorisedVolume']) .withGraphFetched('reviewChargeElements') .modifyGraph('reviewChargeElements', (reviewChargeElementsBuilder) => { - reviewChargeElementsBuilder - .select(['id']) + reviewChargeElementsBuilder.select(['id']) }) .withGraphFetched('reviewChargeVersion') .modifyGraph('reviewChargeVersion', (reviewChargeVersionBuilder) => { reviewChargeVersionBuilder - .select([ - 'id', - 'chargePeriodStartDate', - 'chargePeriodEndDate' - ]).withGraphFetched('reviewLicence') + .select(['id', 'chargePeriodStartDate', 'chargePeriodEndDate']) + .withGraphFetched('reviewLicence') .modifyGraph('reviewLicence', (reviewLicenceBuilder) => { reviewLicenceBuilder - .select([ - 'id', - 'licenceId' - ]) + .select(['id', 'licenceId']) .withGraphFetched('billRun') .modifyGraph('billRun', (billRunBuilder) => { - billRunBuilder - .select([ - 'id', - 'toFinancialYearEnding' - ]) + billRunBuilder.select(['id', 'toFinancialYearEnding']) }) }) }) @@ -102,14 +82,13 @@ async function _fetch (reviewChargeElementId) { .orderBy('reviewReturns.startDate', 'asc') .withGraphFetched('returnLog') .modifyGraph('returnLog', (returnLogBuilder) => { - returnLogBuilder - .select([ - 'id', - ref('metadata:nald.periodStartDay').castInt().as('periodStartDay'), - ref('metadata:nald.periodStartMonth').castInt().as('periodStartMonth'), - ref('metadata:nald.periodEndDay').castInt().as('periodEndDay'), - ref('metadata:nald.periodEndMonth').castInt().as('periodEndMonth') - ]) + returnLogBuilder.select([ + 'id', + ref('metadata:nald.periodStartDay').castInt().as('periodStartDay'), + ref('metadata:nald.periodStartMonth').castInt().as('periodStartMonth'), + ref('metadata:nald.periodEndDay').castInt().as('periodEndDay'), + ref('metadata:nald.periodEndMonth').castInt().as('periodEndMonth') + ]) }) }) } diff --git a/app/services/bill-runs/review/fetch-review-charge-reference.service.js b/app/services/bill-runs/review/fetch-review-charge-reference.service.js index 1f107be829..ca5c3494f2 100644 --- a/app/services/bill-runs/review/fetch-review-charge-reference.service.js +++ b/app/services/bill-runs/review/fetch-review-charge-reference.service.js @@ -20,11 +20,11 @@ const ReviewChargeReferenceModel = require('../../../models/review-charge-refere * @returns {module:ReviewChargeReferenceModel} the matching `ReviewChargeReferenceModel` instance and related data * needed for the two-part tariff review charge reference page and sub-pages */ -async function go (reviewChargeReferenceId) { +async function go(reviewChargeReferenceId) { return _fetch(reviewChargeReferenceId) } -async function _fetch (reviewChargeReferenceId) { +async function _fetch(reviewChargeReferenceId) { return ReviewChargeReferenceModel.query() .findById(reviewChargeReferenceId) .select([ @@ -42,42 +42,24 @@ async function _fetch (reviewChargeReferenceId) { .withGraphFetched('reviewChargeVersion') .modifyGraph('reviewChargeVersion', (reviewChargeVersionBuilder) => { reviewChargeVersionBuilder - .select([ - 'id', - 'chargePeriodStartDate', - 'chargePeriodEndDate' - ]) + .select(['id', 'chargePeriodStartDate', 'chargePeriodEndDate']) .withGraphFetched('reviewLicence') .modifyGraph('reviewLicence', (reviewLicenceBuilder) => { reviewLicenceBuilder - .select([ - 'id' - ]) + .select(['id']) .withGraphFetched('billRun') .modifyGraph('billRun', (billRunBuilder) => { - billRunBuilder - .select([ - 'id', - 'toFinancialYearEnding' - ]) + billRunBuilder.select(['id', 'toFinancialYearEnding']) }) .withGraphFetched('licence') .modifyGraph('licence', (licenceBuilder) => { - licenceBuilder - .select([ - 'id', - 'waterUndertaker' - ]) + licenceBuilder.select(['id', 'waterUndertaker']) }) }) }) .withGraphFetched('reviewChargeElements') .modifyGraph('reviewChargeElements', (reviewChargeElementsBuilder) => { - reviewChargeElementsBuilder - .select([ - 'id', - 'amendedAllocated' - ]) + reviewChargeElementsBuilder.select(['id', 'amendedAllocated']) }) .withGraphFetched('chargeReference') .modifyGraph('chargeReference', (chargeReferenceBuilder) => { @@ -91,12 +73,7 @@ async function _fetch (reviewChargeReferenceId) { ]) .withGraphFetched('chargeCategory') .modifyGraph('chargeCategory', (chargeCategoryBuilder) => { - chargeCategoryBuilder - .select([ - 'id', - 'reference', - 'shortDescription' - ]) + chargeCategoryBuilder.select(['id', 'reference', 'shortDescription']) }) }) } diff --git a/app/services/bill-runs/review/fetch-review-licence.service.js b/app/services/bill-runs/review/fetch-review-licence.service.js index 31161ab0fc..76ed7b3b6b 100644 --- a/app/services/bill-runs/review/fetch-review-licence.service.js +++ b/app/services/bill-runs/review/fetch-review-licence.service.js @@ -17,35 +17,21 @@ const ReviewLicenceModel = require('../../../models/review-licence.model.js') * @returns {module:ReviewLicenceModel} the matching `ReviewLicenceModel` instance and related data needed for the * two-part tariff review licence page */ -async function go (reviewLicenceId) { +async function go(reviewLicenceId) { return _fetch(reviewLicenceId) } -async function _fetch (reviewLicenceId) { +async function _fetch(reviewLicenceId) { return ReviewLicenceModel.query() .findById(reviewLicenceId) - .select([ - 'id', - 'billRunId', - 'licenceId', - 'licenceRef', - 'licenceHolder', - 'status', - 'progress' - ]) + .select(['id', 'billRunId', 'licenceId', 'licenceRef', 'licenceHolder', 'status', 'progress']) .withGraphFetched('billRun') .modifyGraph('billRun', (billRunBuilder) => { billRunBuilder - .select([ - 'id', - 'toFinancialYearEnding' - ]) + .select(['id', 'toFinancialYearEnding']) .withGraphFetched('region') .modifyGraph('region', (regionBuilder) => { - regionBuilder.select([ - 'id', - 'displayName' - ]) + regionBuilder.select(['id', 'displayName']) }) }) .withGraphFetched('reviewReturns') @@ -68,55 +54,35 @@ async function _fetch (reviewLicenceId) { .orderBy('reviewReturns.startDate', 'asc') .withGraphFetched('returnLog') .modifyGraph('returnLog', (returnLogBuilder) => { - returnLogBuilder - .select([ - 'id', - ref('metadata:nald.periodStartDay').castInt().as('periodStartDay'), - ref('metadata:nald.periodStartMonth').castInt().as('periodStartMonth'), - ref('metadata:nald.periodEndDay').castInt().as('periodEndDay'), - ref('metadata:nald.periodEndMonth').castInt().as('periodEndMonth') - ]) + returnLogBuilder.select([ + 'id', + ref('metadata:nald.periodStartDay').castInt().as('periodStartDay'), + ref('metadata:nald.periodStartMonth').castInt().as('periodStartMonth'), + ref('metadata:nald.periodEndDay').castInt().as('periodEndDay'), + ref('metadata:nald.periodEndMonth').castInt().as('periodEndMonth') + ]) }) .withGraphFetched('reviewChargeElements') .modifyGraph('reviewChargeElements', (reviewChargeElementsBuilder) => { - reviewChargeElementsBuilder - .select([ - 'reviewChargeElements.id' - ]) + reviewChargeElementsBuilder.select(['reviewChargeElements.id']) }) }) .withGraphFetched('reviewChargeVersions') .modifyGraph('reviewChargeVersions', (reviewChargeVersions) => { reviewChargeVersions - .select([ - 'id', - 'chargePeriodEndDate', - 'chargePeriodStartDate' - ]) + .select(['id', 'chargePeriodEndDate', 'chargePeriodStartDate']) .orderBy('chargePeriodStartDate', 'asc') .withGraphFetched('reviewChargeReferences') .modifyGraph('reviewChargeReferences', (reviewChargeReferencesBuilder) => { reviewChargeReferencesBuilder - .select([ - 'id', - 'aggregate', - 'amendedAuthorisedVolume', - 'chargeAdjustment' - ]) + .select(['id', 'aggregate', 'amendedAuthorisedVolume', 'chargeAdjustment']) .withGraphFetched('chargeReference') .modifyGraph('chargeReference', (chargeReferenceBuilder) => { chargeReferenceBuilder - .select([ - 'id' - ]) + .select(['id']) .withGraphFetched('chargeCategory') .modifyGraph('chargeCategory', (chargeCategoryBuilder) => { - chargeCategoryBuilder - .select([ - 'id', - 'reference', - 'shortDescription' - ]) + chargeCategoryBuilder.select(['id', 'reference', 'shortDescription']) }) }) .withGraphFetched('reviewChargeElements') @@ -144,31 +110,24 @@ async function _fetch (reviewLicenceId) { ]) .withGraphFetched('purpose') .modifyGraph('purpose', (purposeBuilder) => { - purposeBuilder - .select([ - 'id', - 'description' - ]) + purposeBuilder.select(['id', 'description']) }) }) .withGraphFetched('reviewReturns') .modifyGraph('reviewReturns', (reviewReturnsBuilder) => { - reviewReturnsBuilder - .select([ - 'reviewReturns.id', - 'reviewReturns.quantity', - 'reviewReturns.returnReference', - 'reviewReturns.returnStatus' - ]) + reviewReturnsBuilder.select([ + 'reviewReturns.id', + 'reviewReturns.quantity', + 'reviewReturns.returnReference', + 'reviewReturns.returnStatus' + ]) }) }) }) .withGraphFetched('chargeVersion') .modifyGraph('chargeVersion', (chargeVersionBuilder) => { chargeVersionBuilder - .select([ - 'id' - ]) + .select(['id']) .withGraphFetched('billingAccount') .modifyGraph('billingAccount', (billingAccountBuilder) => { billingAccountBuilder.modify('contactDetails') diff --git a/app/services/bill-runs/review/preview.service.js b/app/services/bill-runs/review/preview.service.js index 315c7c6200..2025ce6f9a 100644 --- a/app/services/bill-runs/review/preview.service.js +++ b/app/services/bill-runs/review/preview.service.js @@ -24,7 +24,7 @@ const FetchReviewChargeReferenceService = require('./fetch-review-charge-referen * @param {string} reviewChargeReferenceId - The UUID of the charge reference review data to calculate the charge for * @param {object} yar - The Hapi `request.yar` session manager passed on by the controller */ -async function go (reviewChargeReferenceId, yar) { +async function go(reviewChargeReferenceId, yar) { const reviewChargeReference = await FetchReviewChargeReferenceService.go(reviewChargeReferenceId) const transaction = _transaction(reviewChargeReference) @@ -37,7 +37,7 @@ async function go (reviewChargeReferenceId, yar) { yar.flash('charge', `Could not calculate a charge. ${result.message}.`) } -function _actualVolume (reviewChargeElements) { +function _actualVolume(reviewChargeElements) { return reviewChargeElements.reduce((total, reviewChargeElement) => { total += reviewChargeElement.amendedAllocated @@ -45,7 +45,7 @@ function _actualVolume (reviewChargeElements) { }, 0) } -async function _calculateCharge (transaction) { +async function _calculateCharge(transaction) { if (transaction.actualVolume === 0) { return { charge: 0 } } @@ -59,7 +59,7 @@ async function _calculateCharge (transaction) { return { message: result.response.body.message } } -function _transaction (reviewChargeReference) { +function _transaction(reviewChargeReference) { const { abatementAgreement: abatementFactor, amendedAggregate: aggregateProportion, diff --git a/app/services/bill-runs/review/process-bill-run-post-remove.service.js b/app/services/bill-runs/review/process-bill-run-post-remove.service.js index 63335aaf96..273b902f46 100644 --- a/app/services/bill-runs/review/process-bill-run-post-remove.service.js +++ b/app/services/bill-runs/review/process-bill-run-post-remove.service.js @@ -16,7 +16,7 @@ const ReviewLicenceModel = require('../../../models/review-licence.model.js') * @returns {Promise} true if it was the last review licence in the bill run, so the bill run is now empty, * else false */ -async function go (billRunId) { +async function go(billRunId) { const empty = await _empty(billRunId) if (empty) { @@ -26,13 +26,13 @@ async function go (billRunId) { return empty } -async function _empty (billRunId) { +async function _empty(billRunId) { const resultSize = await ReviewLicenceModel.query().select('id').where('billRunId', billRunId).resultSize() return resultSize === 0 } -async function _updateStatus (billRunId) { +async function _updateStatus(billRunId) { return BillRunModel.query().findById(billRunId).patch({ status: 'empty' }) } diff --git a/app/services/bill-runs/review/remove-review-licence.service.js b/app/services/bill-runs/review/remove-review-licence.service.js index 51c8a1a327..c3ccd9509b 100644 --- a/app/services/bill-runs/review/remove-review-licence.service.js +++ b/app/services/bill-runs/review/remove-review-licence.service.js @@ -12,7 +12,7 @@ const { db } = require('../../../../db/db.js') * * @param {string} reviewLicenceId - The UUID of the review licence that is being removed from the bill run */ -async function go (reviewLicenceId) { +async function go(reviewLicenceId) { await _removeChargeElementReturns(reviewLicenceId) await _removeReturns(reviewLicenceId) await _removeChargeElements(reviewLicenceId) @@ -21,7 +21,7 @@ async function go (reviewLicenceId) { await _removeLicence(reviewLicenceId) } -async function _removeChargeElements (reviewLicenceId) { +async function _removeChargeElements(reviewLicenceId) { await db .withSchema('water') .del() @@ -32,7 +32,7 @@ async function _removeChargeElements (reviewLicenceId) { .where('rl.id', reviewLicenceId) } -async function _removeChargeElementReturns (reviewLicenceId) { +async function _removeChargeElementReturns(reviewLicenceId) { await db .withSchema('water') .del() @@ -44,7 +44,7 @@ async function _removeChargeElementReturns (reviewLicenceId) { .where('rl.id', reviewLicenceId) } -async function _removeChargeReferences (reviewLicenceId) { +async function _removeChargeReferences(reviewLicenceId) { await db .withSchema('water') .del() @@ -54,7 +54,7 @@ async function _removeChargeReferences (reviewLicenceId) { .where('rl.id', reviewLicenceId) } -async function _removeChargeVersions (reviewLicenceId) { +async function _removeChargeVersions(reviewLicenceId) { await db .withSchema('water') .del() @@ -63,15 +63,11 @@ async function _removeChargeVersions (reviewLicenceId) { .where('rl.id', reviewLicenceId) } -async function _removeLicence (reviewLicenceId) { - await db - .withSchema('water') - .del() - .from('reviewLicences') - .where('id', reviewLicenceId) +async function _removeLicence(reviewLicenceId) { + await db.withSchema('water').del().from('reviewLicences').where('id', reviewLicenceId) } -async function _removeReturns (reviewLicenceId) { +async function _removeReturns(reviewLicenceId) { await db .withSchema('water') .del() diff --git a/app/services/bill-runs/review/remove.service.js b/app/services/bill-runs/review/remove.service.js index aa6c5dae88..f9aa44afd3 100644 --- a/app/services/bill-runs/review/remove.service.js +++ b/app/services/bill-runs/review/remove.service.js @@ -16,7 +16,7 @@ const RemovePresenter = require('../../../presenters/bill-runs/review/remove.pre * @returns {Promise} an object representing the `pageData` needed by the remove licence template. It contains * details of the bill run & the licence reference. */ -async function go (reviewLicenceId) { +async function go(reviewLicenceId) { const reviewLicence = await FetchRemoveReviewLicenceService.go(reviewLicenceId) return RemovePresenter.go(reviewLicence) diff --git a/app/services/bill-runs/review/review-bill-run.service.js b/app/services/bill-runs/review/review-bill-run.service.js index 6c518574e0..b26d1882ae 100644 --- a/app/services/bill-runs/review/review-bill-run.service.js +++ b/app/services/bill-runs/review/review-bill-run.service.js @@ -19,7 +19,7 @@ const ReviewBillRunPresenter = require('../../../presenters/bill-runs/review/rev * @returns {Promise} An object representing the `pageData` needed by the review bill run template. It contains * details of the bill run and the licences linked to it as well as any data that has been used to filter the results. */ -async function go (id, page, yar) { +async function go(id, page, yar) { const { filterIssues, filterLicenceHolderNumber, filterLicenceStatus, filterProgress } = _getFilters(id, yar) const selectedPageNumber = page ? Number(page) : 1 @@ -51,7 +51,7 @@ async function go (id, page, yar) { return { bannerMessage, ...pageData, pageTitle, pagination } } -function _getFilters (id, yar) { +function _getFilters(id, yar) { const filters = yar.get(`review-${id}`) const filterIssues = filters?.filterIssues const filterLicenceHolderNumber = filters?.filterLicenceHolderNumber @@ -61,7 +61,7 @@ function _getFilters (id, yar) { return { filterIssues, filterLicenceHolderNumber, filterLicenceStatus, filterProgress } } -function _pageTitle (numberOfPages, selectedPageNumber) { +function _pageTitle(numberOfPages, selectedPageNumber) { if (numberOfPages < 2) { return 'Review licences' } diff --git a/app/services/bill-runs/review/review-charge-element.service.js b/app/services/bill-runs/review/review-charge-element.service.js index c5bd75a7ed..9e4e9be405 100644 --- a/app/services/bill-runs/review/review-charge-element.service.js +++ b/app/services/bill-runs/review/review-charge-element.service.js @@ -18,7 +18,7 @@ const ReviewChargeElementPresenter = require('../../../presenters/bill-runs/revi * * @returns {Promise} the 'pageData' needed for the review charge element page */ -async function go (reviewChargeElementId, elementIndex, yar) { +async function go(reviewChargeElementId, elementIndex, yar) { const reviewChargeElement = await FetchReviewChargeElementService.go(reviewChargeElementId) const [bannerMessage] = yar.flash('banner') diff --git a/app/services/bill-runs/review/review-charge-reference.service.js b/app/services/bill-runs/review/review-charge-reference.service.js index 62e0890164..cb286b9092 100644 --- a/app/services/bill-runs/review/review-charge-reference.service.js +++ b/app/services/bill-runs/review/review-charge-reference.service.js @@ -17,7 +17,7 @@ const ReviewChargeReferencePresenter = require('../../../presenters/bill-runs/re * @returns {Promise} the 'pageData' needed for the review charge reference page. It contains details of the * bill run, charge reference and the charge adjustments */ -async function go (reviewChargeReferenceId, yar) { +async function go(reviewChargeReferenceId, yar) { const reviewChargeReference = await FetchReviewChargeReferenceService.go(reviewChargeReferenceId) const [bannerMessage] = yar.flash('banner') diff --git a/app/services/bill-runs/review/review-licence.service.js b/app/services/bill-runs/review/review-licence.service.js index 71e32ce152..16d0948ac6 100644 --- a/app/services/bill-runs/review/review-licence.service.js +++ b/app/services/bill-runs/review/review-licence.service.js @@ -17,7 +17,7 @@ const ReviewLicencePresenter = require('../../../presenters/bill-runs/review/rev * @returns {Promise} the 'pageData' needed for the review licence page. It contains the licence, bill run, * matched and unmatched returns and the licence charge data */ -async function go (reviewLicenceId, yar) { +async function go(reviewLicenceId, yar) { const reviewLicence = await FetchReviewLicenceService.go(reviewLicenceId) const [bannerMessage] = yar.flash('banner') diff --git a/app/services/bill-runs/review/submit-authorised.service.js b/app/services/bill-runs/review/submit-authorised.service.js index a1ec47b74f..9adc0715e1 100644 --- a/app/services/bill-runs/review/submit-authorised.service.js +++ b/app/services/bill-runs/review/submit-authorised.service.js @@ -20,7 +20,7 @@ const ReviewChargeReferenceModel = require('../../../models/review-charge-refere * @returns {Promise} An empty object if there are no errors else the page data for the page including the * validation error details */ -async function go (reviewChargeReferenceId, yar, payload) { +async function go(reviewChargeReferenceId, yar, payload) { const validationResult = _validate(payload) if (!validationResult) { @@ -41,13 +41,13 @@ async function go (reviewChargeReferenceId, yar, payload) { } } -async function _save (reviewChargeReferenceId, payload) { +async function _save(reviewChargeReferenceId, payload) { return ReviewChargeReferenceModel.query() .findById(reviewChargeReferenceId) .patch({ amendedAuthorisedVolume: payload.amendedAuthorisedVolume }) } -function _validate (payload) { +function _validate(payload) { const validation = AuthorisedValidator.go(payload) if (!validation.error) { diff --git a/app/services/bill-runs/review/submit-edit.service.js b/app/services/bill-runs/review/submit-edit.service.js index d7c35da9a1..73a6e5dda8 100644 --- a/app/services/bill-runs/review/submit-edit.service.js +++ b/app/services/bill-runs/review/submit-edit.service.js @@ -21,7 +21,7 @@ const ReviewChargeElementModel = require('../../../models/review-charge-element. * * @returns {Promise} The updated value for the billable returns */ -async function go (reviewChargeElementId, elementIndex, yar, payload) { +async function go(reviewChargeElementId, elementIndex, yar, payload) { const validationResult = _validate(payload) if (!validationResult) { @@ -43,15 +43,13 @@ async function go (reviewChargeElementId, elementIndex, yar, payload) { } } -function _save (reviewChargeElementId, payload) { +function _save(reviewChargeElementId, payload) { const volume = payload.quantityOptions === 'customQuantity' ? payload.customQuantity : payload.quantityOptions - return ReviewChargeElementModel.query() - .findById(reviewChargeElementId) - .patch({ amendedAllocated: volume }) + return ReviewChargeElementModel.query().findById(reviewChargeElementId).patch({ amendedAllocated: volume }) } -function _validate (payload) { +function _validate(payload) { const validation = EditValidator.go(payload) if (!validation.error) { diff --git a/app/services/bill-runs/review/submit-factors.service.js b/app/services/bill-runs/review/submit-factors.service.js index 9415757ad9..77df5a7eea 100644 --- a/app/services/bill-runs/review/submit-factors.service.js +++ b/app/services/bill-runs/review/submit-factors.service.js @@ -29,7 +29,7 @@ const ReviewChargeReferenceModel = require('../../../models/review-charge-refere * @returns {Promise} An empty object if there are no errors else the page data for the page including the * validation error details */ -async function go (reviewChargeReferenceId, yar, payload) { +async function go(reviewChargeReferenceId, yar, payload) { const validationResult = _validate(payload) if (!validationResult) { @@ -51,13 +51,11 @@ async function go (reviewChargeReferenceId, yar, payload) { } } -async function _save (reviewChargeReferenceId, payload) { - return ReviewChargeReferenceModel.query() - .findById(reviewChargeReferenceId) - .patch(payload) +async function _save(reviewChargeReferenceId, payload) { + return ReviewChargeReferenceModel.query().findById(reviewChargeReferenceId).patch(payload) } -function _validate (payload) { +function _validate(payload) { const validation = FactorsValidator.go(payload) if (!validation.error) { diff --git a/app/services/bill-runs/review/submit-remove.service.js b/app/services/bill-runs/review/submit-remove.service.js index c36f53c1a4..9b0d4e9cf6 100644 --- a/app/services/bill-runs/review/submit-remove.service.js +++ b/app/services/bill-runs/review/submit-remove.service.js @@ -25,7 +25,7 @@ const RemoveReviewLicenceService = require('./remove-review-licence.service.js') * @returns {Promise} an object containing the bill run ID plus a boolean flag that indicates whether this was * the last licence in the bill run (bill run is now empty) */ -async function go (reviewLicenceId, yar) { +async function go(reviewLicenceId, yar) { const reviewLicence = await FetchRemoveReviewLicenceModel.go(reviewLicenceId) await RemoveReviewLicenceService.go(reviewLicenceId) @@ -47,13 +47,13 @@ async function go (reviewLicenceId, yar) { } } -async function _empty (reviewLicence) { +async function _empty(reviewLicence) { const { billRun } = reviewLicence return ProcessBillRunPostRemove.go(billRun.id) } -async function _flagForSupplementaryBilling (reviewLicence) { +async function _flagForSupplementaryBilling(reviewLicence) { const { billRun, licenceId } = reviewLicence return CreateLicenceSupplementaryYearService.go(licenceId, [billRun.toFinancialYearEnding], true) diff --git a/app/services/bill-runs/review/submit-review-bill-run.service.js b/app/services/bill-runs/review/submit-review-bill-run.service.js index f5ac10a68f..4bb3025f95 100644 --- a/app/services/bill-runs/review/submit-review-bill-run.service.js +++ b/app/services/bill-runs/review/submit-review-bill-run.service.js @@ -12,7 +12,7 @@ * @param {object} payload - The `request.payload` containing the filter data. * @param {object} yar - The Hapi `request.yar` session manager passed on by the controller */ -async function go (billRunId, payload, yar) { +async function go(billRunId, payload, yar) { const clearFilters = payload?.clearFilters const filterIssues = payload?.filterIssues const filterLicenceHolderNumber = payload?.filterLicenceHolderNumber diff --git a/app/services/bill-runs/review/submit-review-licence.service.js b/app/services/bill-runs/review/submit-review-licence.service.js index cfd9b9305d..4ce2ede6d3 100644 --- a/app/services/bill-runs/review/submit-review-licence.service.js +++ b/app/services/bill-runs/review/submit-review-licence.service.js @@ -22,7 +22,7 @@ const ReviewLicenceModel = require('../../../models/review-licence.model.js') * @param {object} yar - The Hapi `request.yar` session manager passed on by the controller * @param {object} payload - The Hapi `request.payload` object passed on by the controller */ -async function go (reviewLicenceId, yar, payload) { +async function go(reviewLicenceId, yar, payload) { const parsedPayload = _parsePayload(payload) // NOTE: The YarPlugin decorates the Hapi request object with a yar property. Yar is a session manager @@ -31,7 +31,7 @@ async function go (reviewLicenceId, yar, payload) { await _update(reviewLicenceId, parsedPayload) } -function _bannerMessage (yar, parsedPayload) { +function _bannerMessage(yar, parsedPayload) { const { progress, status } = parsedPayload if (status) { @@ -49,7 +49,7 @@ function _bannerMessage (yar, parsedPayload) { yar.flash('banner', 'The progress mark for this licence has been removed.') } -function _parsePayload (payload) { +function _parsePayload(payload) { const markProgress = payload['mark-progress'] ?? null const licenceStatus = payload['licence-status'] ?? null @@ -59,7 +59,7 @@ function _parsePayload (payload) { } } -async function _update (reviewLicenceId, parsedPayload) { +async function _update(reviewLicenceId, parsedPayload) { const { progress, status } = parsedPayload const patch = {} @@ -69,9 +69,7 @@ async function _update (reviewLicenceId, parsedPayload) { patch.progress = progress } - await ReviewLicenceModel.query() - .findById(reviewLicenceId) - .patch(patch) + await ReviewLicenceModel.query().findById(reviewLicenceId).patch(patch) } module.exports = { diff --git a/app/services/bill-runs/send-transactions.service.js b/app/services/bill-runs/send-transactions.service.js index 0b3f781437..c7fb758eaf 100644 --- a/app/services/bill-runs/send-transactions.service.js +++ b/app/services/bill-runs/send-transactions.service.js @@ -24,7 +24,7 @@ const ChargingModuleCreateTransactionPresenter = require('../../presenters/charg * @returns {Promise} Array of transactions which have been sent to the Charging Module and updated with its * response */ -async function go (transactions, billRunExternalId, accountNumber, licence) { +async function go(transactions, billRunExternalId, accountNumber, licence) { // NOTE: we purposefully loop through all the transactions to send without awaiting them. This is for performance // purposes. If for example we have 3 transactions to send we'll send the requests 1 straight after the other. We // then wait for all 3 to complete. The overall process time will only be that of the one that takes the longest. If @@ -39,7 +39,7 @@ async function go (transactions, billRunExternalId, accountNumber, licence) { return Promise.all(sendRequests) } -async function _sendTransactionToChargingModule (transaction, billRunExternalId, accountNumber, licence) { +async function _sendTransactionToChargingModule(transaction, billRunExternalId, accountNumber, licence) { try { const chargingModuleRequest = ChargingModuleCreateTransactionPresenter.go(transaction, accountNumber, licence) diff --git a/app/services/bill-runs/send/send-bill-run.service.js b/app/services/bill-runs/send/send-bill-run.service.js index 6fe89ae125..fa01c4ce8d 100644 --- a/app/services/bill-runs/send/send-bill-run.service.js +++ b/app/services/bill-runs/send/send-bill-run.service.js @@ -23,7 +23,7 @@ const { timestampForPostgres } = require('../../../lib/general.lib.js') * * @returns {Promise} the bill run including its `externalId` and status */ -async function go (billRunId) { +async function go(billRunId) { const billRun = await _fetchBillRun(billRunId) if (billRun.status === 'ready') { @@ -48,24 +48,14 @@ async function go (billRunId) { * * @private */ -async function _fetchBillRun (id) { +async function _fetchBillRun(id) { return BillRunModel.query() .findById(id) - .select([ - 'id', - 'batchType', - 'createdAt', - 'externalId', - 'regionId', - 'scheme', - 'status' - ]) + .select(['id', 'batchType', 'createdAt', 'externalId', 'regionId', 'scheme', 'status']) } -async function _updateStatus (billRunId) { - return BillRunModel.query() - .findById(billRunId) - .patch({ status: 'sending', updatedAt: timestampForPostgres() }) +async function _updateStatus(billRunId) { + return BillRunModel.query().findById(billRunId).patch({ status: 'sending', updatedAt: timestampForPostgres() }) } module.exports = { diff --git a/app/services/bill-runs/send/submit-send-bill-run.service.js b/app/services/bill-runs/send/submit-send-bill-run.service.js index d450d2e504..e47dcf210d 100644 --- a/app/services/bill-runs/send/submit-send-bill-run.service.js +++ b/app/services/bill-runs/send/submit-send-bill-run.service.js @@ -24,7 +24,7 @@ const UpdateInvoiceNumbersService = require('./update-invoice-numbers.service.js * * @param {string} billRunId - UUID of the bill run to be sent */ -async function go (billRunId) { +async function go(billRunId) { const billRun = await SendBillBunService.go(billRunId) if (billRun.status === 'sending') { diff --git a/app/services/bill-runs/send/update-invoice-numbers.service.js b/app/services/bill-runs/send/update-invoice-numbers.service.js index a2e7664af4..e045848b32 100644 --- a/app/services/bill-runs/send/update-invoice-numbers.service.js +++ b/app/services/bill-runs/send/update-invoice-numbers.service.js @@ -26,7 +26,7 @@ const UnflagBilledLicencesService = require('../supplementary/unflag-billed-lice * * @param {module:BillRunModule} billRun - The bill run to be sent */ -async function go (billRun) { +async function go(billRun) { try { const startTime = process.hrtime.bigint() @@ -50,7 +50,7 @@ async function go (billRun) { } } -async function _fetchChargingModuleBillRun (externalId) { +async function _fetchChargingModuleBillRun(externalId) { const result = await ChargingModuleViewBillRunRequest.send(externalId) if (!result.succeeded) { @@ -60,7 +60,7 @@ async function _fetchChargingModuleBillRun (externalId) { return result.response.body.billRun } -async function _updateBills (externalBillRun) { +async function _updateBills(externalBillRun) { const { invoices } = externalBillRun for (const invoice of invoices) { @@ -70,11 +70,10 @@ async function _updateBills (externalBillRun) { } } -async function _updateBillRun (billRunId, externalBillRun) { +async function _updateBillRun(billRunId, externalBillRun) { const { transactionFileReference } = externalBillRun - return BillRunModel - .query() + return BillRunModel.query() .findById(billRunId) .patch({ status: 'sent', transactionFileReference, updatedAt: timestampForPostgres() }) } diff --git a/app/services/bill-runs/send/view-send-bill-run.service.js b/app/services/bill-runs/send/view-send-bill-run.service.js index 1769e442e1..c241184865 100644 --- a/app/services/bill-runs/send/view-send-bill-run.service.js +++ b/app/services/bill-runs/send/view-send-bill-run.service.js @@ -16,7 +16,7 @@ const ViewSendBillRunPresenter = require('../../../presenters/bill-runs/view-sen * @returns {Promise} an object representing the `pageData` needed by the send bill run template. It contains * details of the bill run. */ -async function go (id) { +async function go(id) { const billRun = await _fetchBillRun(id) const pageData = ViewSendBillRunPresenter.go(billRun) @@ -24,25 +24,13 @@ async function go (id) { return pageData } -async function _fetchBillRun (id) { +async function _fetchBillRun(id) { return BillRunModel.query() .findById(id) - .select([ - 'id', - 'batchType', - 'billRunNumber', - 'createdAt', - 'scheme', - 'status', - 'summer', - 'toFinancialYearEnding' - ]) + .select(['id', 'batchType', 'billRunNumber', 'createdAt', 'scheme', 'status', 'summer', 'toFinancialYearEnding']) .withGraphFetched('region') .modifyGraph('region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) } diff --git a/app/services/bill-runs/setup/create.service.js b/app/services/bill-runs/setup/create.service.js index 232b395281..1de4c58303 100644 --- a/app/services/bill-runs/setup/create.service.js +++ b/app/services/bill-runs/setup/create.service.js @@ -21,7 +21,7 @@ const StartBillRunProcessService = require('../start-bill-run-process.service.js * @param {object} user - Instance of `UserModel` that represents the user making the request * @param {object} existsResults - Results of `ExistsService` returned in the controller and passed on to this service */ -async function go (user, existsResults) { +async function go(user, existsResults) { const { matchResults, session, yearToUse } = existsResults const { region: regionId, type, summer } = session @@ -33,7 +33,7 @@ async function go (user, existsResults) { await session.$query().delete() } -async function _triggerBillRun (regionId, batchType, user, year, existingBillRun = null) { +async function _triggerBillRun(regionId, batchType, user, year, existingBillRun = null) { const { username: userEmail } = user // The one case we have to handle is where the user selected supplementary and a match was found, but it was to an @@ -51,7 +51,7 @@ async function _triggerBillRun (regionId, batchType, user, year, existingBillRun return StartBillRunProcessService.go(regionId, batchType, userEmail, year) } -async function _triggerLegacyBillRun (regionId, batchType, user, year, summer, existingBillRun = null) { +async function _triggerLegacyBillRun(regionId, batchType, user, year, summer, existingBillRun = null) { // The legacy service no longer handles annual billing if (batchType === 'annual') { return null diff --git a/app/services/bill-runs/setup/determine-financial-year-end.service.js b/app/services/bill-runs/setup/determine-financial-year-end.service.js index b3a519c92a..5fa8b12138 100644 --- a/app/services/bill-runs/setup/determine-financial-year-end.service.js +++ b/app/services/bill-runs/setup/determine-financial-year-end.service.js @@ -37,7 +37,7 @@ const { determineCurrentFinancialYear } = require('../../../lib/general.lib.js') * * @returns {Promise} The financial end year to use for selected bill run type and region */ -async function go (regionId, billRunType, year = null) { +async function go(regionId, billRunType, year = null) { const currentFinancialYear = determineCurrentFinancialYear() const currentFinancialYearEnd = currentFinancialYear.endDate.getFullYear() @@ -52,12 +52,9 @@ async function go (regionId, billRunType, year = null) { return currentFinancialYearEnd } -async function _determineSupplementaryEndYear (regionId, currentFinancialYearEnd) { +async function _determineSupplementaryEndYear(regionId, currentFinancialYearEnd) { const billRun = await BillRunModel.query() - .select([ - 'id', - 'toFinancialYearEnding' - ]) + .select(['id', 'toFinancialYearEnding']) .where('regionId', regionId) .where('batchType', 'annual') .where('status', 'sent') diff --git a/app/services/bill-runs/setup/exists.service.js b/app/services/bill-runs/setup/exists.service.js index c51c112d68..66f7134b8f 100644 --- a/app/services/bill-runs/setup/exists.service.js +++ b/app/services/bill-runs/setup/exists.service.js @@ -35,7 +35,7 @@ const SessionModel = require('../../../models/session.model.js') * If the bill run is supplementary and 2 matches are found it returns the most recent match formatted for use in the * '/exists' page. */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const { region, type, year } = session @@ -53,13 +53,13 @@ async function go (sessionId) { } } -async function _fetchMatchingBillRun (session, year) { +async function _fetchMatchingBillRun(session, year) { const { region, season, type } = session return DetermineBlockingBillRunService.go(region, type, year, season) } -function _pageData (session, matchResults) { +function _pageData(session, matchResults) { const { type } = session // No matches so we can create the bill run diff --git a/app/services/bill-runs/setup/fetch-licence-supplementary-years.service.js b/app/services/bill-runs/setup/fetch-licence-supplementary-years.service.js index 32dd2e8e4c..c20c95bf55 100644 --- a/app/services/bill-runs/setup/fetch-licence-supplementary-years.service.js +++ b/app/services/bill-runs/setup/fetch-licence-supplementary-years.service.js @@ -15,7 +15,7 @@ const LicenceSupplementaryYearModel = require('../../../models/licence-supplemen * * @returns {Promise} An array of distinct years flagged for supplementary billing in descending order */ -async function go (regionId, twoPartTariff) { +async function go(regionId, twoPartTariff) { return LicenceSupplementaryYearModel.query() .distinct('financialYearEnd') .innerJoinRelated('licence') diff --git a/app/services/bill-runs/setup/fetch-regions.service.js b/app/services/bill-runs/setup/fetch-regions.service.js index ebfd20b98c..e98e61b764 100644 --- a/app/services/bill-runs/setup/fetch-regions.service.js +++ b/app/services/bill-runs/setup/fetch-regions.service.js @@ -12,15 +12,10 @@ const RegionModel = require('../../../models/region.model.js') * * @returns {Promise} The display name and ID for all regions in the service ordered by display name */ -async function go () { +async function go() { return RegionModel.query() - .select([ - 'id', - 'displayName' - ]) - .orderBy([ - { column: 'displayName', order: 'asc' } - ]) + .select(['id', 'displayName']) + .orderBy([{ column: 'displayName', order: 'asc' }]) } module.exports = { diff --git a/app/services/bill-runs/setup/initiate-session.service.js b/app/services/bill-runs/setup/initiate-session.service.js index 67d94a67e5..e7a657d75f 100644 --- a/app/services/bill-runs/setup/initiate-session.service.js +++ b/app/services/bill-runs/setup/initiate-session.service.js @@ -19,7 +19,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} the newly created session record */ -async function go () { +async function go() { // NOTE: data defaults to {} when a new record is created. But Objection.js throws a 'The query is empty' if we pass // nothing into `insert()`. return SessionModel.query().insert({ data: {} }).returning('id') diff --git a/app/services/bill-runs/setup/no-licences.service.js b/app/services/bill-runs/setup/no-licences.service.js index 8ac9e5f63e..5005bd91a0 100644 --- a/app/services/bill-runs/setup/no-licences.service.js +++ b/app/services/bill-runs/setup/no-licences.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The display name of the region */ -async function go (sessionId) { +async function go(sessionId) { const { region: regionId } = await SessionModel.query().findById(sessionId) const { displayName: regionName } = await RegionModel.query().findById(regionId).select('displayName') diff --git a/app/services/bill-runs/setup/region.service.js b/app/services/bill-runs/setup/region.service.js index f943410f77..a17d8310cb 100644 --- a/app/services/bill-runs/setup/region.service.js +++ b/app/services/bill-runs/setup/region.service.js @@ -19,7 +19,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the region page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const regions = await FetchRegionsService.go() diff --git a/app/services/bill-runs/setup/season.service.js b/app/services/bill-runs/setup/season.service.js index e2752c7a48..13fb3753d4 100644 --- a/app/services/bill-runs/setup/season.service.js +++ b/app/services/bill-runs/setup/season.service.js @@ -18,7 +18,7 @@ const SeasonPresenter = require('../../../presenters/bill-runs/setup/season.pres * * @returns {Promise} The view data for the season page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = SeasonPresenter.go(session) diff --git a/app/services/bill-runs/setup/submit-region.service.js b/app/services/bill-runs/setup/submit-region.service.js index 8e7183d32a..d94535c6e4 100644 --- a/app/services/bill-runs/setup/submit-region.service.js +++ b/app/services/bill-runs/setup/submit-region.service.js @@ -30,7 +30,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} An object with a `setupComplete:` property if there are no errors else the page data for * the region page including the validation error details */ -async function go (sessionId, payload) { +async function go(sessionId, payload) { const session = await SessionModel.query().findById(sessionId) const regions = await FetchRegionsService.go() @@ -51,7 +51,7 @@ async function go (sessionId, payload) { } } -async function _save (session, payload) { +async function _save(session, payload) { const currentData = session currentData.region = payload.region @@ -59,7 +59,7 @@ async function _save (session, payload) { return session.$query().patch({ data: currentData }) } -function _validate (payload, regions) { +function _validate(payload, regions) { const validation = RegionValidator.go(payload, regions) if (!validation.error) { diff --git a/app/services/bill-runs/setup/submit-season.service.js b/app/services/bill-runs/setup/submit-season.service.js index bae553c101..3eaf2620d5 100644 --- a/app/services/bill-runs/setup/submit-season.service.js +++ b/app/services/bill-runs/setup/submit-season.service.js @@ -28,7 +28,7 @@ const SeasonValidator = require('../../../validators/bill-runs/setup/season.vali * @returns {Promise} An empty object if there are no errors else the page data for the type page including the * validation error details */ -async function go (sessionId, payload) { +async function go(sessionId, payload) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -47,13 +47,13 @@ async function go (sessionId, payload) { } } -async function _save (session, payload) { +async function _save(session, payload) { session.season = payload.season return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = SeasonValidator.go(payload) if (!validation.error) { diff --git a/app/services/bill-runs/setup/submit-type.service.js b/app/services/bill-runs/setup/submit-type.service.js index 8a785d80e4..5686d93068 100644 --- a/app/services/bill-runs/setup/submit-type.service.js +++ b/app/services/bill-runs/setup/submit-type.service.js @@ -28,7 +28,7 @@ const TypeValidator = require('../../../validators/bill-runs/setup/type.validato * @returns {Promise} An empty object if there are no errors else the page data for the type page including the * validation error details */ -async function go (sessionId, payload) { +async function go(sessionId, payload) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -47,13 +47,13 @@ async function go (sessionId, payload) { } } -async function _save (session, payload) { +async function _save(session, payload) { session.type = payload.type return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = TypeValidator.go(payload) if (!validation.error) { diff --git a/app/services/bill-runs/setup/submit-year.service.js b/app/services/bill-runs/setup/submit-year.service.js index cd05fa24b3..74c58b8e83 100644 --- a/app/services/bill-runs/setup/submit-year.service.js +++ b/app/services/bill-runs/setup/submit-year.service.js @@ -30,7 +30,7 @@ const YearValidator = require('../../../validators/bill-runs/setup/year.validato * @returns {Promise} An object with a `setupComplete:` property if there are no errors else the page data for * the year page including the validation error details */ -async function go (sessionId, payload) { +async function go(sessionId, payload) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -59,13 +59,13 @@ async function go (sessionId, payload) { } } -async function _save (session, payload) { +async function _save(session, payload) { session.year = payload.year return session.$update() } -function _validate (payload, regions) { +function _validate(payload, regions) { const validation = YearValidator.go(payload, regions) if (!validation.error) { diff --git a/app/services/bill-runs/setup/type.service.js b/app/services/bill-runs/setup/type.service.js index 67259e3515..117b1feed8 100644 --- a/app/services/bill-runs/setup/type.service.js +++ b/app/services/bill-runs/setup/type.service.js @@ -20,7 +20,7 @@ const FeatureFlagsConfig = require('../../../../config/feature-flags.config.js') * * @returns {Promise} The view data for the type page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = TypePresenter.go(session) diff --git a/app/services/bill-runs/setup/year.service.js b/app/services/bill-runs/setup/year.service.js index 2250246213..98ce2ea8f9 100644 --- a/app/services/bill-runs/setup/year.service.js +++ b/app/services/bill-runs/setup/year.service.js @@ -19,7 +19,7 @@ const YearPresenter = require('../../../presenters/bill-runs/setup/year.presente * * @returns {Promise} The view data for the year page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const regionId = session.region diff --git a/app/services/bill-runs/start-bill-run-process.service.js b/app/services/bill-runs/start-bill-run-process.service.js index f5bd6dfdf3..65a439f251 100644 --- a/app/services/bill-runs/start-bill-run-process.service.js +++ b/app/services/bill-runs/start-bill-run-process.service.js @@ -23,7 +23,7 @@ const TwoPartTariffProcessBillRunService = require('./two-part-tariff/process-bi * * @returns {Promise} Object that will be the JSON response returned to the client */ -async function go (regionId, batchType, userEmail, financialYearEnding) { +async function go(regionId, batchType, userEmail, financialYearEnding) { const billingPeriods = DetermineBillingPeriodsService.go(batchType, financialYearEnding) if (billingPeriods.length === 0) { @@ -38,14 +38,14 @@ async function go (regionId, batchType, userEmail, financialYearEnding) { return _response(billRun) } -function _financialYearEndings (billingPeriods) { +function _financialYearEndings(billingPeriods) { return { fromFinancialYearEnding: billingPeriods[billingPeriods.length - 1].endDate.getFullYear(), toFinancialYearEnding: billingPeriods[0].endDate.getFullYear() } } -function _processBillRun (billRun, billingPeriods) { +function _processBillRun(billRun, billingPeriods) { // We do not `await` the bill run being processed so we can leave it to run in the background while we return an // immediate response switch (billRun.batchType) { @@ -61,7 +61,7 @@ function _processBillRun (billRun, billingPeriods) { } } -function _response (billRun) { +function _response(billRun) { return CreateBillRunPresenter.go(billRun) } diff --git a/app/services/bill-runs/supplementary/fetch-billing-accounts.service.js b/app/services/bill-runs/supplementary/fetch-billing-accounts.service.js index 062cef2b03..9b6afda595 100644 --- a/app/services/bill-runs/supplementary/fetch-billing-accounts.service.js +++ b/app/services/bill-runs/supplementary/fetch-billing-accounts.service.js @@ -14,7 +14,7 @@ const BillingAccountModel = require('../../../models/billing-account.model.js') * * @returns {Promise} Array of objects in the format { billingAccountId: '...', accountNumber: '...' } */ -async function go (chargeVersions) { +async function go(chargeVersions) { const uniqueBillingAccountIds = _extractUniqueBillingAccountIds(chargeVersions) const billingAccountModels = await _fetch(uniqueBillingAccountIds) @@ -25,7 +25,7 @@ async function go (chargeVersions) { return billingAccountObjects } -function _extractUniqueBillingAccountIds (chargeVersions) { +function _extractUniqueBillingAccountIds(chargeVersions) { const allBillingAccountIds = chargeVersions.map((chargeVersion) => { return chargeVersion.billingAccountId }) @@ -35,13 +35,13 @@ function _extractUniqueBillingAccountIds (chargeVersions) { return [...new Set(allBillingAccountIds)] } -function _fetch (uniqueBillingAccountIds) { +function _fetch(uniqueBillingAccountIds) { return BillingAccountModel.query() .select('id', 'accountNumber') .findByIds([...uniqueBillingAccountIds]) } -function _makeObjects (models) { +function _makeObjects(models) { return models.map((model) => { return model.toJSON() }) diff --git a/app/services/bill-runs/supplementary/fetch-charge-versions.service.js b/app/services/bill-runs/supplementary/fetch-charge-versions.service.js index f39f2d8249..4ef6c2a2f8 100644 --- a/app/services/bill-runs/supplementary/fetch-charge-versions.service.js +++ b/app/services/bill-runs/supplementary/fetch-charge-versions.service.js @@ -30,13 +30,13 @@ const Workflow = require('../../../models/workflow.model.js') * * @returns {Promise} Contains an array of unique licence IDs and array of charge versions to be processed */ -async function go (regionId, billingPeriod) { +async function go(regionId, billingPeriod) { const allChargeVersions = await _fetch(regionId, billingPeriod) return _extractLicenceIdsThenRemoveNonChargeableChargeVersions(allChargeVersions) } -async function _fetch (regionId, billingPeriod) { +async function _fetch(regionId, billingPeriod) { const allChargeVersions = await ChargeVersionModel.query() .select([ 'chargeVersions.id', @@ -58,10 +58,7 @@ async function _fetch (regionId, billingPeriod) { .whereColumn('chargeVersions.licenceId', 'workflows.licenceId') .whereNull('workflows.deletedAt') ) - .orderBy([ - { column: 'chargeVersions.billingAccountId' }, - { column: 'chargeVersions.licenceId' } - ]) + .orderBy([{ column: 'chargeVersions.billingAccountId' }, { column: 'chargeVersions.licenceId' }]) .withGraphFetched('licence') .modifyGraph('licence', (builder) => { builder.select([ @@ -78,35 +75,19 @@ async function _fetch (regionId, billingPeriod) { }) .withGraphFetched('licence.region') .modifyGraph('licence.region', (builder) => { - builder.select([ - 'id', - 'chargeRegionId' - ]) + builder.select(['id', 'chargeRegionId']) }) .withGraphFetched('changeReason') .modifyGraph('changeReason', (builder) => { - builder.select([ - 'triggersMinimumCharge' - ]) + builder.select(['triggersMinimumCharge']) }) .withGraphFetched('chargeReferences') .modifyGraph('chargeReferences', (builder) => { - builder.select([ - 'id', - 'source', - 'loss', - 'volume', - 'adjustments', - 'additionalCharges', - 'description' - ]) + builder.select(['id', 'source', 'loss', 'volume', 'adjustments', 'additionalCharges', 'description']) }) .withGraphFetched('chargeReferences.chargeCategory') .modifyGraph('chargeReferences.chargeCategory', (builder) => { - builder.select([ - 'reference', - 'shortDescription' - ]) + builder.select(['reference', 'shortDescription']) }) .withGraphFetched('chargeReferences.chargeElements') .modifyGraph('chargeReferences.chargeElements', (builder) => { @@ -131,7 +112,7 @@ async function _fetch (regionId, billingPeriod) { * * @private */ -function _extractLicenceIdsThenRemoveNonChargeableChargeVersions (allChargeVersions) { +function _extractLicenceIdsThenRemoveNonChargeableChargeVersions(allChargeVersions) { const chargeVersions = [] let licenceIdsForPeriod = [] diff --git a/app/services/bill-runs/supplementary/fetch-previous-transactions.service.js b/app/services/bill-runs/supplementary/fetch-previous-transactions.service.js index 5944efff01..d5ce112fa2 100644 --- a/app/services/bill-runs/supplementary/fetch-previous-transactions.service.js +++ b/app/services/bill-runs/supplementary/fetch-previous-transactions.service.js @@ -19,7 +19,7 @@ const TransactionModel = require('../../../models/transaction.model.js') * * @returns {Promise} The resulting matched transactions */ -async function go (billingAccountId, licenceId, financialYearEnding) { +async function go(billingAccountId, licenceId, financialYearEnding) { const transactions = await _fetch(billingAccountId, licenceId, financialYearEnding) return _cleanse(transactions) @@ -33,7 +33,7 @@ async function go (billingAccountId, licenceId, financialYearEnding) { * * @private */ -function _cleanse (transactions) { +function _cleanse(transactions) { const credits = transactions.filter((transaction) => { return transaction.credit }) @@ -54,7 +54,7 @@ function _cleanse (transactions) { return debits } -async function _fetch (billingAccountId, licenceId, financialYearEnding) { +async function _fetch(billingAccountId, licenceId, financialYearEnding) { return TransactionModel.query() .select([ 'transactions.authorisedDays', diff --git a/app/services/bill-runs/supplementary/pre-generate-billing-data.service.js b/app/services/bill-runs/supplementary/pre-generate-billing-data.service.js index d054f34f43..e0118f2430 100644 --- a/app/services/bill-runs/supplementary/pre-generate-billing-data.service.js +++ b/app/services/bill-runs/supplementary/pre-generate-billing-data.service.js @@ -20,7 +20,7 @@ const { generateUUID } = require('../../../lib/general.lib.js') * * @returns {Promise} An object containing arrays of bills and billLicences objects */ -async function go (chargeVersions, billRunId, billingPeriod) { +async function go(chargeVersions, billRunId, billingPeriod) { const billingAccounts = await FetchBillingAccountsService.go(chargeVersions) const bills = _preGenerateBills(billingAccounts, billRunId, billingPeriod) @@ -29,7 +29,7 @@ async function go (chargeVersions, billRunId, billingPeriod) { return { bills, billLicences } } -function _generateBill (billingAccountId, accountNumber, billRunId, financialYearEnding) { +function _generateBill(billingAccountId, accountNumber, billRunId, financialYearEnding) { return { id: generateUUID(), accountNumber, @@ -41,7 +41,7 @@ function _generateBill (billingAccountId, accountNumber, billRunId, financialYea } } -function _generateBillLicence (billId, licenceId, licenceRef) { +function _generateBillLicence(billId, licenceId, licenceRef) { return { id: generateUUID(), billId, @@ -65,7 +65,7 @@ function _generateBillLicence (billId, licenceId, licenceRef) { * * @private */ -function _preGenerateBillLicences (chargeVersions, bills) { +function _preGenerateBillLicences(chargeVersions, bills) { const keyedBillLicences = chargeVersions.reduce((acc, chargeVersion) => { const { id: billId } = bills[chargeVersion.billingAccountId] const { id: licenceId, licenceRef } = chargeVersion.licence @@ -87,7 +87,7 @@ function _preGenerateBillLicences (chargeVersions, bills) { return keyedBillLicences } -function _billLicenceKey (billId, licenceId) { +function _billLicenceKey(billId, licenceId) { return `${billId}-${licenceId}` } @@ -105,7 +105,7 @@ function _billLicenceKey (billId, licenceId) { * * @private */ -function _preGenerateBills (billingAccounts, billRunId, billingPeriod) { +function _preGenerateBills(billingAccounts, billRunId, billingPeriod) { const keyedBills = billingAccounts.reduce((acc, billingAccount) => { const { id: billingAccountId, accountNumber } = billingAccount @@ -113,12 +113,7 @@ function _preGenerateBills (billingAccounts, billRunId, billingPeriod) { // bill licence already exists in the object before generating one return { ...acc, - [billingAccountId]: _generateBill( - billingAccountId, - accountNumber, - billRunId, - billingPeriod.endDate.getFullYear() - ) + [billingAccountId]: _generateBill(billingAccountId, accountNumber, billRunId, billingPeriod.endDate.getFullYear()) } }, {}) diff --git a/app/services/bill-runs/supplementary/process-bill-run.service.js b/app/services/bill-runs/supplementary/process-bill-run.service.js index ab47db8203..1da2a98cd4 100644 --- a/app/services/bill-runs/supplementary/process-bill-run.service.js +++ b/app/services/bill-runs/supplementary/process-bill-run.service.js @@ -22,7 +22,7 @@ const UnflagUnbilledLicencesService = require('./unflag-unbilled-licences.servic * @param {module:BillRunModel} billRun * @param {object[]} billingPeriods - An array of billing periods each containing a `startDate` and `endDate` */ -async function go (billRun, billingPeriods) { +async function go(billRun, billingPeriods) { const { id: billRunId } = billRun try { @@ -39,7 +39,7 @@ async function go (billRun, billingPeriods) { } } -async function _processBillingPeriods (billingPeriods, billRun) { +async function _processBillingPeriods(billingPeriods, billRun) { const accumulatedLicenceIds = [] // We use `results` to check if any db changes have been made (which is indicated by a billing period being processed @@ -57,7 +57,7 @@ async function _processBillingPeriods (billingPeriods, billRun) { await _finaliseBillRun(billRun, accumulatedLicenceIds, results) } -async function _fetchChargeVersions (billRun, billingPeriod) { +async function _fetchChargeVersions(billRun, billingPeriod) { try { const chargeVersionData = await FetchChargeVersionsService.go(billRun.regionId, billingPeriod) @@ -76,7 +76,7 @@ async function _fetchChargeVersions (billRun, billingPeriod) { * * @private */ -async function _finaliseBillRun (billRun, accumulatedLicenceIds, resultsOfProcessing) { +async function _finaliseBillRun(billRun, accumulatedLicenceIds, resultsOfProcessing) { // Creating a new set from accumulatedLicenceIds gives us just the unique ids. Objection does not accept sets in // .findByIds() so we spread it into an array const allLicenceIds = [...new Set(accumulatedLicenceIds)] @@ -103,14 +103,12 @@ async function _finaliseBillRun (billRun, accumulatedLicenceIds, resultsOfProces await LegacyRefreshBillRunRequest.send(billRun.id) } -function _logError (billRun, error) { +function _logError(billRun, error) { global.GlobalNotifier.omfg('Bill run process errored', { billRun }, error) } -async function _updateStatus (billRunId, status) { - await BillRunModel.query() - .findById(billRunId) - .patch({ status }) +async function _updateStatus(billRunId, status) { + await BillRunModel.query().findById(billRunId).patch({ status }) } module.exports = { diff --git a/app/services/bill-runs/supplementary/process-billing-period.service.js b/app/services/bill-runs/supplementary/process-billing-period.service.js index 752546b68b..d926f36630 100644 --- a/app/services/bill-runs/supplementary/process-billing-period.service.js +++ b/app/services/bill-runs/supplementary/process-billing-period.service.js @@ -26,16 +26,12 @@ const TransactionModel = require('../../../models/transaction.model.js') * * @returns {boolean} true if the bill run is not empty (there are transactions to bill) else false */ -async function go (billRun, billingPeriod, chargeVersions) { +async function go(billRun, billingPeriod, chargeVersions) { if (chargeVersions.length === 0) { return false } - const preGeneratedData = await PreGenerateBillingDataService.go( - chargeVersions, - billRun.id, - billingPeriod - ) + const preGeneratedData = await PreGenerateBillingDataService.go(chargeVersions, billRun.id, billingPeriod) const billingData = _buildBillingDataWithTransactions(chargeVersions, preGeneratedData, billingPeriod) const dataToPersist = await _buildDataToPersist(billingData, billingPeriod, billRun.externalId) @@ -51,7 +47,7 @@ async function go (billRun, billingPeriod, chargeVersions) { * * @private */ -async function _buildDataToPersist (billingData, billingPeriod, billRunExternalId) { +async function _buildDataToPersist(billingData, billingPeriod, billRunExternalId) { const dataToPersist = { transactions: [], // We use a set as this won't create an additional entry if we try to add a billing invoice already in it @@ -105,7 +101,7 @@ async function _buildDataToPersist (billingData, billingPeriod, billRunExternalI * * @private */ -function _buildBillingDataWithTransactions (chargeVersions, preGeneratedData, billingPeriod) { +function _buildBillingDataWithTransactions(chargeVersions, preGeneratedData, billingPeriod) { // We use reduce to build up the object as this allows us to start with an empty object and populate it with each // charge version. return chargeVersions.reduce((acc, chargeVersion) => { @@ -138,7 +134,7 @@ function _buildBillingDataWithTransactions (chargeVersions, preGeneratedData, bi * * @private */ -async function _persistData (dataToPersist) { +async function _persistData(dataToPersist) { // If we don't have any transactions to persist then we also won't have any bills or bill licences, so we // simply return early if (dataToPersist.transactions.length === 0) { @@ -152,7 +148,7 @@ async function _persistData (dataToPersist) { return true } -function _retrievePreGeneratedData (preGeneratedData, billingAccountId, licence) { +function _retrievePreGeneratedData(preGeneratedData, billingAccountId, licence) { const { bills, billLicences } = preGeneratedData const bill = bills[billingAccountId] @@ -163,11 +159,11 @@ function _retrievePreGeneratedData (preGeneratedData, billingAccountId, licence) return { bill, billLicence } } -function _billLicenceKey (billId, licenceId) { +function _billLicenceKey(billId, licenceId) { return `${billId}-${licenceId}` } -function _initialBillingData (licence, bill, billLicence) { +function _initialBillingData(licence, bill, billLicence) { return { licence, bill, @@ -176,7 +172,7 @@ function _initialBillingData (licence, bill, billLicence) { } } -async function _cleanseTransactions (currentBillingData, billingPeriod) { +async function _cleanseTransactions(currentBillingData, billingPeriod) { // Guard clause which is most likely to hit in the event that no charge versions were 'fetched' to be billed in // the first place if (!currentBillingData.bill) { @@ -193,7 +189,7 @@ async function _cleanseTransactions (currentBillingData, billingPeriod) { return cleansedTransactions } -function _generateCalculatedTransactions (billLicenceId, billingPeriod, chargeVersion) { +function _generateCalculatedTransactions(billLicenceId, billingPeriod, chargeVersion) { try { const chargePeriod = DetermineChargePeriodService.go(chargeVersion, billingPeriod) diff --git a/app/services/bill-runs/supplementary/process-transactions.service.js b/app/services/bill-runs/supplementary/process-transactions.service.js index 67457a3733..d09e028bc1 100644 --- a/app/services/bill-runs/supplementary/process-transactions.service.js +++ b/app/services/bill-runs/supplementary/process-transactions.service.js @@ -25,7 +25,7 @@ const ReverseTransactionsService = require('./reverse-transactions.service.js') * @returns {Promise} An array of the remaining calculated transactions (ie. those which were not cancelled * out by a previous matching credit) */ -async function go (calculatedTransactions, billingAccountId, billLicence, billingPeriod) { +async function go(calculatedTransactions, billingAccountId, billLicence, billingPeriod) { const { id: billLicenceId, licenceId } = billLicence const previousTransactions = await _fetchPreviousTransactions(billingAccountId, licenceId, billingPeriod) @@ -50,7 +50,7 @@ async function go (calculatedTransactions, billingAccountId, billLicence, billin * * @private */ -function _cancelCalculatedTransaction (calculatedTransaction, reversedTransactions) { +function _cancelCalculatedTransaction(calculatedTransaction, reversedTransactions) { const result = reversedTransactions.findIndex((reversedTransaction) => { return transactionsMatch(reversedTransaction, calculatedTransaction) }) @@ -72,7 +72,7 @@ function _cancelCalculatedTransaction (calculatedTransaction, reversedTransactio * * @private */ -function _cleanseTransactions (calculatedTransactions, reverseTransactions) { +function _cleanseTransactions(calculatedTransactions, reverseTransactions) { const cleansedTransactionLines = [] // Iterate over each calculated transaction to see if a transaction in the reverse transactions would form a @@ -91,7 +91,7 @@ function _cleanseTransactions (calculatedTransactions, reverseTransactions) { return cleansedTransactionLines } -async function _fetchPreviousTransactions (billingAccountId, licenceId, billingPeriod) { +async function _fetchPreviousTransactions(billingAccountId, licenceId, billingPeriod) { const financialYearEnding = billingPeriod.endDate.getFullYear() const transactions = await FetchPreviousTransactionsService.go(billingAccountId, licenceId, financialYearEnding) diff --git a/app/services/bill-runs/supplementary/reverse-transactions.service.js b/app/services/bill-runs/supplementary/reverse-transactions.service.js index 3d5c3b719a..ee6a738834 100644 --- a/app/services/bill-runs/supplementary/reverse-transactions.service.js +++ b/app/services/bill-runs/supplementary/reverse-transactions.service.js @@ -19,7 +19,7 @@ const { generateUUID } = require('../../../lib/general.lib.js') * * @returns {object[]} Array of reversed transactions with `billLicenceId` set to the id of the supplied `billLicence` */ -function go (transactions, billLicenceId) { +function go(transactions, billLicenceId) { return _reverseTransactions(transactions, billLicenceId) } @@ -30,7 +30,7 @@ function go (transactions, billLicenceId) { * * @private */ -function _reverseTransactions (transactions, billLicenceId) { +function _reverseTransactions(transactions, billLicenceId) { return transactions.map((transaction) => { return { ...transaction, diff --git a/app/services/bill-runs/supplementary/unflag-billed-licences.service.js b/app/services/bill-runs/supplementary/unflag-billed-licences.service.js index a2273597a6..855701a706 100644 --- a/app/services/bill-runs/supplementary/unflag-billed-licences.service.js +++ b/app/services/bill-runs/supplementary/unflag-billed-licences.service.js @@ -36,7 +36,7 @@ const LicenceModel = require('../../../models/licence.model.js') * * @returns {Promise} Resolves to the count of records updated */ -async function go (billRun) { +async function go(billRun) { const { scheme } = billRun if (scheme === 'sroc') { @@ -51,7 +51,7 @@ async function go (billRun) { * * @private */ -async function _updateOldScheme (billRun) { +async function _updateOldScheme(billRun) { const { createdAt, regionId } = billRun return LicenceModel.query() @@ -59,10 +59,7 @@ async function _updateOldScheme (billRun) { .where('updatedAt', '<=', createdAt) .where('regionId', regionId) .where('includeInPresrocBilling', 'yes') - .whereNotExists( - LicenceModel.relatedQuery('workflows') - .whereNull('workflows.deletedAt') - ) + .whereNotExists(LicenceModel.relatedQuery('workflows').whereNull('workflows.deletedAt')) } /** @@ -70,16 +67,13 @@ async function _updateOldScheme (billRun) { * * @private */ -async function _updateCurrentScheme (billRun) { +async function _updateCurrentScheme(billRun) { const { id: billRunId, createdAt } = billRun return LicenceModel.query() .patch({ includeInSrocBilling: false }) .where('updatedAt', '<=', createdAt) - .whereNotExists( - LicenceModel.relatedQuery('workflows') - .whereNull('workflows.deletedAt') - ) + .whereNotExists(LicenceModel.relatedQuery('workflows').whereNull('workflows.deletedAt')) .whereExists( LicenceModel.relatedQuery('billLicences') .join('bills', 'bills.id', 'billLicences.billId') diff --git a/app/services/bill-runs/supplementary/unflag-unbilled-licences.service.js b/app/services/bill-runs/supplementary/unflag-unbilled-licences.service.js index d0a7b36a80..e9e53a3748 100644 --- a/app/services/bill-runs/supplementary/unflag-unbilled-licences.service.js +++ b/app/services/bill-runs/supplementary/unflag-unbilled-licences.service.js @@ -36,16 +36,13 @@ const LicenceModel = require('../../../models/licence.model.js') * * @returns {Promise} Resolves to the count of records updated */ -async function go (billRun, allLicenceIds) { +async function go(billRun, allLicenceIds) { const { id: billRunId, createdAt } = billRun const result = await LicenceModel.query() .patch({ includeInSrocBilling: false }) .where('updatedAt', '<=', createdAt) - .whereNotExists( - LicenceModel.relatedQuery('workflows') - .whereNull('workflows.deletedAt') - ) + .whereNotExists(LicenceModel.relatedQuery('workflows').whereNull('workflows.deletedAt')) .whereNotExists( LicenceModel.relatedQuery('billLicences') .join('bills', 'bills.id', '=', 'billLicences.billId') diff --git a/app/services/bill-runs/two-part-tariff/fetch-billing-accounts.service.js b/app/services/bill-runs/two-part-tariff/fetch-billing-accounts.service.js index 6ff72084ef..76719005ee 100644 --- a/app/services/bill-runs/two-part-tariff/fetch-billing-accounts.service.js +++ b/app/services/bill-runs/two-part-tariff/fetch-billing-accounts.service.js @@ -31,16 +31,11 @@ const ChargeVersionModel = require('../../../models/charge-version.model.js') * licence, charge version, charge element etc records, plus the two-part tariff review details needed to generate the * bill run */ -async function go (billRunId) { +async function go(billRunId) { return BillingAccountModel.query() - .select([ - 'billingAccounts.id', - 'billingAccounts.accountNumber' - ]) + .select(['billingAccounts.id', 'billingAccounts.accountNumber']) .whereExists(_whereBillingAccountExistsClause(billRunId)) - .orderBy([ - { column: 'billingAccounts.accountNumber' } - ]) + .orderBy([{ column: 'billingAccounts.accountNumber' }]) .withGraphFetched('chargeVersions') .modifyGraph('chargeVersions', (builder) => { builder @@ -76,22 +71,20 @@ async function go (billRunId) { }) .withGraphFetched('chargeVersions.licence.region') .modifyGraph('chargeVersions.licence.region', (builder) => { - builder.select([ - 'id', - 'chargeRegionId' - ]) + builder.select(['id', 'chargeRegionId']) }) .withGraphFetched('chargeVersions.chargeReferences') .modifyGraph('chargeVersions.chargeReferences', (builder) => { - builder.select([ - 'chargeReferences.id', - 'chargeReferences.source', - 'chargeReferences.loss', - 'chargeReferences.volume', - 'chargeReferences.adjustments', - 'chargeReferences.additionalCharges', - 'chargeReferences.description' - ]) + builder + .select([ + 'chargeReferences.id', + 'chargeReferences.source', + 'chargeReferences.loss', + 'chargeReferences.volume', + 'chargeReferences.adjustments', + 'chargeReferences.additionalCharges', + 'chargeReferences.description' + ]) .innerJoin('reviewChargeReferences', 'reviewChargeReferences.chargeReferenceId', 'chargeReferences.id') .innerJoin('reviewChargeVersions', 'reviewChargeVersions.id', 'reviewChargeReferences.reviewChargeVersionId') .innerJoin('reviewLicences', 'reviewLicences.id', 'reviewChargeVersions.reviewLicenceId') @@ -99,53 +92,57 @@ async function go (billRunId) { }) .withGraphFetched('chargeVersions.chargeReferences.reviewChargeReferences') .modifyGraph('chargeVersions.chargeReferences.reviewChargeReferences', (builder) => { - builder.select([ - 'reviewChargeReferences.id', - 'reviewChargeReferences.amendedAggregate', - 'reviewChargeReferences.amendedChargeAdjustment', - 'reviewChargeReferences.amendedAuthorisedVolume' - ]) + builder + .select([ + 'reviewChargeReferences.id', + 'reviewChargeReferences.amendedAggregate', + 'reviewChargeReferences.amendedChargeAdjustment', + 'reviewChargeReferences.amendedAuthorisedVolume' + ]) .innerJoin('reviewChargeVersions', 'reviewChargeVersions.id', 'reviewChargeReferences.reviewChargeVersionId') .innerJoin('reviewLicences', 'reviewLicences.id', 'reviewChargeVersions.reviewLicenceId') .where('reviewLicences.billRunId', billRunId) }) .withGraphFetched('chargeVersions.chargeReferences.chargeCategory') .modifyGraph('chargeVersions.chargeReferences.chargeCategory', (builder) => { - builder.select([ - 'id', - 'reference', - 'shortDescription' - ]) + builder.select(['id', 'reference', 'shortDescription']) }) .withGraphFetched('chargeVersions.chargeReferences.chargeElements') .modifyGraph('chargeVersions.chargeReferences.chargeElements', (builder) => { - builder.select([ - 'chargeElements.id', - 'chargeElements.abstractionPeriodStartDay', - 'chargeElements.abstractionPeriodStartMonth', - 'chargeElements.abstractionPeriodEndDay', - 'chargeElements.abstractionPeriodEndMonth' - ]) + builder + .select([ + 'chargeElements.id', + 'chargeElements.abstractionPeriodStartDay', + 'chargeElements.abstractionPeriodStartMonth', + 'chargeElements.abstractionPeriodEndDay', + 'chargeElements.abstractionPeriodEndMonth' + ]) .innerJoin('reviewChargeElements', 'reviewChargeElements.chargeElementId', 'chargeElements.id') - .innerJoin('reviewChargeReferences', 'reviewChargeReferences.id', 'reviewChargeElements.reviewChargeReferenceId') + .innerJoin( + 'reviewChargeReferences', + 'reviewChargeReferences.id', + 'reviewChargeElements.reviewChargeReferenceId' + ) .innerJoin('reviewChargeVersions', 'reviewChargeVersions.id', 'reviewChargeReferences.reviewChargeVersionId') .innerJoin('reviewLicences', 'reviewLicences.id', 'reviewChargeVersions.reviewLicenceId') .where('reviewLicences.billRunId', billRunId) }) .withGraphFetched('chargeVersions.chargeReferences.chargeElements.reviewChargeElements') .modifyGraph('chargeVersions.chargeReferences.chargeElements.reviewChargeElements', (builder) => { - builder.select([ - 'reviewChargeElements.id', - 'reviewChargeElements.amendedAllocated' - ]) - .innerJoin('reviewChargeReferences', 'reviewChargeReferences.id', 'reviewChargeElements.reviewChargeReferenceId') + builder + .select(['reviewChargeElements.id', 'reviewChargeElements.amendedAllocated']) + .innerJoin( + 'reviewChargeReferences', + 'reviewChargeReferences.id', + 'reviewChargeElements.reviewChargeReferenceId' + ) .innerJoin('reviewChargeVersions', 'reviewChargeVersions.id', 'reviewChargeReferences.reviewChargeVersionId') .innerJoin('reviewLicences', 'reviewLicences.id', 'reviewChargeVersions.reviewLicenceId') .where('reviewLicences.billRunId', billRunId) }) } -function _whereBillingAccountExistsClause (billRunId) { +function _whereBillingAccountExistsClause(billRunId) { const query = ChargeVersionModel.query().select(1) query diff --git a/app/services/bill-runs/two-part-tariff/generate-bill-run.service.js b/app/services/bill-runs/two-part-tariff/generate-bill-run.service.js index 2869a20fc9..66b0d8ead1 100644 --- a/app/services/bill-runs/two-part-tariff/generate-bill-run.service.js +++ b/app/services/bill-runs/two-part-tariff/generate-bill-run.service.js @@ -43,7 +43,7 @@ const ProcessBillingPeriodService = require('./process-billing-period.service.js * @param {module:BillRunModel} billRunId - The UUID of the two-part tariff bill run that has been reviewed and is ready * for generating */ -async function go (billRunId) { +async function go(billRunId) { const billRun = await _fetchBillRun(billRunId) if (billRun.status !== 'review') { @@ -64,7 +64,7 @@ async function go (billRunId) { * * @private */ -function _billingPeriod (billRun) { +function _billingPeriod(billRun) { const { toFinancialYearEnding } = billRun return { @@ -73,7 +73,7 @@ function _billingPeriod (billRun) { } } -async function _fetchBillingAccounts (billRunId) { +async function _fetchBillingAccounts(billRunId) { try { return await FetchBillingAccountsService.go(billRunId) } catch (error) { @@ -83,22 +83,13 @@ async function _fetchBillingAccounts (billRunId) { } } -async function _fetchBillRun (billRunId) { +async function _fetchBillRun(billRunId) { return BillRunModel.query() .findById(billRunId) - .select([ - 'id', - 'batchType', - 'createdAt', - 'externalId', - 'regionId', - 'scheme', - 'status', - 'toFinancialYearEnding' - ]) + .select(['id', 'batchType', 'createdAt', 'externalId', 'regionId', 'scheme', 'status', 'toFinancialYearEnding']) } -async function _finaliseBillRun (billRun, billRunPopulated) { +async function _finaliseBillRun(billRun, billRunPopulated) { // If there are no bill licences then the bill run is considered empty. We just need to set the status to indicate // this in the UI if (!billRunPopulated) { @@ -121,7 +112,7 @@ async function _finaliseBillRun (billRun, billRunPopulated) { * * @private */ -async function _generateBillRun (billRun) { +async function _generateBillRun(billRun) { const { id: billRunId } = billRun try { @@ -138,7 +129,7 @@ async function _generateBillRun (billRun) { } } -async function _processBillingPeriod (billingPeriod, billRun) { +async function _processBillingPeriod(billingPeriod, billRun) { const { id: billRunId } = billRun const billingAccounts = await _fetchBillingAccounts(billRunId) @@ -148,10 +139,8 @@ async function _processBillingPeriod (billingPeriod, billRun) { await _finaliseBillRun(billRun, billRunPopulated) } -async function _updateStatus (billRunId, status) { - return BillRunModel.query() - .findById(billRunId) - .patch({ status, updatedAt: timestampForPostgres() }) +async function _updateStatus(billRunId, status) { + return BillRunModel.query().findById(billRunId).patch({ status, updatedAt: timestampForPostgres() }) } module.exports = { diff --git a/app/services/bill-runs/two-part-tariff/generate-transaction.service.js b/app/services/bill-runs/two-part-tariff/generate-transaction.service.js index bbd101e869..f47ca1d608 100644 --- a/app/services/bill-runs/two-part-tariff/generate-transaction.service.js +++ b/app/services/bill-runs/two-part-tariff/generate-transaction.service.js @@ -32,7 +32,7 @@ const { generateUUID } = require('../../../lib/general.lib.js') * * @returns {object} the two-part tariff transaction */ -function go (billLicenceId, chargeReference, chargePeriod, newLicence, waterUndertaker) { +function go(billLicenceId, chargeReference, chargePeriod, newLicence, waterUndertaker) { const billableQuantity = _billableQuantity(chargeReference.chargeElements) if (billableQuantity === 0) { @@ -49,7 +49,7 @@ function go (billLicenceId, chargeReference, chargePeriod, newLicence, waterUnde ) } -function _billableQuantity (chargeElements) { +function _billableQuantity(chargeElements) { return chargeElements.reduce((total, chargeElement) => { total += chargeElement.reviewChargeElements[0].amendedAllocated @@ -57,7 +57,7 @@ function _billableQuantity (chargeElements) { }, 0) } -function _description (chargeReference) { +function _description(chargeReference) { // If the value is false, undefined, null or simply doesn't exist we return the standard description if (!chargeReference.adjustments.s127) { return `Water abstraction charge: ${chargeReference.description}` @@ -71,7 +71,7 @@ function _description (chargeReference) { * * @private */ -function _generateElements (chargeReference) { +function _generateElements(chargeReference) { const jsonChargeElements = chargeReference.chargeElements.map((chargeElement) => { delete chargeElement.reviewChargeElements @@ -86,7 +86,7 @@ function _generateElements (chargeReference) { * * @private */ -function _standardTransaction ( +function _standardTransaction( billLicenceId, billableQuantity, chargeReference, diff --git a/app/services/bill-runs/two-part-tariff/process-bill-run.service.js b/app/services/bill-runs/two-part-tariff/process-bill-run.service.js index 57b1f82b0d..fdfb3db351 100644 --- a/app/services/bill-runs/two-part-tariff/process-bill-run.service.js +++ b/app/services/bill-runs/two-part-tariff/process-bill-run.service.js @@ -23,7 +23,7 @@ const MatchAndAllocateService = require('../match/match-and-allocate.service.js' * @param {object[]} billingPeriods - An array of billing periods each containing a `startDate` and `endDate`. For 2PT * this will only ever contain a single period */ -async function go (billRun, billingPeriods) { +async function go(billRun, billingPeriods) { const { id: billRunId } = billRun // NOTE: billingPeriods come from `DetermineBillingPeriodsService` which always returns an array because it is used by // all billing types. For two-part tariff we know it will only contain one because 2PT bill runs are only for a single @@ -47,7 +47,7 @@ async function go (billRun, billingPeriods) { } } -async function _setBillRunStatus (billRunId, populated) { +async function _setBillRunStatus(billRunId, populated) { // It is highly unlikely no licences were matched to returns. So we default status to 'review' let status = 'review' @@ -60,10 +60,8 @@ async function _setBillRunStatus (billRunId, populated) { return _updateStatus(billRunId, status) } -async function _updateStatus (billRunId, status) { - return BillRunModel.query() - .findById(billRunId) - .patch({ status }) +async function _updateStatus(billRunId, status) { + return BillRunModel.query().findById(billRunId).patch({ status }) } module.exports = { diff --git a/app/services/bill-runs/two-part-tariff/process-billing-period.service.js b/app/services/bill-runs/two-part-tariff/process-billing-period.service.js index 4de3f8c438..b4a6fc20b7 100644 --- a/app/services/bill-runs/two-part-tariff/process-billing-period.service.js +++ b/app/services/bill-runs/two-part-tariff/process-billing-period.service.js @@ -27,7 +27,7 @@ const BillingConfig = require('../../../../config/billing.config.js') * * @returns {Promise} true if the bill run is not empty (there are transactions to bill) else false */ -async function go (billRun, billingPeriod, billingAccounts) { +async function go(billRun, billingPeriod, billingAccounts) { let billRunIsPopulated = false if (billingAccounts.length === 0) { @@ -91,7 +91,7 @@ async function go (billRun, billingPeriod, billingAccounts) { * * @private */ -async function _createBillLicencesAndTransactions (billId, billingAccount, billRunExternalId, billingPeriod) { +async function _createBillLicencesAndTransactions(billId, billingAccount, billRunExternalId, billingPeriod) { const allBillLicences = [] const transactions = [] @@ -122,7 +122,7 @@ async function _createBillLicencesAndTransactions (billId, billingAccount, billR * * @private */ -async function _createTransactions (billLicenceId, billingPeriod, chargeVersion, billRunExternalId, accountNumber) { +async function _createTransactions(billLicenceId, billingPeriod, chargeVersion, billRunExternalId, accountNumber) { const chargePeriod = DetermineChargePeriodService.go(chargeVersion, billingPeriod) if (!chargePeriod.startDate) { @@ -148,7 +148,7 @@ async function _createTransactions (billLicenceId, billingPeriod, chargeVersion, * * @private */ -function _extractBillableLicences (allBillLicences) { +function _extractBillableLicences(allBillLicences) { const billableBillLicences = [] allBillLicences.forEach((billLicence) => { @@ -187,7 +187,7 @@ function _extractBillableLicences (allBillLicences) { * * @private */ -function _findOrCreateBillLicence (billLicences, licence, billId) { +function _findOrCreateBillLicence(billLicences, licence, billId) { const { id: licenceId, licenceRef } = licence let billLicence = billLicences.find((existingBillLicence) => { @@ -220,7 +220,7 @@ function _findOrCreateBillLicence (billLicences, licence, billId) { * * @private */ -function _generateTransactionData (billLicenceId, chargePeriod, chargeVersion) { +function _generateTransactionData(billLicenceId, chargePeriod, chargeVersion) { try { const firstChargeOnNewLicence = DetermineMinimumChargeService.go(chargeVersion, chargePeriod) @@ -257,7 +257,7 @@ function _generateTransactionData (billLicenceId, chargePeriod, chargeVersion) { * * @private */ -async function _processBillingAccount (billingAccount, billRun, billingPeriod) { +async function _processBillingAccount(billingAccount, billRun, billingPeriod) { const { id: billingAccountId, accountNumber } = billingAccount const { id: billRunId, externalId: billRunExternalId } = billRun @@ -283,7 +283,7 @@ async function _processBillingAccount (billingAccount, billRun, billingPeriod) { return _persistBillData(bill, billLicences, transactions) } -async function _persistBillData (bill, billLicences, transactions) { +async function _persistBillData(bill, billLicences, transactions) { await BillModel.query().insert(bill) await BillLicenceModel.query().insert(billLicences) await TransactionModel.query().insert(transactions) diff --git a/app/services/bill-runs/view-bill-run.service.js b/app/services/bill-runs/view-bill-run.service.js index 2e0fab099f..9a5d4180a4 100644 --- a/app/services/bill-runs/view-bill-run.service.js +++ b/app/services/bill-runs/view-bill-run.service.js @@ -19,7 +19,7 @@ const FetchBillRunService = require('./fetch-bill-run.service.js') * @returns {Promise} an object representing the `pageData` needed by the view bill run template. It contains * details of the bill run and the bills linked to it plus the page title. */ -async function go (id) { +async function go(id) { const result = await FetchBillRunService.go(id) const pageData = _pageData(result) @@ -27,7 +27,7 @@ async function go (id) { return pageData } -function _pageData (fetchResult) { +function _pageData(fetchResult) { const { billRun, billSummaries } = fetchResult if (billRun.status === 'empty') { diff --git a/app/services/billing-accounts/change-address.service.js b/app/services/billing-accounts/change-address.service.js index 594866eec5..c4280386f8 100644 --- a/app/services/billing-accounts/change-address.service.js +++ b/app/services/billing-accounts/change-address.service.js @@ -52,7 +52,7 @@ const SendCustomerChangeService = require('./send-customer-change.service.js') * @returns {Promise} contains a copy of the persisted address, agent company and contact if they were also * changed */ -async function go (billingAccountId, address, agentCompany = {}, contact = {}) { +async function go(billingAccountId, address, agentCompany = {}, contact = {}) { const billingAccount = await _fetchBillingAccount(billingAccountId) // We use the same timestamp for all date created/updated values. We then have something to tie together all the @@ -82,14 +82,12 @@ async function go (billingAccountId, address, agentCompany = {}, contact = {}) { return _response(persistedData) } -async function _fetchBillingAccount (billingAccountId) { +async function _fetchBillingAccount(billingAccountId) { return BillingAccountModel.query() .findById(billingAccountId) .withGraphFetched('company') .modifyGraph('company', (builder) => { - builder.select([ - 'name' - ]) + builder.select(['name']) }) } @@ -122,7 +120,7 @@ async function _fetchBillingAccount (billingAccountId) { * @returns {Promise} a single object that contains the persisted billingAccountAddress, plus address, agent * company and contact */ -async function _persist (timestamp, billingAccount, address, company, contact) { +async function _persist(timestamp, billingAccount, address, company, contact) { const persistedData = {} await BillingAccountModel.transaction(async (trx) => { @@ -148,7 +146,7 @@ async function _persist (timestamp, billingAccount, address, company, contact) { return persistedData } -async function _patchExistingBillingAccountAddressEndDate (trx, billingAccountId, timestamp) { +async function _patchExistingBillingAccountAddressEndDate(trx, billingAccountId, timestamp) { // The timestamp represents the current date and time we're making this change, i.e. today. So, the new billing // account address will start from today. To show that the old record is no longer current, we need to set its // `endDate` to be today - 1 (yesterday). The following works it all out even if we're over a month or year boundary @@ -178,18 +176,15 @@ async function _patchExistingBillingAccountAddressEndDate (trx, billingAccountId * * @private */ -async function _persistBillingAccountAddress (trx, billingAccountAddress) { - return billingAccountAddress.$query(trx) - .insert() - .onConflict(['billingAccountId', 'startDate']) - // If a conflict is found this specifies what fields should get updated - .merge([ - 'addressId', - 'companyId', - 'contactId', - 'endDate', - 'updatedAt' - ]) +async function _persistBillingAccountAddress(trx, billingAccountAddress) { + return ( + billingAccountAddress + .$query(trx) + .insert() + .onConflict(['billingAccountId', 'startDate']) + // If a conflict is found this specifies what fields should get updated + .merge(['addressId', 'companyId', 'contactId', 'endDate', 'updatedAt']) + ) } /** @@ -216,29 +211,30 @@ async function _persistBillingAccountAddress (trx, billingAccountAddress) { * * @private */ -async function _persistAddress (trx, address) { +async function _persistAddress(trx, address) { if (address.id) { return address } - return address.$query(trx) - .insert() - .onConflict('uprn') - // If a conflict is found this specifies what fields should get updated - .merge([ - 'address1', - 'address2', - 'address3', - 'address4', - 'address5', - 'address6', - 'country', - 'postcode', - 'updatedAt' - ]) - .returning([ - 'id' - ]) + return ( + address + .$query(trx) + .insert() + .onConflict('uprn') + // If a conflict is found this specifies what fields should get updated + .merge([ + 'address1', + 'address2', + 'address3', + 'address4', + 'address5', + 'address6', + 'country', + 'postcode', + 'updatedAt' + ]) + .returning(['id']) + ) } /** @@ -267,22 +263,20 @@ async function _persistAddress (trx, address) { * * @private */ -async function _persistCompany (trx, company) { +async function _persistCompany(trx, company) { if (company.id || !company.name) { return company } - return company.$query(trx) - .insert() - .onConflict('companyNumber') - // If a conflict is found this specifies what fields should get updated - .merge([ - 'name', - 'updatedAt' - ]) - .returning([ - 'id' - ]) + return ( + company + .$query(trx) + .insert() + .onConflict('companyNumber') + // If a conflict is found this specifies what fields should get updated + .merge(['name', 'updatedAt']) + .returning(['id']) + ) } /** @@ -293,18 +287,14 @@ async function _persistCompany (trx, company) { * * @private */ -async function _persistContact (trx, contact) { +async function _persistContact(trx, contact) { if (!contact.contactType) { return contact } // NOTE: The only constraint in contacts which would lead to a conflict is email. But it is not collected as part of // the journey. So, we don't have to include `onConflict()` and `merge()` - return contact.$query(trx) - .insert() - .returning([ - 'id' - ]) + return contact.$query(trx).insert().returning(['id']) } /** @@ -322,7 +312,7 @@ async function _persistContact (trx, contact) { * * @private */ -function _response (persistedData) { +function _response(persistedData) { const { address, company, contact, billingAccountAddress } = persistedData return { @@ -333,7 +323,7 @@ function _response (persistedData) { } } -function _transformAddress (timestamp, address) { +function _transformAddress(timestamp, address) { return AddressModel.fromJson({ id: address.addressId, address1: address.addressLine1, @@ -351,7 +341,7 @@ function _transformAddress (timestamp, address) { }) } -function _transformCompany (timestamp, company) { +function _transformCompany(timestamp, company) { return CompanyModel.fromJson({ id: company.companyId, type: company.type, @@ -363,7 +353,7 @@ function _transformCompany (timestamp, company) { }) } -function _transformContact (timestamp, contact) { +function _transformContact(timestamp, contact) { return ContactModel.fromJson({ contactType: contact.type, salutation: contact.salutation, diff --git a/app/services/billing-accounts/send-customer-change.service.js b/app/services/billing-accounts/send-customer-change.service.js index 621267b82c..070e9fdbe0 100644 --- a/app/services/billing-accounts/send-customer-change.service.js +++ b/app/services/billing-accounts/send-customer-change.service.js @@ -30,7 +30,7 @@ const ExpandedError = require('../../errors/expanded.error.js') * @param {module:ContactModel} contact - The new contact for the billing account if an FAO was setup by the user during * the change address journey */ -async function go (billingAccount, address, company, contact) { +async function go(billingAccount, address, company, contact) { const requestData = CreateCustomerChangePresenter.go(billingAccount, address, company, contact) const result = await ChargingModuleCreateCustomerChangeRequest.send(requestData) diff --git a/app/services/bills/fetch-bill-service.js b/app/services/bills/fetch-bill-service.js index d53928aeb9..cd7e9b2962 100644 --- a/app/services/bills/fetch-bill-service.js +++ b/app/services/bills/fetch-bill-service.js @@ -18,7 +18,7 @@ const { db } = require('../../../db/db.js') * @returns {Promise} the matching instance of BillModel plus a summary (ID, reference, and total net amount) * for each licence linked to the bill */ -async function go (id) { +async function go(id) { const bill = await _fetchBill(id) const licenceSummaries = await _fetchLicenceSummaries(id) @@ -28,7 +28,7 @@ async function go (id) { } } -async function _fetchBill (id) { +async function _fetchBill(id) { return BillModel.query() .findById(id) .select([ @@ -61,10 +61,7 @@ async function _fetchBill (id) { }) .withGraphFetched('billRun.region') .modifyGraph('billRun.region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) } @@ -83,7 +80,7 @@ async function _fetchBill (id) { * * @private */ -async function _fetchLicenceSummaries (id) { +async function _fetchLicenceSummaries(id) { return db .distinct(['bil.id', 'bil.licenceRef']) .sum('bt.net_amount AS total') diff --git a/app/services/bills/fetch-bill-summary.service.js b/app/services/bills/fetch-bill-summary.service.js index 1689d4552a..7fefac4efa 100644 --- a/app/services/bills/fetch-bill-summary.service.js +++ b/app/services/bills/fetch-bill-summary.service.js @@ -21,30 +21,21 @@ const BillModel = require('../../models/bill.model.js') * @returns {Promise} the matching instance of BillModel plus the linked billing account and bill * run. Also all bill licences linked to the bill so we can display which licences are in the bill */ -async function go (billId) { +async function go(billId) { return _fetch(billId) } -async function _fetch (billId) { +async function _fetch(billId) { return BillModel.query() .findById(billId) - .select([ - 'id', - 'netAmount' - ]) + .select(['id', 'netAmount']) .withGraphFetched('billingAccount') .modifyGraph('billingAccount', (builder) => { builder.modify('contactDetails') }) .withGraphFetched('billLicences') .modifyGraph('billLicences', (builder) => { - builder.select([ - 'id', - 'licenceRef' - ]) - .orderBy([ - { column: 'licenceRef', order: 'asc' } - ]) + builder.select(['id', 'licenceRef']).orderBy([{ column: 'licenceRef', order: 'asc' }]) }) .withGraphFetched('billRun') .modifyGraph('billRun', (builder) => { @@ -61,10 +52,7 @@ async function _fetch (billId) { }) .withGraphFetched('billRun.region') .modifyGraph('billRun.region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) } diff --git a/app/services/bills/remove-bill.service.js b/app/services/bills/remove-bill.service.js index b27443bb1b..b5cdbf3d20 100644 --- a/app/services/bills/remove-bill.service.js +++ b/app/services/bills/remove-bill.service.js @@ -16,7 +16,7 @@ const RemoveBillPresenter = require('../../presenters/bills/remove-bill.presente * @returns {Promise} a formatted representation of the bill, its billing account and the bill run it is linked * to for the remove bill page */ -async function go (billId) { +async function go(billId) { const bill = await FetchBillSummaryService.go(billId) return RemoveBillPresenter.go(bill) diff --git a/app/services/bills/submit-remove-bill.service.js b/app/services/bills/submit-remove-bill.service.js index c7a39f6735..2267eb53fa 100644 --- a/app/services/bills/submit-remove-bill.service.js +++ b/app/services/bills/submit-remove-bill.service.js @@ -16,7 +16,7 @@ const LegacyDeleteBillRequest = require('../../requests/legacy/delete-bill.reque * * @returns {Promise} Returns the redirect path the controller needs */ -async function go (billId, user) { +async function go(billId, user) { const { billRunId } = await _fetchBill(billId) await LegacyDeleteBillRequest.send(billRunId, billId, user) @@ -24,13 +24,8 @@ async function go (billId, user) { return `/billing/batch/${billRunId}/processing` } -async function _fetchBill (billId) { - return BillModel.query() - .findById(billId) - .select([ - 'id', - 'billRunId' - ]) +async function _fetchBill(billId) { + return BillModel.query().findById(billId).select(['id', 'billRunId']) } module.exports = { diff --git a/app/services/bills/view-bill.service.js b/app/services/bills/view-bill.service.js index 84a0cf4c79..6962b4e827 100644 --- a/app/services/bills/view-bill.service.js +++ b/app/services/bills/view-bill.service.js @@ -29,7 +29,7 @@ const ViewLicenceSummariesPresenter = require('../../presenters/bills/view-licen * @returns {Promise} a formatted representation of the bill, its bill run and billing account plus summaries * for all the licences linked to the bill for use in the bill view page */ -async function go (id) { +async function go(id) { const { bill, licenceSummaries } = await FetchBillService.go(id) const billingAccount = await _fetchBillingAccount(bill.billingAccountId) @@ -56,7 +56,7 @@ async function go (id) { } } -async function _fetchBillingAccount (billingAccountId) { +async function _fetchBillingAccount(billingAccountId) { return BillingAccountModel.query().findById(billingAccountId).modify('contactDetails') } diff --git a/app/services/data/deduplicate/de-duplicate-licence.service.js b/app/services/data/deduplicate/de-duplicate-licence.service.js index ae95389dba..c8f852e472 100644 --- a/app/services/data/deduplicate/de-duplicate-licence.service.js +++ b/app/services/data/deduplicate/de-duplicate-licence.service.js @@ -34,7 +34,7 @@ const LicenceModel = require('../../../models/licence.model.js') * * @param {string} licenceRef - Reference for the licence with a duplicate record */ -async function go (licenceRef) { +async function go(licenceRef) { const invalidLicences = await _determineInvalidLicences(licenceRef) // NOTE: In theory there could be more than one 'bad' licence for the matching licence reference! But mainly we do @@ -59,13 +59,8 @@ async function go (licenceRef) { } } -async function _determineInvalidLicences (licenceRef) { - const licences = await LicenceModel.query() - .select([ - 'id', - 'licenceRef' - ]) - .whereILike('licenceRef', `%${licenceRef}%`) +async function _determineInvalidLicences(licenceRef) { + const licences = await LicenceModel.query().select(['id', 'licenceRef']).whereILike('licenceRef', `%${licenceRef}%`) // NOTE: Match any string which has whitespace at the start or the end of the string // ^ asserts position at start of the string @@ -82,90 +77,126 @@ async function _determineInvalidLicences (licenceRef) { return invalidLicences } -async function _documentHeaders (licenceRef) { - return db.raw(` +async function _documentHeaders(licenceRef) { + return db.raw( + ` DELETE FROM crm.document_header WHERE system_external_id = ?; - `, licenceRef) + `, + licenceRef + ) } -async function _documentRoles (licenceRef) { - return db.raw(` +async function _documentRoles(licenceRef) { + return db.raw( + ` DELETE FROM "crm_v2"."document_roles" WHERE document_id IN ( SELECT document_id FROM "crm_v2"."documents" WHERE document_ref = ? ); - `, licenceRef) + `, + licenceRef + ) } -async function _documents (licenceRef) { - return db.raw(` +async function _documents(licenceRef) { + return db.raw( + ` DELETE FROM "crm_v2"."documents" WHERE document_ref = ?; - `, licenceRef) + `, + licenceRef + ) } -async function _licences (licenceId) { - return db.raw(` +async function _licences(licenceId) { + return db.raw( + ` DELETE FROM water.licences WHERE licence_id = ?; - `, licenceId) + `, + licenceId + ) } -async function _licenceVersionPurposeConditions (licenceId) { - return db.raw(` +async function _licenceVersionPurposeConditions(licenceId) { + return db.raw( + ` DELETE FROM water.licence_version_purpose_conditions WHERE licence_version_purpose_id IN ( SELECT licence_version_purpose_id FROM water.licence_version_purposes WHERE licence_version_id IN ( SELECT licence_version_id FROM water.licence_versions WHERE licence_id = ? ) ); - `, licenceId) + `, + licenceId + ) } -async function _licenceVersionPurposes (licenceId) { - return db.raw(` +async function _licenceVersionPurposes(licenceId) { + return db.raw( + ` DELETE FROM water.licence_version_purposes WHERE licence_version_id IN ( SELECT licence_version_id FROM water.licence_versions WHERE licence_id = ? ); - `, licenceId) + `, + licenceId + ) } -async function _licenceVersions (licenceId) { - return db.raw(` +async function _licenceVersions(licenceId) { + return db.raw( + ` DELETE FROM water.licence_versions WHERE licence_id = ?; - `, licenceId) + `, + licenceId + ) } -async function _permitLicences (licenceRef) { - return db.raw(` +async function _permitLicences(licenceRef) { + return db.raw( + ` DELETE FROM permit.licence WHERE licence_ref = ?; - `, licenceRef) + `, + licenceRef + ) } -async function _returnRequirementPurposes (licenceId) { - return db.raw(` +async function _returnRequirementPurposes(licenceId) { + return db.raw( + ` DELETE FROM water.return_requirement_purposes WHERE return_requirement_id IN ( SELECT return_requirement_id FROM water.return_requirements WHERE return_version_id IN ( SELECT return_version_id FROM water.return_versions WHERE licence_id = ? ) ); - `, licenceId) + `, + licenceId + ) } -async function _returnRequirements (licenceId) { - return db.raw(` +async function _returnRequirements(licenceId) { + return db.raw( + ` DELETE FROM water.return_requirements WHERE return_version_id IN ( SELECT return_version_id FROM water.return_versions WHERE licence_id = ? ); - `, licenceId) + `, + licenceId + ) } -async function _returns (licenceRef) { - return db.raw(` +async function _returns(licenceRef) { + return db.raw( + ` DELETE FROM "returns"."returns" WHERE licence_ref = ?; - `, licenceRef) + `, + licenceRef + ) } -async function _returnVersions (licenceId) { - return db.raw(` +async function _returnVersions(licenceId) { + return db.raw( + ` DELETE FROM water.return_versions WHERE licence_id = ?; - `, licenceId) + `, + licenceId + ) } module.exports = { diff --git a/app/services/data/deduplicate/submit-deduplicate.service.js b/app/services/data/deduplicate/submit-deduplicate.service.js index 7e0eed76c2..f603f9e73c 100644 --- a/app/services/data/deduplicate/submit-deduplicate.service.js +++ b/app/services/data/deduplicate/submit-deduplicate.service.js @@ -25,7 +25,7 @@ const DeDuplicateService = require('./de-duplicate-licence.service.js') * @returns {Promise} an object containing a parsed version of the licence reference submitted else an error * message if nothing was entered */ -async function go (payload) { +async function go(payload) { const licenceRef = payload['licence-ref'] if (!licenceRef || licenceRef.trim() === '') { diff --git a/app/services/data/load/load.service.js b/app/services/data/load/load.service.js index 05ffb8cdb9..1b626ca87f 100644 --- a/app/services/data/load/load.service.js +++ b/app/services/data/load/load.service.js @@ -75,33 +75,89 @@ const LOAD_HELPERS = { billRunVolumes: { helper: BillRunVolumeHelper, test: false }, billRuns: { helper: BillRunHelper, test: false }, bills: { helper: BillHelper, test: false }, - billingAccountAddresses: { helper: BillingAccountAddressHelper, test: true, legacy: { schema: 'crm_v2', table: 'invoice_account_addresses', id: 'invoice_account_address_id' } }, - billingAccounts: { helper: BillingAccountHelper, test: true, legacy: { schema: 'crm_v2', table: 'invoice_accounts', id: 'invoice_account_id' } }, + billingAccountAddresses: { + helper: BillingAccountAddressHelper, + test: true, + legacy: { schema: 'crm_v2', table: 'invoice_account_addresses', id: 'invoice_account_address_id' } + }, + billingAccounts: { + helper: BillingAccountHelper, + test: true, + legacy: { schema: 'crm_v2', table: 'invoice_accounts', id: 'invoice_account_id' } + }, changeReasons: { helper: ChangeReasonHelper, test: false }, - chargeElements: { helper: ChargeElementHelper, test: true, legacy: { schema: 'water', table: 'charge_purposes', id: 'charge_purpose_id' } }, - chargeReferences: { helper: ChargeReferenceHelper, test: true, legacy: { schema: 'water', table: 'charge_elements', id: 'charge_element_id' } }, - chargeVersions: { helper: ChargeVersionHelper, test: true, legacy: { schema: 'water', table: 'charge_versions', id: 'charge_version_id' } }, - companyAddresses: { helper: CompanyAddressHelper, test: true, legacy: { schema: 'crm_v2', table: 'company_addresses', id: 'company_address_id' } }, - companyContacts: { helper: CompanyContactHelper, test: true, legacy: { schema: 'crm_v2', table: 'company_contacts', id: 'company_contact_id' } }, + chargeElements: { + helper: ChargeElementHelper, + test: true, + legacy: { schema: 'water', table: 'charge_purposes', id: 'charge_purpose_id' } + }, + chargeReferences: { + helper: ChargeReferenceHelper, + test: true, + legacy: { schema: 'water', table: 'charge_elements', id: 'charge_element_id' } + }, + chargeVersions: { + helper: ChargeVersionHelper, + test: true, + legacy: { schema: 'water', table: 'charge_versions', id: 'charge_version_id' } + }, + companyAddresses: { + helper: CompanyAddressHelper, + test: true, + legacy: { schema: 'crm_v2', table: 'company_addresses', id: 'company_address_id' } + }, + companyContacts: { + helper: CompanyContactHelper, + test: true, + legacy: { schema: 'crm_v2', table: 'company_contacts', id: 'company_contact_id' } + }, companies: { helper: CompanyHelper, test: true, legacy: { schema: 'crm_v2', table: 'companies', id: 'company_id' } }, contacts: { helper: ContactHelper, test: true, legacy: { schema: 'crm_v2', table: 'contacts', id: 'contact_id' } }, events: { helper: EventHelper, test: false }, - licenceAgreements: { helper: LicenceAgreementHelper, test: true, legacy: { schema: 'water', table: 'licence_agreements', id: 'licence_agreement_id' } }, + licenceAgreements: { + helper: LicenceAgreementHelper, + test: true, + legacy: { schema: 'water', table: 'licence_agreements', id: 'licence_agreement_id' } + }, licenceDocumentHeaders: { helper: LicenceDocumentHeaderHelper, test: false }, - licenceDocumentRoles: { helper: LicenceDocumentRoleHelper, test: true, legacy: { schema: 'crm_v2', table: 'document_roles', id: 'document_role_id' } }, - licenceDocuments: { helper: LicenceDocumentHelper, test: true, legacy: { schema: 'crm_v2', table: 'documents', id: 'document_id' } }, + licenceDocumentRoles: { + helper: LicenceDocumentRoleHelper, + test: true, + legacy: { schema: 'crm_v2', table: 'document_roles', id: 'document_role_id' } + }, + licenceDocuments: { + helper: LicenceDocumentHelper, + test: true, + legacy: { schema: 'crm_v2', table: 'documents', id: 'document_id' } + }, licenceEntityRoles: { helper: LicenceEntityRoleHelper, test: false }, licenceEntities: { helper: LicenceEntityHelper, test: false }, - licenceMonitoringStations: { helper: LicenceMonitoringStationHelper, test: true, legacy: { schema: 'water', table: 'licence_gauging_stations', id: 'licence_gauging_station_id' } }, + licenceMonitoringStations: { + helper: LicenceMonitoringStationHelper, + test: true, + legacy: { schema: 'water', table: 'licence_gauging_stations', id: 'licence_gauging_station_id' } + }, licenceRoles: { helper: LicenceRoleHelper, test: false }, LicenceSupplementaryYears: { helper: LicenceSupplementaryYearHelper, test: false }, licenceVersionPurposeConditions: { helper: LicenceVersionPurposeConditionHelper, test: false }, - licenceVersionPurposes: { helper: LicenceVersionPurposeHelper, test: true, legacy: { schema: 'water', table: 'licence_version_purposes', id: 'licence_version_purpose_id' } }, + licenceVersionPurposes: { + helper: LicenceVersionPurposeHelper, + test: true, + legacy: { schema: 'water', table: 'licence_version_purposes', id: 'licence_version_purpose_id' } + }, licenceVersionPurposePoints: { helper: LicenceVersionPurposePointHelper, test: false }, - licenceVersions: { helper: LicenceVersionHelper, test: true, legacy: { schema: 'water', table: 'licence_versions', id: 'licence_version_id' } }, + licenceVersions: { + helper: LicenceVersionHelper, + test: true, + legacy: { schema: 'water', table: 'licence_versions', id: 'licence_version_id' } + }, licences: { helper: LicenceHelper, test: true, legacy: { schema: 'water', table: 'licences', id: 'licence_id' } }, modLogs: { helper: ModLogHelper, test: false }, - monitoringStations: { helper: MonitoringStationHelper, test: true, legacy: { schema: 'water', table: 'gauging_stations', id: 'gauging_station_id' } }, + monitoringStations: { + helper: MonitoringStationHelper, + test: true, + legacy: { schema: 'water', table: 'gauging_stations', id: 'gauging_station_id' } + }, points: { helper: PointHelper, test: false }, permitLicences: { helper: PermitLicenceHelper, test: false }, returnLogs: { helper: ReturnLogHelper, test: true, legacy: { schema: 'returns', table: 'returns', id: 'return_id' } }, @@ -210,7 +266,7 @@ const LOAD_HELPERS = { * } * ``` */ -async function go (payload) { +async function go(payload) { // Instantiate a result object to which we'll record the ID's generated/used const result = {} @@ -279,7 +335,7 @@ async function go (payload) { * * @private */ -async function _applyLookups (instance) { +async function _applyLookups(instance) { const keys = Object.keys(instance) for (const key of keys) { @@ -309,13 +365,13 @@ async function _applyLookups (instance) { * * @private */ -async function _applyTestFlag (legacy, id) { +async function _applyTestFlag(legacy, id) { const { schema, table, id: tableId } = legacy return db(table).withSchema(schema).update('is_test', true).where(tableId, id) } -function _helper (entityKey) { +function _helper(entityKey) { const loadHelper = LOAD_HELPERS[entityKey] if (!loadHelper) { @@ -325,12 +381,8 @@ function _helper (entityKey) { return loadHelper } -async function _selector (schema, table, select, where, value) { - const result = await db - .withSchema(schema) - .first(select) - .from(table) - .where(where, value) +async function _selector(schema, table, select, where, value) { + const result = await db.withSchema(schema).first(select).from(table).where(where, value) return result[select] } diff --git a/app/services/data/seed/seed.service.js b/app/services/data/seed/seed.service.js index fcb377d525..479433368e 100644 --- a/app/services/data/seed/seed.service.js +++ b/app/services/data/seed/seed.service.js @@ -19,7 +19,7 @@ const { db } = require('../../../../db/db.js') * * Credit to {@link https://stackoverflow.com/a/53169879 | Programmatically run knex seed:run} */ -async function go () { +async function go() { await db.seed.run() } diff --git a/app/services/data/tear-down/README.md b/app/services/data/tear-down/README.md index ee496013a1..b3e948f525 100644 --- a/app/services/data/tear-down/README.md +++ b/app/services/data/tear-down/README.md @@ -87,7 +87,7 @@ Again, this confirmed disabling the table triggers still had a massive impact on > The average times are in milliseconds. Just divide by 1000 for secs, for example, 1770 / 1000 = 1.7 secs | Schema | No change | Just triggers | Single Query | Promise all | Best of | All in one | -|---------|-----------|---------------|--------------|-------------|---------|------------| +| ------- | --------- | ------------- | ------------ | ----------- | ------- | ---------- | | CRM | 1770 | 2106 | **1185** | 964 | 1444 | N/A | | IDM | 58 | 73 | **46** | 852 | 1199 | N/A | | PERMIT | 165 | 266 | **156** | 893 | 1282 | N/A | diff --git a/app/services/data/tear-down/crm-schema.service.js b/app/services/data/tear-down/crm-schema.service.js index 0736423e27..73e5662b9b 100644 --- a/app/services/data/tear-down/crm-schema.service.js +++ b/app/services/data/tear-down/crm-schema.service.js @@ -12,11 +12,11 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go () { +async function go() { return _deleteAllTestData() } -async function _deleteAllTestData () { +async function _deleteAllTestData() { return db.raw(` ALTER TABLE crm.document_header DISABLE TRIGGER ALL; ALTER TABLE crm_v2.addresses DISABLE TRIGGER ALL; diff --git a/app/services/data/tear-down/idm-schema.service.js b/app/services/data/tear-down/idm-schema.service.js index 106b8d28d3..a4b0457ac5 100644 --- a/app/services/data/tear-down/idm-schema.service.js +++ b/app/services/data/tear-down/idm-schema.service.js @@ -12,11 +12,11 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go () { +async function go() { return _deleteAllTestData() } -async function _deleteAllTestData () { +async function _deleteAllTestData() { return db.raw(` DELETE FROM diff --git a/app/services/data/tear-down/permit-schema.service.js b/app/services/data/tear-down/permit-schema.service.js index d748362502..f6ce5aa345 100644 --- a/app/services/data/tear-down/permit-schema.service.js +++ b/app/services/data/tear-down/permit-schema.service.js @@ -12,11 +12,11 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go () { +async function go() { return _deleteAllTestData() } -async function _deleteAllTestData () { +async function _deleteAllTestData() { return db.raw(` ALTER TABLE permit.licence DISABLE TRIGGER ALL; diff --git a/app/services/data/tear-down/returns-schema.service.js b/app/services/data/tear-down/returns-schema.service.js index 88dfa88784..21c8531d63 100644 --- a/app/services/data/tear-down/returns-schema.service.js +++ b/app/services/data/tear-down/returns-schema.service.js @@ -12,11 +12,11 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go () { +async function go() { return _deleteAllTestData() } -async function _deleteAllTestData () { +async function _deleteAllTestData() { return db.raw(` ALTER TABLE returns.lines DISABLE TRIGGER ALL; ALTER TABLE returns.versions DISABLE TRIGGER ALL; diff --git a/app/services/data/tear-down/tear-down.service.js b/app/services/data/tear-down/tear-down.service.js index caf4a672d7..4dc78480eb 100644 --- a/app/services/data/tear-down/tear-down.service.js +++ b/app/services/data/tear-down/tear-down.service.js @@ -15,7 +15,7 @@ const WaterSchemaService = require('./water-schema.service.js') /** * Removes all data created for acceptance tests */ -async function go () { +async function go() { const startTime = currentTimeInNanoseconds() await Promise.all([ diff --git a/app/services/data/tear-down/water-schema.service.js b/app/services/data/tear-down/water-schema.service.js index 70fb2fca24..68ab8be738 100644 --- a/app/services/data/tear-down/water-schema.service.js +++ b/app/services/data/tear-down/water-schema.service.js @@ -12,11 +12,11 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go () { +async function go() { return _deleteAllTestData() } -async function _deleteAllTestData () { +async function _deleteAllTestData() { return db.raw(` ALTER TABLE water.billing_batch_charge_version_years DISABLE TRIGGER ALL; ALTER TABLE water.billing_batches DISABLE TRIGGER ALL; diff --git a/app/services/health/create-redis-client.service.js b/app/services/health/create-redis-client.service.js index fadad3f2a4..51125d6c76 100644 --- a/app/services/health/create-redis-client.service.js +++ b/app/services/health/create-redis-client.service.js @@ -14,7 +14,7 @@ const redisConfig = require('../../../config/redis.config.js') * * @returns {Promise} - a new redis instance */ -async function go () { +async function go() { return new Redis({ host: redisConfig.host, port: redisConfig.port, diff --git a/app/services/health/database-health-check.service.js b/app/services/health/database-health-check.service.js index cdbc4f916e..31f9541919 100644 --- a/app/services/health/database-health-check.service.js +++ b/app/services/health/database-health-check.service.js @@ -18,7 +18,7 @@ const { db } = require('../../../db/db.js') * * @returns an array of stats for each table found in the db */ -async function go () { +async function go() { const stats = db.select().table('pg_stat_user_tables') return stats diff --git a/app/services/health/fetch-system-info.service.js b/app/services/health/fetch-system-info.service.js index ab662a38de..215bd607fb 100644 --- a/app/services/health/fetch-system-info.service.js +++ b/app/services/health/fetch-system-info.service.js @@ -14,7 +14,7 @@ const exec = util.promisify(require('child_process').exec) * * @returns {Promise} An object containing the `name`, `serviceName`, `version`, `commit` & `jobs` */ -async function go () { +async function go() { return { name: 'System', serviceName: 'system', @@ -24,7 +24,7 @@ async function go () { } } -async function _getCommitHash () { +async function _getCommitHash() { try { const { stdout, stderr } = await exec('git rev-parse HEAD') @@ -34,7 +34,7 @@ async function _getCommitHash () { } } -async function _getTagReference () { +async function _getTagReference() { try { const { stdout, stderr } = await exec('git describe --always --tags') diff --git a/app/services/health/info.service.js b/app/services/health/info.service.js index 8f6090c0ac..4cc11a74c8 100644 --- a/app/services/health/info.service.js +++ b/app/services/health/info.service.js @@ -29,7 +29,7 @@ const servicesConfig = require('../../../config/services.config.js') * * @returns {object} data about each service formatted for the view */ -async function go () { +async function go() { const addressFacadeData = await _getAddressFacadeData() const chargingModuleData = await _getChargingModuleData() const legacyAppData = await _getLegacyAppData() @@ -47,13 +47,13 @@ async function go () { } } -async function _addSystemInfoToLegacyAppData (appData) { +async function _addSystemInfoToLegacyAppData(appData) { const systemInfo = await FetchSystemInfoService.go() return [...appData, systemInfo] } -async function _getAddressFacadeData () { +async function _getAddressFacadeData() { const statusUrl = new URL('/address-service/hola', servicesConfig.addressFacade.url) const result = await BaseRequest.get(statusUrl.href) @@ -64,7 +64,7 @@ async function _getAddressFacadeData () { return _parseFailedRequestResult(result) } -async function _getLegacyAppData () { +async function _getLegacyAppData() { const healthInfoPath = 'health/info' const services = [ @@ -94,7 +94,7 @@ async function _getLegacyAppData () { return services } -async function _getChargingModuleData () { +async function _getChargingModuleData() { const result = await ChargingModuleRequest.get('status') if (result.succeeded) { @@ -104,7 +104,7 @@ async function _getChargingModuleData () { return _parseFailedRequestResult(result) } -async function _getRedisConnectivityData () { +async function _getRedisConnectivityData() { let redis try { @@ -122,7 +122,7 @@ async function _getRedisConnectivityData () { } } -async function _getVirusScannerData () { +async function _getVirusScannerData() { try { const { stdout, stderr } = await exec('clamdscan --version') @@ -132,7 +132,7 @@ async function _getVirusScannerData () { } } -function _parseFailedRequestResult (result) { +function _parseFailedRequestResult(result) { if (result.response.statusCode) { return `ERROR: ${result.response.statusCode} - ${result.response.body}` } diff --git a/app/services/idm/fetch-user-roles-and-groups.service.js b/app/services/idm/fetch-user-roles-and-groups.service.js index 3bb2ebb0e2..1140114003 100644 --- a/app/services/idm/fetch-user-roles-and-groups.service.js +++ b/app/services/idm/fetch-user-roles-and-groups.service.js @@ -22,10 +22,8 @@ const UserModel = require('../../models/user.model.js') * * @returns {Promise} returns an object containing the matching `UserModel` and an array of its roles and groups */ -async function go (userId) { - const user = await UserModel.query() - .findById(userId) - .withGraphFetched('[roles, groups.roles]') +async function go(userId) { + const user = await UserModel.query().findById(userId).withGraphFetched('[roles, groups.roles]') if (!user) { return { @@ -53,7 +51,7 @@ async function go (userId) { * * @private */ -function _extractRolesAndGroupsFromUser (user) { +function _extractRolesAndGroupsFromUser(user) { const { roles, groups } = user delete user.roles @@ -70,7 +68,7 @@ function _extractRolesAndGroupsFromUser (user) { * * @private */ -function _extractRolesFromGroups (groups) { +function _extractRolesFromGroups(groups) { return groups.flatMap((group) => { const { roles } = group @@ -80,7 +78,7 @@ function _extractRolesFromGroups (groups) { }) } -function _combineAndDedupeRoles (rolesArrayToDedupe) { +function _combineAndDedupeRoles(rolesArrayToDedupe) { // Our usual method of de-duping arrays (putting the array into a new Set and then spreading it back into an array) // doesn't work here as the Role objects are not considered to be equal when doing this. We therefore use reduce to // dedupe by going through each Role object in the original array and only adding it to the accumulated results array diff --git a/app/services/import/determine-supplementary-billing-flags.service.js b/app/services/import/determine-supplementary-billing-flags.service.js index ed438a3edf..e71bfca93d 100644 --- a/app/services/import/determine-supplementary-billing-flags.service.js +++ b/app/services/import/determine-supplementary-billing-flags.service.js @@ -20,7 +20,7 @@ const ProcessImportedLicenceService = require('../licences/supplementary/process * @param {object} importedLicence - The imported licence * @param {string} licenceId - The UUID of the licence being updated by the import */ -async function go (importedLicence, licenceId) { +async function go(importedLicence, licenceId) { try { const licenceChanged = await _licenceChanged(importedLicence, licenceId) @@ -32,10 +32,8 @@ async function go (importedLicence, licenceId) { } } -async function _licenceChanged (importedLicence, licenceId) { - const query = LicenceModel.query() - .select(['id']) - .where('id', licenceId) +async function _licenceChanged(importedLicence, licenceId) { + const query = LicenceModel.query().select(['id']).where('id', licenceId) _whereClauses(query, importedLicence) @@ -60,7 +58,7 @@ async function _licenceChanged (importedLicence, licenceId) { * * @private */ -function _whereClauses (query, importedLicence) { +function _whereClauses(query, importedLicence) { const { expiredDate, lapsedDate, revokedDate } = importedLicence if (expiredDate) { diff --git a/app/services/import/legacy/fetch-address.service.js b/app/services/import/legacy/fetch-address.service.js index 38cc805c32..5fc150a677 100644 --- a/app/services/import/legacy/fetch-address.service.js +++ b/app/services/import/legacy/fetch-address.service.js @@ -15,7 +15,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const query = _query() const { rows } = await db.raw(query, [regionCode, licenceId, licenceId]) @@ -23,7 +23,7 @@ async function go (regionCode, licenceId) { return rows } -function _query () { +function _query() { return ` SELECT DISTINCT ON (external_id) ( diff --git a/app/services/import/legacy/fetch-company-address.service.js b/app/services/import/legacy/fetch-company-address.service.js index 61fa003cc0..de8a5ac779 100644 --- a/app/services/import/legacy/fetch-company-address.service.js +++ b/app/services/import/legacy/fetch-company-address.service.js @@ -17,7 +17,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const licenceHolderData = await _getLicenceHolder(regionCode, licenceId) const returnsToData = await _getReturnsTo(regionCode, licenceId) @@ -29,7 +29,7 @@ async function go (regionCode, licenceId) { * * @private */ -async function _getLicenceHolder (regionCode, licenceId) { +async function _getLicenceHolder(regionCode, licenceId) { const query = ` WITH end_date_cte AS ( SELECT @@ -78,7 +78,7 @@ async function _getLicenceHolder (regionCode, licenceId) { * * @private */ -async function _getReturnsTo (regionCode, licenceId) { +async function _getReturnsTo(regionCode, licenceId) { const query = ` SELECT CASE diff --git a/app/services/import/legacy/fetch-company.service.js b/app/services/import/legacy/fetch-company.service.js index 3f1a278dff..9e73ca93f5 100644 --- a/app/services/import/legacy/fetch-company.service.js +++ b/app/services/import/legacy/fetch-company.service.js @@ -17,7 +17,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const query = _query() const { rows } = await db.raw(query, [regionCode, licenceId, regionCode, licenceId]) @@ -25,7 +25,7 @@ async function go (regionCode, licenceId) { return rows } -function _query () { +function _query() { return ` SELECT DISTINCT ON (np."ID") (concat_ws(':', np."FGAC_REGION_CODE", np."ID")) AS external_id, diff --git a/app/services/import/legacy/fetch-contacts.service.js b/app/services/import/legacy/fetch-contacts.service.js index a43a6a5406..44c513fff9 100644 --- a/app/services/import/legacy/fetch-contacts.service.js +++ b/app/services/import/legacy/fetch-contacts.service.js @@ -17,7 +17,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const query = _query() const { rows } = await db.raw(query, [regionCode, licenceId]) @@ -25,7 +25,7 @@ async function go (regionCode, licenceId) { return rows } -function _query () { +function _query() { return ` SELECT DISTINCT ON (np."ID") to_date(nalv."EFF_ST_DATE", 'DD/MM/YYYY') as start_date, diff --git a/app/services/import/legacy/fetch-licence-document-roles.service.js b/app/services/import/legacy/fetch-licence-document-roles.service.js index c6296c537f..1b051070f0 100644 --- a/app/services/import/legacy/fetch-licence-document-roles.service.js +++ b/app/services/import/legacy/fetch-licence-document-roles.service.js @@ -19,14 +19,14 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const returnsToData = await _getReturnsTo(regionCode, licenceId) const licenceHolderData = await _getLicenceHolder(regionCode, licenceId) return [...returnsToData, ...licenceHolderData] } -async function _getReturnsTo (regionCode, licenceId) { +async function _getReturnsTo(regionCode, licenceId) { const query = ` SELECT lr.id as licence_role_id, @@ -57,7 +57,7 @@ async function _getReturnsTo (regionCode, licenceId) { return rows } -async function _getLicenceHolder (regionCode, licenceId) { +async function _getLicenceHolder(regionCode, licenceId) { const query = ` SELECT DISTINCT ON (start_date, nalv."ISSUE_NO") lr.id as licence_role_id, diff --git a/app/services/import/legacy/fetch-licence-document.service.js b/app/services/import/legacy/fetch-licence-document.service.js index 822d93c0d5..7500b30583 100644 --- a/app/services/import/legacy/fetch-licence-document.service.js +++ b/app/services/import/legacy/fetch-licence-document.service.js @@ -15,15 +15,17 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const query = _query() - const { rows: [row] } = await db.raw(query, [regionCode, licenceId]) + const { + rows: [row] + } = await db.raw(query, [regionCode, licenceId]) return row } -function _query () { +function _query() { return ` SELECT CASE diff --git a/app/services/import/legacy/fetch-licence-version-purpose-conditions.service.js b/app/services/import/legacy/fetch-licence-version-purpose-conditions.service.js index 5be5f3f4af..0c11f70c7e 100644 --- a/app/services/import/legacy/fetch-licence-version-purpose-conditions.service.js +++ b/app/services/import/legacy/fetch-licence-version-purpose-conditions.service.js @@ -17,7 +17,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const query = _query() const { rows } = await db.raw(query, [regionCode, licenceId]) @@ -25,7 +25,7 @@ async function go (regionCode, licenceId) { return rows } -function _query () { +function _query() { return ` SELECT nalc."ACIN_CODE" AS code, diff --git a/app/services/import/legacy/fetch-licence-version-purposes.service.js b/app/services/import/legacy/fetch-licence-version-purposes.service.js index 516cdfe604..cb4c3b0eec 100644 --- a/app/services/import/legacy/fetch-licence-version-purposes.service.js +++ b/app/services/import/legacy/fetch-licence-version-purposes.service.js @@ -15,7 +15,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const query = _query() const { rows } = await db.raw(query, [regionCode, licenceId]) @@ -23,7 +23,7 @@ async function go (regionCode, licenceId) { return rows } -function _query () { +function _query() { return ` SELECT (nalp."PERIOD_END_DAY")::INTEGER AS abstraction_period_end_day, diff --git a/app/services/import/legacy/fetch-licence-versions.service.js b/app/services/import/legacy/fetch-licence-versions.service.js index 8ebaeda4e7..633a95a5e1 100644 --- a/app/services/import/legacy/fetch-licence-versions.service.js +++ b/app/services/import/legacy/fetch-licence-versions.service.js @@ -15,7 +15,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const query = _query() const { rows } = await db.raw(query, [regionCode, licenceId]) @@ -23,7 +23,7 @@ async function go (regionCode, licenceId) { return rows } -function _query () { +function _query() { return ` SELECT ( diff --git a/app/services/import/legacy/fetch-licence.service.js b/app/services/import/legacy/fetch-licence.service.js index a8cb2e82d9..1a4ebd2d41 100644 --- a/app/services/import/legacy/fetch-licence.service.js +++ b/app/services/import/legacy/fetch-licence.service.js @@ -14,15 +14,17 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} */ -async function go (licenceRef) { +async function go(licenceRef) { const query = _query() - const { rows: [row] } = await db.raw(query, [licenceRef]) + const { + rows: [row] + } = await db.raw(query, [licenceRef]) return row } -function _query () { +function _query() { return ` SELECT nal."AREP_AREA_CODE" AS historical_area_code, diff --git a/app/services/import/legacy/process-licence.service.js b/app/services/import/legacy/process-licence.service.js index 81b3321d41..ee591c84b6 100644 --- a/app/services/import/legacy/process-licence.service.js +++ b/app/services/import/legacy/process-licence.service.js @@ -28,7 +28,7 @@ const { currentTimeInNanoseconds, calculateAndLogTimeTaken } = require('../../.. * * @returns {Promise} an object representing the saved licence in the database */ -async function go (licenceRef) { +async function go(licenceRef) { try { const startTime = currentTimeInNanoseconds() diff --git a/app/services/import/legacy/transform-addresses.service.js b/app/services/import/legacy/transform-addresses.service.js index af731697c4..d486ef455a 100644 --- a/app/services/import/legacy/transform-addresses.service.js +++ b/app/services/import/legacy/transform-addresses.service.js @@ -19,7 +19,7 @@ const ImportAddressValidator = require('../../../validators/import/address.valid * @param {object[]} transformedCompanies * */ -async function go (regionCode, licenceId, transformedCompanies) { +async function go(regionCode, licenceId, transformedCompanies) { const naldAddresses = await FetchAddressesService.go(regionCode, licenceId) naldAddresses.forEach((naldAddress) => { @@ -33,7 +33,7 @@ async function go (regionCode, licenceId, transformedCompanies) { }) } -function _matchingCompany (transformedCompanies, naldAddress) { +function _matchingCompany(transformedCompanies, naldAddress) { return transformedCompanies.find((company) => { return company.externalId === naldAddress.company_external_id }) diff --git a/app/services/import/legacy/transform-companies.service.js b/app/services/import/legacy/transform-companies.service.js index c9e43d3125..1290dddcd3 100644 --- a/app/services/import/legacy/transform-companies.service.js +++ b/app/services/import/legacy/transform-companies.service.js @@ -18,7 +18,7 @@ const ImportCompanyValidator = require('../../../validators/import/company.valid * @returns {Promise} an object representing an array of valid WRLS transformed companies and * an array of companies from the db */ -async function go (regionCode, licenceId) { +async function go(regionCode, licenceId) { const companies = await FetchCompanyService.go(regionCode, licenceId) const transformedCompanies = [] diff --git a/app/services/import/legacy/transform-company-addresses.service.js b/app/services/import/legacy/transform-company-addresses.service.js index 0960f8ef19..2c97bdff16 100644 --- a/app/services/import/legacy/transform-company-addresses.service.js +++ b/app/services/import/legacy/transform-company-addresses.service.js @@ -16,7 +16,7 @@ const FetchCompanyAddressesService = require('./fetch-company-address.service.js * @param {object[]} transformedCompanies * */ -async function go (regionCode, licenceId, transformedCompanies) { +async function go(regionCode, licenceId, transformedCompanies) { const naldAddresses = await FetchCompanyAddressesService.go(regionCode, licenceId) naldAddresses.forEach((naldAddress) => { @@ -28,7 +28,7 @@ async function go (regionCode, licenceId, transformedCompanies) { }) } -function _matchingCompany (transformedCompanies, naldAddress) { +function _matchingCompany(transformedCompanies, naldAddress) { return transformedCompanies.find((company) => { return company.externalId === naldAddress.company_external_id }) diff --git a/app/services/import/legacy/transform-contacts.service.js b/app/services/import/legacy/transform-contacts.service.js index 60e3a17260..10acc89f7f 100644 --- a/app/services/import/legacy/transform-contacts.service.js +++ b/app/services/import/legacy/transform-contacts.service.js @@ -18,7 +18,7 @@ const ImportContactValidator = require('../../../validators/import/contact.valid * @param {object[]} transformedCompanies * */ -async function go (regionCode, licenceId, transformedCompanies) { +async function go(regionCode, licenceId, transformedCompanies) { const naldContacts = await FetchContactsService.go(regionCode, licenceId) naldContacts.forEach((naldContact) => { @@ -34,7 +34,7 @@ async function go (regionCode, licenceId, transformedCompanies) { }) } -function _matchingCompany (transformedCompanies, naldContact) { +function _matchingCompany(transformedCompanies, naldContact) { return transformedCompanies.find((company) => { return company.externalId === naldContact.external_id }) diff --git a/app/services/import/legacy/transform-licence-document-roles.service.js b/app/services/import/legacy/transform-licence-document-roles.service.js index 1db600a3a3..c446cbf4b4 100644 --- a/app/services/import/legacy/transform-licence-document-roles.service.js +++ b/app/services/import/legacy/transform-licence-document-roles.service.js @@ -20,7 +20,7 @@ const LicenceDocumentRolePresenter = require('../../../presenters/import/legacy/ * @param licenceRef * */ -async function go (regionCode, naldLicenceId, transformedLicence, licenceRef) { +async function go(regionCode, naldLicenceId, transformedLicence, licenceRef) { const naldLicenceDocumentRoles = await FetchLicenceDocumentRolesService.go(regionCode, naldLicenceId) for (const licenceDocumentRole of naldLicenceDocumentRoles) { diff --git a/app/services/import/legacy/transform-licence-document.service.js b/app/services/import/legacy/transform-licence-document.service.js index ec404b597a..b82468f544 100644 --- a/app/services/import/legacy/transform-licence-document.service.js +++ b/app/services/import/legacy/transform-licence-document.service.js @@ -20,7 +20,7 @@ const LicenceDocumentValidator = require('../../../validators/import/licence-doc * @param {string} naldLicenceId - The NALD ID for the licence being imported * @param {object} transformedLicence - An object representing a valid WRLS licence */ -async function go (regionCode, naldLicenceId, transformedLicence) { +async function go(regionCode, naldLicenceId, transformedLicence) { const naldLicenceDocument = await FetchLicenceDocumentService.go(regionCode, naldLicenceId) const transformedLicenceDocument = LicenceDocumentPresenter.go(naldLicenceDocument) diff --git a/app/services/import/legacy/transform-licence-version-purpose-conditions.service.js b/app/services/import/legacy/transform-licence-version-purpose-conditions.service.js index c2a168c0a8..b259f95f37 100644 --- a/app/services/import/legacy/transform-licence-version-purpose-conditions.service.js +++ b/app/services/import/legacy/transform-licence-version-purpose-conditions.service.js @@ -19,7 +19,7 @@ const LicenceVersionPurposeConditionPresenter = require('../../../presenters/imp * @param {string} naldLicenceId - The NALD ID for the licence being imported * @param {object} transformedLicence - An object representing a valid WRLS licence */ -async function go (regionCode, naldLicenceId, transformedLicence) { +async function go(regionCode, naldLicenceId, transformedLicence) { const naldLicenceVersionPurposeConditions = await FetchLicenceVersionPurposeConditionsService.go( regionCode, naldLicenceId @@ -27,7 +27,8 @@ async function go (regionCode, naldLicenceId, transformedLicence) { for (const naldLicenceVersionPurposeCondition of naldLicenceVersionPurposeConditions) { const matchingLicenceVersionPurpose = _matchingLicenceVersionPurpose( - transformedLicence.licenceVersions, naldLicenceVersionPurposeCondition + transformedLicence.licenceVersions, + naldLicenceVersionPurposeCondition ) const transformedLicenceVersionPurposeCondition = LicenceVersionPurposeConditionPresenter.go( @@ -40,7 +41,7 @@ async function go (regionCode, naldLicenceId, transformedLicence) { } } -function _matchingLicenceVersionPurpose (licenceVersions, naldLicenceVersionPurposesCondition) { +function _matchingLicenceVersionPurpose(licenceVersions, naldLicenceVersionPurposesCondition) { let matchedLicenceVersionPurpose // Because the licence version purpose we need to match is against a licence version, we need to iterate through them diff --git a/app/services/import/legacy/transform-licence-version-purposes.service.js b/app/services/import/legacy/transform-licence-version-purposes.service.js index 8a854d15f2..f0fa5ffaf3 100644 --- a/app/services/import/legacy/transform-licence-version-purposes.service.js +++ b/app/services/import/legacy/transform-licence-version-purposes.service.js @@ -19,12 +19,13 @@ const LicenceVersionPurposeValidator = require('../../../validators/import/licen * @param {string} naldLicenceId - The NALD ID for the licence being imported * @param {object} transformedLicence - An object representing a valid WRLS licence */ -async function go (regionCode, naldLicenceId, transformedLicence) { +async function go(regionCode, naldLicenceId, transformedLicence) { const naldLicenceVersionPurposes = await FetchLicenceVersionPurposesService.go(regionCode, naldLicenceId) naldLicenceVersionPurposes.forEach((naldLicenceVersionPurpose) => { const matchingLicenceVersion = _matchingLicenceVersion( - transformedLicence.licenceVersions, naldLicenceVersionPurpose + transformedLicence.licenceVersions, + naldLicenceVersionPurpose ) const transformedLicenceVersionPurpose = LicenceVersionPurposePresenter.go(naldLicenceVersionPurpose) @@ -35,7 +36,7 @@ async function go (regionCode, naldLicenceId, transformedLicence) { }) } -function _matchingLicenceVersion (licenceVersions, naldLicenceVersionPurpose) { +function _matchingLicenceVersion(licenceVersions, naldLicenceVersionPurpose) { return licenceVersions.find((licenceVersion) => { return licenceVersion.externalId === naldLicenceVersionPurpose.version_external_id }) diff --git a/app/services/import/legacy/transform-licence-versions.service.js b/app/services/import/legacy/transform-licence-versions.service.js index 8e139b0c93..3bd12833c6 100644 --- a/app/services/import/legacy/transform-licence-versions.service.js +++ b/app/services/import/legacy/transform-licence-versions.service.js @@ -18,7 +18,7 @@ const LicenceVersionValidator = require('../../../validators/import/licence-vers * @param {string} naldLicenceId - The NALD ID for the licence being imported * @param {object} transformedLicence - An object representing a valid WRLS licence */ -async function go (regionCode, naldLicenceId, transformedLicence) { +async function go(regionCode, naldLicenceId, transformedLicence) { const naldLicenceVersions = await FetchLicenceVersionsService.go(regionCode, naldLicenceId) naldLicenceVersions.forEach((naldLicenceVersion) => { diff --git a/app/services/import/legacy/transform-licence.service.js b/app/services/import/legacy/transform-licence.service.js index 752a375d30..e44b9b38db 100644 --- a/app/services/import/legacy/transform-licence.service.js +++ b/app/services/import/legacy/transform-licence.service.js @@ -16,7 +16,7 @@ const LicenceValidator = require('../../../validators/import/licence.validator.j * * @returns {Promise} an object representing a valid WRLS licence */ -async function go (licenceRef) { +async function go(licenceRef) { const naldLicence = await FetchLicenceService.go(licenceRef) const transformedLicence = LicencePresenter.go(naldLicence) diff --git a/app/services/import/persist-import.service.js b/app/services/import/persist-import.service.js index 6f6407c758..e6f51b8c47 100644 --- a/app/services/import/persist-import.service.js +++ b/app/services/import/persist-import.service.js @@ -20,7 +20,7 @@ const { timestampForPostgres } = require('../../lib/general.lib.js') * * @returns {Promise} */ -async function go (transformedLicence, transformedCompanies) { +async function go(transformedLicence, transformedCompanies) { return LicenceModel.transaction(async (trx) => { const updatedAt = timestampForPostgres() diff --git a/app/services/import/persist/persist-company.service.js b/app/services/import/persist/persist-company.service.js index a4a8d0dd0b..bd4a7d2e83 100644 --- a/app/services/import/persist/persist-company.service.js +++ b/app/services/import/persist/persist-company.service.js @@ -17,34 +17,24 @@ const { db } = require('../../../../db/db.js') * @param {string} updatedAt - The timestamp indicating when the entity was last updated. * @param {object} transformedCompanies - An object representing a valid WRLS Company. */ -async function go (trx, updatedAt, transformedCompanies) { +async function go(trx, updatedAt, transformedCompanies) { await _persistCompanies(trx, updatedAt, transformedCompanies) } -async function _persistAddress (trx, updatedAt, address) { +async function _persistAddress(trx, updatedAt, address) { await AddressModel.query(trx) .insert({ ...address, updatedAt }) .onConflict('externalId') - .merge([ - 'address1', - 'address2', - 'address3', - 'address4', - 'address5', - 'address6', - 'country', - 'postcode', - 'updatedAt' - ]) + .merge(['address1', 'address2', 'address3', 'address4', 'address5', 'address6', 'country', 'postcode', 'updatedAt']) } -async function _persistAddresses (trx, updatedAt, addresses) { +async function _persistAddresses(trx, updatedAt, addresses) { for (const address of addresses) { await _persistAddress(trx, updatedAt, address) } } -async function _persistCompanies (trx, updatedAt, companies) { +async function _persistCompanies(trx, updatedAt, companies) { for (const company of companies) { await _persistCompany(trx, updatedAt, company) @@ -62,29 +52,27 @@ async function _persistCompanies (trx, updatedAt, companies) { } } -async function _persistCompany (trx, updatedAt, company) { +async function _persistCompany(trx, updatedAt, company) { const { contact, companyContact, addresses, companyAddresses, ...propertiesToPersist } = company await CompanyModel.query(trx) .insert({ ...propertiesToPersist, updatedAt }) .onConflict('externalId') - .merge([ - 'name', - 'type', - 'updatedAt' - ]) + .merge(['name', 'type', 'updatedAt']) } -async function _persistCompanyAddresses (trx, updatedAt, companyAddresses) { +async function _persistCompanyAddresses(trx, updatedAt, companyAddresses) { for (const companyAddress of companyAddresses) { await _persistCompanyAddress(trx, updatedAt, companyAddress) } } -async function _persistCompanyAddress (trx, updatedAt, companyAddress) { +async function _persistCompanyAddress(trx, updatedAt, companyAddress) { const { companyId, startDate, endDate, licenceRoleId, addressId } = companyAddress - await db.raw(` + await db + .raw( + ` INSERT INTO public."company_addresses" (company_id, address_id, licence_role_id, start_date, end_date, "default", created_at, updated_at) SELECT com.id, add.id, lr.id, ? ,?, true, NOW(), ? FROM public.companies com @@ -97,14 +85,18 @@ async function _persistCompanyAddress (trx, updatedAt, companyAddress) { "default" = EXCLUDED."default", end_date = EXCLUDED.end_date, updated_at = EXCLUDED.updated_at - `, [startDate, endDate, updatedAt, licenceRoleId, addressId, companyId]) + `, + [startDate, endDate, updatedAt, licenceRoleId, addressId, companyId] + ) .transacting(trx) } -async function _persistsCompanyContact (trx, updatedAt, companyContact) { +async function _persistsCompanyContact(trx, updatedAt, companyContact) { const { externalId, startDate, licenceRoleId } = companyContact - await db.raw(` + await db + .raw( + ` INSERT INTO public."company_contacts" (company_id, contact_id, licence_role_id, start_date, "default", created_at, updated_at) SELECT com.id, con.id, lr.id, ?, true, NOW(), ? FROM public.companies com @@ -116,21 +108,17 @@ async function _persistsCompanyContact (trx, updatedAt, companyContact) { contact_id = EXCLUDED.contact_id, "default" = EXCLUDED."default", updated_at = EXCLUDED.updated_at - `, [startDate, updatedAt, licenceRoleId, externalId, externalId]) + `, + [startDate, updatedAt, licenceRoleId, externalId, externalId] + ) .transacting(trx) } -async function _persistContact (trx, updatedAt, contact) { +async function _persistContact(trx, updatedAt, contact) { await ContactModel.query(trx) .insert({ ...contact, updatedAt }) .onConflict('externalId') - .merge([ - 'salutation', - 'initials', - 'firstName', - 'lastName', - 'updatedAt' - ]) + .merge(['salutation', 'initials', 'firstName', 'lastName', 'updatedAt']) } module.exports = { diff --git a/app/services/import/persist/persist-licence-document.service.js b/app/services/import/persist/persist-licence-document.service.js index 0a06af68f0..595bdd257b 100644 --- a/app/services/import/persist/persist-licence-document.service.js +++ b/app/services/import/persist/persist-licence-document.service.js @@ -17,35 +17,33 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} - The licence ID from WRLS. */ -async function go (trx, updatedAt, transformedLicence) { +async function go(trx, updatedAt, transformedLicence) { await _persistLicenceDocument(trx, updatedAt, transformedLicence.licenceDocument) await _persistLicenceDocumentRoles(trx, updatedAt, transformedLicence.licenceDocument.licenceDocumentRoles) } -async function _persistLicenceDocument (trx, updatedAt, licenceDocument) { +async function _persistLicenceDocument(trx, updatedAt, licenceDocument) { const { licenceDocumentRoles, ...propertiesToPersist } = licenceDocument return LicenceDocumentModel.query(trx) .insert({ ...propertiesToPersist, updatedAt }) .onConflict('licenceRef') - .merge([ - 'endDate', - 'startDate', - 'updatedAt' - ]) + .merge(['endDate', 'startDate', 'updatedAt']) } -async function _persistLicenceDocumentRoles (trx, updatedAt, licenceDocumentRoles) { +async function _persistLicenceDocumentRoles(trx, updatedAt, licenceDocumentRoles) { for (const licenceDocumentRole of licenceDocumentRoles) { await _persistLicenceDocumentRole(trx, updatedAt, licenceDocumentRole) } } -async function _persistLicenceDocumentRole (trx, updatedAt, licenceDocument) { +async function _persistLicenceDocumentRole(trx, updatedAt, licenceDocument) { const { addressId, companyId, contactId, documentId, licenceRoleId, startDate, endDate } = licenceDocument - return db.raw(` + return db + .raw( + ` INSERT INTO public."licence_document_roles" (address_id, company_id, contact_id, licence_document_id, licence_role_id, start_date, end_date, updated_at) SELECT add.id, com.id, con.id, ld.id, lr.id, ? ,?, ? FROM public.licence_documents ld @@ -61,7 +59,9 @@ async function _persistLicenceDocumentRole (trx, updatedAt, licenceDocument) { address_id=EXCLUDED.address_id, end_date=EXCLUDED.end_date, updated_at = EXCLUDED.updated_at - `, [startDate, endDate, updatedAt, licenceRoleId, addressId, companyId, contactId, documentId]) + `, + [startDate, endDate, updatedAt, licenceRoleId, addressId, companyId, contactId, documentId] + ) .transacting(trx) } diff --git a/app/services/import/persist/persist-licence-versions.service.js b/app/services/import/persist/persist-licence-versions.service.js index 20a1524e21..c886c3d536 100644 --- a/app/services/import/persist/persist-licence-versions.service.js +++ b/app/services/import/persist/persist-licence-versions.service.js @@ -17,26 +17,21 @@ const LicenceVersionModel = require('../../../models/licence-version.model.js') * @param {object} transformedLicence - An object representing a valid WRLS licence. * @param {string} licenceId - A licence id from WRLS */ -async function go (trx, updatedAt, transformedLicence, licenceId) { +async function go(trx, updatedAt, transformedLicence, licenceId) { await _persistLicenceVersions(trx, updatedAt, transformedLicence.licenceVersions, licenceId) } -async function _persistLicenceVersion (trx, updatedAt, licenceVersion, licenceId) { +async function _persistLicenceVersion(trx, updatedAt, licenceVersion, licenceId) { const { licenceVersionPurposes, ...propertiesToPersist } = licenceVersion return LicenceVersionModel.query(trx) .insert({ ...propertiesToPersist, licenceId, updatedAt }) .onConflict('externalId') - .merge([ - 'endDate', - 'startDate', - 'status', - 'updatedAt' - ]) + .merge(['endDate', 'startDate', 'status', 'updatedAt']) .returning('id') } -async function _persistLicenceVersions (trx, updatedAt, licenceVersions, licenceId) { +async function _persistLicenceVersions(trx, updatedAt, licenceVersions, licenceId) { for (const licenceVersion of licenceVersions) { const { id } = await _persistLicenceVersion(trx, updatedAt, licenceVersion, licenceId) @@ -44,7 +39,7 @@ async function _persistLicenceVersions (trx, updatedAt, licenceVersions, licence } } -async function _persistLicenceVersionPurpose (trx, updatedAt, licenceVersionPurpose, licenceVersionId) { +async function _persistLicenceVersionPurpose(trx, updatedAt, licenceVersionPurpose, licenceVersionId) { const { ...propertiesToPersist } = licenceVersionPurpose return LicenceVersionPurposeModel.query(trx) @@ -70,39 +65,44 @@ async function _persistLicenceVersionPurpose (trx, updatedAt, licenceVersionPurp .returning('id') } -async function _persistLicenceVersionPurposes (trx, updatedAt, licenceVersionPurposes, licenceVersionId) { +async function _persistLicenceVersionPurposes(trx, updatedAt, licenceVersionPurposes, licenceVersionId) { for (const licenceVersionPurpose of licenceVersionPurposes) { const licenceVersionPurposeConditions = licenceVersionPurpose.licenceVersionPurposeConditions - const { id } = await _persistLicenceVersionPurpose( - trx, updatedAt, licenceVersionPurpose, licenceVersionId) + const { id } = await _persistLicenceVersionPurpose(trx, updatedAt, licenceVersionPurpose, licenceVersionId) await _persistLicenceVersionPurposeConditions(trx, updatedAt, licenceVersionPurposeConditions, id) } } -async function _persistLicenceVersionPurposeCondition ( - trx, updatedAt, licenceVersionPurposeConditions, licenceVersionPurposeId) { +async function _persistLicenceVersionPurposeCondition( + trx, + updatedAt, + licenceVersionPurposeConditions, + licenceVersionPurposeId +) { const { ...propertiesToPersist } = licenceVersionPurposeConditions return LicenceVersionPurposeConditionModel.query(trx) .insert({ ...propertiesToPersist, licenceVersionPurposeId, updatedAt }) .onConflict('externalId') - .merge([ - 'licenceVersionPurposeConditionTypeId', - 'param1', - 'param2', - 'notes', - 'updatedAt' - ]) + .merge(['licenceVersionPurposeConditionTypeId', 'param1', 'param2', 'notes', 'updatedAt']) .returning('id') } -async function _persistLicenceVersionPurposeConditions ( - trx, updatedAt, licenceVersionPurposeConditions, licenceVersionPurposeId) { +async function _persistLicenceVersionPurposeConditions( + trx, + updatedAt, + licenceVersionPurposeConditions, + licenceVersionPurposeId +) { for (const licenceVersionPurposeCondition of licenceVersionPurposeConditions) { await _persistLicenceVersionPurposeCondition( - trx, updatedAt, licenceVersionPurposeCondition, licenceVersionPurposeId) + trx, + updatedAt, + licenceVersionPurposeCondition, + licenceVersionPurposeId + ) } } diff --git a/app/services/import/persist/persist-licence.service.js b/app/services/import/persist/persist-licence.service.js index 4076b7a8ce..4c7dd6ef5b 100644 --- a/app/services/import/persist/persist-licence.service.js +++ b/app/services/import/persist/persist-licence.service.js @@ -16,27 +16,19 @@ const LicenceModel = require('../../../models/licence.model.js') * * @returns {Promise} - The licence ID from WRLS. */ -async function go (trx, updatedAt, transformedLicence) { +async function go(trx, updatedAt, transformedLicence) { const { id } = await _persistLicence(trx, updatedAt, transformedLicence) return id } -async function _persistLicence (trx, updatedAt, licence) { +async function _persistLicence(trx, updatedAt, licence) { const { licenceVersions, licenceDocument, ...propertiesToPersist } = licence return LicenceModel.query(trx) .insert({ ...propertiesToPersist, updatedAt }) .onConflict('licenceRef') - .merge([ - 'expiredDate', - 'lapsedDate', - 'regions', - 'revokedDate', - 'startDate', - 'updatedAt', - 'waterUndertaker' - ]) + .merge(['expiredDate', 'lapsedDate', 'regions', 'revokedDate', 'startDate', 'updatedAt', 'waterUndertaker']) .returning('id') } diff --git a/app/services/jobs/export/compress-schema-folder.service.js b/app/services/jobs/export/compress-schema-folder.service.js index 62a4a80c89..bbc30be853 100644 --- a/app/services/jobs/export/compress-schema-folder.service.js +++ b/app/services/jobs/export/compress-schema-folder.service.js @@ -14,7 +14,7 @@ const tar = require('tar') * * @returns {Promise} The path to the created tarball file */ -async function go (schemaFolderPath) { +async function go(schemaFolderPath) { const file = `${schemaFolderPath}.tgz` await tar.create( diff --git a/app/services/jobs/export/convert-to-csv.service.js b/app/services/jobs/export/convert-to-csv.service.js index 49a68a6dd6..58d783fb44 100644 --- a/app/services/jobs/export/convert-to-csv.service.js +++ b/app/services/jobs/export/convert-to-csv.service.js @@ -12,7 +12,7 @@ * * @returns {string} A CSV formatted string */ -function go (data) { +function go(data) { if (!data) { return undefined } @@ -25,10 +25,12 @@ function go (data) { * * @private */ -function _transformDataToCSV (data) { - const transformedRow = data.map((value) => { - return _transformValueToCSV(value) - }).join(',') +function _transformDataToCSV(data) { + const transformedRow = data + .map((value) => { + return _transformValueToCSV(value) + }) + .join(',') return transformedRow + '\n' } @@ -38,7 +40,7 @@ function _transformDataToCSV (data) { * * @private */ -function _transformValueToCSV (value) { +function _transformValueToCSV(value) { // Return empty string for undefined or null values if (!value && value !== false) { return '' @@ -58,9 +60,7 @@ function _transformValueToCSV (value) { if (typeof value === 'object') { const objectToString = JSON.stringify(value) - const escapedObjectToString = objectToString.replace(/"/g, '""') - .replace(/:/g, ': ') - .replace(/,/g, ', ') + const escapedObjectToString = objectToString.replace(/"/g, '""').replace(/:/g, ': ').replace(/,/g, ', ') return `"${escapedObjectToString}"` } diff --git a/app/services/jobs/export/delete-files.service.js b/app/services/jobs/export/delete-files.service.js index acb42a0b3e..f35ffeca14 100644 --- a/app/services/jobs/export/delete-files.service.js +++ b/app/services/jobs/export/delete-files.service.js @@ -12,7 +12,7 @@ const fsPromises = require('fs').promises * * @param {string} path - The folder or file path that we want to delete */ -async function go (path) { +async function go(path) { try { await fsPromises.rm(path, { recursive: true, force: true }) } catch (error) { diff --git a/app/services/jobs/export/export-table.service.js b/app/services/jobs/export/export-table.service.js index 020f79259f..64d933f06e 100644 --- a/app/services/jobs/export/export-table.service.js +++ b/app/services/jobs/export/export-table.service.js @@ -18,7 +18,7 @@ const WriteTableToFileService = require('./write-table-to-file.service.js') * @param {string} schemaFolderPath - The folder path where the schema files are stored * @param {string} schemaName - The name of the database schema */ -async function go (tableName, schemaFolderPath, schemaName) { +async function go(tableName, schemaFolderPath, schemaName) { const data = await FetchTableService.go(tableName, schemaName) await WriteTableToFileService.go(data.headers, data.rows, schemaFolderPath, tableName) diff --git a/app/services/jobs/export/export.service.js b/app/services/jobs/export/export.service.js index eed551f084..604c424913 100644 --- a/app/services/jobs/export/export.service.js +++ b/app/services/jobs/export/export.service.js @@ -11,7 +11,7 @@ const SchemaExportService = require('./schema-export.service.js') /** * Calls SchemaExportService giving it a schemaName */ -async function go () { +async function go() { // Mark the start time for later logging const startTime = currentTimeInNanoseconds() diff --git a/app/services/jobs/export/fetch-table-names.service.js b/app/services/jobs/export/fetch-table-names.service.js index 5a60d3da5c..99c311068e 100644 --- a/app/services/jobs/export/fetch-table-names.service.js +++ b/app/services/jobs/export/fetch-table-names.service.js @@ -14,7 +14,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} Table names for the specified schema */ -async function go (schemaName) { +async function go(schemaName) { const tableData = await _fetchTableNames(schemaName) // tableData has information we do not need @@ -27,7 +27,7 @@ async function go (schemaName) { return tableNames } -async function _fetchTableNames (schemaName) { +async function _fetchTableNames(schemaName) { const query = ` SELECT table_name FROM information_schema.tables @@ -38,7 +38,7 @@ async function _fetchTableNames (schemaName) { return db.raw(query) } -function _pluckTableNames (tableData) { +function _pluckTableNames(tableData) { return tableData.map((obj) => { return obj.table_name }) diff --git a/app/services/jobs/export/fetch-table.service.js b/app/services/jobs/export/fetch-table.service.js index b0cc26d4e3..0828706559 100644 --- a/app/services/jobs/export/fetch-table.service.js +++ b/app/services/jobs/export/fetch-table.service.js @@ -16,7 +16,7 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} The headers, query and table name from the table */ -async function go (tableName, schemaName) { +async function go(tableName, schemaName) { const data = { headers: await _headers(tableName, schemaName), rows: _rows(tableName, schemaName) @@ -25,16 +25,12 @@ async function go (tableName, schemaName) { return data } -async function _rows (tableName, schemaName) { +async function _rows(tableName, schemaName) { // Retrieves the input streams query - return db - .withSchema(schemaName) - .select('*') - .from(tableName) - .stream() + return db.withSchema(schemaName).select('*').from(tableName).stream() } -async function _headers (tableName, schemaName) { +async function _headers(tableName, schemaName) { const columns = await db(tableName).withSchema(schemaName).columnInfo() // We are only interested in the column names diff --git a/app/services/jobs/export/schema-export.service.js b/app/services/jobs/export/schema-export.service.js index 2fd91a7750..f7c63207c1 100644 --- a/app/services/jobs/export/schema-export.service.js +++ b/app/services/jobs/export/schema-export.service.js @@ -21,7 +21,7 @@ const SendToS3BucketService = require('./send-to-s3-bucket.service.js') * * @param {string} schemaName - The name of the database schema to export */ -async function go (schemaName) { +async function go(schemaName) { const schemaFolderPath = _folderToUpload(schemaName) let compressedSchemaPath @@ -51,7 +51,7 @@ async function go (schemaName) { * * @private */ -function _folderToUpload (schemaName) { +function _folderToUpload(schemaName) { const temporaryFilePath = os.tmpdir() return path.join(temporaryFilePath, schemaName) diff --git a/app/services/jobs/export/send-to-s3-bucket.service.js b/app/services/jobs/export/send-to-s3-bucket.service.js index 2356a89cd7..ba41455ded 100644 --- a/app/services/jobs/export/send-to-s3-bucket.service.js +++ b/app/services/jobs/export/send-to-s3-bucket.service.js @@ -19,7 +19,7 @@ const S3Config = require('../../../../config/s3.config.js') * * @param {string} filePath - A string containing the path of the file to send to the S3 bucket */ -async function go (filePath) { +async function go(filePath) { const bucketName = S3Config.s3.bucket const fileName = path.basename(filePath) const fileContent = await fsPromises.readFile(filePath) @@ -40,11 +40,11 @@ async function go (filePath) { * * @private */ -function _customConfig () { +function _customConfig() { return { requestHandler: new NodeHttpHandler({ - // This uses the ternary operator to give either an `http/httpsAgent` object or an empty object, and the spread - // operator to bring the result back into the top level of the `customConfig` object. + // This uses the ternary operator to give either an `http/httpsAgent` object or an empty object, and the spread + // operator to bring the result back into the top level of the `customConfig` object. ...(requestConfig.httpProxy ? { httpsAgent: new HttpsProxyAgent({ proxy: requestConfig.httpProxy }), @@ -56,7 +56,7 @@ function _customConfig () { } } -async function _uploadFileToS3Bucket (params) { +async function _uploadFileToS3Bucket(params) { const customConfig = _customConfig() const s3Client = new S3Client(customConfig) const command = new PutObjectCommand(params) diff --git a/app/services/jobs/export/write-table-to-file.service.js b/app/services/jobs/export/write-table-to-file.service.js index 0ab2fd16c7..0b9aaa6113 100644 --- a/app/services/jobs/export/write-table-to-file.service.js +++ b/app/services/jobs/export/write-table-to-file.service.js @@ -21,7 +21,7 @@ const ConvertToCSVService = require('./convert-to-csv.service.js') * @param {string} schemaFolderPath - The folder path of the schema * @param {string} tableName - The name of the table */ -async function go (headers, rows, schemaFolderPath, tableName) { +async function go(headers, rows, schemaFolderPath, tableName) { const filePath = await _filenameWithPath(tableName, schemaFolderPath) const writeToFileStream = fs.createWriteStream(filePath, { flags: 'a' }) const promisifiedPipeline = util.promisify(pipeline) @@ -44,7 +44,7 @@ async function go (headers, rows, schemaFolderPath, tableName) { * * @private */ -function _transformDataStream () { +function _transformDataStream() { return new Transform({ objectMode: true, transform: function (row, _encoding, callback) { @@ -66,7 +66,7 @@ function _transformDataStream () { * * @private */ -async function _filenameWithPath (tableName, schemaFolderPath) { +async function _filenameWithPath(tableName, schemaFolderPath) { await fsPromises.mkdir(schemaFolderPath, { recursive: true }) return path.normalize( diff --git a/app/services/jobs/licence-updates/fetch-licence-updates.service.js b/app/services/jobs/licence-updates/fetch-licence-updates.service.js index 882e32d697..eb9589bc1d 100644 --- a/app/services/jobs/licence-updates/fetch-licence-updates.service.js +++ b/app/services/jobs/licence-updates/fetch-licence-updates.service.js @@ -22,45 +22,44 @@ const { db } = require('../../../../db/db.js') * @returns {Promise} The ID for each licence version created in the last 2 months without a workflow record, * plus associated licence ID and whether a charge version exists for the licence */ -async function go () { +async function go() { const twoMonthsAgo = _twoMonthsAgo() // NOTE: We've resorted to Knex rather than Objection JS due to the complexity of the query. As we are not intending // to work with the results directly their was no driver to return LicenceVersionModel instances which Objection // would have provided. - return db - .select( - 'lv.id', - 'lv.licenceId', - // We add this information to the `data` property of the workflow record so we can tell the user whether they - // need to create a charge version (new licence) or check the existing one(s) - db.raw('EXISTS(SELECT 1 FROM public.charge_versions cv WHERE cv.licence_id = lv.licence_id) AS charge_version_exists') - ) - .from('licenceVersions AS lv') - .whereNotExists( - db - .select(1) - .from('workflows as w') - .whereColumn('w.licenceVersionId', 'lv.id') - ) - // This is only relevant for PRESROC bill runs (see WATER-3528). If a licence is linked to an in-progress PRESROC - // bill run and gets added to workflow it appears to break the PRESROC billing engine - .whereNotExists( - db - .select(1) - .from('chargeVersions AS cv') - .innerJoin('billRunChargeVersionYears AS brcvy', 'brcvy.chargeVersionId', 'cv.id') - .innerJoin('billRuns AS br', 'br.id', 'brcvy.billRunId') - .whereIn('br.status', ['processing', 'queued', 'ready', 'review']) - .whereColumn('cv.licenceId', 'lv.licenceId') - ) - .where('lv.createdAt', '>=', twoMonthsAgo.toISOString()) - // We're not sure when a licence version's status is set to draft. But the legacy job we are replacing excluded - // licence versions with this state - .whereNot('lv.status', 'draft') + return ( + db + .select( + 'lv.id', + 'lv.licenceId', + // We add this information to the `data` property of the workflow record so we can tell the user whether they + // need to create a charge version (new licence) or check the existing one(s) + db.raw( + 'EXISTS(SELECT 1 FROM public.charge_versions cv WHERE cv.licence_id = lv.licence_id) AS charge_version_exists' + ) + ) + .from('licenceVersions AS lv') + .whereNotExists(db.select(1).from('workflows as w').whereColumn('w.licenceVersionId', 'lv.id')) + // This is only relevant for PRESROC bill runs (see WATER-3528). If a licence is linked to an in-progress PRESROC + // bill run and gets added to workflow it appears to break the PRESROC billing engine + .whereNotExists( + db + .select(1) + .from('chargeVersions AS cv') + .innerJoin('billRunChargeVersionYears AS brcvy', 'brcvy.chargeVersionId', 'cv.id') + .innerJoin('billRuns AS br', 'br.id', 'brcvy.billRunId') + .whereIn('br.status', ['processing', 'queued', 'ready', 'review']) + .whereColumn('cv.licenceId', 'lv.licenceId') + ) + .where('lv.createdAt', '>=', twoMonthsAgo.toISOString()) + // We're not sure when a licence version's status is set to draft. But the legacy job we are replacing excluded + // licence versions with this state + .whereNot('lv.status', 'draft') + ) } -function _twoMonthsAgo () { +function _twoMonthsAgo() { const today = new Date() today.setMonth(today.getMonth() - 2) diff --git a/app/services/jobs/licence-updates/process-licence-updates.js b/app/services/jobs/licence-updates/process-licence-updates.js index 1b8d2fbc31..ec3931d9b9 100644 --- a/app/services/jobs/licence-updates/process-licence-updates.js +++ b/app/services/jobs/licence-updates/process-licence-updates.js @@ -6,7 +6,11 @@ */ const FetchLicenceUpdatesService = require('./fetch-licence-updates.service.js') -const { calculateAndLogTimeTaken, currentTimeInNanoseconds, timestampForPostgres } = require('../../../lib/general.lib.js') +const { + calculateAndLogTimeTaken, + currentTimeInNanoseconds, + timestampForPostgres +} = require('../../../lib/general.lib.js') const Workflow = require('../../../models/workflow.model.js') /** @@ -30,7 +34,7 @@ const Workflow = require('../../../models/workflow.model.js') * in future bill runs until Billing & Data have had a chance to review the existing charge versions. This is because * the change to the licence might require changes to the charge versions. */ -async function go () { +async function go() { try { const startTime = currentTimeInNanoseconds() @@ -44,7 +48,7 @@ async function go () { } } -async function _addWorkflowRecords (licenceVersions) { +async function _addWorkflowRecords(licenceVersions) { const timestamp = timestampForPostgres() for (const licenceVersion of licenceVersions) { diff --git a/app/services/jobs/return-logs/fetch-licence-return-requirements.service.js b/app/services/jobs/return-logs/fetch-licence-return-requirements.service.js index 8dfacd256f..e0c511df2b 100644 --- a/app/services/jobs/return-logs/fetch-licence-return-requirements.service.js +++ b/app/services/jobs/return-logs/fetch-licence-return-requirements.service.js @@ -19,11 +19,11 @@ const { cycleEndDateAsISO, cycleStartDateAsISO, cycleStartDate } = require('../. * * @returns {Promise} the array of return log payloads to be created in the database */ -async function go (licenceReference) { +async function go(licenceReference) { return _fetchReturnRequirements(licenceReference) } -async function _fetchExternalIds (licenceReference) { +async function _fetchExternalIds(licenceReference) { const externalIds = await ReturnLogModel.query() .select([db.raw("concat(metadata->'nald'->>'regionCode', ':', return_reference) as externalid")]) .where('startDate', '>=', cycleStartDate(false)) @@ -36,7 +36,7 @@ async function _fetchExternalIds (licenceReference) { return externalIdsArray } -async function _fetchReturnRequirements (licenceReference) { +async function _fetchReturnRequirements(licenceReference) { // pass in false to ge the all year start and end date to make sure we cover the entire year const _cycleEndDate = cycleEndDateAsISO(false) const _cycleStartDate = cycleStartDateAsISO(false) @@ -47,19 +47,18 @@ async function _fetchReturnRequirements (licenceReference) { .whereExists(_whereExistsClause(licenceReference, _cycleStartDate, _cycleEndDate)) .withGraphFetched('returnVersion') .modifyGraph('returnVersion', (builder) => { - builder.select(['endDate', - 'id', - 'startDate', - 'reason']) + builder.select(['endDate', 'id', 'startDate', 'reason']) }) .withGraphFetched('returnVersion.licence') .modifyGraph('returnVersion.licence', (builder) => { - builder.select(['expiredDate', + builder.select([ + 'expiredDate', 'id', 'lapsedDate', 'licenceRef', 'revokedDate', - db.raw('regions->>\'historicalAreaCode\' as areacode')]) + db.raw("regions->>'historicalAreaCode' as areacode") + ]) }) .withGraphFetched('returnVersion.licence.region') .modifyGraph('returnVersion.licence.region', (builder) => { @@ -67,13 +66,7 @@ async function _fetchReturnRequirements (licenceReference) { }) .withGraphFetched('points') .modifyGraph('points', (builder) => { - builder.select([ - 'points.description', - 'points.ngr1', - 'points.ngr2', - 'points.ngr3', - 'points.ngr4' - ]) + builder.select(['points.description', 'points.ngr1', 'points.ngr2', 'points.ngr3', 'points.ngr4']) }) .withGraphFetched('returnRequirementPurposes.primaryPurpose') .modifyGraph('returnRequirementPurposes.primaryPurpose', (builder) => { @@ -89,33 +82,26 @@ async function _fetchReturnRequirements (licenceReference) { }) } -function _whereExistsClause (licenceReference, cycleStartDate, cycleEndDate) { +function _whereExistsClause(licenceReference, cycleStartDate, cycleEndDate) { const query = ReturnVersionModel.query().select(1) - query.select(1) + query + .select(1) .innerJoinRelated('licence') .where('licence.licenceRef', licenceReference) .where('returnVersions.startDate', '<=', cycleEndDate) .where('returnVersions.status', 'current') .where((builder) => { - builder - .whereNull('returnVersions.endDate') - .orWhere('returnVersions.endDate', '>=', cycleStartDate) + builder.whereNull('returnVersions.endDate').orWhere('returnVersions.endDate', '>=', cycleStartDate) }) .where((builder) => { - builder - .whereNull('licence.expiredDate') - .orWhere('licence.expiredDate', '>=', cycleStartDate) + builder.whereNull('licence.expiredDate').orWhere('licence.expiredDate', '>=', cycleStartDate) }) .where((builder) => { - builder - .whereNull('licence.lapsedDate') - .orWhere('licence.lapsedDate', '>=', cycleStartDate) + builder.whereNull('licence.lapsedDate').orWhere('licence.lapsedDate', '>=', cycleStartDate) }) .where((builder) => { - builder - .whereNull('licence.revokedDate') - .orWhere('licence.revokedDate', '>=', cycleStartDate) + builder.whereNull('licence.revokedDate').orWhere('licence.revokedDate', '>=', cycleStartDate) }) query.whereColumn('returnVersions.id', 'returnRequirements.returnVersionId') diff --git a/app/services/jobs/return-logs/fetch-return-cycle.service.js b/app/services/jobs/return-logs/fetch-return-cycle.service.js index a842a68293..80edbe334e 100644 --- a/app/services/jobs/return-logs/fetch-return-cycle.service.js +++ b/app/services/jobs/return-logs/fetch-return-cycle.service.js @@ -17,7 +17,7 @@ const { returnCycleDates } = require('../../../lib/static-lookups.lib.js') * * @returns {Promise} the id of the return cycle */ -async function go (date, summer) { +async function go(date, summer) { const _date = new Date(date) const cycleStartDate = _cycleStartDateByDate(_date, summer) const cycleEndDate = _cycleEndDateByDate(_date, summer) @@ -30,7 +30,7 @@ async function go (date, summer) { return undefined } -function _cycleEndDateByDate (date, summer) { +function _cycleEndDateByDate(date, summer) { const year = date.getFullYear() const month = date.getMonth() @@ -49,7 +49,7 @@ function _cycleEndDateByDate (date, summer) { return `${year}-03-31` } -function _cycleStartDateByDate (date, summer) { +function _cycleStartDateByDate(date, summer) { const year = date.getFullYear() const month = date.getMonth() @@ -68,7 +68,7 @@ function _cycleStartDateByDate (date, summer) { return `${year}-04-01` } -async function _fetchReturnCycle (startDate, endDate, summer) { +async function _fetchReturnCycle(startDate, endDate, summer) { return ReturnCycleModel.query() .select(['id']) .where('startDate', '>=', startDate) diff --git a/app/services/jobs/return-logs/fetch-return-requirements.service.js b/app/services/jobs/return-logs/fetch-return-requirements.service.js index 490c18131c..c9bb4a8715 100644 --- a/app/services/jobs/return-logs/fetch-return-requirements.service.js +++ b/app/services/jobs/return-logs/fetch-return-requirements.service.js @@ -20,15 +20,13 @@ const { cycleEndDateAsISO, cycleStartDateAsISO } = require('../../../lib/return- * * @returns {Promise} the list of return requirement ids */ -async function go (summer, licenceReference) { +async function go(summer, licenceReference) { return _fetchReturnRequirements(summer, licenceReference) } -async function _fetchExternalIds (cycleStartDate) { +async function _fetchExternalIds(cycleStartDate) { const externalIds = await ReturnLogModel.query() - .select(['licenceRef', - db.raw("concat(metadata->'nald'->>'regionCode', ':', return_reference) as externalid") - ]) + .select(['licenceRef', db.raw("concat(metadata->'nald'->>'regionCode', ':', return_reference) as externalid")]) .where('startDate', '>=', cycleStartDate) const externalIdsArray = externalIds.map((item) => { @@ -38,7 +36,7 @@ async function _fetchExternalIds (cycleStartDate) { return externalIdsArray } -async function _fetchReturnRequirements (summer, licenceReference) { +async function _fetchReturnRequirements(summer, licenceReference) { const _cycleEndDate = cycleEndDateAsISO(summer) const _cycleStartDate = cycleStartDateAsISO(summer) const externalIds = await _fetchExternalIds(_cycleStartDate) @@ -64,19 +62,18 @@ async function _fetchReturnRequirements (summer, licenceReference) { .where('returnRequirements.summer', summer) .withGraphFetched('returnVersion') .modifyGraph('returnVersion', (builder) => { - builder.select(['endDate', - 'id', - 'startDate', - 'reason']) + builder.select(['endDate', 'id', 'startDate', 'reason']) }) .withGraphFetched('returnVersion.licence') .modifyGraph('returnVersion.licence', (builder) => { - builder.select(['expiredDate', + builder.select([ + 'expiredDate', 'id', 'lapsedDate', 'licenceRef', 'revokedDate', - db.raw('regions->>\'historicalAreaCode\' as areacode')]) + db.raw("regions->>'historicalAreaCode' as areacode") + ]) }) .withGraphFetched('returnVersion.licence.region') .modifyGraph('returnVersion.licence.region', (builder) => { @@ -84,13 +81,7 @@ async function _fetchReturnRequirements (summer, licenceReference) { }) .withGraphFetched('points') .modifyGraph('points', (builder) => { - builder.select([ - 'points.description', - 'points.ngr1', - 'points.ngr2', - 'points.ngr3', - 'points.ngr4' - ]) + builder.select(['points.description', 'points.ngr1', 'points.ngr2', 'points.ngr3', 'points.ngr4']) }) .withGraphFetched('returnRequirementPurposes.primaryPurpose') .modifyGraph('returnRequirementPurposes.primaryPurpose', (builder) => { @@ -106,32 +97,25 @@ async function _fetchReturnRequirements (summer, licenceReference) { }) } -function _whereExistsClause (licenceReference, cycleStartDate, cycleEndDate) { +function _whereExistsClause(licenceReference, cycleStartDate, cycleEndDate) { const query = ReturnVersionModel.query().select(1) - query.select(1) + query + .select(1) .innerJoinRelated('licence') .where('returnVersions.startDate', '<=', cycleEndDate) .where('returnVersions.status', 'current') .where((builder) => { - builder - .whereNull('returnVersions.endDate') - .orWhere('returnVersions.endDate', '>=', cycleStartDate) + builder.whereNull('returnVersions.endDate').orWhere('returnVersions.endDate', '>=', cycleStartDate) }) .where((builder) => { - builder - .whereNull('licence.expiredDate') - .orWhere('licence.expiredDate', '>=', cycleStartDate) + builder.whereNull('licence.expiredDate').orWhere('licence.expiredDate', '>=', cycleStartDate) }) .where((builder) => { - builder - .whereNull('licence.lapsedDate') - .orWhere('licence.lapsedDate', '>=', cycleStartDate) + builder.whereNull('licence.lapsedDate').orWhere('licence.lapsedDate', '>=', cycleStartDate) }) .where((builder) => { - builder - .whereNull('licence.revokedDate') - .orWhere('licence.revokedDate', '>=', cycleStartDate) + builder.whereNull('licence.revokedDate').orWhere('licence.revokedDate', '>=', cycleStartDate) }) query.whereColumn('returnVersions.id', 'returnRequirements.returnVersionId') diff --git a/app/services/jobs/return-logs/generate-return-cycle.service.js b/app/services/jobs/return-logs/generate-return-cycle.service.js index 645085d11a..05d40805b4 100644 --- a/app/services/jobs/return-logs/generate-return-cycle.service.js +++ b/app/services/jobs/return-logs/generate-return-cycle.service.js @@ -15,25 +15,21 @@ const ReturnCycleModel = require('../../../models/return-cycle.model.js') * * @returns {Promise} the UUID of the return cycle that has been created */ -async function go (summer) { +async function go(summer) { const data = _generateData(summer) const returnCycle = await _createReturnCycle(data) return returnCycle.id } -function _createReturnCycle (returnCycle) { +function _createReturnCycle(returnCycle) { return ReturnCycleModel.query() .insert(returnCycle) .onConflict(['startDate', 'endDate', 'summer']) - .merge([ - 'dueDate', - 'submittedInWrls', - 'updatedAt' - ]) + .merge(['dueDate', 'submittedInWrls', 'updatedAt']) } -function _generateData (summer) { +function _generateData(summer) { const dueDate = cycleDueDateAsISO(summer) const endDate = cycleEndDateAsISO(summer) const startDate = cycleStartDateAsISO(summer) diff --git a/app/services/jobs/return-logs/generate-return-logs.service.js b/app/services/jobs/return-logs/generate-return-logs.service.js index 1de78d4a7c..00f779ee7b 100644 --- a/app/services/jobs/return-logs/generate-return-logs.service.js +++ b/app/services/jobs/return-logs/generate-return-logs.service.js @@ -23,7 +23,7 @@ const GenerateReturnCycleService = require('./generate-return-cycle.service.js') * * @returns {Promise} the array of return log payloads to be created in the database */ -async function go (returnRequirements) { +async function go(returnRequirements) { const { allYearReturnCycleId, summerReturnCycleId } = await _fetchReturnCycleIds() const returnLogs = returnRequirements.map(async (requirements) => { @@ -54,7 +54,7 @@ async function go (returnRequirements) { return results } -function _endDate (summer, returnVersion) { +function _endDate(summer, returnVersion) { const earliestDate = _earliestDate(summer, returnVersion) const _cycleEndDate = cycleEndDate(summer) @@ -66,7 +66,7 @@ function _endDate (summer, returnVersion) { return cycleEndDateAsISO(summer) } -function _earliestDate (summer, returnVersion) { +function _earliestDate(summer, returnVersion) { const dates = [ returnVersion.licence.expiredDate, returnVersion.licence.lapsedDate, @@ -91,7 +91,7 @@ function _earliestDate (summer, returnVersion) { return new Date(Math.min(...dates)) } -async function _fetchReturnCycleIds () { +async function _fetchReturnCycleIds() { const today = formatDateObjectToISO(new Date()) let allYearReturnCycleId = await FetchReturnCycleService.go(today, false) @@ -111,7 +111,7 @@ async function _fetchReturnCycleIds () { } } -function _id (requirements, startDate, endDate) { +function _id(requirements, startDate, endDate) { const regionCode = requirements.returnVersion.licence.region.naldRegionId const licenceReference = requirements.returnVersion.licence.licenceRef const legacyId = requirements.legacyId @@ -119,13 +119,13 @@ function _id (requirements, startDate, endDate) { return `v1:${regionCode}:${licenceReference}:${legacyId}:${startDate}:${endDate}` } -function _isFinal (endDateString, summer) { +function _isFinal(endDateString, summer) { const endDate = new Date(endDateString) return endDate < cycleEndDate(summer) } -async function _metadata (summer, endDate, requirements) { +async function _metadata(summer, endDate, requirements) { return { description: requirements.siteDescription, isCurrent: requirements.returnVersion.reason !== 'succession-or-transfer-of-licence', @@ -148,7 +148,7 @@ async function _metadata (summer, endDate, requirements) { } } -function _metadataPoints (points) { +function _metadataPoints(points) { return points.map((point) => { return { name: point.description, @@ -160,7 +160,7 @@ function _metadataPoints (points) { }) } -function _metadataPurposes (returnRequirementPurposes) { +function _metadataPurposes(returnRequirementPurposes) { return returnRequirementPurposes.map((returnRequirementPurpose) => { return { ...(returnRequirementPurpose.alias !== null && { alias: returnRequirementPurpose.alias }), @@ -180,7 +180,7 @@ function _metadataPurposes (returnRequirementPurposes) { }) } -function _startDate (summer, returnVersion) { +function _startDate(summer, returnVersion) { const returnVersionStartDate = new Date(returnVersion.startDate) if (returnVersionStartDate > cycleStartDate(summer)) { diff --git a/app/services/jobs/return-logs/process-licence-return-logs.service.js b/app/services/jobs/return-logs/process-licence-return-logs.service.js index aacce3bd58..1030e2afb9 100644 --- a/app/services/jobs/return-logs/process-licence-return-logs.service.js +++ b/app/services/jobs/return-logs/process-licence-return-logs.service.js @@ -25,7 +25,7 @@ const ReturnLogModel = require('../../../models/return-log.model.js') * * @param {string} [licenceReference] - An optional argument to limit return log creation to just the specific licence */ -async function go (licenceReference) { +async function go(licenceReference) { try { const startTime = currentTimeInNanoseconds() @@ -40,10 +40,9 @@ async function go (licenceReference) { } } -async function _createReturnLogs (returnLogs) { +async function _createReturnLogs(returnLogs) { for (const returnLog of returnLogs) { - await ReturnLogModel.query() - .insert(returnLog) + await ReturnLogModel.query().insert(returnLog) } } diff --git a/app/services/jobs/return-logs/process-return-logs.service.js b/app/services/jobs/return-logs/process-return-logs.service.js index b7e8bf242f..5e1dc06542 100644 --- a/app/services/jobs/return-logs/process-return-logs.service.js +++ b/app/services/jobs/return-logs/process-return-logs.service.js @@ -33,7 +33,7 @@ const ReturnLogModel = require('../../../models/return-log.model.js') * @param {string} cycle - the return cycle to create logs for (summer or all-year) * @param {string} [licenceReference] - An optional argument to limit return log creation to just the specific licence */ -async function go (cycle, licenceReference = null) { +async function go(cycle, licenceReference = null) { try { const startTime = currentTimeInNanoseconds() const summer = cycle === 'summer' @@ -49,10 +49,9 @@ async function go (cycle, licenceReference = null) { } } -async function _createReturnLogs (returnLogs) { +async function _createReturnLogs(returnLogs) { for (const returnLog of returnLogs) { - await ReturnLogModel.query() - .insert(returnLog) + await ReturnLogModel.query().insert(returnLog) } } diff --git a/app/services/jobs/session-cleanup/process-session-storage-cleanup.service.js b/app/services/jobs/session-cleanup/process-session-storage-cleanup.service.js index b78f3bf660..3c77695cd1 100644 --- a/app/services/jobs/session-cleanup/process-session-storage-cleanup.service.js +++ b/app/services/jobs/session-cleanup/process-session-storage-cleanup.service.js @@ -11,7 +11,7 @@ const SessionModel = require('../../../models/session.model.js') /** * Deletes any temporary session records where the `created_at` date is more than 1 day ago */ -async function go () { +async function go() { const startTime = currentTimeInNanoseconds() const numberOfRowsDeleted = await _deleteSessionRecords() @@ -19,13 +19,11 @@ async function go () { calculateAndLogTimeTaken(startTime, 'Session storage cleanup job complete', { rowsDeleted: numberOfRowsDeleted }) } -async function _deleteSessionRecords () { +async function _deleteSessionRecords() { const maxAgeInDays = 1 const maxSessionAge = new Date(new Date().setDate(new Date().getDate() - maxAgeInDays)).toISOString() - const numberOfRowsDeleted = await SessionModel.query() - .delete() - .where('created_at', '<', maxSessionAge) + const numberOfRowsDeleted = await SessionModel.query().delete().where('created_at', '<', maxSessionAge) return numberOfRowsDeleted } diff --git a/app/services/jobs/time-limited/fetch-time-limited-licences.service.js b/app/services/jobs/time-limited/fetch-time-limited-licences.service.js index b85591cef8..d853ed3e44 100644 --- a/app/services/jobs/time-limited/fetch-time-limited-licences.service.js +++ b/app/services/jobs/time-limited/fetch-time-limited-licences.service.js @@ -23,7 +23,7 @@ const { db } = require('../../../../db/db.js') * @returns {Promise} The licence IDs with time-limited elements and their current licence version ID (needed * else we break the workflow). Also the ID of the charge version that has the time limited charge element */ -async function go () { +async function go() { // NOTE: We've resorted to Knex rather than Objection JS due to just how many JOINS we need to get from licence to // charge purposes! Our Objection JS skills failed us as we could not get the query to work using innerJoinRelated() return db @@ -34,9 +34,7 @@ async function go () { .innerJoin('chargeReferences as cr', 'cv.id', 'cr.chargeVersionId') .innerJoin('chargeElements as ce', 'cr.id', 'ce.chargeReferenceId') .where((builder) => { - builder - .whereNull('l.expiredDate') - .orWhere('l.expiredDate', '>', new Date()) + builder.whereNull('l.expiredDate').orWhere('l.expiredDate', '>', new Date()) }) .whereNull('l.revokedDate') .whereNull('l.lapsedDate') @@ -46,16 +44,10 @@ async function go () { .where('cv.status', 'current') .whereNotNull('ce.timeLimitedEndDate') .where('ce.timeLimitedEndDate', '<', _offSetCurrentDateByDays(50)) - .whereNotExists( - db - .select(1) - .from('workflows as w') - .whereColumn('l.id', 'w.licenceId') - .whereNull('w.deletedAt') - ) + .whereNotExists(db.select(1).from('workflows as w').whereColumn('l.id', 'w.licenceId').whereNull('w.deletedAt')) } -function _offSetCurrentDateByDays (days) { +function _offSetCurrentDateByDays(days) { const date = new Date() date.setDate(date.getDate() + days) diff --git a/app/services/jobs/time-limited/process-time-limited-licences.service.js b/app/services/jobs/time-limited/process-time-limited-licences.service.js index 2df796367b..729bdade8a 100644 --- a/app/services/jobs/time-limited/process-time-limited-licences.service.js +++ b/app/services/jobs/time-limited/process-time-limited-licences.service.js @@ -6,13 +6,17 @@ */ const FetchTimeLimitedLicencesService = require('./fetch-time-limited-licences.service.js') -const { calculateAndLogTimeTaken, currentTimeInNanoseconds, timestampForPostgres } = require('../../../lib/general.lib.js') +const { + calculateAndLogTimeTaken, + currentTimeInNanoseconds, + timestampForPostgres +} = require('../../../lib/general.lib.js') const Workflow = require('../../../models/workflow.model.js') /** * Puts SROC licences into workflow that have a related `purpose` that is due to expire in less than 50 days */ -async function go () { +async function go() { try { const startTime = currentTimeInNanoseconds() @@ -26,7 +30,7 @@ async function go () { } } -async function _addWorkflowRecords (timeLimitedResults) { +async function _addWorkflowRecords(timeLimitedResults) { const timestamp = timestampForPostgres() for (const timeLimitedResult of timeLimitedResults) { diff --git a/app/services/licences/determine-licence-has-return-versions.service.js b/app/services/licences/determine-licence-has-return-versions.service.js index 3e1524ccb7..58aacaaaf3 100644 --- a/app/services/licences/determine-licence-has-return-versions.service.js +++ b/app/services/licences/determine-licence-has-return-versions.service.js @@ -14,20 +14,14 @@ const ReturnVersionModel = require('../../models/return-version.model.js') * * @returns {Promise} true if the licence has return versions else false */ -async function go (licenceId) { +async function go(licenceId) { const requirement = await _fetch(licenceId) return !!requirement } -async function _fetch (licenceId) { - return ReturnVersionModel.query() - .select([ - 'id' - ]) - .where('licenceId', licenceId) - .limit(1) - .first() +async function _fetch(licenceId) { + return ReturnVersionModel.query().select(['id']).where('licenceId', licenceId).limit(1).first() } module.exports = { diff --git a/app/services/licences/fetch-agreements.service.js b/app/services/licences/fetch-agreements.service.js index 72350953b7..fb0cf98ae0 100644 --- a/app/services/licences/fetch-agreements.service.js +++ b/app/services/licences/fetch-agreements.service.js @@ -14,30 +14,20 @@ const LicenceAgreementModel = require('../../models/licence-agreement.model.js') * * @returns {Promise} the data needed to populate the view licence page's set up tab */ -async function go (licenceRef) { +async function go(licenceRef) { return _fetch(licenceRef) } -async function _fetch (licenceRef) { +async function _fetch(licenceRef) { return LicenceAgreementModel.query() .where('licenceRef', licenceRef) .whereNull('deletedAt') - .select([ - 'id', - 'startDate', - 'endDate', - 'signedOn' - ]) + .select(['id', 'startDate', 'endDate', 'signedOn']) .withGraphFetched('financialAgreement') .modifyGraph('financialAgreement', (builder) => { - builder.select([ - 'id', - 'code' - ]) + builder.select(['id', 'code']) }) - .orderBy([ - { column: 'createdAt', order: 'asc' } - ]) + .orderBy([{ column: 'createdAt', order: 'asc' }]) } module.exports = { diff --git a/app/services/licences/fetch-charge-versions.service.js b/app/services/licences/fetch-charge-versions.service.js index b3955362b6..9b2a2bfad6 100644 --- a/app/services/licences/fetch-charge-versions.service.js +++ b/app/services/licences/fetch-charge-versions.service.js @@ -14,25 +14,17 @@ const ChargeVersionModel = require('../../models/charge-version.model.js') * * @returns {Promise} the data needed to populate the view licence page's set up tab */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return ChargeVersionModel.query() .where('licenceId', licenceId) - .select([ - 'id', - 'startDate', - 'endDate', - 'status', - 'licenceId' - ]) + .select(['id', 'startDate', 'endDate', 'status', 'licenceId']) .withGraphFetched('changeReason') .modifyGraph('changeReason', (builder) => { - builder.select([ - 'description' - ]) + builder.select(['description']) }) .orderBy([ { column: 'startDate', order: 'desc' }, diff --git a/app/services/licences/fetch-communications.service.js b/app/services/licences/fetch-communications.service.js index 0433ac7a7b..53a465b9a2 100644 --- a/app/services/licences/fetch-communications.service.js +++ b/app/services/licences/fetch-communications.service.js @@ -19,32 +19,21 @@ const DatabaseConfig = require('../../../config/database.config.js') * * @returns {Promise} the data needed to populate the view licence page's communications tab */ -async function go (licenceRef, page) { +async function go(licenceRef, page) { const { results, total } = await _fetch(licenceRef, page) return { communications: results, pagination: { total } } } -async function _fetch (licenceRef, page) { +async function _fetch(licenceRef, page) { return ScheduledNotificationModel.query() - .select([ - 'id', - 'messageType', - 'messageRef' - ]) + .select(['id', 'messageType', 'messageRef']) .where('licences', '@>', `["${licenceRef}"]`) .andWhere('notifyStatus', 'in', ['delivered', 'received']) .andWhere('eventId', 'is not', null) .withGraphFetched('event') .modifyGraph('event', (builder) => { - builder.select([ - 'createdAt', - 'issuer', - 'metadata', - 'status', - 'subtype', - 'type' - ]) + builder.select(['createdAt', 'issuer', 'metadata', 'status', 'subtype', 'type']) }) .page(page - 1, DatabaseConfig.defaultPageSize) .orderBy('sendAfter', 'desc') diff --git a/app/services/licences/fetch-customer-contacts.service.js b/app/services/licences/fetch-customer-contacts.service.js index 68af9ca452..e0416d80f0 100644 --- a/app/services/licences/fetch-customer-contacts.service.js +++ b/app/services/licences/fetch-customer-contacts.service.js @@ -14,12 +14,13 @@ const { db } = require('../../../db/db.js') * * @returns {Promise} the data needed to populate the view licence page's contact details tab */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { - return db.withSchema('public') +async function _fetch(licenceId) { + return db + .withSchema('public') .select([ 'con.contact_type', 'con.data_source', diff --git a/app/services/licences/fetch-licence-bills.service.js b/app/services/licences/fetch-licence-bills.service.js index d16464ec86..b338a884b1 100644 --- a/app/services/licences/fetch-licence-bills.service.js +++ b/app/services/licences/fetch-licence-bills.service.js @@ -17,13 +17,13 @@ const DatabaseConfig = require('../../../config/database.config.js') * * @returns {Promise} the data needed to populate the view licence page's bills tab */ -async function go (licenceId, page) { +async function go(licenceId, page) { const { results, total } = await _fetch(licenceId, page) return { bills: results, pagination: { total } } } -async function _fetch (licenceId, page) { +async function _fetch(licenceId, page) { return BillModel.query() .select([ 'bills.accountNumber', @@ -43,16 +43,9 @@ async function _fetch (licenceId, page) { .where('billRuns.status', 'sent') .withGraphFetched('billRun') .modifyGraph('billRun', (builder) => { - builder.select([ - 'id', - 'batchType', - 'scheme', - 'summer' - ]) + builder.select(['id', 'batchType', 'scheme', 'summer']) }) - .orderBy([ - { column: 'createdAt', order: 'desc' } - ]) + .orderBy([{ column: 'createdAt', order: 'desc' }]) .page(page - 1, DatabaseConfig.defaultPageSize) } diff --git a/app/services/licences/fetch-licence-contact-details.service.js b/app/services/licences/fetch-licence-contact-details.service.js index 543ed436ad..0b7e349b11 100644 --- a/app/services/licences/fetch-licence-contact-details.service.js +++ b/app/services/licences/fetch-licence-contact-details.service.js @@ -17,23 +17,17 @@ const LicenceModel = require('../../models/licence.model.js') * @returns {Promise} the matching `licenceModel` populated with the data needed for the view * licence contact details page */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return LicenceModel.query() .findById(licenceId) - .select([ - 'id', - 'licenceRef' - ]) + .select(['id', 'licenceRef']) .withGraphFetched('licenceDocumentHeader') .modifyGraph('licenceDocumentHeader', (builder) => { - builder.select([ - 'id', - 'metadata' - ]) + builder.select(['id', 'metadata']) }) } diff --git a/app/services/licences/fetch-licence-contacts.service.js b/app/services/licences/fetch-licence-contacts.service.js index a48fe210f8..33ed1d48f3 100644 --- a/app/services/licences/fetch-licence-contacts.service.js +++ b/app/services/licences/fetch-licence-contacts.service.js @@ -14,12 +14,13 @@ const { db } = require('../../../db/db.js') * * @returns {Promise} the data needed to populate the view licence page's contact details tab */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { - return db.withSchema('public') +async function _fetch(licenceId) { + return db + .withSchema('public') .select([ 'lr.label AS communicationType', 'cmp.id AS companyId', diff --git a/app/services/licences/fetch-licence-history.service.js b/app/services/licences/fetch-licence-history.service.js index 6bb63248cc..62cf6fe1df 100644 --- a/app/services/licences/fetch-licence-history.service.js +++ b/app/services/licences/fetch-licence-history.service.js @@ -14,34 +14,25 @@ const LicenceModel = require('../../models/licence.model.js') * * @returns {Promise} the licence and related charge, licence and return versions */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return LicenceModel.query() .findById(licenceId) .select(['id', 'licenceRef']) .withGraphFetched('chargeVersions') .modifyGraph('chargeVersions', (builder) => { - builder.select( - 'id' - ) - .modify('history') + builder.select('id').modify('history') }) .withGraphFetched('licenceVersions') .modifyGraph('licenceVersions', (builder) => { - builder.select( - 'id' - ) - .modify('history') + builder.select('id').modify('history') }) .withGraphFetched('returnVersions') .modifyGraph('returnVersions', (builder) => { - builder.select( - 'id' - ) - .modify('history') + builder.select('id').modify('history') }) } diff --git a/app/services/licences/fetch-licence-points.service.js b/app/services/licences/fetch-licence-points.service.js index b6f61232f9..ee0be47b5b 100644 --- a/app/services/licences/fetch-licence-points.service.js +++ b/app/services/licences/fetch-licence-points.service.js @@ -16,7 +16,7 @@ const LicenceModel = require('../../models/licence.model.js') * @returns {Promise} An object containing the licence instance and related points data needed for the licence * points page */ -async function go (licenceId) { +async function go(licenceId) { const licence = await _fetchLicence(licenceId) const points = await _fetchPoints(licenceId) @@ -26,16 +26,11 @@ async function go (licenceId) { } } -async function _fetchLicence (licenceId) { - return LicenceModel.query() - .findById(licenceId) - .select( - 'id', - 'licenceRef' - ) +async function _fetchLicence(licenceId) { + return LicenceModel.query().findById(licenceId).select('id', 'licenceRef') } -async function _fetchPoints (licenceId) { +async function _fetchPoints(licenceId) { const points = await db .distinct() .select( diff --git a/app/services/licences/fetch-licence-purposes.service.js b/app/services/licences/fetch-licence-purposes.service.js index 0d14e54e35..ec4b24954a 100644 --- a/app/services/licences/fetch-licence-purposes.service.js +++ b/app/services/licences/fetch-licence-purposes.service.js @@ -15,63 +15,47 @@ const LicenceModel = require('../../models/licence.model.js') * @returns {Promise} The licence instance and related licenceVersionPurposes data needed for the * licence purposes page */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return LicenceModel.query() .findById(licenceId) - .select([ - 'id', - 'licenceRef' - ]) + .select(['id', 'licenceRef']) .modify('currentVersion') .withGraphFetched('licenceVersions.licenceVersionPurposes') .modifyGraph('licenceVersions.licenceVersionPurposes', (builder) => { - builder.select([ - 'abstractionPeriodStartDay', - 'abstractionPeriodStartMonth', - 'abstractionPeriodEndDay', - 'abstractionPeriodEndMonth', - 'annualQuantity', - 'dailyQuantity', - 'hourlyQuantity', - 'instantQuantity' - ]) + builder + .select([ + 'abstractionPeriodStartDay', + 'abstractionPeriodStartMonth', + 'abstractionPeriodEndDay', + 'abstractionPeriodEndMonth', + 'annualQuantity', + 'dailyQuantity', + 'hourlyQuantity', + 'instantQuantity' + ]) .orderBy('licenceVersionPurposes.createdAt', 'asc') }) .withGraphFetched('licenceVersions.licenceVersionPurposes.licenceVersionPurposePoints') .modifyGraph('licenceVersions.licenceVersionPurposes.licenceVersionPurposePoints', (builder) => { - builder.select([ - 'licenceVersionPurposePoints.abstractionMethod' - ]) + builder.select(['licenceVersionPurposePoints.abstractionMethod']) }) .withGraphFetched('licenceVersions.licenceVersionPurposes.points') .modifyGraph('licenceVersions.licenceVersionPurposes.points', (builder) => { - builder.select([ - 'points.description', - 'points.id', - 'points.ngr1', - 'points.ngr2', - 'points.ngr3', - 'points.ngr4' - ]) + 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' - ]) + builder.select(['sources.description', 'sources.id']) }) .withGraphFetched('licenceVersions.licenceVersionPurposes.purpose') .modifyGraph('licenceVersions.licenceVersionPurposes.purpose', (builder) => { - builder.select([ - 'id', - 'description' - ]) + builder.select(['id', 'description']) }) } diff --git a/app/services/licences/fetch-licence-returns.service.js b/app/services/licences/fetch-licence-returns.service.js index f7420ce3d1..673dd05ecb 100644 --- a/app/services/licences/fetch-licence-returns.service.js +++ b/app/services/licences/fetch-licence-returns.service.js @@ -17,13 +17,13 @@ const DatabaseConfig = require('../../../config/database.config.js') * * @returns {Promise} the data needed to populate the view licence page's returns tab */ -async function go (licenceId, page) { +async function go(licenceId, page) { const { results, total } = await _fetch(licenceId, page) return { returns: results, pagination: { total } } } -async function _fetch (licenceId, page) { +async function _fetch(licenceId, page) { return ReturnLogModel.query() .select([ 'returnLogs.id', @@ -36,9 +36,7 @@ async function _fetch (licenceId, page) { ]) .innerJoinRelated('licence') .where('licence.id', licenceId) - .orderBy([ - { column: 'dueDate', order: 'desc' } - ]) + .orderBy([{ column: 'dueDate', order: 'desc' }]) .page(page - 1, DatabaseConfig.defaultPageSize) } diff --git a/app/services/licences/fetch-licence-summary.service.js b/app/services/licences/fetch-licence-summary.service.js index be897ee6dd..2dd0c179e1 100644 --- a/app/services/licences/fetch-licence-summary.service.js +++ b/app/services/licences/fetch-licence-summary.service.js @@ -16,32 +16,23 @@ const LicenceModel = require('../../models/licence.model.js') * * @returns {Promise} the data needed to populate the view licence page summary tab */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return LicenceModel.query() .findById(licenceId) - .select([ - 'id', - 'expiredDate', - 'startDate' - ]) + .select(['id', 'expiredDate', 'startDate']) .modify('currentVersion') .modify('licenceHolder') .withGraphFetched('region') .modifyGraph('region', (builder) => { - builder.select([ - 'id', - 'displayName' - ]) + builder.select(['id', 'displayName']) }) .withGraphFetched('licenceDocumentHeader') .modifyGraph('licenceDocumentHeader', (builder) => { - builder.select([ - 'id' - ]) + builder.select(['id']) }) .withGraphFetched('licenceVersions.licenceVersionPurposes') .modifyGraph('licenceVersions.licenceVersionPurposes', (builder) => { @@ -59,55 +50,36 @@ async function _fetch (licenceId) { }) .withGraphFetched('licenceVersions.licenceVersionPurposes.points') .modifyGraph('licenceVersions.licenceVersionPurposes.points', (builder) => { - builder.select([ - 'points.description', - 'points.id', - 'points.ngr1', - 'points.ngr2', - 'points.ngr3', - 'points.ngr4' - ]) + builder.select(['points.description', 'points.id', 'points.ngr1', 'points.ngr2', 'points.ngr3', 'points.ngr4']) }) .withGraphFetched('licenceVersions.licenceVersionPurposes.points.source') .modifyGraph('licenceVersions.licenceVersionPurposes.points.source', (builder) => { - builder.select([ - 'sources.description', - 'sources.id' - ]) + builder.select(['sources.description', 'sources.id']) }) .withGraphFetched('licenceVersions.licenceVersionPurposes.purpose') .modifyGraph('licenceVersions.licenceVersionPurposes.purpose', (builder) => { - builder.select([ - 'id', - 'description' - ]) + builder.select(['id', 'description']) }) .withGraphFetched('licenceVersions.licenceVersionPurposes.licenceVersionPurposeConditions') .modifyGraph('licenceVersions.licenceVersionPurposes.licenceVersionPurposeConditions', (builder) => { - builder.select([ - 'id' - ]) - }) - .withGraphFetched('licenceVersions.licenceVersionPurposes.licenceVersionPurposeConditions.licenceVersionPurposeConditionType') - .modifyGraph('licenceVersions.licenceVersionPurposes.licenceVersionPurposeConditions.licenceVersionPurposeConditionType', (builder) => { - builder.select([ - 'id', - 'displayTitle' - ]) + builder.select(['id']) }) + .withGraphFetched( + 'licenceVersions.licenceVersionPurposes.licenceVersionPurposeConditions.licenceVersionPurposeConditionType' + ) + .modifyGraph( + 'licenceVersions.licenceVersionPurposes.licenceVersionPurposeConditions.licenceVersionPurposeConditionType', + (builder) => { + builder.select(['id', 'displayTitle']) + } + ) .withGraphFetched('licenceMonitoringStations') .modifyGraph('licenceMonitoringStations', (builder) => { - builder.select([ - 'id' - ]) - .whereNull('deletedAt') + builder.select(['id']).whereNull('deletedAt') }) .withGraphFetched('licenceMonitoringStations.monitoringStation') .modifyGraph('licenceMonitoringStations.monitoringStation', (builder) => { - builder.select([ - 'id', - 'label' - ]) + builder.select(['id', 'label']) }) } diff --git a/app/services/licences/fetch-licence.service.js b/app/services/licences/fetch-licence.service.js index 0d4d0533be..407634ed99 100644 --- a/app/services/licences/fetch-licence.service.js +++ b/app/services/licences/fetch-licence.service.js @@ -17,11 +17,11 @@ const LicenceModel = require('../../models/licence.model.js') * @returns {Promise} the matching `LicenceModel` populated with the data needed for the view * licence page top section (shared by all tab pages) and some elements needed for the summary tab */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return LicenceModel.query() .findById(licenceId) .select([ @@ -37,20 +37,11 @@ async function _fetch (licenceId) { .modify('primaryUser') .withGraphFetched('licenceSupplementaryYears') .modifyGraph('licenceSupplementaryYears', (builder) => { - builder - .select([ - 'id' - ]) - .where('twoPartTariff', true) + builder.select(['id']).where('twoPartTariff', true) }) .withGraphFetched('workflows') .modifyGraph('workflows', (builder) => { - builder - .select([ - 'id', - 'status' - ]) - .whereNull('deletedAt') + builder.select(['id', 'status']).whereNull('deletedAt') }) } diff --git a/app/services/licences/fetch-return-versions.service.js b/app/services/licences/fetch-return-versions.service.js index 0146a85791..98debbe8cb 100644 --- a/app/services/licences/fetch-return-versions.service.js +++ b/app/services/licences/fetch-return-versions.service.js @@ -14,19 +14,13 @@ const ReturnVersionModel = require('../../models/return-version.model.js') * * @returns {Promise} the data needed to populate the view licence page's set up tab */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return ReturnVersionModel.query() - .select([ - 'id', - 'startDate', - 'endDate', - 'status', - 'reason' - ]) + .select(['id', 'startDate', 'endDate', 'status', 'reason']) .where('licenceId', licenceId) .whereNot('status', 'draft') .orderBy([ @@ -35,12 +29,7 @@ async function _fetch (licenceId) { ]) .withGraphFetched('modLogs') .modifyGraph('modLogs', (builder) => { - builder - .select([ - 'id', - 'reasonDescription' - ]) - .orderBy('externalId', 'asc') + builder.select(['id', 'reasonDescription']).orderBy('externalId', 'asc') }) } diff --git a/app/services/licences/fetch-workflows.service.js b/app/services/licences/fetch-workflows.service.js index 66fe5074e6..ec2aee9e43 100644 --- a/app/services/licences/fetch-workflows.service.js +++ b/app/services/licences/fetch-workflows.service.js @@ -14,24 +14,16 @@ const WorkflowModel = require('../../models/workflow.model.js') * * @returns {Promise} the data needed to populate the view licence page's set up tab */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return WorkflowModel.query() .where('licenceId', licenceId) .andWhere('deletedAt', null) - .select([ - 'id', - 'createdAt', - 'status', - 'licenceId', - 'data' - ]) - .orderBy([ - { column: 'createdAt', order: 'desc' } - ]) + .select(['id', 'createdAt', 'status', 'licenceId', 'data']) + .orderBy([{ column: 'createdAt', order: 'desc' }]) } module.exports = { diff --git a/app/services/licences/supplementary/create-licence-supplementary-year.service.js b/app/services/licences/supplementary/create-licence-supplementary-year.service.js index 354f5f3998..4a311e249e 100644 --- a/app/services/licences/supplementary/create-licence-supplementary-year.service.js +++ b/app/services/licences/supplementary/create-licence-supplementary-year.service.js @@ -14,7 +14,7 @@ const LicenceSupplementaryYearModel = require('../../../models/licence-supplemen * @param {object[]} financialYearEnds - An array of the financial year ends to be persisted as individual records * @param {boolean} twoPartTariff - If there are any two-part tariff indicators on the licence */ -async function go (licenceId, financialYearEnds, twoPartTariff) { +async function go(licenceId, financialYearEnds, twoPartTariff) { for (const financialYearEnd of financialYearEnds) { const match = await _fetchExistingLicenceSupplementaryYears(licenceId, financialYearEnd, twoPartTariff) @@ -27,7 +27,7 @@ async function go (licenceId, financialYearEnds, twoPartTariff) { } } -async function _fetchExistingLicenceSupplementaryYears (licenceId, financialYearEnd, twoPartTariff) { +async function _fetchExistingLicenceSupplementaryYears(licenceId, financialYearEnd, twoPartTariff) { return LicenceSupplementaryYearModel.query() .select('id') .where('licenceId', licenceId) @@ -38,13 +38,12 @@ async function _fetchExistingLicenceSupplementaryYears (licenceId, financialYear .first() } -async function _persistSupplementaryBillingYearsData (licenceId, financialYearEnd, twoPartTariff) { - return LicenceSupplementaryYearModel.query() - .insert({ - licenceId, - financialYearEnd, - twoPartTariff - }) +async function _persistSupplementaryBillingYearsData(licenceId, financialYearEnd, twoPartTariff) { + return LicenceSupplementaryYearModel.query().insert({ + licenceId, + financialYearEnd, + twoPartTariff + }) } module.exports = { diff --git a/app/services/licences/supplementary/determine-billing-years.service.js b/app/services/licences/supplementary/determine-billing-years.service.js index 75f1ce0d29..e7d3decae9 100644 --- a/app/services/licences/supplementary/determine-billing-years.service.js +++ b/app/services/licences/supplementary/determine-billing-years.service.js @@ -22,7 +22,7 @@ const LAST_PRE_SROC_FINANCIAL_YEAR_END = 2022 * @returns {object[]} - The financial year end that are impacted by the changes between the start and end dates and are * relevant for SROC. */ -function go (startDate, endDate) { +function go(startDate, endDate) { const years = [] const startYear = _adjustedFinancialYearEnd(startDate) @@ -48,7 +48,7 @@ function go (startDate, endDate) { * * @private */ -function _adjustedFinancialYearEnd (date) { +function _adjustedFinancialYearEnd(date) { let year = date.getFullYear() if (date.getMonth() >= APRIL) { diff --git a/app/services/licences/supplementary/determine-charge-version-flags.service.js b/app/services/licences/supplementary/determine-charge-version-flags.service.js index 355b69593f..7d63d15b95 100644 --- a/app/services/licences/supplementary/determine-charge-version-flags.service.js +++ b/app/services/licences/supplementary/determine-charge-version-flags.service.js @@ -32,7 +32,7 @@ const ChargeVersionModel = require('../../../models/charge-version.model.js') * @returns {object} - An object containing the related licenceId, regionId, charge version start and end date and * licence supplementary billing flags */ -async function go (chargeVersionId) { +async function go(chargeVersionId) { const { chargeReferences, licence, endDate, startDate, scheme } = await _fetchChargeVersion(chargeVersionId) const twoPartTariff = _twoPartTariffSrocIndicators(chargeReferences) @@ -58,34 +58,21 @@ async function go (chargeVersionId) { return result } -async function _fetchChargeVersion (chargeVersionId) { +async function _fetchChargeVersion(chargeVersionId) { return ChargeVersionModel.query() .findById(chargeVersionId) - .select([ - 'id', - 'scheme', - 'startDate', - 'endDate']) + .select(['id', 'scheme', 'startDate', 'endDate']) .withGraphFetched('chargeReferences') .modifyGraph('chargeReferences', (builder) => { - builder.select([ - 'id', - 'scheme', - ref('adjustments:s127').castBool().as('twoPartTariff') - ]) + builder.select(['id', 'scheme', ref('adjustments:s127').castBool().as('twoPartTariff')]) }) .withGraphFetched('licence') .modifyGraph('licence', (builder) => { - builder.select([ - 'id', - 'regionId', - 'includeInSrocBilling', - 'includeInPresrocBilling' - ]) + builder.select(['id', 'regionId', 'includeInSrocBilling', 'includeInPresrocBilling']) }) } -function _twoPartTariffSrocIndicators (chargeReferences) { +function _twoPartTariffSrocIndicators(chargeReferences) { return chargeReferences.some((chargeReference) => { return chargeReference.twoPartTariff && chargeReference.scheme === 'sroc' }) diff --git a/app/services/licences/supplementary/determine-existing-bill-run-years.service.js b/app/services/licences/supplementary/determine-existing-bill-run-years.service.js index 6be3d7d6bb..fa2515d2e9 100644 --- a/app/services/licences/supplementary/determine-existing-bill-run-years.service.js +++ b/app/services/licences/supplementary/determine-existing-bill-run-years.service.js @@ -24,7 +24,7 @@ const BillRunModel = require('../../../models/bill-run.model.js') * * @returns {object[]} - The years that can be flagged for supplementary billing */ -async function go (regionId, years, twoPartTariff) { +async function go(regionId, years, twoPartTariff) { return _supplementaryBillingYears(regionId, years, twoPartTariff) } @@ -35,7 +35,7 @@ async function go (regionId, years, twoPartTariff) { * * @private */ -async function _supplementaryBillingYears (regionId, years, twoPartTariff) { +async function _supplementaryBillingYears(regionId, years, twoPartTariff) { const batchType = twoPartTariff ? 'two_part_tariff' : 'annual' const billRuns = await BillRunModel.query() diff --git a/app/services/licences/supplementary/determine-return-log-flags.service.js b/app/services/licences/supplementary/determine-return-log-flags.service.js index 853247b4da..f6a60e71ee 100644 --- a/app/services/licences/supplementary/determine-return-log-flags.service.js +++ b/app/services/licences/supplementary/determine-return-log-flags.service.js @@ -38,7 +38,7 @@ const SROC_START_DATE = new Date('2022-04-01') * @returns {object} - An object containing the related licenceId, regionId, return start and end date and licence * supplementary billing flags */ -async function go (returnLogId) { +async function go(returnLogId) { const { twoPartTariff, licence, endDate, startDate } = await _fetchReturnLog(returnLogId) const result = { @@ -62,7 +62,7 @@ async function go (returnLogId) { return result } -async function _fetchReturnLog (returnLogId) { +async function _fetchReturnLog(returnLogId) { return ReturnLogModel.query() .findById(returnLogId) .select([ @@ -74,12 +74,7 @@ async function _fetchReturnLog (returnLogId) { ]) .withGraphFetched('licence') .modifyGraph('licence', (builder) => { - builder.select([ - 'id', - 'regionId', - 'includeInSrocBilling', - 'includeInPresrocBilling' - ]) + builder.select(['id', 'regionId', 'includeInSrocBilling', 'includeInPresrocBilling']) }) } diff --git a/app/services/licences/supplementary/determine-workflow-flags.service.js b/app/services/licences/supplementary/determine-workflow-flags.service.js index ebd537b0ad..e22c0b3123 100644 --- a/app/services/licences/supplementary/determine-workflow-flags.service.js +++ b/app/services/licences/supplementary/determine-workflow-flags.service.js @@ -39,7 +39,7 @@ const { determineCurrentFinancialYear } = require('../../../lib/general.lib.js') * @returns {object} - An object containing the related licenceId, regionId, workflow start and end date and * licence supplementary billing flags */ -async function go (workflowId) { +async function go(workflowId) { const licence = await FetchLicenceService.go(workflowId) const { endDate } = determineCurrentFinancialYear() @@ -65,7 +65,7 @@ async function go (workflowId) { return result } -async function _updateFlags (licence, result) { +async function _updateFlags(licence, result) { // If the licence is not already flagged for SROC billing and has SROC charge versions we check if it needs to be // flagged if (licence.sroc_charge_versions && !licence.include_in_sroc_billing) { @@ -89,7 +89,7 @@ async function _updateFlags (licence, result) { * * @private */ -async function _flagForSrocSupplementary (createdAt, regionId) { +async function _flagForSrocSupplementary(createdAt, regionId) { const recordCount = await BillRunModel.query() .where('createdAt', '>=', createdAt) .where('batchType', 'annual') diff --git a/app/services/licences/supplementary/fetch-existing-licence-details.service.js b/app/services/licences/supplementary/fetch-existing-licence-details.service.js index f28421c92d..9ea726089d 100644 --- a/app/services/licences/supplementary/fetch-existing-licence-details.service.js +++ b/app/services/licences/supplementary/fetch-existing-licence-details.service.js @@ -24,15 +24,17 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} - The data needed to determine which supplementary flags the licence needs */ -async function go (licenceId) { +async function go(licenceId) { const query = _query() - const { rows: [row] } = await db.raw(query, [licenceId]) + const { + rows: [row] + } = await db.raw(query, [licenceId]) return row } -function _query () { +function _query() { return ` SELECT l.id, diff --git a/app/services/licences/supplementary/fetch-licence.service.js b/app/services/licences/supplementary/fetch-licence.service.js index 5b02ee1a41..ae684edc79 100644 --- a/app/services/licences/supplementary/fetch-licence.service.js +++ b/app/services/licences/supplementary/fetch-licence.service.js @@ -24,15 +24,17 @@ const { db } = require('../../../../db/db.js') * * @returns {Promise} - The data needed to determine which supplementary flags the licence needs */ -async function go (workflowId) { +async function go(workflowId) { const query = _query() - const { rows: [row] } = await db.raw(query, [workflowId]) + const { + rows: [row] + } = await db.raw(query, [workflowId]) return row } -function _query () { +function _query() { return ` SELECT l.include_in_sroc_billing, diff --git a/app/services/licences/supplementary/mark-for-supplementary-billing.service.js b/app/services/licences/supplementary/mark-for-supplementary-billing.service.js index 3119fdb477..b21a0409f6 100644 --- a/app/services/licences/supplementary/mark-for-supplementary-billing.service.js +++ b/app/services/licences/supplementary/mark-for-supplementary-billing.service.js @@ -16,7 +16,7 @@ const MarkForSupplementaryBillingPresenter = require('../../../presenters/licenc * @returns {Promise} an object representing the `pageData` needed by the mark for supplementary billing page. * It contains details of the last 6 years from todays date and the licence details. */ -async function go (licenceId) { +async function go(licenceId) { const licenceData = await _fetchLicenceData(licenceId) const pageData = MarkForSupplementaryBillingPresenter.go(licenceData) @@ -24,13 +24,8 @@ async function go (licenceId) { return pageData } -async function _fetchLicenceData (licenceId) { - return LicenceModel.query() - .findById(licenceId) - .select([ - 'id', - 'licenceRef' - ]) +async function _fetchLicenceData(licenceId) { + return LicenceModel.query().findById(licenceId).select(['id', 'licenceRef']) } module.exports = { diff --git a/app/services/licences/supplementary/marked-for-supplementary-billing.service.js b/app/services/licences/supplementary/marked-for-supplementary-billing.service.js index 745e499afd..434d6db866 100644 --- a/app/services/licences/supplementary/marked-for-supplementary-billing.service.js +++ b/app/services/licences/supplementary/marked-for-supplementary-billing.service.js @@ -15,7 +15,7 @@ const LicenceModel = require('../../../../app/models/licence.model.js') * @returns {Promise} an object representing the `pageData` needed by the marked for supplementary billing * confirmation page. It contains details of the licence. */ -async function go (licenceId) { +async function go(licenceId) { const licenceData = await _fetchLicenceData(licenceId) return { @@ -24,13 +24,8 @@ async function go (licenceId) { } } -async function _fetchLicenceData (licenceId) { - return LicenceModel.query() - .findById(licenceId) - .select([ - 'id', - 'licenceRef' - ]) +async function _fetchLicenceData(licenceId) { + return LicenceModel.query().findById(licenceId).select(['id', 'licenceRef']) } module.exports = { diff --git a/app/services/licences/supplementary/persist-supplementary-billing-flags.service.js b/app/services/licences/supplementary/persist-supplementary-billing-flags.service.js index bb86910c8d..8c624e9d4d 100644 --- a/app/services/licences/supplementary/persist-supplementary-billing-flags.service.js +++ b/app/services/licences/supplementary/persist-supplementary-billing-flags.service.js @@ -24,7 +24,7 @@ const LicenceModel = require('../../../models/licence.model.js') * sroc billing * @param {string} licenceId - The UUID of the licence that needs the flags persisting for */ -async function go (twoPartTariffBillingYears, flagForPreSrocSupplementary, flagForSrocSupplementary, licenceId) { +async function go(twoPartTariffBillingYears, flagForPreSrocSupplementary, flagForSrocSupplementary, licenceId) { const includeInPresrocBilling = flagForPreSrocSupplementary ? 'yes' : 'no' await _updateLicenceFlags(includeInPresrocBilling, flagForSrocSupplementary, licenceId) @@ -36,7 +36,7 @@ async function go (twoPartTariffBillingYears, flagForPreSrocSupplementary, flagF * Persists two-part tariff financial years in the LicenceSupplementaryYears table. * @private */ -async function _flagForLicenceSupplementaryYears (twoPartTariffBillingYears, licenceId) { +async function _flagForLicenceSupplementaryYears(twoPartTariffBillingYears, licenceId) { if (twoPartTariffBillingYears.length === 0) { return } @@ -46,7 +46,7 @@ async function _flagForLicenceSupplementaryYears (twoPartTariffBillingYears, lic await CreateLicenceSupplementaryYearService.go(licenceId, twoPartTariffBillingYears, twoPartTariff) } -async function _updateLicenceFlags (includeInPresrocBilling, flagForSrocSupplementary, licenceId) { +async function _updateLicenceFlags(includeInPresrocBilling, flagForSrocSupplementary, licenceId) { return LicenceModel.query() .patch({ includeInPresrocBilling, includeInSrocBilling: flagForSrocSupplementary }) .where('id', licenceId) diff --git a/app/services/licences/supplementary/process-billing-flag.service.js b/app/services/licences/supplementary/process-billing-flag.service.js index 41cab3ea97..e1ea09c153 100644 --- a/app/services/licences/supplementary/process-billing-flag.service.js +++ b/app/services/licences/supplementary/process-billing-flag.service.js @@ -33,7 +33,7 @@ const PersistSupplementaryBillingFlagsService = require('./persist-supplementary * * @param {object} payload - The payload from the request */ -async function go (payload) { +async function go(payload) { try { const startTime = currentTimeInNanoseconds() const result = await _determineFlags(payload) @@ -46,7 +46,7 @@ async function go (payload) { } } -async function _determineFlags (payload) { +async function _determineFlags(payload) { if (payload.chargeVersionId) { return await DetermineChargeVersionFlagsService.go(payload.chargeVersionId) } else if (payload.returnId) { @@ -58,7 +58,7 @@ async function _determineFlags (payload) { } } -async function _determineTwoPartTariffYears (twoPartTariffBillingYears, result) { +async function _determineTwoPartTariffYears(twoPartTariffBillingYears, result) { const { endDate, startDate, regionId, flagForTwoPartTariffSupplementary } = result const years = DetermineBillingYearsService.go(startDate, endDate) @@ -69,13 +69,8 @@ async function _determineTwoPartTariffYears (twoPartTariffBillingYears, result) return DetermineExistingBillRunYearsService.go(regionId, years, flagForTwoPartTariffSupplementary) } -async function _setFlagForLicence (result) { - const { - licenceId, - flagForPreSrocSupplementary, - flagForSrocSupplementary, - flagForTwoPartTariffSupplementary - } = result +async function _setFlagForLicence(result) { + const { licenceId, flagForPreSrocSupplementary, flagForSrocSupplementary, flagForTwoPartTariffSupplementary } = result let twoPartTariffBillingYears = [] diff --git a/app/services/licences/supplementary/process-imported-licence.service.js b/app/services/licences/supplementary/process-imported-licence.service.js index ce9ed81d55..f808e2366a 100644 --- a/app/services/licences/supplementary/process-imported-licence.service.js +++ b/app/services/licences/supplementary/process-imported-licence.service.js @@ -18,7 +18,7 @@ const SROC_START_DATE = new Date('2022-04-01') * @param {object} importedLicence - Object representing the updated licence being imported * @param {string} licenceId - The UUID of the licence being imported */ -async function go (importedLicence, licenceId) { +async function go(importedLicence, licenceId) { const existingLicenceDetails = await FetchExistingLicenceDetailsService.go(licenceId) const earliestChangedDate = _earliestChangedDate(importedLicence, existingLicenceDetails) @@ -40,7 +40,7 @@ async function go (importedLicence, licenceId) { ) } -function _earliestChangedDate (importedLicence, existingLicenceDetails) { +function _earliestChangedDate(importedLicence, existingLicenceDetails) { const { endDate: currentFinancialYearEndDate } = determineCurrentFinancialYear() const changedDates = [] @@ -67,14 +67,14 @@ function _earliestChangedDate (importedLicence, existingLicenceDetails) { // Filter out those greater than the current financial year end date const filteredDates = changedDates.filter((changedDate) => { - return (changedDate < currentFinancialYearEndDate) + return changedDate < currentFinancialYearEndDate }) // Now work out the earliest end date from those that have changed return filteredDates.length > 0 ? new Date(Math.min(...filteredDates)) : null } -function _flagForPresrocSupplementary (existingLicenceDetails, earliestChangedDate) { +function _flagForPresrocSupplementary(existingLicenceDetails, earliestChangedDate) { const { flagged_for_presroc: flagged, pre_sroc_charge_versions: chargeVersions } = existingLicenceDetails // If the licence has no presroc charge versions return false. We check this before the existing flag, because this @@ -93,7 +93,7 @@ function _flagForPresrocSupplementary (existingLicenceDetails, earliestChangedDa return earliestChangedDate < SROC_START_DATE } -function _flagForSrocSupplementary (existingLicenceDetails) { +function _flagForSrocSupplementary(existingLicenceDetails) { const { sroc_charge_versions: chargeVersions } = existingLicenceDetails // If the licence has no SROC charge versions, return false. We check because it's an opportunity @@ -103,7 +103,7 @@ function _flagForSrocSupplementary (existingLicenceDetails) { return !!chargeVersions } -function _flagForTwoPartTariffSupplementary (existingLicenceDetails, earliestChangedDate) { +function _flagForTwoPartTariffSupplementary(existingLicenceDetails, earliestChangedDate) { const { two_part_tariff_charge_versions: chargeVersions } = existingLicenceDetails const billingYears = [] diff --git a/app/services/licences/supplementary/submit-mark-for-supplementary-billing.service.js b/app/services/licences/supplementary/submit-mark-for-supplementary-billing.service.js index bd1dcc536a..fcfab0c896 100644 --- a/app/services/licences/supplementary/submit-mark-for-supplementary-billing.service.js +++ b/app/services/licences/supplementary/submit-mark-for-supplementary-billing.service.js @@ -25,7 +25,7 @@ const SupplementaryYearValidator = require('../../../validators/licences/supplem * * @returns {Promise} The licence marked for supplementary billing */ -async function go (licenceId, payload, user) { +async function go(licenceId, payload, user) { const validationResult = _validate(payload) if (!validationResult) { @@ -50,17 +50,11 @@ async function go (licenceId, payload, user) { } } -async function _fetchLicenceData (licenceId) { - return LicenceModel.query() - .findById(licenceId) - .select([ - 'id', - 'licenceRef', - 'regionId' - ]) +async function _fetchLicenceData(licenceId) { + return LicenceModel.query().findById(licenceId).select(['id', 'licenceRef', 'regionId']) } -async function _flagLicenceYears (supplementaryYears, licenceId, user) { +async function _flagLicenceYears(supplementaryYears, licenceId, user) { if (supplementaryYears.includes('preSroc')) { await LegacyRequest.post('water', `licences/${licenceId}/mark-for-supplementary-billing`, user.id) @@ -87,7 +81,7 @@ async function _flagLicenceYears (supplementaryYears, licenceId, user) { await CreateLicenceSupplementaryYearService.go(licenceId, financialYearEnds, twoPartTariff) } -async function _getPageData (licenceId) { +async function _getPageData(licenceId) { const licenceData = await _fetchLicenceData(licenceId) const pageData = MarkForSupplementaryBillingPresenter.go(licenceData) @@ -95,7 +89,7 @@ async function _getPageData (licenceId) { return pageData } -function _validate (payload) { +function _validate(payload) { const validation = SupplementaryYearValidator.go(payload) if (!validation.error) { diff --git a/app/services/licences/view-licence-bills.service.js b/app/services/licences/view-licence-bills.service.js index f526d3d04a..54da15ed6c 100644 --- a/app/services/licences/view-licence-bills.service.js +++ b/app/services/licences/view-licence-bills.service.js @@ -19,13 +19,17 @@ const ViewLicenceService = require('./view-licence.service.js') * * @returns {Promise} an object representing the `pageData` needed by the licence bills template. */ -async function go (licenceId, auth, page) { +async function go(licenceId, auth, page) { const commonData = await ViewLicenceService.go(licenceId, auth) const billsData = await FetchLicenceBillsService.go(licenceId, page) const pageData = ViewLicenceBillsPresenter.go(billsData.bills) - const pagination = PaginatorPresenter.go(billsData.pagination.total, Number(page), `/system/licences/${licenceId}/bills`) + const pagination = PaginatorPresenter.go( + billsData.pagination.total, + Number(page), + `/system/licences/${licenceId}/bills` + ) return { activeTab: 'bills', diff --git a/app/services/licences/view-licence-communications.service.js b/app/services/licences/view-licence-communications.service.js index 4714a08728..9cafc844f2 100644 --- a/app/services/licences/view-licence-communications.service.js +++ b/app/services/licences/view-licence-communications.service.js @@ -19,13 +19,17 @@ const ViewLicenceCommunicationsPresenter = require('../../presenters/licences/vi * * @returns {Promise} an object representing the `pageData` needed by the licence communication template. */ -async function go (licenceId, auth, page) { +async function go(licenceId, auth, page) { const commonData = await ViewLicenceService.go(licenceId, auth) const communications = await FetchCommunicationsService.go(commonData.licenceRef, page) const communicationsData = ViewLicenceCommunicationsPresenter.go(communications.communications) - const pagination = PaginatorPresenter.go(communications.pagination.total, Number(page), `/system/licences/${licenceId}/communications`) + const pagination = PaginatorPresenter.go( + communications.pagination.total, + Number(page), + `/system/licences/${licenceId}/communications` + ) return { activeTab: 'communications', diff --git a/app/services/licences/view-licence-contact-details.service.js b/app/services/licences/view-licence-contact-details.service.js index d785f413bb..46d288b00a 100644 --- a/app/services/licences/view-licence-contact-details.service.js +++ b/app/services/licences/view-licence-contact-details.service.js @@ -15,7 +15,7 @@ const FetchLicenceContactDetailsService = require('./fetch-licence-contact-detai * * @returns {Promise} The view data for the licence contacts page */ -async function go (licenceId) { +async function go(licenceId) { const licence = await FetchLicenceContactDetailsService.go(licenceId) const formattedData = await ViewLicenceContactDetailsPresenter.go(licence) diff --git a/app/services/licences/view-licence-contacts.service.js b/app/services/licences/view-licence-contacts.service.js index 3e875da087..3fd0b33aac 100644 --- a/app/services/licences/view-licence-contacts.service.js +++ b/app/services/licences/view-licence-contacts.service.js @@ -19,7 +19,7 @@ const ViewLicenceService = require('./view-licence.service.js') * * @returns {Promise} an object representing the `pageData` needed by the licence contact details template. */ -async function go (licenceId, auth) { +async function go(licenceId, auth) { const commonData = await ViewLicenceService.go(licenceId, auth) const licenceContacts = await FetchLicenceContactsService.go(licenceId) diff --git a/app/services/licences/view-licence-history.service.js b/app/services/licences/view-licence-history.service.js index 873266f901..e3570b6705 100644 --- a/app/services/licences/view-licence-history.service.js +++ b/app/services/licences/view-licence-history.service.js @@ -15,7 +15,7 @@ const ViewLicenceHistoryPresenter = require('../../presenters/licences/view-lice * * @returns {Promise} an object representing the `pageData` needed by the licence history template. */ -async function go (licenceId) { +async function go(licenceId) { const licence = await FetchLicenceHistoryService.go(licenceId) const pageData = ViewLicenceHistoryPresenter.go(licence) diff --git a/app/services/licences/view-licence-points.service.js b/app/services/licences/view-licence-points.service.js index 982a70c778..79809dcf4e 100644 --- a/app/services/licences/view-licence-points.service.js +++ b/app/services/licences/view-licence-points.service.js @@ -15,7 +15,7 @@ const ViewLicencePointsPresenter = require('../../presenters/licences/view-licen * * @returns {Promise} an object representing the `pageData` needed by the licence points template */ -async function go (licenceId) { +async function go(licenceId) { const licencePoints = await FetchLicencePointsService.go(licenceId) const pageData = ViewLicencePointsPresenter.go(licencePoints) diff --git a/app/services/licences/view-licence-purposes.service.js b/app/services/licences/view-licence-purposes.service.js index 9e409b7d50..221a1ed2b1 100644 --- a/app/services/licences/view-licence-purposes.service.js +++ b/app/services/licences/view-licence-purposes.service.js @@ -15,7 +15,7 @@ const ViewLicencePurposesPresenter = require('../../presenters/licences/view-lic * * @returns {Promise} an object representing the `pageData` needed by the licence purposes template */ -async function go (licenceId) { +async function go(licenceId) { const licencePurposes = await FetchLicencePurposesService.go(licenceId) const pageData = ViewLicencePurposesPresenter.go(licencePurposes) diff --git a/app/services/licences/view-licence-returns.service.js b/app/services/licences/view-licence-returns.service.js index b8e7a0ad09..d9161c52b3 100644 --- a/app/services/licences/view-licence-returns.service.js +++ b/app/services/licences/view-licence-returns.service.js @@ -20,7 +20,7 @@ const ViewLicenceService = require('./view-licence.service.js') * * @returns {Promise} an object representing the `pageData` needed by the licence summary template. */ -async function go (licenceId, auth, page) { +async function go(licenceId, auth, page) { const commonData = await ViewLicenceService.go(licenceId, auth) const hasRequirements = await DetermineLicenceHasReturnVersionsService.go(licenceId) @@ -28,7 +28,11 @@ async function go (licenceId, auth, page) { const returnsData = await FetchLicenceReturnsService.go(licenceId, page) const pageData = ViewLicenceReturnsPresenter.go(returnsData.returns, hasRequirements, auth) - const pagination = PaginatorPresenter.go(returnsData.pagination.total, Number(page), `/system/licences/${licenceId}/returns`) + const pagination = PaginatorPresenter.go( + returnsData.pagination.total, + Number(page), + `/system/licences/${licenceId}/returns` + ) return { activeTab: 'returns', diff --git a/app/services/licences/view-licence-set-up.service.js b/app/services/licences/view-licence-set-up.service.js index 1f04683d75..10642a9ee1 100644 --- a/app/services/licences/view-licence-set-up.service.js +++ b/app/services/licences/view-licence-set-up.service.js @@ -20,7 +20,7 @@ const ViewLicenceService = require('./view-licence.service.js') * * @returns {Promise} an object representing the `pageData` needed by the licence set up template. */ -async function go (licenceId, auth) { +async function go(licenceId, auth) { const commonData = await ViewLicenceService.go(licenceId, auth) const agreements = await FetchAgreementsService.go(commonData.licenceRef) @@ -29,7 +29,12 @@ async function go (licenceId, auth) { const returnVersions = await FetchReturnVersionsService.go(licenceId) const licenceSetUpData = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) return { diff --git a/app/services/licences/view-licence-summary.service.js b/app/services/licences/view-licence-summary.service.js index d8543081f8..14dc24bf92 100644 --- a/app/services/licences/view-licence-summary.service.js +++ b/app/services/licences/view-licence-summary.service.js @@ -17,7 +17,7 @@ const ViewLicenceService = require('./view-licence.service.js') * * @returns {Promise} an object representing the `pageData` needed by the licence summary template. */ -async function go (licenceId, auth) { +async function go(licenceId, auth) { const commonData = await ViewLicenceService.go(licenceId, auth) const summaryLicenceData = await FetchLicenceSummaryService.go(licenceId) diff --git a/app/services/licences/view-licence.service.js b/app/services/licences/view-licence.service.js index 22b29adcfc..774d54accc 100644 --- a/app/services/licences/view-licence.service.js +++ b/app/services/licences/view-licence.service.js @@ -16,7 +16,7 @@ const ViewLicencePresenter = require('../../presenters/licences/view-licence.pre * * @returns {Promise} an object representing the `pageData` needed by the licence summary template. */ -async function go (licenceId, auth) { +async function go(licenceId, auth) { const licence = await FetchLicenceService.go(licenceId) const pageData = ViewLicencePresenter.go(licence, auth) diff --git a/app/services/monitoring-stations/fetch-monitoring-station.service.js b/app/services/monitoring-stations/fetch-monitoring-station.service.js index 6046a65fcc..c72083ab39 100644 --- a/app/services/monitoring-stations/fetch-monitoring-station.service.js +++ b/app/services/monitoring-stations/fetch-monitoring-station.service.js @@ -15,21 +15,14 @@ const MonitoringStationModel = require('../../models/monitoring-station.model.js * @returns {Promise} the matching instance of `MonitoringStationModel` populated with * the data needed for the view monitoring station page */ -async function go (monitoringStationId) { +async function go(monitoringStationId) { return _fetch(monitoringStationId) } -async function _fetch (monitoringStationId) { +async function _fetch(monitoringStationId) { return MonitoringStationModel.query() .findById(monitoringStationId) - .select([ - 'id', - 'gridReference', - 'label', - 'riverName', - 'stationReference', - 'wiskiId' - ]) + .select(['id', 'gridReference', 'label', 'riverName', 'stationReference', 'wiskiId']) .withGraphFetched('licenceMonitoringStations') .modifyGraph('licenceMonitoringStations', (licenceMonitoringStationsBuilder) => { licenceMonitoringStationsBuilder @@ -55,28 +48,21 @@ async function _fetch (monitoringStationId) { ]) .withGraphFetched('licence') .modifyGraph('licence', (licenceBuilder) => { - licenceBuilder - .select([ - 'id', - 'licenceRef' - ]) + licenceBuilder.select(['id', 'licenceRef']) }) .withGraphFetched('licenceVersionPurposeCondition') .modifyGraph('licenceVersionPurposeCondition', (licenceVersionPurposeConditionBuilder) => { licenceVersionPurposeConditionBuilder - .select([ - 'id' - ]) + .select(['id']) .withGraphFetched('licenceVersionPurpose') .modifyGraph('licenceVersionPurpose', (licenceVersionPurposeBuilder) => { - licenceVersionPurposeBuilder - .select([ - 'id', - 'abstractionPeriodEndDay', - 'abstractionPeriodEndMonth', - 'abstractionPeriodStartMonth', - 'abstractionPeriodStartDay' - ]) + licenceVersionPurposeBuilder.select([ + 'id', + 'abstractionPeriodEndDay', + 'abstractionPeriodEndMonth', + 'abstractionPeriodStartMonth', + 'abstractionPeriodStartDay' + ]) }) }) }) diff --git a/app/services/monitoring-stations/view.service.js b/app/services/monitoring-stations/view.service.js index a8e370d7ae..38757fe010 100644 --- a/app/services/monitoring-stations/view.service.js +++ b/app/services/monitoring-stations/view.service.js @@ -16,7 +16,7 @@ const ViewPresenter = require('../../presenters/monitoring-stations/view.present * * @returns {Promise} page data needed by the view template */ -async function go (monitoringStationId, auth) { +async function go(monitoringStationId, auth) { const monitoringStation = await FetchMonitoringStationService.go(monitoringStationId) const pageData = ViewPresenter.go(monitoringStation, auth) diff --git a/app/services/plugins/auth.service.js b/app/services/plugins/auth.service.js index e0dfe5e19b..28bbf71ba5 100644 --- a/app/services/plugins/auth.service.js +++ b/app/services/plugins/auth.service.js @@ -44,7 +44,7 @@ const FetchUserRolesAndGroupsService = require('../idm/fetch-user-roles-and-grou * * @returns {object} the permission object */ -async function go (userId) { +async function go(userId) { const { user, roles, groups } = await FetchUserRolesAndGroupsService.go(userId) // We put each role's name into the scope array for hapi to use for its scope authorisation @@ -79,7 +79,7 @@ async function go (userId) { * * @private */ -function _permission (scope = []) { +function _permission(scope = []) { const billRuns = scope.includes('billing') const manageRoles = [ @@ -95,10 +95,7 @@ function _permission (scope = []) { return manageRoles.includes(role) }) - const abstractionReformRoles = [ - 'ar_user', - 'ar_approver' - ] + const abstractionReformRoles = ['ar_user', 'ar_approver'] const abstractionReform = scope.some((role) => { return abstractionReformRoles.includes(role) }) diff --git a/app/services/plugins/error-pages.service.js b/app/services/plugins/error-pages.service.js index 5e0aa90825..628d36ce4a 100644 --- a/app/services/plugins/error-pages.service.js +++ b/app/services/plugins/error-pages.service.js @@ -20,7 +20,7 @@ * @returns {object} Contains the properties `stopResponse:` and `statusCode:` which are used by the plugin to * decide how to direct the response */ -function go (request) { +function go(request) { const stopResponse = _stopResponse(request) let statusCode = _extractStatusCode(request) @@ -47,7 +47,7 @@ function go (request) { * * @private */ -function _extractStatusCode (request) { +function _extractStatusCode(request) { const { response } = request if (response.isBoom) { @@ -57,7 +57,7 @@ function _extractStatusCode (request) { return response.statusCode } -function _logError (statusCode, request) { +function _logError(statusCode, request) { const { response } = request if (statusCode === 404) { @@ -88,7 +88,7 @@ function _logError (statusCode, request) { * * @private */ -function _stopResponse (request) { +function _stopResponse(request) { // `isBoom` is only present when dealing with requests that have resulted in an error being thrown. // `plainOutput` is only present when the route's `options:` property has `app: { plainOutput: true }` applied. // !! typecasts undefined values into booleans which means we can be explicit in what we are dealing with. @@ -112,7 +112,7 @@ function _stopResponse (request) { * * @private */ -function _determineSafeStatusCode (statusCode) { +function _determineSafeStatusCode(statusCode) { // The status code will be a 2xx or 3xx so safe to return as is if (statusCode < 400) { return statusCode diff --git a/app/services/plugins/filter-routes.service.js b/app/services/plugins/filter-routes.service.js index 6b028a6e00..f3bcfbdc0a 100644 --- a/app/services/plugins/filter-routes.service.js +++ b/app/services/plugins/filter-routes.service.js @@ -29,7 +29,7 @@ * @returns {object[]} an array of Hapi routes, filtered depending on the current environment and whether any paths * have been registered as needing filtering */ -function go (routes, environment) { +function go(routes, environment) { if (_protectedEnvironment(environment)) { return _filteredRoutes(routes) } @@ -37,11 +37,11 @@ function go (routes, environment) { return routes } -function _protectedEnvironment (environment) { +function _protectedEnvironment(environment) { return ['prd', 'pre'].includes(environment) } -function _filteredRoutes (routes) { +function _filteredRoutes(routes) { return routes.filter((route) => { return !route?.options?.app?.excludeFromProd }) diff --git a/app/services/plugins/hapi-pino-ignore-request.service.js b/app/services/plugins/hapi-pino-ignore-request.service.js index 91ae80d7c3..1f3fe430b2 100644 --- a/app/services/plugins/hapi-pino-ignore-request.service.js +++ b/app/services/plugins/hapi-pino-ignore-request.service.js @@ -53,7 +53,7 @@ * * @returns {boolean} true if the request should be ignored, else false */ -function go (options, request) { +function go(options, request) { const staticPaths = ['/', '/import/licence/legacy', '/status', '/favicon.ico'] // If request is a known path ignore it diff --git a/app/services/plugins/hapi-pino-log-in-test.service.js b/app/services/plugins/hapi-pino-log-in-test.service.js index fe786ba614..f94c93d0b4 100644 --- a/app/services/plugins/hapi-pino-log-in-test.service.js +++ b/app/services/plugins/hapi-pino-log-in-test.service.js @@ -18,7 +18,7 @@ * * @returns {object} an empty object or one containing Hapi-pino config to tell it not to log events */ -function go (logInTest) { +function go(logInTest) { if (process.env.NODE_ENV !== 'test' || logInTest) { return {} } diff --git a/app/services/plugins/payload-cleaning.service.js b/app/services/plugins/payload-cleaning.service.js index 7c4fa53a98..077b63d2d1 100644 --- a/app/services/plugins/payload-cleaning.service.js +++ b/app/services/plugins/payload-cleaning.service.js @@ -77,7 +77,7 @@ const Sanitizer = require('sanitizer') * * @returns {object} - returns a 'clean' payload object */ -function go (payload) { +function go(payload) { return _cleanObject(payload) } @@ -100,7 +100,7 @@ function go (payload) { * * @private */ -function _cleanObject (obj) { +function _cleanObject(obj) { if (obj === null) { return null } @@ -146,7 +146,7 @@ function _cleanObject (obj) { * * @private */ -function _cleanArray (array) { +function _cleanArray(array) { const cleanedArray = [] for (const item of array) { @@ -180,13 +180,13 @@ function _cleanArray (array) { * * @private */ -function _keepValue (value) { +function _keepValue(value) { if (value === null) { return false } else if (typeof value === 'object') { - return (Object.keys(value).length > 0) + return Object.keys(value).length > 0 } else if (typeof value === 'string') { - return (value !== '') + return value !== '' } // If its not null, an object or a string assume we need to keep it! @@ -210,7 +210,7 @@ function _keepValue (value) { * * @private */ -function _cleanValue (value) { +function _cleanValue(value) { if (typeof value === 'string') { let cleanedValue = Sanitizer.sanitize(value) diff --git a/app/services/return-versions/fetch-return-version.service.js b/app/services/return-versions/fetch-return-version.service.js index 0998249f78..2c0032ff6a 100644 --- a/app/services/return-versions/fetch-return-version.service.js +++ b/app/services/return-versions/fetch-return-version.service.js @@ -15,30 +15,18 @@ const ReturnVersionModel = require('../../models/return-version.model.js') * @returns {Promise} The return version plus linked licence, return requirements (requirement, * points, purposes) */ -async function go (id) { +async function go(id) { return _fetch(id) } -async function _fetch (id) { +async function _fetch(id) { return ReturnVersionModel.query() .findById(id) - .select([ - 'createdAt', - 'id', - 'multipleUpload', - 'notes', - 'reason', - 'quarterlyReturns', - 'startDate', - 'status' - ]) + .select(['createdAt', 'id', 'multipleUpload', 'notes', 'reason', 'quarterlyReturns', 'startDate', 'status']) .modify('history') .withGraphFetched('licence') .modifyGraph('licence', (builder) => { - builder.select([ - 'id', - 'licenceRef' - ]).modify('licenceHolder') + builder.select(['id', 'licenceRef']).modify('licenceHolder') }) .withGraphFetched('returnRequirements') .modifyGraph('returnRequirements', (returnRequirementsBuilder) => { @@ -62,30 +50,22 @@ async function _fetch (id) { .orderBy('legacyId', 'asc') .withGraphFetched('points') .modifyGraph('points', (pointsBuilder) => { - pointsBuilder - .select([ - 'points.description', - 'points.id', - 'points.ngr1', - 'points.ngr2', - 'points.ngr3', - 'points.ngr4' - ]) + pointsBuilder.select([ + 'points.description', + 'points.id', + 'points.ngr1', + 'points.ngr2', + 'points.ngr3', + 'points.ngr4' + ]) }) .withGraphFetched('returnRequirementPurposes') .modifyGraph('returnRequirementPurposes', (returnRequirementPurposesBuilder) => { returnRequirementPurposesBuilder - .select([ - 'alias', - 'id' - ]) + .select(['alias', 'id']) .withGraphFetched('purpose') .modifyGraph('purpose', (builder) => { - builder - .select([ - 'description', - 'id' - ]) + builder.select(['description', 'id']) }) }) }) diff --git a/app/services/return-versions/setup/abstraction-period.service.js b/app/services/return-versions/setup/abstraction-period.service.js index 3bd34de5b2..1d259a64dd 100644 --- a/app/services/return-versions/setup/abstraction-period.service.js +++ b/app/services/return-versions/setup/abstraction-period.service.js @@ -19,7 +19,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the abstraction period page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const formattedData = AbstractionPeriodPresenter.go(session, requirementIndex) diff --git a/app/services/return-versions/setup/add.service.js b/app/services/return-versions/setup/add.service.js index 93e6a9fed3..faf4fd3a08 100644 --- a/app/services/return-versions/setup/add.service.js +++ b/app/services/return-versions/setup/add.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {number} - The index of the new requirement. Needed by the setup pages so they know which requirement to * display and update */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) await _save(session) @@ -26,7 +26,7 @@ async function go (sessionId) { return session.requirements.length - 1 } -async function _save (session) { +async function _save(session) { session.requirements.push({}) session.checkPageVisited = false diff --git a/app/services/return-versions/setup/additional-submission-options.service.js b/app/services/return-versions/setup/additional-submission-options.service.js index 9497cca926..5617143707 100644 --- a/app/services/return-versions/setup/additional-submission-options.service.js +++ b/app/services/return-versions/setup/additional-submission-options.service.js @@ -20,7 +20,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the points page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = AdditionalSubmissionOptionsPresenter.go(session) diff --git a/app/services/return-versions/setup/agreements-exceptions.service.js b/app/services/return-versions/setup/agreements-exceptions.service.js index e0f35beb90..2eb09018bb 100644 --- a/app/services/return-versions/setup/agreements-exceptions.service.js +++ b/app/services/return-versions/setup/agreements-exceptions.service.js @@ -19,7 +19,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the agreements and exceptions page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const formattedData = AgreementsExceptionsPresenter.go(session, requirementIndex) diff --git a/app/services/return-versions/setup/cancel.service.js b/app/services/return-versions/setup/cancel.service.js index 0554f63662..e47dadb289 100644 --- a/app/services/return-versions/setup/cancel.service.js +++ b/app/services/return-versions/setup/cancel.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the cancel requirements page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = CancelPresenter.go(session) diff --git a/app/services/return-versions/setup/check/check.service.js b/app/services/return-versions/setup/check/check.service.js index 5948f9dc55..9e53248bf2 100644 --- a/app/services/return-versions/setup/check/check.service.js +++ b/app/services/return-versions/setup/check/check.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../../models/session.model.js') * * @returns {Promise} page data needed by the view template */ -async function go (sessionId, yar) { +async function go(sessionId, yar) { const session = await SessionModel.query().findById(sessionId) await _markCheckPageVisited(session) @@ -37,13 +37,13 @@ async function go (sessionId, yar) { } } -async function _markCheckPageVisited (session) { +async function _markCheckPageVisited(session) { session.checkPageVisited = true return session.$update() } -async function _returnRequirements (session) { +async function _returnRequirements(session) { const { licence, requirements, journey } = session const points = await FetchPointsService.go(licence.id) diff --git a/app/services/return-versions/setup/check/generate-return-version-requirements.service.js b/app/services/return-versions/setup/check/generate-return-version-requirements.service.js index 9a92fcb285..c9e4314266 100644 --- a/app/services/return-versions/setup/check/generate-return-version-requirements.service.js +++ b/app/services/return-versions/setup/check/generate-return-version-requirements.service.js @@ -20,7 +20,7 @@ const ReturnRequirementModel = require('../../../../models/return-requirement.mo * * @returns {Promise} The new return version requirements data for a licence */ -async function go (licenceId, requirements) { +async function go(licenceId, requirements) { const naldRegionId = await _fetchNaldRegionId(licenceId) const returnRequirements = [] @@ -59,7 +59,7 @@ async function go (licenceId, requirements) { return returnRequirements } -async function _fetchNaldRegionId (licenceId) { +async function _fetchNaldRegionId(licenceId) { const { naldRegionId } = await LicenceModel.query() .findById(licenceId) .select('region.naldRegionId') @@ -68,7 +68,7 @@ async function _fetchNaldRegionId (licenceId) { return naldRegionId } -async function _generateReturnRequirementPurposes (licenceId, purposes) { +async function _generateReturnRequirementPurposes(licenceId, purposes) { const returnRequirementPurposes = [] for (const purpose of purposes) { @@ -93,7 +93,7 @@ async function _generateReturnRequirementPurposes (licenceId, purposes) { return returnRequirementPurposes } -async function _nextLegacyId (naldRegionId) { +async function _nextLegacyId(naldRegionId) { const { lastLegacyId } = await ReturnRequirementModel.query() .max('legacyId as lastLegacyId') .whereLike('externalId', `${naldRegionId}%`) diff --git a/app/services/return-versions/setup/check/generate-return-version.service.js b/app/services/return-versions/setup/check/generate-return-version.service.js index 60a595ee5e..ca33e82496 100644 --- a/app/services/return-versions/setup/check/generate-return-version.service.js +++ b/app/services/return-versions/setup/check/generate-return-version.service.js @@ -21,7 +21,7 @@ const { isQuarterlyReturnSubmissions } = require('../../../../lib/dates.lib.js') * * @returns {Promise} The new return version and requirement data for a licence */ -async function go (sessionData, userId) { +async function go(sessionData, userId) { const nextVersionNumber = await _nextVersionNumber(sessionData.licence.id) const returnVersion = await _generateReturnVersion(nextVersionNumber, sessionData, userId) @@ -33,7 +33,7 @@ async function go (sessionData, userId) { } } -async function _generateReturnRequirements (sessionData) { +async function _generateReturnRequirements(sessionData) { // When no returns are required a return version is created without any return requirements if (sessionData.journey === 'no-returns-required') { return [] @@ -47,7 +47,7 @@ async function _generateReturnRequirements (sessionData) { return returnRequirements } -async function _generateReturnVersion (nextVersionNumber, sessionData, userId) { +async function _generateReturnVersion(nextVersionNumber, sessionData, userId) { const startDate = new Date(sessionData.returnVersionStartDate) let endDate = null let quarterlyReturns = false @@ -74,7 +74,7 @@ async function _generateReturnVersion (nextVersionNumber, sessionData, userId) { } } -async function _nextVersionNumber (licenceId) { +async function _nextVersionNumber(licenceId) { const { lastVersionNumber } = await ReturnVersionModel.query() .max('version as lastVersionNumber') .where({ licenceId }) diff --git a/app/services/return-versions/setup/check/persist-return-version.service.js b/app/services/return-versions/setup/check/persist-return-version.service.js index 2d2b5a52e8..b7020db86b 100644 --- a/app/services/return-versions/setup/check/persist-return-version.service.js +++ b/app/services/return-versions/setup/check/persist-return-version.service.js @@ -19,7 +19,7 @@ const ReturnVersionModel = require('../../../../models/return-version.model.js') * * @param {object} returnVersionData - The return version data required to persist a new return version for a licence */ -async function go (returnVersionData) { +async function go(returnVersionData) { const { returnRequirements, returnVersion } = returnVersionData const { id: returnVersionId } = await ReturnVersionModel.query().insert(returnVersion) @@ -27,40 +27,39 @@ async function go (returnVersionData) { await _persistReturnRequirements(returnRequirements, returnVersionId) } -async function _persistReturnRequirements (returnRequirements, returnVersionId) { +async function _persistReturnRequirements(returnRequirements, returnVersionId) { for (const returnRequirement of returnRequirements) { - const { id: returnRequirementId } = await ReturnRequirementModel.query() - .insert({ - abstractionPeriodStartDay: returnRequirement.abstractionPeriodStartDay, - abstractionPeriodStartMonth: returnRequirement.abstractionPeriodStartMonth, - abstractionPeriodEndDay: returnRequirement.abstractionPeriodEndDay, - abstractionPeriodEndMonth: returnRequirement.abstractionPeriodEndMonth, - collectionFrequency: returnRequirement.collectionFrequency, - externalId: returnRequirement.externalId, - fiftySixException: returnRequirement.fiftySixException, - gravityFill: returnRequirement.gravityFill, - legacyId: returnRequirement.legacyId, - reabstraction: returnRequirement.reabstraction, - reportingFrequency: returnRequirement.reportingFrequency, - returnsFrequency: returnRequirement.returnsFrequency, - returnVersionId, - siteDescription: returnRequirement.siteDescription, - summer: returnRequirement.summer, - twoPartTariff: returnRequirement.twoPartTariff - }) + const { id: returnRequirementId } = await ReturnRequirementModel.query().insert({ + abstractionPeriodStartDay: returnRequirement.abstractionPeriodStartDay, + abstractionPeriodStartMonth: returnRequirement.abstractionPeriodStartMonth, + abstractionPeriodEndDay: returnRequirement.abstractionPeriodEndDay, + abstractionPeriodEndMonth: returnRequirement.abstractionPeriodEndMonth, + collectionFrequency: returnRequirement.collectionFrequency, + externalId: returnRequirement.externalId, + fiftySixException: returnRequirement.fiftySixException, + gravityFill: returnRequirement.gravityFill, + legacyId: returnRequirement.legacyId, + reabstraction: returnRequirement.reabstraction, + reportingFrequency: returnRequirement.reportingFrequency, + returnsFrequency: returnRequirement.returnsFrequency, + returnVersionId, + siteDescription: returnRequirement.siteDescription, + summer: returnRequirement.summer, + twoPartTariff: returnRequirement.twoPartTariff + }) await _persistReturnRequirementsPoints(returnRequirement.points, returnRequirementId) await _persistReturnRequirementsPurposes(returnRequirement.returnRequirementPurposes, returnRequirementId) } } -async function _persistReturnRequirementsPoints (points, returnRequirementId) { +async function _persistReturnRequirementsPoints(points, returnRequirementId) { for (const point of points) { await ReturnRequirementPointModel.query().insert({ pointId: point, returnRequirementId }) } } -async function _persistReturnRequirementsPurposes (returnRequirementPurposes, returnRequirementId) { +async function _persistReturnRequirementsPurposes(returnRequirementPurposes, returnRequirementId) { for (const returnRequirementPurpose of returnRequirementPurposes) { await ReturnRequirementPurposeModel.query().insert({ alias: returnRequirementPurpose.alias, diff --git a/app/services/return-versions/setup/check/process-existing-return-versions.service.js b/app/services/return-versions/setup/check/process-existing-return-versions.service.js index 3b440d36de..f211f46d82 100644 --- a/app/services/return-versions/setup/check/process-existing-return-versions.service.js +++ b/app/services/return-versions/setup/check/process-existing-return-versions.service.js @@ -20,7 +20,7 @@ const ReturnVersionModel = require('../../../../models/return-version.model.js') * @returns {Promise} The calculated `endDate` for the new return version if there is one. Null will be returned * if there is no `endDate` */ -async function go (licenceId, newVersionStartDate) { +async function go(licenceId, newVersionStartDate) { const previousVersions = await _previousVersions(licenceId) const previousVersionEndDate = _previousVersionEndDate(newVersionStartDate) @@ -74,10 +74,9 @@ async function go (licenceId, newVersionStartDate) { * * @private */ -async function _endLatestVersion (previousVersions, newVersionStartDate, endDate) { +async function _endLatestVersion(previousVersions, newVersionStartDate, endDate) { const matchedReturnVersion = previousVersions.find((previousVersion) => { - return previousVersion.startDate < newVersionStartDate && - previousVersion.endDate === null + return previousVersion.startDate < newVersionStartDate && previousVersion.endDate === null }) if (!matchedReturnVersion) { @@ -113,10 +112,9 @@ async function _endLatestVersion (previousVersions, newVersionStartDate, endDate * * @private */ -async function _insertBetweenVersions (previousVersions, newVersionStartDate, endDate) { +async function _insertBetweenVersions(previousVersions, newVersionStartDate, endDate) { const matchedReturnVersion = previousVersions.find((previousVersion) => { - return previousVersion.startDate < newVersionStartDate && - previousVersion.endDate > newVersionStartDate + return previousVersion.startDate < newVersionStartDate && previousVersion.endDate > newVersionStartDate }) if (!matchedReturnVersion) { @@ -130,7 +128,7 @@ async function _insertBetweenVersions (previousVersions, newVersionStartDate, en return newVersionEndDate } -function _previousVersionEndDate (newVersionStartDate) { +function _previousVersionEndDate(newVersionStartDate) { // NOTE: You have to create a new date from newVersionStartDate else when we call setDate we amend the source // newVersionStartDate passed to the service. const previousVersionEndDate = new Date(newVersionStartDate) @@ -140,7 +138,7 @@ function _previousVersionEndDate (newVersionStartDate) { return previousVersionEndDate } -function _previousVersions (licenceId) { +function _previousVersions(licenceId) { return ReturnVersionModel.query() .select(['endDate', 'id', 'startDate']) .where('licenceId', licenceId) @@ -173,14 +171,13 @@ function _previousVersions (licenceId) { * * @private */ -async function _replaceLatestVersion (previousVersions, newVersionStartDate) { +async function _replaceLatestVersion(previousVersions, newVersionStartDate) { const matchedReturnVersion = previousVersions.find((previousVersion) => { // NOTE: When you use the equality operator JavaScript will check for reference equality. Dates being objects this // will always return false, even though they refer to the exact same time. This means you need to convert them to // a more primitive value like a string or number first. `getTime()` seems to be the winner according to // stack overflow https://stackoverflow.com/a/4587089/6117745 - return previousVersion.startDate.getTime() === newVersionStartDate.getTime() && - previousVersion.endDate === null + return previousVersion.startDate.getTime() === newVersionStartDate.getTime() && previousVersion.endDate === null }) if (!matchedReturnVersion) { @@ -216,10 +213,12 @@ async function _replaceLatestVersion (previousVersions, newVersionStartDate) { * * @private */ -async function _replacePreviousVersion (previousVersions, newVersionStartDate) { +async function _replacePreviousVersion(previousVersions, newVersionStartDate) { const matchedReturnVersion = previousVersions.find((previousVersion) => { - return previousVersion.startDate.getTime() === newVersionStartDate.getTime() && + return ( + previousVersion.startDate.getTime() === newVersionStartDate.getTime() && previousVersion.endDate >= newVersionStartDate + ) }) if (!matchedReturnVersion) { diff --git a/app/services/return-versions/setup/check/submit-check.service.js b/app/services/return-versions/setup/check/submit-check.service.js index 2de3564008..ceb69c0ad8 100644 --- a/app/services/return-versions/setup/check/submit-check.service.js +++ b/app/services/return-versions/setup/check/submit-check.service.js @@ -22,7 +22,7 @@ const SessionModel = require('../../../../models/session.model.js') * * @returns {string} The licence ID */ -async function go (sessionId, userId) { +async function go(sessionId, userId) { const session = await SessionModel.query().findById(sessionId) const returnVersionData = await GenerateReturnVersionService.go(session.data, userId) diff --git a/app/services/return-versions/setup/delete-note.service.js b/app/services/return-versions/setup/delete-note.service.js index be04a46bed..775f2ab6c2 100644 --- a/app/services/return-versions/setup/delete-note.service.js +++ b/app/services/return-versions/setup/delete-note.service.js @@ -16,7 +16,7 @@ const SessionModel = require('../../../models/session.model.js') * @param {string} sessionId - The id of the current session * @param {object} yar - The Hapi `request.yar` session manager passed on by the controller */ -async function go (sessionId, yar) { +async function go(sessionId, yar) { const session = await SessionModel.query().findById(sessionId) const notification = { title: 'Removed', @@ -28,7 +28,7 @@ async function go (sessionId, yar) { await _save(session) } -async function _save (session) { +async function _save(session) { delete session.note return session.$update() diff --git a/app/services/return-versions/setup/existing/existing.service.js b/app/services/return-versions/setup/existing/existing.service.js index e7179103b9..022fda4d7e 100644 --- a/app/services/return-versions/setup/existing/existing.service.js +++ b/app/services/return-versions/setup/existing/existing.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../../models/session.model.js') * * @returns {Promise} The view data for the purpose page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = ExistingPresenter.go(session) diff --git a/app/services/return-versions/setup/existing/fetch-existing-requirements.service.js b/app/services/return-versions/setup/existing/fetch-existing-requirements.service.js index 27f32a776b..2b02bc521c 100644 --- a/app/services/return-versions/setup/existing/fetch-existing-requirements.service.js +++ b/app/services/return-versions/setup/existing/fetch-existing-requirements.service.js @@ -18,16 +18,14 @@ const ReturnVersionModel = require('../../../../models/return-version.model.js') * * @returns {Promise} the matching return version and related return requirements */ -async function go (returnVersionId) { +async function go(returnVersionId) { return _fetch(returnVersionId) } -async function _fetch (returnVersionId) { +async function _fetch(returnVersionId) { return ReturnVersionModel.query() .findById(returnVersionId) - .select([ - 'id' - ]) + .select(['id']) .withGraphFetched('returnRequirements') .modifyGraph('returnRequirements', (returnRequirementsBuilder) => { returnRequirementsBuilder @@ -49,27 +47,15 @@ async function _fetch (returnVersionId) { .orderBy('siteDescription', 'asc') .withGraphFetched('points') .modifyGraph('points', (pointsBuilder) => { - pointsBuilder - .select([ - 'points.id', - 'points.description' - ]) + pointsBuilder.select(['points.id', 'points.description']) }) .withGraphFetched('returnRequirementPurposes') .modifyGraph('returnRequirementPurposes', (returnRequirementPurposesBuilder) => { returnRequirementPurposesBuilder - .select([ - 'id', - 'alias', - 'purposeId' - ]) + .select(['id', 'alias', 'purposeId']) .withGraphFetched('purpose') .modifyGraph('purpose', (purposeBuilder) => { - purposeBuilder - .select([ - 'id', - 'description' - ]) + purposeBuilder.select(['id', 'description']) }) }) }) diff --git a/app/services/return-versions/setup/existing/generate-from-existing-requirements.service.js b/app/services/return-versions/setup/existing/generate-from-existing-requirements.service.js index ea74b46f3e..052303f3ea 100644 --- a/app/services/return-versions/setup/existing/generate-from-existing-requirements.service.js +++ b/app/services/return-versions/setup/existing/generate-from-existing-requirements.service.js @@ -23,13 +23,13 @@ const FetchExistingRequirementsService = require('./fetch-existing-requirements. * @returns {Promise} an array of return requirements generated from the existing return version and ready to * be persisted to the setup session */ -async function go (returnVersionId) { +async function go(returnVersionId) { const returnVersion = await FetchExistingRequirementsService.go(returnVersionId) return _transformForSetup(returnVersion) } -function _agreementExceptions (returnRequirement) { +function _agreementExceptions(returnRequirement) { const { fiftySixException, gravityFill, reabstraction, twoPartTariff } = returnRequirement const agreementsExceptions = [] @@ -56,13 +56,13 @@ function _agreementExceptions (returnRequirement) { return agreementsExceptions } -function _points (points) { +function _points(points) { return points.map((point) => { return point.id }) } -function _purposes (returnRequirementPurposes) { +function _purposes(returnRequirementPurposes) { return returnRequirementPurposes.map((returnRequirementPurpose) => { const { description, id } = returnRequirementPurpose.purpose @@ -74,7 +74,7 @@ function _purposes (returnRequirementPurposes) { }) } -function _siteDescription (siteDescription, points) { +function _siteDescription(siteDescription, points) { if (siteDescription) { return siteDescription } @@ -82,7 +82,7 @@ function _siteDescription (siteDescription, points) { return points[0].description } -function _transformForSetup (returnVersion) { +function _transformForSetup(returnVersion) { const { returnRequirements } = returnVersion return returnRequirements.map((returnRequirement) => { diff --git a/app/services/return-versions/setup/existing/submit-existing.service.js b/app/services/return-versions/setup/existing/submit-existing.service.js index a4828b94c0..d16b730fc4 100644 --- a/app/services/return-versions/setup/existing/submit-existing.service.js +++ b/app/services/return-versions/setup/existing/submit-existing.service.js @@ -26,7 +26,7 @@ const SessionModel = require('../../../../models/session.model.js') * @returns {Promise} If no errors an empty object else the page data for the existing page including the * validation error details */ -async function go (sessionId, payload) { +async function go(sessionId, payload) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload, session) @@ -47,14 +47,16 @@ async function go (sessionId, payload) { } } -async function _save (session, payload) { +async function _save(session, payload) { session.requirements = await GenerateFromExistingRequirementsService.go(payload.existing) return session.$update() } -function _validate (payload, session) { - const { licence: { returnVersions } } = session +function _validate(payload, session) { + const { + licence: { returnVersions } + } = session const validation = ExistingValidator.go(payload, returnVersions) diff --git a/app/services/return-versions/setup/fetch-points.service.js b/app/services/return-versions/setup/fetch-points.service.js index 75a8c812c0..bd4e5b52fb 100644 --- a/app/services/return-versions/setup/fetch-points.service.js +++ b/app/services/return-versions/setup/fetch-points.service.js @@ -14,7 +14,7 @@ const LicenceModel = require('../../../models/licence.model.js') * * @returns {Promise} All LicenceVersionPurposePoints for the matching licenceId */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } @@ -24,21 +24,14 @@ async function go (licenceId) { // // It made sense to go from licence to the points via our 'currentVersion' modifier. It just means we need to bring // the points back into a single array afterwards. -async function _fetch (licenceId) { +async function _fetch(licenceId) { const licence = await LicenceModel.query() .findById(licenceId) .select(['id']) .modify('currentVersion') .withGraphFetched('licenceVersions.licenceVersionPurposes.points') .modifyGraph('licenceVersions.licenceVersionPurposes.points', (builder) => { - builder.select([ - 'points.id', - 'points.description', - 'points.ngr1', - 'points.ngr2', - 'points.ngr3', - 'points.ngr4' - ]) + builder.select(['points.id', 'points.description', 'points.ngr1', 'points.ngr2', 'points.ngr3', 'points.ngr4']) }) const points = [] diff --git a/app/services/return-versions/setup/fetch-purposes.service.js b/app/services/return-versions/setup/fetch-purposes.service.js index 9af946eb44..2229f6195a 100644 --- a/app/services/return-versions/setup/fetch-purposes.service.js +++ b/app/services/return-versions/setup/fetch-purposes.service.js @@ -14,25 +14,20 @@ const PurposeModel = require('../../../models/purpose.model.js') * * @returns {Promise} The distinct purposes for the matching licence's current version */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } -async function _fetch (licenceId) { +async function _fetch(licenceId) { return PurposeModel.query() - .select([ - 'purposes.id', - 'purposes.description' - ]) + .select(['purposes.id', 'purposes.description']) .whereExists( PurposeModel.relatedQuery('licenceVersionPurposes') .innerJoin('licenceVersions', 'licenceVersions.id', 'licenceVersionPurposes.licenceVersionId') .where('licenceVersions.licenceId', licenceId) .where('licenceVersions.status', 'current') ) - .orderBy([ - { column: 'purposes.description', order: 'asc' } - ]) + .orderBy([{ column: 'purposes.description', order: 'asc' }]) } module.exports = { diff --git a/app/services/return-versions/setup/frequency-collected.service.js b/app/services/return-versions/setup/frequency-collected.service.js index 85a4b8249c..c32867ad05 100644 --- a/app/services/return-versions/setup/frequency-collected.service.js +++ b/app/services/return-versions/setup/frequency-collected.service.js @@ -19,7 +19,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the frequency collected page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const formattedData = FrequencyCollectedPresenter.go(session, requirementIndex) diff --git a/app/services/return-versions/setup/frequency-reported.service.js b/app/services/return-versions/setup/frequency-reported.service.js index af848b99e6..f9c6e28787 100644 --- a/app/services/return-versions/setup/frequency-reported.service.js +++ b/app/services/return-versions/setup/frequency-reported.service.js @@ -19,7 +19,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the frequency reported page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const formattedData = FrequencyReportedPresenter.go(session, requirementIndex) diff --git a/app/services/return-versions/setup/initiate-session.service.js b/app/services/return-versions/setup/initiate-session.service.js index 238c482f39..dffda47306 100644 --- a/app/services/return-versions/setup/initiate-session.service.js +++ b/app/services/return-versions/setup/initiate-session.service.js @@ -26,7 +26,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} the newly created session record */ -async function go (licenceId, journey) { +async function go(licenceId, journey) { const licence = await _fetchLicence(licenceId) const data = _data(licence, journey) @@ -34,7 +34,7 @@ async function go (licenceId, journey) { return _createSession(data) } -async function _createSession (data) { +async function _createSession(data) { const session = await SessionModel.query() .insert({ data @@ -44,7 +44,7 @@ async function _createSession (data) { return session } -function _data (licence, journey) { +function _data(licence, journey) { const { id, licenceRef, licenceVersions, returnVersions, startDate, waterUndertaker } = licence const ends = licence.$ends() @@ -66,36 +66,18 @@ function _data (licence, journey) { } } -async function _fetchLicence (licenceId) { +async function _fetchLicence(licenceId) { const licence = await LicenceModel.query() .findById(licenceId) - .select([ - 'id', - 'expiredDate', - 'lapsedDate', - 'licenceRef', - 'revokedDate', - 'startDate', - 'waterUndertaker' - ]) + .select(['id', 'expiredDate', 'lapsedDate', 'licenceRef', 'revokedDate', 'startDate', 'waterUndertaker']) .withGraphFetched('licenceVersions') .modifyGraph('licenceVersions', (builder) => { - builder - .select([ - 'id', - 'startDate' - ]) - .where('status', 'current') - .orderBy('startDate', 'desc') + builder.select(['id', 'startDate']).where('status', 'current').orderBy('startDate', 'desc') }) .withGraphFetched('returnVersions') .modifyGraph('returnVersions', (builder) => { builder - .select([ - 'id', - 'startDate', - 'reason' - ]) + .select(['id', 'startDate', 'reason']) .where('status', 'current') // A return version must include return requirements in order for us to be able to copy from it .whereExists( @@ -107,12 +89,7 @@ async function _fetchLicence (licenceId) { }) .withGraphFetched('returnVersions.modLogs') .modifyGraph('returnVersions.modLogs', (builder) => { - builder - .select([ - 'id', - 'reasonDescription' - ]) - .orderBy('externalId', 'asc') + builder.select(['id', 'reasonDescription']).orderBy('externalId', 'asc') }) // See licence.model.js `static get modifiers` if you are unsure about what this is doing .modify('licenceHolder') @@ -124,7 +101,7 @@ async function _fetchLicence (licenceId) { return licence } -function _currentVersionStartDate (licenceVersions) { +function _currentVersionStartDate(licenceVersions) { // Extract the start date from the most 'current' licence version. _fetchLicence() ensures in the case // that there is more than one that they are ordered by their start date (DESC) const { startDate } = licenceVersions[0] diff --git a/app/services/return-versions/setup/method/fetch-abstraction-data.service.js b/app/services/return-versions/setup/method/fetch-abstraction-data.service.js index 3deb400573..eecae212b1 100644 --- a/app/services/return-versions/setup/method/fetch-abstraction-data.service.js +++ b/app/services/return-versions/setup/method/fetch-abstraction-data.service.js @@ -24,7 +24,7 @@ const LicenceModel = require('../../../../models/licence.model.js') * @returns {Promise} the matching licence model instance with abstraction data related properties * populated */ -async function go (licenceId) { +async function go(licenceId) { return _fetch(licenceId) } @@ -34,47 +34,50 @@ async function go (licenceId) { * * @private */ -async function _fetch (licenceId) { - return LicenceModel.query() - .findById(licenceId) - .select([ - 'licences.id', - 'licences.waterUndertaker', - // This is generates a sub-select query which uses `EXISTS` to convert whether a user has a current two-part - // tariff agreement into a boolean value - LicenceModel.raw(` +async function _fetch(licenceId) { + return ( + LicenceModel.query() + .findById(licenceId) + .select([ + 'licences.id', + 'licences.waterUndertaker', + // This is generates a sub-select query which uses `EXISTS` to convert whether a user has a current two-part + // tariff agreement into a boolean value + LicenceModel.raw( + ` EXISTS (SELECT 1 FROM licence_agreements la INNER JOIN financial_agreements fa ON fa.id = la.financial_agreement_id WHERE la.licence_ref = licences.licence_ref AND fa.code = 'S127' AND (la.end_date IS NULL OR la.end_date >= ?)) AS two_part_tariff_agreement - `, [new Date()]) - ]) - // Grab only the current version for the licence. The licence version purposes are linked off it - .modify('currentVersion') - .withGraphFetched('licenceVersions.licenceVersionPurposes') - .modifyGraph('licenceVersions.licenceVersionPurposes', (builder) => { - builder.select([ - 'licenceVersionPurposes.id', - 'licenceVersionPurposes.abstractionPeriodEndDay', - 'licenceVersionPurposes.abstractionPeriodEndMonth', - 'licenceVersionPurposes.abstractionPeriodStartDay', - 'licenceVersionPurposes.abstractionPeriodStartMonth', - 'licenceVersionPurposes.dailyQuantity', - 'licenceVersionPurposes.externalId' + `, + [new Date()] + ) ]) - // Use the Objection.js modifier we've added to LicenceVersionPurposeModel to retrieve the purpose, plus primary - // and secondary against a licence version purpose - .modify('allPurposes') - .withGraphFetched('points') - .modifyGraph('points', (pointsBuilder) => { - pointsBuilder.select([ - 'points.id', - 'points.description' + // Grab only the current version for the licence. The licence version purposes are linked off it + .modify('currentVersion') + .withGraphFetched('licenceVersions.licenceVersionPurposes') + .modifyGraph('licenceVersions.licenceVersionPurposes', (builder) => { + builder + .select([ + 'licenceVersionPurposes.id', + 'licenceVersionPurposes.abstractionPeriodEndDay', + 'licenceVersionPurposes.abstractionPeriodEndMonth', + 'licenceVersionPurposes.abstractionPeriodStartDay', + 'licenceVersionPurposes.abstractionPeriodStartMonth', + 'licenceVersionPurposes.dailyQuantity', + 'licenceVersionPurposes.externalId' ]) - }) - }) + // Use the Objection.js modifier we've added to LicenceVersionPurposeModel to retrieve the purpose, plus primary + // and secondary against a licence version purpose + .modify('allPurposes') + .withGraphFetched('points') + .modifyGraph('points', (pointsBuilder) => { + pointsBuilder.select(['points.id', 'points.description']) + }) + }) + ) } module.exports = { diff --git a/app/services/return-versions/setup/method/generate-from-abstraction-data.service.js b/app/services/return-versions/setup/method/generate-from-abstraction-data.service.js index fab6d03d9b..2ca90ab970 100644 --- a/app/services/return-versions/setup/method/generate-from-abstraction-data.service.js +++ b/app/services/return-versions/setup/method/generate-from-abstraction-data.service.js @@ -32,7 +32,7 @@ const TWO_PART_IRRIGATION_IDS = ['380', '390', '400', '410', '420', '600', '620' * @returns {Promise} an array of return requirements generated from the licence's abstraction and ready to * be persisted to the setup session */ -async function go (licenceId) { +async function go(licenceId) { const licence = await FetchAbstractionDataService.go(licenceId) const returnRequirements = _transformForSetup(licence) @@ -60,7 +60,7 @@ async function go (licenceId) { * * @private */ -function _agreementExceptions (purpose) { +function _agreementExceptions(purpose) { const { twoPartTariff } = purpose if (twoPartTariff) { @@ -80,7 +80,7 @@ function _agreementExceptions (purpose) { * * @private */ -function _returnsCycle (startMonth, endMonth) { +function _returnsCycle(startMonth, endMonth) { const summerMonths = [4, 5, 6, 7, 8, 9, 10] // If the start month is after the end month it can't be within April to October @@ -134,7 +134,7 @@ function _returnsCycle (startMonth, endMonth) { * * @private */ -function _frequencyCollected (licence, licenceVersionPurpose) { +function _frequencyCollected(licence, licenceVersionPurpose) { const { twoPartTariffAgreement, waterUndertaker } = licence const { dailyQuantity, purpose } = licenceVersionPurpose @@ -165,7 +165,7 @@ function _frequencyCollected (licence, licenceVersionPurpose) { * * @private */ -function _frequencyReported (licence, licenceVersionPurpose) { +function _frequencyReported(licence, licenceVersionPurpose) { const { waterUndertaker } = licence const { dailyQuantity } = licenceVersionPurpose @@ -189,7 +189,7 @@ function _frequencyReported (licence, licenceVersionPurpose) { * * @private */ -function _points (points) { +function _points(points) { return points.map((point) => { return point.id }) @@ -205,7 +205,7 @@ function _points (points) { * * @private */ -function _siteDescription (points) { +function _siteDescription(points) { const descriptions = points.map((point) => { return point.description }) @@ -225,7 +225,7 @@ function _siteDescription (points) { * * @private */ -function _transformForSetup (licence) { +function _transformForSetup(licence) { const { licenceVersionPurposes } = licence.$currentVersion() return licenceVersionPurposes.map((licenceVersionPurpose) => { diff --git a/app/services/return-versions/setup/method/method.service.js b/app/services/return-versions/setup/method/method.service.js index 6a2bbb9924..f6dc50895e 100644 --- a/app/services/return-versions/setup/method/method.service.js +++ b/app/services/return-versions/setup/method/method.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../../models/session.model.js') * * @returns {Promise} page data needed by the view template */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = MethodPresenter.go(session) diff --git a/app/services/return-versions/setup/method/submit-method.service.js b/app/services/return-versions/setup/method/submit-method.service.js index 9d036d9ff2..a2c589f57c 100644 --- a/app/services/return-versions/setup/method/submit-method.service.js +++ b/app/services/return-versions/setup/method/submit-method.service.js @@ -25,7 +25,7 @@ const MethodValidator = require('../../../../validators/return-versions/setup/me * @returns {Promise} If no errors a the url for where the user should be redirected else the page data for the * setup page including the validation error details */ -async function go (sessionId, payload) { +async function go(sessionId, payload) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -48,7 +48,7 @@ async function go (sessionId, payload) { } } -function _redirect (method) { +function _redirect(method) { if (method === 'use-abstraction-data') { return 'check' } @@ -60,7 +60,7 @@ function _redirect (method) { return 'purpose/0' } -async function _save (session, payload) { +async function _save(session, payload) { session.method = payload.method // If the user selected the method 'Start by using abstraction data' to setup the return requirements we use @@ -73,7 +73,7 @@ async function _save (session, payload) { return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = MethodValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/no-returns-required.service.js b/app/services/return-versions/setup/no-returns-required.service.js index 4f8c403b75..95e1cc2301 100644 --- a/app/services/return-versions/setup/no-returns-required.service.js +++ b/app/services/return-versions/setup/no-returns-required.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the no returns required page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = NoReturnsRequiredPresenter.go(session) diff --git a/app/services/return-versions/setup/note.service.js b/app/services/return-versions/setup/note.service.js index 26cc51462a..7a82db41bc 100644 --- a/app/services/return-versions/setup/note.service.js +++ b/app/services/return-versions/setup/note.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the note page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = NotePresenter.go(session) diff --git a/app/services/return-versions/setup/points.service.js b/app/services/return-versions/setup/points.service.js index 6f8bd41715..40aa60b92d 100644 --- a/app/services/return-versions/setup/points.service.js +++ b/app/services/return-versions/setup/points.service.js @@ -20,7 +20,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the points page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const points = await FetchPointsService.go(session.licence.id) diff --git a/app/services/return-versions/setup/purpose.service.js b/app/services/return-versions/setup/purpose.service.js index 68fe1485ce..00622d2d44 100644 --- a/app/services/return-versions/setup/purpose.service.js +++ b/app/services/return-versions/setup/purpose.service.js @@ -20,7 +20,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the purpose page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const purposesData = await FetchPurposesService.go(session.licence.id) diff --git a/app/services/return-versions/setup/reason.service.js b/app/services/return-versions/setup/reason.service.js index c6b610d183..06a67867f2 100644 --- a/app/services/return-versions/setup/reason.service.js +++ b/app/services/return-versions/setup/reason.service.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} page data needed by the view template */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = SelectReasonPresenter.go(session) diff --git a/app/services/return-versions/setup/remove.service.js b/app/services/return-versions/setup/remove.service.js index 474db5f19a..7690c07d48 100644 --- a/app/services/return-versions/setup/remove.service.js +++ b/app/services/return-versions/setup/remove.service.js @@ -21,7 +21,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the remove requirements page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const formattedData = RemovePresenter.go(session, requirementIndex) diff --git a/app/services/return-versions/setup/returns-cycle.service.js b/app/services/return-versions/setup/returns-cycle.service.js index 55aa148b17..25f1c1aa18 100644 --- a/app/services/return-versions/setup/returns-cycle.service.js +++ b/app/services/return-versions/setup/returns-cycle.service.js @@ -19,7 +19,7 @@ const SessionModel = require('../../../models/session.model.js') * * @returns {Promise} The view data for the returns cycle page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const formattedData = ReturnsCyclePresenter.go(session, requirementIndex) diff --git a/app/services/return-versions/setup/site-description.service.js b/app/services/return-versions/setup/site-description.service.js index 86d5cc0c47..5ef4d5109b 100644 --- a/app/services/return-versions/setup/site-description.service.js +++ b/app/services/return-versions/setup/site-description.service.js @@ -19,7 +19,7 @@ const SiteDescriptionPresenter = require('../../../presenters/return-versions/se * * @returns {Promise} The view data for the site description page */ -async function go (sessionId, requirementIndex) { +async function go(sessionId, requirementIndex) { const session = await SessionModel.query().findById(sessionId) const formattedData = SiteDescriptionPresenter.go(session, requirementIndex) diff --git a/app/services/return-versions/setup/start-date.service.js b/app/services/return-versions/setup/start-date.service.js index ab247cfaa7..9571138fab 100644 --- a/app/services/return-versions/setup/start-date.service.js +++ b/app/services/return-versions/setup/start-date.service.js @@ -18,7 +18,7 @@ const StartDatePresenter = require('../../../presenters/return-versions/setup/st * * @returns {Promise} The view data for the start date page */ -async function go (sessionId) { +async function go(sessionId) { const session = await SessionModel.query().findById(sessionId) const formattedData = StartDatePresenter.go(session) diff --git a/app/services/return-versions/setup/submit-abstraction-period.service.js b/app/services/return-versions/setup/submit-abstraction-period.service.js index 33f25275ee..5d3fc163f6 100644 --- a/app/services/return-versions/setup/submit-abstraction-period.service.js +++ b/app/services/return-versions/setup/submit-abstraction-period.service.js @@ -27,7 +27,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the abstraction period page including the validation error details */ -async function go (sessionId, requirementIndex, payload, yar) { +async function go(sessionId, requirementIndex, payload, yar) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -54,7 +54,7 @@ async function go (sessionId, requirementIndex, payload, yar) { } } -async function _save (session, requirementIndex, payload) { +async function _save(session, requirementIndex, payload) { session.requirements[requirementIndex].abstractionPeriod = payload return session.$update() @@ -66,13 +66,13 @@ async function _save (session, requirementIndex, payload) { * * @private */ -function _submittedSessionData (session, requirementIndex, payload) { +function _submittedSessionData(session, requirementIndex, payload) { session.requirements[requirementIndex].abstractionPeriod = Object.keys(payload).length > 0 ? payload : null return AbstractionPeriodPresenter.go(session, requirementIndex) } -function _validate (payload) { +function _validate(payload) { const validation = AbstractionPeriodValidator.go(payload) if (!validation.startResult.error && !validation.endResult.error) { diff --git a/app/services/return-versions/setup/submit-additional-submission-options.service.js b/app/services/return-versions/setup/submit-additional-submission-options.service.js index f6fe30405f..8e627e9ec5 100644 --- a/app/services/return-versions/setup/submit-additional-submission-options.service.js +++ b/app/services/return-versions/setup/submit-additional-submission-options.service.js @@ -25,7 +25,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors it returns an empty object else the page data for the note page including the * validation error details */ -async function go (sessionId, payload, yar) { +async function go(sessionId, payload, yar) { const session = await SessionModel.query().findById(sessionId) _handleOneOptionSelected(payload) @@ -55,19 +55,19 @@ async function go (sessionId, payload, yar) { } /** -* When a single additional submission option is checked by the user, it returns as a string. When multiple options are + * When a single additional submission option is checked by the user, it returns as a string. When multiple options are * checked, the 'additionalSubmissionOptions' is returned as an array. * This function works to make those single selected string 'additionalSubmissionOptions' into an array for uniformity. * * @private */ -function _handleOneOptionSelected (payload) { +function _handleOneOptionSelected(payload) { if (!Array.isArray(payload.additionalSubmissionOptions)) { payload.additionalSubmissionOptions = [payload.additionalSubmissionOptions] } } -function _notification (session, payload) { +function _notification(session, payload) { const { additionalSubmissionOptions } = session ?? {} if (additionalSubmissionOptions !== payload.additionalSubmissionOptions) { @@ -80,7 +80,7 @@ function _notification (session, payload) { return null } -async function _save (session, payload) { +async function _save(session, payload) { session.multipleUpload = payload.additionalSubmissionOptions.includes('multiple-upload') session.quarterlyReturns = payload.additionalSubmissionOptions.includes('quarterly-returns') @@ -90,13 +90,13 @@ async function _save (session, payload) { return session.$update() } -function _submittedSessionData (session, payload) { +function _submittedSessionData(session, payload) { session.additionalSubmissionOptions = payload.additionalSubmissionOptions ?? [] return AdditionalSubmissionOptionsPresenter.go(session) } -function _validate (payload) { +function _validate(payload) { const validation = AdditionalSubmissionOptionsValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-agreements-exceptions.service.js b/app/services/return-versions/setup/submit-agreements-exceptions.service.js index e0063ec078..6e121dbfef 100644 --- a/app/services/return-versions/setup/submit-agreements-exceptions.service.js +++ b/app/services/return-versions/setup/submit-agreements-exceptions.service.js @@ -27,7 +27,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the agreements exceptions page including the validation error details */ -async function go (sessionId, requirementIndex, payload, yar) { +async function go(sessionId, requirementIndex, payload, yar) { const session = await SessionModel.query().findById(sessionId) _handleOneOptionSelected(payload) @@ -65,19 +65,19 @@ async function go (sessionId, requirementIndex, payload, yar) { * * @private */ -function _handleOneOptionSelected (payload) { +function _handleOneOptionSelected(payload) { if (!Array.isArray(payload.agreementsExceptions)) { payload.agreementsExceptions = [payload.agreementsExceptions] } } -async function _save (session, requirementIndex, payload) { +async function _save(session, requirementIndex, payload) { session.requirements[requirementIndex].agreementsExceptions = payload.agreementsExceptions return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = AgreementsExceptionsValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-cancel.service.js b/app/services/return-versions/setup/submit-cancel.service.js index 52aeef3fb3..12cf62a1e9 100644 --- a/app/services/return-versions/setup/submit-cancel.service.js +++ b/app/services/return-versions/setup/submit-cancel.service.js @@ -15,7 +15,7 @@ const SessionModel = require('../../../models/session.model.js') * * @param {string} sessionId - The UUID for the return requirement setup session record */ -async function go (sessionId) { +async function go(sessionId) { await SessionModel.query().deleteById(sessionId) } diff --git a/app/services/return-versions/setup/submit-frequency-collected.service.js b/app/services/return-versions/setup/submit-frequency-collected.service.js index 038fa0266f..bdc1a0e77e 100644 --- a/app/services/return-versions/setup/submit-frequency-collected.service.js +++ b/app/services/return-versions/setup/submit-frequency-collected.service.js @@ -27,7 +27,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the frequency collected page including the validation error details */ -async function go (sessionId, requirementIndex, payload, yar) { +async function go(sessionId, requirementIndex, payload, yar) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -54,13 +54,13 @@ async function go (sessionId, requirementIndex, payload, yar) { } } -async function _save (session, requirementIndex, payload) { +async function _save(session, requirementIndex, payload) { session.requirements[requirementIndex].frequencyCollected = payload.frequencyCollected return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = FrequencyCollectedValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-frequency-reported.service.js b/app/services/return-versions/setup/submit-frequency-reported.service.js index e5c521dc6d..46992cb20f 100644 --- a/app/services/return-versions/setup/submit-frequency-reported.service.js +++ b/app/services/return-versions/setup/submit-frequency-reported.service.js @@ -27,7 +27,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the frequency reported page including the validation error details */ -async function go (sessionId, requirementIndex, payload, yar) { +async function go(sessionId, requirementIndex, payload, yar) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -54,13 +54,13 @@ async function go (sessionId, requirementIndex, payload, yar) { } } -async function _save (session, requirementIndex, payload) { +async function _save(session, requirementIndex, payload) { session.requirements[requirementIndex].frequencyReported = payload.frequencyReported return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = FrequencyReportedValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-no-returns-required.service.js b/app/services/return-versions/setup/submit-no-returns-required.service.js index ab64607141..1ddd13ee61 100644 --- a/app/services/return-versions/setup/submit-no-returns-required.service.js +++ b/app/services/return-versions/setup/submit-no-returns-required.service.js @@ -25,7 +25,7 @@ const GeneralLib = require('../../../lib/general.lib.js') * * @returns {Promise} The page data for the no returns required page */ -async function go (sessionId, payload, yar) { +async function go(sessionId, payload, yar) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -52,13 +52,13 @@ async function go (sessionId, payload, yar) { } } -async function _save (session, payload) { +async function _save(session, payload) { session.reason = payload.reason return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = NoReturnsRequiredValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-note.service.js b/app/services/return-versions/setup/submit-note.service.js index 6cd1108e87..510201684e 100644 --- a/app/services/return-versions/setup/submit-note.service.js +++ b/app/services/return-versions/setup/submit-note.service.js @@ -26,7 +26,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors it returns an empty object else the page data for the note page including the * validation error details */ -async function go (sessionId, payload, user, yar) { +async function go(sessionId, payload, user, yar) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -52,8 +52,10 @@ async function go (sessionId, payload, user, yar) { } } -function _notification (session, newNote) { - const { data: { note } } = session +function _notification(session, newNote) { + const { + data: { note } + } = session const text = 'Changes made' if (!note && newNote) { @@ -73,7 +75,7 @@ function _notification (session, newNote) { return null } -async function _save (session, payload, user) { +async function _save(session, payload, user) { session.note = { content: payload.note, userEmail: user.username @@ -82,13 +84,13 @@ async function _save (session, payload, user) { return session.$update() } -function _submittedSessionData (session, payload) { +function _submittedSessionData(session, payload) { session.note = payload.note ? payload.note : null return NotePresenter.go(session) } -function _validate (payload) { +function _validate(payload) { const validation = NoteValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-points.service.js b/app/services/return-versions/setup/submit-points.service.js index 1847d225fa..62febd6d7c 100644 --- a/app/services/return-versions/setup/submit-points.service.js +++ b/app/services/return-versions/setup/submit-points.service.js @@ -28,7 +28,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the points page including the validation error details */ -async function go (sessionId, requirementIndex, payload, yar) { +async function go(sessionId, requirementIndex, payload, yar) { const session = await SessionModel.query().findById(sessionId) _handleOneOptionSelected(payload) @@ -65,19 +65,19 @@ async function go (sessionId, requirementIndex, payload, yar) { * * @private */ -function _handleOneOptionSelected (payload) { +function _handleOneOptionSelected(payload) { if (!Array.isArray(payload.points)) { payload.points = [payload.points] } } -async function _save (session, requirementIndex, payload) { +async function _save(session, requirementIndex, payload) { session.requirements[requirementIndex].points = payload.points return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = PointsValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-purpose.service.js b/app/services/return-versions/setup/submit-purpose.service.js index 50c1844aaa..2a136825a7 100644 --- a/app/services/return-versions/setup/submit-purpose.service.js +++ b/app/services/return-versions/setup/submit-purpose.service.js @@ -28,7 +28,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the purpose page including the validation error details */ -async function go (sessionId, requirementIndex, payload, yar) { +async function go(sessionId, requirementIndex, payload, yar) { const session = await SessionModel.query().findById(sessionId) const licencePurposes = await FetchPurposesService.go(session.licence.id) @@ -60,7 +60,7 @@ async function go (sessionId, requirementIndex, payload, yar) { } } -function _combinePurposeDetails (payload, licencePurposes) { +function _combinePurposeDetails(payload, licencePurposes) { const combinedValues = [] for (const purpose of payload.purposes) { @@ -86,7 +86,7 @@ function _combinePurposeDetails (payload, licencePurposes) { * * @private */ -function _handleOneOptionSelected (payload) { +function _handleOneOptionSelected(payload) { if (!payload.purposes) { payload.purposes = [] } @@ -96,7 +96,7 @@ function _handleOneOptionSelected (payload) { } } -async function _save (session, requirementIndex, purposes) { +async function _save(session, requirementIndex, purposes) { session.requirements[requirementIndex].purposes = purposes return session.$update() @@ -107,13 +107,13 @@ async function _save (session, requirementIndex, purposes) { * * @private */ -function _submittedSessionData (session, requirementIndex, purposes, licencePurposes) { +function _submittedSessionData(session, requirementIndex, purposes, licencePurposes) { session.requirements[requirementIndex].purposes = purposes return PurposePresenter.go(session, requirementIndex, licencePurposes) } -async function _validate (payload, purposesData) { +async function _validate(payload, purposesData) { const purposeIds = purposesData.map((purpose) => { return purpose.id }) diff --git a/app/services/return-versions/setup/submit-reason.service.js b/app/services/return-versions/setup/submit-reason.service.js index e9e59add47..77f4590789 100644 --- a/app/services/return-versions/setup/submit-reason.service.js +++ b/app/services/return-versions/setup/submit-reason.service.js @@ -26,7 +26,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the reason page including the validation error details */ -async function go (sessionId, payload, yar) { +async function go(sessionId, payload, yar) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -53,13 +53,13 @@ async function go (sessionId, payload, yar) { } } -async function _save (session, payload) { +async function _save(session, payload) { session.reason = payload.reason return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = ReasonValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-remove.service.js b/app/services/return-versions/setup/submit-remove.service.js index 860dd775a9..8e3b275053 100644 --- a/app/services/return-versions/setup/submit-remove.service.js +++ b/app/services/return-versions/setup/submit-remove.service.js @@ -17,7 +17,7 @@ const SessionModel = require('../../../models/session.model.js') * @param {number} requirementIndex - The index of the requirement being removed * @param {object} yar - The Hapi `request.yar` session manager passed on by the controller */ -async function go (sessionId, requirementIndex, yar) { +async function go(sessionId, requirementIndex, yar) { const session = await SessionModel.query().findById(sessionId) const notification = { @@ -30,7 +30,7 @@ async function go (sessionId, requirementIndex, yar) { await _removeRequirementFromSession(session, requirementIndex) } -async function _removeRequirementFromSession (session, requirementIndex) { +async function _removeRequirementFromSession(session, requirementIndex) { session.requirements.splice(requirementIndex, 1) await session.$update() diff --git a/app/services/return-versions/setup/submit-returns-cycle.service.js b/app/services/return-versions/setup/submit-returns-cycle.service.js index dcebb4afdc..e67d6afd9b 100644 --- a/app/services/return-versions/setup/submit-returns-cycle.service.js +++ b/app/services/return-versions/setup/submit-returns-cycle.service.js @@ -27,7 +27,7 @@ const SessionModel = require('../../../models/session.model.js') * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the returns cycle page including the validation error details */ -async function go (sessionId, requirementIndex, payload, yar) { +async function go(sessionId, requirementIndex, payload, yar) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -54,13 +54,13 @@ async function go (sessionId, requirementIndex, payload, yar) { } } -async function _save (session, requirementIndex, payload) { +async function _save(session, requirementIndex, payload) { session.requirements[requirementIndex].returnsCycle = payload.returnsCycle return session.$update() } -function _validate (payload) { +function _validate(payload) { const validation = ReturnsCycleValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-site-description.service.js b/app/services/return-versions/setup/submit-site-description.service.js index ee1d381b9b..d91acdc0ec 100644 --- a/app/services/return-versions/setup/submit-site-description.service.js +++ b/app/services/return-versions/setup/submit-site-description.service.js @@ -27,7 +27,7 @@ const SiteDescriptionValidator = require('../../../validators/return-versions/se * @returns {Promise} If no errors a flag that determines whether the user is returned to the check page else * the page data for the site description page including the validation error details */ -async function go (sessionId, requirementIndex, payload, yar) { +async function go(sessionId, requirementIndex, payload, yar) { const session = await SessionModel.query().findById(sessionId) const validationResult = _validate(payload) @@ -54,7 +54,7 @@ async function go (sessionId, requirementIndex, payload, yar) { } } -async function _save (session, requirementIndex, payload) { +async function _save(session, requirementIndex, payload) { session.requirements[requirementIndex].siteDescription = payload.siteDescription return session.$update() @@ -66,13 +66,13 @@ async function _save (session, requirementIndex, payload) { * * @private */ -function _submittedSessionData (session, requirementIndex, payload) { +function _submittedSessionData(session, requirementIndex, payload) { session.requirements[requirementIndex].siteDescription = payload.siteDescription ? payload.siteDescription : null return SiteDescriptionPresenter.go(session, requirementIndex) } -function _validate (payload) { +function _validate(payload) { const validation = SiteDescriptionValidator.go(payload) if (!validation.error) { diff --git a/app/services/return-versions/setup/submit-start-date.service.js b/app/services/return-versions/setup/submit-start-date.service.js index c700b6a2e6..6cf568ca7d 100644 --- a/app/services/return-versions/setup/submit-start-date.service.js +++ b/app/services/return-versions/setup/submit-start-date.service.js @@ -28,7 +28,7 @@ const { isQuarterlyReturnSubmissions } = require('../../../lib/dates.lib.js') * @returns {Promise} If no errors 2 flags that determine whether the user is returned to the check page or the * next page in the journey else the page data for the start date page including the validation error details */ -async function go (sessionId, payload, yar) { +async function go(sessionId, payload, yar) { const session = await SessionModel.query().findById(sessionId) const { endDate, startDate } = session.licence @@ -70,15 +70,17 @@ async function go (sessionId, payload, yar) { * * @private */ -function _defaultQuarterlyReturns (session) { - if (!session.checkPageVisited && +function _defaultQuarterlyReturns(session) { + if ( + !session.checkPageVisited && isQuarterlyReturnSubmissions(session.returnVersionStartDate) && - session.licence.waterUndertaker) { + session.licence.waterUndertaker + ) { session.quarterlyReturns = true } } -async function _save (session, payload) { +async function _save(session, payload) { const selectedOption = payload['start-date-options'] session.startDateOptions = selectedOption @@ -87,7 +89,9 @@ async function _save (session, payload) { session.startDateDay = payload['start-date-day'] session.startDateMonth = payload['start-date-month'] session.startDateYear = payload['start-date-year'] - session.returnVersionStartDate = new Date(`${payload['start-date-year']}-${payload['start-date-month']}-${payload['start-date-day']}`) + session.returnVersionStartDate = new Date( + `${payload['start-date-year']}-${payload['start-date-month']}-${payload['start-date-day']}` + ) } else { session.returnVersionStartDate = new Date(session.licence.currentVersionStartDate) } @@ -97,7 +101,7 @@ async function _save (session, payload) { return session.$update() } -function _submittedSessionData (session, payload) { +function _submittedSessionData(session, payload) { session.startDateDay = payload['start-date-day'] ? payload['start-date-day'] : null session.startDateMonth = payload['start-date-month'] ? payload['start-date-month'] : null session.startDateYear = payload['start-date-year'] ? payload['start-date-year'] : null @@ -106,7 +110,7 @@ function _submittedSessionData (session, payload) { return StartDatePresenter.go(session, payload) } -function _validate (payload, licenceStartDate, licenceEndDate) { +function _validate(payload, licenceStartDate, licenceEndDate) { const validation = StartDateValidator.go(payload, licenceStartDate, licenceEndDate) if (!validation.error) { diff --git a/app/services/return-versions/view.service.js b/app/services/return-versions/view.service.js index e5ff2b89f2..64e5db6d1f 100644 --- a/app/services/return-versions/view.service.js +++ b/app/services/return-versions/view.service.js @@ -15,7 +15,7 @@ const ViewPresenter = require('../../presenters/return-versions/view.presenter.j * * @returns {Promise} page data needed by the view template */ -async function go (returnVersionId) { +async function go(returnVersionId) { const requirementsForReturns = await FetchReturnVersionService.go(returnVersionId) const data = ViewPresenter.go(requirementsForReturns) diff --git a/app/validators/bill-runs/review/authorised.validator.js b/app/validators/bill-runs/review/authorised.validator.js index 2a40c10e96..f00b36aa06 100644 --- a/app/validators/bill-runs/review/authorised.validator.js +++ b/app/validators/bill-runs/review/authorised.validator.js @@ -20,15 +20,14 @@ const Joi = require('joi') * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const { amendedAuthorisedVolume, totalBillableReturns } = payload return _validate(amendedAuthorisedVolume, Number(totalBillableReturns)) } -function _validate (amendedAuthorisedVolume, totalBillableReturns) { - const schema = Joi - .number() +function _validate(amendedAuthorisedVolume, totalBillableReturns) { + const schema = Joi.number() .min(totalBillableReturns) .required() .custom(_maxDecimals, 'Max decimals') @@ -58,7 +57,7 @@ function _validate (amendedAuthorisedVolume, totalBillableReturns) { * @returns {number|object} if valid the original value else a Joi 'any.invalid' error. Knowing we return this means * you can assign what error message to use when a number has too many decimals. */ -function _maxDecimals (value, helpers) { +function _maxDecimals(value, helpers) { // Guard clause to ensure we don't try and interact with a null or undefined value if (!value) { return value diff --git a/app/validators/bill-runs/review/edit.validator.js b/app/validators/bill-runs/review/edit.validator.js index f68d61d4ff..fd5826a3bb 100644 --- a/app/validators/bill-runs/review/edit.validator.js +++ b/app/validators/bill-runs/review/edit.validator.js @@ -20,7 +20,7 @@ const Joi = require('joi') * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const { quantityOptions } = payload if (quantityOptions === 'customQuantity') { @@ -45,7 +45,7 @@ function go (payload) { * @returns {number|object} if valid the original value else a Joi 'any.invalid' error. Knowing we return this means * you can assign what error message to use when a number has too many decimals. */ -function _maxDecimals (value, helpers) { +function _maxDecimals(value, helpers) { // Guard clause to ensure we don't try and interact with a null or undefined value if (!value) { return value @@ -60,32 +60,23 @@ function _maxDecimals (value, helpers) { return helpers.error('any.invalid') } -function _validateCustomQuantity (customQuantity, authorisedVolume) { - const schema = Joi - .number() - .min(0) - .max(authorisedVolume) - .custom(_maxDecimals, 'Max decimals') - .required() - .messages({ - 'number.unsafe': 'The quantity must be a number', - 'number.base': 'The quantity must be a number', - 'number.min': 'The quantity must be zero or higher', - 'number.max': 'The quantity must be the same as or less than the authorised amount', - 'any.required': 'Enter the billable quantity', - 'any.invalid': 'The quantity must contain no more than 6 decimal places' - }) +function _validateCustomQuantity(customQuantity, authorisedVolume) { + const schema = Joi.number().min(0).max(authorisedVolume).custom(_maxDecimals, 'Max decimals').required().messages({ + 'number.unsafe': 'The quantity must be a number', + 'number.base': 'The quantity must be a number', + 'number.min': 'The quantity must be zero or higher', + 'number.max': 'The quantity must be the same as or less than the authorised amount', + 'any.required': 'Enter the billable quantity', + 'any.invalid': 'The quantity must contain no more than 6 decimal places' + }) return schema.validate(customQuantity, { abortEarly: true }) } -function _validateAuthorisedQuantity (quantityOptions) { - const schema = Joi - .number() - .required() - .messages({ - 'any.required': 'Select the billable quantity' - }) +function _validateAuthorisedQuantity(quantityOptions) { + const schema = Joi.number().required().messages({ + 'any.required': 'Select the billable quantity' + }) return schema.validate(quantityOptions, { abortEarly: true }) } diff --git a/app/validators/bill-runs/review/factors.validator.js b/app/validators/bill-runs/review/factors.validator.js index 17203f48d9..d975a010a7 100644 --- a/app/validators/bill-runs/review/factors.validator.js +++ b/app/validators/bill-runs/review/factors.validator.js @@ -18,32 +18,22 @@ const Joi = require('joi') * @returns {object} The result from calling Joi's schema.validate(). If any errors are found the `error:` property will * also exist detailing what the issue is. */ -function go (payload) { +function go(payload) { const schema = Joi.object({ - amendedAggregate: Joi - .number() - .min(0) - .required() - .custom(_maxDecimals, 'Max decimals') - .messages({ - 'number.base': 'The aggregate factor must be a number', - 'number.unsafe': 'The aggregate factor must be a number', - 'number.min': 'The aggregate factor must be greater than 0', - 'any.required': 'Enter an aggregate factor', - 'any.invalid': 'The aggregate factor must not have more than 15 decimal places' - }), - amendedChargeAdjustment: Joi - .number() - .min(0) - .required() - .custom(_maxDecimals, 'Max decimals') - .messages({ - 'number.base': 'The charge factor must be a number', - 'number.unsafe': 'The charge factor must be a number', - 'number.min': 'The charge factor must be greater than 0', - 'any.required': 'Enter a charge factor', - 'any.invalid': 'The charge factor must not have more than 15 decimal places' - }) + amendedAggregate: Joi.number().min(0).required().custom(_maxDecimals, 'Max decimals').messages({ + 'number.base': 'The aggregate factor must be a number', + 'number.unsafe': 'The aggregate factor must be a number', + 'number.min': 'The aggregate factor must be greater than 0', + 'any.required': 'Enter an aggregate factor', + 'any.invalid': 'The aggregate factor must not have more than 15 decimal places' + }), + amendedChargeAdjustment: Joi.number().min(0).required().custom(_maxDecimals, 'Max decimals').messages({ + 'number.base': 'The charge factor must be a number', + 'number.unsafe': 'The charge factor must be a number', + 'number.min': 'The charge factor must be greater than 0', + 'any.required': 'Enter a charge factor', + 'any.invalid': 'The charge factor must not have more than 15 decimal places' + }) }) return schema.validate(payload, { abortEarly: false }) @@ -64,7 +54,7 @@ function go (payload) { * @returns {number|object} if valid the original value else a Joi 'any.invalid' error. Knowing we return this means * you can assign what error message to use when a number has too many decimals. */ -function _maxDecimals (value, helpers) { +function _maxDecimals(value, helpers) { // Guard clause to ensure we don't try and interact with a null or undefined value if (!value) { return value diff --git a/app/validators/bill-runs/setup/region.validator.js b/app/validators/bill-runs/setup/region.validator.js index 49752a7356..7e0dda3021 100644 --- a/app/validators/bill-runs/setup/region.validator.js +++ b/app/validators/bill-runs/setup/region.validator.js @@ -16,7 +16,7 @@ const Joi = require('joi') * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload, regions) { +function go(payload, regions) { const validValues = regions.map((region) => { return region.id }) diff --git a/app/validators/bill-runs/setup/season.validator.js b/app/validators/bill-runs/setup/season.validator.js index 876cbb1261..e818343342 100644 --- a/app/validators/bill-runs/setup/season.validator.js +++ b/app/validators/bill-runs/setup/season.validator.js @@ -7,10 +7,7 @@ const Joi = require('joi') -const VALID_VALUES = [ - 'summer', - 'winter_all_year' -] +const VALID_VALUES = ['summer', 'winter_all_year'] /** * Validates data submitted for the `/bill-runs/setup/{sessionId}/season` page @@ -20,7 +17,7 @@ const VALID_VALUES = [ * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const schema = Joi.object({ season: Joi.string() .required() diff --git a/app/validators/bill-runs/setup/type.validator.js b/app/validators/bill-runs/setup/type.validator.js index bce42ae99e..4e6f0947ca 100644 --- a/app/validators/bill-runs/setup/type.validator.js +++ b/app/validators/bill-runs/setup/type.validator.js @@ -7,12 +7,7 @@ const Joi = require('joi') -const VALID_VALUES = [ - 'annual', - 'supplementary', - 'two_part_supplementary', - 'two_part_tariff' -] +const VALID_VALUES = ['annual', 'supplementary', 'two_part_supplementary', 'two_part_tariff'] /** * Validates data submitted for the `/bill-runs/setup/{sessionId}/type` page @@ -22,7 +17,7 @@ const VALID_VALUES = [ * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const schema = Joi.object({ type: Joi.string() .required() diff --git a/app/validators/bill-runs/setup/year.validator.js b/app/validators/bill-runs/setup/year.validator.js index e06b0f12d2..52cfbf660d 100644 --- a/app/validators/bill-runs/setup/year.validator.js +++ b/app/validators/bill-runs/setup/year.validator.js @@ -7,12 +7,7 @@ const Joi = require('joi') -const VALID_VALUES = [ - '2024', - '2023', - '2022', - '2021' -] +const VALID_VALUES = ['2024', '2023', '2022', '2021'] /** * Validates data submitted for the `/bill-runs/setup/{sessionId}/year` page @@ -22,7 +17,7 @@ const VALID_VALUES = [ * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const schema = Joi.object({ year: Joi.string() .required() diff --git a/app/validators/change-address.validator.js b/app/validators/change-address.validator.js index 53f0e75c48..5670e2e764 100644 --- a/app/validators/change-address.validator.js +++ b/app/validators/change-address.validator.js @@ -18,7 +18,7 @@ const StaticLookupsLib = require('../lib/static-lookups.lib.js') * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const schema = Joi.object({ address: _addressSchema(), agentCompany: _agentCompanySchema(), @@ -28,7 +28,7 @@ function go (payload) { return schema.validate(payload) } -function _addressSchema () { +function _addressSchema() { return Joi.object({ id: Joi.string().guid().optional(), addressLine1: Joi.string().optional(), @@ -44,20 +44,26 @@ function _addressSchema () { }).required() } -function _agentCompanySchema () { +function _agentCompanySchema() { return Joi.object({ id: Joi.string().guid().optional(), - type: Joi.string().valid(...StaticLookupsLib.companyTypes).optional(), - organisationType: Joi.string().valid(...StaticLookupsLib.organisationTypes).optional(), + type: Joi.string() + .valid(...StaticLookupsLib.companyTypes) + .optional(), + organisationType: Joi.string() + .valid(...StaticLookupsLib.organisationTypes) + .optional(), name: Joi.string().optional(), companyNumber: Joi.string().optional() }).optional() } -function _contactSchema () { +function _contactSchema() { return Joi.object({ id: Joi.string().guid().optional(), - type: Joi.string().valid(...StaticLookupsLib.contactTypes).optional(), + type: Joi.string() + .valid(...StaticLookupsLib.contactTypes) + .optional(), salutation: Joi.string().optional(), firstName: Joi.string().optional(), initials: Joi.string().optional(), @@ -65,7 +71,9 @@ function _contactSchema () { lastName: Joi.string().optional(), suffix: Joi.string().optional(), department: Joi.string().optional(), - source: Joi.string().valid(...StaticLookupsLib.sources).optional(), + source: Joi.string() + .valid(...StaticLookupsLib.sources) + .optional(), isTest: Joi.boolean().default(false).optional() }).optional() } diff --git a/app/validators/import/address.validator.js b/app/validators/import/address.validator.js index 3fcd9ca9b0..3739ff4f7b 100644 --- a/app/validators/import/address.validator.js +++ b/app/validators/import/address.validator.js @@ -13,7 +13,7 @@ const Joi = require('joi') * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (address) { +function go(address) { const schema = Joi.object({ address1: Joi.string().required(), address2: Joi.string().allow(null), diff --git a/app/validators/import/company.validator.js b/app/validators/import/company.validator.js index 81484b9daa..98df1cb22e 100644 --- a/app/validators/import/company.validator.js +++ b/app/validators/import/company.validator.js @@ -13,7 +13,7 @@ const Joi = require('joi') * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (company) { +function go(company) { const schema = Joi.object({ name: Joi.string().required(), type: Joi.string().valid('organisation', 'person').required(), diff --git a/app/validators/import/contact.validator.js b/app/validators/import/contact.validator.js index 97ab628595..b96faf1a1c 100644 --- a/app/validators/import/contact.validator.js +++ b/app/validators/import/contact.validator.js @@ -13,7 +13,7 @@ const Joi = require('joi') * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (contact) { +function go(contact) { const schema = Joi.object({ salutation: Joi.string().allow(null), initials: Joi.string().allow(null), diff --git a/app/validators/import/licence-document-role.validator.js b/app/validators/import/licence-document-role.validator.js index 136e997152..476eec5a03 100644 --- a/app/validators/import/licence-document-role.validator.js +++ b/app/validators/import/licence-document-role.validator.js @@ -14,7 +14,7 @@ const Joi = require('joi') * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (licenceDocumentRole) { +function go(licenceDocumentRole) { const schema = Joi.object({ addressId: Joi.string().required(), companyId: Joi.string().required(), @@ -23,7 +23,6 @@ function go (licenceDocumentRole) { endDate: Joi.date().required().allow(null), licenceRoleId: Joi.string().guid().required(), startDate: Joi.date().required() - }) const result = schema.validate(licenceDocumentRole, { convert: false }) diff --git a/app/validators/import/licence-document.validator.js b/app/validators/import/licence-document.validator.js index d6531896ec..019658d951 100644 --- a/app/validators/import/licence-document.validator.js +++ b/app/validators/import/licence-document.validator.js @@ -13,7 +13,7 @@ const Joi = require('joi') * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (licenceDocument) { +function go(licenceDocument) { const schema = Joi.object({ licenceRef: Joi.string().required(), endDate: Joi.date().required().allow(null), diff --git a/app/validators/import/licence-structure.validator.js b/app/validators/import/licence-structure.validator.js index 21ed5840ca..982150209a 100644 --- a/app/validators/import/licence-structure.validator.js +++ b/app/validators/import/licence-structure.validator.js @@ -33,15 +33,16 @@ const Joi = require('joi') * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (licence) { +function go(licence) { const schema = Joi.object({ - licenceVersions: Joi.array().min(1).items( - Joi.object({ - licenceVersionPurposes: Joi.array().min(1) - }) - .unknown(true)) - }) - .unknown(true) + licenceVersions: Joi.array() + .min(1) + .items( + Joi.object({ + licenceVersionPurposes: Joi.array().min(1) + }).unknown(true) + ) + }).unknown(true) const result = schema.validate(licence) diff --git a/app/validators/import/licence-version-purpose-condition.validator.js b/app/validators/import/licence-version-purpose-condition.validator.js index c46923d0d9..391b8a27a4 100644 --- a/app/validators/import/licence-version-purpose-condition.validator.js +++ b/app/validators/import/licence-version-purpose-condition.validator.js @@ -15,15 +15,14 @@ const Joi = require('joi') * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (data) { - const schema = - Joi.object({ - licenceVersionPurposeConditionTypeId: Joi.string().guid().required(), - param1: Joi.string().allow(null).optional(), - param2: Joi.string().allow(null).optional(), - notes: Joi.string().allow(null).optional(), - externalId: Joi.string().required() - }) +function go(data) { + const schema = Joi.object({ + licenceVersionPurposeConditionTypeId: Joi.string().guid().required(), + param1: Joi.string().allow(null).optional(), + param2: Joi.string().allow(null).optional(), + notes: Joi.string().allow(null).optional(), + externalId: Joi.string().required() + }) const result = schema.validate(data, { convert: false }) diff --git a/app/validators/import/licence-version-purpose.validator.js b/app/validators/import/licence-version-purpose.validator.js index c03f0492be..b4761b24bc 100644 --- a/app/validators/import/licence-version-purpose.validator.js +++ b/app/validators/import/licence-version-purpose.validator.js @@ -15,7 +15,7 @@ const MONTHS_IN_YEAR = 12 * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (licenceVersionPurpose) { +function go(licenceVersionPurpose) { const schema = Joi.object({ abstractionPeriodEndDay: _daysInMonthSchema('abstractionPeriodEndMonth'), abstractionPeriodEndMonth: Joi.number().integer().min(1).max(MONTHS_IN_YEAR).required(), @@ -54,18 +54,17 @@ function go (licenceVersionPurpose) { * * @private */ -function _daysInMonthSchema (endMonthProperty) { - return Joi.number() - .when(endMonthProperty, { - switch: [ - { is: 2, then: Joi.number().integer().min(1).max(28).required() }, - { is: 4, then: Joi.number().integer().min(1).max(30).required() }, - { is: 6, then: Joi.number().integer().min(1).max(30).required() }, - { is: 9, then: Joi.number().integer().min(1).max(30).required() }, - { is: 11, then: Joi.number().integer().min(1).max(30).required() } - ], - otherwise: Joi.number().integer().min(1).max(31).required() - }) +function _daysInMonthSchema(endMonthProperty) { + return Joi.number().when(endMonthProperty, { + switch: [ + { is: 2, then: Joi.number().integer().min(1).max(28).required() }, + { is: 4, then: Joi.number().integer().min(1).max(30).required() }, + { is: 6, then: Joi.number().integer().min(1).max(30).required() }, + { is: 9, then: Joi.number().integer().min(1).max(30).required() }, + { is: 11, then: Joi.number().integer().min(1).max(30).required() } + ], + otherwise: Joi.number().integer().min(1).max(31).required() + }) } module.exports = { diff --git a/app/validators/import/licence-version.validator.js b/app/validators/import/licence-version.validator.js index 8a54857479..9609968b65 100644 --- a/app/validators/import/licence-version.validator.js +++ b/app/validators/import/licence-version.validator.js @@ -15,7 +15,7 @@ const WRLS_STATUSES = ['current', 'superseded'] * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (licenceVersion) { +function go(licenceVersion) { const schema = Joi.object({ endDate: Joi.date().required().allow(null), externalId: Joi.string().required(), @@ -23,7 +23,9 @@ function go (licenceVersion) { issue: Joi.number().required(), licenceVersionPurposes: Joi.array().required(), startDate: Joi.date().required(), - status: Joi.string().required().valid(...WRLS_STATUSES) + status: Joi.string() + .required() + .valid(...WRLS_STATUSES) }) const result = schema.validate(licenceVersion, { convert: false }) diff --git a/app/validators/import/licence.validator.js b/app/validators/import/licence.validator.js index f6be178b9d..973aa3c520 100644 --- a/app/validators/import/licence.validator.js +++ b/app/validators/import/licence.validator.js @@ -13,7 +13,7 @@ const Joi = require('joi') * * @throws {Joi.ValidationError} - throws a Joi validation error if the validation fails */ -function go (licence) { +function go(licence) { const schema = Joi.object({ expiredDate: Joi.date().allow(null), lapsedDate: Joi.date().allow(null), diff --git a/app/validators/licences/supplementary/supplementary-year.validator.js b/app/validators/licences/supplementary/supplementary-year.validator.js index f44048957c..69172ecd4d 100644 --- a/app/validators/licences/supplementary/supplementary-year.validator.js +++ b/app/validators/licences/supplementary/supplementary-year.validator.js @@ -18,7 +18,7 @@ const Joi = require('joi') * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { let years = payload.supplementaryYears if (!Array.isArray(years)) { @@ -28,13 +28,10 @@ function go (payload) { const errorMessage = 'Select at least one financial year' const schema = Joi.object({ - years: Joi.array() - .items(Joi.string()) - .required() - .messages({ - 'any.required': errorMessage, - 'array.sparse': errorMessage - }) + years: Joi.array().items(Joi.string()).required().messages({ + 'any.required': errorMessage, + 'array.sparse': errorMessage + }) }) return schema.validate({ years }, { abortEarly: true }) diff --git a/app/validators/return-versions/setup/abstraction-period.validator.js b/app/validators/return-versions/setup/abstraction-period.validator.js index d4a797a6c7..e1744eca7f 100644 --- a/app/validators/return-versions/setup/abstraction-period.validator.js +++ b/app/validators/return-versions/setup/abstraction-period.validator.js @@ -21,7 +21,7 @@ const { leftPadZeroes } = require('../../../presenters/base.presenter.js') * @returns {object} - The result from calling Joi's schema.validate(). If any errors are found the 'error: ' property * will also exist, detailing what the issue is. */ -function go (payload) { +function go(payload) { const { 'start-abstraction-period-day': startDay, 'start-abstraction-period-month': startMonth, @@ -42,7 +42,7 @@ function go (payload) { return result } -function _parsePayload (startDay, startMonth, endDay, endMonth) { +function _parsePayload(startDay, startMonth, endDay, endMonth) { const parsedStartDay = startDay ? leftPadZeroes(startDay, 2) : '' const parsedStartMonth = startMonth ? leftPadZeroes(startMonth, 2) : '' const parsedEndDay = endDay ? leftPadZeroes(endDay, 2) : '' @@ -62,39 +62,29 @@ function _parsePayload (startDay, startMonth, endDay, endMonth) { return parsePayload } -function _validateAbstractionStartDate (startDate) { +function _validateAbstractionStartDate(startDate) { const schema = Joi.object({ - entry: Joi.string() - .required() - .messages({ - 'string.empty': 'Select the start date of the abstraction period' - }), - fullDate: Joi.date() - .format(['YYYY-MM-DD']) - .required() - .messages({ - 'date.base': 'Enter a real start date', - 'date.format': 'Enter a real start date' - }) + entry: Joi.string().required().messages({ + 'string.empty': 'Select the start date of the abstraction period' + }), + fullDate: Joi.date().format(['YYYY-MM-DD']).required().messages({ + 'date.base': 'Enter a real start date', + 'date.format': 'Enter a real start date' + }) }) return schema.validate(startDate, { abortEarly: true }) } -function _validateAbstractionEndDate (endDate) { +function _validateAbstractionEndDate(endDate) { const schema = Joi.object({ - entry: Joi.string() - .required() - .messages({ - 'string.empty': 'Select the end date of the abstraction period' - }), - fullDate: Joi.date() - .format(['YYYY-MM-DD']) - .required() - .messages({ - 'date.base': 'Enter a real end date', - 'date.format': 'Enter a real end date' - }) + entry: Joi.string().required().messages({ + 'string.empty': 'Select the end date of the abstraction period' + }), + fullDate: Joi.date().format(['YYYY-MM-DD']).required().messages({ + 'date.base': 'Enter a real end date', + 'date.format': 'Enter a real end date' + }) }) return schema.validate(endDate, { abortEarly: true }) diff --git a/app/validators/return-versions/setup/additional-submission-options.validator.js b/app/validators/return-versions/setup/additional-submission-options.validator.js index 077c2361c2..5604988ac5 100644 --- a/app/validators/return-versions/setup/additional-submission-options.validator.js +++ b/app/validators/return-versions/setup/additional-submission-options.validator.js @@ -19,15 +19,13 @@ const Joi = require('joi') * @returns {object} The result from calling Joi's schema.validate(). If any errors are found the `error:` property will * also exist detailing what the issue is. */ -function go (options) { +function go(options) { const additionalSubmissionOptions = options.additionalSubmissionOptions const errorMessage = 'Select additional submission options for the requirements for returns' const schema = Joi.object({ - additionalSubmissionOptions: Joi.array() - .items(Joi.string()) - .required() + additionalSubmissionOptions: Joi.array().items(Joi.string()).required() }).messages({ 'any.required': errorMessage, 'array.sparse': errorMessage diff --git a/app/validators/return-versions/setup/agreements-exceptions.validator.js b/app/validators/return-versions/setup/agreements-exceptions.validator.js index 4fcb8935c4..cb484edb8e 100644 --- a/app/validators/return-versions/setup/agreements-exceptions.validator.js +++ b/app/validators/return-versions/setup/agreements-exceptions.validator.js @@ -19,7 +19,7 @@ const Joi = require('joi') * @returns {object} The result from calling Joi's schema.validate(). If any errors are found the * `error:` property will also exist detailing what the issue is. */ -function go (payload) { +function go(payload) { const agreementsExceptions = payload.agreementsExceptions const errorMessage = 'Select if there are any agreements and exceptions needed for the requirements for returns' diff --git a/app/validators/return-versions/setup/existing.validator.js b/app/validators/return-versions/setup/existing.validator.js index f2e6a978f4..5c318910e9 100644 --- a/app/validators/return-versions/setup/existing.validator.js +++ b/app/validators/return-versions/setup/existing.validator.js @@ -18,7 +18,7 @@ const errorMessage = 'Select a return version' * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload, returnVersions) { +function go(payload, returnVersions) { const returnVersionIds = returnVersions.map((returnVersion) => { return returnVersion.id }) diff --git a/app/validators/return-versions/setup/frequency-collected.validator.js b/app/validators/return-versions/setup/frequency-collected.validator.js index aa3faeeadd..09a6425567 100644 --- a/app/validators/return-versions/setup/frequency-collected.validator.js +++ b/app/validators/return-versions/setup/frequency-collected.validator.js @@ -19,14 +19,10 @@ const Joi = require('joi') * @returns {object} The result from calling Joi's schema.validate(). If any errors are found the `error:` property will * also exist detailing what the issue is. */ -function go (payload) { +function go(payload) { const frequencyCollected = payload.frequencyCollected - const VALID_VALUES = [ - 'day', - 'week', - 'month' - ] + const VALID_VALUES = ['day', 'week', 'month'] const errorMessage = 'Select how often readings or volumes are collected' diff --git a/app/validators/return-versions/setup/frequency-reported.validator.js b/app/validators/return-versions/setup/frequency-reported.validator.js index a3de1ea883..cf81687a05 100644 --- a/app/validators/return-versions/setup/frequency-reported.validator.js +++ b/app/validators/return-versions/setup/frequency-reported.validator.js @@ -19,14 +19,10 @@ const Joi = require('joi') * @returns {object} The result from calling Joi's schema.validate(). If any errors are found the `error:` property will * also exist detailing what the issue is. */ -function go (payload) { +function go(payload) { const frequencyReported = payload.frequencyReported - const VALID_VALUES = [ - 'day', - 'week', - 'month' - ] + const VALID_VALUES = ['day', 'week', 'month'] const errorMessage = 'Select how often readings or volumes are reported' diff --git a/app/validators/return-versions/setup/method.validator.js b/app/validators/return-versions/setup/method.validator.js index 3b0e825bf4..0adc2d9911 100644 --- a/app/validators/return-versions/setup/method.validator.js +++ b/app/validators/return-versions/setup/method.validator.js @@ -7,11 +7,7 @@ const Joi = require('joi') -const VALID_VALUES = [ - 'use-abstraction-data', - 'use-existing-requirements', - 'set-up-manually' -] +const VALID_VALUES = ['use-abstraction-data', 'use-existing-requirements', 'set-up-manually'] /** * Validates data submitted for the `/return-requirements/{sessionId}/method` page @@ -21,7 +17,7 @@ const VALID_VALUES = [ * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const errorMessage = 'Select how you want to set up the requirements for returns' const schema = Joi.object({ method: Joi.string() diff --git a/app/validators/return-versions/setup/no-returns-required.validator.js b/app/validators/return-versions/setup/no-returns-required.validator.js index 7bb207d172..dd59f58650 100644 --- a/app/validators/return-versions/setup/no-returns-required.validator.js +++ b/app/validators/return-versions/setup/no-returns-required.validator.js @@ -22,7 +22,7 @@ const VALID_VALUES = [ * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const schema = Joi.object({ reason: Joi.string() .required() diff --git a/app/validators/return-versions/setup/note.validator.js b/app/validators/return-versions/setup/note.validator.js index 35872dcaf2..4397926984 100644 --- a/app/validators/return-versions/setup/note.validator.js +++ b/app/validators/return-versions/setup/note.validator.js @@ -15,19 +15,16 @@ const Joi = require('joi') * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const errorMessage = 'Enter details' const maxErrorMessage = 'Enter no more than 500 characters' const schema = Joi.object({ - note: Joi.string() - .required() - .max(500) - .messages({ - 'any.required': errorMessage, - 'any.only': errorMessage, - 'string.empty': errorMessage, - 'string.max': maxErrorMessage - }) + note: Joi.string().required().max(500).messages({ + 'any.required': errorMessage, + 'any.only': errorMessage, + 'string.empty': errorMessage, + 'string.max': maxErrorMessage + }) }) return schema.validate(payload, { abortEarly: false }) diff --git a/app/validators/return-versions/setup/points.validator.js b/app/validators/return-versions/setup/points.validator.js index 195e0cfbbd..4a0ce35bcf 100644 --- a/app/validators/return-versions/setup/points.validator.js +++ b/app/validators/return-versions/setup/points.validator.js @@ -18,13 +18,11 @@ const Joi = require('joi') * @returns {object} The result from calling Joi's schema.validate(). If any errors are found the `error:` property will * also exist detailing what the issue is. */ -function go (payload) { +function go(payload) { const errorMessage = 'Select any points for the requirements for returns' const schema = Joi.object({ - points: Joi.array() - .items(Joi.string().guid()) - .required() + points: Joi.array().items(Joi.string().guid()).required() }).messages({ 'any.required': errorMessage, 'array.sparse': errorMessage, diff --git a/app/validators/return-versions/setup/purpose.validator.js b/app/validators/return-versions/setup/purpose.validator.js index a2a3fac4a7..ea3e0d2c0c 100644 --- a/app/validators/return-versions/setup/purpose.validator.js +++ b/app/validators/return-versions/setup/purpose.validator.js @@ -23,33 +23,26 @@ const Joi = require('joi') * @returns {object} The result from calling Joi's schema.validate(). If any errors are found the * `error:` property will also exist detailing what the issue is. */ -function go (purposes, purposeIds) { +function go(purposes, purposeIds) { const errorMessage = 'Select any purpose for the requirements for returns' const schema = Joi.object({ purposes: Joi.array() .items({ - id: Joi - .string() + id: Joi.string() .valid(...purposeIds) .required() .messages({ 'any.required': errorMessage, 'any.only': errorMessage }), - alias: Joi - .string() - .max(100) - .optional() - .allow('') - .messages({ - 'string.max': 'Purpose description must be 100 characters or less' - }), + alias: Joi.string().max(100).optional().allow('').messages({ + 'string.max': 'Purpose description must be 100 characters or less' + }), // Description will not be persisted. It is simply to avoid having to fetch the purpose description again in // the /check page. But if we didn't match a selected ID to a description in the SubmitPurposeService then // something has gone wrong! - description: Joi - .string() + description: Joi.string() }) .min(1) .required() diff --git a/app/validators/return-versions/setup/reason.validator.js b/app/validators/return-versions/setup/reason.validator.js index 32989c9764..6f6f5c6115 100644 --- a/app/validators/return-versions/setup/reason.validator.js +++ b/app/validators/return-versions/setup/reason.validator.js @@ -19,7 +19,7 @@ const errorMessage = 'Select the reason for the requirements for returns' * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload) { +function go(payload) { const validValues = Object.keys(returnRequirementReasons) const schema = Joi.object({ diff --git a/app/validators/return-versions/setup/returns-cycle.validator.js b/app/validators/return-versions/setup/returns-cycle.validator.js index b3ec16c879..02df8ad57e 100644 --- a/app/validators/return-versions/setup/returns-cycle.validator.js +++ b/app/validators/return-versions/setup/returns-cycle.validator.js @@ -18,13 +18,10 @@ const Joi = require('joi') * @returns {object} The result from calling Joi's schema.validate(). The result from calling Joi's schema.validate(). * If any errors are found the `error:` property will also exist detailing what the issue is. */ -function go (payload) { +function go(payload) { const returnsCycle = payload.returnsCycle - const VALID_VALUES = [ - 'summer', - 'winter-and-all-year' - ] + const VALID_VALUES = ['summer', 'winter-and-all-year'] const errorMessage = 'Select the returns cycle for the requirements for returns' diff --git a/app/validators/return-versions/setup/site-description.validator.js b/app/validators/return-versions/setup/site-description.validator.js index eaf791a961..b692657797 100644 --- a/app/validators/return-versions/setup/site-description.validator.js +++ b/app/validators/return-versions/setup/site-description.validator.js @@ -20,7 +20,7 @@ const Joi = require('joi') * @returns {object} the result from calling Joi's schema.validate(). If any errors are found the * `error:` property will also exist detailing what the issue is. */ -function go (payload) { +function go(payload) { const errorMessage = { empty: 'Enter a description of the site', small: 'Site description must be 10 characters or more', @@ -28,15 +28,11 @@ function go (payload) { } const schema = Joi.object({ - siteDescription: Joi.string() - .required() - .min(10) - .max(100) - .messages({ - 'any.required': errorMessage.empty, - 'string.min': errorMessage.small, - 'string.max': errorMessage.big - }) + siteDescription: Joi.string().required().min(10).max(100).messages({ + 'any.required': errorMessage.empty, + 'string.min': errorMessage.small, + 'string.max': errorMessage.big + }) }) return schema.validate(payload, { abortEarly: false }) diff --git a/app/validators/return-versions/setup/start-date.validator.js b/app/validators/return-versions/setup/start-date.validator.js index 26aef92cc9..9b4f2145a5 100644 --- a/app/validators/return-versions/setup/start-date.validator.js +++ b/app/validators/return-versions/setup/start-date.validator.js @@ -31,7 +31,7 @@ const { leftPadZeroes } = require('../../../presenters/base.presenter.js') * @returns {object} the result from calling Joi's schema.validate(). It will be an object with a `value:` property. If * any errors are found the `error:` property will also exist detailing what the issues were */ -function go (payload, licenceStartDate, licenceEndDate) { +function go(payload, licenceStartDate, licenceEndDate) { const { 'start-date-options': selectedOption } = payload if (selectedOption === 'anotherStartDate') { @@ -43,12 +43,8 @@ function go (payload, licenceStartDate, licenceEndDate) { return _validateLicenceVersionStartDate(payload) } -function _fullDate (payload) { - const { - 'start-date-day': day, - 'start-date-month': month, - 'start-date-year': year - } = payload +function _fullDate(payload) { + const { 'start-date-day': day, 'start-date-month': month, 'start-date-year': year } = payload const paddedMonth = month ? leftPadZeroes(month, 2) : '' const paddedDay = day ? leftPadZeroes(day, 2) : '' @@ -56,10 +52,9 @@ function _fullDate (payload) { return `${year}-${paddedMonth}-${paddedDay}` } -function _validateAnotherStartDate (payload, licenceStartDate, licenceEndDate) { +function _validateAnotherStartDate(payload, licenceStartDate, licenceEndDate) { const schema = Joi.object({ - fullDate: Joi - .date() + fullDate: Joi.date() .format(['YYYY-MM-DD']) .required() .min(licenceStartDate) @@ -76,14 +71,12 @@ function _validateAnotherStartDate (payload, licenceStartDate, licenceEndDate) { return schema.validate(payload, { abortEarly: false, allowUnknown: true }) } -function _validateLicenceVersionStartDate (payload) { +function _validateLicenceVersionStartDate(payload) { const schema = Joi.object({ - 'start-date-options': Joi.string() - .required() - .messages({ - 'any.required': 'Select the start date for the requirements for returns', - 'string.empty': 'Select the start date for the requirements for returns' - }) + 'start-date-options': Joi.string().required().messages({ + 'any.required': 'Select the start date for the requirements for returns', + 'string.empty': 'Select the start date for the requirements for returns' + }) }) return schema.validate(payload, { abortEarly: false, allowUnknown: true }) diff --git a/client/sass/application.scss b/client/sass/application.scss index 90941e9071..9e77d6ca7b 100644 --- a/client/sass/application.scss +++ b/client/sass/application.scss @@ -1,6 +1,6 @@ $govuk-global-styles: true; -@import "node_modules/govuk-frontend/govuk/all"; +@import 'node_modules/govuk-frontend/govuk/all'; // ========== ========== ========== ========== ========== // Dividers @@ -14,37 +14,37 @@ $govuk-global-styles: true; // ========== ========== ========== ========== ========== .meta-data__label { width: 100%; - order:1; + order: 1; margin-bottom: 0px; line-height: 25px; } .meta-data__value { - order:2; + order: 2; margin-bottom: 10px; line-height: 25px; } -@media screen and (min-width:600px) { +@media screen and (min-width: 600px) { .flex_container { display: flex; width: 100%; - flex-wrap:nowrap; + flex-wrap: nowrap; } } /* 2 columns */ -@media screen and (min-width:600px) { +@media screen and (min-width: 600px) { .meta-data__label { width: 20% !important; - padding:0px !important; + padding: 0px !important; font-weight: 400; } .meta-data__value { flex: 1; width: 80% !important; margin-bottom: 0; - padding:0px !important; + padding: 0px !important; } } @@ -66,8 +66,8 @@ $govuk-global-styles: true; @media (min-width: 768px) { font-size: 19px; margin-top: 0; - position:relative; - left:-15px; + position: relative; + left: -15px; } } @@ -98,13 +98,13 @@ $govuk-global-styles: true; .navbar__link--active { border-left: 4px solid $govuk-link-colour; margin-left: -10px; - padding-left: 5px; + padding-left: 5px; @media (min-width: 768px) { border-left: none; border-bottom: 4px solid $govuk-link-colour; margin-bottom: -1px; - margin-left:0; - padding-left:15px; + margin-left: 0; + padding-left: 15px; } } @@ -161,14 +161,14 @@ $govuk-global-styles: true; float: right; } -.float-left{ - float:left; +.float-left { + float: left; } // ========== ========== ========== ========== ========== // Font // ========== ========== ========== ========== ========== -.govuk-font-size-64{ +.govuk-font-size-64 { font-size: 64px !important; font-size: 4rem !important; } diff --git a/config/feature-flags.config.js b/config/feature-flags.config.js index 180ca0ba72..1d9e5947c2 100644 --- a/config/feature-flags.config.js +++ b/config/feature-flags.config.js @@ -12,14 +12,14 @@ require('dotenv').config() const config = { // Credit to https://stackoverflow.com/a/323546/6117745 for how to handle // converting the env var to a boolean - enableLicencePointsView: (String(process.env.ENABLE_LICENCE_POINTS_VIEW) === 'true') || false, - enableLicencePurposesView: (String(process.env.ENABLE_LICENCE_PURPOSES_VIEW) === 'true') || false, - enableMonitoringStationsView: (String(process.env.ENABLE_MONITORING_STATIONS_VIEW) === 'true') || false, - enableReissuingBillingBatches: (String(process.env.ENABLE_REISSUING_BILLING_BATCHES) === 'true') || false, - enableRequirementsForReturns: (String(process.env.ENABLE_REQUIREMENTS_FOR_RETURNS) === 'true') || false, - enableSystemLicenceView: (String(process.env.ENABLE_SYSTEM_LICENCE_VIEW) === 'true') || false, - enableSystemImportLegacyLicence: (String(process.env.ENABLE_IMPORT_LEGACY_LICENCE) === 'true') || false, - enableTwoPartTariffSupplementary: (String(process.env.ENABLE_TWO_PART_TARIFF_SUPPLEMENTARY) === 'true') || false + enableLicencePointsView: String(process.env.ENABLE_LICENCE_POINTS_VIEW) === 'true' || false, + enableLicencePurposesView: String(process.env.ENABLE_LICENCE_PURPOSES_VIEW) === 'true' || false, + enableMonitoringStationsView: String(process.env.ENABLE_MONITORING_STATIONS_VIEW) === 'true' || false, + enableReissuingBillingBatches: String(process.env.ENABLE_REISSUING_BILLING_BATCHES) === 'true' || false, + enableRequirementsForReturns: String(process.env.ENABLE_REQUIREMENTS_FOR_RETURNS) === 'true' || false, + enableSystemLicenceView: String(process.env.ENABLE_SYSTEM_LICENCE_VIEW) === 'true' || false, + enableSystemImportLegacyLicence: String(process.env.ENABLE_IMPORT_LEGACY_LICENCE) === 'true' || false, + enableTwoPartTariffSupplementary: String(process.env.ENABLE_TWO_PART_TARIFF_SUPPLEMENTARY) === 'true' || false } module.exports = config diff --git a/config/log.config.js b/config/log.config.js index d2d8ac3297..e6088580f0 100644 --- a/config/log.config.js +++ b/config/log.config.js @@ -12,8 +12,8 @@ require('dotenv').config() const config = { // Credit to https://stackoverflow.com/a/323546/6117745 for how to handle // converting the env var to a boolean - logAssetRequests: (String(process.env.LOG_ASSET_REQUESTS) === 'true') || false, - logInTest: (String(process.env.LOG_IN_TEST) === 'true') || false + logAssetRequests: String(process.env.LOG_ASSET_REQUESTS) === 'true' || false, + logInTest: String(process.env.LOG_IN_TEST) === 'true' || false } module.exports = config diff --git a/config/redis.config.js b/config/redis.config.js index b715bb2654..a8dbf6384d 100644 --- a/config/redis.config.js +++ b/config/redis.config.js @@ -13,7 +13,7 @@ const config = { host: process.env.REDIS_HOST, port: process.env.REDIS_PORT, password: process.env.REDIS_PASSWORD, - disableTls: (String(process.env.REDIS_DISABLE_TLS) === 'true') || false + disableTls: String(process.env.REDIS_DISABLE_TLS) === 'true' || false } module.exports = config diff --git a/db/clean.js b/db/clean.js index 65165e0086..bd45922ff3 100644 --- a/db/clean.js +++ b/db/clean.js @@ -11,7 +11,7 @@ const Database = require('../test/support/database.js') // https://knexjs.org/faq/recipes.html#node-instance-doesn-t-stop-after-using-knex // // To do this we have added a function to close the connection in database support -async function run () { +async function run() { console.log('Database clean for tests') try { diff --git a/db/migrations/legacy/20221108002001_crm-document-header.js b/db/migrations/legacy/20221108002001_crm-document-header.js index 3816df2234..2427ab5a16 100644 --- a/db/migrations/legacy/20221108002001_crm-document-header.js +++ b/db/migrations/legacy/20221108002001_crm-document-header.js @@ -3,43 +3,42 @@ const tableName = 'document_header' exports.up = function (knex) { - return knex - .schema - .withSchema('crm') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('document_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm').createTable(tableName, (table) => { + // Primary Key + table.uuid('document_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('regime_entity_id').notNullable() - table.string('system_id').notNullable().defaultTo('permit-repo') - table.string('system_internal_id').notNullable() - table.string('system_external_id').notNullable() - table.jsonb('metadata') - table.string('company_entity_id') - table.string('verification_id') - table.string('document_name') - table.date('date_deleted') + // Data + table.string('regime_entity_id').notNullable() + table.string('system_id').notNullable().defaultTo('permit-repo') + table.string('system_internal_id').notNullable() + table.string('system_external_id').notNullable() + table.jsonb('metadata') + table.string('company_entity_id') + table.string('verification_id') + table.string('document_name') + table.date('date_deleted') - // Legacy timestamps - table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique( - ['system_id', 'system_internal_id', 'regime_entity_id'], - { useConstraint: true, indexName: 'external_key' } - ) - table.unique([ - 'document_id', 'regime_entity_id', 'system_id', 'system_internal_id', - 'system_external_id', 'company_entity_id', 'verification_id' - ]) + // Constraints + table.unique(['system_id', 'system_internal_id', 'regime_entity_id'], { + useConstraint: true, + indexName: 'external_key' }) + table.unique([ + 'document_id', + 'regime_entity_id', + 'system_id', + 'system_internal_id', + 'system_external_id', + 'company_entity_id', + 'verification_id' + ]) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108002002_crm-entity.js b/db/migrations/legacy/20221108002002_crm-entity.js index 690b7dda85..38513e48c1 100644 --- a/db/migrations/legacy/20221108002002_crm-entity.js +++ b/db/migrations/legacy/20221108002002_crm-entity.js @@ -3,31 +3,25 @@ const tableName = 'entity' exports.up = function (knex) { - return knex - .schema - .withSchema('crm') - .createTable(tableName, (table) => { - // Data - table.string('entity_id').notNullable() - table.string('entity_nm').notNullable() - table.string('entity_type').notNullable() - table.jsonb('entity_definition') - table.string('source') + return knex.schema.withSchema('crm').createTable(tableName, (table) => { + // Data + table.string('entity_id').notNullable() + table.string('entity_nm').notNullable() + table.string('entity_type').notNullable() + table.jsonb('entity_definition') + table.string('source') - // Legacy timestamps - // NOTE: They are not automatically set - table.timestamp('created_at') - table.timestamp('updated_at') + // Legacy timestamps + // NOTE: They are not automatically set + table.timestamp('created_at') + table.timestamp('updated_at') - // Primary Key - // NOTE: It is not entity_id. The primary key is made up of all these columns - table.primary(['entity_id', 'entity_nm', 'entity_type']) - }) + // Primary Key + // NOTE: It is not entity_id. The primary key is made up of all these columns + table.primary(['entity_id', 'entity_nm', 'entity_type']) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108002003_crm-entity-roles.js b/db/migrations/legacy/20221108002003_crm-entity-roles.js index 7f39d373be..424b2fdacd 100644 --- a/db/migrations/legacy/20221108002003_crm-entity-roles.js +++ b/db/migrations/legacy/20221108002003_crm-entity-roles.js @@ -3,10 +3,11 @@ const tableName = 'entity_roles' exports.up = function (knex) { - return knex - .schema - .withSchema('crm') - .createTable(tableName, (table) => { + return ( + // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks + // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after + // Knex has created the table. + knex.schema.withSchema('crm').createTable(tableName, (table) => { // Primary Key table.string('entity_role_id').primary() @@ -20,11 +21,7 @@ exports.up = function (knex) { // Legacy timestamps // NOTE: They are not automatically set table.timestamp('created_at').defaultTo(knex.fn.now()) - }) - // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks - // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after - // Knex has created the table. - .raw(` + }).raw(` CREATE UNIQUE INDEX unique_role ON crm.entity_roles USING btree ( entity_id, @@ -33,12 +30,9 @@ exports.up = function (knex) { role ); `) + ) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm') - .dropTableIfExists(tableName) - .drop + return knex.schema.withSchema('crm').dropTableIfExists(tableName).drop } diff --git a/db/migrations/legacy/20221108003001_crm-v2-addresses.js b/db/migrations/legacy/20221108003001_crm-v2-addresses.js index 3114ce464e..1329ff2a86 100644 --- a/db/migrations/legacy/20221108003001_crm-v2-addresses.js +++ b/db/migrations/legacy/20221108003001_crm-v2-addresses.js @@ -3,38 +3,32 @@ const tableName = 'addresses' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('address_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('address_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('address_1') - table.string('address_2') - table.string('address_3') - table.string('address_4') - table.string('town') - table.string('county') - table.string('postcode') - table.string('country') - table.string('external_id').unique() - table.boolean('is_test').notNullable().defaultTo(false) - table.string('data_source').notNullable() - table.integer('uprn').unique() - table.string('last_hash') - table.string('current_hash') + // Data + table.string('address_1') + table.string('address_2') + table.string('address_3') + table.string('address_4') + table.string('town') + table.string('county') + table.string('postcode') + table.string('country') + table.string('external_id').unique() + table.boolean('is_test').notNullable().defaultTo(false) + table.string('data_source').notNullable() + table.integer('uprn').unique() + table.string('last_hash') + table.string('current_hash') - // Legacy timestamps - table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003002_crm-v2-contacts.js b/db/migrations/legacy/20221108003002_crm-v2-contacts.js index f5f6643010..3d7fe2ef36 100644 --- a/db/migrations/legacy/20221108003002_crm-v2-contacts.js +++ b/db/migrations/legacy/20221108003002_crm-v2-contacts.js @@ -3,38 +3,32 @@ const tableName = 'contacts' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('contact_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('contact_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('salutation') - table.string('first_name') - table.string('middle_initials') - table.string('last_name') - table.string('external_id').unique() - table.string('initials') - table.boolean('is_test').notNullable().defaultTo(false) - table.string('data_source').notNullable() - table.string('contact_type') - table.string('suffix') - table.string('department') - table.string('last_hash') - table.string('current_hash') - table.string('email') + // Data + table.string('salutation') + table.string('first_name') + table.string('middle_initials') + table.string('last_name') + table.string('external_id').unique() + table.string('initials') + table.boolean('is_test').notNullable().defaultTo(false) + table.string('data_source').notNullable() + table.string('contact_type') + table.string('suffix') + table.string('department') + table.string('last_hash') + table.string('current_hash') + table.string('email') - // Legacy timestamps - table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003003_crm-v2-companies.js b/db/migrations/legacy/20221108003003_crm-v2-companies.js index 641cbde754..341e29a2cc 100644 --- a/db/migrations/legacy/20221108003003_crm-v2-companies.js +++ b/db/migrations/legacy/20221108003003_crm-v2-companies.js @@ -3,32 +3,26 @@ const tableName = 'companies' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('company_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('company_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('name').notNullable() - table.string('type') - table.string('company_number').unique() - table.string('external_id').unique() - table.boolean('is_test').notNullable().defaultTo(false) - table.string('organisation_type') - table.string('last_hash') - table.uuid('current_hash') + // Data + table.string('name').notNullable() + table.string('type') + table.string('company_number').unique() + table.string('external_id').unique() + table.boolean('is_test').notNullable().defaultTo(false) + table.string('organisation_type') + table.string('last_hash') + table.uuid('current_hash') - // Legacy timestamps - table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003004_crm-v2-documents.js b/db/migrations/legacy/20221108003004_crm-v2-documents.js index 3c4b4d8d22..906cafcf17 100644 --- a/db/migrations/legacy/20221108003004_crm-v2-documents.js +++ b/db/migrations/legacy/20221108003004_crm-v2-documents.js @@ -3,35 +3,29 @@ const tableName = 'documents' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('document_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('document_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('regime').notNullable().defaultTo('water') - table.string('document_type').notNullable().defaultTo('abstraction_licence') - table.string('document_ref').notNullable() - table.date('start_date').notNullable() - table.date('end_date') - table.string('external_id') - table.boolean('is_test').notNullable().defaultTo(false) - table.timestamp('date_deleted') + // Data + table.string('regime').notNullable().defaultTo('water') + table.string('document_type').notNullable().defaultTo('abstraction_licence') + table.string('document_ref').notNullable() + table.date('start_date').notNullable() + table.date('end_date') + table.string('external_id') + table.boolean('is_test').notNullable().defaultTo(false) + table.timestamp('date_deleted') - // Legacy timestamps - table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['document_ref']) - }) + // Constraints + table.unique(['document_ref']) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003005_crm-v2-roles.js b/db/migrations/legacy/20221108003005_crm-v2-roles.js index a5b3251a6b..43fa3e7301 100644 --- a/db/migrations/legacy/20221108003005_crm-v2-roles.js +++ b/db/migrations/legacy/20221108003005_crm-v2-roles.js @@ -3,26 +3,20 @@ const tableName = 'roles' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('role_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('role_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('name').notNullable() - table.string('label') + // Data + table.string('name').notNullable() + table.string('label') - // Legacy timestamps - table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003006_crm-v2-document-roles.js b/db/migrations/legacy/20221108003006_crm-v2-document-roles.js index 26dde01581..ebf59fb104 100644 --- a/db/migrations/legacy/20221108003006_crm-v2-document-roles.js +++ b/db/migrations/legacy/20221108003006_crm-v2-document-roles.js @@ -3,10 +3,11 @@ const tableName = 'document_roles' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { + return ( + // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks + // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after + // Knex has created the table. + knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { // Primary Key table.uuid('document_role_id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -27,22 +28,16 @@ exports.up = function (knex) { // Constraints table.unique(['document_id', 'role_id', 'start_date'], { useConstraint: true }) - }) - // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks - // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after - // Knex has created the table. - .raw(` + }).raw(` ALTER TABLE crm_v2.document_roles ADD CONSTRAINT company_or_invoice_account CHECK ( ((company_id IS NOT NULL AND address_id IS NOT NULL) OR invoice_account_id IS NOT NULL) ); `) + ) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003007_crm-v2-invoice-accounts.js b/db/migrations/legacy/20221108003007_crm-v2-invoice-accounts.js index 4789429ed3..5b40cf2497 100644 --- a/db/migrations/legacy/20221108003007_crm-v2-invoice-accounts.js +++ b/db/migrations/legacy/20221108003007_crm-v2-invoice-accounts.js @@ -3,34 +3,31 @@ const tableName = 'invoice_accounts' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('invoice_account_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('invoice_account_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('company_id').notNullable() - table.string('invoice_account_number').notNullable().unique() - table.date('start_date') - table.date('end_date') - table.boolean('is_test').notNullable().defaultTo(false) - table.string('last_transaction_file_reference') - table.timestamp('date_last_transaction_file_reference_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Data + table.uuid('company_id').notNullable() + table.string('invoice_account_number').notNullable().unique() + table.date('start_date') + table.date('end_date') + table.boolean('is_test').notNullable().defaultTo(false) + table.string('last_transaction_file_reference') + table + .timestamp('date_last_transaction_file_reference_updated', { useTz: false }) + .notNullable() + .defaultTo(knex.fn.now()) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['company_id', 'invoice_account_number'], { useConstraint: true }) - }) + // Constraints + table.unique(['company_id', 'invoice_account_number'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003008_crm-v2-invoice-account-addresses.js b/db/migrations/legacy/20221108003008_crm-v2-invoice-account-addresses.js index 0eebb20aff..87065bf2bb 100644 --- a/db/migrations/legacy/20221108003008_crm-v2-invoice-account-addresses.js +++ b/db/migrations/legacy/20221108003008_crm-v2-invoice-account-addresses.js @@ -3,34 +3,28 @@ const tableName = 'invoice_account_addresses' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('invoice_account_address_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('invoice_account_address_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('invoice_account_id').notNullable() - table.uuid('address_id').notNullable() - table.date('start_date').notNullable() - table.date('end_date') - table.boolean('is_test').notNullable().defaultTo(false) - table.uuid('agent_company_id') - table.uuid('contact_id') + // Data + table.uuid('invoice_account_id').notNullable() + table.uuid('address_id').notNullable() + table.date('start_date').notNullable() + table.date('end_date') + table.boolean('is_test').notNullable().defaultTo(false) + table.uuid('agent_company_id') + table.uuid('contact_id') - // Legacy timestamps - table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created').notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated').notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['invoice_account_id', 'start_date'], { useConstraint: true }) - }) + // Constraints + table.unique(['invoice_account_id', 'start_date'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003009_crm-v2-company-contacts.js b/db/migrations/legacy/20221108003009_crm-v2-company-contacts.js index 57b37d1698..04e10b9cdd 100644 --- a/db/migrations/legacy/20221108003009_crm-v2-company-contacts.js +++ b/db/migrations/legacy/20221108003009_crm-v2-company-contacts.js @@ -3,36 +3,30 @@ const tableName = 'company_contacts' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('company_contact_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('company_contact_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('company_id').notNullable() - table.uuid('contact_id').notNullable() - table.uuid('role_id').notNullable() - table.boolean('is_default').notNullable().defaultTo(false) - table.string('email_address') - table.date('start_date').notNullable() - table.date('end_date') - table.boolean('is_test').notNullable().defaultTo(false) - table.boolean('water_abstraction_alerts_enabled').defaultTo(false) + // Data + table.uuid('company_id').notNullable() + table.uuid('contact_id').notNullable() + table.uuid('role_id').notNullable() + table.boolean('is_default').notNullable().defaultTo(false) + table.string('email_address') + table.date('start_date').notNullable() + table.date('end_date') + table.boolean('is_test').notNullable().defaultTo(false) + table.boolean('water_abstraction_alerts_enabled').defaultTo(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['company_id', 'contact_id', 'role_id', 'start_date'], { useConstraint: true }) - }) + // Constraints + table.unique(['company_id', 'contact_id', 'role_id', 'start_date'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108003010_crm-v2-company-addresses.js b/db/migrations/legacy/20221108003010_crm-v2-company-addresses.js index df446b806f..a7e8b7d2cf 100644 --- a/db/migrations/legacy/20221108003010_crm-v2-company-addresses.js +++ b/db/migrations/legacy/20221108003010_crm-v2-company-addresses.js @@ -3,34 +3,28 @@ const tableName = 'company_addresses' exports.up = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('company_address_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('crm_v2').createTable(tableName, (table) => { + // Primary Key + table.uuid('company_address_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('company_id').notNullable() - table.uuid('address_id').notNullable() - table.uuid('role_id').notNullable() - table.boolean('is_default').notNullable().defaultTo(false) - table.date('start_date').notNullable() - table.date('end_date') - table.boolean('is_test').notNullable().defaultTo(false) + // Data + table.uuid('company_id').notNullable() + table.uuid('address_id').notNullable() + table.uuid('role_id').notNullable() + table.boolean('is_default').notNullable().defaultTo(false) + table.date('start_date').notNullable() + table.date('end_date') + table.boolean('is_test').notNullable().defaultTo(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['company_id', 'address_id', 'role_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['company_id', 'address_id', 'role_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('crm_v2') - .dropTableIfExists(tableName) + return knex.schema.withSchema('crm_v2').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108004001_idm-groups.js b/db/migrations/legacy/20221108004001_idm-groups.js index 1fc3d50bc4..2360bea52c 100644 --- a/db/migrations/legacy/20221108004001_idm-groups.js +++ b/db/migrations/legacy/20221108004001_idm-groups.js @@ -3,30 +3,24 @@ const tableName = 'groups' exports.up = function (knex) { - return knex - .schema - .withSchema('idm') - .createTable(tableName, (table) => { - // Primary Key - table.string('group_id').primary().notNullable() + return knex.schema.withSchema('idm').createTable(tableName, (table) => { + // Primary Key + table.string('group_id').primary().notNullable() - // Data - table.string('application') - table.string('group').notNullable() - table.string('description').notNullable() + // Data + table.string('application') + table.string('group').notNullable() + table.string('description').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['application', 'group'], { useConstraint: true }) - }) + // Constraints + table.unique(['application', 'group'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('idm') - .dropTableIfExists(tableName) + return knex.schema.withSchema('idm').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108004002_idm-roles.js b/db/migrations/legacy/20221108004002_idm-roles.js index f5a7c9d1b9..f6a1f8b31f 100644 --- a/db/migrations/legacy/20221108004002_idm-roles.js +++ b/db/migrations/legacy/20221108004002_idm-roles.js @@ -3,30 +3,24 @@ const tableName = 'roles' exports.up = function (knex) { - return knex - .schema - .withSchema('idm') - .createTable(tableName, (table) => { - // Primary Key - table.string('role_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('idm').createTable(tableName, (table) => { + // Primary Key + table.string('role_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('application') - table.string('role').notNullable() - table.string('description').notNullable() + // Data + table.string('application') + table.string('role').notNullable() + table.string('description').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['application', 'role'], { useConstraint: true }) - }) + // Constraints + table.unique(['application', 'role'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('idm') - .dropTableIfExists(tableName) + return knex.schema.withSchema('idm').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108004003_idm-users.js b/db/migrations/legacy/20221108004003_idm-users.js index f9fa9717b1..59ec4f7d9d 100644 --- a/db/migrations/legacy/20221108004003_idm-users.js +++ b/db/migrations/legacy/20221108004003_idm-users.js @@ -3,40 +3,34 @@ const tableName = 'users' exports.up = function (knex) { - return knex - .schema - .withSchema('idm') - .createTable(tableName, (table) => { - // Primary Key -- note `.increments()` is implicitly the primary key but we add `primary()` to make it explicit - table.increments('user_id').primary() + return knex.schema.withSchema('idm').createTable(tableName, (table) => { + // Primary Key -- note `.increments()` is implicitly the primary key but we add `primary()` to make it explicit + table.increments('user_id').primary() - // Data - table.string('user_name').notNullable() - table.string('password').notNullable() - table.jsonb('user_data') - table.string('reset_guid') - table.bigint('reset_required') + // Data + table.string('user_name').notNullable() + table.string('password').notNullable() + table.jsonb('user_data') + table.string('reset_guid') + table.bigint('reset_required') - table.timestamp('last_login') - table.bigint('bad_logins') - table.string('application') - table.jsonb('role') - table.string('external_id') - table.timestamp('reset_guid_date_created') - table.boolean('enabled').notNullable().defaultTo(true) + table.timestamp('last_login') + table.bigint('bad_logins') + table.string('application') + table.jsonb('role') + table.string('external_id') + table.timestamp('reset_guid_date_created') + table.boolean('enabled').notNullable().defaultTo(true) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['user_name', 'application'], { useConstraint: true }) - }) + // Constraints + table.unique(['user_name', 'application'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('idm') - .dropTableIfExists(tableName) + return knex.schema.withSchema('idm').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108004004_idm-group-roles.js b/db/migrations/legacy/20221108004004_idm-group-roles.js index 13bd33c3b7..8c2aa6c844 100644 --- a/db/migrations/legacy/20221108004004_idm-group-roles.js +++ b/db/migrations/legacy/20221108004004_idm-group-roles.js @@ -3,29 +3,23 @@ const tableName = 'group_roles' exports.up = function (knex) { - return knex - .schema - .withSchema('idm') - .createTable(tableName, (table) => { - // Primary Key - table.string('group_role_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('idm').createTable(tableName, (table) => { + // Primary Key + table.string('group_role_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('group_id').notNullable() - table.string('role_id').notNullable() + // Data + table.string('group_id').notNullable() + table.string('role_id').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['group_id', 'role_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['group_id', 'role_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('idm') - .dropTableIfExists(tableName) + return knex.schema.withSchema('idm').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108004005_idm-user-groups.js b/db/migrations/legacy/20221108004005_idm-user-groups.js index 162c249c03..9564f0361f 100644 --- a/db/migrations/legacy/20221108004005_idm-user-groups.js +++ b/db/migrations/legacy/20221108004005_idm-user-groups.js @@ -3,26 +3,20 @@ const tableName = 'user_groups' exports.up = function (knex) { - return knex - .schema - .withSchema('idm') - .createTable(tableName, (table) => { - // Primary Key - table.string('user_group_id').primary().notNullable() + return knex.schema.withSchema('idm').createTable(tableName, (table) => { + // Primary Key + table.string('user_group_id').primary().notNullable() - // Data - table.integer('user_id').notNullable() - table.string('group_id').notNullable() + // Data + table.integer('user_id').notNullable() + table.string('group_id').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('idm') - .dropTableIfExists(tableName) + return knex.schema.withSchema('idm').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108004006_idm-user-roles.js b/db/migrations/legacy/20221108004006_idm-user-roles.js index ed7948deb1..0263220c43 100644 --- a/db/migrations/legacy/20221108004006_idm-user-roles.js +++ b/db/migrations/legacy/20221108004006_idm-user-roles.js @@ -3,26 +3,20 @@ const tableName = 'user_roles' exports.up = function (knex) { - return knex - .schema - .withSchema('idm') - .createTable(tableName, (table) => { - // Primary Key - table.string('user_role_id').primary().notNullable() + return knex.schema.withSchema('idm').createTable(tableName, (table) => { + // Primary Key + table.string('user_role_id').primary().notNullable() - // Data - table.integer('user_id').notNullable() - table.string('role_id').notNullable() + // Data + table.integer('user_id').notNullable() + table.string('role_id').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('idm') - .dropTableIfExists(tableName) + return knex.schema.withSchema('idm').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108005001_permit-licence.js.js b/db/migrations/legacy/20221108005001_permit-licence.js.js index 7554580c8c..fd217c27aa 100644 --- a/db/migrations/legacy/20221108005001_permit-licence.js.js +++ b/db/migrations/legacy/20221108005001_permit-licence.js.js @@ -3,36 +3,30 @@ const tableName = 'licence' exports.up = function (knex) { - return knex - .schema - .withSchema('permit') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('licence_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('permit').createTable(tableName, (table) => { + // Primary Key + table.uuid('licence_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.integer('licence_status_id').notNullable() - table.integer('licence_type_id').notNullable() - table.integer('licence_regime_id').notNullable() - table.string('licence_search_key') - table.tinyint('is_public_domain') - table.date('licence_start_dt') - table.date('licence_end_dt') - table.string('licence_ref').notNullable() - table.jsonb('licence_data_value') - table.jsonb('licence_summary') - table.jsonb('metadata') - table.dateTime('date_licence_version_purpose_conditions_last_copied') - table.dateTime('date_gauging_station_links_last_copied') + // Data + table.integer('licence_status_id').notNullable() + table.integer('licence_type_id').notNullable() + table.integer('licence_regime_id').notNullable() + table.string('licence_search_key') + table.tinyint('is_public_domain') + table.date('licence_start_dt') + table.date('licence_end_dt') + table.string('licence_ref').notNullable() + table.jsonb('licence_data_value') + table.jsonb('licence_summary') + table.jsonb('metadata') + table.dateTime('date_licence_version_purpose_conditions_last_copied') + table.dateTime('date_gauging_station_links_last_copied') - // Constraints - table.unique(['licence_regime_id', 'licence_type_id', 'licence_ref'], { useConstraint: true }) - }) + // Constraints + table.unique(['licence_regime_id', 'licence_type_id', 'licence_ref'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('permit') - .dropTableIfExists(tableName) + return knex.schema.withSchema('permit').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108006001_returns-returns.js b/db/migrations/legacy/20221108006001_returns-returns.js index c60b30d90f..41fb26d96a 100644 --- a/db/migrations/legacy/20221108006001_returns-returns.js +++ b/db/migrations/legacy/20221108006001_returns-returns.js @@ -3,44 +3,40 @@ const tableName = 'returns' exports.up = function (knex) { - return knex - .schema - .withSchema('returns') - .createTable(tableName, (table) => { - // Primary Key - table.string('return_id').primary() + return knex.schema.withSchema('returns').createTable(tableName, (table) => { + // Primary Key + table.string('return_id').primary() - // Data - table.string('regime').notNullable().defaultTo('water') - table.string('licence_type').notNullable().defaultTo('abstraction') - table.string('licence_ref').notNullable() - table.date('start_date').notNullable() - table.date('end_date').notNullable() - table.string('returns_frequency').notNullable() - table.string('status').notNullable() - table.string('source') - table.jsonb('metadata') - table.date('received_date') - table.string('return_requirement').notNullable() - table.date('due_date').notNullable() - table.boolean('under_query').notNullable().defaultTo(false) - table.string('under_query_comment') - table.boolean('is_test').notNullable().defaultTo(false) - table.uuid('return_cycle_id') + // Data + table.string('regime').notNullable().defaultTo('water') + table.string('licence_type').notNullable().defaultTo('abstraction') + table.string('licence_ref').notNullable() + table.date('start_date').notNullable() + table.date('end_date').notNullable() + table.string('returns_frequency').notNullable() + table.string('status').notNullable() + table.string('source') + table.jsonb('metadata') + table.date('received_date') + table.string('return_requirement').notNullable() + table.date('due_date').notNullable() + table.boolean('under_query').notNullable().defaultTo(false) + table.string('under_query_comment') + table.boolean('is_test').notNullable().defaultTo(false) + table.uuid('return_cycle_id') - // Legacy timestamps - // NOTE: They are not automatically set - table.timestamp('created_at').notNullable() - table.timestamp('updated_at') + // Legacy timestamps + // NOTE: They are not automatically set + table.timestamp('created_at').notNullable() + table.timestamp('updated_at') - // Constraints - table.unique(['regime', 'licence_type', 'licence_ref', 'start_date', 'end_date', 'return_requirement'], { useConstraint: true }) + // Constraints + table.unique(['regime', 'licence_type', 'licence_ref', 'start_date', 'end_date', 'return_requirement'], { + useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('returns') - .dropTableIfExists(tableName) + return knex.schema.withSchema('returns').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108006002_returns-versions.js b/db/migrations/legacy/20221108006002_returns-versions.js index 51fc035697..1d41b93ed1 100644 --- a/db/migrations/legacy/20221108006002_returns-versions.js +++ b/db/migrations/legacy/20221108006002_returns-versions.js @@ -3,35 +3,29 @@ const tableName = 'versions' exports.up = function (knex) { - return knex - .schema - .withSchema('returns') - .createTable(tableName, (table) => { - // Primary Key - table.string('version_id').primary() + return knex.schema.withSchema('returns').createTable(tableName, (table) => { + // Primary Key + table.string('version_id').primary() - // Data - table.string('return_id').notNullable() - table.string('user_id').notNullable() - table.string('user_type').notNullable() - table.integer('version_number').notNullable() - table.jsonb('metadata').notNullable() - table.boolean('nil_return').notNullable() - table.boolean('current') + // Data + table.string('return_id').notNullable() + table.string('user_id').notNullable() + table.string('user_type').notNullable() + table.integer('version_number').notNullable() + table.jsonb('metadata').notNullable() + table.boolean('nil_return').notNullable() + table.boolean('current') - // Legacy timestamps - // NOTE: They are not automatically set - table.timestamp('created_at').notNullable() - table.timestamp('updated_at') + // Legacy timestamps + // NOTE: They are not automatically set + table.timestamp('created_at').notNullable() + table.timestamp('updated_at') - // Constraints - table.unique(['return_id', 'version_number'], { useConstraint: true }) - }) + // Constraints + table.unique(['return_id', 'version_number'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('returns') - .dropTableIfExists(tableName) + return knex.schema.withSchema('returns').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108006003_returns-lines.js b/db/migrations/legacy/20221108006003_returns-lines.js index 1117370d52..87e4be6f0e 100644 --- a/db/migrations/legacy/20221108006003_returns-lines.js +++ b/db/migrations/legacy/20221108006003_returns-lines.js @@ -3,38 +3,32 @@ const tableName = 'lines' exports.up = function (knex) { - return knex - .schema - .withSchema('returns') - .createTable(tableName, (table) => { - // Primary Key - table.string('line_id').primary() + return knex.schema.withSchema('returns').createTable(tableName, (table) => { + // Primary Key + table.string('line_id').primary() - // Data - table.string('version_id').notNullable() - table.string('substance').notNullable().defaultTo('water') - table.decimal('quantity').notNullable() - table.string('unit').notNullable().defaultTo('m³') - table.date('start_date').notNullable() - table.date('end_date').notNullable() - table.string('time_period').notNullable() - table.jsonb('metadata') - table.string('reading_type') - table.string('user_unit') + // Data + table.string('version_id').notNullable() + table.string('substance').notNullable().defaultTo('water') + table.decimal('quantity').notNullable() + table.string('unit').notNullable().defaultTo('m³') + table.date('start_date').notNullable() + table.date('end_date').notNullable() + table.string('time_period').notNullable() + table.jsonb('metadata') + table.string('reading_type') + table.string('user_unit') - // Legacy timestamps - // NOTE: They are not automatically set - table.timestamp('created_at').notNullable() - table.timestamp('updated_at') + // Legacy timestamps + // NOTE: They are not automatically set + table.timestamp('created_at').notNullable() + table.timestamp('updated_at') - // Constraints - table.unique(['version_id', 'substance', 'start_date', 'end_date'], { useConstraint: true }) - }) + // Constraints + table.unique(['version_id', 'substance', 'start_date', 'end_date'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('returns') - .dropTableIfExists(tableName) + return knex.schema.withSchema('returns').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108006004_returns-return-cycles.js b/db/migrations/legacy/20221108006004_returns-return-cycles.js index 8efaab318f..05c07bf2fc 100644 --- a/db/migrations/legacy/20221108006004_returns-return-cycles.js +++ b/db/migrations/legacy/20221108006004_returns-return-cycles.js @@ -3,33 +3,27 @@ const tableName = 'return_cycles' exports.up = function (knex) { - return knex - .schema - .withSchema('returns') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('return_cycle_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('returns').createTable(tableName, (table) => { + // Primary Key + table.uuid('return_cycle_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.date('start_date').notNullable() - table.date('end_date').notNullable() - table.date('due_date').notNullable() - table.boolean('is_summer') - table.boolean('is_submitted_in_wrls') + // Data + table.date('start_date').notNullable() + table.date('end_date').notNullable() + table.date('due_date').notNullable() + table.boolean('is_summer') + table.boolean('is_submitted_in_wrls') - // Legacy timestamps - // NOTE: They are not automatically set - table.timestamp('date_created').notNullable() - table.timestamp('date_updated') + // Legacy timestamps + // NOTE: They are not automatically set + table.timestamp('date_created').notNullable() + table.timestamp('date_updated') - // Constraints - table.unique(['start_date', 'end_date', 'is_summer']) - }) + // Constraints + table.unique(['start_date', 'end_date', 'is_summer']) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('returns') - .dropTableIfExists(tableName) + return knex.schema.withSchema('returns').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007001_water-regions.js b/db/migrations/legacy/20221108007001_water-regions.js index a2df9c440f..d46ee309b1 100644 --- a/db/migrations/legacy/20221108007001_water-regions.js +++ b/db/migrations/legacy/20221108007001_water-regions.js @@ -3,29 +3,23 @@ const tableName = 'regions' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('region_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('region_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('charge_region_id').notNullable() - table.integer('nald_region_id').notNullable() - table.string('name').notNullable() - table.text('display_name').notNullable() - table.boolean('is_test').notNullable().defaultTo(false) + // Data + table.string('charge_region_id').notNullable() + table.integer('nald_region_id').notNullable() + table.string('name').notNullable() + table.text('display_name').notNullable() + table.boolean('is_test').notNullable().defaultTo(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007002_water-billing-charge-categories.js b/db/migrations/legacy/20221108007002_water-billing-charge-categories.js index f1afdf7a61..58c9a1eecc 100755 --- a/db/migrations/legacy/20221108007002_water-billing-charge-categories.js +++ b/db/migrations/legacy/20221108007002_water-billing-charge-categories.js @@ -3,34 +3,28 @@ const tableName = 'billing_charge_categories' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('billing_charge_category_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('billing_charge_category_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('reference').notNullable().unique() - table.integer('subsistence_charge').notNullable() - table.string('description').notNullable() - table.string('short_description').notNullable() - table.boolean('is_tidal').defaultTo(false) - table.string('loss_factor') - table.string('model_tier') - table.boolean('is_restricted_source').defaultTo(false) - table.bigInteger('min_volume').notNullable().defaultTo(0) - table.bigInteger('max_volume').notNullable().defaultTo(0) + // Data + table.string('reference').notNullable().unique() + table.integer('subsistence_charge').notNullable() + table.string('description').notNullable() + table.string('short_description').notNullable() + table.boolean('is_tidal').defaultTo(false) + table.string('loss_factor') + table.string('model_tier') + table.boolean('is_restricted_source').defaultTo(false) + table.bigInteger('min_volume').notNullable().defaultTo(0) + table.bigInteger('max_volume').notNullable().defaultTo(0) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable() - table.timestamp('date_updated', { useTz: false }) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable() + table.timestamp('date_updated', { useTz: false }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007003_water-change-reasons.js b/db/migrations/legacy/20221108007003_water-change-reasons.js index 2ffcfcefd6..0f3214ef56 100644 --- a/db/migrations/legacy/20221108007003_water-change-reasons.js +++ b/db/migrations/legacy/20221108007003_water-change-reasons.js @@ -3,28 +3,22 @@ const tableName = 'change_reasons' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('change_reason_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('change_reason_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('description').notNullable() - table.boolean('triggers_minimum_charge').notNullable().defaultTo(false) - table.string('type').notNullable() - table.boolean('is_enabled_for_new_charge_versions').notNullable() + // Data + table.string('description').notNullable() + table.boolean('triggers_minimum_charge').notNullable().defaultTo(false) + table.string('type').notNullable() + table.boolean('is_enabled_for_new_charge_versions').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable() - table.timestamp('date_updated', { useTz: false }) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable() + table.timestamp('date_updated', { useTz: false }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007004_water-events.js b/db/migrations/legacy/20221108007004_water-events.js index 3225413f58..7a04f9abac 100644 --- a/db/migrations/legacy/20221108007004_water-events.js +++ b/db/migrations/legacy/20221108007004_water-events.js @@ -3,33 +3,27 @@ const tableName = 'events' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('event_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('event_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('reference_code') - table.string('type').notNullable() - table.string('subtype') - table.string('issuer') - table.jsonb('licences') - table.jsonb('entities') - table.string('comment') - table.jsonb('metadata') - table.string('status') + // Data + table.string('reference_code') + table.string('type').notNullable() + table.string('subtype') + table.string('issuer') + table.jsonb('licences') + table.jsonb('entities') + table.string('comment') + table.jsonb('metadata') + table.string('status') - // Legacy timestamps - table.timestamp('created', { precision: 0, useTz: false }) - table.timestamp('modified', { precision: 0, useTz: false }) - }) + // Legacy timestamps + table.timestamp('created', { precision: 0, useTz: false }) + table.timestamp('modified', { precision: 0, useTz: false }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007005_water-purposes-uses.js b/db/migrations/legacy/20221108007005_water-purposes-uses.js index 1b4d32f277..058b89847a 100644 --- a/db/migrations/legacy/20221108007005_water-purposes-uses.js +++ b/db/migrations/legacy/20221108007005_water-purposes-uses.js @@ -3,29 +3,23 @@ const tableName = 'purposes_uses' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('purpose_use_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('purpose_use_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('legacy_id').notNullable().unique() - table.string('description').notNullable() - table.string('loss_factor').notNullable() - table.boolean('is_two_part_tariff').notNullable().defaultTo(false) - table.boolean('is_test').notNullable().defaultTo(false) + // Data + table.string('legacy_id').notNullable().unique() + table.string('description').notNullable() + table.string('loss_factor').notNullable() + table.boolean('is_two_part_tariff').notNullable().defaultTo(false) + table.boolean('is_test').notNullable().defaultTo(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007006_water-licences.js b/db/migrations/legacy/20221108007006_water-licences.js index 8ae221f5d8..a48342124f 100644 --- a/db/migrations/legacy/20221108007006_water-licences.js +++ b/db/migrations/legacy/20221108007006_water-licences.js @@ -3,37 +3,31 @@ const tableName = 'licences' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('licence_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('licence_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('region_id').notNullable() - table.string('licence_ref').notNullable().unique() - table.boolean('is_water_undertaker').notNullable() - table.jsonb('regions').notNullable() - table.date('start_date').notNullable() - table.date('expired_date') - table.date('lapsed_date') - table.date('revoked_date') - table.boolean('suspend_from_billing').notNullable().defaultTo(false) - table.boolean('is_test').notNullable().defaultTo(false) - table.string('include_in_supplementary_billing').notNullable().defaultTo('no') - table.boolean('include_in_sroc_supplementary_billing').notNullable().defaultTo(false) - table.boolean('include_in_sroc_tpt_supplementary_billing').notNullable().defaultTo(false) + // Data + table.uuid('region_id').notNullable() + table.string('licence_ref').notNullable().unique() + table.boolean('is_water_undertaker').notNullable() + table.jsonb('regions').notNullable() + table.date('start_date').notNullable() + table.date('expired_date') + table.date('lapsed_date') + table.date('revoked_date') + table.boolean('suspend_from_billing').notNullable().defaultTo(false) + table.boolean('is_test').notNullable().defaultTo(false) + table.string('include_in_supplementary_billing').notNullable().defaultTo('no') + table.boolean('include_in_sroc_supplementary_billing').notNullable().defaultTo(false) + table.boolean('include_in_sroc_tpt_supplementary_billing').notNullable().defaultTo(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007007_water-licence-versions.js b/db/migrations/legacy/20221108007007_water-licence-versions.js index 7efcbfa0be..6ae663566d 100644 --- a/db/migrations/legacy/20221108007007_water-licence-versions.js +++ b/db/migrations/legacy/20221108007007_water-licence-versions.js @@ -3,33 +3,27 @@ const tableName = 'licence_versions' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('licence_version_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('licence_version_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('licence_id').notNullable() - table.integer('issue').notNullable() - table.integer('increment').notNullable() - table.string('status').notNullable() - table.date('start_date').notNullable() - table.date('end_date') - table.string('external_id').notNullable().unique() - table.boolean('is_test').notNullable().defaultTo(false) + // Data + table.uuid('licence_id').notNullable() + table.integer('issue').notNullable() + table.integer('increment').notNullable() + table.string('status').notNullable() + table.date('start_date').notNullable() + table.date('end_date') + table.string('external_id').notNullable().unique() + table.boolean('is_test').notNullable().defaultTo(false) - // Legacy timestamps - // NOTE: They are not automatically set - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + // NOTE: They are not automatically set + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007008_water-licence-version-purposes-table.js b/db/migrations/legacy/20221108007008_water-licence-version-purposes-table.js index d90f4a135d..d9748f53b2 100644 --- a/db/migrations/legacy/20221108007008_water-licence-version-purposes-table.js +++ b/db/migrations/legacy/20221108007008_water-licence-version-purposes-table.js @@ -3,45 +3,39 @@ const tableName = 'licence_version_purposes' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('licence_version_purpose_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('licence_version_purpose_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('licence_version_id').notNullable() - table.uuid('purpose_primary_id').notNullable() - table.uuid('purpose_secondary_id').notNullable() - table.uuid('purpose_use_id').notNullable() - table.smallint('abstraction_period_start_day').notNullable() - table.smallint('abstraction_period_start_month').notNullable() - table.smallint('abstraction_period_end_day').notNullable() - table.smallint('abstraction_period_end_month').notNullable() - table.date('time_limited_start_date') - table.date('time_limited_end_date') - table.text('notes') - table.decimal('instant_quantity', null, null) - table.decimal('daily_quantity', null, null) - table.decimal('hourly_quantity', null, null) - table.decimal('annual_quantity', null, null) - table.string('external_id').notNullable() - table.boolean('is_test').notNullable().default(false) + // Data + table.uuid('licence_version_id').notNullable() + table.uuid('purpose_primary_id').notNullable() + table.uuid('purpose_secondary_id').notNullable() + table.uuid('purpose_use_id').notNullable() + table.smallint('abstraction_period_start_day').notNullable() + table.smallint('abstraction_period_start_month').notNullable() + table.smallint('abstraction_period_end_day').notNullable() + table.smallint('abstraction_period_end_month').notNullable() + table.date('time_limited_start_date') + table.date('time_limited_end_date') + table.text('notes') + table.decimal('instant_quantity', null, null) + table.decimal('daily_quantity', null, null) + table.decimal('hourly_quantity', null, null) + table.decimal('annual_quantity', null, null) + table.string('external_id').notNullable() + table.boolean('is_test').notNullable().default(false) - // Legacy timestamps - // NOTE: They are not automatically set - table.dateTime('date_created').notNullable().defaultTo(knex.fn.now()) - table.dateTime('date_updated').notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + // NOTE: They are not automatically set + table.dateTime('date_created').notNullable().defaultTo(knex.fn.now()) + table.dateTime('date_updated').notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007009_water-charge-version-workflows.js b/db/migrations/legacy/20221108007009_water-charge-version-workflows.js index 93bd8968c0..2947e760c4 100644 --- a/db/migrations/legacy/20221108007009_water-charge-version-workflows.js +++ b/db/migrations/legacy/20221108007009_water-charge-version-workflows.js @@ -3,10 +3,11 @@ const tableName = 'charge_version_workflows' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { + return ( + // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks + // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after + // Knex has created the table. + knex.schema.withSchema('water').createTable(tableName, (table) => { // Primary Key table.uuid('charge_version_workflow_id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -22,22 +23,16 @@ exports.up = function (knex) { // Legacy timestamps table.timestamp('date_created', { useTz: false }).notNullable() table.timestamp('date_updated', { useTz: false }) - }) - // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks - // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after - // Knex has created the table. - .raw(` + }).raw(` CREATE UNIQUE INDEX unique_licence_version_id_date_deleted_null ON water.charge_version_workflows USING btree ( licence_version_id ) WHERE (date_deleted IS NULL); `) + ) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007010_water-charge-versions.js b/db/migrations/legacy/20221108007010_water-charge-versions.js index 368a05b533..7cc9f52551 100644 --- a/db/migrations/legacy/20221108007010_water-charge-versions.js +++ b/db/migrations/legacy/20221108007010_water-charge-versions.js @@ -3,44 +3,38 @@ const tableName = 'charge_versions' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('charge_version_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('charge_version_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('licence_ref').notNullable() - table.string('scheme').notNullable() - table.string('external_id').unique() - table.integer('version_number').notNullable() - table.date('start_date').notNullable() - table.string('status').notNullable() - table.boolean('apportionment') - table.boolean('error').notNullable().defaultTo(false) - table.date('end_date') - table.date('billed_upto_date') - table.integer('region_code').notNullable() - table.string('source').notNullable() - table.boolean('is_test').notNullable().defaultTo(false) - table.uuid('company_id') - table.uuid('invoice_account_id') - table.uuid('change_reason_id') - table.jsonb('created_by') - table.jsonb('approved_by') - table.uuid('licence_id').notNullable() - table.uuid('note_id') + // Data + table.string('licence_ref').notNullable() + table.string('scheme').notNullable() + table.string('external_id').unique() + table.integer('version_number').notNullable() + table.date('start_date').notNullable() + table.string('status').notNullable() + table.boolean('apportionment') + table.boolean('error').notNullable().defaultTo(false) + table.date('end_date') + table.date('billed_upto_date') + table.integer('region_code').notNullable() + table.string('source').notNullable() + table.boolean('is_test').notNullable().defaultTo(false) + table.uuid('company_id') + table.uuid('invoice_account_id') + table.uuid('change_reason_id') + table.jsonb('created_by') + table.jsonb('approved_by') + table.uuid('licence_id').notNullable() + table.uuid('note_id') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007011_water-charge-elements.js b/db/migrations/legacy/20221108007011_water-charge-elements.js index 4bac7cc1c8..e1512bf3d1 100755 --- a/db/migrations/legacy/20221108007011_water-charge-elements.js +++ b/db/migrations/legacy/20221108007011_water-charge-elements.js @@ -3,10 +3,11 @@ const tableName = 'charge_elements' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { + return ( + // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks + // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after + // Knex has created the table. + knex.schema.withSchema('water').createTable(tableName, (table) => { // Primary Key table.uuid('charge_element_id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -47,22 +48,16 @@ exports.up = function (knex) { // Legacy timestamps table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) - // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks - // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after - // Knex has created the table. - .raw(` + }).raw(` ALTER TABLE water.charge_elements ADD CONSTRAINT volume_authorised_annual_quantity CHECK ( ((volume IS NOT NULL) OR (authorised_annual_quantity IS NOT NULL)) ); `) + ) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007012_water-charge-purposes.js b/db/migrations/legacy/20221108007012_water-charge-purposes.js index 77ec66a545..19063e3eb0 100755 --- a/db/migrations/legacy/20221108007012_water-charge-purposes.js +++ b/db/migrations/legacy/20221108007012_water-charge-purposes.js @@ -3,41 +3,35 @@ const tableName = 'charge_purposes' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('charge_purpose_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('charge_purpose_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('charge_element_id').notNullable() - table.smallint('abstraction_period_start_day').notNullable() - table.smallint('abstraction_period_start_month').notNullable() - table.smallint('abstraction_period_end_day').notNullable() - table.smallint('abstraction_period_end_month').notNullable() - table.decimal('authorised_annual_quantity').notNullable() - table.string('loss').notNullable() - table.boolean('factors_overridden').notNullable() - table.decimal('billable_annual_quantity') - table.date('time_limited_start_date') - table.date('time_limited_end_date') - table.string('description') - table.boolean('is_test').notNullable().defaultTo(false) - table.uuid('purpose_primary_id') - table.uuid('purpose_secondary_id') - table.uuid('purpose_use_id').notNullable() - table.boolean('is_section_127_agreement_enabled').notNullable().defaultTo(true) + // Data + table.uuid('charge_element_id').notNullable() + table.smallint('abstraction_period_start_day').notNullable() + table.smallint('abstraction_period_start_month').notNullable() + table.smallint('abstraction_period_end_day').notNullable() + table.smallint('abstraction_period_end_month').notNullable() + table.decimal('authorised_annual_quantity').notNullable() + table.string('loss').notNullable() + table.boolean('factors_overridden').notNullable() + table.decimal('billable_annual_quantity') + table.date('time_limited_start_date') + table.date('time_limited_end_date') + table.string('description') + table.boolean('is_test').notNullable().defaultTo(false) + table.uuid('purpose_primary_id') + table.uuid('purpose_secondary_id') + table.uuid('purpose_use_id').notNullable() + table.boolean('is_section_127_agreement_enabled').notNullable().defaultTo(true) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007013_water-billing-batches.js b/db/migrations/legacy/20221108007013_water-billing-batches.js index 7c1651a2af..c5b008f5d1 100644 --- a/db/migrations/legacy/20221108007013_water-billing-batches.js +++ b/db/migrations/legacy/20221108007013_water-billing-batches.js @@ -3,47 +3,41 @@ const tableName = 'billing_batches' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('billing_batch_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('billing_batch_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('region_id').notNullable() - table.string('batch_type').notNullable() - table.integer('from_financial_year_ending').notNullable() - table.integer('to_financial_year_ending').notNullable() - table.string('status').notNullable() - table.integer('invoice_count') - table.integer('credit_note_count') - table.integer('net_total') - table.integer('bill_run_number') - table.integer('error_code') - table.uuid('external_id') - table.boolean('is_summer').notNullable().defaultTo(false) - table.string('source').notNullable().defaultTo('wrls') - table.string('legacy_id').unique() - table.jsonb('metadata') - table.decimal('invoice_value') - table.decimal('credit_note_value') - table.string('transaction_file_reference') - table.string('scheme') + // Data + table.uuid('region_id').notNullable() + table.string('batch_type').notNullable() + table.integer('from_financial_year_ending').notNullable() + table.integer('to_financial_year_ending').notNullable() + table.string('status').notNullable() + table.integer('invoice_count') + table.integer('credit_note_count') + table.integer('net_total') + table.integer('bill_run_number') + table.integer('error_code') + table.uuid('external_id') + table.boolean('is_summer').notNullable().defaultTo(false) + table.string('source').notNullable().defaultTo('wrls') + table.string('legacy_id').unique() + table.jsonb('metadata') + table.decimal('invoice_value') + table.decimal('credit_note_value') + table.string('transaction_file_reference') + table.string('scheme') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.check('?? >= 0', ['invoice_count']) - table.check('?? >= 0', ['invoice_value']) - }) + // Constraints + table.check('?? >= 0', ['invoice_count']) + table.check('?? >= 0', ['invoice_value']) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007014_water-billing-volumes.js b/db/migrations/legacy/20221108007014_water-billing-volumes.js index 39e250e2e5..c00516a27f 100644 --- a/db/migrations/legacy/20221108007014_water-billing-volumes.js +++ b/db/migrations/legacy/20221108007014_water-billing-volumes.js @@ -3,10 +3,11 @@ const tableName = 'billing_volumes' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { + return ( + // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks + // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after + // Knex has created the table. + knex.schema.withSchema('water').createTable(tableName, (table) => { // Primary Key table.uuid('billing_volume_id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -23,11 +24,7 @@ exports.up = function (knex) { // Specify the precision and scale table.decimal('volume', 20, 6).defaultTo(0) table.timestamp('errored_on') - }) - // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks - // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after - // Knex has created the table. - .raw(` + }).raw(` CREATE UNIQUE INDEX uniq_charge_element_id_financial_year_season_err ON water.billing_volumes USING btree ( charge_element_id, @@ -37,11 +34,9 @@ exports.up = function (knex) { ) WHERE (errored_on IS NULL); `) + ) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007015_water-billing-invoices.js b/db/migrations/legacy/20221108007015_water-billing-invoices.js index 170ab268b4..eb1c1f191b 100755 --- a/db/migrations/legacy/20221108007015_water-billing-invoices.js +++ b/db/migrations/legacy/20221108007015_water-billing-invoices.js @@ -3,10 +3,11 @@ const tableName = 'billing_invoices' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { + return ( + // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks + // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after + // Knex has created the table. + knex.schema.withSchema('water').createTable(tableName, (table) => { // Primary Key table.uuid('billing_invoice_id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -32,11 +33,7 @@ exports.up = function (knex) { // Legacy timestamps table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) - // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks - // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after - // Knex has created the table. - .raw(` + }).raw(` CREATE UNIQUE INDEX unique_batch_year_invoice ON water.billing_invoices USING btree ( billing_batch_id, @@ -44,8 +41,7 @@ exports.up = function (knex) { invoice_account_id ) WHERE ((legacy_id IS NULL) AND (rebilling_state IS NULL)); - `) - .raw(` + `).raw(` CREATE UNIQUE INDEX unique_batch_year_rebilling_invoice ON water.billing_invoices USING btree ( billing_batch_id, @@ -55,11 +51,9 @@ exports.up = function (knex) { ) WHERE ((legacy_id IS NULL) AND (rebilling_state IS NOT NULL)); `) + ) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007016_water-billing-invoice-licences.js b/db/migrations/legacy/20221108007016_water-billing-invoice-licences.js index e5b31f9501..a15f0ed3c5 100755 --- a/db/migrations/legacy/20221108007016_water-billing-invoice-licences.js +++ b/db/migrations/legacy/20221108007016_water-billing-invoice-licences.js @@ -3,30 +3,24 @@ const tableName = 'billing_invoice_licences' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('billing_invoice_licence_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('billing_invoice_licence_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('billing_invoice_id').notNullable() - table.string('licence_ref').notNullable() - table.uuid('licence_id').notNullable() + // Data + table.uuid('billing_invoice_id').notNullable() + table.string('licence_ref').notNullable() + table.uuid('licence_id').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['billing_invoice_id', 'licence_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['billing_invoice_id', 'licence_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007017_water-billing-transactions.js b/db/migrations/legacy/20221108007017_water-billing-transactions.js index 172deaa0fa..5818b77221 100644 --- a/db/migrations/legacy/20221108007017_water-billing-transactions.js +++ b/db/migrations/legacy/20221108007017_water-billing-transactions.js @@ -3,10 +3,11 @@ const tableName = 'billing_transactions' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { + return ( + // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks + // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after + // Knex has created the table. + knex.schema.withSchema('water').createTable(tableName, (table) => { // Primary Key table.uuid('billing_transaction_id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -68,78 +69,64 @@ exports.up = function (knex) { // Legacy timestamps table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) - // If it was a simple check constraint we could have used https://knexjs.org/guide/schema-builder.html#checks - // But because of the complexity of the constraint we have had to drop to using raw() to add the constraint after - // Knex has created the table. - .raw(` + }).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT abstraction_period_check CHECK ( ((charge_type = 'minimum_charge') OR (abstraction_period IS NOT NULL) OR (scheme = 'sroc')) ); - `) - .raw(` + `).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT charge_element_id_check CHECK ( ((charge_type = 'minimum_charge') OR (charge_element_id IS NOT NULL)) ); - `) - .raw(` + `).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT end_date_check CHECK ( ((charge_type = 'minimum_charge') OR (end_date IS NOT NULL)) ); - `) - .raw(` + `).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT loss_check CHECK ( ((charge_type = 'minimum_charge') OR (loss IS NOT NULL)) ); - `) - .raw(` + `).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT purposes_check CHECK ( ((purposes IS NOT NULL) OR (scheme = 'alcs')) ); - `) - .raw(` + `).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT season_check CHECK ( ((charge_type = 'minimum_charge') OR (season IS NOT NULL) OR (scheme = 'sroc')) ); - `) - .raw(` + `).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT source_check CHECK ( ((charge_type = 'minimum_charge') OR (source IS NOT NULL)) ); - `) - .raw(` + `).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT start_date_check CHECK ( ((charge_type = 'minimum_charge') OR (start_date IS NOT NULL)) ); - `) - .raw(` + `).raw(` ALTER TABLE water.billing_transactions ADD CONSTRAINT volume_check CHECK ( ((charge_type = 'minimum_charge') OR (volume IS NOT NULL)) ); `) + ) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007018_water-billing-batch-charge-version-years.js b/db/migrations/legacy/20221108007018_water-billing-batch-charge-version-years.js index 3d4e3e385d..8f148debec 100644 --- a/db/migrations/legacy/20221108007018_water-billing-batch-charge-version-years.js +++ b/db/migrations/legacy/20221108007018_water-billing-batch-charge-version-years.js @@ -3,35 +3,31 @@ const tableName = 'billing_batch_charge_version_years' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('billing_batch_charge_version_year_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('billing_batch_charge_version_year_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('billing_batch_id').notNullable() - table.uuid('charge_version_id').notNullable() - table.integer('financial_year_ending').notNullable() - table.string('status').notNullable() - table.string('transaction_type').notNullable() - table.boolean('is_summer').notNullable() - table.boolean('has_two_part_agreement').defaultTo(false) - table.boolean('is_chargeable').defaultTo(true) + // Data + table.uuid('billing_batch_id').notNullable() + table.uuid('charge_version_id').notNullable() + table.integer('financial_year_ending').notNullable() + table.string('status').notNullable() + table.string('transaction_type').notNullable() + table.boolean('is_summer').notNullable() + table.boolean('has_two_part_agreement').defaultTo(false) + table.boolean('is_chargeable').defaultTo(true) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['billing_batch_id', 'charge_version_id', 'financial_year_ending', 'transaction_type', 'is_summer'], { useConstraint: true }) + // Constraints + table.unique(['billing_batch_id', 'charge_version_id', 'financial_year_ending', 'transaction_type', 'is_summer'], { + useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007023_water-return-versions.js b/db/migrations/legacy/20221108007023_water-return-versions.js index 267f1a380f..11065a5146 100644 --- a/db/migrations/legacy/20221108007023_water-return-versions.js +++ b/db/migrations/legacy/20221108007023_water-return-versions.js @@ -3,38 +3,32 @@ const tableName = 'return_versions' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('return_version_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('return_version_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('licence_id').notNullable() - table.integer('version_number').notNullable() - table.date('start_date').notNullable() - table.date('end_date') - table.string('status').notNullable() - table.string('external_id') - table.text('reason') - table.boolean('multiple_upload').notNullable().defaultTo(false) - table.boolean('quarterly_returns').notNullable().defaultTo(false) - table.text('notes') - table.integer('created_by') + // Data + table.uuid('licence_id').notNullable() + table.integer('version_number').notNullable() + table.date('start_date').notNullable() + table.date('end_date') + table.string('status').notNullable() + table.string('external_id') + table.text('reason') + table.boolean('multiple_upload').notNullable().defaultTo(false) + table.boolean('quarterly_returns').notNullable().defaultTo(false) + table.text('notes') + table.integer('created_by') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007024_water-return-requirements.js b/db/migrations/legacy/20221108007024_water-return-requirements.js index 922e2089d7..8556c25dea 100644 --- a/db/migrations/legacy/20221108007024_water-return-requirements.js +++ b/db/migrations/legacy/20221108007024_water-return-requirements.js @@ -3,45 +3,39 @@ const tableName = 'return_requirements' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('return_requirement_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('return_requirement_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('return_version_id').notNullable() - table.string('returns_frequency').notNullable() - table.boolean('is_summer').notNullable().defaultTo(false) - table.boolean('is_upload').notNullable().defaultTo(false) - table.smallint('abstraction_period_start_day') - table.smallint('abstraction_period_start_month') - table.smallint('abstraction_period_end_day') - table.smallint('abstraction_period_end_month') - table.string('site_description') - table.string('description') - table.integer('legacy_id') - table.string('external_id') - table.text('collection_frequency').notNullable().defaultTo('day') - table.boolean('gravity_fill').notNullable().defaultTo(false) - table.boolean('reabstraction').notNullable().defaultTo(false) - table.boolean('two_part_tariff').notNullable().defaultTo(false) - table.boolean('fifty_six_exception').notNullable().defaultTo(false) - table.text('reporting_frequency').notNullable().defaultTo('day') + // Data + table.uuid('return_version_id').notNullable() + table.string('returns_frequency').notNullable() + table.boolean('is_summer').notNullable().defaultTo(false) + table.boolean('is_upload').notNullable().defaultTo(false) + table.smallint('abstraction_period_start_day') + table.smallint('abstraction_period_start_month') + table.smallint('abstraction_period_end_day') + table.smallint('abstraction_period_end_month') + table.string('site_description') + table.string('description') + table.integer('legacy_id') + table.string('external_id') + table.text('collection_frequency').notNullable().defaultTo('day') + table.boolean('gravity_fill').notNullable().defaultTo(false) + table.boolean('reabstraction').notNullable().defaultTo(false) + table.boolean('two_part_tariff').notNullable().defaultTo(false) + table.boolean('fifty_six_exception').notNullable().defaultTo(false) + table.text('reporting_frequency').notNullable().defaultTo('day') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007025_water-return-requirement-purposes.js b/db/migrations/legacy/20221108007025_water-return-requirement-purposes.js index 749a1736b4..6c7c5c1fa8 100644 --- a/db/migrations/legacy/20221108007025_water-return-requirement-purposes.js +++ b/db/migrations/legacy/20221108007025_water-return-requirement-purposes.js @@ -3,33 +3,27 @@ const tableName = 'return_requirement_purposes' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('return_requirement_purpose_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('return_requirement_purpose_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('return_requirement_id').notNullable() - table.uuid('purpose_primary_id').notNullable() - table.uuid('purpose_secondary_id').notNullable() - table.uuid('purpose_use_id').notNullable() - table.string('purpose_alias') - table.string('external_id') + // Data + table.uuid('return_requirement_id').notNullable() + table.uuid('purpose_primary_id').notNullable() + table.uuid('purpose_secondary_id').notNullable() + table.uuid('purpose_use_id').notNullable() + table.string('purpose_alias') + table.string('external_id') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007026_water-gauging-stations.js b/db/migrations/legacy/20221108007026_water-gauging-stations.js index 0eeebe8787..bfb57a6d4c 100644 --- a/db/migrations/legacy/20221108007026_water-gauging-stations.js +++ b/db/migrations/legacy/20221108007026_water-gauging-stations.js @@ -3,41 +3,35 @@ const tableName = 'gauging_stations' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('gauging_station_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('gauging_station_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('label').notNullable() - table.decimal('lat') - table.decimal('long') - table.integer('easting') - table.integer('northing') - table.string('grid_reference') - table.string('catchment_name') - table.string('river_name') - table.string('wiski_id') - table.string('station_reference') - table.string('status') - table.jsonb('metadata') - table.uuid('hydrology_station_id').notNullable() - table.boolean('is_test').defaultTo(false) + // Data + table.string('label').notNullable() + table.decimal('lat') + table.decimal('long') + table.integer('easting') + table.integer('northing') + table.string('grid_reference') + table.string('catchment_name') + table.string('river_name') + table.string('wiski_id') + table.string('station_reference') + table.string('status') + table.jsonb('metadata') + table.uuid('hydrology_station_id').notNullable() + table.boolean('is_test').defaultTo(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }) - table.timestamp('date_updated', { useTz: false }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }) + table.timestamp('date_updated', { useTz: false }) - // Constraints - table.unique(['hydrology_station_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['hydrology_station_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007027_water-licence-gauging-stations.js b/db/migrations/legacy/20221108007027_water-licence-gauging-stations.js index e1b09bce06..084236f654 100644 --- a/db/migrations/legacy/20221108007027_water-licence-gauging-stations.js +++ b/db/migrations/legacy/20221108007027_water-licence-gauging-stations.js @@ -3,40 +3,34 @@ const tableName = 'licence_gauging_stations' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('licence_gauging_station_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('licence_gauging_station_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('licence_id').notNullable() - table.uuid('gauging_station_id').notNullable() - table.string('source').notNullable() - table.uuid('licence_version_purpose_condition_id') - table.smallint('abstraction_period_start_day') - table.smallint('abstraction_period_start_month') - table.smallint('abstraction_period_end_day') - table.smallint('abstraction_period_end_month') - table.string('restriction_type').notNullable() - table.string('threshold_unit').notNullable() - table.decimal('threshold_value').notNullable() - table.string('status').notNullable().defaultTo('resume') - table.timestamp('date_status_updated', { useTz: false }) - table.timestamp('date_deleted', { useTz: false }) - table.string('alert_type').notNullable().default('reduce') - table.boolean('is_test').defaultTo(false) + // Data + table.uuid('licence_id').notNullable() + table.uuid('gauging_station_id').notNullable() + table.string('source').notNullable() + table.uuid('licence_version_purpose_condition_id') + table.smallint('abstraction_period_start_day') + table.smallint('abstraction_period_start_month') + table.smallint('abstraction_period_end_day') + table.smallint('abstraction_period_end_month') + table.string('restriction_type').notNullable() + table.string('threshold_unit').notNullable() + table.decimal('threshold_value').notNullable() + table.string('status').notNullable().defaultTo('resume') + table.timestamp('date_status_updated', { useTz: false }) + table.timestamp('date_deleted', { useTz: false }) + table.string('alert_type').notNullable().default('reduce') + table.boolean('is_test').defaultTo(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable() - table.timestamp('date_updated', { useTz: false }).notNullable() - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable() + table.timestamp('date_updated', { useTz: false }).notNullable() + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007028_water-licence-version-purpose-condition-types.js b/db/migrations/legacy/20221108007028_water-licence-version-purpose-condition-types.js index 6297da9d4b..09dff1417c 100644 --- a/db/migrations/legacy/20221108007028_water-licence-version-purpose-condition-types.js +++ b/db/migrations/legacy/20221108007028_water-licence-version-purpose-condition-types.js @@ -3,31 +3,25 @@ const tableName = 'licence_version_purpose_condition_types' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('licence_version_purpose_condition_type_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('licence_version_purpose_condition_type_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('code').notNullable() - table.string('subcode').notNullable() - table.string('description').notNullable() - table.string('subcode_description').notNullable() - table.string('display_title').notNullable() + // Data + table.string('code').notNullable() + table.string('subcode').notNullable() + table.string('description').notNullable() + table.string('subcode_description').notNullable() + table.string('display_title').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.unique(['code', 'subcode'], 'uidx_code_subcode') - }) + table.unique(['code', 'subcode'], 'uidx_code_subcode') + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007029_water-licence-version-purpose-conditions.js b/db/migrations/legacy/20221108007029_water-licence-version-purpose-conditions.js index b22ebdbfbb..7f89cee0ba 100644 --- a/db/migrations/legacy/20221108007029_water-licence-version-purpose-conditions.js +++ b/db/migrations/legacy/20221108007029_water-licence-version-purpose-conditions.js @@ -3,34 +3,28 @@ const tableName = 'licence_version_purpose_conditions' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('licence_version_purpose_condition_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('licence_version_purpose_condition_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('licence_version_purpose_id').notNullable() - table.uuid('licence_version_purpose_condition_type_id').notNullable() - table.string('param_1') - table.string('param_2') - table.string('notes') - table.string('external_id').notNullable() - table.string('source').notNullable() + // Data + table.uuid('licence_version_purpose_id').notNullable() + table.uuid('licence_version_purpose_condition_type_id').notNullable() + table.string('param_1') + table.string('param_2') + table.string('notes') + table.string('external_id').notNullable() + table.string('source').notNullable() - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id']) - }) + // Constraints + table.unique(['external_id']) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007030_water-financial-agreement-types.js b/db/migrations/legacy/20221108007030_water-financial-agreement-types.js index 8956466175..ef714e7f29 100644 --- a/db/migrations/legacy/20221108007030_water-financial-agreement-types.js +++ b/db/migrations/legacy/20221108007030_water-financial-agreement-types.js @@ -3,31 +3,25 @@ const tableName = 'financial_agreement_types' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('financial_agreement_type_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('financial_agreement_type_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('financial_agreement_code').notNullable() - table.string('description').notNullable() - table.boolean('disabled').default(false) - table.boolean('is_test').notNullable().default(false) + // Data + table.string('financial_agreement_code').notNullable() + table.string('description').notNullable() + table.boolean('disabled').default(false) + table.boolean('is_test').notNullable().default(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['financial_agreement_code']) - }) + // Constraints + table.unique(['financial_agreement_code']) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007031_water-licence-agreements.js b/db/migrations/legacy/20221108007031_water-licence-agreements.js index 80525f9b20..5e98b0b4df 100644 --- a/db/migrations/legacy/20221108007031_water-licence-agreements.js +++ b/db/migrations/legacy/20221108007031_water-licence-agreements.js @@ -3,32 +3,26 @@ const tableName = 'licence_agreements' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('licence_agreement_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('licence_agreement_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('financial_agreement_type_id').notNullable() - table.string('licence_ref').notNullable() - table.date('start_date').notNullable() - table.date('end_date') - table.date('date_signed') - table.date('date_deleted') - table.string('source').notNullable().default('wrls') - table.boolean('is_test').notNullable().default(false) + // Data + table.uuid('financial_agreement_type_id').notNullable() + table.string('licence_ref').notNullable() + table.date('start_date').notNullable() + table.date('end_date') + table.date('date_signed') + table.date('date_deleted') + table.string('source').notNullable().default('wrls') + table.boolean('is_test').notNullable().default(false) - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007033_water-scheduled-notification.js b/db/migrations/legacy/20221108007033_water-scheduled-notification.js index 85d9cc0b98..f9d1f5faab 100644 --- a/db/migrations/legacy/20221108007033_water-scheduled-notification.js +++ b/db/migrations/legacy/20221108007033_water-scheduled-notification.js @@ -3,46 +3,40 @@ const tableName = 'scheduled_notification' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('recipient') - table.string('message_type') - table.string('message_ref') - table.jsonb('personalisation') - table.timestamp('send_after') - table.string('status') - table.string('log') - table.jsonb('licences') - table.string('individual_entity_id') - table.string('company_entity_id') - table.string('medium') - table.string('notify_id') - table.string('notify_status') - table.string('plaintext') - table.uuid('event_id') - table.jsonb('metadata') - table.bigint('status_checks') - table.timestamp('next_status_check') - table.decimal('notification_type') - table.string('job_id') + // Data + table.string('recipient') + table.string('message_type') + table.string('message_ref') + table.jsonb('personalisation') + table.timestamp('send_after') + table.string('status') + table.string('log') + table.jsonb('licences') + table.string('individual_entity_id') + table.string('company_entity_id') + table.string('medium') + table.string('notify_id') + table.string('notify_status') + table.string('plaintext') + table.uuid('event_id') + table.jsonb('metadata') + table.bigint('status_checks') + table.timestamp('next_status_check') + table.decimal('notification_type') + table.string('job_id') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable() + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable() - // Constraints - table.unique(['job_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['job_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007034_water-return-requirement-points.js b/db/migrations/legacy/20221108007034_water-return-requirement-points.js index d4a8c296e3..e88e379a9b 100644 --- a/db/migrations/legacy/20221108007034_water-return-requirement-points.js +++ b/db/migrations/legacy/20221108007034_water-return-requirement-points.js @@ -3,36 +3,30 @@ const tableName = 'return_requirement_points' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('return_requirement_id').notNullable() - table.text('description') - table.text('ngr_1') - table.text('ngr_2') - table.text('ngr_3') - table.text('ngr_4') - table.text('external_id') - table.integer('nald_point_id') - table.uuid('point_id') + // Data + table.uuid('return_requirement_id').notNullable() + table.text('description') + table.text('ngr_1') + table.text('ngr_2') + table.text('ngr_3') + table.text('ngr_4') + table.text('external_id') + table.integer('nald_point_id') + table.uuid('point_id') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007035_water-purposes-primary.js b/db/migrations/legacy/20221108007035_water-purposes-primary.js index 8b180d4625..8a0a45f55a 100644 --- a/db/migrations/legacy/20221108007035_water-purposes-primary.js +++ b/db/migrations/legacy/20221108007035_water-purposes-primary.js @@ -3,30 +3,24 @@ const tableName = 'purposes_primary' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('purpose_primary_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('purpose_primary_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('legacy_id').notNullable() - table.string('description').notNullable() - table.boolean('is_test') + // Data + table.string('legacy_id').notNullable() + table.string('description').notNullable() + table.boolean('is_test') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['legacy_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['legacy_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007036_water-purposes-secondary.js b/db/migrations/legacy/20221108007036_water-purposes-secondary.js index a8ea5e8194..8ca2158be6 100644 --- a/db/migrations/legacy/20221108007036_water-purposes-secondary.js +++ b/db/migrations/legacy/20221108007036_water-purposes-secondary.js @@ -3,30 +3,24 @@ const tableName = 'purposes_secondary' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('purpose_secondary_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('purpose_secondary_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('legacy_id').notNullable() - table.string('description').notNullable() - table.boolean('is_test') + // Data + table.string('legacy_id').notNullable() + table.string('description').notNullable() + table.boolean('is_test') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['legacy_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['legacy_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007037_water-notes.js b/db/migrations/legacy/20221108007037_water-notes.js index b18249e137..216be29244 100644 --- a/db/migrations/legacy/20221108007037_water-notes.js +++ b/db/migrations/legacy/20221108007037_water-notes.js @@ -3,29 +3,23 @@ const tableName = 'notes' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('note_id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('note_id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.string('text').notNullable() - table.integer('user_id').notNullable() - table.string('type').notNullable().defaultTo('charge_version') - table.uuid('type_id') - table.uuid('licence_id') + // Data + table.string('text').notNullable() + table.integer('user_id').notNullable() + table.string('type').notNullable().defaultTo('charge_version') + table.uuid('type_id') + table.uuid('licence_id') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007038_water-mod-logs.js b/db/migrations/legacy/20221108007038_water-mod-logs.js index 7c79ae9866..8b501c9dca 100644 --- a/db/migrations/legacy/20221108007038_water-mod-logs.js +++ b/db/migrations/legacy/20221108007038_water-mod-logs.js @@ -3,51 +3,45 @@ const tableName = 'mod_logs' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - - // Data - table.string('external_id').notNullable() - table.string('event_code').notNullable() - table.string('event_description').notNullable() - - table.string('reason_type') - table.string('reason_code') - table.string('reason_description') - - table.date('nald_date').notNullable() - table.string('user_id').notNullable() - table.text('note') - - table.string('licence_ref').notNullable() - table.string('licence_external_id').notNullable() - table.uuid('licence_id') - - table.string('licence_version_external_id') - table.uuid('licence_version_id') - - table.string('charge_version_external_id') - table.uuid('charge_version_id') - - table.string('return_version_external_id') - table.uuid('return_version_id') - - // Timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + + // Data + table.string('external_id').notNullable() + table.string('event_code').notNullable() + table.string('event_description').notNullable() + + table.string('reason_type') + table.string('reason_code') + table.string('reason_description') + + table.date('nald_date').notNullable() + table.string('user_id').notNullable() + table.text('note') + + table.string('licence_ref').notNullable() + table.string('licence_external_id').notNullable() + table.uuid('licence_id') + + table.string('licence_version_external_id') + table.uuid('licence_version_id') + + table.string('charge_version_external_id') + table.uuid('charge_version_id') + + table.string('return_version_external_id') + table.uuid('return_version_id') + + // Timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007039_water-licence-version-purpose-points.js b/db/migrations/legacy/20221108007039_water-licence-version-purpose-points.js index d34273fa4d..e8bef4d5ec 100644 --- a/db/migrations/legacy/20221108007039_water-licence-version-purpose-points.js +++ b/db/migrations/legacy/20221108007039_water-licence-version-purpose-points.js @@ -3,37 +3,31 @@ const tableName = 'licence_version_purpose_points' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('licence_version_purpose_id').notNullable() - table.text('description') - table.text('ngr_1') - table.text('ngr_2') - table.text('ngr_3') - table.text('ngr_4') - table.text('external_id') - table.integer('nald_point_id') - table.uuid('point_id') - table.text('abstraction_method') + // Data + table.uuid('licence_version_purpose_id').notNullable() + table.text('description') + table.text('ngr_1') + table.text('ngr_2') + table.text('ngr_3') + table.text('ngr_4') + table.text('external_id') + table.integer('nald_point_id') + table.uuid('point_id') + table.text('abstraction_method') - // Legacy timestamps - table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('date_created', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('date_updated', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007040_water-sources.js b/db/migrations/legacy/20221108007040_water-sources.js index e0c859cfca..631de3a214 100644 --- a/db/migrations/legacy/20221108007040_water-sources.js +++ b/db/migrations/legacy/20221108007040_water-sources.js @@ -3,32 +3,26 @@ const tableName = 'sources' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.text('description').notNullable() - table.text('source_type').notNullable() - table.text('ngr').notNullable() - table.text('external_id').notNullable() - table.text('legacy_id').notNullable() + // Data + table.text('description').notNullable() + table.text('source_type').notNullable() + table.text('ngr').notNullable() + table.text('external_id').notNullable() + table.text('legacy_id').notNullable() - // Legacy timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Legacy timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007041_water-points.js b/db/migrations/legacy/20221108007041_water-points.js index c6abe4105b..893178e119 100644 --- a/db/migrations/legacy/20221108007041_water-points.js +++ b/db/migrations/legacy/20221108007041_water-points.js @@ -3,43 +3,37 @@ const tableName = 'points' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.text('description').notNullable() - table.text('ngr_1').notNullable() - table.text('ngr_2') - table.text('ngr_3') - table.text('ngr_4') - table.uuid('source_id').notNullable() - table.text('category') - table.text('primary_type') - table.text('secondary_type') - table.text('note') - table.text('location_note') - table.decimal('depth') - table.text('bgs_reference') - table.text('well_reference') - table.text('hydro_reference') - table.decimal('hydro_intercept_distance') - table.decimal('hydro_offset_distance') - table.text('external_id').notNullable() - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + // Data + table.text('description').notNullable() + table.text('ngr_1').notNullable() + table.text('ngr_2') + table.text('ngr_3') + table.text('ngr_4') + table.uuid('source_id').notNullable() + table.text('category') + table.text('primary_type') + table.text('secondary_type') + table.text('note') + table.text('location_note') + table.decimal('depth') + table.text('bgs_reference') + table.text('well_reference') + table.text('hydro_reference') + table.decimal('hydro_intercept_distance') + table.decimal('hydro_offset_distance') + table.text('external_id').notNullable() + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - // Constraints - table.unique(['external_id'], { useConstraint: true }) - }) + // Constraints + table.unique(['external_id'], { useConstraint: true }) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007042_water-licence-supplementary-years.js b/db/migrations/legacy/20221108007042_water-licence-supplementary-years.js index 0633bd255b..da40ea3340 100644 --- a/db/migrations/legacy/20221108007042_water-licence-supplementary-years.js +++ b/db/migrations/legacy/20221108007042_water-licence-supplementary-years.js @@ -3,28 +3,22 @@ const tableName = 'licence_supplementary_years' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('licence_id').notNullable() - table.uuid('bill_run_id') - table.integer('financial_year_end').notNullable() - table.boolean('two_part_tariff') + // Data + table.uuid('licence_id').notNullable() + table.uuid('bill_run_id') + table.integer('financial_year_end').notNullable() + table.boolean('two_part_tariff') - // Timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007043_water-review-charge-elements.js b/db/migrations/legacy/20221108007043_water-review-charge-elements.js index 9ee5fd5e03..b8a918fb16 100644 --- a/db/migrations/legacy/20221108007043_water-review-charge-elements.js +++ b/db/migrations/legacy/20221108007043_water-review-charge-elements.js @@ -3,32 +3,26 @@ const tableName = 'review_charge_elements' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('review_charge_reference_id').notNullable() - table.uuid('charge_element_id').notNullable() - // Specifying `null, null` creates a decimal column that can store numbers of any precision and scale - table.decimal('allocated', null, null).notNullable().defaultTo(0) - table.decimal('amended_allocated', null, null).notNullable().defaultTo(0) - table.boolean('charge_dates_overlap').notNullable().defaultTo(false) - table.text('issues') - table.string('status').notNullable().defaultTo('ready') + // Data + table.uuid('review_charge_reference_id').notNullable() + table.uuid('charge_element_id').notNullable() + // Specifying `null, null` creates a decimal column that can store numbers of any precision and scale + table.decimal('allocated', null, null).notNullable().defaultTo(0) + table.decimal('amended_allocated', null, null).notNullable().defaultTo(0) + table.boolean('charge_dates_overlap').notNullable().defaultTo(false) + table.text('issues') + table.string('status').notNullable().defaultTo('ready') - // Timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007044_water-review-charge-element-returns.js b/db/migrations/legacy/20221108007044_water-review-charge-element-returns.js index 1ce014ec0a..3891da32d8 100644 --- a/db/migrations/legacy/20221108007044_water-review-charge-element-returns.js +++ b/db/migrations/legacy/20221108007044_water-review-charge-element-returns.js @@ -3,26 +3,20 @@ const tableName = 'review_charge_element_returns' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('review_charge_element_id').notNullable() - table.uuid('review_return_id').notNullable() + // Data + table.uuid('review_charge_element_id').notNullable() + table.uuid('review_return_id').notNullable() - // Timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007045_water-review-charge-references.js b/db/migrations/legacy/20221108007045_water-review-charge-references.js index 7414a34f0b..a552d56e42 100644 --- a/db/migrations/legacy/20221108007045_water-review-charge-references.js +++ b/db/migrations/legacy/20221108007045_water-review-charge-references.js @@ -3,37 +3,31 @@ const tableName = 'review_charge_references' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('review_charge_version_id').notNullable() - table.uuid('charge_reference_id').notNullable() - // Specifying `null, null` creates a decimal column that can store numbers of any precision and scale - table.decimal('aggregate', null, null).notNullable().defaultTo(1) - table.decimal('amended_aggregate', null, null).notNullable().defaultTo(1) - table.decimal('authorised_volume', null, null).notNullable().defaultTo(0) - table.decimal('amended_authorised_volume', null, null).notNullable().defaultTo(0) - table.decimal('charge_adjustment', null, null).notNullable().defaultTo(1) - table.decimal('amended_charge_adjustment', null, null).notNullable().defaultTo(1) - table.decimal('abatement_agreement', null, null).notNullable().defaultTo(1) - table.boolean('winter_discount').notNullable().defaultTo(false) - table.boolean('two_part_tariff_agreement').notNullable().defaultTo(false) - table.boolean('canal_and_river_trust_agreement').notNullable().defaultTo(false) + // Data + table.uuid('review_charge_version_id').notNullable() + table.uuid('charge_reference_id').notNullable() + // Specifying `null, null` creates a decimal column that can store numbers of any precision and scale + table.decimal('aggregate', null, null).notNullable().defaultTo(1) + table.decimal('amended_aggregate', null, null).notNullable().defaultTo(1) + table.decimal('authorised_volume', null, null).notNullable().defaultTo(0) + table.decimal('amended_authorised_volume', null, null).notNullable().defaultTo(0) + table.decimal('charge_adjustment', null, null).notNullable().defaultTo(1) + table.decimal('amended_charge_adjustment', null, null).notNullable().defaultTo(1) + table.decimal('abatement_agreement', null, null).notNullable().defaultTo(1) + table.boolean('winter_discount').notNullable().defaultTo(false) + table.boolean('two_part_tariff_agreement').notNullable().defaultTo(false) + table.boolean('canal_and_river_trust_agreement').notNullable().defaultTo(false) - // Timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007046_water-review-charge-versions.js b/db/migrations/legacy/20221108007046_water-review-charge-versions.js index 177d9bfac9..e37b7714ce 100644 --- a/db/migrations/legacy/20221108007046_water-review-charge-versions.js +++ b/db/migrations/legacy/20221108007046_water-review-charge-versions.js @@ -3,29 +3,23 @@ const tableName = 'review_charge_versions' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('review_licence_id').notNullable() - table.uuid('charge_version_id').notNullable() - table.string('change_reason').notNullable() - table.date('charge_period_start_date').notNullable() - table.date('charge_period_end_date').notNullable() + // Data + table.uuid('review_licence_id').notNullable() + table.uuid('charge_version_id').notNullable() + table.string('change_reason').notNullable() + table.date('charge_period_start_date').notNullable() + table.date('charge_period_end_date').notNullable() - // Timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007047_water-review-licences.js b/db/migrations/legacy/20221108007047_water-review-licences.js index a13ba9a50c..a2bebb5c32 100644 --- a/db/migrations/legacy/20221108007047_water-review-licences.js +++ b/db/migrations/legacy/20221108007047_water-review-licences.js @@ -3,31 +3,25 @@ const tableName = 'review_licences' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('bill_run_id').notNullable() - table.uuid('licence_id').notNullable() - table.string('licence_ref').notNullable() - table.string('licence_holder').notNullable() - table.text('issues') - table.string('status').notNullable().defaultTo('ready') - table.boolean('progress').notNullable().defaultTo(false) + // Data + table.uuid('bill_run_id').notNullable() + table.uuid('licence_id').notNullable() + table.string('licence_ref').notNullable() + table.string('licence_holder').notNullable() + table.text('issues') + table.string('status').notNullable().defaultTo('ready') + table.boolean('progress').notNullable().defaultTo(false) - // Timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/legacy/20221108007048_water-review-returns.js b/db/migrations/legacy/20221108007048_water-review-returns.js index c22b537ddb..bc77a47c6f 100644 --- a/db/migrations/legacy/20221108007048_water-review-returns.js +++ b/db/migrations/legacy/20221108007048_water-review-returns.js @@ -3,41 +3,35 @@ const tableName = 'review_returns' exports.up = function (knex) { - return knex - .schema - .withSchema('water') - .createTable(tableName, (table) => { - // Primary Key - table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) + return knex.schema.withSchema('water').createTable(tableName, (table) => { + // Primary Key + table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) - // Data - table.uuid('review_licence_id').notNullable() - table.string('return_id').notNullable() - table.string('return_reference').notNullable() - // Specifying `null, null` creates a decimal column that can store numbers of any precision and scale - table.decimal('quantity', null, null).notNullable().defaultTo(0) - table.decimal('allocated', null, null).notNullable().defaultTo(0) - table.boolean('under_query').notNullable().defaultTo(false) - table.string('return_status').notNullable() - table.boolean('nil_return').notNullable().defaultTo(false) - table.boolean('abstraction_outside_period').notNullable().defaultTo(false) - table.date('received_date') - table.date('due_date').notNullable() - table.jsonb('purposes') - table.string('description') - table.date('start_date').notNullable() - table.date('end_date').notNullable() - table.text('issues') + // Data + table.uuid('review_licence_id').notNullable() + table.string('return_id').notNullable() + table.string('return_reference').notNullable() + // Specifying `null, null` creates a decimal column that can store numbers of any precision and scale + table.decimal('quantity', null, null).notNullable().defaultTo(0) + table.decimal('allocated', null, null).notNullable().defaultTo(0) + table.boolean('under_query').notNullable().defaultTo(false) + table.string('return_status').notNullable() + table.boolean('nil_return').notNullable().defaultTo(false) + table.boolean('abstraction_outside_period').notNullable().defaultTo(false) + table.date('received_date') + table.date('due_date').notNullable() + table.jsonb('purposes') + table.string('description') + table.date('start_date').notNullable() + table.date('end_date').notNullable() + table.text('issues') - // Timestamps - table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) - }) + // Timestamps + table.timestamp('created_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + table.timestamp('updated_at', { useTz: false }).notNullable().defaultTo(knex.fn.now()) + }) } exports.down = function (knex) { - return knex - .schema - .withSchema('water') - .dropTableIfExists(tableName) + return knex.schema.withSchema('water').dropTableIfExists(tableName) } diff --git a/db/migrations/public/20231120122556_create-return-logs-view.js b/db/migrations/public/20231120122556_create-return-logs-view.js index b0bf458b77..99b51630a4 100644 --- a/db/migrations/public/20231120122556_create-return-logs-view.js +++ b/db/migrations/public/20231120122556_create-return-logs-view.js @@ -3,11 +3,10 @@ const viewName = 'return_logs' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('returns').withSchema('returns').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('returns').withSchema('returns').select([ 'return_id AS id', // 'regime', // always 'water' // 'licence_type', // always 'abstraction' @@ -27,12 +26,11 @@ exports.up = function (knex) { // 'return_cycle_id' // is populated but links to a table that does not appear to be used 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231120140419_create-return-submissions-view.js b/db/migrations/public/20231120140419_create-return-submissions-view.js index 73613e39a9..8b6c743ee8 100644 --- a/db/migrations/public/20231120140419_create-return-submissions-view.js +++ b/db/migrations/public/20231120140419_create-return-submissions-view.js @@ -3,26 +3,26 @@ const viewName = 'return_submissions' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('versions').withSchema('returns').select([ - 'version_id AS id', - 'return_id as return_log_id', - 'user_id', - 'user_type', - 'version_number as version', - 'metadata', - 'nil_return', - 'current', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('versions') + .withSchema('returns') + .select([ + 'version_id AS id', + 'return_id as return_log_id', + 'user_id', + 'user_type', + 'version_number as version', + 'metadata', + 'nil_return', + 'current', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231120141532_create-return-submission-lines-view.js b/db/migrations/public/20231120141532_create-return-submission-lines-view.js index 6654f906bd..2220cad017 100644 --- a/db/migrations/public/20231120141532_create-return-submission-lines-view.js +++ b/db/migrations/public/20231120141532_create-return-submission-lines-view.js @@ -3,11 +3,10 @@ const viewName = 'return_submission_lines' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('lines').withSchema('returns').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('lines').withSchema('returns').select([ 'line_id AS id', 'version_id AS return_submission_id', // 'substance', // always 'water' @@ -21,12 +20,11 @@ exports.up = function (knex) { 'user_unit', 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231122121546_create-review-charge-element-results.js b/db/migrations/public/20231122121546_create-review-charge-element-results.js index d8fc4509f8..4d640d2607 100644 --- a/db/migrations/public/20231122121546_create-review-charge-element-results.js +++ b/db/migrations/public/20231122121546_create-review-charge-element-results.js @@ -3,8 +3,7 @@ const tableName = 'review_charge_element_results' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -31,7 +30,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20231122145716_create-review-return-results.js b/db/migrations/public/20231122145716_create-review-return-results.js index 4e2db69e18..9bc9439cc2 100644 --- a/db/migrations/public/20231122145716_create-review-return-results.js +++ b/db/migrations/public/20231122145716_create-review-return-results.js @@ -3,8 +3,7 @@ const tableName = 'review_return_results' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -41,7 +40,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20231122152504_create-review-results.js b/db/migrations/public/20231122152504_create-review-results.js index e94b0d184f..38e7e06e29 100644 --- a/db/migrations/public/20231122152504_create-review-results.js +++ b/db/migrations/public/20231122152504_create-review-results.js @@ -3,8 +3,7 @@ const tableName = 'review_results' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -35,7 +34,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20231127190241_create-bill-licences-view.js b/db/migrations/public/20231127190241_create-bill-licences-view.js index e612cc84be..520de35947 100644 --- a/db/migrations/public/20231127190241_create-bill-licences-view.js +++ b/db/migrations/public/20231127190241_create-bill-licences-view.js @@ -3,22 +3,22 @@ const viewName = 'bill_licences' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('billing_invoice_licences').withSchema('water').select([ - 'billing_invoice_licence_id AS id', - 'billing_invoice_id AS bill_id', - 'licence_ref', - 'licence_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('billing_invoice_licences') + .withSchema('water') + .select([ + 'billing_invoice_licence_id AS id', + 'billing_invoice_id AS bill_id', + 'licence_ref', + 'licence_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127193216_create-bills-view.js b/db/migrations/public/20231127193216_create-bills-view.js index 523e4fac2c..07946e06ca 100644 --- a/db/migrations/public/20231127193216_create-bills-view.js +++ b/db/migrations/public/20231127193216_create-bills-view.js @@ -3,36 +3,36 @@ const viewName = 'bills' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('billing_invoices').withSchema('water').select([ - 'billing_invoice_id AS id', - 'invoice_account_id AS billing_account_id', - 'address', - 'invoice_account_number AS account_number', - 'net_amount', - 'is_credit AS credit', - 'billing_batch_id AS bill_run_id', - 'financial_year_ending', - 'invoice_number', - 'legacy_id', - 'metadata', - 'credit_note_value', - 'invoice_value', - 'is_de_minimis AS deminimis', - 'external_id', - 'is_flagged_for_rebilling AS flagged_for_rebilling', - 'original_billing_invoice_id AS original_bill_id', - 'rebilling_state', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('billing_invoices') + .withSchema('water') + .select([ + 'billing_invoice_id AS id', + 'invoice_account_id AS billing_account_id', + 'address', + 'invoice_account_number AS account_number', + 'net_amount', + 'is_credit AS credit', + 'billing_batch_id AS bill_run_id', + 'financial_year_ending', + 'invoice_number', + 'legacy_id', + 'metadata', + 'credit_note_value', + 'invoice_value', + 'is_de_minimis AS deminimis', + 'external_id', + 'is_flagged_for_rebilling AS flagged_for_rebilling', + 'original_billing_invoice_id AS original_bill_id', + 'rebilling_state', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127195654_create-bill-runs-view.js b/db/migrations/public/20231127195654_create-bill-runs-view.js index d1be103406..da21d49974 100644 --- a/db/migrations/public/20231127195654_create-bill-runs-view.js +++ b/db/migrations/public/20231127195654_create-bill-runs-view.js @@ -3,11 +3,10 @@ const viewName = 'bill_runs' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('billing_batches').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('billing_batches').withSchema('water').select([ 'billing_batch_id AS id', 'region_id', 'batch_type', @@ -30,12 +29,11 @@ exports.up = function (knex) { 'scheme', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127202549_create-bill-run-volumes-view.js b/db/migrations/public/20231127202549_create-bill-run-volumes-view.js index 8e0ca0b9b5..5adfb5361b 100644 --- a/db/migrations/public/20231127202549_create-bill-run-volumes-view.js +++ b/db/migrations/public/20231127202549_create-bill-run-volumes-view.js @@ -3,11 +3,10 @@ const viewName = 'bill_run_volumes' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('billing_volumes').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('billing_volumes').withSchema('water').select([ 'billing_volume_id AS id', 'charge_element_id AS charge_reference_id', 'financial_year', @@ -20,12 +19,11 @@ exports.up = function (knex) { 'billing_batch_id AS bill_run_id', 'volume' // 'errored_on' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127204818_create-change-reasons-view.js b/db/migrations/public/20231127204818_create-change-reasons-view.js index 9208901a61..6ce337e9ce 100644 --- a/db/migrations/public/20231127204818_create-change-reasons-view.js +++ b/db/migrations/public/20231127204818_create-change-reasons-view.js @@ -3,23 +3,23 @@ const viewName = 'change_reasons' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('change_reasons').withSchema('water').select([ - 'change_reason_id AS id', - 'description', - 'triggers_minimum_charge', - 'type', - 'is_enabled_for_new_charge_versions AS enabled_for_new_charge_versions', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('change_reasons') + .withSchema('water') + .select([ + 'change_reason_id AS id', + 'description', + 'triggers_minimum_charge', + 'type', + 'is_enabled_for_new_charge_versions AS enabled_for_new_charge_versions', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127205331_create-charge-categories-view.js b/db/migrations/public/20231127205331_create-charge-categories-view.js index 0be42bb17c..3f806fa857 100644 --- a/db/migrations/public/20231127205331_create-charge-categories-view.js +++ b/db/migrations/public/20231127205331_create-charge-categories-view.js @@ -3,29 +3,29 @@ const viewName = 'charge_categories' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('billing_charge_categories').withSchema('water').select([ - 'billing_charge_category_id AS id', - 'reference', - 'subsistence_charge', - 'description', - 'short_description', - 'is_tidal AS tidal', - 'loss_factor', - 'model_tier', - 'is_restricted_source AS restricted_source', - 'min_volume', - 'max_volume', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('billing_charge_categories') + .withSchema('water') + .select([ + 'billing_charge_category_id AS id', + 'reference', + 'subsistence_charge', + 'description', + 'short_description', + 'is_tidal AS tidal', + 'loss_factor', + 'model_tier', + 'is_restricted_source AS restricted_source', + 'min_volume', + 'max_volume', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127211121_create-charge-elements-view.js b/db/migrations/public/20231127211121_create-charge-elements-view.js index 7f76a1fd90..33e740be06 100644 --- a/db/migrations/public/20231127211121_create-charge-elements-view.js +++ b/db/migrations/public/20231127211121_create-charge-elements-view.js @@ -3,11 +3,10 @@ const viewName = 'charge_elements' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('charge_purposes').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('charge_purposes').withSchema('water').select([ 'charge_purpose_id AS id', 'charge_element_id as charge_reference_id', 'abstraction_period_start_day', @@ -28,12 +27,11 @@ exports.up = function (knex) { 'is_section_127_agreement_enabled AS section_127_agreement', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127212015_create-charge-references-view.js b/db/migrations/public/20231127212015_create-charge-references-view.js index 12974c6206..c2e779fdbf 100644 --- a/db/migrations/public/20231127212015_create-charge-references-view.js +++ b/db/migrations/public/20231127212015_create-charge-references-view.js @@ -3,11 +3,10 @@ const viewName = 'charge_references' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('charge_elements').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('charge_elements').withSchema('water').select([ 'charge_element_id AS id', 'charge_version_id', 'external_id', @@ -42,12 +41,11 @@ exports.up = function (knex) { 'eiuc_region', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127214320_create-charge-versions-view.js b/db/migrations/public/20231127214320_create-charge-versions-view.js index 2149b2e530..a171f0f952 100644 --- a/db/migrations/public/20231127214320_create-charge-versions-view.js +++ b/db/migrations/public/20231127214320_create-charge-versions-view.js @@ -3,11 +3,10 @@ const viewName = 'charge_versions' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('charge_versions').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('charge_versions').withSchema('water').select([ 'charge_version_id AS id', 'licence_ref', 'scheme', @@ -31,12 +30,11 @@ exports.up = function (knex) { 'note_id', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127220809_create-events-view.js b/db/migrations/public/20231127220809_create-events-view.js index 993506bfdf..3eea7f2836 100644 --- a/db/migrations/public/20231127220809_create-events-view.js +++ b/db/migrations/public/20231127220809_create-events-view.js @@ -3,11 +3,10 @@ const viewName = 'events' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('events').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('events').withSchema('water').select([ 'event_id AS id', 'reference_code', 'type', @@ -20,12 +19,11 @@ exports.up = function (knex) { 'status', 'created AS created_at', 'modified AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127221645_create-licence-versions-view.js b/db/migrations/public/20231127221645_create-licence-versions-view.js index 097b2b2adb..5b89868d0f 100644 --- a/db/migrations/public/20231127221645_create-licence-versions-view.js +++ b/db/migrations/public/20231127221645_create-licence-versions-view.js @@ -3,11 +3,10 @@ const viewName = 'licence_versions' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_versions').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licence_versions').withSchema('water').select([ 'licence_version_id AS id', 'licence_id', 'issue', @@ -19,12 +18,11 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127222209_create-licences-view.js b/db/migrations/public/20231127222209_create-licences-view.js index bbc8072b07..190f30a58e 100644 --- a/db/migrations/public/20231127222209_create-licences-view.js +++ b/db/migrations/public/20231127222209_create-licences-view.js @@ -3,11 +3,10 @@ const viewName = 'licences' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licences').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licences').withSchema('water').select([ 'licence_id AS id', 'region_id', 'licence_ref', @@ -23,12 +22,11 @@ exports.up = function (knex) { 'include_in_sroc_supplementary_billing AS include_in_sroc_billing', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127222742_create-purposes-view.js b/db/migrations/public/20231127222742_create-purposes-view.js index 39baac0080..9c98742a84 100644 --- a/db/migrations/public/20231127222742_create-purposes-view.js +++ b/db/migrations/public/20231127222742_create-purposes-view.js @@ -3,11 +3,10 @@ const viewName = 'purposes' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('purposes_uses').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('purposes_uses').withSchema('water').select([ 'purpose_use_id AS id', 'legacy_id', 'description', @@ -16,12 +15,11 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127223359_create-regions-view.js b/db/migrations/public/20231127223359_create-regions-view.js index 74492fd8c9..4cae2fcb00 100644 --- a/db/migrations/public/20231127223359_create-regions-view.js +++ b/db/migrations/public/20231127223359_create-regions-view.js @@ -3,11 +3,10 @@ const viewName = 'regions' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('regions').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('regions').withSchema('water').select([ 'region_id AS id', 'charge_region_id', 'nald_region_id', @@ -16,12 +15,11 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127224323_create-transactions-view.js b/db/migrations/public/20231127224323_create-transactions-view.js index c190f97753..b11abf4530 100644 --- a/db/migrations/public/20231127224323_create-transactions-view.js +++ b/db/migrations/public/20231127224323_create-transactions-view.js @@ -3,11 +3,10 @@ const viewName = 'transactions' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('billing_transactions').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('billing_transactions').withSchema('water').select([ 'billing_transaction_id AS id', 'billing_invoice_licence_id as bill_licence_id', 'charge_element_id AS charge_reference_id', @@ -64,12 +63,11 @@ exports.up = function (knex) { 'calc_s_130_factor', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231127230416_create-workflows-view.js b/db/migrations/public/20231127230416_create-workflows-view.js index 255fe7935a..35e0a968ff 100644 --- a/db/migrations/public/20231127230416_create-workflows-view.js +++ b/db/migrations/public/20231127230416_create-workflows-view.js @@ -3,26 +3,26 @@ const viewName = 'workflows' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('charge_version_workflows').withSchema('water').select([ - 'charge_version_workflow_id AS id', - 'licence_id', - 'created_by', - 'approver_comments', - 'status', - 'data', - 'licence_version_id', - 'date_deleted AS deleted_at', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('charge_version_workflows') + .withSchema('water') + .select([ + 'charge_version_workflow_id AS id', + 'licence_id', + 'created_by', + 'approver_comments', + 'status', + 'data', + 'licence_version_id', + 'date_deleted AS deleted_at', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128131625_create-users-view.js b/db/migrations/public/20231128131625_create-users-view.js index 9b4cc9b2f7..d0d81a01bd 100644 --- a/db/migrations/public/20231128131625_create-users-view.js +++ b/db/migrations/public/20231128131625_create-users-view.js @@ -3,11 +3,10 @@ const viewName = 'users' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('users').withSchema('idm').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('users').withSchema('idm').select([ 'users.user_id AS id', 'users.user_name AS username', 'users.password', @@ -23,12 +22,11 @@ exports.up = function (knex) { 'users.enabled', 'users.date_created AS created_at', 'users.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128133650_create-roles-view.js b/db/migrations/public/20231128133650_create-roles-view.js index 218cb3421d..c2d02ac285 100644 --- a/db/migrations/public/20231128133650_create-roles-view.js +++ b/db/migrations/public/20231128133650_create-roles-view.js @@ -3,23 +3,21 @@ const viewName = 'roles' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('roles').withSchema('idm').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('roles').withSchema('idm').select([ 'roles.role_id AS id', // 'roles.application', // is always water_admin 'roles.role', 'roles.description', 'roles.date_created AS created_at', 'roles.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128133938_create-groups-view.js b/db/migrations/public/20231128133938_create-groups-view.js index d7d77a9c3d..a79360e263 100644 --- a/db/migrations/public/20231128133938_create-groups-view.js +++ b/db/migrations/public/20231128133938_create-groups-view.js @@ -3,23 +3,21 @@ const viewName = 'groups' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('groups').withSchema('idm').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('groups').withSchema('idm').select([ 'groups.group_id AS id', // 'groups.application', // is always water_admin 'groups.group', 'groups.description', 'groups.date_created AS created_at', 'groups.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128134441_create-user-roles-view.js b/db/migrations/public/20231128134441_create-user-roles-view.js index 50091bd8a0..7ca2c6be4f 100644 --- a/db/migrations/public/20231128134441_create-user-roles-view.js +++ b/db/migrations/public/20231128134441_create-user-roles-view.js @@ -3,21 +3,21 @@ const viewName = 'user_roles' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('user_roles').withSchema('idm').select([ - 'user_roles.user_role_id AS id', - 'user_roles.user_id', - 'user_roles.role_id', - 'user_roles.date_created AS created_at', - 'user_roles.date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('user_roles') + .withSchema('idm') + .select([ + 'user_roles.user_role_id AS id', + 'user_roles.user_id', + 'user_roles.role_id', + 'user_roles.date_created AS created_at', + 'user_roles.date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128134656_create-user-groups-view.js b/db/migrations/public/20231128134656_create-user-groups-view.js index 60e89d1456..794aaad1eb 100644 --- a/db/migrations/public/20231128134656_create-user-groups-view.js +++ b/db/migrations/public/20231128134656_create-user-groups-view.js @@ -3,21 +3,21 @@ const viewName = 'user_groups' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('user_groups').withSchema('idm').select([ - 'user_groups.user_group_id AS id', - 'user_groups.user_id', - 'user_groups.group_id', - 'user_groups.date_created AS created_at', - 'user_groups.date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('user_groups') + .withSchema('idm') + .select([ + 'user_groups.user_group_id AS id', + 'user_groups.user_id', + 'user_groups.group_id', + 'user_groups.date_created AS created_at', + 'user_groups.date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128134839_create-group-roles-view.js b/db/migrations/public/20231128134839_create-group-roles-view.js index 0d11c2177d..b754a5974f 100644 --- a/db/migrations/public/20231128134839_create-group-roles-view.js +++ b/db/migrations/public/20231128134839_create-group-roles-view.js @@ -3,21 +3,21 @@ const viewName = 'group_roles' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('group_roles').withSchema('idm').select([ - 'group_roles.group_role_id AS id', - 'group_roles.group_id', - 'group_roles.role_id', - 'group_roles.date_created AS created_at', - 'group_roles.date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('group_roles') + .withSchema('idm') + .select([ + 'group_roles.group_role_id AS id', + 'group_roles.group_id', + 'group_roles.role_id', + 'group_roles.date_created AS created_at', + 'group_roles.date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128140249_create-billing-accounts-view.js b/db/migrations/public/20231128140249_create-billing-accounts-view.js index e56eb8f480..e307ee6371 100644 --- a/db/migrations/public/20231128140249_create-billing-accounts-view.js +++ b/db/migrations/public/20231128140249_create-billing-accounts-view.js @@ -3,11 +3,10 @@ const viewName = 'billing_accounts' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('invoice_accounts').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('invoice_accounts').withSchema('crm_v2').select([ 'invoice_accounts.invoice_account_id AS id', 'invoice_accounts.company_id', 'invoice_accounts.invoice_account_number AS account_number', @@ -18,12 +17,11 @@ exports.up = function (knex) { 'invoice_accounts.date_last_transaction_file_reference_updated AS last_transaction_file_created_at', 'invoice_accounts.date_created AS created_at', 'invoice_accounts.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128141428_create-billing-account-addresses-view.js b/db/migrations/public/20231128141428_create-billing-account-addresses-view.js index 5a679d117f..3cdb24ac76 100644 --- a/db/migrations/public/20231128141428_create-billing-account-addresses-view.js +++ b/db/migrations/public/20231128141428_create-billing-account-addresses-view.js @@ -3,11 +3,10 @@ const viewName = 'billing_account_addresses' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('invoice_account_addresses').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('invoice_account_addresses').withSchema('crm_v2').select([ 'invoice_account_addresses.invoice_account_address_id AS id', 'invoice_account_addresses.invoice_account_id AS billing_account_id', 'invoice_account_addresses.address_id', @@ -18,12 +17,11 @@ exports.up = function (knex) { 'invoice_account_addresses.contact_id', 'invoice_account_addresses.date_created AS created_at', 'invoice_account_addresses.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128142558_create-addresses-view.js b/db/migrations/public/20231128142558_create-addresses-view.js index bc1c3bf394..597f9df103 100644 --- a/db/migrations/public/20231128142558_create-addresses-view.js +++ b/db/migrations/public/20231128142558_create-addresses-view.js @@ -3,11 +3,10 @@ const viewName = 'addresses' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('addresses').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('addresses').withSchema('crm_v2').select([ 'addresses.address_id AS id', 'addresses.address_1', 'addresses.address_2', @@ -25,12 +24,11 @@ exports.up = function (knex) { // 'addresses.current_hash', // is populated but is only used by the legacy import process 'addresses.date_created AS created_at', 'addresses.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128143653_create-companies-view.js b/db/migrations/public/20231128143653_create-companies-view.js index cce82e943c..94b115e4a2 100644 --- a/db/migrations/public/20231128143653_create-companies-view.js +++ b/db/migrations/public/20231128143653_create-companies-view.js @@ -3,11 +3,10 @@ const viewName = 'companies' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('companies').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('companies').withSchema('crm_v2').select([ 'companies.company_id AS id', 'companies.name', 'companies.type', @@ -19,12 +18,11 @@ exports.up = function (knex) { // 'companies.current_hash', // is populated but is only used by the legacy import process 'companies.date_created AS created_at', 'companies.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231128143937_create-contacts-view.js b/db/migrations/public/20231128143937_create-contacts-view.js index 6b024d41d8..5c33fc198c 100644 --- a/db/migrations/public/20231128143937_create-contacts-view.js +++ b/db/migrations/public/20231128143937_create-contacts-view.js @@ -3,11 +3,10 @@ const viewName = 'contacts' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('contacts').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('contacts').withSchema('crm_v2').select([ 'contacts.contact_id AS id', 'contacts.salutation', 'contacts.first_name', @@ -25,12 +24,11 @@ exports.up = function (knex) { 'contacts.email', 'contacts.date_created AS created_at', 'contacts.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20231215113321_create-sessions.js b/db/migrations/public/20231215113321_create-sessions.js index 423933da11..a7871991aa 100644 --- a/db/migrations/public/20231215113321_create-sessions.js +++ b/db/migrations/public/20231215113321_create-sessions.js @@ -3,8 +3,7 @@ const tableName = 'sessions' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -26,7 +25,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20231215174532_alter-bill-runs-view.js b/db/migrations/public/20231215174532_alter-bill-runs-view.js index 91d16af93c..f20acd50b0 100644 --- a/db/migrations/public/20231215174532_alter-bill-runs-view.js +++ b/db/migrations/public/20231215174532_alter-bill-runs-view.js @@ -3,44 +3,43 @@ const viewName = 'bill_runs' exports.up = function (knex) { - return knex - .schema - .dropView(viewName) - .createView(viewName, (view) => { - view.as(knex('billing_batches').withSchema('water').select([ - 'billing_batch_id AS id', - 'region_id', - 'batch_type', - 'from_financial_year_ending', - 'to_financial_year_ending', - 'status', - 'invoice_count', - 'credit_note_count', - 'net_total', - 'bill_run_number', - 'error_code', - 'external_id', - 'is_summer AS summer', - 'source', - 'legacy_id', - 'metadata', - 'invoice_value', - 'credit_note_value', - 'transaction_file_reference', - 'scheme', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.dropView(viewName).createView(viewName, (view) => { + view.as( + knex('billing_batches') + .withSchema('water') + .select([ + 'billing_batch_id AS id', + 'region_id', + 'batch_type', + 'from_financial_year_ending', + 'to_financial_year_ending', + 'status', + 'invoice_count', + 'credit_note_count', + 'net_total', + 'bill_run_number', + 'error_code', + 'external_id', + 'is_summer AS summer', + 'source', + 'legacy_id', + 'metadata', + 'invoice_value', + 'credit_note_value', + 'transaction_file_reference', + 'scheme', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropView(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('billing_batches').withSchema('water').select([ + return knex.schema.dropView(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('billing_batches').withSchema('water').select([ 'billing_batch_id AS id', 'region_id', 'batch_type', @@ -63,6 +62,7 @@ exports.down = function (knex) { 'scheme', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20231221144424_create-licence-documents-view.js b/db/migrations/public/20231221144424_create-licence-documents-view.js index 4237c6229d..3a7d6af4ea 100644 --- a/db/migrations/public/20231221144424_create-licence-documents-view.js +++ b/db/migrations/public/20231221144424_create-licence-documents-view.js @@ -3,11 +3,10 @@ const viewName = 'licence_documents' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('documents').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('documents').withSchema('crm_v2').select([ 'document_id AS id', // 'regime', // 'document_type', @@ -18,12 +17,11 @@ exports.up = function (knex) { 'date_deleted AS deleted_at', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240103124409_create-licence-roles-view.js b/db/migrations/public/20240103124409_create-licence-roles-view.js index c000a15d00..24a6928993 100644 --- a/db/migrations/public/20240103124409_create-licence-roles-view.js +++ b/db/migrations/public/20240103124409_create-licence-roles-view.js @@ -3,21 +3,15 @@ const viewName = 'licence_roles' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('roles').withSchema('crm_v2').select([ - 'role_id AS id', - 'name', - 'label', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('roles') + .withSchema('crm_v2') + .select(['role_id AS id', 'name', 'label', 'date_created AS created_at', 'date_updated AS updated_at']) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240103152905_create-licence-document-roles-view.js b/db/migrations/public/20240103152905_create-licence-document-roles-view.js index a697eb948d..585633cf35 100644 --- a/db/migrations/public/20240103152905_create-licence-document-roles-view.js +++ b/db/migrations/public/20240103152905_create-licence-document-roles-view.js @@ -3,11 +3,10 @@ const viewName = 'licence_document_roles' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('document_roles').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('document_roles').withSchema('crm_v2').select([ 'document_role_id AS id', 'document_id AS licence_document_id', 'company_id', @@ -20,12 +19,11 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240107233126_create-licence-document-headers.js b/db/migrations/public/20240107233126_create-licence-document-headers.js index 0a9a287a4a..0b4ecdea00 100644 --- a/db/migrations/public/20240107233126_create-licence-document-headers.js +++ b/db/migrations/public/20240107233126_create-licence-document-headers.js @@ -3,11 +3,10 @@ const viewName = 'licence_document_headers' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('document_header').withSchema('crm').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('document_header').withSchema('crm').select([ 'document_id AS id', // This could be ignored as it is always set to the same ID. But that id comes from a single record in the // crm.entity table which has the `entity_type` regime. So, for the purposes of testing we just have to live @@ -23,12 +22,11 @@ exports.up = function (knex) { 'date_created AS created_at', 'date_updated AS updated_at', 'date_deleted AS deleted_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240127121136_create-licence-entities-view.js b/db/migrations/public/20240127121136_create-licence-entities-view.js index e094f6f816..f039bb7523 100644 --- a/db/migrations/public/20240127121136_create-licence-entities-view.js +++ b/db/migrations/public/20240127121136_create-licence-entities-view.js @@ -3,11 +3,10 @@ const viewName = 'licence_entities' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('entity').withSchema('crm').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('entity').withSchema('crm').select([ 'entity_id AS id', 'entity_nm AS name', 'entity_type AS type', @@ -15,12 +14,11 @@ exports.up = function (knex) { // 'source', 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240127134739_create-licence-entity-roles-view.js b/db/migrations/public/20240127134739_create-licence-entity-roles-view.js index 8cb0072d2a..4eecc37654 100644 --- a/db/migrations/public/20240127134739_create-licence-entity-roles-view.js +++ b/db/migrations/public/20240127134739_create-licence-entity-roles-view.js @@ -3,10 +3,9 @@ const viewName = 'licence_entity_roles' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('entity_roles').withSchema('crm').select([ + return knex.schema.createView(viewName, (view) => { + view.as( + knex('entity_roles').withSchema('crm').select([ 'entity_role_id AS id', 'entity_id AS licence_entity_id', 'role', @@ -18,12 +17,11 @@ exports.up = function (knex) { // NOTE: Can be a UUID to another entity or the email address of the user or NULL 'created_by', 'created_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240127170505_alter-licence-document-headers.js b/db/migrations/public/20240127170505_alter-licence-document-headers.js index bdcbca0222..2de5864ac3 100644 --- a/db/migrations/public/20240127170505_alter-licence-document-headers.js +++ b/db/migrations/public/20240127170505_alter-licence-document-headers.js @@ -3,11 +3,9 @@ const viewName = 'licence_document_headers' exports.up = function (knex) { - return knex - .schema - .dropView(viewName) - .createView(viewName, (view) => { - view.as(knex('document_header').withSchema('crm').select([ + return knex.schema.dropView(viewName).createView(viewName, (view) => { + view.as( + knex('document_header').withSchema('crm').select([ 'document_id AS id', // This could be ignored as it is always set to the same ID. But that id comes from a single record in the // crm.entity table which has the `entity_type` regime. So, for the purposes of testing we just have to live @@ -23,17 +21,16 @@ exports.up = function (knex) { 'date_created AS created_at', 'date_updated AS updated_at', 'date_deleted AS deleted_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropView(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('document_header').withSchema('crm').select([ + return knex.schema.dropView(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('document_header').withSchema('crm').select([ 'document_id AS id', // This could be ignored as it is always set to the same ID. But that id comes from a single record in the // crm.entity table which has the `entity_type` regime. So, for the purposes of testing we just have to live @@ -49,6 +46,7 @@ exports.down = function (knex) { 'date_created AS created_at', 'date_updated AS updated_at', 'date_deleted AS deleted_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240129151549_create-licence-version-purposes-view.js b/db/migrations/public/20240129151549_create-licence-version-purposes-view.js index 6357ac0eb5..7db5265554 100644 --- a/db/migrations/public/20240129151549_create-licence-version-purposes-view.js +++ b/db/migrations/public/20240129151549_create-licence-version-purposes-view.js @@ -3,11 +3,10 @@ const viewName = 'licence_version_purposes' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_version_purposes').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licence_version_purposes').withSchema('water').select([ 'licence_version_purpose_id AS id', 'licence_version_id', 'purpose_primary_id', @@ -25,12 +24,11 @@ exports.up = function (knex) { // 'is_test ', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240214142212_create-permit-licence-view.js b/db/migrations/public/20240214142212_create-permit-licence-view.js index 435ce0ceec..f1031a1e4c 100644 --- a/db/migrations/public/20240214142212_create-permit-licence-view.js +++ b/db/migrations/public/20240214142212_create-permit-licence-view.js @@ -3,30 +3,30 @@ const viewName = 'permit_licences' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('licence').withSchema('permit').select([ - 'licence_id AS id', - 'licence_status_id', - 'licence_type_id', - 'licence_regime_id', - 'licence_search_key', - 'is_public_domain AS public_domain', - 'licence_start_dt AS start_date ', - 'licence_end_dt AS end_date', - 'licence_ref', - 'licence_data_value', - 'licence_summary', - 'metadata', - 'date_licence_version_purpose_conditions_last_copied', - 'date_gauging_station_links_last_copied' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('licence') + .withSchema('permit') + .select([ + 'licence_id AS id', + 'licence_status_id', + 'licence_type_id', + 'licence_regime_id', + 'licence_search_key', + 'is_public_domain AS public_domain', + 'licence_start_dt AS start_date ', + 'licence_end_dt AS end_date', + 'licence_ref', + 'licence_data_value', + 'licence_summary', + 'metadata', + 'date_licence_version_purpose_conditions_last_copied', + 'date_gauging_station_links_last_copied' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240228145034_drop-review-results.js b/db/migrations/public/20240228145034_drop-review-results.js index 158a6b110b..7a81adc301 100644 --- a/db/migrations/public/20240228145034_drop-review-results.js +++ b/db/migrations/public/20240228145034_drop-review-results.js @@ -3,14 +3,11 @@ const tableName = 'review_results' exports.up = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } exports.down = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) diff --git a/db/migrations/public/20240228155509_create-review-licences.js b/db/migrations/public/20240228155509_create-review-licences.js index e6ceb0d0d5..ec1bc276fa 100644 --- a/db/migrations/public/20240228155509_create-review-licences.js +++ b/db/migrations/public/20240228155509_create-review-licences.js @@ -3,8 +3,7 @@ const tableName = 'review_licences' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -32,7 +31,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20240229122120_create-review-charge-elements.js b/db/migrations/public/20240229122120_create-review-charge-elements.js index e23594d046..f0405a37c9 100644 --- a/db/migrations/public/20240229122120_create-review-charge-elements.js +++ b/db/migrations/public/20240229122120_create-review-charge-elements.js @@ -4,8 +4,7 @@ const tableName = 'review_charge_elements' const replacedTableName = 'review_charge_element_results' exports.up = function (knex) { - return knex - .schema + return knex.schema .dropTableIfExists(replacedTableName) .createTable(tableName, (table) => { // Primary Key @@ -35,8 +34,7 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema + return knex.schema .dropTableIfExists(tableName) .createTable(replacedTableName, (table) => { // Primary Key diff --git a/db/migrations/public/20240229123014_create-review-returns.js b/db/migrations/public/20240229123014_create-review-returns.js index 747b5c84c1..a079bd9927 100644 --- a/db/migrations/public/20240229123014_create-review-returns.js +++ b/db/migrations/public/20240229123014_create-review-returns.js @@ -4,8 +4,7 @@ const tableName = 'review_returns' const replacedTableName = 'review_return_results' exports.up = function (knex) { - return knex - .schema + return knex.schema .dropTableIfExists(replacedTableName) .createTable(tableName, (table) => { // Primary Key @@ -45,8 +44,7 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema + return knex.schema .dropTableIfExists(tableName) .createTable(replacedTableName, (table) => { // Primary Key diff --git a/db/migrations/public/20240229142857_create-water-gauging-stations-view.js b/db/migrations/public/20240229142857_create-water-gauging-stations-view.js index eb2184439f..1ab6217b26 100644 --- a/db/migrations/public/20240229142857_create-water-gauging-stations-view.js +++ b/db/migrations/public/20240229142857_create-water-gauging-stations-view.js @@ -3,10 +3,9 @@ const viewName = 'gauging_stations' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('gauging_stations').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + view.as( + knex('gauging_stations').withSchema('water').select([ 'gauging_station_id AS id', 'label', 'lat', @@ -24,12 +23,11 @@ exports.up = function (knex) { // 'is_test' 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240229150626_create-water-licence-gauging-stations-view.js b/db/migrations/public/20240229150626_create-water-licence-gauging-stations-view.js index 84f8004684..25e9ed4922 100644 --- a/db/migrations/public/20240229150626_create-water-licence-gauging-stations-view.js +++ b/db/migrations/public/20240229150626_create-water-licence-gauging-stations-view.js @@ -3,10 +3,9 @@ const viewName = 'licence_gauging_stations' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('licence_gauging_stations').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + view.as( + knex('licence_gauging_stations').withSchema('water').select([ 'licence_gauging_station_id AS id', 'licence_id', 'gauging_station_id', @@ -26,12 +25,11 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240229170332_create-bill-run-charge-version-years.js b/db/migrations/public/20240229170332_create-bill-run-charge-version-years.js index 916f3d1de3..7f638501fa 100644 --- a/db/migrations/public/20240229170332_create-bill-run-charge-version-years.js +++ b/db/migrations/public/20240229170332_create-bill-run-charge-version-years.js @@ -3,27 +3,27 @@ const viewName = 'bill_run_charge_version_years' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('billing_batch_charge_version_years').withSchema('water').select([ - 'billing_batch_charge_version_year_id AS id', - 'billing_batch_id AS bill_run_id', - 'charge_version_id', - 'financial_year_ending', - 'status', - 'transaction_type AS batch_type', - 'is_summer AS summer', - 'has_two_part_agreement AS two_part_agreement', - 'is_chargeable AS chargeable', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('billing_batch_charge_version_years') + .withSchema('water') + .select([ + 'billing_batch_charge_version_year_id AS id', + 'billing_batch_id AS bill_run_id', + 'charge_version_id', + 'financial_year_ending', + 'status', + 'transaction_type AS batch_type', + 'is_summer AS summer', + 'has_two_part_agreement AS two_part_agreement', + 'is_chargeable AS chargeable', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240301151323_alter-return-logs-view.js b/db/migrations/public/20240301151323_alter-return-logs-view.js index 883b3f4017..265bd0b0dc 100644 --- a/db/migrations/public/20240301151323_alter-return-logs-view.js +++ b/db/migrations/public/20240301151323_alter-return-logs-view.js @@ -3,12 +3,10 @@ const viewName = 'return_logs' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('returns').withSchema('returns').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('returns').withSchema('returns').select([ 'return_id AS id', // 'regime', // always 'water' // 'licence_type', // always 'abstraction' @@ -28,17 +26,16 @@ exports.up = function (knex) { // 'return_cycle_id' // is populated but links to a table that does not appear to be used 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('returns').withSchema('returns').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('returns').withSchema('returns').select([ 'return_id AS id', // 'regime', // always 'water' // 'licence_type', // always 'abstraction' @@ -58,6 +55,7 @@ exports.down = function (knex) { // 'return_cycle_id' // is populated but links to a table that does not appear to be used 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240305145354_create-review-charge-versions.js b/db/migrations/public/20240305145354_create-review-charge-versions.js index e51b900344..baca3ec5f9 100644 --- a/db/migrations/public/20240305145354_create-review-charge-versions.js +++ b/db/migrations/public/20240305145354_create-review-charge-versions.js @@ -3,8 +3,7 @@ const tableName = 'review_charge_versions' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -31,7 +30,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20240305150224_create-review-charge-references.js b/db/migrations/public/20240305150224_create-review-charge-references.js index 1adef10907..e1b215eb3e 100644 --- a/db/migrations/public/20240305150224_create-review-charge-references.js +++ b/db/migrations/public/20240305150224_create-review-charge-references.js @@ -3,8 +3,7 @@ const tableName = 'review_charge_references' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -29,7 +28,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20240305150609_create-review-charge-elements-returns.js b/db/migrations/public/20240305150609_create-review-charge-elements-returns.js index 2c771c9248..d653f8459b 100644 --- a/db/migrations/public/20240305150609_create-review-charge-elements-returns.js +++ b/db/migrations/public/20240305150609_create-review-charge-elements-returns.js @@ -3,8 +3,7 @@ const tableName = 'review_charge_elements_returns' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -28,7 +27,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20240308133100_create-licence-version-purpose-condition-types-view.js b/db/migrations/public/20240308133100_create-licence-version-purpose-condition-types-view.js index a2d1f5a3ac..65218d6431 100644 --- a/db/migrations/public/20240308133100_create-licence-version-purpose-condition-types-view.js +++ b/db/migrations/public/20240308133100_create-licence-version-purpose-condition-types-view.js @@ -3,24 +3,24 @@ const viewName = 'licence_version_purpose_condition_types' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('licence_version_purpose_condition_types').withSchema('water').select([ - 'licence_version_purpose_condition_type_id AS id', - 'code', - 'subcode', - 'description', - 'subcode_description', - 'display_title', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('licence_version_purpose_condition_types') + .withSchema('water') + .select([ + 'licence_version_purpose_condition_type_id AS id', + 'code', + 'subcode', + 'description', + 'subcode_description', + 'display_title', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240308141804_create-licence-version-purpose-conditions-view.js b/db/migrations/public/20240308141804_create-licence-version-purpose-conditions-view.js index 5f587d300e..a7090d5309 100644 --- a/db/migrations/public/20240308141804_create-licence-version-purpose-conditions-view.js +++ b/db/migrations/public/20240308141804_create-licence-version-purpose-conditions-view.js @@ -3,26 +3,26 @@ const viewName = 'licence_version_purpose_conditions' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('licence_version_purpose_conditions').withSchema('water').select([ - 'licence_version_purpose_condition_id AS id', - 'licence_version_purpose_id', - 'licence_version_purpose_condition_type_id', - 'param_1', - 'param_2', - 'notes', - 'external_id', - 'source', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('licence_version_purpose_conditions') + .withSchema('water') + .select([ + 'licence_version_purpose_condition_id AS id', + 'licence_version_purpose_id', + 'licence_version_purpose_condition_type_id', + 'param_1', + 'param_2', + 'notes', + 'external_id', + 'source', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240327200101_alter-review-issues-columns.js b/db/migrations/public/20240327200101_alter-review-issues-columns.js index 007cf137dd..5e60fe0269 100644 --- a/db/migrations/public/20240327200101_alter-review-issues-columns.js +++ b/db/migrations/public/20240327200101_alter-review-issues-columns.js @@ -1,41 +1,29 @@ 'use strict' exports.up = async function (knex) { - await knex - .schema - .alterTable('review_charge_elements', (table) => { - table.text('issues').alter() - }) + await knex.schema.alterTable('review_charge_elements', (table) => { + table.text('issues').alter() + }) - await knex - .schema - .alterTable('review_licences', (table) => { - table.text('issues').alter() - }) + await knex.schema.alterTable('review_licences', (table) => { + table.text('issues').alter() + }) - return knex - .schema - .alterTable('review_returns', (table) => { - table.text('issues').alter() - }) + return knex.schema.alterTable('review_returns', (table) => { + table.text('issues').alter() + }) } exports.down = async function (knex) { - await knex - .schema - .alterTable('review_charge_elements', (table) => { - table.string('issues').alter() - }) + await knex.schema.alterTable('review_charge_elements', (table) => { + table.string('issues').alter() + }) - await knex - .schema - .alterTable('review_licences', (table) => { - table.string('issues').alter() - }) + await knex.schema.alterTable('review_licences', (table) => { + table.string('issues').alter() + }) - return knex - .schema - .alterTable('review_returns', (table) => { - table.string('issues').alter() - }) + return knex.schema.alterTable('review_returns', (table) => { + table.string('issues').alter() + }) } diff --git a/db/migrations/public/20240409101132_alter-review-licences.js b/db/migrations/public/20240409101132_alter-review-licences.js index 10e2c87490..6a6d370f7d 100644 --- a/db/migrations/public/20240409101132_alter-review-licences.js +++ b/db/migrations/public/20240409101132_alter-review-licences.js @@ -3,17 +3,13 @@ const tableName = 'review_licences' exports.up = function (knex) { - return knex - .schema - .alterTable(tableName, (table) => { - table.boolean('progress').notNullable().defaultTo(false) - }) + return knex.schema.alterTable(tableName, (table) => { + table.boolean('progress').notNullable().defaultTo(false) + }) } exports.down = function (knex) { - return knex - .schema - .alterTable(tableName, (table) => { - table.dropColumn('progress') - }) + return knex.schema.alterTable(tableName, (table) => { + table.dropColumn('progress') + }) } diff --git a/db/migrations/public/20240416145558_alter-review-charge-elements-columns.js b/db/migrations/public/20240416145558_alter-review-charge-elements-columns.js index 8664dad7f7..dd2360d669 100644 --- a/db/migrations/public/20240416145558_alter-review-charge-elements-columns.js +++ b/db/migrations/public/20240416145558_alter-review-charge-elements-columns.js @@ -3,17 +3,13 @@ const tableName = 'review_charge_elements' exports.up = async function (knex) { - return knex - .schema - .alterTable(tableName, (table) => { - table.decimal('calculated') - }) + return knex.schema.alterTable(tableName, (table) => { + table.decimal('calculated') + }) } exports.down = async function (knex) { - return knex - .schema - .alterTable(tableName, (table) => { - table.dropColumn('calculated') - }) + return knex.schema.alterTable(tableName, (table) => { + table.dropColumn('calculated') + }) } diff --git a/db/migrations/public/20240425143644_alter-review-tables.js b/db/migrations/public/20240425143644_alter-review-tables.js index e24a9e3bd9..74e88ee0c5 100644 --- a/db/migrations/public/20240425143644_alter-review-tables.js +++ b/db/migrations/public/20240425143644_alter-review-tables.js @@ -1,41 +1,33 @@ 'use strict' exports.up = async function (knex) { - await knex - .schema - .alterTable('review_charge_references', (table) => { - table.decimal('amended_aggregate', null, null).defaultTo(1) - table.decimal('charge_adjustment', null, null).defaultTo(1) - table.decimal('amended_charge_adjustment', null, null).defaultTo(1) - table.decimal('abatement_agreement', null, null).defaultTo(1) - table.boolean('winter_discount') - table.boolean('two_part_tariff_agreement') - table.boolean('canal_and_river_trust_agreement') - }) + await knex.schema.alterTable('review_charge_references', (table) => { + table.decimal('amended_aggregate', null, null).defaultTo(1) + table.decimal('charge_adjustment', null, null).defaultTo(1) + table.decimal('amended_charge_adjustment', null, null).defaultTo(1) + table.decimal('abatement_agreement', null, null).defaultTo(1) + table.boolean('winter_discount') + table.boolean('two_part_tariff_agreement') + table.boolean('canal_and_river_trust_agreement') + }) - await knex - .schema - .alterTable('review_charge_elements', (table) => { - table.renameColumn('calculated', 'amended_allocated') - }) + await knex.schema.alterTable('review_charge_elements', (table) => { + table.renameColumn('calculated', 'amended_allocated') + }) } exports.down = async function (knex) { - await knex - .schema - .alterTable('review_charge_references', (table) => { - table.dropColumn('amended_aggregate') - table.dropColumn('charge_adjustment') - table.dropColumn('amended_charge_adjustment') - table.dropColumn('winter_discount') - table.dropColumn('abatement_agreement') - table.dropColumn('two_part_tariff_agreement') - table.dropColumn('canal_and_river_trust_agreement') - }) + await knex.schema.alterTable('review_charge_references', (table) => { + table.dropColumn('amended_aggregate') + table.dropColumn('charge_adjustment') + table.dropColumn('amended_charge_adjustment') + table.dropColumn('winter_discount') + table.dropColumn('abatement_agreement') + table.dropColumn('two_part_tariff_agreement') + table.dropColumn('canal_and_river_trust_agreement') + }) - await knex - .schema - .alterTable('review_charge_elements', (table) => { - table.renameColumn('amended_allocated', 'calculated') - }) + await knex.schema.alterTable('review_charge_elements', (table) => { + table.renameColumn('amended_allocated', 'calculated') + }) } diff --git a/db/migrations/public/20240426123717_alter-licence-version-purposes-view.js b/db/migrations/public/20240426123717_alter-licence-version-purposes-view.js index ed595b11ee..639b59eaed 100644 --- a/db/migrations/public/20240426123717_alter-licence-version-purposes-view.js +++ b/db/migrations/public/20240426123717_alter-licence-version-purposes-view.js @@ -3,12 +3,10 @@ const viewName = 'licence_version_purposes' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_version_purposes').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licence_version_purposes').withSchema('water').select([ 'licence_version_purpose_id AS id', 'licence_version_id', 'purpose_primary_id AS primary_purpose_id', @@ -29,17 +27,16 @@ exports.up = function (knex) { // 'is_test ', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_version_purposes').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licence_version_purposes').withSchema('water').select([ 'licence_version_purpose_id AS id', 'licence_version_id', 'purpose_primary_id', @@ -57,6 +54,7 @@ exports.down = function (knex) { // 'is_test ', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240429145100_alter-licences-view.js b/db/migrations/public/20240429145100_alter-licences-view.js index cc8672bd25..67a2fce792 100644 --- a/db/migrations/public/20240429145100_alter-licences-view.js +++ b/db/migrations/public/20240429145100_alter-licences-view.js @@ -3,12 +3,10 @@ const viewName = 'licences' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licences').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licences').withSchema('water').select([ 'licence_id AS id', 'region_id', 'licence_ref', @@ -25,17 +23,16 @@ exports.up = function (knex) { 'include_in_sroc_tpt_supplementary_billing AS include_in_sroc_tpt_billing', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licences').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licences').withSchema('water').select([ 'licence_id AS id', 'region_id', 'licence_ref', @@ -51,6 +48,7 @@ exports.down = function (knex) { 'include_in_sroc_supplementary_billing AS include_in_sroc_billing', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240430125140_create-financial-agreements-view.js b/db/migrations/public/20240430125140_create-financial-agreements-view.js index c503c4e9bb..3ccb817eb5 100644 --- a/db/migrations/public/20240430125140_create-financial-agreements-view.js +++ b/db/migrations/public/20240430125140_create-financial-agreements-view.js @@ -3,11 +3,10 @@ const viewName = 'financial_agreements' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('financial_agreement_types').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('financial_agreement_types').withSchema('water').select([ 'financial_agreement_type_id AS id', 'financial_agreement_code AS code', 'description', @@ -15,12 +14,11 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240430133702_create-licence-agreements-view.js b/db/migrations/public/20240430133702_create-licence-agreements-view.js index fc24a2760b..5722433330 100644 --- a/db/migrations/public/20240430133702_create-licence-agreements-view.js +++ b/db/migrations/public/20240430133702_create-licence-agreements-view.js @@ -3,11 +3,10 @@ const viewName = 'licence_agreements' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_agreements').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licence_agreements').withSchema('water').select([ 'licence_agreement_id AS id', 'financial_agreement_type_id AS financial_agreement_id', 'licence_ref', @@ -19,12 +18,11 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240501152641_alter-review-charge-references.js b/db/migrations/public/20240501152641_alter-review-charge-references.js index 95caf28164..33bd56005c 100644 --- a/db/migrations/public/20240501152641_alter-review-charge-references.js +++ b/db/migrations/public/20240501152641_alter-review-charge-references.js @@ -3,19 +3,15 @@ const tableName = 'review_charge_references' exports.up = function (knex) { - return knex - .schema - .alterTable(tableName, (table) => { - table.decimal('authorised_volume', null, null).defaultTo(0) - table.decimal('amended_authorised_volume', null, null).defaultTo(0) - }) + return knex.schema.alterTable(tableName, (table) => { + table.decimal('authorised_volume', null, null).defaultTo(0) + table.decimal('amended_authorised_volume', null, null).defaultTo(0) + }) } exports.down = function (knex) { - return knex - .schema - .alterTable(tableName, (table) => { - table.dropColumn('authorised_volume') - table.dropColumn('amended_authorised_volume') - }) + return knex.schema.alterTable(tableName, (table) => { + table.dropColumn('authorised_volume') + table.dropColumn('amended_authorised_volume') + }) } diff --git a/db/migrations/public/20240503155022_alter-review-charge-elements.js b/db/migrations/public/20240503155022_alter-review-charge-elements.js index 3fa142194e..0b6830f4cf 100644 --- a/db/migrations/public/20240503155022_alter-review-charge-elements.js +++ b/db/migrations/public/20240503155022_alter-review-charge-elements.js @@ -3,17 +3,13 @@ const tableName = 'review_charge_elements' exports.up = async function (knex) { - return knex - .schema - .alterTable(tableName, (table) => { - table.decimal('amended_allocated', null, null).defaultTo(0).alter() - }) + return knex.schema.alterTable(tableName, (table) => { + table.decimal('amended_allocated', null, null).defaultTo(0).alter() + }) } exports.down = async function (knex) { - return knex - .schema - .alterTable(tableName, (table) => { - table.decimal('amended_allocated').alter() - }) + return knex.schema.alterTable(tableName, (table) => { + table.decimal('amended_allocated').alter() + }) } diff --git a/db/migrations/public/20240513134550_create-company-contacts-view.js b/db/migrations/public/20240513134550_create-company-contacts-view.js index bb4c85ad63..1d0711a370 100644 --- a/db/migrations/public/20240513134550_create-company-contacts-view.js +++ b/db/migrations/public/20240513134550_create-company-contacts-view.js @@ -3,11 +3,10 @@ const viewName = 'company_contacts' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('company_contacts').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('company_contacts').withSchema('crm_v2').select([ 'company_contact_id AS id', 'company_id', 'contact_id', @@ -20,12 +19,11 @@ exports.up = function (knex) { // is_test 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240515082450_create-scheduled-notifications-view.js b/db/migrations/public/20240515082450_create-scheduled-notifications-view.js index d737f7a057..9d569c3093 100644 --- a/db/migrations/public/20240515082450_create-scheduled-notifications-view.js +++ b/db/migrations/public/20240515082450_create-scheduled-notifications-view.js @@ -3,11 +3,10 @@ const viewName = 'scheduled_notifications' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('scheduled_notification').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('scheduled_notification').withSchema('water').select([ 'id', 'recipient', 'message_type', @@ -30,12 +29,11 @@ exports.up = function (knex) { 'notification_type', 'job_id', 'date_created AS created_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240606103641_create-return-versions-view.js b/db/migrations/public/20240606103641_create-return-versions-view.js index 94d4429051..b4b9ec2102 100644 --- a/db/migrations/public/20240606103641_create-return-versions-view.js +++ b/db/migrations/public/20240606103641_create-return-versions-view.js @@ -3,29 +3,29 @@ const viewName = 'return_versions' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('return_versions').withSchema('water').select([ - 'return_version_id AS id', - 'licence_id', - 'version_number AS version', - 'start_date', - 'end_date', - 'status', - 'external_id', - 'reason', - 'multiple_upload', - 'notes', - 'created_by', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('return_versions') + .withSchema('water') + .select([ + 'return_version_id AS id', + 'licence_id', + 'version_number AS version', + 'start_date', + 'end_date', + 'status', + 'external_id', + 'reason', + 'multiple_upload', + 'notes', + 'created_by', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240606104018_create-return-requirements-view.js b/db/migrations/public/20240606104018_create-return-requirements-view.js index 5e6df5ac24..04e8ce2460 100644 --- a/db/migrations/public/20240606104018_create-return-requirements-view.js +++ b/db/migrations/public/20240606104018_create-return-requirements-view.js @@ -3,36 +3,36 @@ const viewName = 'return_requirements' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('return_requirements').withSchema('water').select([ - 'return_requirement_id AS id', - 'return_version_id', - 'returns_frequency', - 'is_summer AS summer', - 'is_upload AS upload', - 'abstraction_period_start_day', - 'abstraction_period_start_month', - 'abstraction_period_end_day', - 'abstraction_period_end_month', - 'site_description', - 'legacy_id', - 'external_id', - 'reporting_frequency', - 'collection_frequency', - 'gravity_fill', - 'reabstraction', - 'two_part_tariff', - 'fifty_six_exception', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('return_requirements') + .withSchema('water') + .select([ + 'return_requirement_id AS id', + 'return_version_id', + 'returns_frequency', + 'is_summer AS summer', + 'is_upload AS upload', + 'abstraction_period_start_day', + 'abstraction_period_start_month', + 'abstraction_period_end_day', + 'abstraction_period_end_month', + 'site_description', + 'legacy_id', + 'external_id', + 'reporting_frequency', + 'collection_frequency', + 'gravity_fill', + 'reabstraction', + 'two_part_tariff', + 'fifty_six_exception', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240606104927_create-return-requirement-purposes-view.js b/db/migrations/public/20240606104927_create-return-requirement-purposes-view.js index a4277064c1..f6ba2fc0ca 100644 --- a/db/migrations/public/20240606104927_create-return-requirement-purposes-view.js +++ b/db/migrations/public/20240606104927_create-return-requirement-purposes-view.js @@ -3,25 +3,25 @@ const viewName = 'return_requirement_purposes' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('return_requirement_purposes').withSchema('water').select([ - 'return_requirement_purpose_id AS id', - 'return_requirement_id', - 'purpose_primary_id AS primary_purpose_id', - 'purpose_secondary_id AS secondary_purpose_id', - 'purpose_use_id AS purpose_id', - 'purpose_alias AS alias', - 'external_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('return_requirement_purposes') + .withSchema('water') + .select([ + 'return_requirement_purpose_id AS id', + 'return_requirement_id', + 'purpose_primary_id AS primary_purpose_id', + 'purpose_secondary_id AS secondary_purpose_id', + 'purpose_use_id AS purpose_id', + 'purpose_alias AS alias', + 'external_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240606105250_create-return-requirement-points-view.js b/db/migrations/public/20240606105250_create-return-requirement-points-view.js index e0ce85f7f0..551d01db43 100644 --- a/db/migrations/public/20240606105250_create-return-requirement-points-view.js +++ b/db/migrations/public/20240606105250_create-return-requirement-points-view.js @@ -3,27 +3,27 @@ const viewName = 'return_requirement_points' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('return_requirement_points').withSchema('water').select([ - 'id', - 'return_requirement_id', - 'description', - 'ngr_1', - 'ngr_2', - 'ngr_3', - 'ngr_4', - 'external_id', - 'nald_point_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('return_requirement_points') + .withSchema('water') + .select([ + 'id', + 'return_requirement_id', + 'description', + 'ngr_1', + 'ngr_2', + 'ngr_3', + 'ngr_4', + 'external_id', + 'nald_point_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240611200155_create-primary-purposes-view.js b/db/migrations/public/20240611200155_create-primary-purposes-view.js index 122f69163e..5681b8fd52 100644 --- a/db/migrations/public/20240611200155_create-primary-purposes-view.js +++ b/db/migrations/public/20240611200155_create-primary-purposes-view.js @@ -3,23 +3,21 @@ const viewName = 'primary_purposes' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('purposes_primary').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('purposes_primary').withSchema('water').select([ 'purpose_primary_id AS id', 'legacy_id', 'description', // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240611200206_create-secondary-purposes-view.js b/db/migrations/public/20240611200206_create-secondary-purposes-view.js index f197b303a5..3a258c6de7 100644 --- a/db/migrations/public/20240611200206_create-secondary-purposes-view.js +++ b/db/migrations/public/20240611200206_create-secondary-purposes-view.js @@ -3,23 +3,21 @@ const viewName = 'secondary_purposes' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('purposes_secondary').withSchema('water').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('purposes_secondary').withSchema('water').select([ 'purpose_secondary_id AS id', 'legacy_id', 'description', // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240613152012_alter-licence-gauging-stations.js b/db/migrations/public/20240613152012_alter-licence-gauging-stations.js index cce7ec888f..1cf64a4579 100644 --- a/db/migrations/public/20240613152012_alter-licence-gauging-stations.js +++ b/db/migrations/public/20240613152012_alter-licence-gauging-stations.js @@ -3,12 +3,10 @@ const viewName = 'licence_gauging_stations' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_gauging_stations').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licence_gauging_stations').withSchema('water').select([ 'licence_gauging_station_id AS id', 'licence_id', 'gauging_station_id', @@ -28,16 +26,15 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('licence_gauging_stations').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('licence_gauging_stations').withSchema('water').select([ 'licence_gauging_station_id AS id', 'licence_id', 'gauging_station_id', @@ -57,6 +54,7 @@ exports.down = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240625082201_create-company-addresses-view.js b/db/migrations/public/20240625082201_create-company-addresses-view.js index b307beb5c0..644b6be55b 100644 --- a/db/migrations/public/20240625082201_create-company-addresses-view.js +++ b/db/migrations/public/20240625082201_create-company-addresses-view.js @@ -3,11 +3,10 @@ const viewName = 'company_addresses' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('company_addresses').withSchema('crm_v2').select([ + return knex.schema.createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('company_addresses').withSchema('crm_v2').select([ 'company_address_id AS id', 'company_id', 'address_id', @@ -18,12 +17,11 @@ exports.up = function (knex) { // is_test 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240806103222_create-licence-supplementary-years.js b/db/migrations/public/20240806103222_create-licence-supplementary-years.js index b9c883b190..40925e0596 100644 --- a/db/migrations/public/20240806103222_create-licence-supplementary-years.js +++ b/db/migrations/public/20240806103222_create-licence-supplementary-years.js @@ -3,8 +3,7 @@ const tableName = 'licence_supplementary_years' exports.up = function (knex) { - return knex - .schema + return knex.schema .createTable(tableName, (table) => { // Primary Key table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -30,7 +29,5 @@ exports.up = function (knex) { } exports.down = function (knex) { - return knex - .schema - .dropTableIfExists(tableName) + return knex.schema.dropTableIfExists(tableName) } diff --git a/db/migrations/public/20240807131002_create-charge-version-note-view.js b/db/migrations/public/20240807131002_create-charge-version-note-view.js index 6358bcc7e5..c548069f18 100644 --- a/db/migrations/public/20240807131002_create-charge-version-note-view.js +++ b/db/migrations/public/20240807131002_create-charge-version-note-view.js @@ -3,12 +3,10 @@ const viewName = 'charge_version_notes' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('notes').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('notes').withSchema('water').select([ 'note_id AS id', 'text AS note', // 'type', @@ -17,12 +15,11 @@ exports.up = function (knex) { // 'licence_id', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240807132127_alter-return-logs-view-include-source.js b/db/migrations/public/20240807132127_alter-return-logs-view-include-source.js index 96458fc86d..9d7e2bcf8e 100644 --- a/db/migrations/public/20240807132127_alter-return-logs-view-include-source.js +++ b/db/migrations/public/20240807132127_alter-return-logs-view-include-source.js @@ -3,12 +3,10 @@ const viewName = 'return_logs' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('returns').withSchema('returns').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('returns').withSchema('returns').select([ 'return_id AS id', // 'regime', // always 'water' // 'licence_type', // always 'abstraction' @@ -28,17 +26,16 @@ exports.up = function (knex) { // 'return_cycle_id' // is populated but links to a table that does not appear to be used 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('returns').withSchema('returns').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('returns').withSchema('returns').select([ 'return_id AS id', // 'regime', // always 'water' // 'licence_type', // always 'abstraction' @@ -58,6 +55,7 @@ exports.down = function (knex) { // 'return_cycle_id' // is populated but links to a table that does not appear to be used 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240807160605_alter-licences-view.js b/db/migrations/public/20240807160605_alter-licences-view.js index 14bdba3f42..d72e291037 100644 --- a/db/migrations/public/20240807160605_alter-licences-view.js +++ b/db/migrations/public/20240807160605_alter-licences-view.js @@ -3,12 +3,10 @@ const viewName = 'licences' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licences').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licences').withSchema('water').select([ 'licence_id AS id', 'region_id', 'licence_ref', @@ -25,17 +23,16 @@ exports.up = function (knex) { // 'include_in_sroc_tpt_supplementary_billing AS include_in_sroc_tpt_billing', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licences').withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licences').withSchema('water').select([ 'licence_id AS id', 'region_id', 'licence_ref', @@ -52,6 +49,7 @@ exports.down = function (knex) { 'include_in_sroc_tpt_supplementary_billing AS include_in_sroc_tpt_billing', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240818105000_create-mod-logs-view.js b/db/migrations/public/20240818105000_create-mod-logs-view.js index 1667552bb4..4e68f4c092 100644 --- a/db/migrations/public/20240818105000_create-mod-logs-view.js +++ b/db/migrations/public/20240818105000_create-mod-logs-view.js @@ -3,38 +3,37 @@ const viewName = 'mod_logs' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('mod_logs').withSchema('water').select([ - 'id', - 'external_id', - 'event_code', - 'event_description', - 'reason_type', - 'reason_code', - 'reason_description', - 'nald_date', - 'user_id', - 'note', - 'licence_ref', - 'licence_external_id', - 'licence_id', - 'licence_version_external_id', - 'licence_version_id', - 'charge_version_external_id', - 'charge_version_id', - 'return_version_external_id', - 'return_version_id', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('mod_logs') + .withSchema('water') + .select([ + 'id', + 'external_id', + 'event_code', + 'event_description', + 'reason_type', + 'reason_code', + 'reason_description', + 'nald_date', + 'user_id', + 'note', + 'licence_ref', + 'licence_external_id', + 'licence_id', + 'licence_version_external_id', + 'licence_version_id', + 'charge_version_external_id', + 'charge_version_id', + 'return_version_external_id', + 'return_version_id', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240827195147_create-licence-version-purpose-points-view.js b/db/migrations/public/20240827195147_create-licence-version-purpose-points-view.js index 85853c433c..2d4d5947a1 100644 --- a/db/migrations/public/20240827195147_create-licence-version-purpose-points-view.js +++ b/db/migrations/public/20240827195147_create-licence-version-purpose-points-view.js @@ -3,27 +3,27 @@ const viewName = 'licence_version_purpose_points' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('licence_version_purpose_points').withSchema('water').select([ - 'id', - 'licence_version_purpose_id', - 'description', - 'ngr_1', - 'ngr_2', - 'ngr_3', - 'ngr_4', - 'external_id', - 'nald_point_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('licence_version_purpose_points') + .withSchema('water') + .select([ + 'id', + 'licence_version_purpose_id', + 'description', + 'ngr_1', + 'ngr_2', + 'ngr_3', + 'ngr_4', + 'external_id', + 'nald_point_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240828111744_alter-users-view.js b/db/migrations/public/20240828111744_alter-users-view.js index ce12bf33c3..42ae41f48c 100644 --- a/db/migrations/public/20240828111744_alter-users-view.js +++ b/db/migrations/public/20240828111744_alter-users-view.js @@ -3,12 +3,10 @@ const viewName = 'users' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('users').withSchema('idm').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('users').withSchema('idm').select([ 'users.user_id AS id', 'users.user_name AS username', 'users.password', @@ -24,17 +22,16 @@ exports.up = function (knex) { 'users.enabled', 'users.date_created AS created_at', 'users.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('users').withSchema('idm').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('users').withSchema('idm').select([ 'users.user_id AS id', 'users.user_name AS username', 'users.password', @@ -50,6 +47,7 @@ exports.down = function (knex) { 'users.enabled', 'users.date_created AS created_at', 'users.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240905081225_alter-companies-view.js b/db/migrations/public/20240905081225_alter-companies-view.js index 286e4ed1aa..0fea2684a3 100644 --- a/db/migrations/public/20240905081225_alter-companies-view.js +++ b/db/migrations/public/20240905081225_alter-companies-view.js @@ -3,12 +3,10 @@ const viewName = 'companies' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex(viewName).withSchema('crm_v2').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex(viewName).withSchema('crm_v2').select([ 'companies.company_id AS id', 'companies.name', 'companies.type', @@ -20,17 +18,16 @@ exports.up = function (knex) { // 'companies.current_hash', // is populated but is only used by the legacy import process 'companies.date_created AS created_at', 'companies.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropView(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex(viewName).withSchema('crm_v2').select([ + return knex.schema.dropView(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex(viewName).withSchema('crm_v2').select([ 'companies.company_id AS id', 'companies.name', 'companies.type', @@ -42,6 +39,7 @@ exports.down = function (knex) { // 'companies.current_hash', // is populated but is only used by the legacy import process 'companies.date_created AS created_at', 'companies.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240909132727_alter-contacts-view.js b/db/migrations/public/20240909132727_alter-contacts-view.js index ab01439d54..78c8dcbfd5 100644 --- a/db/migrations/public/20240909132727_alter-contacts-view.js +++ b/db/migrations/public/20240909132727_alter-contacts-view.js @@ -3,12 +3,10 @@ const viewName = 'contacts' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex(viewName).withSchema('crm_v2').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex(viewName).withSchema('crm_v2').select([ 'contacts.contact_id AS id', 'contacts.salutation', 'contacts.first_name', @@ -26,17 +24,16 @@ exports.up = function (knex) { 'contacts.email', 'contacts.date_created AS created_at', 'contacts.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropView(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex(viewName).withSchema('crm_v2').select([ + return knex.schema.dropView(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex(viewName).withSchema('crm_v2').select([ 'contacts.contact_id AS id', 'contacts.salutation', 'contacts.first_name', @@ -55,6 +52,7 @@ exports.down = function (knex) { 'contacts.email', 'contacts.date_created AS created_at', 'contacts.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240918125758_create-return-cycles-view.js b/db/migrations/public/20240918125758_create-return-cycles-view.js index 7841f8eafe..3e75da3711 100644 --- a/db/migrations/public/20240918125758_create-return-cycles-view.js +++ b/db/migrations/public/20240918125758_create-return-cycles-view.js @@ -3,24 +3,24 @@ const viewName = 'return_cycles' exports.up = function (knex) { - return knex - .schema - .createView(viewName, (view) => { - view.as(knex('return_cycles').withSchema('returns').select([ - 'return_cycle_id AS id', - 'start_date', - 'end_date', - 'due_date', - 'is_summer AS summer', - 'is_submitted_in_wrls AS submitted_in_wrls', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.createView(viewName, (view) => { + view.as( + knex('return_cycles') + .withSchema('returns') + .select([ + 'return_cycle_id AS id', + 'start_date', + 'end_date', + 'due_date', + 'is_summer AS summer', + 'is_submitted_in_wrls AS submitted_in_wrls', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240918144353_alter-return-logs-view.js b/db/migrations/public/20240918144353_alter-return-logs-view.js index 57ce08e945..539a76d195 100644 --- a/db/migrations/public/20240918144353_alter-return-logs-view.js +++ b/db/migrations/public/20240918144353_alter-return-logs-view.js @@ -3,12 +3,10 @@ const viewName = 'return_logs' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('returns').withSchema('returns').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('returns').withSchema('returns').select([ 'return_id AS id', // 'regime', // always 'water' // 'licence_type', // always 'abstraction' @@ -28,17 +26,16 @@ exports.up = function (knex) { 'return_cycle_id', 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('returns').withSchema('returns').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('returns').withSchema('returns').select([ 'return_id AS id', // 'regime', // always 'water' // 'licence_type', // always 'abstraction' @@ -58,6 +55,7 @@ exports.down = function (knex) { // 'return_cycle_id' // is populated but links to a table that does not appear to be used 'created_at', 'updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240918152451_alter-addresses-view.js.js b/db/migrations/public/20240918152451_alter-addresses-view.js.js index 7225281ff4..00bdc9b4bf 100644 --- a/db/migrations/public/20240918152451_alter-addresses-view.js.js +++ b/db/migrations/public/20240918152451_alter-addresses-view.js.js @@ -3,12 +3,10 @@ const viewName = 'addresses' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex(viewName).withSchema('crm_v2').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex(viewName).withSchema('crm_v2').select([ 'addresses.address_id AS id', 'addresses.address_1', 'addresses.address_2', @@ -26,17 +24,16 @@ exports.up = function (knex) { // 'addresses.current_hash', // is populated but is only used by the legacy import process 'addresses.date_created AS created_at', 'addresses.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropView(viewName) - .createView(viewName, (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex(viewName).withSchema('crm_v2').select([ + return knex.schema.dropView(viewName).createView(viewName, (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex(viewName).withSchema('crm_v2').select([ 'addresses.address_id AS id', 'addresses.address_1', 'addresses.address_2', @@ -54,6 +51,7 @@ exports.down = function (knex) { // 'addresses.current_hash', // is populated but is only used by the legacy import process 'addresses.date_created AS created_at', 'addresses.date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20240922211248_create-sources-view.js b/db/migrations/public/20240922211248_create-sources-view.js index 59a16c409e..3f8362daed 100644 --- a/db/migrations/public/20240922211248_create-sources-view.js +++ b/db/migrations/public/20240922211248_create-sources-view.js @@ -3,25 +3,15 @@ const viewName = 'sources' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('sources').withSchema('water').select([ - 'id', - 'description', - 'source_type', - 'ngr', - 'external_id', - 'legacy_id', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('sources') + .withSchema('water') + .select(['id', 'description', 'source_type', 'ngr', 'external_id', 'legacy_id', 'created_at', 'updated_at']) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240922211359_create-points-view.js b/db/migrations/public/20240922211359_create-points-view.js index e742a8336c..3135ee68fe 100644 --- a/db/migrations/public/20240922211359_create-points-view.js +++ b/db/migrations/public/20240922211359_create-points-view.js @@ -3,38 +3,37 @@ const viewName = 'points' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('points').withSchema('water').select([ - 'id', - 'description', - 'ngr_1', - 'ngr_2', - 'ngr_3', - 'ngr_4', - 'source_id', - 'category', - 'primary_type', - 'secondary_type', - 'note', - 'location_note', - 'depth', - 'bgs_reference', - 'well_reference', - 'hydro_reference', - 'hydro_intercept_distance', - 'hydro_offset_distance', - 'external_id', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('points') + .withSchema('water') + .select([ + 'id', + 'description', + 'ngr_1', + 'ngr_2', + 'ngr_3', + 'ngr_4', + 'source_id', + 'category', + 'primary_type', + 'secondary_type', + 'note', + 'location_note', + 'depth', + 'bgs_reference', + 'well_reference', + 'hydro_reference', + 'hydro_intercept_distance', + 'hydro_offset_distance', + 'external_id', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20240923103355_alter-return-requirements-points-view.js b/db/migrations/public/20240923103355_alter-return-requirements-points-view.js index 9f8cfdd29a..fcaee96d16 100644 --- a/db/migrations/public/20240923103355_alter-return-requirements-points-view.js +++ b/db/migrations/public/20240923103355_alter-return-requirements-points-view.js @@ -3,38 +3,40 @@ const viewName = 'return_requirement_points' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('return_requirement_points').withSchema('water').select([ - 'id', - 'return_requirement_id', - 'point_id', - 'external_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('return_requirement_points') + .withSchema('water') + .select([ + 'id', + 'return_requirement_id', + 'point_id', + 'external_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('return_requirement_points').withSchema('water').select([ - 'id', - 'return_requirement_id', - 'description', - 'ngr_1', - 'ngr_2', - 'ngr_3', - 'ngr_4', - 'external_id', - 'nald_point_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('return_requirement_points') + .withSchema('water') + .select([ + 'id', + 'return_requirement_id', + 'description', + 'ngr_1', + 'ngr_2', + 'ngr_3', + 'ngr_4', + 'external_id', + 'nald_point_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } diff --git a/db/migrations/public/20240923103738_alter-licence-version-purpose-points-view.js b/db/migrations/public/20240923103738_alter-licence-version-purpose-points-view.js index 38e413ee35..6f783a6601 100644 --- a/db/migrations/public/20240923103738_alter-licence-version-purpose-points-view.js +++ b/db/migrations/public/20240923103738_alter-licence-version-purpose-points-view.js @@ -3,38 +3,40 @@ const viewName = 'licence_version_purpose_points' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('licence_version_purpose_points').withSchema('water').select([ - 'id', - 'licence_version_purpose_id', - 'point_id', - 'external_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('licence_version_purpose_points') + .withSchema('water') + .select([ + 'id', + 'licence_version_purpose_id', + 'point_id', + 'external_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('licence_version_purpose_points').withSchema('water').select([ - 'id', - 'licence_version_purpose_id', - 'description', - 'ngr_1', - 'ngr_2', - 'ngr_3', - 'ngr_4', - 'external_id', - 'nald_point_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('licence_version_purpose_points') + .withSchema('water') + .select([ + 'id', + 'licence_version_purpose_id', + 'description', + 'ngr_1', + 'ngr_2', + 'ngr_3', + 'ngr_4', + 'external_id', + 'nald_point_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } diff --git a/db/migrations/public/20241003073555_alter-licence-version-purpose-points-view.js b/db/migrations/public/20241003073555_alter-licence-version-purpose-points-view.js index 4ca7b705a7..a3ac10dc3f 100644 --- a/db/migrations/public/20241003073555_alter-licence-version-purpose-points-view.js +++ b/db/migrations/public/20241003073555_alter-licence-version-purpose-points-view.js @@ -3,34 +3,36 @@ const viewName = 'licence_version_purpose_points' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('licence_version_purpose_points').withSchema('water').select([ - 'id', - 'licence_version_purpose_id', - 'point_id', - 'external_id', - 'abstraction_method', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('licence_version_purpose_points') + .withSchema('water') + .select([ + 'id', + 'licence_version_purpose_id', + 'point_id', + 'external_id', + 'abstraction_method', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('licence_version_purpose_points').withSchema('water').select([ - 'id', - 'licence_version_purpose_id', - 'point_id', - 'external_id', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('licence_version_purpose_points') + .withSchema('water') + .select([ + 'id', + 'licence_version_purpose_id', + 'point_id', + 'external_id', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) + }) } diff --git a/db/migrations/public/20241016161831_rename-water-gauging-stations-view.js b/db/migrations/public/20241016161831_rename-water-gauging-stations-view.js index 9e09e9876f..0e6ddcba57 100644 --- a/db/migrations/public/20241016161831_rename-water-gauging-stations-view.js +++ b/db/migrations/public/20241016161831_rename-water-gauging-stations-view.js @@ -1,11 +1,9 @@ 'use strict' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists('gauging_stations') - .createView('monitoring_stations', (view) => { - view.as(knex('gauging_stations').withSchema('water').select([ + return knex.schema.dropViewIfExists('gauging_stations').createView('monitoring_stations', (view) => { + view.as( + knex('gauging_stations').withSchema('water').select([ 'gauging_station_id AS id', 'label', 'lat', @@ -23,16 +21,15 @@ exports.up = function (knex) { // 'is_test' 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists('monitoring_stations') - .createView('gauging_stations', (view) => { - view.as(knex('gauging_stations').withSchema('water').select([ + return knex.schema.dropViewIfExists('monitoring_stations').createView('gauging_stations', (view) => { + view.as( + knex('gauging_stations').withSchema('water').select([ 'gauging_station_id AS id', 'label', 'lat', @@ -50,6 +47,7 @@ exports.down = function (knex) { // 'is_test' 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20241016161842_rename-water-licence-gauging-stations-view.js b/db/migrations/public/20241016161842_rename-water-licence-gauging-stations-view.js index a5c55c0f31..309aba9c55 100644 --- a/db/migrations/public/20241016161842_rename-water-licence-gauging-stations-view.js +++ b/db/migrations/public/20241016161842_rename-water-licence-gauging-stations-view.js @@ -1,12 +1,10 @@ 'use strict' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists('licence_gauging_stations') - .createView('licence_monitoring_stations', (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_gauging_stations').withSchema('water').select([ + return knex.schema.dropViewIfExists('licence_gauging_stations').createView('licence_monitoring_stations', (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licence_gauging_stations').withSchema('water').select([ 'licence_gauging_station_id AS id', 'licence_id', 'gauging_station_id AS monitoring_station_id', @@ -26,17 +24,16 @@ exports.up = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists('licence_monitoring_stations') - .createView('licence_gauging_stations', (view) => { - // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_gauging_stations').withSchema('water').select([ + return knex.schema.dropViewIfExists('licence_monitoring_stations').createView('licence_gauging_stations', (view) => { + // NOTE: We have commented out unused columns from the source table + view.as( + knex('licence_gauging_stations').withSchema('water').select([ 'licence_gauging_station_id AS id', 'licence_id', 'gauging_station_id', @@ -56,6 +53,7 @@ exports.down = function (knex) { // 'is_test', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20241107101130_alter-return-version-view.js.js b/db/migrations/public/20241107101130_alter-return-version-view.js.js index d77f197d70..0e7a609360 100644 --- a/db/migrations/public/20241107101130_alter-return-version-view.js.js +++ b/db/migrations/public/20241107101130_alter-return-version-view.js.js @@ -3,11 +3,9 @@ const viewName = 'return_versions' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex(viewName).withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex(viewName).withSchema('water').select([ 'return_version_id AS id', 'licence_id', 'version_number AS version', @@ -22,16 +20,15 @@ exports.up = function (knex) { 'created_by', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex(viewName).withSchema('water').select([ + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex(viewName).withSchema('water').select([ 'return_version_id AS id', 'licence_id', 'version_number AS version', @@ -46,6 +43,7 @@ exports.down = function (knex) { 'created_by', 'date_created AS created_at', 'date_updated AS updated_at' - ])) - }) + ]) + ) + }) } diff --git a/db/migrations/public/20241110153834_drop-review-tables.js b/db/migrations/public/20241110153834_drop-review-tables.js index a3d15d83ed..c45894b144 100644 --- a/db/migrations/public/20241110153834_drop-review-tables.js +++ b/db/migrations/public/20241110153834_drop-review-tables.js @@ -1,45 +1,23 @@ 'use strict' exports.up = async function (knex) { - await knex - .schema - .withSchema('public') - .dropTableIfExists('review_returns') + await knex.schema.withSchema('public').dropTableIfExists('review_returns') - await knex - .schema - .withSchema('public') - .dropTableIfExists('review_licences') + await knex.schema.withSchema('public').dropTableIfExists('review_licences') - await knex - .schema - .withSchema('public') - .dropTableIfExists('review_charge_versions') + await knex.schema.withSchema('public').dropTableIfExists('review_charge_versions') - await knex - .schema - .withSchema('public') - .dropTableIfExists('review_charge_references') + await knex.schema.withSchema('public').dropTableIfExists('review_charge_references') - await knex - .schema - .withSchema('public') - .dropTableIfExists('review_charge_elements_returns') + await knex.schema.withSchema('public').dropTableIfExists('review_charge_elements_returns') - await knex - .schema - .withSchema('public') - .dropTableIfExists('review_charge_elements') + await knex.schema.withSchema('public').dropTableIfExists('review_charge_elements') - return knex - .schema - .withSchema('public') - .dropTableIfExists('licence_supplementary_years') + return knex.schema.withSchema('public').dropTableIfExists('licence_supplementary_years') } exports.down = async function (knex) { - await knex - .schema + await knex.schema .withSchema('public') .createTable('review_returns', (table) => { table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -71,8 +49,7 @@ exports.down = async function (knex) { `) }) - await knex - .schema + await knex.schema .withSchema('public') .createTable('review_licences', (table) => { table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -95,8 +72,7 @@ exports.down = async function (knex) { `) }) - await knex - .schema + await knex.schema .withSchema('public') .createTable('review_charge_versions', (table) => { table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -117,8 +93,7 @@ exports.down = async function (knex) { `) }) - await knex - .schema + await knex.schema .withSchema('public') .createTable('review_charge_references', (table) => { table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -146,8 +121,7 @@ exports.down = async function (knex) { `) }) - await knex - .schema + await knex.schema .withSchema('public') .createTable('review_charge_elements_returns', (table) => { table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -165,8 +139,7 @@ exports.down = async function (knex) { `) }) - await knex - .schema + await knex.schema .withSchema('public') .createTable('review_charge_elements', (table) => { table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) @@ -189,8 +162,7 @@ exports.down = async function (knex) { `) }) - return knex - .schema + return knex.schema .withSchema('public') .createTable('licence_supplementary_years', (table) => { table.uuid('id').primary().defaultTo(knex.raw('gen_random_uuid()')) diff --git a/db/migrations/public/20241110154027_create-licence-supplementary-years-view.js b/db/migrations/public/20241110154027_create-licence-supplementary-years-view.js index 3449b73ad9..2652476852 100644 --- a/db/migrations/public/20241110154027_create-licence-supplementary-years-view.js +++ b/db/migrations/public/20241110154027_create-licence-supplementary-years-view.js @@ -3,24 +3,23 @@ const viewName = 'licence_supplementary_years' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('licence_supplementary_years').withSchema('water').select([ - 'id', - 'licence_id', - 'bill_run_id', - 'financial_year_end', - 'two_part_tariff', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('licence_supplementary_years') + .withSchema('water') + .select([ + 'id', + 'licence_id', + 'bill_run_id', + 'financial_year_end', + 'two_part_tariff', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20241110154202_create-review-charge-elements-view.js b/db/migrations/public/20241110154202_create-review-charge-elements-view.js index 98ed604aac..8bc4581279 100644 --- a/db/migrations/public/20241110154202_create-review-charge-elements-view.js +++ b/db/migrations/public/20241110154202_create-review-charge-elements-view.js @@ -3,27 +3,26 @@ const viewName = 'review_charge_elements' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('review_charge_elements').withSchema('water').select([ - 'id', - 'review_charge_reference_id', - 'charge_element_id', - 'allocated', - 'amended_allocated', - 'charge_dates_overlap', - 'issues', - 'status', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('review_charge_elements') + .withSchema('water') + .select([ + 'id', + 'review_charge_reference_id', + 'charge_element_id', + 'allocated', + 'amended_allocated', + 'charge_dates_overlap', + 'issues', + 'status', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20241110154305_create-review-charge-element-returns-view.js b/db/migrations/public/20241110154305_create-review-charge-element-returns-view.js index 371140b947..2551652924 100644 --- a/db/migrations/public/20241110154305_create-review-charge-element-returns-view.js +++ b/db/migrations/public/20241110154305_create-review-charge-element-returns-view.js @@ -3,22 +3,15 @@ const viewName = 'review_charge_element_returns' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('review_charge_element_returns').withSchema('water').select([ - 'id', - 'review_charge_element_id', - 'review_return_id', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('review_charge_element_returns') + .withSchema('water') + .select(['id', 'review_charge_element_id', 'review_return_id', 'created_at', 'updated_at']) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20241110154434_create-review-charge-references-view.js b/db/migrations/public/20241110154434_create-review-charge-references-view.js index 11be63668b..41d4c8eff5 100644 --- a/db/migrations/public/20241110154434_create-review-charge-references-view.js +++ b/db/migrations/public/20241110154434_create-review-charge-references-view.js @@ -3,32 +3,31 @@ const viewName = 'review_charge_references' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('review_charge_references').withSchema('water').select([ - 'id', - 'review_charge_version_id', - 'charge_reference_id', - 'aggregate', - 'amended_aggregate', - 'charge_adjustment', - 'amended_charge_adjustment', - 'abatement_agreement', - 'winter_discount', - 'two_part_tariff_agreement', - 'canal_and_river_trust_agreement', - 'authorised_volume', - 'amended_authorised_volume', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('review_charge_references') + .withSchema('water') + .select([ + 'id', + 'review_charge_version_id', + 'charge_reference_id', + 'aggregate', + 'amended_aggregate', + 'charge_adjustment', + 'amended_charge_adjustment', + 'abatement_agreement', + 'winter_discount', + 'two_part_tariff_agreement', + 'canal_and_river_trust_agreement', + 'authorised_volume', + 'amended_authorised_volume', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20241110154606_create-review-charge-versions-view.js b/db/migrations/public/20241110154606_create-review-charge-versions-view.js index 48472b76d6..0ba1970bde 100644 --- a/db/migrations/public/20241110154606_create-review-charge-versions-view.js +++ b/db/migrations/public/20241110154606_create-review-charge-versions-view.js @@ -3,25 +3,24 @@ const viewName = 'review_charge_versions' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('review_charge_versions').withSchema('water').select([ - 'id', - 'review_licence_id', - 'charge_version_id', - 'change_reason', - 'charge_period_start_date', - 'charge_period_end_date', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('review_charge_versions') + .withSchema('water') + .select([ + 'id', + 'review_licence_id', + 'charge_version_id', + 'change_reason', + 'charge_period_start_date', + 'charge_period_end_date', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20241110154652_create-review-licences-view.js b/db/migrations/public/20241110154652_create-review-licences-view.js index f3f961db2e..a242e6ee77 100644 --- a/db/migrations/public/20241110154652_create-review-licences-view.js +++ b/db/migrations/public/20241110154652_create-review-licences-view.js @@ -3,27 +3,26 @@ const viewName = 'review_licences' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('review_licences').withSchema('water').select([ - 'id', - 'bill_run_id', - 'licence_id', - 'licence_ref', - 'licence_holder', - 'issues', - 'status', - 'progress', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('review_licences') + .withSchema('water') + .select([ + 'id', + 'bill_run_id', + 'licence_id', + 'licence_ref', + 'licence_holder', + 'issues', + 'status', + 'progress', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20241110154755_create-review-returns-view.js b/db/migrations/public/20241110154755_create-review-returns-view.js index a6dba4cacb..4966121eff 100644 --- a/db/migrations/public/20241110154755_create-review-returns-view.js +++ b/db/migrations/public/20241110154755_create-review-returns-view.js @@ -3,36 +3,35 @@ const viewName = 'review_returns' exports.up = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) - .createView(viewName, (view) => { - view.as(knex('review_returns').withSchema('water').select([ - 'id', - 'review_licence_id', - 'return_id', - 'return_reference', - 'quantity', - 'allocated', - 'under_query', - 'return_status', - 'nil_return', - 'abstraction_outside_period', - 'received_date', - 'due_date', - 'purposes', - 'description', - 'start_date', - 'end_date', - 'issues', - 'created_at', - 'updated_at' - ])) - }) + return knex.schema.dropViewIfExists(viewName).createView(viewName, (view) => { + view.as( + knex('review_returns') + .withSchema('water') + .select([ + 'id', + 'review_licence_id', + 'return_id', + 'return_reference', + 'quantity', + 'allocated', + 'under_query', + 'return_status', + 'nil_return', + 'abstraction_outside_period', + 'received_date', + 'due_date', + 'purposes', + 'description', + 'start_date', + 'end_date', + 'issues', + 'created_at', + 'updated_at' + ]) + ) + }) } exports.down = function (knex) { - return knex - .schema - .dropViewIfExists(viewName) + return knex.schema.dropViewIfExists(viewName) } diff --git a/db/migrations/public/20241115180557_alter-licence-monitoring-stations-view.js b/db/migrations/public/20241115180557_alter-licence-monitoring-stations-view.js index 4ce37ca15b..fdb0e54a88 100644 --- a/db/migrations/public/20241115180557_alter-licence-monitoring-stations-view.js +++ b/db/migrations/public/20241115180557_alter-licence-monitoring-stations-view.js @@ -1,61 +1,63 @@ 'use strict' exports.up = function (knex) { - return knex - .schema + return knex.schema .dropViewIfExists('licence_monitoring_stations') .createView('licence_monitoring_stations', (view) => { // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_gauging_stations').withSchema('water').select([ - 'licence_gauging_station_id AS id', - 'licence_id', - 'gauging_station_id AS monitoring_station_id', - 'source', - 'licence_version_purpose_condition_id', - 'abstraction_period_start_day', - 'abstraction_period_start_month ', - 'abstraction_period_end_day', - 'abstraction_period_end_month', - 'restriction_type AS measure_type', - 'threshold_unit', - 'threshold_value', - 'status', - 'date_status_updated AS status_updated_at', - 'date_deleted AS deleted_at', - 'alert_type AS restriction_type', - // 'is_test', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) + view.as( + knex('licence_gauging_stations').withSchema('water').select([ + 'licence_gauging_station_id AS id', + 'licence_id', + 'gauging_station_id AS monitoring_station_id', + 'source', + 'licence_version_purpose_condition_id', + 'abstraction_period_start_day', + 'abstraction_period_start_month ', + 'abstraction_period_end_day', + 'abstraction_period_end_month', + 'restriction_type AS measure_type', + 'threshold_unit', + 'threshold_value', + 'status', + 'date_status_updated AS status_updated_at', + 'date_deleted AS deleted_at', + 'alert_type AS restriction_type', + // 'is_test', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) }) } exports.down = function (knex) { - return knex - .schema + return knex.schema .dropViewIfExists('licence_monitoring_stations') .createView('licence_monitoring_stations', (view) => { // NOTE: We have commented out unused columns from the source table - view.as(knex('licence_gauging_stations').withSchema('water').select([ - 'licence_gauging_station_id AS id', - 'licence_id', - 'gauging_station_id AS monitoring_station_id', - 'source', - 'licence_version_purpose_condition_id', - 'abstraction_period_start_day', - 'abstraction_period_start_month ', - 'abstraction_period_end_day', - 'abstraction_period_end_month', - 'restriction_type', - 'threshold_unit', - 'threshold_value', - 'status', - 'date_status_updated AS status_updated_at', - 'date_deleted AS deleted_at', - 'alert_type', - // 'is_test', - 'date_created AS created_at', - 'date_updated AS updated_at' - ])) + view.as( + knex('licence_gauging_stations').withSchema('water').select([ + 'licence_gauging_station_id AS id', + 'licence_id', + 'gauging_station_id AS monitoring_station_id', + 'source', + 'licence_version_purpose_condition_id', + 'abstraction_period_start_day', + 'abstraction_period_start_month ', + 'abstraction_period_end_day', + 'abstraction_period_end_month', + 'restriction_type', + 'threshold_unit', + 'threshold_value', + 'status', + 'date_status_updated AS status_updated_at', + 'date_deleted AS deleted_at', + 'alert_type', + // 'is_test', + 'date_created AS created_at', + 'date_updated AS updated_at' + ]) + ) }) } diff --git a/db/seeds/01-regions.seed.js b/db/seeds/01-regions.seed.js index 9652728174..3e3952516c 100644 --- a/db/seeds/01-regions.seed.js +++ b/db/seeds/01-regions.seed.js @@ -18,7 +18,7 @@ const ServerConfig = require('../../config/server.config.js') * We manually check if the combination exits already and update / insert accordingly. * */ -async function seed () { +async function seed() { for (const region of regions) { const exists = await _exists(region) @@ -30,7 +30,7 @@ async function seed () { } } -async function _applyTestFlag (region, id) { +async function _applyTestFlag(region, id) { if (region.name !== 'Test') { return null } @@ -38,7 +38,7 @@ async function _applyTestFlag (region, id) { return db('regions').withSchema('water').update('isTest', true).where('regionId', id) } -async function _exists (region) { +async function _exists(region) { const { chargeRegionId, naldRegionId } = region const result = await RegionModel.query() @@ -51,7 +51,7 @@ async function _exists (region) { return !!result } -async function _insert (region) { +async function _insert(region) { // The Bill Run & Test regions are only intended to be seeded in our non-production environments if ((region.name === 'Bill Run' || region.name === 'Test') && ServerConfig.environment === 'production') { return @@ -62,7 +62,7 @@ async function _insert (region) { return _applyTestFlag(region, result.id) } -async function _update (region) { +async function _update(region) { const { chargeRegionId, displayName, naldRegionId, name } = region return RegionModel.query() diff --git a/db/seeds/02-purposes.seed.js b/db/seeds/02-purposes.seed.js index b0d0a56159..e1b2cb4d44 100644 --- a/db/seeds/02-purposes.seed.js +++ b/db/seeds/02-purposes.seed.js @@ -14,13 +14,13 @@ const PurposeModel = require('../../app/models/purpose.model.js') * Public table name - public.purposes * */ -async function seed () { +async function seed() { for (const purpose of purposes) { await _upsert(purpose) } } -async function _upsert (purpose) { +async function _upsert(purpose) { return PurposeModel.query() .insert({ ...purpose, updatedAt: timestampForPostgres() }) .onConflict('legacyId') diff --git a/db/seeds/03-primary-purposes.seed.js b/db/seeds/03-primary-purposes.seed.js index 60d7e2d722..d1f2ab49c6 100644 --- a/db/seeds/03-primary-purposes.seed.js +++ b/db/seeds/03-primary-purposes.seed.js @@ -14,13 +14,13 @@ const PrimaryPurposeModel = require('../../app/models/primary-purpose.model.js') * Public table name - public.primary_purposes * */ -async function seed () { +async function seed() { for (const purpose of primaryPurposes) { await _upsert(purpose) } } -async function _upsert (primaryPurpose) { +async function _upsert(primaryPurpose) { return PrimaryPurposeModel.query() .insert({ ...primaryPurpose, updatedAt: timestampForPostgres() }) .onConflict('legacyId') diff --git a/db/seeds/04-secondary-purposes.seed.js b/db/seeds/04-secondary-purposes.seed.js index 36f37afbab..10d2d11248 100644 --- a/db/seeds/04-secondary-purposes.seed.js +++ b/db/seeds/04-secondary-purposes.seed.js @@ -14,13 +14,13 @@ const SecondaryPurposeModel = require('../../app/models/secondary-purpose.model. * Public table name - public.secondary_purposes * */ -async function seed () { +async function seed() { for (const purpose of secondaryPurposes) { await _upsert(purpose) } } -async function _upsert (secondaryPurpose) { +async function _upsert(secondaryPurpose) { return SecondaryPurposeModel.query() .insert({ ...secondaryPurpose, updatedAt: timestampForPostgres() }) .onConflict('legacyId') diff --git a/db/seeds/05-licence-version-purpose-condition-types.seed.js b/db/seeds/05-licence-version-purpose-condition-types.seed.js index bf9c2f332a..9c1e74275d 100644 --- a/db/seeds/05-licence-version-purpose-condition-types.seed.js +++ b/db/seeds/05-licence-version-purpose-condition-types.seed.js @@ -14,13 +14,13 @@ const LicenceVersionPurposeConditionTypeModel = require('../../app/models/licenc * Public table name - public.licence_version_purpose_condition_types * */ -async function seed () { +async function seed() { for (const licenceVersionPurposeConditionType of licenceVersionPurposeConditionTypes) { await _upsert(licenceVersionPurposeConditionType) } } -async function _upsert (licenceVersionPurposeConditionType) { +async function _upsert(licenceVersionPurposeConditionType) { return LicenceVersionPurposeConditionTypeModel.query() .insert({ ...licenceVersionPurposeConditionType, updatedAt: timestampForPostgres() }) .onConflict(['code', 'subcode']) diff --git a/db/seeds/06-groups.seed.js b/db/seeds/06-groups.seed.js index 9bdbfb4051..8e937fa48c 100644 --- a/db/seeds/06-groups.seed.js +++ b/db/seeds/06-groups.seed.js @@ -4,13 +4,13 @@ const { timestampForPostgres } = require('../../app/lib/general.lib.js') const { db } = require('../db.js') const { data: groups } = require('./data/groups.js') -async function seed () { +async function seed() { for (const group of groups) { await _upsert(group) } } -async function _upsert (group) { +async function _upsert(group) { // Note: We store the data in a format that matches what we get through Objection.js and our view model GroupModel. // But because of the reason detailed below, the payload we send in the insert has to match how the underlying table // is structured. Hence this transformation. @@ -25,7 +25,8 @@ async function _upsert (group) { // NOTE: We've had to drop back to Knex rather than Objection.js because the view model doesn't expose a field // (application) that we rely on to make the onConflict work. This was by design, `application` never differs across // records so is redundant to us when fetching instances of `GroupModel`. - return db('groups').withSchema('idm') + return db('groups') + .withSchema('idm') .insert(payload) .onConflict(['application', 'group']) .merge(['description', 'dateUpdated']) diff --git a/db/seeds/07-roles.seed.js b/db/seeds/07-roles.seed.js index a5aca99ceb..50b288e34f 100644 --- a/db/seeds/07-roles.seed.js +++ b/db/seeds/07-roles.seed.js @@ -4,13 +4,13 @@ const { timestampForPostgres } = require('../../app/lib/general.lib.js') const { db } = require('../db.js') const { data: roles } = require('./data/roles.js') -async function seed () { +async function seed() { for (const role of roles) { await _upsert(role) } } -async function _upsert (role) { +async function _upsert(role) { // Note: We store the data in a format that matches what we get through Objection.js and our view model RoleModel. // But because of the reason detailed below, the payload we send in the insert has to match how the underlying table // is structured. Hence this transformation. @@ -25,7 +25,8 @@ async function _upsert (role) { // NOTE: We've had to drop back to Knex rather than Objection.js because the view model doesn't expose a field // (application) that we rely on to make the onConflict work. This was by design, `application` never differs across // records so is redundant to us when fetching instances of `RoleModel`. - return db('roles').withSchema('idm') + return db('roles') + .withSchema('idm') .insert(payload) .onConflict(['application', 'role']) .merge(['description', 'dateUpdated']) diff --git a/db/seeds/08-group-roles.seed.js b/db/seeds/08-group-roles.seed.js index 8430f4b5f9..af47087d36 100644 --- a/db/seeds/08-group-roles.seed.js +++ b/db/seeds/08-group-roles.seed.js @@ -6,7 +6,7 @@ const { data: groupRoles } = require('./data/group-roles.js') const { data: groups } = require('./data/groups.js') const { data: roles } = require('./data/roles.js') -async function seed () { +async function seed() { for (const groupRole of groupRoles) { const { group, role } = _names(groupRole) @@ -18,7 +18,7 @@ async function seed () { } } -async function _exists (group, role) { +async function _exists(group, role) { const result = await GroupRoleModel.query() .select('groupRoles.id') .innerJoinRelated('group') @@ -31,17 +31,20 @@ async function _exists (group, role) { return !!result } -async function _insert (id, group, role) { - return db.raw(` +async function _insert(id, group, role) { + return db.raw( + ` INSERT INTO public.group_roles (id, group_id, role_id) SELECT (?) AS id, (SELECT id FROM public."groups" g WHERE g."group" = ?) AS group_id, (SELECT id FROM public.roles r WHERE r.role = ?) AS role_id; - `, [id, group, role]) + `, + [id, group, role] + ) } -function _names (groupRole) { +function _names(groupRole) { const { group } = groups.find((group) => { return group.id === groupRole.groupId }) diff --git a/db/seeds/09-users.seed.js b/db/seeds/09-users.seed.js index ddc71a9ab6..0e85fe9973 100644 --- a/db/seeds/09-users.seed.js +++ b/db/seeds/09-users.seed.js @@ -9,7 +9,7 @@ const UserModel = require('../../app/models/user.model.js') const DatabaseConfig = require('../../config/database.config.js') const ServerConfig = require('../../config/server.config.js') -async function seed () { +async function seed() { // These users are for use in our non-production environments only if (ServerConfig.environment === 'production') { return @@ -28,7 +28,7 @@ async function seed () { } } -async function _exists (user) { +async function _exists(user) { const { application, username } = user const result = await UserModel.query() @@ -41,7 +41,7 @@ async function _exists (user) { return !!result } -function _generateHashedPassword () { +function _generateHashedPassword() { // 10 is the number of salt rounds to perform to generate the salt. The legacy code uses // const salt = bcrypt.genSaltSync(10) to pre-generate the salt before passing it to hashSync(). But this is // intended for operations where you need to hash a large number of values. If you just pass in a number bcrypt will @@ -50,25 +50,15 @@ function _generateHashedPassword () { return bcrypt.hashSync(DatabaseConfig.defaultUserPassword, 10) } -async function _idInUse (id) { - const result = await UserModel.query() - .findById(id) +async function _idInUse(id) { + const result = await UserModel.query().findById(id) return !!result } -async function _insert (user, password) { - const { - application, - badLogins, - enabled, - id, - lastLogin, - resetGuid, - resetGuidCreatedAt, - resetRequired, - username - } = user +async function _insert(user, password) { + const { application, badLogins, enabled, id, lastLogin, resetGuid, resetGuidCreatedAt, resetRequired, username } = + user // NOTE: Seeding users is a pain (!) because of the previous teams choice to use a custom sequence for the ID instead // of sticking with UUIDs. This means it is possible that, for example, a user with @@ -96,17 +86,8 @@ async function _insert (user, password) { return UserModel.query().insert({ ...user, password }) } -async function _update (user, password) { - const { - application, - badLogins, - enabled, - lastLogin, - resetGuid, - resetGuidCreatedAt, - resetRequired, - username - } = user +async function _update(user, password) { + const { application, badLogins, enabled, lastLogin, resetGuid, resetGuidCreatedAt, resetRequired, username } = user return UserModel.query() .patch({ diff --git a/db/seeds/10-user-groups.seed.js b/db/seeds/10-user-groups.seed.js index e4acb3cb49..dcd9de80c1 100644 --- a/db/seeds/10-user-groups.seed.js +++ b/db/seeds/10-user-groups.seed.js @@ -8,7 +8,7 @@ const { data: users } = require('./data/users.js') const ServerConfig = require('../../config/server.config.js') -async function seed () { +async function seed() { // These user groups relate to users that are only for use in our non-production environments if (ServerConfig.environment === 'production') { return @@ -25,7 +25,7 @@ async function seed () { } } -async function _exists (group, username) { +async function _exists(group, username) { const result = await UserGroupModel.query() .select('userGroups.id') .innerJoinRelated('group') @@ -38,17 +38,20 @@ async function _exists (group, username) { return !!result } -async function _insert (id, group, username) { - return db.raw(` +async function _insert(id, group, username) { + return db.raw( + ` INSERT INTO public.user_groups (id, group_id, user_id) SELECT (?) AS id, (SELECT id FROM public."groups" g WHERE g."group" = ?) AS group_id, (SELECT id FROM public.users u WHERE u.username = ?) AS user_id; - `, [id, group, username]) + `, + [id, group, username] + ) } -function _names (userGroup) { +function _names(userGroup) { const { group } = groups.find((group) => { return group.id === userGroup.groupId }) diff --git a/db/seeds/11-financial-agreements.seed.js b/db/seeds/11-financial-agreements.seed.js index cdd20d2aab..9e1ad23a2b 100644 --- a/db/seeds/11-financial-agreements.seed.js +++ b/db/seeds/11-financial-agreements.seed.js @@ -4,13 +4,13 @@ const { timestampForPostgres } = require('../../app/lib/general.lib.js') const { data: financialAgreements } = require('./data/financial-agreements.js') const FinancialAgreementModel = require('../../app/models/financial-agreement.model.js') -async function seed () { +async function seed() { for (const financialAgreement of financialAgreements) { await _upsert(financialAgreement) } } -async function _upsert (financialAgreement) { +async function _upsert(financialAgreement) { return FinancialAgreementModel.query() .insert({ ...financialAgreement, updatedAt: timestampForPostgres() }) .onConflict('code') diff --git a/db/seeds/12-change-reasons.seed.js b/db/seeds/12-change-reasons.seed.js index 0f21150b86..85985a85a9 100644 --- a/db/seeds/12-change-reasons.seed.js +++ b/db/seeds/12-change-reasons.seed.js @@ -4,7 +4,7 @@ const { timestampForPostgres } = require('../../app/lib/general.lib.js') const { data: changeReasons } = require('./data/change-reasons.js') const ChangeReasonModel = require('../../app/models/change-reason.model.js') -async function seed () { +async function seed() { for (const changeReason of changeReasons) { const exists = await _exists(changeReason) @@ -16,7 +16,7 @@ async function seed () { } } -async function _exists (changeReason) { +async function _exists(changeReason) { const { description, type } = changeReason const result = await ChangeReasonModel.query() @@ -29,7 +29,7 @@ async function _exists (changeReason) { return !!result } -async function _insert (changeReason) { +async function _insert(changeReason) { // NOTE: The table does not auto populate the created and updated at fields, but does define them as not nullable! return ChangeReasonModel.query().insert({ ...changeReason, @@ -38,7 +38,7 @@ async function _insert (changeReason) { }) } -async function _update (changeReason) { +async function _update(changeReason) { const { description, enabledForNewChargeVersions, triggersMinimumCharge, type } = changeReason return ChangeReasonModel.query() diff --git a/db/seeds/13-charge-categories.seed.js b/db/seeds/13-charge-categories.seed.js index f81a412654..0c1eadd232 100644 --- a/db/seeds/13-charge-categories.seed.js +++ b/db/seeds/13-charge-categories.seed.js @@ -4,13 +4,13 @@ const ChargeCategoryModel = require('../../app/models/charge-category.model.js') const { data: chargeCategories } = require('./data/charge-categories.js') const { timestampForPostgres } = require('../../app/lib/general.lib.js') -async function seed () { +async function seed() { for (const chargeCategory of chargeCategories) { await _upsert(chargeCategory) } } -async function _upsert (chargeCategory) { +async function _upsert(chargeCategory) { return ChargeCategoryModel.query() .insert({ ...chargeCategory, createdAt: timestampForPostgres(), updatedAt: timestampForPostgres() }) .onConflict('reference') diff --git a/db/seeds/14-licence-roles.seed.js b/db/seeds/14-licence-roles.seed.js index 90403349a9..a6d1a6b157 100644 --- a/db/seeds/14-licence-roles.seed.js +++ b/db/seeds/14-licence-roles.seed.js @@ -4,7 +4,7 @@ const { timestampForPostgres } = require('../../app/lib/general.lib.js') const { data: licenceRoles } = require('./data/licence-roles.js') const LicenceRoleModel = require('../../app/models/licence-role.model.js') -async function seed () { +async function seed() { for (const licenceRole of licenceRoles) { const exists = await _exists(licenceRole) @@ -16,7 +16,7 @@ async function seed () { } } -async function _exists (licenceRole) { +async function _exists(licenceRole) { const { label, name } = licenceRole const result = await LicenceRoleModel.query() @@ -29,11 +29,11 @@ async function _exists (licenceRole) { return !!result } -async function _insert (licenceRole) { +async function _insert(licenceRole) { return LicenceRoleModel.query().insert(licenceRole) } -async function _update (licenceRole) { +async function _update(licenceRole) { const { label, name } = licenceRole return LicenceRoleModel.query() diff --git a/db/seeds/15-sources.seed.js b/db/seeds/15-sources.seed.js index 2f99ad7520..79e361ea49 100644 --- a/db/seeds/15-sources.seed.js +++ b/db/seeds/15-sources.seed.js @@ -4,22 +4,17 @@ const { timestampForPostgres } = require('../../app/lib/general.lib.js') const { data: sources } = require('./data/sources.js') const SourceModel = require('../../app/models/source.model.js') -async function seed () { +async function seed() { for (const source of sources) { await _upsert(source) } } -async function _upsert (source) { +async function _upsert(source) { return SourceModel.query() .insert({ ...source, createdAt: timestampForPostgres(), updatedAt: timestampForPostgres() }) .onConflict('externalId') - .merge([ - 'description', - 'sourceType', - 'ngr', - 'updatedAt' - ]) + .merge(['description', 'sourceType', 'ngr', 'updatedAt']) } module.exports = { diff --git a/db/seeds/16-return-cycles.seed.js b/db/seeds/16-return-cycles.seed.js index 6704901bb2..66a0f57bea 100644 --- a/db/seeds/16-return-cycles.seed.js +++ b/db/seeds/16-return-cycles.seed.js @@ -2,10 +2,14 @@ const { timestampForPostgres } = require('../../app/lib/general.lib.js') const { generateUUID } = require('../../app/lib/general.lib.js') -const { cycleDueDateByDate, cycleEndDateByDate, cycleStartDateByDate } = require('../../app/lib/return-cycle-dates.lib.js') +const { + cycleDueDateByDate, + cycleEndDateByDate, + cycleStartDateByDate +} = require('../../app/lib/return-cycle-dates.lib.js') const ReturnCycleModel = require('../../app/models/return-cycle.model.js') -async function seed () { +async function seed() { const today = new Date() const day = today.getDay() const month = today.getMonth() @@ -22,7 +26,7 @@ async function seed () { } } -function _generateReturnCycle (date, summer) { +function _generateReturnCycle(date, summer) { return { id: generateUUID(), startDate: cycleStartDateByDate(date, summer), @@ -33,15 +37,11 @@ function _generateReturnCycle (date, summer) { } } -async function _upsert (cycle) { +async function _upsert(cycle) { return ReturnCycleModel.query() .insert({ ...cycle, createdAt: timestampForPostgres(), updatedAt: timestampForPostgres() }) .onConflict(['startDate', 'endDate', 'summer']) - .merge([ - 'dueDate', - 'submittedInWrls', - 'updatedAt' - ]) + .merge(['dueDate', 'submittedInWrls', 'updatedAt']) } module.exports = { diff --git a/db/seeds/data/charge-categories.js b/db/seeds/data/charge-categories.js index e288a99c9f..41f5cd5ed0 100644 --- a/db/seeds/data/charge-categories.js +++ b/db/seeds/data/charge-categories.js @@ -5,7 +5,8 @@ const data = [ id: 'b13a469a-aa38-48c8-b899-da7536b44e37', reference: '4.1.1', subsistenceCharge: 9700, - description: 'Low loss tidal abstraction of water up to and including 25,002 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water up to and including 25,002 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, up to and including 25,002 ML/yr', tidal: true, lossFactor: 'low', @@ -18,7 +19,8 @@ const data = [ id: 'fd6c2eb6-921b-4f22-a076-5f96d793c57c', reference: '4.1.2', subsistenceCharge: 10200, - description: 'Low loss tidal abstraction of water up to and including 25,002 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water up to and including 25,002 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, up to and including 25,002 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -31,7 +33,8 @@ const data = [ id: '61aed61d-0dda-4402-ae43-74e344ba8ba1', reference: '4.1.4', subsistenceCharge: 51300, - description: 'Low loss tidal abstraction of water greater than 25,002 up to and including 83,333 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 25,002 up to and including 83,333 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 25,002 up to and including 83,333 ML/yr', tidal: true, lossFactor: 'low', @@ -44,7 +47,8 @@ const data = [ id: 'b0f8d374-eff0-4a9c-ba0d-ea81f312263e', reference: '4.1.5', subsistenceCharge: 53800, - description: 'Low loss tidal abstraction of water greater than 25,002 up to and including 83,333 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 25,002 up to and including 83,333 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 25,002 up to and including 83,333 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -57,7 +61,8 @@ const data = [ id: '0fdb82aa-7880-4c39-afc1-3381e173a06d', reference: '4.1.6', subsistenceCharge: 58800, - description: 'Low loss tidal abstraction of water greater than 25,002 up to and including 83,333 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 25,002 up to and including 83,333 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 25,002 up to and including 83,333 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -70,7 +75,8 @@ const data = [ id: '500d1e03-4755-4748-9ad2-931d8fb6f305', reference: '4.1.7', subsistenceCharge: 116200, - description: 'Low loss tidal abstraction of water greater than 83,333 up to and including 141,667 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 83,333 up to and including 141,667 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 83,333 up to and including 141,667 ML/yr', tidal: true, lossFactor: 'low', @@ -83,7 +89,8 @@ const data = [ id: '81c4eb26-fe91-4f95-8980-5a9ee954099c', reference: '4.1.8', subsistenceCharge: 122000, - description: 'Low loss tidal abstraction of water greater than 83,333 up to and including 141,667 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 83,333 up to and including 141,667 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 83,333 up to and including 141,667 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -96,7 +103,8 @@ const data = [ id: '4fc96c86-a0b9-41ce-b86d-5a63587a1220', reference: '4.1.9', subsistenceCharge: 132100, - description: 'Low loss tidal abstraction of water greater than 83,333 up to and including 141,667 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 83,333 up to and including 141,667 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 83,333 up to and including 141,667 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -109,7 +117,8 @@ const data = [ id: 'd27cd57e-4646-4367-945b-54eaad828299', reference: '4.1.10', subsistenceCharge: 178300, - description: 'Low loss tidal abstraction of water greater than 141,667 up to and including 200,000 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 141,667 up to and including 200,000 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 141,667 up to and including 200,000 ML/yr', tidal: true, lossFactor: 'low', @@ -122,7 +131,8 @@ const data = [ id: '40d84b41-b73f-4ba9-b3d9-8e0f346e6a13', reference: '4.1.11', subsistenceCharge: 187100, - description: 'Low loss tidal abstraction of water greater than 141,667 up to and including 200,000 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 141,667 up to and including 200,000 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 141,667 up to and including 200,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -135,7 +145,8 @@ const data = [ id: 'dfb8d0b3-c619-48c8-abf4-4a648e3acb18', reference: '4.1.12', subsistenceCharge: 202700, - description: 'Low loss tidal abstraction of water greater than 141,667 up to and including 200,000 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 141,667 up to and including 200,000 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 141,667 up to and including 200,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -148,7 +159,8 @@ const data = [ id: 'e6011dda-1c72-4721-85e6-c04b8ac92b1b', reference: '4.6.56', subsistenceCharge: 6869700, - description: 'High loss non-tidal abstraction of water greater than 2,200 up to and including 6,500 megalitres a year where a Tier 1 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 2,200 up to and including 6,500 megalitres a year where a Tier 1 model applies.', shortDescription: 'High loss, non-tidal, greater than 2,200 up to and including 6,500 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', @@ -161,7 +173,8 @@ const data = [ id: 'ad9f9924-50b2-48b4-923d-45c5cd505737', reference: '4.6.57', subsistenceCharge: 7439000, - description: 'High loss non-tidal abstraction of water greater than 2,200 up to and including 6,500 megalitres a year where a Tier 2 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 2,200 up to and including 6,500 megalitres a year where a Tier 2 model applies.', shortDescription: 'High loss, non-tidal, greater than 2,200 up to and including 6,500 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', @@ -174,7 +187,8 @@ const data = [ id: 'a5feda57-b44c-45cc-b3de-0391fe80ad4a', reference: '4.6.58', subsistenceCharge: 7772300, - description: 'High loss non-tidal abstraction of restricted water greater than 2,200 up to and including 6,500 megalitres a year, where no model applies.', + description: + 'High loss non-tidal abstraction of restricted water greater than 2,200 up to and including 6,500 megalitres a year, where no model applies.', shortDescription: 'High loss, non-tidal, restricted water, greater than 2,200 up to and including 6,500 ML/yr', tidal: false, lossFactor: 'high', @@ -187,8 +201,10 @@ const data = [ id: 'dc245af6-23ac-454b-a7ec-fb74813e4866', reference: '4.6.59', subsistenceCharge: 8096900, - description: 'High loss non-tidal abstraction of restricted water greater than 2,200 up to and including 6,500 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'High loss, non-tidal, restricted water, greater than 2,200 up to and including 6,500 ML/yr, Tier 1 model', + description: + 'High loss non-tidal abstraction of restricted water greater than 2,200 up to and including 6,500 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 2,200 up to and including 6,500 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', modelTier: 'tier 1', @@ -200,8 +216,10 @@ const data = [ id: 'f1b09908-bb30-42ab-94c0-b82683d2db33', reference: '4.6.60', subsistenceCharge: 8666200, - description: 'High loss non-tidal abstraction of restricted water greater than 2,200 up to and including 6,500 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'High loss, non-tidal, restricted water, greater than 2,200 up to and including 6,500 ML/yr, Tier 2 model', + description: + 'High loss non-tidal abstraction of restricted water greater than 2,200 up to and including 6,500 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 2,200 up to and including 6,500 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', modelTier: 'tier 2', @@ -213,7 +231,8 @@ const data = [ id: 'f1f53eab-c3fe-4a4b-96d7-704ebc4001b4', reference: '4.6.61', subsistenceCharge: 13958000, - description: 'High loss non-tidal abstraction of water greater than 6,500 up to and including 9,000 megalitres a year where no model applies.', + description: + 'High loss non-tidal abstraction of water greater than 6,500 up to and including 9,000 megalitres a year where no model applies.', shortDescription: 'High loss, non-tidal, greater than 6,500 up to and including 9,000 ML/yr', tidal: false, lossFactor: 'high', @@ -226,7 +245,8 @@ const data = [ id: '03b25c10-7fe8-4c09-bd62-48bba54dadcd', reference: '4.6.62', subsistenceCharge: 14650300, - description: 'High loss non-tidal abstraction of water greater than 6,500 up to and including 9,000 megalitres a year where a Tier 1 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 6,500 up to and including 9,000 megalitres a year where a Tier 1 model applies.', shortDescription: 'High loss, non-tidal, greater than 6,500 up to and including 9,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', @@ -239,7 +259,8 @@ const data = [ id: '1e8262f2-0abc-4d37-bd02-512dc99fd4ff', reference: '4.6.63', subsistenceCharge: 15861800, - description: 'High loss non-tidal abstraction of water greater than 6,500 up to and including 9,000 megalitres a year where a Tier 2 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 6,500 up to and including 9,000 megalitres a year where a Tier 2 model applies.', shortDescription: 'High loss, non-tidal, greater than 6,500 up to and including 9,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', @@ -252,7 +273,8 @@ const data = [ id: 'ea87d509-91d9-4690-ab8c-249e5c0d389a', reference: '4.6.64', subsistenceCharge: 16575100, - description: 'High loss non-tidal abstraction of restricted water greater than 6,500 up to and including 9,000 megalitres a year, where no model applies.', + description: + 'High loss non-tidal abstraction of restricted water greater than 6,500 up to and including 9,000 megalitres a year, where no model applies.', shortDescription: 'High loss, non-tidal, restricted water, greater than 6,500 up to and including 9,000 ML/yr', tidal: false, lossFactor: 'high', @@ -265,8 +287,10 @@ const data = [ id: '33062e2e-e1c7-4b3a-9d5a-059bf9fdb385', reference: '4.6.65', subsistenceCharge: 17267400, - description: 'High loss non-tidal abstraction of restricted water greater than 6,500 up to and including 9,000 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'High loss, non-tidal, restricted water, greater than 6,500 up to and including 9,000 ML/yr, Tier 1 model', + description: + 'High loss non-tidal abstraction of restricted water greater than 6,500 up to and including 9,000 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 6,500 up to and including 9,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', modelTier: 'tier 1', @@ -278,8 +302,10 @@ const data = [ id: '4bf5c78c-0640-44d1-886b-93139940473a', reference: '4.6.66', subsistenceCharge: 18478900, - description: 'High loss non-tidal abstraction of restricted water greater than 6,500 up to and including 9,000 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'High loss, non-tidal, restricted water, greater than 6,500 up to and including 9,000 ML/yr, Tier 2 model', + description: + 'High loss non-tidal abstraction of restricted water greater than 6,500 up to and including 9,000 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 6,500 up to and including 9,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', modelTier: 'tier 2', @@ -291,7 +317,8 @@ const data = [ id: '983a70e8-6a76-49cd-8f10-6afbd944a19a', reference: '4.6.67', subsistenceCharge: 25748600, - description: 'High loss non-tidal abstraction of water greater than 9,000 up to and including 21,500 megalitres a year where no model applies.', + description: + 'High loss non-tidal abstraction of water greater than 9,000 up to and including 21,500 megalitres a year where no model applies.', shortDescription: 'High loss, non-tidal, greater than 9,000 up to and including 21,500 ML/yr', tidal: false, lossFactor: 'high', @@ -304,7 +331,8 @@ const data = [ id: '614dd339-2098-43e1-93b2-71c3b513bf2d', reference: '4.6.68', subsistenceCharge: 27025700, - description: 'High loss non-tidal abstraction of water greater than 9,000 up to and including 21,500 megalitres a year where a Tier 1 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 9,000 up to and including 21,500 megalitres a year where a Tier 1 model applies.', shortDescription: 'High loss, non-tidal, greater than 9,000 up to and including 21,500 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', @@ -317,7 +345,8 @@ const data = [ id: '3192c6b7-185f-4cad-9762-cafe4bf637be', reference: '4.6.69', subsistenceCharge: 29265100, - description: 'High loss non-tidal abstraction of water greater than 9,000 up to and including 21,500 megalitres a year where a Tier 2 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 9,000 up to and including 21,500 megalitres a year where a Tier 2 model applies.', shortDescription: 'High loss, non-tidal, greater than 9,000 up to and including 21,500 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', @@ -330,7 +359,8 @@ const data = [ id: '823120c0-c376-435d-a359-6171aa00a0bc', reference: '4.6.70', subsistenceCharge: 30576500, - description: 'High loss non-tidal abstraction of restricted water greater than 9,000 up to and including 21,500 megalitres a year, where no model applies.', + description: + 'High loss non-tidal abstraction of restricted water greater than 9,000 up to and including 21,500 megalitres a year, where no model applies.', shortDescription: 'High loss, non-tidal, restricted water, greater than 9,000 up to and including 21,500 ML/yr', tidal: false, lossFactor: 'high', @@ -343,8 +373,10 @@ const data = [ id: 'fc700a81-616e-42ec-967b-6f754e54d10e', reference: '4.6.71', subsistenceCharge: 31853600, - description: 'High loss non-tidal abstraction of restricted water greater than 9,000 up to and including 21,500 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'High loss, non-tidal, restricted water, greater than 9,000 up to and including 21,500 ML/yr, Tier 1 model', + description: + 'High loss non-tidal abstraction of restricted water greater than 9,000 up to and including 21,500 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 9,000 up to and including 21,500 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', modelTier: 'tier 1', @@ -356,8 +388,10 @@ const data = [ id: '6ef4c20c-5b33-4808-acf5-729e669b362f', reference: '4.6.72', subsistenceCharge: 34093000, - description: 'High loss non-tidal abstraction of restricted water greater than 9,000 up to and including 21,500 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'High loss, non-tidal, restricted water, greater than 9,000 up to and including 21,500 ML/yr, Tier 2 model', + description: + 'High loss non-tidal abstraction of restricted water greater than 9,000 up to and including 21,500 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 9,000 up to and including 21,500 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', modelTier: 'tier 2', @@ -369,7 +403,8 @@ const data = [ id: '93e7612e-ee64-4e46-8c5f-5eb325034e2b', reference: '4.6.73', subsistenceCharge: 65723300, - description: 'High loss non-tidal abstraction of water greater than 21,500 up to and including 100,000 megalitres a year where no model applies.', + description: + 'High loss non-tidal abstraction of water greater than 21,500 up to and including 100,000 megalitres a year where no model applies.', shortDescription: 'High loss, non-tidal, greater than 21,500 up to and including 100,000 ML/yr', tidal: false, lossFactor: 'high', @@ -382,7 +417,8 @@ const data = [ id: '95b0109c-4ece-4f52-9be4-8326e90a4b55', reference: '4.6.74', subsistenceCharge: 68983000, - description: 'High loss non-tidal abstraction of water greater than 21,500 up to and including 100,000 megalitres a year where a Tier 1 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 21,500 up to and including 100,000 megalitres a year where a Tier 1 model applies.', shortDescription: 'High loss, non-tidal, greater than 21,500 up to and including 100,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', @@ -395,7 +431,8 @@ const data = [ id: '15f6a1d4-987c-4c4a-8dfc-b6713b674c9d', reference: '4.6.75', subsistenceCharge: 74699200, - description: 'High loss non-tidal abstraction of water greater than 21,500 up to and including 100,000 megalitres a year where a Tier 2 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 21,500 up to and including 100,000 megalitres a year where a Tier 2 model applies.', shortDescription: 'High loss, non-tidal, greater than 21,500 up to and including 100,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', @@ -408,7 +445,8 @@ const data = [ id: '52ab740f-784e-45a7-9204-7a776936cc74', reference: '4.6.76', subsistenceCharge: 78046500, - description: 'High loss non-tidal abstraction of restricted water greater than 21,500 up to and including 100,000 megalitres a year, where no model applies.', + description: + 'High loss non-tidal abstraction of restricted water greater than 21,500 up to and including 100,000 megalitres a year, where no model applies.', shortDescription: 'High loss, non-tidal, restricted water, greater than 21,500 up to and including 100,000 ML/yr', tidal: false, lossFactor: 'high', @@ -421,8 +459,10 @@ const data = [ id: '0e61a8e6-dda1-4fbc-a70a-649874395a6b', reference: '4.6.77', subsistenceCharge: 81306200, - description: 'High loss non-tidal abstraction of restricted water greater than 21,500 up to and including 100,000 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'High loss, non-tidal, restricted water, greater than 21,500 up to and including 100,000 ML/yr, Tier 1 model', + description: + 'High loss non-tidal abstraction of restricted water greater than 21,500 up to and including 100,000 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 21,500 up to and including 100,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', modelTier: 'tier 1', @@ -434,7 +474,8 @@ const data = [ id: 'e0a11a98-0382-4ed0-947b-3c17a0e0a60d', reference: '4.1.3', subsistenceCharge: 11000, - description: 'Low loss tidal abstraction of water up to and including 25,002 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water up to and including 25,002 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, up to and including 25,002 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -447,7 +488,8 @@ const data = [ id: '56ff0dfe-c513-4415-8f98-97b6979a821d', reference: '4.2.13', subsistenceCharge: 288900, - description: 'Medium loss tidal abstraction of water greater than 1,000 up to and including 1,833 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 1,000 up to and including 1,833 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 1,000 up to and including 1,833 ML/yr', tidal: true, lossFactor: 'medium', @@ -460,8 +502,10 @@ const data = [ id: '28afd190-0939-4e00-87f7-aa179873c953', reference: '4.6.78', subsistenceCharge: 87022400, - description: 'High loss non-tidal abstraction of restricted water greater than 21,500 up to and including 100,000 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'High loss, non-tidal, restricted water, greater than 21,500 up to and including 100,000 ML/yr, Tier 2 model', + description: + 'High loss non-tidal abstraction of restricted water greater than 21,500 up to and including 100,000 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 21,500 up to and including 100,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', modelTier: 'tier 2', @@ -473,7 +517,8 @@ const data = [ id: '5190936a-4b70-461e-95e2-270501eff66b', reference: '4.6.80', subsistenceCharge: 353223900, - description: 'High loss non-tidal abstraction of water greater than 100,000 megalitres a year, where a Tier 1 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 100,000 megalitres a year, where a Tier 1 model applies.', shortDescription: 'High loss, non-tidal, greater than 100,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'high', @@ -486,7 +531,8 @@ const data = [ id: '4e6420c6-665f-47ea-9706-fb316bb3b0fc', reference: '4.6.81', subsistenceCharge: 382483400, - description: 'High loss non-tidal abstraction of water greater than 100,000 megalitres a year, where a Tier 2 model applies.', + description: + 'High loss non-tidal abstraction of water greater than 100,000 megalitres a year, where a Tier 2 model applies.', shortDescription: 'High loss, non-tidal, greater than 100,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'high', @@ -499,7 +545,8 @@ const data = [ id: '328f8a13-2b3f-45a7-82e2-7fe6ca44b3c1', reference: '4.6.82', subsistenceCharge: 399633000, - description: 'High loss non-tidal abstraction of restricted water greater than 100,000 megalitres a year, where no model applies.', + description: + 'High loss non-tidal abstraction of restricted water greater than 100,000 megalitres a year, where no model applies.', shortDescription: 'High loss, non-tidal, restricted water, greater than 100,000 ML/yr', tidal: false, lossFactor: 'high', @@ -512,7 +559,8 @@ const data = [ id: '9add27b2-76c9-49c3-b2e2-1d94c77c50da', reference: '4.1.16', subsistenceCharge: 525800, - description: 'Low loss tidal abstraction of water greater than 366,667 up to and including 666,667 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 366,667 up to and including 666,667 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 366,667 up to and including 666,667 ML/yr', tidal: true, lossFactor: 'low', @@ -525,7 +573,8 @@ const data = [ id: 'c2f49f48-2b97-4771-8d11-474bb2cd4105', reference: '4.1.17', subsistenceCharge: 551900, - description: 'Low loss tidal abstraction of water greater than 366,667 up to and including 666,667 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 366,667 up to and including 666,667 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 366,667 up to and including 666,667 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -538,7 +587,8 @@ const data = [ id: 'b4de5157-7edf-4399-a6a2-8824e6480f3d', reference: '4.1.18', subsistenceCharge: 597600, - description: 'Low loss tidal abstraction of water greater than 366,667 up to and including 666,667 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 366,667 up to and including 666,667 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 366,667 up to and including 666,667 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -551,7 +601,8 @@ const data = [ id: '5c247460-72d5-4998-a36d-af044a346c47', reference: '4.1.19', subsistenceCharge: 993800, - description: 'Low loss tidal abstraction of water greater than 666,667 up to and including 1,250,000 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 666,667 up to and including 1,250,000 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 666,667 up to and including 1,250,000 ML/yr', tidal: true, lossFactor: 'low', @@ -564,7 +615,8 @@ const data = [ id: '3fc33402-b554-4418-bdd3-4538818ee40d', reference: '4.1.20', subsistenceCharge: 1043100, - description: 'Low loss tidal abstraction of water greater than 666,667 up to and including 1,250,000 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 666,667 up to and including 1,250,000 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 666,667 up to and including 1,250,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -577,7 +629,8 @@ const data = [ id: 'aea17ec1-e378-459e-80c6-507b8bb09bac', reference: '4.1.21', subsistenceCharge: 1129500, - description: 'Low loss tidal abstraction of water greater than 666,667 up to and including 1,250,000 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 666,667 up to and including 1,250,000 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 666,667 up to and including 1,250,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -590,7 +643,8 @@ const data = [ id: 'c37df4e6-57ae-49d6-8c6c-59d73978aa1b', reference: '4.1.22', subsistenceCharge: 1843700, - description: 'Low loss tidal abstraction of water greater than 1,250,000 up to and including 2,333,333 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 1,250,000 up to and including 2,333,333 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 1,250,000 up to and including 2,333,333 ML/yr', tidal: true, lossFactor: 'low', @@ -603,7 +657,8 @@ const data = [ id: '168faad1-ac7a-4e49-b397-dcfba6c098a9', reference: '4.1.23', subsistenceCharge: 1935100, - description: 'Low loss tidal abstraction of water greater than 1,250,000 up to and including 2,333,333 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 1,250,000 up to and including 2,333,333 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 1,250,000 up to and including 2,333,333 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -616,7 +671,8 @@ const data = [ id: 'e716ed19-cc93-49e5-b491-aa5e23c8d052', reference: '4.1.24', subsistenceCharge: 2095500, - description: 'Low loss tidal abstraction of water greater than 1,250,000 up to and including 2,333,333 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 1,250,000 up to and including 2,333,333 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 1,250,000 up to and including 2,333,333 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -629,7 +685,8 @@ const data = [ id: '11938675-c203-44bf-877a-ee4708e60480', reference: '4.1.25', subsistenceCharge: 3162100, - description: 'Low loss tidal abstraction of water greater than 2,333,333 up to and including 3,666,667 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 2,333,333 up to and including 3,666,667 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 2,333,333 up to and including 3,666,667 ML/yr', tidal: true, lossFactor: 'low', @@ -642,7 +699,8 @@ const data = [ id: 'c4058fca-63b3-4553-9c99-bca51d585012', reference: '4.1.13', subsistenceCharge: 288900, - description: 'Low loss tidal abstraction of water greater than 200,000 up to and including 366,667 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 200,000 up to and including 366,667 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 200,000 up to and including 366,667 ML/yr', tidal: true, lossFactor: 'low', @@ -655,7 +713,8 @@ const data = [ id: '76b6f703-fb75-4109-855f-1e811b13a858', reference: '4.1.14', subsistenceCharge: 303200, - description: 'Low loss tidal abstraction of water greater than 200,000 up to and including 366,667 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 200,000 up to and including 366,667 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 200,000 up to and including 366,667 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -668,7 +727,8 @@ const data = [ id: 'b64da4eb-19e9-4a9d-b091-401e6b20c471', reference: '4.1.15', subsistenceCharge: 328300, - description: 'Low loss tidal abstraction of water greater than 200,000 up to and including 366,667 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 200,000 up to and including 366,667 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 200,000 up to and including 366,667 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -681,7 +741,8 @@ const data = [ id: '5a164df9-9c9a-4d59-b248-b336f1de3c2a', reference: '4.1.26', subsistenceCharge: 3318900, - description: 'Low loss tidal abstraction of water greater than 2,333,333 up to and including 3,666,667 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 2,333,333 up to and including 3,666,667 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 2,333,333 up to and including 3,666,667 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -694,7 +755,8 @@ const data = [ id: '1afb00ac-5c3c-4d92-90f1-caee988f73e3', reference: '4.1.27', subsistenceCharge: 3594000, - description: 'Low loss tidal abstraction of water greater than 2,333,333 up to and including 3,666,667 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 2,333,333 up to and including 3,666,667 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 2,333,333 up to and including 3,666,667 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -707,7 +769,8 @@ const data = [ id: '023442c2-37f5-40a7-8267-f0c0e993924e', reference: '4.1.28', subsistenceCharge: 6545100, - description: 'Low loss tidal abstraction of water greater than 3,666,667 up to and including 10,833,333 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 3,666,667 up to and including 10,833,333 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 3,666,667 up to and including 10,833,333 ML/yr', tidal: true, lossFactor: 'low', @@ -720,7 +783,8 @@ const data = [ id: 'cce724ce-84a3-415b-89e5-f766a272916d', reference: '4.1.29', subsistenceCharge: 6869700, - description: 'Low loss tidal abstraction of water greater than 3,666,667 up to and including 10,833,333 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 3,666,667 up to and including 10,833,333 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 3,666,667 up to and including 10,833,333 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -733,7 +797,8 @@ const data = [ id: '6c0f534a-ee7c-43ba-9135-d0968d7bbb76', reference: '4.1.39', subsistenceCharge: 74699200, - description: 'Low loss tidal abstraction of water greater than 35,833,333 up to and including 166,666,667 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 35,833,333 up to and including 166,666,667 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 35,833,333 up to and including 166,666,667 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -746,7 +811,8 @@ const data = [ id: '0be1c802-69bf-43e5-b8b9-41e5796e8808', reference: '4.1.40', subsistenceCharge: 336532800, - description: 'Low loss tidal abstraction of water greater than 166,666,667 megalitres a year, where no model applies', + description: + 'Low loss tidal abstraction of water greater than 166,666,667 megalitres a year, where no model applies', shortDescription: 'Low loss, tidal, greater than 16,6666,667 ML/yr', tidal: true, lossFactor: 'low', @@ -759,7 +825,8 @@ const data = [ id: 'e4d8a5f5-1d90-4da0-81d0-dca86b5376bf', reference: '4.1.41', subsistenceCharge: 353223900, - description: 'Low loss tidal abstraction of water greater than 166,666,667 megalitres a year, where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 166,666,667 megalitres a year, where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 166,666,667 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -772,7 +839,8 @@ const data = [ id: '7a51cb20-9132-45d3-b5ca-f9f94a0ec599', reference: '4.1.42', subsistenceCharge: 382483400, - description: 'Low loss tidal abstraction of water greater than 166,666,667 megalitres a year, where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 166,666,667 megalitres a year, where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 166,666,667 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -785,7 +853,8 @@ const data = [ id: '5da15dbe-7bf2-486b-84d5-3bce0890e692', reference: '4.2.1', subsistenceCharge: 9700, - description: 'Medium loss tidal abstraction of water up to and including 125 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water up to and including 125 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, up to and including 125 ML/yr', tidal: true, lossFactor: 'medium', @@ -798,7 +867,8 @@ const data = [ id: 'f83aae21-fa78-4ad9-89d5-1e9023c075ce', reference: '4.2.2', subsistenceCharge: 10200, - description: 'Medium loss tidal abstraction of water up to and including 125 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water up to and including 125 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, up to and including 125 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -811,7 +881,8 @@ const data = [ id: '6a634f9c-49d9-4ff6-aa26-c08fae117bcb', reference: '4.1.30', subsistenceCharge: 7439000, - description: 'Low loss tidal abstraction of water greater than 3,666,667 up to and including 10,833,333 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 3,666,667 up to and including 10,833,333 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 3,666,667 up to and including 10,833,333 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -824,7 +895,8 @@ const data = [ id: '85bb467d-1985-42b5-afa7-48af44939879', reference: '4.1.31', subsistenceCharge: 13958000, - description: 'Low loss tidal abstraction of water greater than 10,833, 333 up to and including 15,000,000 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 10,833, 333 up to and including 15,000,000 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 10,833,333 up to and including 15,000,000 ML/yr', tidal: true, lossFactor: 'low', @@ -837,7 +909,8 @@ const data = [ id: '0f593203-b5fa-409d-9271-f0e1ea806325', reference: '4.1.32', subsistenceCharge: 14650300, - description: 'Low loss tidal abstraction of water greater than 10,833, 333 up to and including 15,000,000 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 10,833, 333 up to and including 15,000,000 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 10,833,333 up to and including 15,000,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -850,7 +923,8 @@ const data = [ id: '6485d150-927b-40e1-85df-b7543ab48607', reference: '4.1.33', subsistenceCharge: 15861800, - description: 'Low loss tidal abstraction of water greater than 10,833, 333 up to and including 15,000,000 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 10,833, 333 up to and including 15,000,000 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 10,833,333 up to and including 15,000,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -863,7 +937,8 @@ const data = [ id: 'f0525ceb-cba6-43b4-bb97-41867bf9cb82', reference: '4.1.34', subsistenceCharge: 25748600, - description: 'Low loss tidal abstraction of water greater than 15,000,000 up to and including 35,833,333 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 15,000,000 up to and including 35,833,333 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 15,000,000 up to and including 35,833,333 ML/yr', tidal: true, lossFactor: 'low', @@ -876,7 +951,8 @@ const data = [ id: '24e6b693-7351-4f40-9be0-c851a6f5154b', reference: '4.1.35', subsistenceCharge: 27025700, - description: 'Low loss tidal abstraction of water greater than 15,000,000 up to and including 35,833,333 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 15,000,000 up to and including 35,833,333 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 15,000,000 up to and including 35,833,333 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -889,7 +965,8 @@ const data = [ id: '7b19a23e-e20b-4c84-8035-9b4aaa4802ec', reference: '4.1.36', subsistenceCharge: 29265100, - description: 'Low loss tidal abstraction of water greater than 15,000,000 up to and including 35,833,333 megalitres a year where a Tier 2 model applies', + description: + 'Low loss tidal abstraction of water greater than 15,000,000 up to and including 35,833,333 megalitres a year where a Tier 2 model applies', shortDescription: 'Low loss, tidal, greater than 15,000,000 up to and including 35,833,333 ML/yr, Tier 2 model', tidal: true, lossFactor: 'low', @@ -902,7 +979,8 @@ const data = [ id: '8d455f2d-a8e9-429a-9a20-2e3c4ad7d613', reference: '4.1.37', subsistenceCharge: 65723300, - description: 'Low loss tidal abstraction of water greater than 35,833,333 up to and including 166,666,667 megalitres a year where no model applies', + description: + 'Low loss tidal abstraction of water greater than 35,833,333 up to and including 166,666,667 megalitres a year where no model applies', shortDescription: 'Low loss, tidal, greater than 35,833,333 up to and including 166,666,667 ML/yr', tidal: true, lossFactor: 'low', @@ -915,7 +993,8 @@ const data = [ id: 'cc39da2c-6ead-42cd-88dc-34a1a173b7a5', reference: '4.1.38', subsistenceCharge: 68983000, - description: 'Low loss tidal abstraction of water greater than 35,833,333 up to and including 166,666,667 megalitres a year where a Tier 1 model applies', + description: + 'Low loss tidal abstraction of water greater than 35,833,333 up to and including 166,666,667 megalitres a year where a Tier 1 model applies', shortDescription: 'Low loss, tidal, greater than 35,833,333 up to and including 166,666,667 ML/yr, Tier 1 model', tidal: true, lossFactor: 'low', @@ -928,7 +1007,8 @@ const data = [ id: '8ba4208c-746a-49a1-b3dc-f2dd2712a89b', reference: '4.2.3', subsistenceCharge: 11000, - description: 'Medium loss tidal abstraction of water up to and including 125 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water up to and including 125 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, up to and including 125 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -941,7 +1021,8 @@ const data = [ id: 'e0ad679d-9412-419b-9dce-57014b50fe9f', reference: '4.2.4', subsistenceCharge: 51300, - description: 'Medium loss tidal abstraction of water greater than 125 up to and including 417 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 125 up to and including 417 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 125 up to and including 417 ML/yr', tidal: true, lossFactor: 'medium', @@ -954,7 +1035,8 @@ const data = [ id: 'e924522d-2b3b-46f9-ab8a-4ae743926ca8', reference: '4.2.5', subsistenceCharge: 53800, - description: 'Medium loss tidal abstraction of water greater than 125 up to and including 417 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 125 up to and including 417 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 125 up to and including 417 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -967,7 +1049,8 @@ const data = [ id: '4c30c2d7-582f-4129-9afe-4a25c64ac5de', reference: '4.2.6', subsistenceCharge: 58800, - description: 'Medium loss tidal abstraction of water greater than 125 up to and including 417 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 125 up to and including 417 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 125 up to and including 417 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -980,7 +1063,8 @@ const data = [ id: '5d8bdca0-cb88-47c2-9018-b75555852f61', reference: '4.2.7', subsistenceCharge: 116200, - description: 'Medium loss tidal abstraction of water greater than 417 up to and including 708 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 417 up to and including 708 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 417 up to and including 708 ML/yr', tidal: true, lossFactor: 'medium', @@ -993,7 +1077,8 @@ const data = [ id: '55ba4dc3-66b1-42db-934c-3cb8d59bed0f', reference: '4.2.8', subsistenceCharge: 122000, - description: 'Medium loss tidal abstraction of water greater than 417 up to and including 708 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 417 up to and including 708 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 417 up to and including 708 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1006,7 +1091,8 @@ const data = [ id: '09913988-3446-4608-bb3d-1ef1ac282999', reference: '4.2.9', subsistenceCharge: 132100, - description: 'Medium loss tidal abstraction of water greater than 417 up to and including 708 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 417 up to and including 708 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 417 up to and including 708 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1019,7 +1105,8 @@ const data = [ id: 'c01acefe-b01d-4b42-a949-f8894a4fb375', reference: '4.2.10', subsistenceCharge: 178300, - description: 'Medium loss tidal abstraction of water greater than 708 up to and including 1,000 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 708 up to and including 1,000 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 708 up to and including 1,000 ML/yr', tidal: true, lossFactor: 'medium', @@ -1032,7 +1119,8 @@ const data = [ id: '62e4122a-a7d5-41af-bb77-5cf32d3e89d8', reference: '4.2.11', subsistenceCharge: 187100, - description: 'Medium loss tidal abstraction of water greater than 708 up to and including 1,000 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 708 up to and including 1,000 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 708 up to and including 1,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1045,7 +1133,8 @@ const data = [ id: 'b7d2bb00-8928-487b-ae42-619849fe5bd3', reference: '4.2.12', subsistenceCharge: 202700, - description: 'Medium loss tidal abstraction of water greater than 708 up to and including 1,000 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 708 up to and including 1,000 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 708 up to and including 1,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1058,7 +1147,8 @@ const data = [ id: '853bc5c2-e7a6-4134-b062-504e9b1a3fa0', reference: '4.2.14', subsistenceCharge: 303200, - description: 'Medium loss tidal abstraction of water greater than 1,000 up to and including 1,833 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 1,000 up to and including 1,833 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 1,000 up to and including 1,833 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1071,7 +1161,8 @@ const data = [ id: '41d07601-2ca2-4795-be79-30f92e228c96', reference: '4.2.15', subsistenceCharge: 328300, - description: 'Medium loss tidal abstraction of water greater than 1,000 up to and including 1,833 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 1,000 up to and including 1,833 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 1,000 up to and including 1,833 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1084,7 +1175,8 @@ const data = [ id: 'a1ef200f-1620-4762-b4f2-3cf459592f0b', reference: '4.2.16', subsistenceCharge: 525800, - description: 'Medium loss tidal abstraction of water greater than 1,833 up to and including 3,333 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 1,833 up to and including 3,333 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 1,833 up to and including 3,333 ML/yr', tidal: true, lossFactor: 'medium', @@ -1097,7 +1189,8 @@ const data = [ id: '4883c81a-f478-4806-b6af-5c0888611eef', reference: '4.2.17', subsistenceCharge: 551900, - description: 'Medium loss tidal abstraction of water greater than 1,833 up to and including 3,333 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 1,833 up to and including 3,333 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 1,833 up to and including 3,333 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1110,7 +1203,8 @@ const data = [ id: '22bf76da-7f9d-4930-9912-636195f0b350', reference: '4.2.18', subsistenceCharge: 597600, - description: 'Medium loss tidal abstraction of water greater than 1,833 up to and including 3,333 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 1,833 up to and including 3,333 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 1,833 up to and including 3,333 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1123,7 +1217,8 @@ const data = [ id: '1dd7d71d-5cfc-48e1-8a20-78c3ef9ade5b', reference: '4.2.19', subsistenceCharge: 993800, - description: 'Medium loss tidal abstraction of water greater than 3,333 up to and including 6,250 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 3,333 up to and including 6,250 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 3,333 up to and including 6,250 ML/yr', tidal: true, lossFactor: 'medium', @@ -1136,7 +1231,8 @@ const data = [ id: '0d40b64d-1ef0-4123-bf28-21f337285d0a', reference: '4.2.20', subsistenceCharge: 1043100, - description: 'Medium loss tidal abstraction of water greater than 3,333 up to and including 6,250 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 3,333 up to and including 6,250 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 3,333 up to and including 6,250 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1149,7 +1245,8 @@ const data = [ id: '88398c7b-8215-442d-a32a-947780d23d19', reference: '4.2.21', subsistenceCharge: 1129500, - description: 'Medium loss tidal abstraction of water greater than 3,333 up to and including 6,250 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 3,333 up to and including 6,250 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 3,333 up to and including 6,250 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1162,7 +1259,8 @@ const data = [ id: '21ea493d-68ea-4300-98f6-b08491b678ce', reference: '4.2.22', subsistenceCharge: 1843700, - description: 'Medium loss tidal abstraction of water greater than 6,250 up to and including 11,667 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 6,250 up to and including 11,667 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 6,250 up to and including 11,667 ML/yr', tidal: true, lossFactor: 'medium', @@ -1175,7 +1273,8 @@ const data = [ id: '7257f66e-c82d-49d2-a974-1cfe9a31de4a', reference: '4.2.23', subsistenceCharge: 1935100, - description: 'Medium loss tidal abstraction of water greater than 6,250 up to and including 11,667 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 6,250 up to and including 11,667 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 6,250 up to and including 11,667 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1188,7 +1287,8 @@ const data = [ id: '11167ede-4229-4de4-a357-27366e8d953b', reference: '4.2.28', subsistenceCharge: 6545100, - description: 'Medium loss tidal abstraction of water greater than 18,333 up to and including 54,167 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 18,333 up to and including 54,167 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 18,333 up to and including 54,167 ML/yr', tidal: true, lossFactor: 'medium', @@ -1201,7 +1301,8 @@ const data = [ id: 'de9f98d6-b76f-49f2-aa81-bc965fbd14be', reference: '4.2.29', subsistenceCharge: 6869700, - description: 'Medium loss tidal abstraction of water greater than 18,333 up to and including 54,167 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 18,333 up to and including 54,167 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 18,333 up to and including 54,167 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1214,7 +1315,8 @@ const data = [ id: 'e1436d7a-b7bd-4d6c-a03c-5677a03d8656', reference: '4.2.30', subsistenceCharge: 7439000, - description: 'Medium loss tidal abstraction of water greater than 18,333 up to and including 54,167 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 18,333 up to and including 54,167 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 18,333 up to and including 54,167 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1227,7 +1329,8 @@ const data = [ id: 'b58d7fdb-586d-4ed4-916c-98a160611413', reference: '4.2.31', subsistenceCharge: 13958000, - description: 'Medium loss tidal abstraction of water greater than 54,167 up to and including 75,000 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 54,167 up to and including 75,000 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 54,167 up to and including 75,000 ML/yr', tidal: true, lossFactor: 'medium', @@ -1240,7 +1343,8 @@ const data = [ id: '88277c68-32be-4197-8ee2-031ddfc1657d', reference: '4.2.32', subsistenceCharge: 14650300, - description: 'Medium loss tidal abstraction of water greater than 54,167 up to and including 75,000 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 54,167 up to and including 75,000 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 54,167 up to and including 75,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1253,7 +1357,8 @@ const data = [ id: 'f3326882-a7ec-4148-a893-60b9cb308812', reference: '4.2.33', subsistenceCharge: 15861800, - description: 'Medium loss tidal abstraction of water greater than 54,167 up to and including 75,000 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 54,167 up to and including 75,000 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 54,167 up to and including 75,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1266,7 +1371,8 @@ const data = [ id: '358d1be3-b658-4a08-902d-5125817383a5', reference: '4.2.34', subsistenceCharge: 25748600, - description: 'Medium loss tidal abstraction of water greater than 75,000 up to and including 179,167 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 75,000 up to and including 179,167 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 75,000 up to and including 179,167 ML/yr', tidal: true, lossFactor: 'medium', @@ -1279,7 +1385,8 @@ const data = [ id: 'b13a0b9f-af40-4760-b1b9-787cc4e6b8e2', reference: '4.2.35', subsistenceCharge: 27025700, - description: 'Medium loss tidal abstraction of water greater than 75,000 up to and including 179,167 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 75,000 up to and including 179,167 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 75,000 up to and including 179,167 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1292,7 +1399,8 @@ const data = [ id: '76f6afb0-a2a7-4c26-9ad4-647d2c6d22d4', reference: '4.2.36', subsistenceCharge: 29265100, - description: 'Medium loss tidal abstraction of water greater than 75,000 up to and including 179,167 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 75,000 up to and including 179,167 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 75,000 up to and including 179,167 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1305,7 +1413,8 @@ const data = [ id: 'a7213a5d-6323-4f4a-af9c-54324ab6dd9c', reference: '4.2.37', subsistenceCharge: 65723300, - description: 'Medium loss tidal abstraction of water greater than 179,167 up to and including 833,333 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 179,167 up to and including 833,333 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 179,167 up to and including 833,333 ML/yr', tidal: true, lossFactor: 'medium', @@ -1318,7 +1427,8 @@ const data = [ id: 'ed92f41f-5f04-41ef-ab05-d805ebd3cfa9', reference: '4.2.24', subsistenceCharge: 2095500, - description: 'Medium loss tidal abstraction of water greater than 6,250 up to and including 11,667 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 6,250 up to and including 11,667 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 6,250 up to and including 11,667 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1331,7 +1441,8 @@ const data = [ id: 'bf583031-a9a4-4e12-a090-6cb730b3c17a', reference: '4.2.25', subsistenceCharge: 3162100, - description: 'Medium loss tidal abstraction of water greater than 11,667 up to and including 18,333 megalitres a year where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 11,667 up to and including 18,333 megalitres a year where no model applies', shortDescription: 'Medium loss, tidal, greater than 11,667 up to and including 18,333 ML/yr', tidal: true, lossFactor: 'medium', @@ -1344,7 +1455,8 @@ const data = [ id: 'a3452475-5256-4998-9602-a025b36db5e3', reference: '4.2.26', subsistenceCharge: 3318900, - description: 'Medium loss tidal abstraction of water greater than 11,667 up to and including 18,333 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 11,667 up to and including 18,333 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 11,667 up to and including 18,333 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1357,7 +1469,8 @@ const data = [ id: 'f85519e3-0d23-419e-b553-95ce5f789518', reference: '4.2.27', subsistenceCharge: 3594000, - description: 'Medium loss tidal abstraction of water greater than 11,667 up to and including 18,333 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 11,667 up to and including 18,333 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 11,667 up to and including 18,333 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1370,7 +1483,8 @@ const data = [ id: 'cc5ffdd5-fe7d-4d18-89b7-be7379b1e91a', reference: '4.2.38', subsistenceCharge: 68983000, - description: 'Medium loss tidal abstraction of water greater than 179,167 up to and including 833,333 megalitres a year where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 179,167 up to and including 833,333 megalitres a year where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 179,167 up to and including 833,333 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1383,7 +1497,8 @@ const data = [ id: '6c942e4e-2145-4873-9764-86631984c6f0', reference: '4.2.39', subsistenceCharge: 74699200, - description: 'Medium loss tidal abstraction of water greater than 179,167 up to and including 833,333 megalitres a year where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 179,167 up to and including 833,333 megalitres a year where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 179,167 up to and including 833,333 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1396,7 +1511,8 @@ const data = [ id: '78b7f42d-a971-47ef-84c6-c2c107b000a9', reference: '4.2.40', subsistenceCharge: 336532800, - description: 'Medium loss tidal abstraction of water greater than 833,333 megalitres a year, where no model applies', + description: + 'Medium loss tidal abstraction of water greater than 833,333 megalitres a year, where no model applies', shortDescription: 'Medium loss, tidal, greater than 833,333 ML/yr', tidal: true, lossFactor: 'medium', @@ -1409,7 +1525,8 @@ const data = [ id: '9c9fe0d0-8ccd-4515-bef9-d0b7f1559f2b', reference: '4.2.41', subsistenceCharge: 353223900, - description: 'Medium loss tidal abstraction of water greater than 833,333 megalitres a year, where a Tier 1 model applies', + description: + 'Medium loss tidal abstraction of water greater than 833,333 megalitres a year, where a Tier 1 model applies', shortDescription: 'Medium loss, tidal, greater than 833,333 ML/yr, Tier 1 model', tidal: true, lossFactor: 'medium', @@ -1422,7 +1539,8 @@ const data = [ id: 'fe503cf8-db5c-488c-a33f-b601cc799681', reference: '4.3.10', subsistenceCharge: 178300, - description: 'High loss tidal abstraction of water greater than 425 up to and including 600 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 425 up to and including 600 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 425 up to and including 600 ML/yr', tidal: true, lossFactor: 'high', @@ -1435,7 +1553,8 @@ const data = [ id: '6d1f881f-1371-4d70-b949-df0f63faaffd', reference: '4.3.11', subsistenceCharge: 187100, - description: 'High loss tidal abstraction of water greater than 425 up to and including 600 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 425 up to and including 600 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 425 up to and including 600 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1448,7 +1567,8 @@ const data = [ id: '8fdb4837-9d16-4851-b176-48151902c79d', reference: '4.3.12', subsistenceCharge: 202700, - description: 'High loss tidal abstraction of water greater than 425 up to and including 600 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 425 up to and including 600 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 425 up to and including 600 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1461,7 +1581,8 @@ const data = [ id: '94c59695-a46a-43a1-bf6e-022c62ccbb2d', reference: '4.3.13', subsistenceCharge: 288900, - description: 'High loss tidal abstraction of water greater than 600 up to and including 1,100 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 600 up to and including 1,100 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 600 up to and including 1,100 ML/yr', tidal: true, lossFactor: 'high', @@ -1474,7 +1595,8 @@ const data = [ id: 'aca2a0f8-943f-4e5c-9e1f-1d0701f32f21', reference: '4.3.14', subsistenceCharge: 303200, - description: 'High loss tidal abstraction of water greater than 600 up to and including 1,100 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 600 up to and including 1,100 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 600 up to and including 1,100 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1487,7 +1609,8 @@ const data = [ id: '7f56ad70-7fb6-4bff-b394-60c53900ca70', reference: '4.3.15', subsistenceCharge: 328300, - description: 'High loss tidal abstraction of water greater than 600 up to and including 1,100 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 600 up to and including 1,100 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 600 up to and including 1,100 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1500,7 +1623,8 @@ const data = [ id: 'c5cc76e0-091d-4a13-b964-47f3ec777ade', reference: '4.3.16', subsistenceCharge: 525800, - description: 'High loss tidal abstraction of water greater than 1,100 up to and including 2,000 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 1,100 up to and including 2,000 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 1,100 up to and including 2,000 ML/yr', tidal: true, lossFactor: 'high', @@ -1513,7 +1637,8 @@ const data = [ id: '2abfb96b-307a-48e1-bbee-9d20bf63a794', reference: '4.3.27', subsistenceCharge: 3594000, - description: 'High loss tidal abstraction of water greater than 7,000 up to and including 11,000 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 7,000 up to and including 11,000 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 7,000 up to and including 11,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1526,7 +1651,8 @@ const data = [ id: '6190d6c6-c8b0-4d97-a587-f49a1a75773d', reference: '4.3.28', subsistenceCharge: 6545100, - description: 'High loss tidal abstraction of water greater than 11,000 up to and including 32,500 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 11,000 up to and including 32,500 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 11,000 up to and including 32,500 ML/yr', tidal: true, lossFactor: 'high', @@ -1539,7 +1665,8 @@ const data = [ id: '011f2ffb-866b-49c9-bb08-a0f0c6189014', reference: '4.3.29', subsistenceCharge: 6869700, - description: 'High loss tidal abstraction of water greater than 11,000 up to and including 32,500 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 11,000 up to and including 32,500 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 11,000 up to and including 32,500 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1552,7 +1679,8 @@ const data = [ id: '8df1fcd4-4895-4e14-affb-c2a02c4902da', reference: '4.3.30', subsistenceCharge: 7439000, - description: 'High loss tidal abstraction of water greater than 11,000 up to and including 32,500 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 11,000 up to and including 32,500 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 11,000 up to and including 32,500 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1565,7 +1693,8 @@ const data = [ id: '943b5563-5935-49e5-a963-ca6cf5820e5c', reference: '4.3.31', subsistenceCharge: 13958000, - description: 'High loss tidal abstraction of water greater than 32,500 up to and including 45,000 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 32,500 up to and including 45,000 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 32,500 up to and including 45,000 ML/yr', tidal: true, lossFactor: 'high', @@ -1578,7 +1707,8 @@ const data = [ id: 'e28dc865-2c3c-47e6-ae14-1e83bfaeb716', reference: '4.2.42', subsistenceCharge: 382483400, - description: 'Medium loss tidal abstraction of water greater than 833,333 megalitres a year, where a Tier 2 model applies', + description: + 'Medium loss tidal abstraction of water greater than 833,333 megalitres a year, where a Tier 2 model applies', shortDescription: 'Medium loss, tidal, greater than 833,333 ML/yr, Tier 2 model', tidal: true, lossFactor: 'medium', @@ -1604,7 +1734,8 @@ const data = [ id: '8704e9c7-237e-403a-b01a-dd0745a7ba01', reference: '4.3.2', subsistenceCharge: 10200, - description: 'High loss tidal abstraction of water up to and including 75 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water up to and including 75 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, up to and including 75 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1617,7 +1748,8 @@ const data = [ id: '5940b1f3-3bde-4c3e-b790-be0d56630432', reference: '4.3.3', subsistenceCharge: 11000, - description: 'High loss tidal abstraction of water up to and including 75 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water up to and including 75 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, up to and including 75 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1630,7 +1762,8 @@ const data = [ id: 'df8e43e6-6d9b-4a75-9fdd-83d83bbc932d', reference: '4.3.4', subsistenceCharge: 51300, - description: 'High loss tidal abstraction of water greater than 75 up to and including 250 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 75 up to and including 250 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 75 up to and including 250 ML/yr', tidal: true, lossFactor: 'high', @@ -1643,7 +1776,8 @@ const data = [ id: '1a5f60c0-9c9b-44b8-a14f-f37d76b31fc9', reference: '4.3.5', subsistenceCharge: 53800, - description: 'High loss tidal abstraction of water greater than 75 up to and including 250 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 75 up to and including 250 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 75 up to and including 250 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1656,7 +1790,8 @@ const data = [ id: '85671f0d-9c0f-44ca-9294-c236a479ad67', reference: '4.3.6', subsistenceCharge: 58800, - description: 'High loss tidal abstraction of water greater than 75 up to and including 250 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 75 up to and including 250 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 75 up to and including 250 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1669,7 +1804,8 @@ const data = [ id: 'fb1fed90-0ad5-4d22-86ca-34b3ac7ba324', reference: '4.3.7', subsistenceCharge: 116200, - description: 'High loss tidal abstraction of water greater than 250 up to and including 425 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 250 up to and including 425 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 250 up to and including 425 ML/yr', tidal: true, lossFactor: 'high', @@ -1682,7 +1818,8 @@ const data = [ id: '773b1f9b-4a20-45d5-8938-2146de9752fe', reference: '4.3.8', subsistenceCharge: 122000, - description: 'High loss tidal abstraction of water greater than 250 up to and including 425 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 250 up to and including 425 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 250 up to and including 425 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1695,7 +1832,8 @@ const data = [ id: 'b20587f3-a328-4c4d-a3ea-8314445676f9', reference: '4.3.9', subsistenceCharge: 132100, - description: 'High loss tidal abstraction of water greater than 250 up to and including 425 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 250 up to and including 425 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 250 up to and including 425 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1708,7 +1846,8 @@ const data = [ id: '8456ca71-93ba-412b-b9da-ff9628c8adad', reference: '4.3.17', subsistenceCharge: 551900, - description: 'High loss tidal abstraction of water greater than 1,100 up to and including 2,000 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 1,100 up to and including 2,000 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 1,100 up to and including 2,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1721,7 +1860,8 @@ const data = [ id: '723da392-c007-4c2c-83ae-8ddc79039fbc', reference: '4.3.18', subsistenceCharge: 597600, - description: 'High loss tidal abstraction of water greater than 1,100 up to and including 2,000 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 1,100 up to and including 2,000 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 1,100 up to and including 2,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1734,7 +1874,8 @@ const data = [ id: 'a170a57a-cd06-45f3-8703-c850fe78f12a', reference: '4.3.19', subsistenceCharge: 993800, - description: 'High loss tidal abstraction of water greater than 2,000 up to and including 3,750 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 2,000 up to and including 3,750 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 2,000 up to and including 3,750 ML/yr', tidal: true, lossFactor: 'high', @@ -1747,7 +1888,8 @@ const data = [ id: '638ee069-0bac-4f32-8a94-e04f07a51b6d', reference: '4.3.20', subsistenceCharge: 1043100, - description: 'High loss tidal abstraction of water greater than 2,000 up to and including 3,750 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 2,000 up to and including 3,750 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 2,000 up to and including 3,750 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1760,7 +1902,8 @@ const data = [ id: '84366006-b2f8-4abf-86a9-dd144ccd1f24', reference: '4.3.21', subsistenceCharge: 1129500, - description: 'High loss tidal abstraction of water greater than 2,000 up to and including 3,750 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 2,000 up to and including 3,750 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 2,000 up to and including 3,750 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1773,7 +1916,8 @@ const data = [ id: '84f9b8b9-8bd9-48b9-99fc-c1ad32847700', reference: '4.3.22', subsistenceCharge: 1843700, - description: 'High loss tidal abstraction of water greater than 3,750 up to and including 7,000 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 3,750 up to and including 7,000 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 3,750 up to and including 7,000 ML/yr', tidal: true, lossFactor: 'high', @@ -1786,7 +1930,8 @@ const data = [ id: 'd305cf1f-0575-4260-9401-b2b93b9063c4', reference: '4.3.23', subsistenceCharge: 1935100, - description: 'High loss tidal abstraction of water greater than 3,750 up to and including 7,000 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 3,750 up to and including 7,000 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 3,750 up to and including 7,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1799,7 +1944,8 @@ const data = [ id: '23e43b04-ffc3-46e0-a612-14581540b59c', reference: '4.3.24', subsistenceCharge: 2095500, - description: 'High loss tidal abstraction of water greater than 3,750 up to and including 7,000 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 3,750 up to and including 7,000 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 3,750 up to and including 7,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1812,7 +1958,8 @@ const data = [ id: '1fcf62c0-4110-4702-8bc9-703bc063d654', reference: '4.3.25', subsistenceCharge: 3162100, - description: 'High loss tidal abstraction of water greater than 7,000 up to and including 11,000 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 7,000 up to and including 11,000 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 7,000 up to and including 11,000 ML/yr', tidal: true, lossFactor: 'high', @@ -1825,7 +1972,8 @@ const data = [ id: 'b5801692-de56-435a-92ea-5d86c8fe9ed0', reference: '4.3.26', subsistenceCharge: 3318900, - description: 'High loss tidal abstraction of water greater than 7,000 up to and including 11,000 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 7,000 up to and including 11,000 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 7,000 up to and including 11,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1838,7 +1986,8 @@ const data = [ id: '88301721-91f2-4375-9891-b3f7be1fa0d3', reference: '4.3.32', subsistenceCharge: 14650300, - description: 'High loss tidal abstraction of water greater than 32,500 up to and including 45,000 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 32,500 up to and including 45,000 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 32,500 up to and including 45,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1851,7 +2000,8 @@ const data = [ id: '618083d4-b4c3-4521-b4fb-6555f9c09aa1', reference: '4.3.33', subsistenceCharge: 15861800, - description: 'High loss tidal abstraction of water greater than 32,500 up to and including 45,000 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 32,500 up to and including 45,000 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 32,500 up to and including 45,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1864,7 +2014,8 @@ const data = [ id: 'c6a95be6-92ff-4cd4-ae5c-138058692c60', reference: '4.3.34', subsistenceCharge: 25748600, - description: 'High loss tidal abstraction of water greater than 45,000 up to and including 107,500 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 45,000 up to and including 107,500 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 45,000 up to and including 107,500 ML/yr', tidal: true, lossFactor: 'high', @@ -1877,7 +2028,8 @@ const data = [ id: 'b98b227f-4a3f-45cb-ab9f-dfd6d8d9192d', reference: '4.3.35', subsistenceCharge: 27025700, - description: 'High loss tidal abstraction of water greater than 45,000 up to and including 107,500 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 45,000 up to and including 107,500 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 45,000 up to and including 107,500 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1890,7 +2042,8 @@ const data = [ id: '5b827280-b739-4df4-8db5-f7f0c53e6862', reference: '4.3.36', subsistenceCharge: 29265100, - description: 'High loss tidal abstraction of water greater than 45,000 up to and including 107,500 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 45,000 up to and including 107,500 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 45,000 up to and including 107,500 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1903,7 +2056,8 @@ const data = [ id: 'ecd39bba-fd51-4948-b71f-bd5ed76ef8de', reference: '4.3.37', subsistenceCharge: 65723300, - description: 'High loss tidal abstraction of water greater than 107,500 up to and including 500,000 megalitres a year where no model applies', + description: + 'High loss tidal abstraction of water greater than 107,500 up to and including 500,000 megalitres a year where no model applies', shortDescription: 'High loss, tidal, greater than 107,500 up to and including 500,000 ML/yr', tidal: true, lossFactor: 'high', @@ -1916,7 +2070,8 @@ const data = [ id: '3a52071c-35f5-4ffb-b768-e6119d88e5f4', reference: '4.3.38', subsistenceCharge: 68983000, - description: 'High loss tidal abstraction of water greater than 107,500 up to and including 500,000 megalitres a year where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 107,500 up to and including 500,000 megalitres a year where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 107,500 up to and including 500,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -1929,7 +2084,8 @@ const data = [ id: 'c4a83de0-c69c-4420-bbf4-a0cbaa5091a8', reference: '4.3.39', subsistenceCharge: 74699200, - description: 'High loss tidal abstraction of water greater than 107,500 up to and including 500,000 megalitres a year where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 107,500 up to and including 500,000 megalitres a year where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 107,500 up to and including 500,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -1942,7 +2098,8 @@ const data = [ id: '4fb3f0cb-701a-43df-8812-275c2576dfad', reference: '4.4.7', subsistenceCharge: 51300, - description: 'Low loss non-tidal abstraction of water greater than 5,000 up to and including 16,667 megalitres a year where no model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 5,000 up to and including 16,667 megalitres a year where no model applies.', shortDescription: 'Low loss, non-tidal, greater than 5,000 up to and including 16,667 ML/yr', tidal: false, lossFactor: 'low', @@ -1955,7 +2112,8 @@ const data = [ id: '06896a09-29d0-4633-b0e4-382493a69fad', reference: '4.4.8', subsistenceCharge: 53800, - description: 'Low loss non-tidal abstraction of water greater than 5,000 up to and including 16,667 megalitres a year where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 5,000 up to and including 16,667 megalitres a year where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, greater than 5,000 up to and including 16,667 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -1968,7 +2126,8 @@ const data = [ id: 'e48ac371-0efa-441d-ad40-97af0bdf81fb', reference: '4.4.9', subsistenceCharge: 58800, - description: 'Low loss non-tidal abstraction of water greater than 5,000 up to and including 16,667 megalitres a year where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 5,000 up to and including 16,667 megalitres a year where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, greater than 5,000 up to and including 16,667 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -1981,7 +2140,8 @@ const data = [ id: '2e39efed-252a-4a3e-a5d6-4e3d5fec0e3d', reference: '4.4.10', subsistenceCharge: 60900, - description: 'Low loss non-tidal abstraction of restricted water greater than 5,000 up to and including 16,667 megalitres a year, where no model applies.', + description: + 'Low loss non-tidal abstraction of restricted water greater than 5,000 up to and including 16,667 megalitres a year, where no model applies.', shortDescription: 'Low loss, non-tidal, restricted water, greater than 5,000 up to and including 16,667 ML/yr', tidal: false, lossFactor: 'low', @@ -1994,8 +2154,10 @@ const data = [ id: '15866f6c-9af1-4bf0-b95f-531203c71a87', reference: '4.4.11', subsistenceCharge: 63400, - description: 'Low loss non-tidal abstraction of restricted water greater than 5,000 up to and including 16,667 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 5,000 up to and including 16,667 ML/yr, Tier 1 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 5,000 up to and including 16,667 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 5,000 up to and including 16,667 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', modelTier: 'tier 1', @@ -2007,8 +2169,10 @@ const data = [ id: '81232c92-1568-4293-9be7-d42d7c7740c3', reference: '4.4.12', subsistenceCharge: 68400, - description: 'Low loss non-tidal abstraction of restricted water greater than 5,000 up to and including 16,667 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 5,000 up to and including 16,667 ML/yr, Tier 2 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 5,000 up to and including 16,667 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 5,000 up to and including 16,667 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', modelTier: 'tier 2', @@ -2020,7 +2184,8 @@ const data = [ id: '4875cd10-94e6-4fcd-87f0-9e7a242f8277', reference: '4.4.13', subsistenceCharge: 116200, - description: 'Low loss non-tidal abstraction of water greater than 16,667 up to and including 28,333 megalitres a year where no model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 16,667 up to and including 28,333 megalitres a year where no model applies.', shortDescription: 'Low loss, non-tidal, greater than 16,667 up to and including 28,333 ML/yr', tidal: false, lossFactor: 'low', @@ -2046,7 +2211,8 @@ const data = [ id: '407e0ee6-baf8-412a-a420-1b8b8179a484', reference: '4.3.41', subsistenceCharge: 353223900, - description: 'High loss tidal abstraction of water greater than 500,000 megalitres a year, where a Tier 1 model applies', + description: + 'High loss tidal abstraction of water greater than 500,000 megalitres a year, where a Tier 1 model applies', shortDescription: 'High loss, tidal, greater than 500,000 ML/yr, Tier 1 model', tidal: true, lossFactor: 'high', @@ -2059,7 +2225,8 @@ const data = [ id: '749bb29c-2613-4bd0-ae44-ae54b806b907', reference: '4.3.42', subsistenceCharge: 382483400, - description: 'High loss tidal abstraction of water greater than 500,000 megalitres a year, where a Tier 2 model applies', + description: + 'High loss tidal abstraction of water greater than 500,000 megalitres a year, where a Tier 2 model applies', shortDescription: 'High loss, tidal, greater than 500,000 ML/yr, Tier 2 model', tidal: true, lossFactor: 'high', @@ -2072,7 +2239,8 @@ const data = [ id: 'f1afb1b7-e2a8-4987-8f2b-324d5cd67413', reference: '4.4.1', subsistenceCharge: 9700, - description: 'Low loss non-tidal abstraction of water up to and including 5,000 megalitres a year where no model applies.', + description: + 'Low loss non-tidal abstraction of water up to and including 5,000 megalitres a year where no model applies.', shortDescription: 'Low loss, non-tidal, up to and including 5,000 ML/yr', tidal: false, lossFactor: 'low', @@ -2085,7 +2253,8 @@ const data = [ id: '81a8be5e-2d8e-4989-a62f-0f4a002a9bcc', reference: '4.4.2', subsistenceCharge: 10200, - description: 'Low loss non-tidal abstraction of water up to and including 5,000 megalitres a year where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of water up to and including 5,000 megalitres a year where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, up to and including 5,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -2098,7 +2267,8 @@ const data = [ id: 'b75c9590-7923-4af5-ba68-c5681868a47e', reference: '4.4.3', subsistenceCharge: 11000, - description: 'Low loss non-tidal abstraction of water up to and including 5,000 megalitres a year, where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of water up to and including 5,000 megalitres a year, where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, up to and including 5,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -2111,7 +2281,8 @@ const data = [ id: 'c83c3d13-19cb-4a2f-8e5b-9422b230b52a', reference: '4.4.4', subsistenceCharge: 11500, - description: 'Low loss non-tidal abstraction of restricted water up to and including 5,000 megalitres a year, where no model applies.', + description: + 'Low loss non-tidal abstraction of restricted water up to and including 5,000 megalitres a year, where no model applies.', shortDescription: 'Low loss, non-tidal, restricted water, up to and including 5,000 ML/yr', tidal: false, lossFactor: 'low', @@ -2124,7 +2295,8 @@ const data = [ id: 'bd244215-8522-4efe-8394-663e10a2598f', reference: '4.4.5', subsistenceCharge: 12000, - description: 'Low loss non-tidal abstraction of restricted water up to and including 5,000 megalitres a year, where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of restricted water up to and including 5,000 megalitres a year, where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, restricted water, up to and including 5,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -2137,7 +2309,8 @@ const data = [ id: '49c7cc3e-db41-4f93-8833-d8604a13c166', reference: '4.4.6', subsistenceCharge: 12800, - description: 'Low loss non-tidal abstraction of restricted water up to and including 5,000 megalitres a year, where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of restricted water up to and including 5,000 megalitres a year, where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, restricted water, up to and including 5,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -2150,7 +2323,8 @@ const data = [ id: '989aff96-23b1-43db-a2b4-db551c87e548', reference: '4.4.14', subsistenceCharge: 122000, - description: 'Low loss non-tidal abstraction of water greater than 16,667 up to and including 28,333 megalitres a year where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 16,667 up to and including 28,333 megalitres a year where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, greater than 16,667 up to and including 28,333 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -2163,7 +2337,8 @@ const data = [ id: '898abb0f-b501-437b-b0a0-d7169a98555d', reference: '4.4.15', subsistenceCharge: 132100, - description: 'Low loss non-tidal abstraction of water greater than 16,667 up to and including 28,333 megalitres a year where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 16,667 up to and including 28,333 megalitres a year where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, greater than 16,667 up to and including 28,333 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -2176,7 +2351,8 @@ const data = [ id: 'e3b064e0-83bb-421e-999a-caf2616bbe94', reference: '4.4.16', subsistenceCharge: 138000, - description: 'Low loss non-tidal abstraction of restricted water greater than 16,667 up to and including 28,333 megalitres a year, where no model applies.', + description: + 'Low loss non-tidal abstraction of restricted water greater than 16,667 up to and including 28,333 megalitres a year, where no model applies.', shortDescription: 'Low loss, non-tidal, restricted water, greater than 16,667 up to and including 28,333 ML/yr', tidal: false, lossFactor: 'low', @@ -2189,8 +2365,10 @@ const data = [ id: 'b27dd4b5-8926-4c85-9e46-986b24eb7bc1', reference: '4.4.17', subsistenceCharge: 143800, - description: 'Low loss non-tidal abstraction of restricted water greater than 16,667 up to and including 28,333 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 16,667 up to and including 28,333 ML/yr, Tier 1 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 16,667 up to and including 28,333 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 16,667 up to and including 28,333 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', modelTier: 'tier 1', @@ -2202,8 +2380,10 @@ const data = [ id: 'ad8aaf41-92de-4af2-9f62-18af777e0d6a', reference: '4.4.18', subsistenceCharge: 153900, - description: 'Low loss non-tidal abstraction of restricted water greater than 16,667 up to and including 28,333 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 16,667 up to and including 28,333 ML/yr, Tier 2 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 16,667 up to and including 28,333 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 16,667 up to and including 28,333 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', modelTier: 'tier 2', @@ -2215,7 +2395,8 @@ const data = [ id: 'a50abcd5-31cd-40f1-92d4-603944ac4204', reference: '4.4.19', subsistenceCharge: 178300, - description: 'Low loss non-tidal abstraction of water greater than 28,333 up to and including 40,000 megalitres a year where no model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 28,333 up to and including 40,000 megalitres a year where no model applies.', shortDescription: 'Low loss, non-tidal, greater than 28,333 up to and including 40,000 ML/yr', tidal: false, lossFactor: 'low', @@ -2228,7 +2409,8 @@ const data = [ id: '9a15bbef-33bf-48d9-b68e-d8a5176de449', reference: '4.4.20', subsistenceCharge: 187100, - description: 'Low loss non-tidal abstraction of water greater than 28,333 up to and including 40,000 megalitres a year where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 28,333 up to and including 40,000 megalitres a year where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, greater than 28,333 up to and including 40,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -2241,7 +2423,8 @@ const data = [ id: '0ad65e94-cd67-44b8-8e27-bc3eeb2f7962', reference: '4.4.21', subsistenceCharge: 202700, - description: 'Low loss non-tidal abstraction of water greater than 28,333 up to and including 40,000 megalitres a year where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 28,333 up to and including 40,000 megalitres a year where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, greater than 28,333 up to and including 40,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -2254,7 +2437,8 @@ const data = [ id: '48a7df55-317a-4e43-966d-1d46a1a43e42', reference: '4.4.22', subsistenceCharge: 211700, - description: 'Low loss non-tidal abstraction of restricted water greater than 28,333 up to and including 40,000 megalitres a year, where no model applies.', + description: + 'Low loss non-tidal abstraction of restricted water greater than 28,333 up to and including 40,000 megalitres a year, where no model applies.', shortDescription: 'Low loss, non-tidal, restricted water, greater than 28,333 up to and including 40,000 ML/yr', tidal: false, lossFactor: 'low', @@ -2267,8 +2451,10 @@ const data = [ id: '199a145a-6d17-4498-9770-37be4dd2a053', reference: '4.4.30', subsistenceCharge: 382500, - description: 'Low loss non-tidal abstraction of restricted water greater than 40,000 up to and including 73,333 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 40,000 up to and including 73,333 ML/yr, Tier 2 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 40,000 up to and including 73,333 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 40,000 up to and including 73,333 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', modelTier: 'tier 2', @@ -2280,7 +2466,8 @@ const data = [ id: 'd3ad6c7d-6f64-47cf-83db-f27bcfee7625', reference: '4.4.31', subsistenceCharge: 525800, - description: 'Low loss non-tidal abstraction of water greater than 73,333 up to and including 133,333 megalitres a year where no model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 73,333 up to and including 133,333 megalitres a year where no model applies.', shortDescription: 'Low loss, non-tidal, greater than 73,333 up to and including 133,333 ML/yr', tidal: false, lossFactor: 'low', @@ -2293,7 +2480,8 @@ const data = [ id: '6c9e7612-e280-4f40-a984-6dfbd8b0aede', reference: '4.4.32', subsistenceCharge: 551900, - description: 'Low loss non-tidal abstraction of water greater than 73,333 up to and including 133,333 megalitres a year where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 73,333 up to and including 133,333 megalitres a year where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, greater than 73,333 up to and including 133,333 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -2306,7 +2494,8 @@ const data = [ id: '069c4997-8277-401c-b5c4-bbc347a119c3', reference: '4.4.33', subsistenceCharge: 597600, - description: 'Low loss non-tidal abstraction of water greater than 73,333 up to and including 133,333 megalitres a year where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 73,333 up to and including 133,333 megalitres a year where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, greater than 73,333 up to and including 133,333 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -2319,7 +2508,8 @@ const data = [ id: 'd7929105-8c2e-47d9-a75e-8d63bafea044', reference: '4.4.34', subsistenceCharge: 624400, - description: 'Low loss non-tidal abstraction of restricted water greater than 73,333 up to and including 133,333 megalitres a year, where no model applies.', + description: + 'Low loss non-tidal abstraction of restricted water greater than 73,333 up to and including 133,333 megalitres a year, where no model applies.', shortDescription: 'Low loss, non-tidal, restricted water, greater than 73,333 up to and including 133,333 ML/yr', tidal: false, lossFactor: 'low', @@ -2332,8 +2522,10 @@ const data = [ id: '8afc2cf0-0ca1-4a06-8837-aa6337efaa51', reference: '4.4.35', subsistenceCharge: 650500, - description: 'Low loss non-tidal abstraction of restricted water greater than 73,333 up to and including 133,333 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 73,333 up to and including 133,333 ML/yr, Tier 1 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 73,333 up to and including 133,333 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 73,333 up to and including 133,333 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', modelTier: 'tier 1', @@ -2345,8 +2537,10 @@ const data = [ id: 'a9210892-c599-492e-8ed2-8ac302388fff', reference: '4.4.23', subsistenceCharge: 220500, - description: 'Low loss non-tidal abstraction of restricted water greater than 28,333 up to and including 40,000 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 28,333 up to and including 40,000 ML/yr, Tier 1 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 28,333 up to and including 40,000 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 28,333 up to and including 40,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', modelTier: 'tier 1', @@ -2358,8 +2552,10 @@ const data = [ id: '867060b0-4923-41f9-a827-81d6e7bdf311', reference: '4.4.24', subsistenceCharge: 236100, - description: 'Low loss non-tidal abstraction of restricted water greater than 28,333 up to and including 40,000 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 28,333 up to and including 40,000 ML/yr, Tier 2 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 28,333 up to and including 40,000 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 28,333 up to and including 40,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', modelTier: 'tier 2', @@ -2371,7 +2567,8 @@ const data = [ id: 'd4ecd560-2c11-4d0b-893a-725d0a6670f9', reference: '4.4.25', subsistenceCharge: 288900, - description: 'Low loss non-tidal abstraction of water greater than 40,000 up to and including 73,333 megalitres a year where no model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 40,000 up to and including 73,333 megalitres a year where no model applies.', shortDescription: 'Low loss, non-tidal, greater than 40,000 up to and including 73,333 ML/yr', tidal: false, lossFactor: 'low', @@ -2384,7 +2581,8 @@ const data = [ id: 'b202f1fb-259c-41e1-8d57-28c5f381a948', reference: '4.4.26', subsistenceCharge: 303200, - description: 'Low loss non-tidal abstraction of water greater than 40,000 up to and including 73,333 megalitres a year where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 40,000 up to and including 73,333 megalitres a year where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, greater than 40,000 up to and including 73,333 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -2397,7 +2595,8 @@ const data = [ id: '695ce228-565f-49d0-9bd3-a2955be4568d', reference: '4.4.27', subsistenceCharge: 328300, - description: 'Low loss non-tidal abstraction of water greater than 40,000 up to and including 73,333 megalitres a year where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 40,000 up to and including 73,333 megalitres a year where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, greater than 40,000 up to and including 73,333 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -2410,7 +2609,8 @@ const data = [ id: 'fa563d95-d3b5-464c-ada6-806831ab94bd', reference: '4.4.28', subsistenceCharge: 343100, - description: 'Low loss non-tidal abstraction of restricted water greater than 40,000 up to and including 73,333 megalitres a year, where no model applies.', + description: + 'Low loss non-tidal abstraction of restricted water greater than 40,000 up to and including 73,333 megalitres a year, where no model applies.', shortDescription: 'Low loss, non-tidal, restricted water, greater than 40,000 up to and including 73,333 ML/yr', tidal: false, lossFactor: 'low', @@ -2423,8 +2623,10 @@ const data = [ id: 'a85637df-bee6-471e-b1cb-d3954b8a8585', reference: '4.4.29', subsistenceCharge: 357400, - description: 'Low loss non-tidal abstraction of restricted water greater than 40,000 up to and including 73,333 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 40,000 up to and including 73,333 ML/yr, Tier 1 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 40,000 up to and including 73,333 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 40,000 up to and including 73,333 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', modelTier: 'tier 1', @@ -2436,7 +2638,8 @@ const data = [ id: 'd48829bf-7a3f-4fda-8c28-e8f21a9eba7b', reference: '4.4.39', subsistenceCharge: 1129500, - description: 'Low loss non-tidal abstraction of water greater than 133,333 up to and including 250,000 megalitres a year where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 133,333 up to and including 250,000 megalitres a year where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, greater than 133,333 up to and including 250,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -2449,7 +2652,8 @@ const data = [ id: 'cc7fbd1a-3e1e-4451-bbfe-ce90e8d7d11b', reference: '4.4.40', subsistenceCharge: 1180100, - description: 'Low loss non-tidal abstraction of restricted water greater than 133,333 up to and including 250,000 megalitres a year, where no model applies.', + description: + 'Low loss non-tidal abstraction of restricted water greater than 133,333 up to and including 250,000 megalitres a year, where no model applies.', shortDescription: 'Low loss, non-tidal, restricted water, greater than 133,333 up to and including 250,000 ML/yr', tidal: false, lossFactor: 'low', @@ -2462,8 +2666,10 @@ const data = [ id: '3b3412d9-1430-4d21-b856-89c65e171037', reference: '4.4.41', subsistenceCharge: 1229400, - description: 'Low loss non-tidal abstraction of restricted water greater than 133,333 up to and including 250,000 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 133,333 up to and including 250,000 ML/yr, Tier 1 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 133,333 up to and including 250,000 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 133,333 up to and including 250,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', modelTier: 'tier 1', @@ -2475,8 +2681,10 @@ const data = [ id: 'a57f9844-85c1-4938-9177-78dcce93a720', reference: '4.4.36', subsistenceCharge: 696200, - description: 'Low loss non-tidal abstraction of restricted water greater than 73,333 up to and including 133,333 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 73,333 up to and including 133,333 ML/yr, Tier 2 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 73,333 up to and including 133,333 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 73,333 up to and including 133,333 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', modelTier: 'tier 2', @@ -2488,7 +2696,8 @@ const data = [ id: 'c8f1d82c-67e2-4239-9111-ebb6d0ff87ce', reference: '4.4.37', subsistenceCharge: 993800, - description: 'Low loss non-tidal abstraction of water greater than 133,333 up to and including 250,000 megalitres a year where no model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 133,333 up to and including 250,000 megalitres a year where no model applies.', shortDescription: 'Low loss, non-tidal, greater than 133,333 up to and including 250,000 ML/yr', tidal: false, lossFactor: 'low', @@ -2501,7 +2710,8 @@ const data = [ id: 'e4ed4433-4bcd-4954-bbb5-1016e2deff3b', reference: '4.4.38', subsistenceCharge: 1043100, - description: 'Low loss non-tidal abstraction of water greater than 133,333 up to and including 250,000 megalitres a year where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 133,333 up to and including 250,000 megalitres a year where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, greater than 133,333 up to and including 250,000 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -2514,8 +2724,10 @@ const data = [ id: 'cb641a01-27e7-48d5-84bf-05e3406953d2', reference: '4.4.42', subsistenceCharge: 1315800, - description: 'Low loss non-tidal abstraction of restricted water greater than 133,333 up to and including 250,000 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 133,333 up to and including 250,000 ML/yr, Tier 2 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 133,333 up to and including 250,000 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 133,333 up to and including 250,000 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', modelTier: 'tier 2', @@ -2527,7 +2739,8 @@ const data = [ id: '09c507df-4ce0-4743-9bfb-d08fea9e55b8', reference: '4.4.43', subsistenceCharge: 1843700, - description: 'Low loss non-tidal abstraction of water greater than 250,000 up to and including 466,667 megalitres a year where no model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 250,000 up to and including 466,667 megalitres a year where no model applies.', shortDescription: 'Low loss, non-tidal, greater than 250,000 up to and including 466,667 ML/yr', tidal: false, lossFactor: 'low', @@ -2540,7 +2753,8 @@ const data = [ id: '81ef47b5-766e-4684-9f32-720201036927', reference: '4.4.44', subsistenceCharge: 1935100, - description: 'Low loss non-tidal abstraction of water greater than 250,000 up to and including 466,667 megalitres a year where a Tier 1 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 250,000 up to and including 466,667 megalitres a year where a Tier 1 model applies.', shortDescription: 'Low loss, non-tidal, greater than 250,000 up to and including 466,667 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', @@ -2553,7 +2767,8 @@ const data = [ id: '7ba57bec-cc17-4e67-8360-9f9b70bbf58a', reference: '4.4.45', subsistenceCharge: 2095500, - description: 'Low loss non-tidal abstraction of water greater than 250,000 up to and including 466,667 megalitres a year where a Tier 2 model applies.', + description: + 'Low loss non-tidal abstraction of water greater than 250,000 up to and including 466,667 megalitres a year where a Tier 2 model applies.', shortDescription: 'Low loss, non-tidal, greater than 250,000 up to and including 466,667 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', @@ -2566,7 +2781,8 @@ const data = [ id: '2155bfed-eec6-4fae-a08e-01f9a461b67c', reference: '4.4.46', subsistenceCharge: 2189400, - description: 'Low loss non-tidal abstraction of restricted water greater than 250,000 up to and including 466,667 megalitres a year, where no model applies.', + description: + 'Low loss non-tidal abstraction of restricted water greater than 250,000 up to and including 466,667 megalitres a year, where no model applies.', shortDescription: 'Low loss, non-tidal, restricted water, greater than 250,000 up to and including 466,667 ML/yr', tidal: false, lossFactor: 'low', @@ -2579,8 +2795,10 @@ const data = [ id: '35a5acc6-97ab-4693-9065-f5ea6387ea8d', reference: '4.4.47', subsistenceCharge: 2280800, - description: 'Low loss non-tidal abstraction of restricted water greater than 250,000 up to and including 466,667 megalitres a year, where a Tier 1 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 250,000 up to and including 466,667 ML/yr, Tier 1 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 250,000 up to and including 466,667 megalitres a year, where a Tier 1 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 250,000 up to and including 466,667 ML/yr, Tier 1 model', tidal: false, lossFactor: 'low', modelTier: 'tier 1', @@ -2592,8 +2810,10 @@ const data = [ id: 'e52a2a3a-3848-4436-8c47-f6441bef7546', reference: '4.4.48', subsistenceCharge: 2441200, - description: 'Low loss non-tidal abstraction of restricted water greater than 250,000 up to and including 466,667 megalitres a year, where a Tier 2 model applies.', - shortDescription: 'Low loss, non-tidal, restricted water, greater than 250,000 up to and including 466,667 ML/yr, Tier 2 model', + description: + 'Low loss non-tidal abstraction of restricted water greater than 250,000 up to and including 466,667 megalitres a year, where a Tier 2 model applies.', + shortDescription: + 'Low loss, non-tidal, restricted water, greater than 250,000 up to and including 466,667 ML/yr, Tier 2 model', tidal: false, lossFactor: 'low', modelTier: 'tier 2', diff --git a/db/seeds/data/group-roles.js b/db/seeds/data/group-roles.js index 015b40ff05..97a543f65e 100644 --- a/db/seeds/data/group-roles.js +++ b/db/seeds/data/group-roles.js @@ -6,193 +6,345 @@ const { data: roles } = require('./roles.js') const data = [ { id: 'e6fec455-1c2f-4cea-8ce6-7f8a8a52f384', - groupId: groups.find((group) => { return group.group === 'environment_officer' }).id, - roleId: roles.find((role) => { return role.role === 'hof_notifications' }).id + groupId: groups.find((group) => { + return group.group === 'environment_officer' + }).id, + roleId: roles.find((role) => { + return role.role === 'hof_notifications' + }).id }, { id: '521867f4-5816-4fa5-8b01-3433ca304e18', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'returns' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'returns' + }).id }, { id: '90b975b3-6aa6-406d-bfef-bc9867811dea', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'bulk_return_notifications' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'bulk_return_notifications' + }).id }, { id: '4f3014cb-3a42-4eb3-a555-076eb5c96969', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'manage_accounts' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_accounts' + }).id }, { id: 'a4a66587-190c-4f68-bf2c-bae051754bb8', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'unlink_licences' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'unlink_licences' + }).id }, { id: '9aa6163c-faf1-4167-b2ec-3346203f9365', - groupId: groups.find((group) => { return group.group === 'wirs' }).id, - roleId: roles.find((role) => { return role.role === 'returns' }).id + groupId: groups.find((group) => { + return group.group === 'wirs' + }).id, + roleId: roles.find((role) => { + return role.role === 'returns' + }).id }, { id: '2724687a-4f16-47c7-94c4-db9c89522a68', - groupId: groups.find((group) => { return group.group === 'nps' }).id, - roleId: roles.find((role) => { return role.role === 'unlink_licences' }).id + groupId: groups.find((group) => { + return group.group === 'nps' + }).id, + roleId: roles.find((role) => { + return role.role === 'unlink_licences' + }).id }, { id: 'fbf0bc10-14fa-4d69-9f2a-75ebc49aba9b', - groupId: groups.find((group) => { return group.group === 'nps' }).id, - roleId: roles.find((role) => { return role.role === 'renewal_notifications' }).id + groupId: groups.find((group) => { + return group.group === 'nps' + }).id, + roleId: roles.find((role) => { + return role.role === 'renewal_notifications' + }).id }, { id: 'c4bb2367-9491-42c3-844e-2717e20e1050', - groupId: groups.find((group) => { return group.group === 'psc' }).id, - roleId: roles.find((role) => { return role.role === 'unlink_licences' }).id + groupId: groups.find((group) => { + return group.group === 'psc' + }).id, + roleId: roles.find((role) => { + return role.role === 'unlink_licences' + }).id }, { id: '1cef304f-734c-4632-9330-872092979281', - groupId: groups.find((group) => { return group.group === 'psc' }).id, - roleId: roles.find((role) => { return role.role === 'renewal_notifications' }).id + groupId: groups.find((group) => { + return group.group === 'psc' + }).id, + roleId: roles.find((role) => { + return role.role === 'renewal_notifications' + }).id }, { id: 'dc6bc4ad-444f-4ab0-9cda-335c58f14bdd', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'returns' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'returns' + }).id }, { id: '34765744-b2df-4b48-a542-c4a4a4051b7b', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'hof_notifications' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'hof_notifications' + }).id }, { id: '72c9f37f-535d-4bb6-8184-2de8ef64f75b', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'bulk_return_notifications' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'bulk_return_notifications' + }).id }, { id: '10af67ab-b23b-4ed4-a670-f866ba958c7e', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'manage_accounts' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_accounts' + }).id }, { id: 'a8713481-9af2-41b4-88e3-69a59b8daf5e', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'unlink_licences' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'unlink_licences' + }).id }, { id: '04d51975-13e3-4346-97f2-37c367f1d6cc', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'renewal_notifications' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'renewal_notifications' + }).id }, { id: '227243f5-606f-4f5d-aa8b-9fb8104a466a', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'ar_user' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'ar_user' + }).id }, { id: 'd56a2f9e-3272-4f80-aadf-effdda53e14d', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'ar_approver' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'ar_approver' + }).id }, { id: '88ba3607-f0fc-4272-9bb3-ec8792d3ad8a', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'billing' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'billing' + }).id }, { id: '708256ad-2ebf-4871-b58a-7d1db7cac994', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'billing' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'billing' + }).id }, { id: '0e0d76d0-1e3a-4147-8044-e0aecc4346da', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'charge_version_workflow_editor' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'charge_version_workflow_editor' + }).id }, { id: '027be72e-e13f-44bb-9d8d-a2952cc6577d', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'charge_version_workflow_reviewer' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'charge_version_workflow_reviewer' + }).id }, { id: '1830bb37-5e7e-451c-8ae6-3189355287e0', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'charge_version_workflow_reviewer' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'charge_version_workflow_reviewer' + }).id }, { id: 'f740c44f-393b-4f6b-89cb-d8fc57ef5fdc', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'manage_agreements' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_agreements' + }).id }, { id: '460ff8da-4466-4475-83a4-f046d25c8679', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'manage_agreements' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_agreements' + }).id }, { id: '38f2c87f-0885-4dca-b749-247bbe2215b1', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'delete_agreements' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'delete_agreements' + }).id }, { id: 'd063e5d0-9c53-4e42-9348-1862f0f38f1d', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'delete_agreements' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'delete_agreements' + }).id }, { id: '2f2dd7d0-c88f-45a4-9420-e5235105e2b5', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'charge_version_workflow_editor' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'charge_version_workflow_editor' + }).id }, { id: 'febe1594-a854-4289-a06c-a61d21bfcdad', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'manage_billing_accounts' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_billing_accounts' + }).id }, { id: '4abb0505-c88e-43d6-af63-657e1ce2a4b9', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'manage_billing_accounts' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_billing_accounts' + }).id }, { id: '50664eac-4ac1-43e5-9c9b-ac38d2a2ace7', - groupId: groups.find((group) => { return group.group === 'environment_officer' }).id, - roleId: roles.find((role) => { return role.role === 'manage_gauging_station_licence_links' }).id + groupId: groups.find((group) => { + return group.group === 'environment_officer' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_gauging_station_licence_links' + }).id }, { id: '5bdf10a6-76f8-44aa-a53e-4b05b76a0a25', - groupId: groups.find((group) => { return group.group === 'nps' }).id, - roleId: roles.find((role) => { return role.role === 'manage_gauging_station_licence_links' }).id + groupId: groups.find((group) => { + return group.group === 'nps' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_gauging_station_licence_links' + }).id }, { id: '19c3c925-bfd6-46fd-a6cf-964e348067f1', - groupId: groups.find((group) => { return group.group === 'psc' }).id, - roleId: roles.find((role) => { return role.role === 'manage_gauging_station_licence_links' }).id + groupId: groups.find((group) => { + return group.group === 'psc' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_gauging_station_licence_links' + }).id }, { id: '0b8df4ec-47bb-424e-9eb9-ed44a151c3e0', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'manage_gauging_station_licence_links' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'manage_gauging_station_licence_links' + }).id }, { id: '530e62e6-42ff-45d0-b1c3-97082ea82472', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - roleId: roles.find((role) => { return role.role === 'view_charge_versions' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + roleId: roles.find((role) => { + return role.role === 'view_charge_versions' + }).id }, { id: 'f75a60f4-9219-4b18-8f5e-9dbf771b05c1', - groupId: groups.find((group) => { return group.group === 'nps' }).id, - roleId: roles.find((role) => { return role.role === 'view_charge_versions' }).id + groupId: groups.find((group) => { + return group.group === 'nps' + }).id, + roleId: roles.find((role) => { + return role.role === 'view_charge_versions' + }).id }, { id: '1cd4ee5c-89b7-48b7-b08b-d7fe8eef9ee0', - groupId: groups.find((group) => { return group.group === 'psc' }).id, - roleId: roles.find((role) => { return role.role === 'view_charge_versions' }).id + groupId: groups.find((group) => { + return group.group === 'psc' + }).id, + roleId: roles.find((role) => { + return role.role === 'view_charge_versions' + }).id }, { id: '882e3c15-f30d-4e25-b771-184065cc5f26', - groupId: groups.find((group) => { return group.group === 'super' }).id, - roleId: roles.find((role) => { return role.role === 'view_charge_versions' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + roleId: roles.find((role) => { + return role.role === 'view_charge_versions' + }).id } ] diff --git a/db/seeds/data/user-groups.js b/db/seeds/data/user-groups.js index ae2dc8f113..eae56378cb 100644 --- a/db/seeds/data/user-groups.js +++ b/db/seeds/data/user-groups.js @@ -6,38 +6,66 @@ const { data: users } = require('./users.js') const data = [ { id: '950706f1-31f7-4af6-aba0-40bfd00a06e0', - groupId: groups.find((group) => { return group.group === 'super' }).id, - userId: users.find((user) => { return user.username === 'admin-internal@wrls.gov.uk' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + userId: users.find((user) => { + return user.username === 'admin-internal@wrls.gov.uk' + }).id }, { id: '9d2aa1e8-6f36-491d-9e7f-5536b3100d4d', - groupId: groups.find((group) => { return group.group === 'super' }).id, - userId: users.find((user) => { return user.username === 'super.user@wrls.gov.uk' }).id + groupId: groups.find((group) => { + return group.group === 'super' + }).id, + userId: users.find((user) => { + return user.username === 'super.user@wrls.gov.uk' + }).id }, { id: '9d9a7b55-4a31-4561-a556-f71cd367becb', - groupId: groups.find((group) => { return group.group === 'environment_officer' }).id, - userId: users.find((user) => { return user.username === 'environment.officer@wrls.gov.uk' }).id + groupId: groups.find((group) => { + return group.group === 'environment_officer' + }).id, + userId: users.find((user) => { + return user.username === 'environment.officer@wrls.gov.uk' + }).id }, { id: 'b90c6892-6113-4a84-b5a4-fffafba26ae5', - groupId: groups.find((group) => { return group.group === 'wirs' }).id, - userId: users.find((user) => { return user.username === 'waste.industry.regulatory.services@wrls.gov.uk' }).id + groupId: groups.find((group) => { + return group.group === 'wirs' + }).id, + userId: users.find((user) => { + return user.username === 'waste.industry.regulatory.services@wrls.gov.uk' + }).id }, { id: '9d8fd2df-f5da-4450-8151-95f2c68c0232', - groupId: groups.find((group) => { return group.group === 'billing_and_data' }).id, - userId: users.find((user) => { return user.username === 'billing.data@wrls.gov.uk' }).id + groupId: groups.find((group) => { + return group.group === 'billing_and_data' + }).id, + userId: users.find((user) => { + return user.username === 'billing.data@wrls.gov.uk' + }).id }, { id: 'c5d7cbe2-591c-4a77-a3da-1a2acf5cdbd3', - groupId: groups.find((group) => { return group.group === 'psc' }).id, - userId: users.find((user) => { return user.username === 'permitting.support.centre@wrls.gov.uk' }).id + groupId: groups.find((group) => { + return group.group === 'psc' + }).id, + userId: users.find((user) => { + return user.username === 'permitting.support.centre@wrls.gov.uk' + }).id }, { id: 'da306f92-87e6-48f8-a521-411b19c0693f', - groupId: groups.find((group) => { return group.group === 'nps' }).id, - userId: users.find((user) => { return user.username === 'national.permitting.service@wrls.gov.uk' }).id + groupId: groups.find((group) => { + return group.group === 'nps' + }).id, + userId: users.find((user) => { + return user.username === 'national.permitting.service@wrls.gov.uk' + }).id } ] diff --git a/db/wipe.database.js b/db/wipe.database.js index 6b06fb0757..cc913583e9 100644 --- a/db/wipe.database.js +++ b/db/wipe.database.js @@ -19,7 +19,7 @@ const { wipe } = require('../test/support/database.js') * * @returns {Promise} the promise returned by `wipe()` (does not resolve to anything) */ -async function wipeDatabase () { +async function wipeDatabase() { if (process.env.NODE_ENV !== 'test') { throw Error('Will not wipe database unless NODE_ENV is test') } @@ -27,7 +27,7 @@ async function wipeDatabase () { return wipe() } -(async () => { +;(async () => { await wipeDatabase() console.log(`${dbConfig.connection.database} database wiped`) diff --git a/ecosystem.config.json b/ecosystem.config.json index 42a4ea9868..3df129bd3c 100644 --- a/ecosystem.config.json +++ b/ecosystem.config.json @@ -6,8 +6,8 @@ "combine_logs": true, "env_production": { "watch": false, - "instances" : "max", - "exec_mode" : "cluster" + "instances": "max", + "exec_mode": "cluster" } } ] diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000000..f34ac2e383 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,80 @@ +'use strict' + +const jsdocPlugin = require('eslint-plugin-jsdoc') +const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended') +const neostandard = require('neostandard') +const globals = require('globals') + +module.exports = [ + // Start with neostandard ESLint rules. neostandard is the successor to StandardJS (which has stalled due to a + // governance issue https://github.com/standard/standard/issues/1948#issuecomment-2138078249). The maintainers of + // neostandard have opted to lean into ESLint rather than follow the ethos of a standalone tool. + // + // So, it might be better to think of it as superseding eslint-config-standard. But unlike that package and its + // issues, neostandard is built for ESLint 9, so supports the new flat-file config and uses @stylistic/eslint-plugin + // for style rules rather than the deprecated ES Core ones. + // + // It also acknowledges current ways of working. For example, you can now enforce instead of ban semi colons using an + // option (the only blocker to some people using StandardJS in the past). It also acknowledges that many projects, + // like ours, want to apply StandardJS code rules, but leave the formatting to Prettier. Hence, you can now deactivate + // its style rules with the `noStyle` option. + // + // We add it first, so if anything we do conflicts with the StandardJS rules, our customisations take precedence. + // https://github.com/neostandard/neostandard + ...neostandard({ noStyle: true }), + { + languageOptions: { + ecmaVersion: 'latest', + // Needed so ESlint knows it is checking Node code. For example, without it all uses of `console.log()` and + // `process.env()` would be flagged by the 'no-undef' rule + globals: { + ...globals.node + }, + sourceType: 'commonjs' + }, + // Ignore the folder created when JSDocs are generated + ignores: ['docs/**/*'], + plugins: { + // https://github.com/gajus/eslint-plugin-jsdoc + jsdoc: jsdocPlugin + }, + rules: { + // Enforce braces around the function body of arrow functions + 'arrow-body-style': ['error', 'always'], + // Enforce 'use strict' declarations in all modules + strict: ['error', 'global'], + 'jsdoc/check-alignment': 'warn', + 'jsdoc/check-indentation': 'warn', + 'jsdoc/check-types': 'warn', + 'jsdoc/check-tag-names': 'warn', + 'jsdoc/lines-before-block': 'warn', + 'jsdoc/newline-after-description': 'off', // does not work with 'use strict' + 'jsdoc/require-description': 'warn', + 'jsdoc/require-hyphen-before-param-description': 'warn', + 'jsdoc/require-jsdoc': ['warn', { publicOnly: true }], + 'jsdoc/require-param': ['warn', { exemptedBy: ['private'] }], + 'jsdoc/require-returns': ['warn', { publicOnly: true }] + }, + settings: { + jsdoc: { + mode: 'jsdoc', + ignorePrivate: true + } + } + }, + // This section works as an override to the configuration object above. It tells the jsdoc plugin to ignore any files + // in the `app/controllers` and `db/seeds` directories. The controllers purposefully do very little and the purpose of + // the seed files is obvious + { + files: ['app/controllers/**/*', 'db/seeds/**/*'], + rules: { + 'jsdoc/require-jsdoc': 'off' + } + }, + // Adds prettier ESLint rules. It automatically sets up eslint-config-prettier, which turns off any rules declared + // above that conflict with prettier. That shouldn't be any, as we tell neostandard not to include any style rules + // and the ones we've declared we've done as per eslint-config-prettier docs on special rules. As recommended by + // eslint-plugin-prettier, we declare this config last + // https://github.com/prettier/eslint-plugin-prettier?tab=readme-ov-file#configuration-new-eslintconfigjs + eslintPluginPrettierRecommended +] diff --git a/package-lock.json b/package-lock.json index cd0240b47a..dd61ec2d45 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,16 +44,18 @@ "@hapi/code": "^9.0.3", "@hapi/hoek": "^11.0.2", "@hapi/lab": "^25.1.3", - "@stylistic/eslint-plugin-js": "^1.8.1", - "eslint": "^8.57.0", - "eslint-plugin-jsdoc": "^50.2.2", + "eslint": "^9.14.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-jsdoc": "^50.5.0", + "eslint-plugin-prettier": "^5.2.1", "jsdoc": "~4.0.3", "mock-fs": "^5.2.0", + "neostandard": "^0.11.8", "nock": "^13.3.2", "pino-pretty": "^10.2.0", + "prettier": "3.3.3", "proxyquire": "^2.1.3", - "sinon": "^15.2.0", - "standard": "^17.1.0" + "sinon": "^15.2.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -1787,10 +1789,11 @@ } }, "node_modules/@babel/eslint-parser": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.24.1.tgz", - "integrity": "sha512-d5guuzMlPeDfZIbpQ8+g1NaCNuAGBBGNECh0HVqz1sjOeVLh2CEaifuOysCH18URW6R7pqXINvf5PaR/dC6jLQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.25.9.tgz", + "integrity": "sha512-5UXfgpK0j0Xr/xIdgdLEhOFxaDZ0bRPWJJchRpqOSur/3rZoPbqqki5mm0p4NE2cs28krBEiSM2MB7//afRSQQ==", "dev": true, + "license": "MIT", "dependencies": { "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", "eslint-visitor-keys": "^2.1.0", @@ -1801,7 +1804,7 @@ }, "peerDependencies": { "@babel/core": "^7.11.0", - "eslint": "^7.5.0 || ^8.0.0" + "eslint": "^7.5.0 || ^8.0.0 || ^9.0.0" } }, "node_modules/@babel/generator": { @@ -2061,6 +2064,7 @@ "resolved": "https://registry.npmjs.org/@es-joy/jsdoccomment/-/jsdoccomment-0.49.0.tgz", "integrity": "sha512-xjZTSFgECpb9Ohuk5yMX5RhUEbfeQcuOp8IF60e+wyzWEF0M5xeSgqsfLtvPEX8BIyOX9saZqzuGPmZ8oWc+5Q==", "dev": true, + "license": "MIT", "dependencies": { "comment-parser": "1.4.1", "esquery": "^1.6.0", @@ -2071,25 +2075,30 @@ } }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", "dev": true, + "license": "MIT", "dependencies": { - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.3" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, + "funding": { + "url": "https://opencollective.com/eslint" + }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", - "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, + "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -2098,24 +2107,51 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "dev": true, + "license": "MIT", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint/config-array": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.7.0.tgz", + "integrity": "sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", "dev": true, + "license": "MIT", "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", + "espree": "^10.0.1", + "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -2123,46 +2159,56 @@ "strip-json-comments": "^3.1.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, + "license": "MIT", "engines": { - "node": ">=8" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@eslint/eslintrc/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "node_modules/@eslint/js": { + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", + "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", "dev": true, + "license": "MIT", "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, - "node_modules/@eslint/js": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", - "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", "dev": true, + "license": "Apache-2.0", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", + "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@hapi/accept": { @@ -2325,6 +2371,7 @@ "resolved": "https://registry.npmjs.org/@hapi/eslint-plugin/-/eslint-plugin-6.0.0.tgz", "integrity": "sha512-6eN1fnBO742nTTSpQtYB35aFGAT9I7r4u2v/+R2c9ToYTQp4QBoPOBA5R3+C7+Az3I0ugs+lTIqAsMPDLpsRAg==", "dev": true, + "license": "BSD-3-Clause", "peerDependencies": { "@babel/core": "^7.14.3", "@babel/eslint-parser": "^7.14.3" @@ -2469,6 +2516,278 @@ } } }, + "node_modules/@hapi/lab/node_modules/@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@hapi/lab/node_modules/@eslint/js": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, + "node_modules/@hapi/lab/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@hapi/lab/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@hapi/lab/node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@hapi/lab/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@hapi/lab/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@hapi/lab/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@hapi/lab/node_modules/eslint": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@hapi/lab/node_modules/eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@hapi/lab/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@hapi/lab/node_modules/espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@hapi/lab/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/@hapi/lab/node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/@hapi/lab/node_modules/flat-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/@hapi/lab/node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@hapi/mimos": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/@hapi/mimos/-/mimos-7.0.1.tgz", @@ -2644,12 +2963,51 @@ "@hapi/statehood": "^8.0.1" } }, + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.3.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", "integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==", "deprecated": "Use @eslint/config-array instead", "dev": true, + "license": "Apache-2.0", "dependencies": { "@humanwhocodes/object-schema": "^2.0.3", "debug": "^4.3.1", @@ -2659,6 +3017,17 @@ "node": ">=10.10.0" } }, + "node_modules/@humanwhocodes/gitignore-to-minimatch": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz", + "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==", + "dev": true, + "license": "Apache-2.0", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -2677,7 +3046,22 @@ "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "deprecated": "Use @eslint/object-schema instead", - "dev": true + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.1.tgz", + "integrity": "sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } }, "node_modules/@ioredis/commands": { "version": "1.2.0", @@ -2756,6 +3140,7 @@ "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", "dev": true, + "license": "MIT", "dependencies": { "eslint-scope": "5.1.1" } @@ -2800,6 +3185,7 @@ "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", "dev": true, + "license": "MIT", "engines": { "node": "^12.20.0 || ^14.18.0 || >=16.0.0" }, @@ -4081,47 +4467,60 @@ "node": ">=16.0.0" } }, - "node_modules/@stylistic/eslint-plugin-js": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.8.1.tgz", - "integrity": "sha512-c5c2C8Mos5tTQd+NWpqwEu7VT6SSRooAguFPMj1cp2RkTYl1ynKoXo8MWy3k4rkbzoeYHrqC2UlUzsroAN7wtQ==", + "node_modules/@stylistic/eslint-plugin": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.10.1.tgz", + "integrity": "sha512-U+4yzNXElTf9q0kEfnloI9XbOyD4cnEQCxjUI94q0+W++0GAEQvJ/slwEj9lwjDHfGADRSr+Tco/z0XJvmDfCQ==", "dev": true, + "license": "MIT", "dependencies": { - "@types/eslint": "^8.56.10", - "acorn": "^8.11.3", - "escape-string-regexp": "^4.0.0", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1" + "@typescript-eslint/utils": "^8.12.2", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "estraverse": "^5.3.0", + "picomatch": "^4.0.2" }, "engines": { - "node": "^16.0.0 || >=18.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "peerDependencies": { "eslint": ">=8.40.0" } }, - "node_modules/@stylistic/eslint-plugin-js/node_modules/escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", "dev": true, + "license": "Apache-2.0", "engines": { - "node": ">=10" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://opencollective.com/eslint" } }, - "node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "node_modules/@stylistic/eslint-plugin/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, + "license": "BSD-2-Clause", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": ">=4.0" + } + }, + "node_modules/@stylistic/eslint-plugin/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" }, "funding": { - "url": "https://opencollective.com/eslint" + "url": "https://github.com/sponsors/jonschlinkert" } }, "node_modules/@szmarczak/http-timer": { @@ -4140,21 +4539,12 @@ "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz", "integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==" }, - "node_modules/@types/eslint": { - "version": "8.56.10", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", - "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", - "dev": true, - "dependencies": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, "node_modules/@types/estree": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true, + "license": "MIT" }, "node_modules/@types/http-cache-semantics": { "version": "4.0.1", @@ -4165,13 +4555,8 @@ "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true - }, - "node_modules/@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/linkify-it": { "version": "5.0.0", @@ -4210,11 +4595,254 @@ "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.2.tgz", "integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==" }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.14.0.tgz", + "integrity": "sha512-tqp8H7UWFaZj0yNO6bycd5YjMwxa6wIHOLZvWPkidwbgLCsBMetQoGj7DPuAlWa2yGO3H48xmPwjhsSPPCGU5w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.14.0", + "@typescript-eslint/type-utils": "8.14.0", + "@typescript-eslint/utils": "8.14.0", + "@typescript-eslint/visitor-keys": "8.14.0", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.14.0.tgz", + "integrity": "sha512-2p82Yn9juUJq0XynBXtFCyrBDb6/dJombnz6vbo6mgQEtWHfvHbQuEa9kAOVIt1c9YFwi7H6WxtPj1kg+80+RA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/scope-manager": "8.14.0", + "@typescript-eslint/types": "8.14.0", + "@typescript-eslint/typescript-estree": "8.14.0", + "@typescript-eslint/visitor-keys": "8.14.0", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.14.0.tgz", + "integrity": "sha512-aBbBrnW9ARIDn92Zbo7rguLnqQ/pOrUguVpbUwzOhkFg2npFDwTgPGqFqE0H5feXcOoJOfX3SxlJaKEVtq54dw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.14.0", + "@typescript-eslint/visitor-keys": "8.14.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.14.0.tgz", + "integrity": "sha512-Xcz9qOtZuGusVOH5Uk07NGs39wrKkf3AxlkK79RBK6aJC1l03CobXjJbwBPSidetAOV+5rEVuiT1VSBUOAsanQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/typescript-estree": "8.14.0", + "@typescript-eslint/utils": "8.14.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.14.0.tgz", + "integrity": "sha512-yjeB9fnO/opvLJFAsPNYlKPnEM8+z4og09Pk504dkqonT02AyL5Z9SSqlE0XqezS93v6CXn49VHvB2G7XSsl0g==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.14.0.tgz", + "integrity": "sha512-OPXPLYKGZi9XS/49rdaCbR5j/S14HazviBlUQFvSKz3npr3NikF+mrgK7CFVur6XEt95DZp/cmke9d5i3vtVnQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/types": "8.14.0", + "@typescript-eslint/visitor-keys": "8.14.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.14.0.tgz", + "integrity": "sha512-OGqj6uB8THhrHj0Fk27DcHPojW7zKwKkPmHXHvQ58pLYp4hy8CSUdTKykKeh+5vFqTTVmjz0zCOOPKRovdsgHA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.14.0", + "@typescript-eslint/types": "8.14.0", + "@typescript-eslint/typescript-estree": "8.14.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.14.0.tgz", + "integrity": "sha512-vG0XZo8AdTH9OE6VFRwAZldNc7qtJ/6NLGWak+BtENuEUXGZgFpihILPiBvKXvJ2nFu27XNGC6rKiwuaoMbYzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.14.0", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/a-sync-waterfall": { "version": "1.0.1", @@ -4238,10 +4866,11 @@ "integrity": "sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==" }, "node_modules/acorn": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", - "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -4254,6 +4883,7 @@ "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, + "license": "MIT", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } @@ -4314,6 +4944,7 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -4349,6 +4980,7 @@ "resolved": "https://registry.npmjs.org/are-docs-informative/-/are-docs-informative-0.0.2.tgz", "integrity": "sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==", "dev": true, + "license": "MIT", "engines": { "node": ">=14" } @@ -4364,6 +4996,7 @@ "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.1.tgz", "integrity": "sha512-ahC5W1xgou+KTXix4sAO8Ki12Q+jf4i0+tmk3sC+zgcynshkHxzpXdImBehiUYKKKDwvfFiJl1tZt6ewscS1Mg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.5", "is-array-buffer": "^3.0.4" @@ -4380,6 +5013,7 @@ "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.8.tgz", "integrity": "sha512-itaWrbYbqpGXkGhZPGUulwnhVf5Hpy1xiCFsGqyIGglbBxmG5vSjxQen3/WGOjPpNEv1RtBLKxbmVXm8HpJStQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -4409,26 +5043,7 @@ "resolved": "https://registry.npmjs.org/array.prototype.findlast/-/array.prototype.findlast-1.2.5.tgz", "integrity": "sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==", "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.0.0", - "es-shim-unscopables": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/array.prototype.findlastindex": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.5.tgz", - "integrity": "sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==", - "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -4449,6 +5064,7 @@ "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", "integrity": "sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", @@ -4467,6 +5083,7 @@ "resolved": "https://registry.npmjs.org/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz", "integrity": "sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", @@ -4485,6 +5102,7 @@ "resolved": "https://registry.npmjs.org/array.prototype.tosorted/-/array.prototype.tosorted-1.1.4.tgz", "integrity": "sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -4501,6 +5119,7 @@ "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.3.tgz", "integrity": "sha512-bMxMKAjg13EBSVscxTaYA4mRc5t1UAXa2kXiGTNfZ079HIWXEkKmkgFrh/nJqamaLSrXO5H4WFFkPEaLJWbs3A==", "dev": true, + "license": "MIT", "dependencies": { "array-buffer-byte-length": "^1.0.1", "call-bind": "^1.0.5", @@ -4557,6 +5176,7 @@ "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", "dev": true, + "license": "MIT", "dependencies": { "possible-typed-array-names": "^1.0.0" }, @@ -4584,7 +5204,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/base64-js": { "version": "1.5.1", @@ -4661,6 +5282,7 @@ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4729,35 +5351,11 @@ "ieee754": "^1.2.1" } }, - "node_modules/buffer-from": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", - "dev": true - }, - "node_modules/builtins": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.1.0.tgz", - "integrity": "sha512-SW9lzGTLvWTP1AY8xeAMZimqDrIaSdLQUcVr9DMef51niJ022Ri87SwRRKYm4A6iHfkPaiVUu/Duw2Wc4J7kKg==", - "dev": true, - "dependencies": { - "semver": "^7.0.0" - } - }, - "node_modules/builtins/node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true }, "node_modules/cacheable-lookup": { "version": "7.0.0", @@ -4789,6 +5387,7 @@ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dev": true, + "license": "MIT", "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", @@ -4808,6 +5407,7 @@ "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -4981,6 +5581,7 @@ "resolved": "https://registry.npmjs.org/comment-parser/-/comment-parser-1.4.1.tgz", "integrity": "sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12.0.0" } @@ -4989,7 +5590,8 @@ "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/convert-source-map": { "version": "1.8.0", @@ -5043,6 +5645,7 @@ "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.1.tgz", "integrity": "sha512-0lht7OugA5x3iJLOWFhWK/5ehONdprk0ISXqVFn/NFrDu+cuc8iADFrGQz5BnRK7LLU3JmkbXSxaqX+/mXYtUA==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.6", "es-errors": "^1.3.0", @@ -5060,6 +5663,7 @@ "resolved": "https://registry.npmjs.org/data-view-byte-length/-/data-view-byte-length-1.0.1.tgz", "integrity": "sha512-4J7wRJD3ABAzr8wP+OcIcqq2dlUKp4DVflx++hs5h5ZKydWMI6/D/fAot+yh6g2tHh8fLFTvNOaVN357NvSrOQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "es-errors": "^1.3.0", @@ -5077,6 +5681,7 @@ "resolved": "https://registry.npmjs.org/data-view-byte-offset/-/data-view-byte-offset-1.0.0.tgz", "integrity": "sha512-t/Ygsytq+R995EJ5PZlD4Cu56sWa8InXySaViRzw9apusqsOO2bQP+SbYzAhR0pFKoB+43lYy8rWban9JSuXnA==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.6", "es-errors": "^1.3.0", @@ -5163,6 +5768,7 @@ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dev": true, + "license": "MIT", "dependencies": { "es-define-property": "^1.0.0", "es-errors": "^1.3.0", @@ -5180,6 +5786,7 @@ "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", "dev": true, + "license": "MIT", "dependencies": { "define-data-property": "^1.0.1", "has-property-descriptors": "^1.0.0", @@ -5234,6 +5841,7 @@ "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, + "license": "Apache-2.0", "dependencies": { "esutils": "^2.0.2" }, @@ -5276,6 +5884,20 @@ "once": "^1.4.0" } }, + "node_modules/enhanced-resolve": { + "version": "5.17.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", + "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", @@ -5288,15 +5910,6 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, - "node_modules/error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "dependencies": { - "is-arrayish": "^0.2.1" - } - }, "node_modules/error-stack-parser": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", @@ -5306,10 +5919,11 @@ } }, "node_modules/es-abstract": { - "version": "1.23.3", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", - "integrity": "sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==", + "version": "1.23.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.4.tgz", + "integrity": "sha512-HR1gxH5OaiN7XH7uiWH0RLw0RcFySiSoW1ctxmD1ahTw3uGBtkmm/ng0tDU1OtYx5OK6EOL5Y6O21cDflG3Jcg==", "dev": true, + "license": "MIT", "dependencies": { "array-buffer-byte-length": "^1.0.1", "arraybuffer.prototype.slice": "^1.0.3", @@ -5326,7 +5940,7 @@ "function.prototype.name": "^1.1.6", "get-intrinsic": "^1.2.4", "get-symbol-description": "^1.0.2", - "globalthis": "^1.0.3", + "globalthis": "^1.0.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2", "has-proto": "^1.0.3", @@ -5342,10 +5956,10 @@ "is-string": "^1.0.7", "is-typed-array": "^1.1.13", "is-weakref": "^1.0.2", - "object-inspect": "^1.13.1", + "object-inspect": "^1.13.3", "object-keys": "^1.1.1", "object.assign": "^4.1.5", - "regexp.prototype.flags": "^1.5.2", + "regexp.prototype.flags": "^1.5.3", "safe-array-concat": "^1.1.2", "safe-regex-test": "^1.0.3", "string.prototype.trim": "^1.2.9", @@ -5370,6 +5984,7 @@ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", "dev": true, + "license": "MIT", "dependencies": { "get-intrinsic": "^1.2.4" }, @@ -5382,15 +5997,17 @@ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" } }, "node_modules/es-iterator-helpers": { - "version": "1.0.19", - "resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.0.19.tgz", - "integrity": "sha512-zoMwbCcH5hwUkKJkT8kDIBZSz9I6mVG//+lDCinLCGov4+r7NIy0ld8o03M0cJxl2spVf6ESYVS6/gpIfq1FFw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.2.0.tgz", + "integrity": "sha512-tpxqxncxnpw3c93u8n3VOzACmRFoVmWJqbWXvX/JfKbkhBw1oslgPrUfeSt2psuqyEJFD6N/9lg5i7bsKpoq+Q==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -5399,12 +6016,13 @@ "es-set-tostringtag": "^2.0.3", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", - "globalthis": "^1.0.3", + "globalthis": "^1.0.4", + "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2", "has-proto": "^1.0.3", "has-symbols": "^1.0.3", "internal-slot": "^1.0.7", - "iterator.prototype": "^1.1.2", + "iterator.prototype": "^1.1.3", "safe-array-concat": "^1.1.2" }, "engines": { @@ -5415,13 +6033,15 @@ "version": "1.5.4", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.4.tgz", "integrity": "sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/es-object-atoms": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", "dev": true, + "license": "MIT", "dependencies": { "es-errors": "^1.3.0" }, @@ -5434,6 +6054,7 @@ "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.3.tgz", "integrity": "sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==", "dev": true, + "license": "MIT", "dependencies": { "get-intrinsic": "^1.2.4", "has-tostringtag": "^1.0.2", @@ -5448,6 +6069,7 @@ "resolved": "https://registry.npmjs.org/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz", "integrity": "sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==", "dev": true, + "license": "MIT", "dependencies": { "hasown": "^2.0.0" } @@ -5457,6 +6079,7 @@ "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", "dev": true, + "license": "MIT", "dependencies": { "is-callable": "^1.1.4", "is-date-object": "^1.0.1", @@ -5487,226 +6110,128 @@ } }, "node_modules/eslint": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", - "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", + "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", "dev": true, + "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.1", - "@humanwhocodes/config-array": "^0.13.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.18.0", + "@eslint/core": "^0.7.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.14.0", + "@eslint/plugin-kit": "^0.2.0", + "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", + "@humanwhocodes/retry": "^0.4.0", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", - "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", - "esquery": "^1.4.2", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", + "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3", - "strip-ansi": "^6.0.1", "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-config-standard": { - "version": "17.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz", - "integrity": "sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "engines": { - "node": ">=12.0.0" + "url": "https://eslint.org/donate" }, "peerDependencies": { - "eslint": "^8.0.1", - "eslint-plugin-import": "^2.25.2", - "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", - "eslint-plugin-promise": "^6.0.0" - } - }, - "node_modules/eslint-config-standard-jsx": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard-jsx/-/eslint-config-standard-jsx-11.0.0.tgz", - "integrity": "sha512-+1EV/R0JxEK1L0NGolAr8Iktm3Rgotx3BKwgaX+eAuSX8D952LULKtjgZD3F+e6SvibONnhLwoTi9DPxN5LvvQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true } - ], - "peerDependencies": { - "eslint": "^8.8.0", - "eslint-plugin-react": "^7.28.0" - } - }, - "node_modules/eslint-import-resolver-node": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", - "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", - "dev": true, - "dependencies": { - "debug": "^3.2.7", - "is-core-module": "^2.13.0", - "resolve": "^1.22.4" - } - }, - "node_modules/eslint-import-resolver-node/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" } }, - "node_modules/eslint-import-resolver-node/node_modules/resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "node_modules/eslint-compat-utils": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.5.1.tgz", + "integrity": "sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==", "dev": true, + "license": "MIT", "dependencies": { - "is-core-module": "^2.13.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" + "semver": "^7.5.4" }, - "bin": { - "resolve": "bin/resolve" + "engines": { + "node": ">=12" }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "peerDependencies": { + "eslint": ">=6.0.0" } }, - "node_modules/eslint-module-utils": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz", - "integrity": "sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==", + "node_modules/eslint-compat-utils/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, - "dependencies": { - "debug": "^3.2.7" + "license": "ISC", + "bin": { + "semver": "bin/semver.js" }, "engines": { - "node": ">=4" - }, - "peerDependenciesMeta": { - "eslint": { - "optional": true - } - } - }, - "node_modules/eslint-module-utils/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" + "node": ">=10" } }, - "node_modules/eslint-plugin-import": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", - "integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==", + "node_modules/eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", "dev": true, - "dependencies": { - "array-includes": "^3.1.7", - "array.prototype.findlastindex": "^1.2.3", - "array.prototype.flat": "^1.3.2", - "array.prototype.flatmap": "^1.3.2", - "debug": "^3.2.7", - "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.9", - "eslint-module-utils": "^2.8.0", - "hasown": "^2.0.0", - "is-core-module": "^2.13.1", - "is-glob": "^4.0.3", - "minimatch": "^3.1.2", - "object.fromentries": "^2.0.7", - "object.groupby": "^1.0.1", - "object.values": "^1.1.7", - "semver": "^6.3.1", - "tsconfig-paths": "^3.15.0" - }, - "engines": { - "node": ">=4" + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" }, "peerDependencies": { - "eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" - } - }, - "node_modules/eslint-plugin-import/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "dependencies": { - "ms": "^2.1.1" + "eslint": ">=7.0.0" } }, - "node_modules/eslint-plugin-import/node_modules/doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "node_modules/eslint-plugin-es-x": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.8.0.tgz", + "integrity": "sha512-7Ds8+wAAoV3T+LAKeu39Y5BzXCrGKrcISfgKEqTS4BDN8SFEDQd0S43jiQ8vIa3wUKD07qitZdfzlenSi8/0qQ==", "dev": true, + "funding": [ + "https://github.com/sponsors/ota-meshi", + "https://opencollective.com/eslint" + ], + "license": "MIT", "dependencies": { - "esutils": "^2.0.2" + "@eslint-community/eslint-utils": "^4.1.2", + "@eslint-community/regexpp": "^4.11.0", + "eslint-compat-utils": "^0.5.1" }, "engines": { - "node": ">=0.10.0" + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": ">=8" } }, "node_modules/eslint-plugin-jsdoc": { @@ -5714,6 +6239,7 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-50.5.0.tgz", "integrity": "sha512-xTkshfZrUbiSHXBwZ/9d5ulZ2OcHXxSvm/NPo494H/hadLRJwOq5PMV0EUpMqsb9V+kQo+9BAgi6Z7aJtdBp2A==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "@es-joy/jsdoccomment": "~0.49.0", "are-docs-informative": "^0.0.2", @@ -5735,12 +6261,13 @@ } }, "node_modules/eslint-plugin-jsdoc/node_modules/debug": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", - "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", "dev": true, + "license": "MIT", "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -5756,6 +6283,7 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -5763,40 +6291,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint-plugin-jsdoc/node_modules/eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-plugin-jsdoc/node_modules/espree": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", - "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", + "node_modules/eslint-plugin-jsdoc/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true, - "dependencies": { - "acorn": "^8.12.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.0.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } + "license": "MIT" }, "node_modules/eslint-plugin-jsdoc/node_modules/semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, + "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -5805,130 +6312,143 @@ } }, "node_modules/eslint-plugin-n": { - "version": "15.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.7.0.tgz", - "integrity": "sha512-jDex9s7D/Qial8AGVIHq4W7NswpUD5DPDL2RH8Lzd9EloWUuvUkHfv4FRLMipH5q2UtyurorBkPeNi1wVWNh3Q==", + "version": "17.13.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-17.13.1.tgz", + "integrity": "sha512-97qzhk1z3DdSJNCqT45EslwCu5+LB9GDadSyBItgKUfGsXAmN/aa7LRQ0ZxHffUxUzvgbTPJL27/pE9ZQWHy7A==", "dev": true, + "license": "MIT", "dependencies": { - "builtins": "^5.0.1", - "eslint-plugin-es": "^4.1.0", - "eslint-utils": "^3.0.0", - "ignore": "^5.1.1", - "is-core-module": "^2.11.0", - "minimatch": "^3.1.2", - "resolve": "^1.22.1", - "semver": "^7.3.8" + "@eslint-community/eslint-utils": "^4.4.1", + "enhanced-resolve": "^5.17.1", + "eslint-plugin-es-x": "^7.8.0", + "get-tsconfig": "^4.8.1", + "globals": "^15.11.0", + "ignore": "^5.3.2", + "minimatch": "^9.0.5", + "semver": "^7.6.3" }, "engines": { - "node": ">=12.22.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" + "url": "https://opencollective.com/eslint" }, "peerDependencies": { - "eslint": ">=7.0.0" + "eslint": ">=8.23.0" } }, - "node_modules/eslint-plugin-n/node_modules/eslint-plugin-es": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz", - "integrity": "sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==", + "node_modules/eslint-plugin-n/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, + "license": "MIT", "dependencies": { - "eslint-utils": "^2.0.0", - "regexpp": "^3.0.0" - }, + "balanced-match": "^1.0.0" + } + }, + "node_modules/eslint-plugin-n/node_modules/globals": { + "version": "15.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz", + "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", + "dev": true, + "license": "MIT", "engines": { - "node": ">=8.10.0" + "node": ">=18" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=4.19.1" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/eslint-plugin-n/node_modules/eslint-plugin-es/node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "node_modules/eslint-plugin-n/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, + "license": "ISC", "dependencies": { - "eslint-visitor-keys": "^1.1.0" + "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=6" + "node": ">=16 || 14 >=14.17" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" + "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/eslint-plugin-n/node_modules/eslint-plugin-es/node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "node_modules/eslint-plugin-n/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, "engines": { - "node": ">=4" + "node": ">=10" } }, - "node_modules/eslint-plugin-n/node_modules/eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "node_modules/eslint-plugin-prettier": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", + "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", "dev": true, + "license": "MIT", "dependencies": { - "eslint-visitor-keys": "^2.0.0" + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.9.1" }, "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + "node": "^14.18.0 || >=16.0.0" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" + "url": "https://opencollective.com/eslint-plugin-prettier" }, "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-plugin-n/node_modules/semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" }, - "engines": { - "node": ">=10" + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } } }, "node_modules/eslint-plugin-promise": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz", - "integrity": "sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-7.1.0.tgz", + "integrity": "sha512-8trNmPxdAy3W620WKDpaS65NlM5yAumod6XeC4LOb+jxlkG4IVcp68c6dXY2ev+uT4U1PtG57YDV6EGAXN0GbQ==", "dev": true, + "license": "ISC", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" }, "peerDependencies": { - "eslint": "^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0" } }, "node_modules/eslint-plugin-react": { - "version": "7.36.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.36.1.tgz", - "integrity": "sha512-/qwbqNXZoq+VP30s1d4Nc1C5GTxjJQjk4Jzs4Wq2qzxFM7dSmuG2UkIjg2USMLh3A/aVcUNrK7v0J5U1XEGGwA==", + "version": "7.37.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.2.tgz", + "integrity": "sha512-EsTAnj9fLVr/GZleBLFbj/sSuXeWmp1eXIN60ceYnZveqEaUCyW4X+Vh4WTdUhCkW4xutXYqTXCUSyqD4rB75w==", "dev": true, + "license": "MIT", "dependencies": { "array-includes": "^3.1.8", "array.prototype.findlast": "^1.2.5", "array.prototype.flatmap": "^1.3.2", "array.prototype.tosorted": "^1.1.4", "doctrine": "^2.1.0", - "es-iterator-helpers": "^1.0.19", + "es-iterator-helpers": "^1.1.0", "estraverse": "^5.3.0", "hasown": "^2.0.2", "jsx-ast-utils": "^2.4.1 || ^3.0.0", @@ -5954,6 +6474,7 @@ "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, + "license": "Apache-2.0", "dependencies": { "esutils": "^2.0.2" }, @@ -5966,6 +6487,7 @@ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } @@ -5975,6 +6497,7 @@ "resolved": "https://registry.npmjs.org/resolve/-/resolve-2.0.0-next.5.tgz", "integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==", "dev": true, + "license": "MIT", "dependencies": { "is-core-module": "^2.13.0", "path-parse": "^1.0.7", @@ -5992,6 +6515,7 @@ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" @@ -6005,6 +6529,7 @@ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=10" } @@ -6071,28 +6596,30 @@ } }, "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", + "integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", "dev": true, + "license": "Apache-2.0", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -6103,25 +6630,11 @@ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } }, - "node_modules/eslint/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dev": true, - "dependencies": { - "type-fest": "^0.20.2" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/eslint/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -6134,18 +6647,6 @@ "node": ">=8" } }, - "node_modules/eslint/node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/esm": { "version": "3.2.25", "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.25.tgz", @@ -6155,29 +6656,31 @@ } }, "node_modules/espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", "dev": true, + "license": "BSD-2-Clause", "dependencies": { - "acorn": "^8.9.0", + "acorn": "^8.14.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" + "eslint-visitor-keys": "^4.2.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", "dev": true, + "license": "Apache-2.0", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -6230,6 +6733,7 @@ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=4.0" } @@ -6239,6 +6743,7 @@ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, + "license": "BSD-2-Clause", "engines": { "node": ">=0.10.0" } @@ -6283,11 +6788,19 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, + "license": "MIT", "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", @@ -6372,15 +6885,16 @@ } }, "node_modules/file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", "dev": true, + "license": "MIT", "dependencies": { - "flat-cache": "^3.0.4" + "flat-cache": "^4.0.0" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": ">=16.0.0" } }, "node_modules/fill-keys": { @@ -6431,30 +6945,32 @@ } }, "node_modules/flat-cache": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", - "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", "dev": true, + "license": "MIT", "dependencies": { "flatted": "^3.2.9", - "keyv": "^4.5.3", - "rimraf": "^3.0.2" + "keyv": "^4.5.4" }, "engines": { - "node": "^10.12.0 || >=12.0.0" + "node": ">=16" } }, "node_modules/flatted": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", "dev": true, + "license": "MIT", "dependencies": { "is-callable": "^1.1.3" } @@ -6514,7 +7030,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/fsevents": { "version": "2.3.2", @@ -6543,6 +7060,7 @@ "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.6.tgz", "integrity": "sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "define-properties": "^1.2.0", @@ -6561,6 +7079,7 @@ "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", "dev": true, + "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -6587,6 +7106,7 @@ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dev": true, + "license": "MIT", "dependencies": { "es-errors": "^1.3.0", "function-bind": "^1.1.2", @@ -6609,18 +7129,6 @@ "node": ">=8.0.0" } }, - "node_modules/get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -6637,6 +7145,7 @@ "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.2.tgz", "integrity": "sha512-g0QYk1dZBxGwk+Ngc+ltRH2IBp2f7zBkBMBJZCDerh6EhlhSR6+9irMCuT/09zD6qkarHUSn529sK/yL4S27mg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.5", "es-errors": "^1.3.0", @@ -6649,6 +7158,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/get-tsconfig": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.1.tgz", + "integrity": "sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/getopts": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/getopts/-/getopts-2.3.0.tgz", @@ -6666,7 +7188,9 @@ "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, + "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -6708,6 +7232,7 @@ "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", "dev": true, + "license": "MIT", "dependencies": { "define-properties": "^1.2.1", "gopd": "^1.0.1" @@ -6744,6 +7269,7 @@ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", "dev": true, + "license": "MIT", "dependencies": { "get-intrinsic": "^1.1.3" }, @@ -6793,7 +7319,8 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/handlebars": { "version": "4.7.7", @@ -6862,6 +7389,7 @@ "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", "dev": true, + "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -6880,6 +7408,7 @@ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dev": true, + "license": "MIT", "dependencies": { "es-define-property": "^1.0.0" }, @@ -6892,6 +7421,7 @@ "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -6904,6 +7434,7 @@ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -6916,6 +7447,7 @@ "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", "dev": true, + "license": "MIT", "dependencies": { "has-symbols": "^1.0.3" }, @@ -7013,10 +7545,11 @@ ] }, "node_modules/ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true, + "license": "MIT", "engines": { "node": ">= 4" } @@ -7031,6 +7564,7 @@ "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, + "license": "MIT", "dependencies": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" @@ -7055,7 +7589,9 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, + "license": "ISC", "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -7065,13 +7601,15 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/internal-slot": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.7.tgz", "integrity": "sha512-NGnrKwXzSms2qUUih/ILZ5JBqNTSa1+ZmP6flaIp6KmSElgE9qdndzS3cqjrDovwFdmwsGsLdeFgB6suw+1e9g==", "dev": true, + "license": "MIT", "dependencies": { "es-errors": "^1.3.0", "hasown": "^2.0.0", @@ -7117,6 +7655,7 @@ "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", "integrity": "sha512-wcjaerHw0ydZwfhiKbXJWLDY8A7yV7KhjQOpb83hGgGfId/aQa4TOvwyzn2PuswW2gPCYEL/nEAiSVpdOj1lXw==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "get-intrinsic": "^1.2.1" @@ -7128,17 +7667,12 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", - "dev": true - }, "node_modules/is-async-function": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.0.0.tgz", "integrity": "sha512-Y1JXKrfykRJGdlDwdKlLpLyMIiWqWvuSd17TvZk68PLAOGOoF4Xyav1z0Xhoi+gCYjZVeC5SI+hYFOfvXmGRCA==", "dev": true, + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -7154,6 +7688,7 @@ "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", "dev": true, + "license": "MIT", "dependencies": { "has-bigints": "^1.0.1" }, @@ -7179,6 +7714,7 @@ "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" @@ -7195,6 +7731,7 @@ "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -7203,11 +7740,15 @@ } }, "node_modules/is-core-module": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", - "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", + "license": "MIT", "dependencies": { - "hasown": "^2.0.0" + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -7218,6 +7759,7 @@ "resolved": "https://registry.npmjs.org/is-data-view/-/is-data-view-1.0.1.tgz", "integrity": "sha512-AHkaJrsUVW6wq6JS8y3JnM/GJF/9cf+k20+iDzlSaJrinEo5+7vRiteOSwBhHRiAyQATN1AmY4hwzxJKPmYf+w==", "dev": true, + "license": "MIT", "dependencies": { "is-typed-array": "^1.1.13" }, @@ -7233,6 +7775,7 @@ "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", "dev": true, + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -7257,6 +7800,7 @@ "resolved": "https://registry.npmjs.org/is-finalizationregistry/-/is-finalizationregistry-1.0.2.tgz", "integrity": "sha512-0by5vtUJs8iFQb5TYUHHPudOR+qXYIMKtiUzvLIZITZUjknFmziyBJuLhVRc+Ds0dREFlskDNJKYIdIzu/9pfw==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2" }, @@ -7269,6 +7813,7 @@ "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", "dev": true, + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -7296,6 +7841,7 @@ "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -7308,6 +7854,7 @@ "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", "integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -7329,6 +7876,7 @@ "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", "dev": true, + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -7353,6 +7901,7 @@ "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -7362,6 +7911,7 @@ "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-tostringtag": "^1.0.0" @@ -7378,6 +7928,7 @@ "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -7390,6 +7941,7 @@ "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.3.tgz", "integrity": "sha512-nA2hv5XIhLR3uVzDDfCIknerhx8XUKnstuOERPNNIinXG7v9u+ohXF67vxm4TPTEPU6lm61ZkwP3c9PCB97rhg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7" }, @@ -7405,6 +7957,7 @@ "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", "dev": true, + "license": "MIT", "dependencies": { "has-tostringtag": "^1.0.0" }, @@ -7420,6 +7973,7 @@ "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", "dev": true, + "license": "MIT", "dependencies": { "has-symbols": "^1.0.2" }, @@ -7435,6 +7989,7 @@ "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.13.tgz", "integrity": "sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==", "dev": true, + "license": "MIT", "dependencies": { "which-typed-array": "^1.1.14" }, @@ -7455,6 +8010,7 @@ "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" }, @@ -7467,6 +8023,7 @@ "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2" }, @@ -7479,6 +8036,7 @@ "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.3.tgz", "integrity": "sha512-LvIm3/KWzS9oRFHugab7d+M/GcBXuXX5xZkzPmN+NxihdQlZUQ4dWuSV1xR/sq6upL1TJEDrfBgRepHFdBtSNQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "get-intrinsic": "^1.2.4" @@ -7508,16 +8066,20 @@ "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" }, "node_modules/iterator.prototype": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.2.tgz", - "integrity": "sha512-DR33HMMr8EzwuRL8Y9D3u2BMj8+RqSE850jfGu59kS7tbmPLzGkZmVSfyCFSDxuZiEY6Rzt3T2NA/qU+NwVj1w==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.3.tgz", + "integrity": "sha512-FW5iMbeQ6rBGm/oKgzq2aW4KvAGpxPzYES8N4g4xNXUKpL1mclMvOe+76AcLDTvD+Ze+sOpVhgdAQEKF4L9iGQ==", "dev": true, + "license": "MIT", "dependencies": { "define-properties": "^1.2.1", "get-intrinsic": "^1.2.1", "has-symbols": "^1.0.3", "reflect.getprototypeof": "^1.0.4", "set-function-name": "^2.0.1" + }, + "engines": { + "node": ">= 0.4" } }, "node_modules/joi": { @@ -7557,6 +8119,7 @@ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, + "license": "MIT", "dependencies": { "argparse": "^2.0.1" }, @@ -7612,6 +8175,7 @@ "resolved": "https://registry.npmjs.org/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.1.0.tgz", "integrity": "sha512-Hicd6JK5Njt2QB6XYFS7ok9e37O8AYk3jTcppG4YVQnYjOemymvTcmc7OWsmq/Qqj5TdRFO5/x/tIPmBeRtGHg==", "dev": true, + "license": "MIT", "engines": { "node": ">=12.0.0" } @@ -7642,12 +8206,6 @@ "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" }, - "node_modules/json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true - }, "node_modules/json-schema": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", @@ -7700,6 +8258,7 @@ "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", "integrity": "sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==", "dev": true, + "license": "MIT", "dependencies": { "array-includes": "^3.1.6", "array.prototype.flat": "^1.3.1", @@ -7813,22 +8372,6 @@ "uc.micro": "^2.0.0" } }, - "node_modules/load-json-file": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-5.3.0.tgz", - "integrity": "sha512-cJGP40Jc/VXUsp8/OrnyKyTZ1y6v/dphm3bioS+RrKXjK2BB6wHUd6JptZEFDGgGahMT+InnZO5i1Ei9mpC8Bw==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.15", - "parse-json": "^4.0.0", - "pify": "^4.0.1", - "strip-bom": "^3.0.0", - "type-fest": "^0.3.0" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -7876,6 +8419,7 @@ "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", "dev": true, + "license": "MIT", "dependencies": { "js-tokens": "^3.0.0 || ^4.0.0" }, @@ -7894,18 +8438,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/markdown-it": { "version": "14.1.0", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", @@ -8014,6 +8546,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -8121,6 +8654,46 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/neostandard": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/neostandard/-/neostandard-0.11.8.tgz", + "integrity": "sha512-gKgvK0EDlA0x7F1hMu/UdPCRtSSG4d9CBxVym4PMWoHz8+a1ffEz2fPU5FMH3RUqzL1ACvroUMiywMGWZSY+Mw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@humanwhocodes/gitignore-to-minimatch": "^1.0.2", + "@stylistic/eslint-plugin": "^2.10.1", + "eslint-plugin-n": "^17.13.1", + "eslint-plugin-promise": "^7.1.0", + "eslint-plugin-react": "^7.36.1", + "find-up": "^5.0.0", + "globals": "^15.12.0", + "peowly": "^1.3.2", + "typescript-eslint": "^8.13.0" + }, + "bin": { + "neostandard": "cli.mjs" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": "^9.0.0" + } + }, + "node_modules/neostandard/node_modules/globals": { + "version": "15.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz", + "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/nise": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.4.tgz", @@ -8239,15 +8812,20 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, "node_modules/object-inspect": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", - "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", + "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -8257,6 +8835,7 @@ "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" } @@ -8266,6 +8845,7 @@ "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz", "integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.5", "define-properties": "^1.2.1", @@ -8284,6 +8864,7 @@ "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.1.8.tgz", "integrity": "sha512-cmopxi8VwRIAw/fkijJohSfpef5PdN0pMQJN6VC/ZKvn0LIknWD8KtgY6KlQdEc4tIjcQ3HxSMmnvtzIscdaYQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -8298,6 +8879,7 @@ "resolved": "https://registry.npmjs.org/object.fromentries/-/object.fromentries-2.0.8.tgz", "integrity": "sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -8311,25 +8893,12 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/object.groupby": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.3.tgz", - "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/object.values": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.2.0.tgz", "integrity": "sha512-yBYjY9QX2hnRmZHAjG/f13MzmBzxzYgQhFrke06TTyKY5zSTEqkOeukBzIdVA3j3ulu8Qa3MbVFShV7T2RmGtQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -8461,6 +9030,7 @@ "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, + "license": "MIT", "dependencies": { "callsites": "^3.0.0" }, @@ -8469,10 +9039,11 @@ } }, "node_modules/parse-imports": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/parse-imports/-/parse-imports-2.1.1.tgz", - "integrity": "sha512-TDT4HqzUiTMO1wJRwg/t/hYk8Wdp3iF/ToMIlAoVQfL1Xs/sTxq1dKWSMjMbQmIarfWKymOyly40+zmPHXMqCA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/parse-imports/-/parse-imports-2.2.1.tgz", + "integrity": "sha512-OL/zLggRp8mFhKL0rNORUTR4yBYujK/uU+xZL+/0Rgm2QE4nLO9v8PzEweSJEbMGKmDRjJE4R3IMJlL2di4JeQ==", "dev": true, + "license": "Apache-2.0 AND MIT", "dependencies": { "es-module-lexer": "^1.5.3", "slashes": "^3.0.12" @@ -8481,19 +9052,6 @@ "node": ">= 18" } }, - "node_modules/parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==", - "dev": true, - "dependencies": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -8508,6 +9066,7 @@ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -8544,6 +9103,16 @@ "node": ">=8" } }, + "node_modules/peowly": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/peowly/-/peowly-1.3.2.tgz", + "integrity": "sha512-BYIrwr8JCXY49jUZscgw311w9oGEKo7ux/s+BxrhKTQbiQ0iYNdZNJ5LgagaeercQdFHwnR7Z5IxxFWVQ+BasQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.6.0" + } + }, "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -8672,15 +9241,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/pino": { "version": "8.6.1", "resolved": "https://registry.npmjs.org/pino/-/pino-8.6.1.tgz", @@ -8741,80 +9301,6 @@ "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.0.0.tgz", "integrity": "sha512-mMMOwSKrmyl+Y12Ri2xhH1lbzQxwwpuru9VjyJpgFIH4asSj88F2csdMwN6+M5g1Ll4rmsYghHLQJw81tgZ7LQ==" }, - "node_modules/pkg-conf": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-3.1.0.tgz", - "integrity": "sha512-m0OTbR/5VPNPqO1ph6Fqbj7Hv6QU7gR/tQW40ZqrL1rjgCU85W6C1bJn0BItuJqnR98PWzw7Z8hHeChD1WrgdQ==", - "dev": true, - "dependencies": { - "find-up": "^3.0.0", - "load-json-file": "^5.2.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-conf/node_modules/find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "dependencies": { - "locate-path": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-conf/node_modules/locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "dependencies": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-conf/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pkg-conf/node_modules/p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "dependencies": { - "p-limit": "^2.0.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/pkg-conf/node_modules/path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/pkg-up": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz", @@ -8893,6 +9379,7 @@ "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", "integrity": "sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.4" } @@ -8941,6 +9428,35 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -8964,6 +9480,7 @@ "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", "dev": true, + "license": "MIT", "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -9059,7 +9576,8 @@ "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/readable-stream": { "version": "4.2.0", @@ -9131,6 +9649,7 @@ "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.6.tgz", "integrity": "sha512-fmfw4XgoDke3kdI6h4xcUz1dG8uaiv5q9gcEwLS4Pnth2kxT+GZ7YehS1JTMGBQmtV7Y4GFGbs2re2NqhdozUg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -9148,15 +9667,16 @@ } }, "node_modules/regexp.prototype.flags": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz", - "integrity": "sha512-NcDiDkTLuPR+++OCKB0nWafEmhg/Da8aUPLPMQbK+bxKKCm1/S5he+AqYa4PlMCVBalb4/yxIRub6qkEx5yJbw==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.3.tgz", + "integrity": "sha512-vqlC04+RQoFalODCbCumG2xIOvapzVMHwsyIGM/SIE8fRhFFsXeH8/QQ+s0T0kDAhKc4k30s73/0ydkHQz6HlQ==", "dev": true, + "license": "MIT", "dependencies": { - "call-bind": "^1.0.6", + "call-bind": "^1.0.7", "define-properties": "^1.2.1", "es-errors": "^1.3.0", - "set-function-name": "^2.0.1" + "set-function-name": "^2.0.2" }, "engines": { "node": ">= 0.4" @@ -9165,18 +9685,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -9248,11 +9756,12 @@ } }, "node_modules/resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", + "license": "MIT", "dependencies": { - "is-core-module": "^2.9.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -9273,10 +9782,21 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/responselike": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/responselike/-/responselike-3.0.0.tgz", @@ -9305,7 +9825,9 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", "dev": true, + "license": "ISC", "dependencies": { "glob": "^7.1.3" }, @@ -9344,6 +9866,7 @@ "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.2.tgz", "integrity": "sha512-vj6RsCsWBCf19jIeHEfkRMw8DPiBb+DMXklQ/1SGDHOMlHdPUkZXFQ2YdplS23zESTijAcurb1aSgJA3AgMu1Q==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "get-intrinsic": "^1.2.4", @@ -9361,7 +9884,8 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/safe-buffer": { "version": "5.1.2", @@ -9373,6 +9897,7 @@ "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.3.tgz", "integrity": "sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.6", "es-errors": "^1.3.0", @@ -9471,6 +9996,7 @@ "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", "dev": true, + "license": "MIT", "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", @@ -9488,6 +10014,7 @@ "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", "dev": true, + "license": "MIT", "dependencies": { "define-data-property": "^1.1.4", "es-errors": "^1.3.0", @@ -9524,6 +10051,7 @@ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "es-errors": "^1.3.0", @@ -9589,7 +10117,8 @@ "version": "3.0.12", "resolved": "https://registry.npmjs.org/slashes/-/slashes-3.0.12.tgz", "integrity": "sha512-Q9VME8WyGkc7pJf6QEkj3wE+2CnvZMI+XJhwdTPR8Z/kWQRXi7boAWLDibRPyHRTUTPx5FaU7MsyrjI3yLB4HA==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/sonic-boom": { "version": "3.2.0", @@ -9639,23 +10168,26 @@ "version": "2.5.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz", "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==", - "dev": true + "dev": true, + "license": "CC-BY-3.0" }, "node_modules/spdx-expression-parse": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-4.0.0.tgz", "integrity": "sha512-Clya5JIij/7C6bRR22+tnGXbc4VKlibKSVj2iHvVeX5iMW7s1SIQlqu699JkODJJIhh/pUu8L0/VLh8xflD+LQ==", "dev": true, + "license": "MIT", "dependencies": { "spdx-exceptions": "^2.1.0", "spdx-license-ids": "^3.0.0" } }, "node_modules/spdx-license-ids": { - "version": "3.0.18", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.18.tgz", - "integrity": "sha512-xxRs31BqRYHwiMzudOrpSiHtZ8i/GeionCBDSilhYRj+9gIcI8wCZTlXZKu9vZIVqViP3dcp9qE5G6AlIaD+TQ==", - "dev": true + "version": "3.0.20", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.20.tgz", + "integrity": "sha512-jg25NiDV/1fLtSgEgyvVyDunvaNHbuwF9lfNV17gSmPFAlYzdfNBlLtLzXTevwkPj7DhGbmN9VnmJIgLnhvaBw==", + "dev": true, + "license": "CC0-1.0" }, "node_modules/split2": { "version": "4.1.0", @@ -9694,82 +10226,17 @@ "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==" }, - "node_modules/standard": { - "version": "17.1.2", - "resolved": "https://registry.npmjs.org/standard/-/standard-17.1.2.tgz", - "integrity": "sha512-WLm12WoXveKkvnPnPnaFUUHuOB2cUdAsJ4AiGHL2G0UNMrcRAWY2WriQaV8IQ3oRmYr0AWUbLNr94ekYFAHOrA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "eslint": "^8.41.0", - "eslint-config-standard": "17.1.0", - "eslint-config-standard-jsx": "^11.0.0", - "eslint-plugin-import": "^2.27.5", - "eslint-plugin-n": "^15.7.0", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-react": "^7.36.1", - "standard-engine": "^15.1.0", - "version-guard": "^1.1.1" - }, - "bin": { - "standard": "bin/cmd.cjs" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/standard-as-callback": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" }, - "node_modules/standard-engine": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/standard-engine/-/standard-engine-15.1.0.tgz", - "integrity": "sha512-VHysfoyxFu/ukT+9v49d4BRXIokFRZuH3z1VRxzFArZdjSCFpro6rEIU3ji7e4AoAtuSfKBkiOmsrDqKW5ZSRw==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "dependencies": { - "get-stdin": "^8.0.0", - "minimist": "^1.2.6", - "pkg-conf": "^3.1.0", - "xdg-basedir": "^4.0.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "node_modules/string.prototype.matchall": { "version": "4.0.11", "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.11.tgz", "integrity": "sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -9796,6 +10263,7 @@ "resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-1.0.0.tgz", "integrity": "sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==", "dev": true, + "license": "MIT", "dependencies": { "define-properties": "^1.1.3", "es-abstract": "^1.17.5" @@ -9806,6 +10274,7 @@ "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.9.tgz", "integrity": "sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -9824,6 +10293,7 @@ "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.8.tgz", "integrity": "sha512-p73uL5VCHCO2BZZ6krwwQE3kCzM7NKmis8S//xEC6fQonchbum4eP6kR4DLEjQFO3Wnj3Fuo8NM0kOSjVdHjZQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -9838,6 +10308,7 @@ "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz", "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "define-properties": "^1.2.1", @@ -9855,6 +10326,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" }, @@ -9862,15 +10334,6 @@ "node": ">=8" } }, - "node_modules/strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -9915,10 +10378,11 @@ } }, "node_modules/synckit": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.1.tgz", - "integrity": "sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", + "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", "dev": true, + "license": "MIT", "dependencies": { "@pkgr/core": "^0.1.0", "tslib": "^2.6.2" @@ -9930,6 +10394,16 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/tar": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", @@ -10022,28 +10496,17 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, - "node_modules/tsconfig-paths": { - "version": "3.15.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", - "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", - "dev": true, - "dependencies": { - "@types/json5": "^0.0.29", - "json5": "^1.0.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - } - }, - "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", - "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", + "node_modules/ts-api-utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.0.tgz", + "integrity": "sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==", "dev": true, - "dependencies": { - "minimist": "^1.2.0" + "license": "MIT", + "engines": { + "node": ">=16" }, - "bin": { - "json5": "lib/cli.js" + "peerDependencies": { + "typescript": ">=4.2.0" } }, "node_modules/tslib": { @@ -10089,12 +10552,16 @@ } }, "node_modules/type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, + "license": "(MIT OR CC0-1.0)", "engines": { - "node": ">=6" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/typed-array-buffer": { @@ -10102,6 +10569,7 @@ "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.2.tgz", "integrity": "sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "es-errors": "^1.3.0", @@ -10116,6 +10584,7 @@ "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.1.tgz", "integrity": "sha512-3iMJ9q0ao7WE9tWcaYKIptkNBuOIcZCCT0d4MRvuuH88fEoEH62IuQe0OtraD3ebQEoTRk8XCBoknUNc1Y67pw==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "for-each": "^0.3.3", @@ -10135,6 +10604,7 @@ "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.2.tgz", "integrity": "sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==", "dev": true, + "license": "MIT", "dependencies": { "available-typed-arrays": "^1.0.7", "call-bind": "^1.0.7", @@ -10155,6 +10625,7 @@ "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.6.tgz", "integrity": "sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.7", "for-each": "^0.3.3", @@ -10170,6 +10641,45 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/typescript": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.14.0.tgz", + "integrity": "sha512-K8fBJHxVL3kxMmwByvz8hNdBJ8a0YqKzKDX6jRlrjMuNXyd5T2V02HIq37+OiWXvUUOXgOOGiSSOh26Mh8pC3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.14.0", + "@typescript-eslint/parser": "8.14.0", + "@typescript-eslint/utils": "8.14.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", @@ -10194,6 +10704,7 @@ "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "dev": true, + "license": "MIT", "dependencies": { "call-bind": "^1.0.2", "has-bigints": "^1.0.2", @@ -10269,15 +10780,6 @@ "extsprintf": "^1.2.0" } }, - "node_modules/version-guard": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/version-guard/-/version-guard-1.1.2.tgz", - "integrity": "sha512-D8d+YxCUpoqtCnQzDxm6SF7DLU3gr2535T4khAtMq4osBahsQnmSxuwXFdrbAdDGG8Uokzfis/jvyeFPdmlc7w==", - "dev": true, - "engines": { - "node": ">=0.10.48" - } - }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -10312,6 +10814,7 @@ "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", "dev": true, + "license": "MIT", "dependencies": { "is-bigint": "^1.0.1", "is-boolean-object": "^1.1.0", @@ -10324,13 +10827,14 @@ } }, "node_modules/which-builtin-type": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.1.3.tgz", - "integrity": "sha512-YmjsSMDBYsM1CaFiayOVT06+KJeXf0o5M/CAd4o1lTadFAtacTUM49zoYxr/oroopFDfhvN6iEcBxUyc3gvKmw==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.1.4.tgz", + "integrity": "sha512-bppkmBSsHFmIMSl8BO9TbsyzsvGjVoppt8xUiGzwiu/bhDCGxnpOKCxgqj6GuyHE0mINMDecBFPlOm2hzY084w==", "dev": true, + "license": "MIT", "dependencies": { - "function.prototype.name": "^1.1.5", - "has-tostringtag": "^1.0.0", + "function.prototype.name": "^1.1.6", + "has-tostringtag": "^1.0.2", "is-async-function": "^2.0.0", "is-date-object": "^1.0.5", "is-finalizationregistry": "^1.0.2", @@ -10339,8 +10843,8 @@ "is-weakref": "^1.0.2", "isarray": "^2.0.5", "which-boxed-primitive": "^1.0.2", - "which-collection": "^1.0.1", - "which-typed-array": "^1.1.9" + "which-collection": "^1.0.2", + "which-typed-array": "^1.1.15" }, "engines": { "node": ">= 0.4" @@ -10353,13 +10857,15 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/which-collection": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", "dev": true, + "license": "MIT", "dependencies": { "is-map": "^2.0.3", "is-set": "^2.0.3", @@ -10378,6 +10884,7 @@ "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.15.tgz", "integrity": "sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==", "dev": true, + "license": "MIT", "dependencies": { "available-typed-arrays": "^1.0.7", "call-bind": "^1.0.7", @@ -10410,15 +10917,6 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, - "node_modules/xdg-basedir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", - "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/xmlcreate": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", @@ -11891,9 +12389,9 @@ } }, "@babel/eslint-parser": { - "version": "7.24.1", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.24.1.tgz", - "integrity": "sha512-d5guuzMlPeDfZIbpQ8+g1NaCNuAGBBGNECh0HVqz1sjOeVLh2CEaifuOysCH18URW6R7pqXINvf5PaR/dC6jLQ==", + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.25.9.tgz", + "integrity": "sha512-5UXfgpK0j0Xr/xIdgdLEhOFxaDZ0bRPWJJchRpqOSur/3rZoPbqqki5mm0p4NE2cs28krBEiSM2MB7//afRSQQ==", "dev": true, "requires": { "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", @@ -12104,38 +12602,55 @@ } }, "@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", "dev": true, "requires": { - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.3" }, "dependencies": { "eslint-visitor-keys": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz", - "integrity": "sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true } } }, "@eslint-community/regexpp": { - "version": "4.10.0", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", - "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true + }, + "@eslint/config-array": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "dev": true, + "requires": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + } + }, + "@eslint/core": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.7.0.tgz", + "integrity": "sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==", "dev": true }, "@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", + "espree": "^10.0.1", + "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -12144,28 +12659,34 @@ }, "dependencies": { "globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "dev": true } } }, "@eslint/js": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", - "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", + "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", "dev": true }, + "@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "dev": true + }, + "@eslint/plugin-kit": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", + "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", + "dev": true, + "requires": { + "levn": "^0.4.1" + } + }, "@hapi/accept": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/@hapi/accept/-/accept-6.0.3.tgz", @@ -12438,6 +12959,190 @@ "source-map-support": "0.5.x", "supports-color": "^8.1.1", "will-call": "1.x.x" + }, + "dependencies": { + "@eslint/eslintrc": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "dev": true, + "requires": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^9.6.0", + "globals": "^13.19.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + } + }, + "@eslint/js": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz", + "integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true + }, + "eslint": { + "version": "8.57.1", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", + "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.1", + "@humanwhocodes/config-array": "^0.13.0", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "doctrine": "^3.0.0", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "strip-ansi": "^6.0.1", + "text-table": "^0.2.0" + } + }, + "eslint-scope": { + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + } + }, + "eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true + }, + "espree": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "dev": true, + "requires": { + "acorn": "^8.9.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^3.4.1" + } + }, + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + }, + "file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "requires": { + "flat-cache": "^3.0.4" + } + }, + "flat-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "dev": true, + "requires": { + "flatted": "^3.2.9", + "keyv": "^4.5.3", + "rimraf": "^3.0.2" + } + }, + "globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "requires": { + "type-fest": "^0.20.2" + } + } } }, "@hapi/mimos": { @@ -12620,6 +13325,30 @@ "@hapi/statehood": "^8.0.1" } }, + "@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true + }, + "@humanfs/node": { + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", + "dev": true, + "requires": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.3.0" + }, + "dependencies": { + "@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true + } + } + }, "@humanwhocodes/config-array": { "version": "0.13.0", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz", @@ -12631,6 +13360,12 @@ "minimatch": "^3.0.5" } }, + "@humanwhocodes/gitignore-to-minimatch": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz", + "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==", + "dev": true + }, "@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -12643,6 +13378,12 @@ "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, + "@humanwhocodes/retry": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.1.tgz", + "integrity": "sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==", + "dev": true + }, "@ioredis/commands": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", @@ -13814,29 +14555,35 @@ } } }, - "@stylistic/eslint-plugin-js": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.8.1.tgz", - "integrity": "sha512-c5c2C8Mos5tTQd+NWpqwEu7VT6SSRooAguFPMj1cp2RkTYl1ynKoXo8MWy3k4rkbzoeYHrqC2UlUzsroAN7wtQ==", + "@stylistic/eslint-plugin": { + "version": "2.10.1", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-2.10.1.tgz", + "integrity": "sha512-U+4yzNXElTf9q0kEfnloI9XbOyD4cnEQCxjUI94q0+W++0GAEQvJ/slwEj9lwjDHfGADRSr+Tco/z0XJvmDfCQ==", "dev": true, "requires": { - "@types/eslint": "^8.56.10", - "acorn": "^8.11.3", - "escape-string-regexp": "^4.0.0", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1" + "@typescript-eslint/utils": "^8.12.2", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "estraverse": "^5.3.0", + "picomatch": "^4.0.2" }, "dependencies": { - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", "dev": true }, - "eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + }, + "picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", "dev": true } } @@ -13854,20 +14601,10 @@ "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.2.tgz", "integrity": "sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w==" }, - "@types/eslint": { - "version": "8.56.10", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.10.tgz", - "integrity": "sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==", - "dev": true, - "requires": { - "@types/estree": "*", - "@types/json-schema": "*" - } - }, "@types/estree": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", "dev": true }, "@types/http-cache-semantics": { @@ -13881,12 +14618,6 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, - "@types/json5": { - "version": "0.0.29", - "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", - "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", - "dev": true - }, "@types/linkify-it": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", @@ -13924,6 +14655,136 @@ "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-4.0.2.tgz", "integrity": "sha512-Q5vtl1W5ue16D+nIaW8JWebSSraJVlK+EthKn7e7UcD4KWsaSJ8BqGPXNaPghgtcn/fhvrN17Tv8ksUsQpiplw==" }, + "@typescript-eslint/eslint-plugin": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.14.0.tgz", + "integrity": "sha512-tqp8H7UWFaZj0yNO6bycd5YjMwxa6wIHOLZvWPkidwbgLCsBMetQoGj7DPuAlWa2yGO3H48xmPwjhsSPPCGU5w==", + "dev": true, + "requires": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.14.0", + "@typescript-eslint/type-utils": "8.14.0", + "@typescript-eslint/utils": "8.14.0", + "@typescript-eslint/visitor-keys": "8.14.0", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" + } + }, + "@typescript-eslint/parser": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.14.0.tgz", + "integrity": "sha512-2p82Yn9juUJq0XynBXtFCyrBDb6/dJombnz6vbo6mgQEtWHfvHbQuEa9kAOVIt1c9YFwi7H6WxtPj1kg+80+RA==", + "dev": true, + "requires": { + "@typescript-eslint/scope-manager": "8.14.0", + "@typescript-eslint/types": "8.14.0", + "@typescript-eslint/typescript-estree": "8.14.0", + "@typescript-eslint/visitor-keys": "8.14.0", + "debug": "^4.3.4" + } + }, + "@typescript-eslint/scope-manager": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.14.0.tgz", + "integrity": "sha512-aBbBrnW9ARIDn92Zbo7rguLnqQ/pOrUguVpbUwzOhkFg2npFDwTgPGqFqE0H5feXcOoJOfX3SxlJaKEVtq54dw==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.14.0", + "@typescript-eslint/visitor-keys": "8.14.0" + } + }, + "@typescript-eslint/type-utils": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.14.0.tgz", + "integrity": "sha512-Xcz9qOtZuGusVOH5Uk07NGs39wrKkf3AxlkK79RBK6aJC1l03CobXjJbwBPSidetAOV+5rEVuiT1VSBUOAsanQ==", + "dev": true, + "requires": { + "@typescript-eslint/typescript-estree": "8.14.0", + "@typescript-eslint/utils": "8.14.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + } + }, + "@typescript-eslint/types": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.14.0.tgz", + "integrity": "sha512-yjeB9fnO/opvLJFAsPNYlKPnEM8+z4og09Pk504dkqonT02AyL5Z9SSqlE0XqezS93v6CXn49VHvB2G7XSsl0g==", + "dev": true + }, + "@typescript-eslint/typescript-estree": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.14.0.tgz", + "integrity": "sha512-OPXPLYKGZi9XS/49rdaCbR5j/S14HazviBlUQFvSKz3npr3NikF+mrgK7CFVur6XEt95DZp/cmke9d5i3vtVnQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.14.0", + "@typescript-eslint/visitor-keys": "8.14.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true + } + } + }, + "@typescript-eslint/utils": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.14.0.tgz", + "integrity": "sha512-OGqj6uB8THhrHj0Fk27DcHPojW7zKwKkPmHXHvQ58pLYp4hy8CSUdTKykKeh+5vFqTTVmjz0zCOOPKRovdsgHA==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.14.0", + "@typescript-eslint/types": "8.14.0", + "@typescript-eslint/typescript-estree": "8.14.0" + } + }, + "@typescript-eslint/visitor-keys": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.14.0.tgz", + "integrity": "sha512-vG0XZo8AdTH9OE6VFRwAZldNc7qtJ/6NLGWak+BtENuEUXGZgFpihILPiBvKXvJ2nFu27XNGC6rKiwuaoMbYzQ==", + "dev": true, + "requires": { + "@typescript-eslint/types": "8.14.0", + "eslint-visitor-keys": "^3.4.3" + }, + "dependencies": { + "eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true + } + } + }, "@ungap/structured-clone": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", @@ -13949,9 +14810,9 @@ "integrity": "sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==" }, "acorn": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", - "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", "dev": true }, "acorn-jsx": { @@ -14080,20 +14941,6 @@ "es-shim-unscopables": "^1.0.2" } }, - "array.prototype.findlastindex": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.5.tgz", - "integrity": "sha512-zfETvRFA8o7EiNn++N5f/kaCw221hrpGsDmcpndVupkPzEc1Wuf3VgC0qby1BbHs7f5DVYjgtEU2LLh5bqeGfQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.0.0", - "es-shim-unscopables": "^1.0.2" - } - }, "array.prototype.flat": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.2.tgz", @@ -14292,26 +15139,6 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, - "builtins": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.1.0.tgz", - "integrity": "sha512-SW9lzGTLvWTP1AY8xeAMZimqDrIaSdLQUcVr9DMef51niJ022Ri87SwRRKYm4A6iHfkPaiVUu/Duw2Wc4J7kKg==", - "dev": true, - "requires": { - "semver": "^7.0.0" - }, - "dependencies": { - "semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - } - } - }, "cacheable-lookup": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz", @@ -14686,21 +15513,22 @@ "once": "^1.4.0" } }, + "enhanced-resolve": { + "version": "5.17.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz", + "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + } + }, "entities": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", "dev": true }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, "error-stack-parser": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/error-stack-parser/-/error-stack-parser-2.1.4.tgz", @@ -14710,9 +15538,9 @@ } }, "es-abstract": { - "version": "1.23.3", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz", - "integrity": "sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==", + "version": "1.23.4", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.4.tgz", + "integrity": "sha512-HR1gxH5OaiN7XH7uiWH0RLw0RcFySiSoW1ctxmD1ahTw3uGBtkmm/ng0tDU1OtYx5OK6EOL5Y6O21cDflG3Jcg==", "dev": true, "requires": { "array-buffer-byte-length": "^1.0.1", @@ -14730,7 +15558,7 @@ "function.prototype.name": "^1.1.6", "get-intrinsic": "^1.2.4", "get-symbol-description": "^1.0.2", - "globalthis": "^1.0.3", + "globalthis": "^1.0.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2", "has-proto": "^1.0.3", @@ -14746,10 +15574,10 @@ "is-string": "^1.0.7", "is-typed-array": "^1.1.13", "is-weakref": "^1.0.2", - "object-inspect": "^1.13.1", + "object-inspect": "^1.13.3", "object-keys": "^1.1.1", "object.assign": "^4.1.5", - "regexp.prototype.flags": "^1.5.2", + "regexp.prototype.flags": "^1.5.3", "safe-array-concat": "^1.1.2", "safe-regex-test": "^1.0.3", "string.prototype.trim": "^1.2.9", @@ -14779,9 +15607,9 @@ "dev": true }, "es-iterator-helpers": { - "version": "1.0.19", - "resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.0.19.tgz", - "integrity": "sha512-zoMwbCcH5hwUkKJkT8kDIBZSz9I6mVG//+lDCinLCGov4+r7NIy0ld8o03M0cJxl2spVf6ESYVS6/gpIfq1FFw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-iterator-helpers/-/es-iterator-helpers-1.2.0.tgz", + "integrity": "sha512-tpxqxncxnpw3c93u8n3VOzACmRFoVmWJqbWXvX/JfKbkhBw1oslgPrUfeSt2psuqyEJFD6N/9lg5i7bsKpoq+Q==", "dev": true, "requires": { "call-bind": "^1.0.7", @@ -14791,12 +15619,13 @@ "es-set-tostringtag": "^2.0.3", "function-bind": "^1.1.2", "get-intrinsic": "^1.2.4", - "globalthis": "^1.0.3", + "globalthis": "^1.0.4", + "gopd": "^1.0.1", "has-property-descriptors": "^1.0.2", "has-proto": "^1.0.3", "has-symbols": "^1.0.3", "internal-slot": "^1.0.7", - "iterator.prototype": "^1.1.2", + "iterator.prototype": "^1.1.3", "safe-array-concat": "^1.1.2" } }, @@ -14858,48 +15687,45 @@ "dev": true }, "eslint": { - "version": "8.57.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz", - "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", + "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.1", - "@humanwhocodes/config-array": "^0.13.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.18.0", + "@eslint/core": "^0.7.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.14.0", + "@eslint/plugin-kit": "^0.2.0", + "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", - "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", + "@humanwhocodes/retry": "^0.4.0", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", - "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", - "esquery": "^1.4.2", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.5.0", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", + "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", - "globals": "^13.19.0", - "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", - "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", "optionator": "^0.9.3", - "strip-ansi": "^6.0.1", "text-table": "^0.2.0" }, "dependencies": { @@ -14944,9 +15770,9 @@ "dev": true }, "eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", + "integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==", "dev": true, "requires": { "esrecurse": "^4.3.0", @@ -14954,9 +15780,9 @@ } }, "eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", "dev": true }, "estraverse": { @@ -14965,144 +15791,52 @@ "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true }, - "globals": { - "version": "13.24.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", - "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "dev": true - } - } - }, - "eslint-config-standard": { - "version": "17.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz", - "integrity": "sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==", - "dev": true, - "requires": {} - }, - "eslint-config-standard-jsx": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/eslint-config-standard-jsx/-/eslint-config-standard-jsx-11.0.0.tgz", - "integrity": "sha512-+1EV/R0JxEK1L0NGolAr8Iktm3Rgotx3BKwgaX+eAuSX8D952LULKtjgZD3F+e6SvibONnhLwoTi9DPxN5LvvQ==", - "dev": true, - "requires": {} - }, - "eslint-import-resolver-node": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", - "integrity": "sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==", - "dev": true, - "requires": { - "debug": "^3.2.7", - "is-core-module": "^2.13.0", - "resolve": "^1.22.4" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "resolve": { - "version": "1.22.8", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", - "dev": true, - "requires": { - "is-core-module": "^2.13.0", - "path-parse": "^1.0.7", - "supports-preserve-symlinks-flag": "^1.0.0" - } - } - } - }, - "eslint-module-utils": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz", - "integrity": "sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==", - "dev": true, - "requires": { - "debug": "^3.2.7" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - } - } - }, - "eslint-plugin-import": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", - "integrity": "sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==", - "dev": true, - "requires": { - "array-includes": "^3.1.7", - "array.prototype.findlastindex": "^1.2.3", - "array.prototype.flat": "^1.3.2", - "array.prototype.flatmap": "^1.3.2", - "debug": "^3.2.7", - "doctrine": "^2.1.0", - "eslint-import-resolver-node": "^0.3.9", - "eslint-module-utils": "^2.8.0", - "hasown": "^2.0.0", - "is-core-module": "^2.13.1", - "is-glob": "^4.0.3", - "minimatch": "^3.1.2", - "object.fromentries": "^2.0.7", - "object.groupby": "^1.0.1", - "object.values": "^1.1.7", - "semver": "^6.3.1", - "tsconfig-paths": "^3.15.0" - }, - "dependencies": { - "debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "doctrine": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", - "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { - "esutils": "^2.0.2" + "has-flag": "^4.0.0" } } } }, + "eslint-compat-utils": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/eslint-compat-utils/-/eslint-compat-utils-0.5.1.tgz", + "integrity": "sha512-3z3vFexKIEnjHE3zCMRo6fn/e44U7T1khUjg+Hp0ZQMCigh28rALD0nPFBcGZuiLC5rLZa2ubQHDRln09JfU2Q==", + "dev": true, + "requires": { + "semver": "^7.5.4" + }, + "dependencies": { + "semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true + } + } + }, + "eslint-config-prettier": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", + "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", + "dev": true, + "requires": {} + }, + "eslint-plugin-es-x": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es-x/-/eslint-plugin-es-x-7.8.0.tgz", + "integrity": "sha512-7Ds8+wAAoV3T+LAKeu39Y5BzXCrGKrcISfgKEqTS4BDN8SFEDQd0S43jiQ8vIa3wUKD07qitZdfzlenSi8/0qQ==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.1.2", + "@eslint-community/regexpp": "^4.11.0", + "eslint-compat-utils": "^0.5.1" + } + }, "eslint-plugin-jsdoc": { "version": "50.5.0", "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-50.5.0.tgz", @@ -15123,12 +15857,12 @@ }, "dependencies": { "debug": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", - "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", "dev": true, "requires": { - "ms": "2.1.2" + "ms": "^2.1.3" } }, "escape-string-regexp": { @@ -15137,23 +15871,12 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, - "eslint-visitor-keys": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", - "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "espree": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-10.1.0.tgz", - "integrity": "sha512-M1M6CpiE6ffoigIOWYO9UDP8TMUw9kqb21tf+08IgDYjCsOvCuDt4jQcZmoYxx+w7zlKw9/N0KXfto+I8/FrXA==", - "dev": true, - "requires": { - "acorn": "^8.12.0", - "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^4.0.0" - } - }, "semver": { "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", @@ -15163,79 +15886,74 @@ } }, "eslint-plugin-n": { - "version": "15.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.7.0.tgz", - "integrity": "sha512-jDex9s7D/Qial8AGVIHq4W7NswpUD5DPDL2RH8Lzd9EloWUuvUkHfv4FRLMipH5q2UtyurorBkPeNi1wVWNh3Q==", + "version": "17.13.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-17.13.1.tgz", + "integrity": "sha512-97qzhk1z3DdSJNCqT45EslwCu5+LB9GDadSyBItgKUfGsXAmN/aa7LRQ0ZxHffUxUzvgbTPJL27/pE9ZQWHy7A==", "dev": true, "requires": { - "builtins": "^5.0.1", - "eslint-plugin-es": "^4.1.0", - "eslint-utils": "^3.0.0", - "ignore": "^5.1.1", - "is-core-module": "^2.11.0", - "minimatch": "^3.1.2", - "resolve": "^1.22.1", - "semver": "^7.3.8" + "@eslint-community/eslint-utils": "^4.4.1", + "enhanced-resolve": "^5.17.1", + "eslint-plugin-es-x": "^7.8.0", + "get-tsconfig": "^4.8.1", + "globals": "^15.11.0", + "ignore": "^5.3.2", + "minimatch": "^9.0.5", + "semver": "^7.6.3" }, "dependencies": { - "eslint-plugin-es": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz", - "integrity": "sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==", + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "requires": { - "eslint-utils": "^2.0.0", - "regexpp": "^3.0.0" - }, - "dependencies": { - "eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - } - }, - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - } + "balanced-match": "^1.0.0" } }, - "eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "globals": { + "version": "15.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz", + "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", + "dev": true + }, + "minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, "requires": { - "eslint-visitor-keys": "^2.0.0" + "brace-expansion": "^2.0.1" } }, "semver": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", - "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true } } }, + "eslint-plugin-prettier": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", + "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.9.1" + } + }, "eslint-plugin-promise": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz", - "integrity": "sha512-tjqWDwVZQo7UIPMeDReOpUgHCmCiH+ePnVT+5zVapL0uuHnegBUs2smM13CzOs2Xb5+MHMRFTs9v24yjba4Oig==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-7.1.0.tgz", + "integrity": "sha512-8trNmPxdAy3W620WKDpaS65NlM5yAumod6XeC4LOb+jxlkG4IVcp68c6dXY2ev+uT4U1PtG57YDV6EGAXN0GbQ==", "dev": true, "requires": {} }, "eslint-plugin-react": { - "version": "7.36.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.36.1.tgz", - "integrity": "sha512-/qwbqNXZoq+VP30s1d4Nc1C5GTxjJQjk4Jzs4Wq2qzxFM7dSmuG2UkIjg2USMLh3A/aVcUNrK7v0J5U1XEGGwA==", + "version": "7.37.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.2.tgz", + "integrity": "sha512-EsTAnj9fLVr/GZleBLFbj/sSuXeWmp1eXIN60ceYnZveqEaUCyW4X+Vh4WTdUhCkW4xutXYqTXCUSyqD4rB75w==", "dev": true, "requires": { "array-includes": "^3.1.8", @@ -15243,7 +15961,7 @@ "array.prototype.flatmap": "^1.3.2", "array.prototype.tosorted": "^1.1.4", "doctrine": "^2.1.0", - "es-iterator-helpers": "^1.0.19", + "es-iterator-helpers": "^1.1.0", "estraverse": "^5.3.0", "hasown": "^2.0.2", "jsx-ast-utils": "^2.4.1 || ^3.0.0", @@ -15308,20 +16026,20 @@ "integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==" }, "espree": { - "version": "9.6.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", - "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", "dev": true, "requires": { - "acorn": "^8.9.0", + "acorn": "^8.14.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.4.1" + "eslint-visitor-keys": "^4.2.0" }, "dependencies": { "eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", "dev": true } } @@ -15403,10 +16121,16 @@ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" }, + "fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, "fast-glob": { - "version": "3.2.12", - "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", - "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", @@ -15472,12 +16196,12 @@ } }, "file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", "dev": true, "requires": { - "flat-cache": "^3.0.4" + "flat-cache": "^4.0.0" } }, "fill-keys": { @@ -15516,14 +16240,13 @@ } }, "flat-cache": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", - "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", "dev": true, "requires": { "flatted": "^3.2.9", - "keyv": "^4.5.3", - "rimraf": "^3.0.2" + "keyv": "^4.5.4" } }, "flatted": { @@ -15644,12 +16367,6 @@ "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==" }, - "get-stdin": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-8.0.0.tgz", - "integrity": "sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg==", - "dev": true - }, "get-stream": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", @@ -15666,6 +16383,15 @@ "get-intrinsic": "^1.2.4" } }, + "get-tsconfig": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.8.1.tgz", + "integrity": "sha512-k9PN+cFBmaLWtVz29SkUoqU5O0slLuHJXt/2P+tMVFT+phsSGXGkp9t3rQIqdz0e+06EHNGs3oM6ZX1s2zHxRg==", + "dev": true, + "requires": { + "resolve-pkg-maps": "^1.0.0" + } + }, "getopts": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/getopts/-/getopts-2.3.0.tgz", @@ -15920,9 +16646,9 @@ "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" }, "ignore": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.0.tgz", - "integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==", + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", "dev": true }, "immutable": { @@ -16004,12 +16730,6 @@ "get-intrinsic": "^1.2.1" } }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", - "dev": true - }, "is-async-function": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.0.0.tgz", @@ -16055,11 +16775,11 @@ "dev": true }, "is-core-module": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz", - "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", "requires": { - "hasown": "^2.0.0" + "hasown": "^2.0.2" } }, "is-data-view": { @@ -16252,9 +16972,9 @@ "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" }, "iterator.prototype": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.2.tgz", - "integrity": "sha512-DR33HMMr8EzwuRL8Y9D3u2BMj8+RqSE850jfGu59kS7tbmPLzGkZmVSfyCFSDxuZiEY6Rzt3T2NA/qU+NwVj1w==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.3.tgz", + "integrity": "sha512-FW5iMbeQ6rBGm/oKgzq2aW4KvAGpxPzYES8N4g4xNXUKpL1mclMvOe+76AcLDTvD+Ze+sOpVhgdAQEKF4L9iGQ==", "dev": true, "requires": { "define-properties": "^1.2.1", @@ -16366,12 +17086,6 @@ "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==" }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true - }, "json-schema": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", @@ -16492,19 +17206,6 @@ "uc.micro": "^2.0.0" } }, - "load-json-file": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-5.3.0.tgz", - "integrity": "sha512-cJGP40Jc/VXUsp8/OrnyKyTZ1y6v/dphm3bioS+RrKXjK2BB6wHUd6JptZEFDGgGahMT+InnZO5i1Ei9mpC8Bw==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.15", - "parse-json": "^4.0.0", - "pify": "^4.0.1", - "strip-bom": "^3.0.0", - "type-fest": "^0.3.0" - } - }, "locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -16555,15 +17256,6 @@ "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz", "integrity": "sha512-ozCC6gdQ+glXOQsveKD0YsDy8DSQFjDTz4zyzEHNV5+JP5D62LmfDZ6o1cycFx9ouG940M5dE8C8CTewdj2YWQ==" }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, "markdown-it": { "version": "14.1.0", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-14.1.0.tgz", @@ -16724,6 +17416,31 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "neostandard": { + "version": "0.11.8", + "resolved": "https://registry.npmjs.org/neostandard/-/neostandard-0.11.8.tgz", + "integrity": "sha512-gKgvK0EDlA0x7F1hMu/UdPCRtSSG4d9CBxVym4PMWoHz8+a1ffEz2fPU5FMH3RUqzL1ACvroUMiywMGWZSY+Mw==", + "dev": true, + "requires": { + "@humanwhocodes/gitignore-to-minimatch": "^1.0.2", + "@stylistic/eslint-plugin": "^2.10.1", + "eslint-plugin-n": "^17.13.1", + "eslint-plugin-promise": "^7.1.0", + "eslint-plugin-react": "^7.36.1", + "find-up": "^5.0.0", + "globals": "^15.12.0", + "peowly": "^1.3.2", + "typescript-eslint": "^8.13.0" + }, + "dependencies": { + "globals": { + "version": "15.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz", + "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", + "dev": true + } + } + }, "nise": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/nise/-/nise-5.1.4.tgz", @@ -16803,9 +17520,9 @@ "dev": true }, "object-inspect": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", - "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", + "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", "dev": true }, "object-keys": { @@ -16849,17 +17566,6 @@ "es-object-atoms": "^1.0.0" } }, - "object.groupby": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/object.groupby/-/object.groupby-1.0.3.tgz", - "integrity": "sha512-+Lhy3TQTuzXI5hevh8sBGqbmurHbbIjAi0Z4S63nthVLmLxfbj4T54a4CfZrXIrt9iP4mVAPYMo/v99taj3wjQ==", - "dev": true, - "requires": { - "call-bind": "^1.0.7", - "define-properties": "^1.2.1", - "es-abstract": "^1.23.2" - } - }, "object.values": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.2.0.tgz", @@ -16966,25 +17672,15 @@ } }, "parse-imports": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/parse-imports/-/parse-imports-2.1.1.tgz", - "integrity": "sha512-TDT4HqzUiTMO1wJRwg/t/hYk8Wdp3iF/ToMIlAoVQfL1Xs/sTxq1dKWSMjMbQmIarfWKymOyly40+zmPHXMqCA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/parse-imports/-/parse-imports-2.2.1.tgz", + "integrity": "sha512-OL/zLggRp8mFhKL0rNORUTR4yBYujK/uU+xZL+/0Rgm2QE4nLO9v8PzEweSJEbMGKmDRjJE4R3IMJlL2di4JeQ==", "dev": true, "requires": { "es-module-lexer": "^1.5.3", "slashes": "^3.0.12" } }, - "parse-json": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", - "integrity": "sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==", - "dev": true, - "requires": { - "error-ex": "^1.3.1", - "json-parse-better-errors": "^1.0.1" - } - }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -17023,6 +17719,12 @@ "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true }, + "peowly": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/peowly/-/peowly-1.3.2.tgz", + "integrity": "sha512-BYIrwr8JCXY49jUZscgw311w9oGEKo7ux/s+BxrhKTQbiQ0iYNdZNJ5LgagaeercQdFHwnR7Z5IxxFWVQ+BasQ==", + "dev": true + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -17121,12 +17823,6 @@ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "devOptional": true }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true - }, "pino": { "version": "8.6.1", "resolved": "https://registry.npmjs.org/pino/-/pino-8.6.1.tgz", @@ -17181,61 +17877,6 @@ "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-6.0.0.tgz", "integrity": "sha512-mMMOwSKrmyl+Y12Ri2xhH1lbzQxwwpuru9VjyJpgFIH4asSj88F2csdMwN6+M5g1Ll4rmsYghHLQJw81tgZ7LQ==" }, - "pkg-conf": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/pkg-conf/-/pkg-conf-3.1.0.tgz", - "integrity": "sha512-m0OTbR/5VPNPqO1ph6Fqbj7Hv6QU7gR/tQW40ZqrL1rjgCU85W6C1bJn0BItuJqnR98PWzw7Z8hHeChD1WrgdQ==", - "dev": true, - "requires": { - "find-up": "^3.0.0", - "load-json-file": "^5.2.0" - }, - "dependencies": { - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", - "dev": true - } - } - }, "pkg-up": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz", @@ -17325,6 +17966,21 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -17479,23 +18135,17 @@ } }, "regexp.prototype.flags": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz", - "integrity": "sha512-NcDiDkTLuPR+++OCKB0nWafEmhg/Da8aUPLPMQbK+bxKKCm1/S5he+AqYa4PlMCVBalb4/yxIRub6qkEx5yJbw==", + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.3.tgz", + "integrity": "sha512-vqlC04+RQoFalODCbCumG2xIOvapzVMHwsyIGM/SIE8fRhFFsXeH8/QQ+s0T0kDAhKc4k30s73/0ydkHQz6HlQ==", "dev": true, "requires": { - "call-bind": "^1.0.6", + "call-bind": "^1.0.7", "define-properties": "^1.2.1", "es-errors": "^1.3.0", - "set-function-name": "^2.0.1" + "set-function-name": "^2.0.2" } }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true - }, "request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -17555,11 +18205,11 @@ } }, "resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "requires": { - "is-core-module": "^2.9.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" } @@ -17575,6 +18225,12 @@ "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, + "resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true + }, "responselike": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/responselike/-/responselike-3.0.0.tgz", @@ -17854,9 +18510,9 @@ } }, "spdx-license-ids": { - "version": "3.0.18", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.18.tgz", - "integrity": "sha512-xxRs31BqRYHwiMzudOrpSiHtZ8i/GeionCBDSilhYRj+9gIcI8wCZTlXZKu9vZIVqViP3dcp9qE5G6AlIaD+TQ==", + "version": "3.0.20", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.20.tgz", + "integrity": "sha512-jg25NiDV/1fLtSgEgyvVyDunvaNHbuwF9lfNV17gSmPFAlYzdfNBlLtLzXTevwkPj7DhGbmN9VnmJIgLnhvaBw==", "dev": true }, "split2": { @@ -17885,40 +18541,11 @@ "resolved": "https://registry.npmjs.org/stackframe/-/stackframe-1.3.4.tgz", "integrity": "sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==" }, - "standard": { - "version": "17.1.2", - "resolved": "https://registry.npmjs.org/standard/-/standard-17.1.2.tgz", - "integrity": "sha512-WLm12WoXveKkvnPnPnaFUUHuOB2cUdAsJ4AiGHL2G0UNMrcRAWY2WriQaV8IQ3oRmYr0AWUbLNr94ekYFAHOrA==", - "dev": true, - "requires": { - "eslint": "^8.41.0", - "eslint-config-standard": "17.1.0", - "eslint-config-standard-jsx": "^11.0.0", - "eslint-plugin-import": "^2.27.5", - "eslint-plugin-n": "^15.7.0", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-react": "^7.36.1", - "standard-engine": "^15.1.0", - "version-guard": "^1.1.1" - } - }, "standard-as-callback": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" }, - "standard-engine": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/standard-engine/-/standard-engine-15.1.0.tgz", - "integrity": "sha512-VHysfoyxFu/ukT+9v49d4BRXIokFRZuH3z1VRxzFArZdjSCFpro6rEIU3ji7e4AoAtuSfKBkiOmsrDqKW5ZSRw==", - "dev": true, - "requires": { - "get-stdin": "^8.0.0", - "minimist": "^1.2.6", - "pkg-conf": "^3.1.0", - "xdg-basedir": "^4.0.0" - } - }, "string.prototype.matchall": { "version": "4.0.11", "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.11.tgz", @@ -17992,12 +18619,6 @@ "ansi-regex": "^5.0.1" } }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", - "dev": true - }, "strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", @@ -18024,15 +18645,21 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" }, "synckit": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.1.tgz", - "integrity": "sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A==", + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", + "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", "dev": true, "requires": { "@pkgr/core": "^0.1.0", "tslib": "^2.6.2" } }, + "tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true + }, "tar": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", @@ -18107,28 +18734,12 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, - "tsconfig-paths": { - "version": "3.15.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", - "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", + "ts-api-utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.0.tgz", + "integrity": "sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==", "dev": true, - "requires": { - "@types/json5": "^0.0.29", - "json5": "^1.0.2", - "minimist": "^1.2.6", - "strip-bom": "^3.0.0" - }, - "dependencies": { - "json5": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", - "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", - "dev": true, - "requires": { - "minimist": "^1.2.0" - } - } - } + "requires": {} }, "tslib": { "version": "2.6.2", @@ -18164,9 +18775,9 @@ "dev": true }, "type-fest": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.3.1.tgz", - "integrity": "sha512-cUGJnCdr4STbePCgqNFbpVNCepa+kAVohJs1sLhxzdH+gnEoOd8VhbYa7pD3zZYGiURWM2xzEII3fQcRizDkYQ==", + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true }, "typed-array-buffer": { @@ -18221,6 +18832,24 @@ "possible-typed-array-names": "^1.0.0" } }, + "typescript": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, + "peer": true + }, + "typescript-eslint": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.14.0.tgz", + "integrity": "sha512-K8fBJHxVL3kxMmwByvz8hNdBJ8a0YqKzKDX6jRlrjMuNXyd5T2V02HIq37+OiWXvUUOXgOOGiSSOh26Mh8pC3w==", + "dev": true, + "requires": { + "@typescript-eslint/eslint-plugin": "8.14.0", + "@typescript-eslint/parser": "8.14.0", + "@typescript-eslint/utils": "8.14.0" + } + }, "uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", @@ -18285,12 +18914,6 @@ "extsprintf": "^1.2.0" } }, - "version-guard": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/version-guard/-/version-guard-1.1.2.tgz", - "integrity": "sha512-D8d+YxCUpoqtCnQzDxm6SF7DLU3gr2535T4khAtMq4osBahsQnmSxuwXFdrbAdDGG8Uokzfis/jvyeFPdmlc7w==", - "dev": true - }, "webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -18328,13 +18951,13 @@ } }, "which-builtin-type": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.1.3.tgz", - "integrity": "sha512-YmjsSMDBYsM1CaFiayOVT06+KJeXf0o5M/CAd4o1lTadFAtacTUM49zoYxr/oroopFDfhvN6iEcBxUyc3gvKmw==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.1.4.tgz", + "integrity": "sha512-bppkmBSsHFmIMSl8BO9TbsyzsvGjVoppt8xUiGzwiu/bhDCGxnpOKCxgqj6GuyHE0mINMDecBFPlOm2hzY084w==", "dev": true, "requires": { - "function.prototype.name": "^1.1.5", - "has-tostringtag": "^1.0.0", + "function.prototype.name": "^1.1.6", + "has-tostringtag": "^1.0.2", "is-async-function": "^2.0.0", "is-date-object": "^1.0.5", "is-finalizationregistry": "^1.0.2", @@ -18343,8 +18966,8 @@ "is-weakref": "^1.0.2", "isarray": "^2.0.5", "which-boxed-primitive": "^1.0.2", - "which-collection": "^1.0.1", - "which-typed-array": "^1.1.9" + "which-collection": "^1.0.2", + "which-typed-array": "^1.1.15" }, "dependencies": { "isarray": { @@ -18398,12 +19021,6 @@ "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, - "xdg-basedir": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", - "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", - "dev": true - }, "xmlcreate": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.4.tgz", diff --git a/package.json b/package.json index c2e9a13b9a..a0e3ea2694 100644 --- a/package.json +++ b/package.json @@ -66,15 +66,17 @@ "@hapi/code": "^9.0.3", "@hapi/hoek": "^11.0.2", "@hapi/lab": "^25.1.3", - "@stylistic/eslint-plugin-js": "^1.8.1", - "eslint": "^8.57.0", - "eslint-plugin-jsdoc": "^50.2.2", + "eslint": "^9.14.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-jsdoc": "^50.5.0", + "eslint-plugin-prettier": "^5.2.1", "jsdoc": "~4.0.3", "mock-fs": "^5.2.0", + "neostandard": "^0.11.8", "nock": "^13.3.2", "pino-pretty": "^10.2.0", + "prettier": "3.3.3", "proxyquire": "^2.1.3", - "sinon": "^15.2.0", - "standard": "^17.1.0" + "sinon": "^15.2.0" } } diff --git a/test/controllers/bill-licences.controller.test.js b/test/controllers/bill-licences.controller.test.js index 25f6249fd2..b74c0de0a7 100644 --- a/test/controllers/bill-licences.controller.test.js +++ b/test/controllers/bill-licences.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -143,7 +143,7 @@ describe('Bill Licences controller', () => { }) }) -function _options (path) { +function _options(path) { const root = '/bill-licences/64924759-8142-4a08-9d1e-1e902cd9d316' const url = path ? `${root}/${path}` : root @@ -157,7 +157,7 @@ function _options (path) { } } -function _presrocPageData () { +function _presrocPageData() { return { accountNumber: 'W99999999A', billId: '5a5b313b-e707-490a-a693-799339941e4f', @@ -201,7 +201,7 @@ function _presrocPageData () { } } -function _srocPageData () { +function _srocPageData() { return { accountNumber: 'B99990099A', billId: '13822096-1118-404c-81a4-fdbe5fb73d8f', @@ -218,12 +218,15 @@ function _srocPageData () { additionalCharges: '', adjustments: 'Two-part tariff (0.5)', billableDays: '214/214', - chargeCategoryDescription: 'High loss, non-tidal, restricted water, greater than 120 up to and including 220 ML/yr, Tier 1 model', - chargeElements: [{ - purpose: 'Trickle Irrigation - Direct', - abstractionPeriod: '1 April to 31 October', - volume: '150ML' - }], + chargeCategoryDescription: + 'High loss, non-tidal, restricted water, greater than 120 up to and including 220 ML/yr, Tier 1 model', + chargeElements: [ + { + purpose: 'Trickle Irrigation - Direct', + abstractionPeriod: '1 April to 31 October', + volume: '150ML' + } + ], chargePeriod: '1 April 2023 to 31 March 2024', chargeReference: '4.6.29 (£35.74)', chargeType: 'standard', diff --git a/test/controllers/bill-runs-review.controller.test.js b/test/controllers/bill-runs-review.controller.test.js index 99789c2898..0af123f323 100644 --- a/test/controllers/bill-runs-review.controller.test.js +++ b/test/controllers/bill-runs-review.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -139,9 +139,7 @@ describe('Bill Runs Review controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal( - '/system/bill-runs/review/97db1a27-8308-4aba-b463-8a6af2558b28' - ) + expect(response.headers.location).to.equal('/system/bill-runs/review/97db1a27-8308-4aba-b463-8a6af2558b28') }) }) }) @@ -319,7 +317,9 @@ describe('Bill Runs Review controller', () => { expect(response.statusCode).to.equal(200) expect(response.payload).to.contain('Charge reference 4.6.5') - expect(response.payload).to.contain('High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model') + expect(response.payload).to.contain( + 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model' + ) expect(response.payload).to.contain('Reference details') }) }) @@ -354,7 +354,9 @@ describe('Bill Runs Review controller', () => { expect(response.statusCode).to.equal(200) expect(response.payload).to.contain('Set the authorised volume') - expect(response.payload).to.contain('High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model') + expect(response.payload).to.contain( + 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model' + ) expect(response.payload).to.contain('Total billable returns') }) }) @@ -435,7 +437,9 @@ describe('Bill Runs Review controller', () => { expect(response.statusCode).to.equal(200) expect(response.payload).to.contain('Set the adjustment factors') - expect(response.payload).to.contain('High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model') + expect(response.payload).to.contain( + 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model' + ) }) }) }) @@ -526,60 +530,65 @@ describe('Bill Runs Review controller', () => { Sinon.stub(ReviewLicenceService, 'go').resolves({ billRunId: '97db1a27-8308-4aba-b463-8a6af2558b28', - chargeVersions: [{ - billingAccountDetails: [{ - billingAccountId: 'ee3f5562-26ad-4d58-9b59-5c388a13d7d0', - accountNumber: 'E99999999A', - accountName: 'Mr B Blobby', - contactName: null, - addressLines: [ - 'C/O Noel Edmonds', - 'Crinkley Bottom', - 'Cricket St Thomas', - 'Somerset', - 'TA20 1KL' - ] - }], - chargePeriod: '1 April 2023 to 31 March 2024', - chargeReferences: [{ - billableReturnsWarning: false, - chargeCategory: 'Charge reference 4.6.5', - chargeDescription: 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model', - id: '7c09753d-f606-4deb-a929-4bc8aa7acb8d', - chargeElements: [{ - billableReturns: '0 ML / 9.092 ML', - chargePeriods: ['1 April 2023 to 30 September 2023'], - returnVolumes: ['0 ML (11142960)'], - description: 'Spray Irrigation - Direct', - elementCount: 1, - elementIndex: 1, - status: 'review', - id: 'a1840523-a04c-4c64-bff7-4a515e8ba1c1', - issues: ['Aggregate'], - purpose: 'Spray Irrigation - Direct' - }], - chargeReferenceLinkTitle: 'Change details', - totalBillableReturns: '0 ML / 9.092 ML' - }], - description: '1 charge reference with 1 two-part tariff charge element', - financialPeriod: '2023 to 2024' - }], + chargeVersions: [ + { + billingAccountDetails: [ + { + billingAccountId: 'ee3f5562-26ad-4d58-9b59-5c388a13d7d0', + accountNumber: 'E99999999A', + accountName: 'Mr B Blobby', + contactName: null, + addressLines: ['C/O Noel Edmonds', 'Crinkley Bottom', 'Cricket St Thomas', 'Somerset', 'TA20 1KL'] + } + ], + chargePeriod: '1 April 2023 to 31 March 2024', + chargeReferences: [ + { + billableReturnsWarning: false, + chargeCategory: 'Charge reference 4.6.5', + chargeDescription: + 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model', + id: '7c09753d-f606-4deb-a929-4bc8aa7acb8d', + chargeElements: [ + { + billableReturns: '0 ML / 9.092 ML', + chargePeriods: ['1 April 2023 to 30 September 2023'], + returnVolumes: ['0 ML (11142960)'], + description: 'Spray Irrigation - Direct', + elementCount: 1, + elementIndex: 1, + status: 'review', + id: 'a1840523-a04c-4c64-bff7-4a515e8ba1c1', + issues: ['Aggregate'], + purpose: 'Spray Irrigation - Direct' + } + ], + chargeReferenceLinkTitle: 'Change details', + totalBillableReturns: '0 ML / 9.092 ML' + } + ], + description: '1 charge reference with 1 two-part tariff charge element', + financialPeriod: '2023 to 2024' + } + ], elementsInReview: true, licenceHolder: 'Licence Holder Ltd', licenceId: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', licenceRef: '1/11/10/*S/0084', - matchedReturns: [{ - abstractionPeriod: '1 April to 30 September', - description: 'Test Road. Points 1 and 2.', - issues: ['Returns received late'], - purpose: 'Spray Irrigation - Direct', - reference: '11142960', - returnId: 'v1:5:1/11/10/*S/0084:11142960:2022-11-01:2023-10-31', - returnLink: '/returns/return?id=v1:5:1/11/10/*S/0084:11142960:2022-11-01:2023-10-31', - returnPeriod: '1 November 2022 to 31 October 2023', - returnStatus: 'completed', - returnTotal: '0 ML / 0 ML' - }], + matchedReturns: [ + { + abstractionPeriod: '1 April to 30 September', + description: 'Test Road. Points 1 and 2.', + issues: ['Returns received late'], + purpose: 'Spray Irrigation - Direct', + reference: '11142960', + returnId: 'v1:5:1/11/10/*S/0084:11142960:2022-11-01:2023-10-31', + returnLink: '/returns/return?id=v1:5:1/11/10/*S/0084:11142960:2022-11-01:2023-10-31', + returnPeriod: '1 November 2022 to 31 October 2023', + returnStatus: 'completed', + returnTotal: '0 ML / 0 ML' + } + ], pageTitle: 'Licence 13/43/028/S/045', progress: false, region: 'Southern (Test replica)', @@ -611,7 +620,9 @@ describe('Bill Runs Review controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/bill-runs/review/licence/deaffa60-6488-4e54-a402-485d43aca1af') + expect(response.headers.location).to.equal( + '/system/bill-runs/review/licence/deaffa60-6488-4e54-a402-485d43aca1af' + ) }) }) }) @@ -696,7 +707,7 @@ describe('Bill Runs Review controller', () => { }) }) -function _getRequestOptions (path, query = null) { +function _getRequestOptions(path, query = null) { const root = '/bill-runs/review' const rootPath = path ? `${root}/${path}` : root const url = query ? `${rootPath}?${query}` : rootPath @@ -711,7 +722,7 @@ function _getRequestOptions (path, query = null) { } } -function _postRequestOptions (path) { +function _postRequestOptions(path) { const root = '/bill-runs/review' const rootPath = path ? `${root}/${path}` : root diff --git a/test/controllers/bill-runs-setup.controller.test.js b/test/controllers/bill-runs-setup.controller.test.js index d7217a99ba..a6cd97d20c 100644 --- a/test/controllers/bill-runs-setup.controller.test.js +++ b/test/controllers/bill-runs-setup.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -159,7 +159,9 @@ describe('Bill Runs Setup controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(200) - expect(response.payload).to.contain('There are no licences marked for two-part tariff supplementary billing in the Test region') + expect(response.payload).to.contain( + 'There are no licences marked for two-part tariff supplementary billing in the Test region' + ) }) }) }) @@ -205,7 +207,9 @@ describe('Bill Runs Setup controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/create') + expect(response.headers.location).to.equal( + '/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/create' + ) }) }) @@ -218,7 +222,9 @@ describe('Bill Runs Setup controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/year') + expect(response.headers.location).to.equal( + '/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/year' + ) }) }) }) @@ -279,7 +285,9 @@ describe('Bill Runs Setup controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/create') + expect(response.headers.location).to.equal( + '/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/create' + ) }) }) @@ -338,7 +346,9 @@ describe('Bill Runs Setup controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/region') + expect(response.headers.location).to.equal( + '/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/region' + ) }) }) @@ -406,7 +416,9 @@ describe('Bill Runs Setup controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/no-licences') + expect(response.headers.location).to.equal( + '/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/no-licences' + ) }) }) }) @@ -426,7 +438,9 @@ describe('Bill Runs Setup controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/create') + expect(response.headers.location).to.equal( + '/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/create' + ) }) }) @@ -439,7 +453,9 @@ describe('Bill Runs Setup controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/season') + expect(response.headers.location).to.equal( + '/system/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/season' + ) }) }) @@ -480,7 +496,7 @@ describe('Bill Runs Setup controller', () => { }) }) -function _getOptions (path) { +function _getOptions(path) { return { method: 'GET', url: `/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/${path}`, @@ -491,6 +507,6 @@ function _getOptions (path) { } } -function _postOptions (path, payload) { +function _postOptions(path, payload) { return postRequestOptions(`/bill-runs/setup/e009b394-8405-4358-86af-1a9eb31298a5/${path}`, payload) } diff --git a/test/controllers/bill-runs.controller.test.js b/test/controllers/bill-runs.controller.test.js index 06c23b6409..2db3149ecd 100644 --- a/test/controllers/bill-runs.controller.test.js +++ b/test/controllers/bill-runs.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -62,18 +62,20 @@ describe('Bill Runs controller', () => { describe('when the request succeeds', () => { beforeEach(async () => { Sinon.stub(IndexBillRunsService, 'go').resolves({ - billRuns: [{ - id: '31fec553-f2de-40cf-a8d7-a5fb65f5761b', - createdAt: '1 January 2024', - link: '/system/bill-runs/31fec553-f2de-40cf-a8d7-a5fb65f5761b', - number: 1002, - numberOfBills: 7, - region: 'Avalon', - scheme: 'sroc', - status: 'ready', - total: '£200.00', - type: 'Supplementary' - }], + billRuns: [ + { + id: '31fec553-f2de-40cf-a8d7-a5fb65f5761b', + createdAt: '1 January 2024', + link: '/system/bill-runs/31fec553-f2de-40cf-a8d7-a5fb65f5761b', + number: 1002, + numberOfBills: 7, + region: 'Avalon', + scheme: 'sroc', + status: 'ready', + total: '£200.00', + type: 'Supplementary' + } + ], busy: 'none', pageTitle: 'Bill runs (page 2 of 30)', pagination: { @@ -304,7 +306,7 @@ describe('Bill Runs controller', () => { }) }) -function _getRequestOptions (path) { +function _getRequestOptions(path) { const root = '/bill-runs/97db1a27-8308-4aba-b463-8a6af2558b28' const url = path ? `${root}/${path}` : root @@ -318,14 +320,14 @@ function _getRequestOptions (path) { } } -function _postRequestOptions (path) { +function _postRequestOptions(path) { const root = '/bill-runs/97db1a27-8308-4aba-b463-8a6af2558b28' const url = path ? `${root}/${path}` : root return postRequestOptions(url) } -function _multiGroupBillRun () { +function _multiGroupBillRun() { return { billsCount: '2 Annual bills', billRunId: '2c80bd22-a005-4cf4-a2a2-73812a9861de', @@ -349,35 +351,39 @@ function _multiGroupBillRun () { { type: 'water-companies', caption: '1 water company', - bills: [{ - id: '64924759-8142-4a08-9d1e-1e902cd9d316', - accountNumber: 'E22288888A', - billingContact: 'Acme Water Services Ltd', - licences: ['17/53/001/A/101', '17/53/002/B/205', '17/53/002/C/308'], - licencesCount: 3, - financialYear: 2023, - total: '£213,178.00' - }] + bills: [ + { + id: '64924759-8142-4a08-9d1e-1e902cd9d316', + accountNumber: 'E22288888A', + billingContact: 'Acme Water Services Ltd', + licences: ['17/53/001/A/101', '17/53/002/B/205', '17/53/002/C/308'], + licencesCount: 3, + financialYear: 2023, + total: '£213,178.00' + } + ] }, { type: 'other-abstractors', caption: '1 other abstractor', - bills: [{ - id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', - accountNumber: 'E11101999A', - billingContact: 'Geordie Leforge', - licences: ['17/53/001/G/782'], - licencesCount: 1, - financialYear: 2023, - total: '£97.00' - }] + bills: [ + { + id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', + accountNumber: 'E11101999A', + billingContact: 'Geordie Leforge', + licences: ['17/53/001/G/782'], + licencesCount: 1, + financialYear: 2023, + total: '£97.00' + } + ] } ], view: 'bill-runs/view.njk' } } -function _singleGroupBillRun () { +function _singleGroupBillRun() { return { billsCount: '1 Annual bill', billRunId: '2c80bd22-a005-4cf4-a2a2-73812a9861de', @@ -401,15 +407,17 @@ function _singleGroupBillRun () { { type: 'other-abstractors', caption: '1 other abstractor', - bills: [{ - id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', - accountNumber: 'E11101999A', - billingContact: 'Geordie Leforge', - licences: ['17/53/001/G/782'], - licencesCount: 1, - financialYear: 2023, - total: '£97.00' - }] + bills: [ + { + id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', + accountNumber: 'E11101999A', + billingContact: 'Geordie Leforge', + licences: ['17/53/001/G/782'], + licencesCount: 1, + financialYear: 2023, + total: '£97.00' + } + ] } ], view: 'bill-runs/view.njk' diff --git a/test/controllers/billing-accounts.controller.test.js b/test/controllers/billing-accounts.controller.test.js index d9764caede..c7c32085e7 100644 --- a/test/controllers/billing-accounts.controller.test.js +++ b/test/controllers/billing-accounts.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/controllers/bills.controller.test.js b/test/controllers/bills.controller.test.js index 0173810694..577872f21b 100644 --- a/test/controllers/bills.controller.test.js +++ b/test/controllers/bills.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -146,9 +146,7 @@ describe('Bills controller', () => { const response = await server.inject(options) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal( - '/billing/batch/c04ea618-d1ad-494b-bdc4-1bfa670876d0/processing' - ) + expect(response.headers.location).to.equal('/billing/batch/c04ea618-d1ad-494b-bdc4-1bfa670876d0/processing') }) }) @@ -171,17 +169,11 @@ describe('Bills controller', () => { }) }) -function _testMultiLicenceBill () { +function _testMultiLicenceBill() { return { accountName: 'Mr B Blobby', accountNumber: 'E99999999A', - addressLines: [ - 'C/O Noel Edmonds', - 'Crinkley Bottom', - 'Cricket St Thomas', - 'Somerset', - 'TA20 1KL' - ], + addressLines: ['C/O Noel Edmonds', 'Crinkley Bottom', 'Cricket St Thomas', 'Somerset', 'TA20 1KL'], billId: '64924759-8142-4a08-9d1e-1e902cd9d316', billingAccountId: 'ee3f5562-26ad-4d58-9b59-5c388a13d7d0', billNumber: 'EAI9999999T', @@ -218,17 +210,11 @@ function _testMultiLicenceBill () { } } -function _testSingleLicenceBill () { +function _testSingleLicenceBill() { return { accountName: 'Mr B Blobby', accountNumber: 'E99999999A', - addressLines: [ - 'C/O Noel Edmonds', - 'Crinkley Bottom', - 'Cricket St Thomas', - 'Somerset', - 'TA20 1KL' - ], + addressLines: ['C/O Noel Edmonds', 'Crinkley Bottom', 'Cricket St Thomas', 'Somerset', 'TA20 1KL'], billId: '8b8b8831-d671-4456-93cd-30310e6fdf7a', billingAccountId: '7771d5a3-305c-4564-8167-74ba0cc4f08e', billNumber: 'EAI9999999T', @@ -261,11 +247,13 @@ function _testSingleLicenceBill () { adjustments: '', billableDays: '214/214', chargeCategoryDescription: 'Medium loss, non-tidal, greater than 83 up to and including 142 ML/yr', - chargeElements: [{ - purpose: 'Trickle Irrigation - Direct', - abstractionPeriod: '1 April to 31 October', - volume: '21.474ML' - }], + chargeElements: [ + { + purpose: 'Trickle Irrigation - Direct', + abstractionPeriod: '1 April to 31 October', + volume: '21.474ML' + } + ], chargePeriod: '1 April 2023 to 31 March 2024', chargeReference: '4.5.13 (£11.62)', chargeType: 'standard', @@ -288,17 +276,11 @@ function _testSingleLicenceBill () { } } -function _testSingleLicenceBillPreSroc () { +function _testSingleLicenceBillPreSroc() { return { accountName: 'Mr B Blobby', accountNumber: 'E99999999A', - addressLines: [ - 'C/O Noel Edmonds', - 'Crinkley Bottom', - 'Cricket St Thomas', - 'Somerset', - 'TA20 1KL' - ], + addressLines: ['C/O Noel Edmonds', 'Crinkley Bottom', 'Cricket St Thomas', 'Somerset', 'TA20 1KL'], billId: '8b8b8831-d671-4456-93cd-30310e6fdf7a', billingAccountId: '7771d5a3-305c-4564-8167-74ba0cc4f08e', billNumber: 'EAI9999999T', @@ -331,11 +313,13 @@ function _testSingleLicenceBillPreSroc () { adjustments: '', billableDays: '214/214', chargeCategoryDescription: 'Medium loss, non-tidal, greater than 83 up to and including 142 ML/yr', - chargeElements: [{ - purpose: 'Trickle Irrigation - Direct', - abstractionPeriod: '1 April to 31 October', - volume: '21.474ML' - }], + chargeElements: [ + { + purpose: 'Trickle Irrigation - Direct', + abstractionPeriod: '1 April to 31 October', + volume: '21.474ML' + } + ], chargePeriod: '1 April 2023 to 31 March 2024', chargeReference: '4.5.13 (£11.62)', chargeType: 'standard', diff --git a/test/controllers/check.controller.test.js b/test/controllers/check.controller.test.js index d03539648f..6532358449 100644 --- a/test/controllers/check.controller.test.js +++ b/test/controllers/check.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code const ProcessLicenceReturnLogsService = require('../../app/services/jobs/return-logs/process-licence-return-logs.service.js') diff --git a/test/controllers/data.controller.test.js b/test/controllers/data.controller.test.js index e436d3c407..412625cf83 100644 --- a/test/controllers/data.controller.test.js +++ b/test/controllers/data.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/controllers/health.controller.test.js b/test/controllers/health.controller.test.js index 884de5e126..ab414d6f7b 100644 --- a/test/controllers/health.controller.test.js +++ b/test/controllers/health.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/controllers/import.controller.test.js b/test/controllers/import.controller.test.js index 5ad5b66f61..521f6c3c31 100644 --- a/test/controllers/import.controller.test.js +++ b/test/controllers/import.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/controllers/jobs.controller.test.js b/test/controllers/jobs.controller.test.js index ba668208c7..32e9849e32 100644 --- a/test/controllers/jobs.controller.test.js +++ b/test/controllers/jobs.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/controllers/licences.controller.test.js b/test/controllers/licences.controller.test.js index aaf75da168..65071fc809 100644 --- a/test/controllers/licences.controller.test.js +++ b/test/controllers/licences.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -559,7 +559,8 @@ describe('Licences controller', () => { describe('when a request is valid', () => { beforeEach(async () => { Sinon.stub(MarkedForSupplementaryBillingService, 'go').resolves({ - licenceId: '7861814c-ca19-43f2-be11-3c612f0d744b', licenceRef: '01/test' + licenceId: '7861814c-ca19-43f2-be11-3c612f0d744b', + licenceRef: '01/test' }) }) @@ -574,7 +575,7 @@ describe('Licences controller', () => { }) }) -function _markForSupplementaryBilling () { +function _markForSupplementaryBilling() { return { licenceId: '7861814c-ca19-43f2-be11-3c612f0d744b', licenceRef: '01/test', @@ -587,7 +588,7 @@ function _markForSupplementaryBilling () { } } -function _viewLicenceBills () { +function _viewLicenceBills() { const commonLicenceData = _viewLicence() return { @@ -597,7 +598,7 @@ function _viewLicenceBills () { } } -function _viewLicenceCommunications () { +function _viewLicenceCommunications() { const commonLicenceData = _viewLicence() return { @@ -607,7 +608,7 @@ function _viewLicenceCommunications () { } } -function _viewLicenceContacts () { +function _viewLicenceContacts() { const commonLicenceData = _viewLicence() return { @@ -618,7 +619,7 @@ function _viewLicenceContacts () { } } -function _viewLicenceHistory () { +function _viewLicenceHistory() { return { entries: [{}], licenceId: '7861814c-ca19-43f2-be11-3c612f0d744b', @@ -627,7 +628,7 @@ function _viewLicenceHistory () { } } -function _viewLicenceContactDetails () { +function _viewLicenceContactDetails() { const commonLicenceData = _viewLicence() commonLicenceData.pageTitle = null @@ -648,7 +649,7 @@ function _viewLicenceContactDetails () { } } -function _viewLicencePoints () { +function _viewLicencePoints() { return { id: 'f500992f-b178-480b-9325-51fe7fdbc9fd', licencePoints: [ @@ -674,7 +675,7 @@ function _viewLicencePoints () { } } -function _viewLicencePurposes () { +function _viewLicencePurposes() { return { id: '5ca7bf18-d433-491c-ac83-483f67ee7d93', licenceRef: '01/140/R01', @@ -686,9 +687,7 @@ function _viewLicencePurposes () { '455.00 cubic metres per hour' ], abstractionPeriod: '1 November to 31 March', - abstractionPoints: [ - 'At National Grid Reference TQ 78392 78004 (LIPWELL STREAM POINT A)' - ], + abstractionPoints: ['At National Grid Reference TQ 78392 78004 (LIPWELL STREAM POINT A)'], purposeDescription: 'Transfer Between Sources (Pre Water Act 2003)' } ], @@ -696,27 +695,25 @@ function _viewLicencePurposes () { } } -function _viewLicenceReturns () { +function _viewLicenceReturns() { const commonLicenceData = _viewLicence() return { ...commonLicenceData, activeTab: 'returns', - returns: [ - { id: 'returns-id' } - ], + returns: [{ id: 'returns-id' }], noReturnsMessage: null } } -function _viewLicenceSetUp () { +function _viewLicenceSetUp() { const commonLicenceData = _viewLicence() return { ...commonLicenceData, activeTab: 'set-up', agreements: [{}], - chargeInformation: [{ }], + chargeInformation: [{}], enableRequirementsForReturns: true, links: { agreements: { @@ -731,11 +728,11 @@ function _viewLicenceSetUp () { noReturnsRequired: '/' } }, - returnVersions: [{ }] + returnVersions: [{}] } } -function _viewLicenceSummary () { +function _viewLicenceSummary() { const commonLicenceData = _viewLicence() return { @@ -748,7 +745,7 @@ function _viewLicenceSummary () { } } -function _viewLicence () { +function _viewLicence() { return { documentId: 'e8f491f0-0c60-4083-9d41-d2be69f17a1e', licenceId: 'f1288f6c-8503-4dc1-b114-75c408a14bd0', diff --git a/test/controllers/monitoring-stations.controller.test.js b/test/controllers/monitoring-stations.controller.test.js index 2440d2a2ba..5dd38faa05 100644 --- a/test/controllers/monitoring-stations.controller.test.js +++ b/test/controllers/monitoring-stations.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -60,21 +60,22 @@ describe('Monitoring stations controller', () => { { licenceId: 'bf1befed-2ece-4805-89fd-3056a5cf5020', licenceRef: '01/0157', - linkages: [{ - abstractionPeriod: '01 May to 12 August', - alertType: 'Stop', - alertUpdatedAt: '26 September 2024', - createdAt: '2023-12-14 21:33:04.006', - lastUpdatedAt: '2024-09-26 01:39:11.340', - id: '76ada4a6-00f6-4e9a-b930-a3512b0f4d77', - licenceRef: 'AT/Test', - restrictionType: 'Level', - threshold: '500 Ml/d' - }] + linkages: [ + { + abstractionPeriod: '01 May to 12 August', + alertType: 'Stop', + alertUpdatedAt: '26 September 2024', + createdAt: '2023-12-14 21:33:04.006', + lastUpdatedAt: '2024-09-26 01:39:11.340', + id: '76ada4a6-00f6-4e9a-b930-a3512b0f4d77', + licenceRef: 'AT/Test', + restrictionType: 'Level', + threshold: '500 Ml/d' + } + ] } ] - } - ) + }) }) describe('when the request succeeds', () => { diff --git a/test/controllers/return-versions-setup.controller.test.js b/test/controllers/return-versions-setup.controller.test.js index 58ad38b0b6..dee91bc062 100644 --- a/test/controllers/return-versions-setup.controller.test.js +++ b/test/controllers/return-versions-setup.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -115,7 +115,9 @@ describe('Return Versions controller', () => { const response = await server.inject(_postOptions(path, requirementIndex)) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/return-versions/setup/' + sessionId + '/returns-cycle/0') + expect(response.headers.location).to.equal( + '/system/return-versions/setup/' + sessionId + '/returns-cycle/0' + ) }) }) @@ -164,7 +166,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(NoteService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Add a note' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Add a note' }) }) @@ -274,7 +277,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(CheckService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Check the return requirements for Acme Corp.' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Check the return requirements for Acme Corp.' }) }) @@ -316,7 +320,8 @@ describe('Return Versions controller', () => { describe('when the request succeeds', () => { beforeEach(async () => { Sinon.stub(ExistingService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Use previous requirements for returns' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Use previous requirements for returns' }) }) @@ -366,7 +371,8 @@ describe('Return Versions controller', () => { describe('GET ', () => { beforeEach(async () => { Sinon.stub(FrequencyCollectedService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Select how often readings or volumes are collected' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Select how often readings or volumes are collected' }) }) @@ -404,7 +410,9 @@ describe('Return Versions controller', () => { const response = await server.inject(_postOptions(path, requirementIndex)) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/return-versions/setup/' + sessionId + '/frequency-reported/0') + expect(response.headers.location).to.equal( + '/system/return-versions/setup/' + sessionId + '/frequency-reported/0' + ) }) }) @@ -430,7 +438,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(FrequencyReportedService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Select how often readings or volumes are reported' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Select how often readings or volumes are reported' }) }) @@ -468,7 +477,9 @@ describe('Return Versions controller', () => { const response = await server.inject(_postOptions(path, requirementIndex)) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/return-versions/setup/' + sessionId + '/agreements-exceptions/0') + expect(response.headers.location).to.equal( + '/system/return-versions/setup/' + sessionId + '/agreements-exceptions/0' + ) }) }) @@ -494,7 +505,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(MethodService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'How do you want to set up the requirements for returns?' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'How do you want to set up the requirements for returns?' }) }) @@ -532,7 +544,9 @@ describe('Return Versions controller', () => { const response = await server.inject(_postOptions(path)) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/return-versions/setup/' + sessionId + '/page-data-redirect') + expect(response.headers.location).to.equal( + '/system/return-versions/setup/' + sessionId + '/page-data-redirect' + ) }) }) }) @@ -545,7 +559,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(NoReturnsRequiredService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Why are no returns required?' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Why are no returns required?' }) }) @@ -563,7 +578,7 @@ describe('Return Versions controller', () => { describe('when the request succeeds', () => { describe('and the validation passes', () => { beforeEach(async () => { - Sinon.stub(SubmitNoReturnsRequiredService, 'go').resolves({ }) + Sinon.stub(SubmitNoReturnsRequiredService, 'go').resolves({}) }) it('redirects to /system/return-versions/{sessionId}/check', async () => { @@ -596,7 +611,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(PointsService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Select the points for the requirements for returns' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Select the points for the requirements for returns' }) }) @@ -634,7 +650,9 @@ describe('Return Versions controller', () => { const response = await server.inject(_postOptions(path, requirementIndex)) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/return-versions/setup/' + sessionId + '/abstraction-period/0') + expect(response.headers.location).to.equal( + '/system/return-versions/setup/' + sessionId + '/abstraction-period/0' + ) }) }) @@ -660,7 +678,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(SelectPurposeService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Select the purpose for the requirement for returns' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Select the purpose for the requirement for returns' }) }) @@ -724,7 +743,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(SelectReasonService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Select the reason for the requirements for returns' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Select the reason for the requirements for returns' }) }) @@ -788,7 +808,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(RemoveService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'You are about to remove these requirements for returns' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'You are about to remove these requirements for returns' }) }) @@ -809,7 +830,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(ReturnCycleService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Select the returns cycle for the return requirement' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Select the returns cycle for the return requirement' }) }) @@ -847,7 +869,9 @@ describe('Return Versions controller', () => { const response = await server.inject(_postOptions(path, requirementIndex)) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/return-versions/setup/' + sessionId + '/site-description/0') + expect(response.headers.location).to.equal( + '/system/return-versions/setup/' + sessionId + '/site-description/0' + ) }) }) @@ -912,7 +936,9 @@ describe('Return Versions controller', () => { const response = await server.inject(_postOptions(path, requirementIndex)) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/return-versions/setup/' + sessionId + '/frequency-collected/0') + expect(response.headers.location).to.equal( + '/system/return-versions/setup/' + sessionId + '/frequency-collected/0' + ) }) }) @@ -938,7 +964,8 @@ describe('Return Versions controller', () => { describe('GET', () => { beforeEach(async () => { Sinon.stub(StartDateService, 'go').resolves({ - id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', pageTitle: 'Select the start date for the requirements for returns' + id: '8702b98f-ae51-475d-8fcc-e049af8b8d38', + pageTitle: 'Select the start date for the requirements for returns' }) }) @@ -989,7 +1016,9 @@ describe('Return Versions controller', () => { const response = await server.inject(postRequestOptions(`/return-versions/setup/${sessionId}/${path}`)) expect(response.statusCode).to.equal(302) - expect(response.headers.location).to.equal('/system/return-versions/setup/' + sessionId + '/no-returns-required') + expect(response.headers.location).to.equal( + '/system/return-versions/setup/' + sessionId + '/no-returns-required' + ) }) }) @@ -1010,7 +1039,7 @@ describe('Return Versions controller', () => { }) }) -function _getOptions (path, index = -1) { +function _getOptions(path, index = -1) { let url = `/return-versions/setup/${sessionId}/${path}` if (index > -1) { @@ -1027,7 +1056,7 @@ function _getOptions (path, index = -1) { } } -function _postOptions (path, index = -1, payload) { +function _postOptions(path, index = -1, payload) { let url = `/return-versions/setup/${sessionId}/${path}` if (index > -1) { diff --git a/test/controllers/return-versions.controller.test.js b/test/controllers/return-versions.controller.test.js index d96377a646..71e8d30394 100644 --- a/test/controllers/return-versions.controller.test.js +++ b/test/controllers/return-versions.controller.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/controllers/root.controller.test.js b/test/controllers/root.controller.test.js index 69bf8c309d..f4984005db 100644 --- a/test/controllers/root.controller.test.js +++ b/test/controllers/root.controller.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // For running our service diff --git a/test/errors/expanded.error.test.js b/test/errors/expanded.error.test.js index f9dede7895..64ca098fa3 100644 --- a/test/errors/expanded.error.test.js +++ b/test/errors/expanded.error.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/fixtures/bill-runs-review.fixture.js b/test/fixtures/bill-runs-review.fixture.js index d8151ff39b..3a6e3cf92b 100644 --- a/test/fixtures/bill-runs-review.fixture.js +++ b/test/fixtures/bill-runs-review.fixture.js @@ -7,7 +7,7 @@ const BillingAccountModel = require('../../app/models/billing-account.model.js') * * @returns {object} */ -function removeReviewLicence () { +function removeReviewLicence() { return { id: 'bb779166-0576-4581-b504-edbc0227d763', licenceId: '32416c67-f755-4c3f-8816-ecde0ee596bd', @@ -31,7 +31,7 @@ function removeReviewLicence () { * * @returns {object} */ -function reviewChargeElement () { +function reviewChargeElement() { return { id: 'a1840523-a04c-4c64-bff7-4a515e8ba1c1', amendedAllocated: 0, @@ -49,9 +49,7 @@ function reviewChargeElement () { reviewChargeReference: { id: '6c70461b-3f83-47b1-9538-8305e82b34eb', amendedAuthorisedVolume: 9.092, - reviewChargeElements: [ - { id: 'a1840523-a04c-4c64-bff7-4a515e8ba1c1' } - ], + reviewChargeElements: [{ id: 'a1840523-a04c-4c64-bff7-4a515e8ba1c1' }], reviewChargeVersion: { id: 'a71c386c-d9b8-4915-a508-74fb1508c071', chargePeriodStartDate: new Date('2023-04-01'), @@ -103,7 +101,7 @@ function reviewChargeElement () { * * @returns {object} */ -function reviewChargeReference () { +function reviewChargeReference() { return { id: '6b3d11f2-d361-4eaa-bce2-5561283bd023', abatementAgreement: 1, @@ -158,7 +156,7 @@ function reviewChargeReference () { * * @returns {object} */ -function reviewLicence () { +function reviewLicence() { return { id: 'bb779166-0576-4581-b504-edbc0227d763', billRunId: '287aeb25-cf11-429d-8c6f-f98f06db021d', diff --git a/test/lib/base-notifier.lib.test.js b/test/lib/base-notifier.lib.test.js index 90ee824ee2..64171844f3 100644 --- a/test/lib/base-notifier.lib.test.js +++ b/test/lib/base-notifier.lib.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/lib/boom-notifier.lib.test.js b/test/lib/boom-notifier.lib.test.js index 22646579e1..58aa601ee1 100644 --- a/test/lib/boom-notifier.lib.test.js +++ b/test/lib/boom-notifier.lib.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/lib/dates.lib.test.js b/test/lib/dates.lib.test.js index c05ba1307f..3a8bbfa67c 100644 --- a/test/lib/dates.lib.test.js +++ b/test/lib/dates.lib.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/lib/general.lib.test.js b/test/lib/general.lib.test.js index 8404eef62c..597a1771f2 100644 --- a/test/lib/general.lib.test.js +++ b/test/lib/general.lib.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -40,9 +40,7 @@ describe('GeneralLib', () => { const logDataArg = notifierStub.omg.args[0][1] - expect( - notifierStub.omg.calledWith('I am the test with no data') - ).to.be.true() + expect(notifierStub.omg.calledWith('I am the test with no data')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.name).not.to.exist() @@ -55,9 +53,7 @@ describe('GeneralLib', () => { const logDataArg = notifierStub.omg.args[0][1] - expect( - notifierStub.omg.calledWith('I am the test with data') - ).to.be.true() + expect(notifierStub.omg.calledWith('I am the test with data')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.name).to.exist() }) @@ -167,15 +163,19 @@ describe('GeneralLib', () => { describe('when given periods that do not overlap', () => { beforeEach(() => { - referencePeriod = [{ - startDate: new Date('2023-02-01'), - endDate: new Date('2023-02-02') - }] - - checkPeriod = [{ - startDate: new Date('2023-01-01'), - endDate: new Date('2023-01-31') - }] + referencePeriod = [ + { + startDate: new Date('2023-02-01'), + endDate: new Date('2023-02-02') + } + ] + + checkPeriod = [ + { + startDate: new Date('2023-01-01'), + endDate: new Date('2023-01-31') + } + ] }) it('returns false', () => { @@ -187,15 +187,19 @@ describe('GeneralLib', () => { describe('when a check period overlaps the start of a reference period', () => { beforeEach(() => { - referencePeriod = [{ - startDate: new Date('2023-02-01'), - endDate: new Date('2023-02-28') - }] - - checkPeriod = [{ - startDate: new Date('2023-01-15'), - endDate: new Date('2023-02-15') - }] + referencePeriod = [ + { + startDate: new Date('2023-02-01'), + endDate: new Date('2023-02-28') + } + ] + + checkPeriod = [ + { + startDate: new Date('2023-01-15'), + endDate: new Date('2023-02-15') + } + ] }) it('returns true', () => { @@ -207,15 +211,19 @@ describe('GeneralLib', () => { describe('when a check period overlaps the end of a reference period', () => { beforeEach(() => { - referencePeriod = [{ - startDate: new Date('2023-01-01'), - endDate: new Date('2023-01-31') - }] - - checkPeriod = [{ - startDate: new Date('2023-01-15'), - endDate: new Date('2023-02-15') - }] + referencePeriod = [ + { + startDate: new Date('2023-01-01'), + endDate: new Date('2023-01-31') + } + ] + + checkPeriod = [ + { + startDate: new Date('2023-01-15'), + endDate: new Date('2023-02-15') + } + ] }) it('returns true', () => { @@ -227,15 +235,19 @@ describe('GeneralLib', () => { describe('when a reference period is completely inside a check period', () => { beforeEach(() => { - referencePeriod = [{ - startDate: new Date('2023-02-01'), - endDate: new Date('2023-02-15') - }] - - checkPeriod = [{ - startDate: new Date('2023-01-01'), - endDate: new Date('2023-02-28') - }] + referencePeriod = [ + { + startDate: new Date('2023-02-01'), + endDate: new Date('2023-02-15') + } + ] + + checkPeriod = [ + { + startDate: new Date('2023-01-01'), + endDate: new Date('2023-02-28') + } + ] }) it('returns true', () => { @@ -247,15 +259,19 @@ describe('GeneralLib', () => { describe('when a check period is completely inside a reference period', () => { beforeEach(() => { - referencePeriod = [{ - startDate: new Date('2023-01-01'), - endDate: new Date('2023-02-28') - }] - - checkPeriod = [{ - startDate: new Date('2023-02-01'), - endDate: new Date('2023-02-15') - }] + referencePeriod = [ + { + startDate: new Date('2023-01-01'), + endDate: new Date('2023-02-28') + } + ] + + checkPeriod = [ + { + startDate: new Date('2023-02-01'), + endDate: new Date('2023-02-15') + } + ] }) it('returns true', () => { @@ -267,15 +283,19 @@ describe('GeneralLib', () => { describe('when the periods are the same', () => { beforeEach(() => { - referencePeriod = [{ - startDate: new Date('2023-02-01'), - endDate: new Date('2023-02-28') - }] - - checkPeriod = [{ - startDate: new Date('2023-02-01'), - endDate: new Date('2023-02-28') - }] + referencePeriod = [ + { + startDate: new Date('2023-02-01'), + endDate: new Date('2023-02-28') + } + ] + + checkPeriod = [ + { + startDate: new Date('2023-02-01'), + endDate: new Date('2023-02-28') + } + ] }) it('returns true', () => { diff --git a/test/lib/global-notifier.lib.test.js b/test/lib/global-notifier.lib.test.js index 8b674c4404..4f6aafdf53 100644 --- a/test/lib/global-notifier.lib.test.js +++ b/test/lib/global-notifier.lib.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/lib/legacy-db-snake-case-mappers.lib.test.js b/test/lib/legacy-db-snake-case-mappers.lib.test.js index 809e5c55cd..dcebd7263e 100644 --- a/test/lib/legacy-db-snake-case-mappers.lib.test.js +++ b/test/lib/legacy-db-snake-case-mappers.lib.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -55,7 +55,7 @@ describe('Legacy DB Snake Case Mappers lib', () => { }) describe('when the wrapIdentifier() hook it creates is used', () => { - function origWrap (identifier) { + function origWrap(identifier) { return identifier } diff --git a/test/lib/request-notifier.lib.test.js b/test/lib/request-notifier.lib.test.js index ce10b08e6f..352882b3e0 100644 --- a/test/lib/request-notifier.lib.test.js +++ b/test/lib/request-notifier.lib.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/lib/return-cycle-dates.lib.test.js b/test/lib/return-cycle-dates.lib.test.js index 2075b7ee7d..84ea2ad146 100644 --- a/test/lib/return-cycle-dates.lib.test.js +++ b/test/lib/return-cycle-dates.lib.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { afterEach, describe, it, before, beforeEach } = exports.lab = Lab.script() +const { afterEach, describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code const { returnCycleDates } = require('../../app/lib/static-lookups.lib.js') @@ -119,7 +119,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() + 1, returnCycleDates.summer.dueDate.month, returnCycleDates.summer.dueDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] it('should return the due date of next years summer cycle formatted as YYYY-MM-DD', () => { const result = ReturnCycleDatesLib.cycleDueDateAsISO(summer) @@ -139,7 +141,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.summer.dueDate.month, returnCycleDates.summer.dueDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the due date for this years summer cycle formatted as YYYY-MM-DD', () => { @@ -159,7 +163,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() + 1, returnCycleDates.allYear.dueDate.month, returnCycleDates.allYear.dueDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the due date of the next winter and all year cycle formatted as YYYY-MM-DD', () => { @@ -179,7 +185,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.allYear.dueDate.month, returnCycleDates.allYear.dueDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the due date of the current winter and all year cycle formatted as YYYY-MM-DD', () => { @@ -283,7 +291,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() + 1, returnCycleDates.summer.endDate.month, returnCycleDates.summer.endDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the end date for the next summer cycle formatted as YYYY-MM-DD', () => { @@ -303,7 +313,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.summer.endDate.month, returnCycleDates.summer.endDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the end date for the current summer cycle formatted as YYYY-MM-DD', () => { @@ -323,7 +335,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() + 1, returnCycleDates.allYear.endDate.month, returnCycleDates.allYear.endDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the end date of the next winter and all year cycle formatted as YYYY-MM-DD', () => { @@ -343,7 +357,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.allYear.endDate.month, returnCycleDates.allYear.endDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the end date of the current winter and all year cycle formatted as YYYY-MM-DD', () => { @@ -447,7 +463,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.summer.startDate.month, returnCycleDates.summer.startDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the start date for the current summer cycle formatted as YYYY-MM-DD', () => { @@ -467,7 +485,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 1, returnCycleDates.summer.startDate.month, returnCycleDates.summer.startDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the start date for the previous summer cycle formatted as YYYY-MM-DD', () => { @@ -487,7 +507,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.allYear.startDate.month, returnCycleDates.allYear.startDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the start date of the current winter and all year cycle formatted as YYYY-MM-DD', () => { @@ -507,7 +529,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 1, returnCycleDates.allYear.startDate.month, returnCycleDates.allYear.startDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the start date of the previous winter and all year cycle formatted as YYYY-MM-DD', () => { @@ -526,7 +550,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.summer.dueDate.month, returnCycleDates.summer.dueDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct due date for the summer cycle formatted as YYYY-MM-DD', () => { @@ -544,7 +570,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 1, returnCycleDates.summer.dueDate.month, returnCycleDates.summer.dueDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct due date for the summer cycle formatted as YYYY-MM-DD', () => { @@ -562,7 +590,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.allYear.dueDate.month, returnCycleDates.allYear.dueDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct due date for the all year cycle formatted as YYYY-MM-DD', () => { @@ -580,7 +610,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 1, returnCycleDates.allYear.dueDate.month, returnCycleDates.allYear.dueDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct due date for the all year cycle formatted as YYYY-MM-DD', () => { @@ -600,7 +632,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.summer.endDate.month, returnCycleDates.summer.endDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct end date for the summer cycle formatted as YYYY-MM-DD', () => { @@ -618,7 +652,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 1, returnCycleDates.summer.endDate.month, returnCycleDates.summer.endDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct end date for the summer cycle formatted as YYYY-MM-DD', () => { @@ -636,7 +672,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear(), returnCycleDates.allYear.endDate.month, returnCycleDates.allYear.endDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct end date for the all year cycle formatted as YYYY-MM-DD', () => { @@ -654,7 +692,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 1, returnCycleDates.allYear.endDate.month, returnCycleDates.allYear.endDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct end date for the all year cycle formatted as YYYY-MM-DD', () => { @@ -674,7 +714,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 1, returnCycleDates.summer.startDate.month, returnCycleDates.summer.startDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct end date for the summer cycle formatted as YYYY-MM-DD', () => { @@ -692,7 +734,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 2, returnCycleDates.summer.startDate.month, returnCycleDates.summer.startDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct end date for the summer cycle formatted as YYYY-MM-DD', () => { @@ -710,7 +754,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 1, returnCycleDates.allYear.startDate.month, returnCycleDates.allYear.startDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct end date for the all year cycle formatted as YYYY-MM-DD', () => { @@ -728,7 +774,9 @@ describe('Return Cycle Dates lib', () => { new Date().getFullYear() - 2, returnCycleDates.allYear.startDate.month, returnCycleDates.allYear.startDate.day - ).toISOString().split('T')[0] + ) + .toISOString() + .split('T')[0] }) it('should return the correct end date for the all year cycle formatted as YYYY-MM-DD', () => { diff --git a/test/models/address.model.test.js b/test/models/address.model.test.js index 97641e7102..0d2a6688a1 100644 --- a/test/models/address.model.test.js +++ b/test/models/address.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -55,16 +55,13 @@ describe('Address model', () => { }) it('can successfully run a related query', async () => { - const query = await AddressModel.query() - .innerJoinRelated('billingAccountAddresses') + const query = await AddressModel.query().innerJoinRelated('billingAccountAddresses') expect(query).to.exist() }) it('can eager load the billing account addresses', async () => { - const result = await AddressModel.query() - .findById(testRecord.id) - .withGraphFetched('billingAccountAddresses') + const result = await AddressModel.query().findById(testRecord.id).withGraphFetched('billingAccountAddresses') expect(result).to.be.instanceOf(AddressModel) expect(result.id).to.equal(testRecord.id) @@ -93,16 +90,13 @@ describe('Address model', () => { }) it('can successfully run a related query', async () => { - const query = await AddressModel.query() - .innerJoinRelated('companyAddresses') + const query = await AddressModel.query().innerJoinRelated('companyAddresses') expect(query).to.exist() }) it('can eager load the company addresses', async () => { - const result = await AddressModel.query() - .findById(testRecord.id) - .withGraphFetched('companyAddresses') + const result = await AddressModel.query().findById(testRecord.id).withGraphFetched('companyAddresses') expect(result).to.be.instanceOf(AddressModel) expect(result.id).to.equal(testRecord.id) @@ -131,16 +125,13 @@ describe('Address model', () => { }) it('can successfully run a related query', async () => { - const query = await AddressModel.query() - .innerJoinRelated('licenceDocumentRoles') + const query = await AddressModel.query().innerJoinRelated('licenceDocumentRoles') expect(query).to.exist() }) it('can eager load the licence document roles', async () => { - const result = await AddressModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceDocumentRoles') + const result = await AddressModel.query().findById(testRecord.id).withGraphFetched('licenceDocumentRoles') expect(result).to.be.instanceOf(AddressModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/bill-licence.model.test.js b/test/models/bill-licence.model.test.js index b3acf233dd..ea7eef6585 100644 --- a/test/models/bill-licence.model.test.js +++ b/test/models/bill-licence.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,16 +48,13 @@ describe('Bill Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await BillLicenceModel.query() - .innerJoinRelated('bill') + const query = await BillLicenceModel.query().innerJoinRelated('bill') expect(query).to.exist() }) it('can eager load the bill', async () => { - const result = await BillLicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('bill') + const result = await BillLicenceModel.query().findById(testRecord.id).withGraphFetched('bill') expect(result).to.be.instanceOf(BillLicenceModel) expect(result.id).to.equal(testRecord.id) @@ -83,16 +80,13 @@ describe('Bill Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await BillLicenceModel.query() - .innerJoinRelated('transactions') + const query = await BillLicenceModel.query().innerJoinRelated('transactions') expect(query).to.exist() }) it('can eager load the transactions', async () => { - const result = await BillLicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('transactions') + const result = await BillLicenceModel.query().findById(testRecord.id).withGraphFetched('transactions') expect(result).to.be.instanceOf(BillLicenceModel) expect(result.id).to.equal(testRecord.id) @@ -116,16 +110,13 @@ describe('Bill Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await BillLicenceModel.query() - .innerJoinRelated('licence') + const query = await BillLicenceModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await BillLicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await BillLicenceModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(BillLicenceModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/bill-run-charge-version-year.model.test.js b/test/models/bill-run-charge-version-year.model.test.js index 03510e46ca..8a425ea097 100644 --- a/test/models/bill-run-charge-version-year.model.test.js +++ b/test/models/bill-run-charge-version-year.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -46,16 +46,13 @@ describe('Bill Run Charge Version Year model', () => { }) it('can successfully run a related query', async () => { - const query = await BillRunChargeVersionYearModel.query() - .innerJoinRelated('billRun') + const query = await BillRunChargeVersionYearModel.query().innerJoinRelated('billRun') expect(query).to.exist() }) it('can eager load the bill run', async () => { - const result = await BillRunChargeVersionYearModel.query() - .findById(testRecord.id) - .withGraphFetched('billRun') + const result = await BillRunChargeVersionYearModel.query().findById(testRecord.id).withGraphFetched('billRun') expect(result).to.be.instanceOf(BillRunChargeVersionYearModel) expect(result.id).to.equal(testRecord.id) @@ -77,8 +74,7 @@ describe('Bill Run Charge Version Year model', () => { }) it('can successfully run a related query', async () => { - const query = await BillRunChargeVersionYearModel.query() - .innerJoinRelated('chargeVersion') + const query = await BillRunChargeVersionYearModel.query().innerJoinRelated('chargeVersion') expect(query).to.exist() }) diff --git a/test/models/bill-run-volume.model.test.js b/test/models/bill-run-volume.model.test.js index 61e4e1bd80..4de91f6ac0 100644 --- a/test/models/bill-run-volume.model.test.js +++ b/test/models/bill-run-volume.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -46,16 +46,13 @@ describe('Bill Run Volume model', () => { }) it('can successfully run a related query', async () => { - const query = await BillRunVolumeModel.query() - .innerJoinRelated('billRun') + const query = await BillRunVolumeModel.query().innerJoinRelated('billRun') expect(query).to.exist() }) it('can eager load the bill run', async () => { - const result = await BillRunVolumeModel.query() - .findById(testRecord.id) - .withGraphFetched('billRun') + const result = await BillRunVolumeModel.query().findById(testRecord.id).withGraphFetched('billRun') expect(result).to.be.instanceOf(BillRunVolumeModel) expect(result.id).to.equal(testRecord.id) @@ -77,16 +74,13 @@ describe('Bill Run Volume model', () => { }) it('can successfully run a related query', async () => { - const query = await BillRunVolumeModel.query() - .innerJoinRelated('chargeReference') + const query = await BillRunVolumeModel.query().innerJoinRelated('chargeReference') expect(query).to.exist() }) it('can eager load the charge reference', async () => { - const result = await BillRunVolumeModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeReference') + const result = await BillRunVolumeModel.query().findById(testRecord.id).withGraphFetched('chargeReference') expect(result).to.be.instanceOf(BillRunVolumeModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/bill-run.model.test.js b/test/models/bill-run.model.test.js index c491844efe..d8c0c4d69a 100644 --- a/test/models/bill-run.model.test.js +++ b/test/models/bill-run.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,16 +47,13 @@ describe('Bill Run model', () => { }) it('can successfully run a related query', async () => { - const query = await BillRunModel.query() - .innerJoinRelated('region') + const query = await BillRunModel.query().innerJoinRelated('region') expect(query).to.exist() }) it('can eager load the region', async () => { - const result = await BillRunModel.query() - .findById(testRecord.id) - .withGraphFetched('region') + const result = await BillRunModel.query().findById(testRecord.id).withGraphFetched('region') expect(result).to.be.instanceOf(BillRunModel) expect(result.id).to.equal(testRecord.id) @@ -82,16 +79,13 @@ describe('Bill Run model', () => { }) it('can successfully run a related query', async () => { - const query = await BillRunModel.query() - .innerJoinRelated('bills') + const query = await BillRunModel.query().innerJoinRelated('bills') expect(query).to.exist() }) it('can eager load the bills', async () => { - const result = await BillRunModel.query() - .findById(testRecord.id) - .withGraphFetched('bills') + const result = await BillRunModel.query().findById(testRecord.id).withGraphFetched('bills') expect(result).to.be.instanceOf(BillRunModel) expect(result.id).to.equal(testRecord.id) @@ -119,16 +113,13 @@ describe('Bill Run model', () => { }) it('can successfully run a related query', async () => { - const query = await BillRunModel.query() - .innerJoinRelated('billRunVolumes') + const query = await BillRunModel.query().innerJoinRelated('billRunVolumes') expect(query).to.exist() }) it('can eager load the bills', async () => { - const result = await BillRunModel.query() - .findById(testRecord.id) - .withGraphFetched('billRunVolumes') + const result = await BillRunModel.query().findById(testRecord.id).withGraphFetched('billRunVolumes') expect(result).to.be.instanceOf(BillRunModel) expect(result.id).to.equal(testRecord.id) @@ -156,16 +147,13 @@ describe('Bill Run model', () => { }) it('can successfully run a related query', async () => { - const query = await BillRunModel.query() - .innerJoinRelated('reviewLicences') + const query = await BillRunModel.query().innerJoinRelated('reviewLicences') expect(query).to.exist() }) it('can eager load the review licences', async () => { - const result = await BillRunModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewLicences') + const result = await BillRunModel.query().findById(testRecord.id).withGraphFetched('reviewLicences') expect(result).to.be.instanceOf(BillRunModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/bill.model.test.js b/test/models/bill.model.test.js index 7177f135be..b96ef6f23e 100644 --- a/test/models/bill.model.test.js +++ b/test/models/bill.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,16 +48,13 @@ describe('Bill model', () => { }) it('can successfully run a related query', async () => { - const query = await BillModel.query() - .innerJoinRelated('billingAccount') + const query = await BillModel.query().innerJoinRelated('billingAccount') expect(query).to.exist() }) it('can eager load the billing account', async () => { - const result = await BillModel.query() - .findById(testRecord.id) - .withGraphFetched('billingAccount') + const result = await BillModel.query().findById(testRecord.id).withGraphFetched('billingAccount') expect(result).to.be.instanceOf(BillModel) expect(result.id).to.equal(testRecord.id) @@ -76,16 +73,13 @@ describe('Bill model', () => { }) it('can successfully run a related query', async () => { - const query = await BillModel.query() - .innerJoinRelated('billRun') + const query = await BillModel.query().innerJoinRelated('billRun') expect(query).to.exist() }) it('can eager load the bill run', async () => { - const result = await BillModel.query() - .findById(testRecord.id) - .withGraphFetched('billRun') + const result = await BillModel.query().findById(testRecord.id).withGraphFetched('billRun') expect(result).to.be.instanceOf(BillModel) expect(result.id).to.equal(testRecord.id) @@ -111,16 +105,13 @@ describe('Bill model', () => { }) it('can successfully run a related query', async () => { - const query = await BillModel.query() - .innerJoinRelated('billLicences') + const query = await BillModel.query().innerJoinRelated('billLicences') expect(query).to.exist() }) it('can eager load the bill licences', async () => { - const result = await BillModel.query() - .findById(testRecord.id) - .withGraphFetched('billLicences') + const result = await BillModel.query().findById(testRecord.id).withGraphFetched('billLicences') expect(result).to.be.instanceOf(BillModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/billing-account-address.model.test.js b/test/models/billing-account-address.model.test.js index e51a8a4053..840a5a3276 100644 --- a/test/models/billing-account-address.model.test.js +++ b/test/models/billing-account-address.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,16 +47,13 @@ describe('Billing Account Address model', () => { }) it('can successfully run a related query', async () => { - const query = await BillingAccountAddressModel.query() - .innerJoinRelated('address') + const query = await BillingAccountAddressModel.query().innerJoinRelated('address') expect(query).to.exist() }) it('can eager load the address', async () => { - const result = await BillingAccountAddressModel.query() - .findById(testRecord.id) - .withGraphFetched('address') + const result = await BillingAccountAddressModel.query().findById(testRecord.id).withGraphFetched('address') expect(result).to.be.instanceOf(BillingAccountAddressModel) expect(result.id).to.equal(testRecord.id) @@ -75,16 +72,13 @@ describe('Billing Account Address model', () => { }) it('can successfully run a related query', async () => { - const query = await BillingAccountAddressModel.query() - .innerJoinRelated('company') + const query = await BillingAccountAddressModel.query().innerJoinRelated('company') expect(query).to.exist() }) it('can eager load the company', async () => { - const result = await BillingAccountAddressModel.query() - .findById(testRecord.id) - .withGraphFetched('company') + const result = await BillingAccountAddressModel.query().findById(testRecord.id).withGraphFetched('company') expect(result).to.be.instanceOf(BillingAccountAddressModel) expect(result.id).to.equal(testRecord.id) @@ -103,8 +97,7 @@ describe('Billing Account Address model', () => { }) it('can successfully run a related query', async () => { - const query = await BillingAccountAddressModel.query() - .innerJoinRelated('billingAccount') + const query = await BillingAccountAddressModel.query().innerJoinRelated('billingAccount') expect(query).to.exist() }) @@ -131,16 +124,13 @@ describe('Billing Account Address model', () => { }) it('can successfully run a related query', async () => { - const query = await BillingAccountAddressModel.query() - .innerJoinRelated('contact') + const query = await BillingAccountAddressModel.query().innerJoinRelated('contact') expect(query).to.exist() }) it('can eager load the contact', async () => { - const result = await BillingAccountAddressModel.query() - .findById(testRecord.id) - .withGraphFetched('contact') + const result = await BillingAccountAddressModel.query().findById(testRecord.id).withGraphFetched('contact') expect(result).to.be.instanceOf(BillingAccountAddressModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/billing-account.model.test.js b/test/models/billing-account.model.test.js index 3b7c298f74..f117269d28 100644 --- a/test/models/billing-account.model.test.js +++ b/test/models/billing-account.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -42,7 +42,9 @@ describe('Billing Account model', () => { const startDate = i === 0 ? new Date(2023, 8, 1) : new Date(2023, 9, 1) const endDate = i === 0 ? new Date(2023, 8, 31) : null const billingAccountAddress = await BillingAccountAddressHelper.add({ - billingAccountId: testRecord.id, endDate, startDate + billingAccountId: testRecord.id, + endDate, + startDate }) testBillingAccountAddresses.push(billingAccountAddress) @@ -75,8 +77,7 @@ describe('Billing Account model', () => { describe('Relationships', () => { describe('when linking to billing account addresses', () => { it('can successfully run a related query', async () => { - const query = await BillingAccountModel.query() - .innerJoinRelated('billingAccountAddresses') + const query = await BillingAccountModel.query().innerJoinRelated('billingAccountAddresses') expect(query).to.exist() }) @@ -98,16 +99,13 @@ describe('Billing Account model', () => { describe('when linking to bills', () => { it('can successfully run a related query', async () => { - const query = await BillingAccountModel.query() - .innerJoinRelated('bills') + const query = await BillingAccountModel.query().innerJoinRelated('bills') expect(query).to.exist() }) it('can eager load the bills', async () => { - const result = await BillingAccountModel.query() - .findById(testRecord.id) - .withGraphFetched('bills') + const result = await BillingAccountModel.query().findById(testRecord.id).withGraphFetched('bills') expect(result).to.be.instanceOf(BillingAccountModel) expect(result.id).to.equal(testRecord.id) @@ -121,16 +119,13 @@ describe('Billing Account model', () => { describe('when linking to charge versions', () => { it('can successfully run a related query', async () => { - const query = await BillingAccountModel.query() - .innerJoinRelated('chargeVersions') + const query = await BillingAccountModel.query().innerJoinRelated('chargeVersions') expect(query).to.exist() }) it('can eager load the charge versions', async () => { - const result = await BillingAccountModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersions') + const result = await BillingAccountModel.query().findById(testRecord.id).withGraphFetched('chargeVersions') expect(result).to.be.instanceOf(BillingAccountModel) expect(result.id).to.equal(testRecord.id) @@ -144,16 +139,13 @@ describe('Billing Account model', () => { describe('when linking to company', () => { it('can successfully run a related query', async () => { - const query = await BillingAccountModel.query() - .innerJoinRelated('company') + const query = await BillingAccountModel.query().innerJoinRelated('company') expect(query).to.exist() }) it('can eager load the company', async () => { - const result = await BillingAccountModel.query() - .findById(testRecord.id) - .withGraphFetched('company') + const result = await BillingAccountModel.query().findById(testRecord.id).withGraphFetched('company') expect(result).to.be.instanceOf(BillingAccountModel) expect(result.id).to.equal(testRecord.id) @@ -210,7 +202,9 @@ describe('Billing Account model', () => { describe("when the 'current' billing account address is linked to a company", () => { it('uses the name of the company linked to the billing account address', async () => { - fetchedRecord = await BillingAccountModel.query().findById(alternateBillingAccount.id).modify('contactDetails') + fetchedRecord = await BillingAccountModel.query() + .findById(alternateBillingAccount.id) + .modify('contactDetails') const result = fetchedRecord.$accountName() @@ -252,8 +246,7 @@ describe('Billing Account model', () => { describe('and it is linked to an address', () => { it('returns an array of just the populated address lines', async () => { - fetchedRecord = await BillingAccountModel - .query() + fetchedRecord = await BillingAccountModel.query() .findById(alternateBillingAccount.id) .modify('contactDetails') @@ -294,7 +287,9 @@ describe('Billing Account model', () => { describe("when the 'current' billing account address is linked to a contact", () => { it('returns the contact name', async () => { - fetchedRecord = await BillingAccountModel.query().findById(alternateBillingAccount.id).modify('contactDetails') + fetchedRecord = await BillingAccountModel.query() + .findById(alternateBillingAccount.id) + .modify('contactDetails') const result = fetchedRecord.$contactName() diff --git a/test/models/change-reason.model.test.js b/test/models/change-reason.model.test.js index 66e5e959e9..5864e44a1a 100644 --- a/test/models/change-reason.model.test.js +++ b/test/models/change-reason.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -49,16 +49,13 @@ describe('Change Reason model', () => { }) it('can successfully run a related query', async () => { - const query = await ChangeReasonModel.query() - .innerJoinRelated('chargeVersions') + const query = await ChangeReasonModel.query().innerJoinRelated('chargeVersions') expect(query).to.exist() }) it('can eager load the charge versions', async () => { - const result = await ChangeReasonModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersions') + const result = await ChangeReasonModel.query().findById(testRecord.id).withGraphFetched('chargeVersions') expect(result).to.be.instanceOf(ChangeReasonModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/charge-category.model.test.js b/test/models/charge-category.model.test.js index 39df716fb7..e65a20568b 100644 --- a/test/models/charge-category.model.test.js +++ b/test/models/charge-category.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,16 +47,13 @@ describe('Charge Category model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeCategoryModel.query() - .innerJoinRelated('chargeReferences') + const query = await ChargeCategoryModel.query().innerJoinRelated('chargeReferences') expect(query).to.exist() }) it('can eager load the charge references', async () => { - const result = await ChargeCategoryModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeReferences') + const result = await ChargeCategoryModel.query().findById(testRecord.id).withGraphFetched('chargeReferences') expect(result).to.be.instanceOf(ChargeCategoryModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/charge-element.model.test.js b/test/models/charge-element.model.test.js index 358bd53a5b..c7a7d25b8b 100644 --- a/test/models/charge-element.model.test.js +++ b/test/models/charge-element.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,16 +48,13 @@ describe('Charge Element model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeElementModel.query() - .innerJoinRelated('chargeReference') + const query = await ChargeElementModel.query().innerJoinRelated('chargeReference') expect(query).to.exist() }) it('can eager load the charge reference', async () => { - const result = await ChargeElementModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeReference') + const result = await ChargeElementModel.query().findById(testRecord.id).withGraphFetched('chargeReference') expect(result).to.be.instanceOf(ChargeElementModel) expect(result.id).to.equal(testRecord.id) @@ -79,16 +76,13 @@ describe('Charge Element model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeElementModel.query() - .innerJoinRelated('purpose') + const query = await ChargeElementModel.query().innerJoinRelated('purpose') expect(query).to.exist() }) it('can eager load the purposes use', async () => { - const result = await ChargeElementModel.query() - .findById(testRecord.id) - .withGraphFetched('purpose') + const result = await ChargeElementModel.query().findById(testRecord.id).withGraphFetched('purpose') expect(result).to.be.instanceOf(ChargeElementModel) expect(result.id).to.equal(testRecord.id) @@ -113,16 +107,13 @@ describe('Charge Element model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeElementModel.query() - .innerJoinRelated('reviewChargeElements') + const query = await ChargeElementModel.query().innerJoinRelated('reviewChargeElements') expect(query).to.exist() }) it('can eager load the review charge elements', async () => { - const result = await ChargeElementModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewChargeElements') + const result = await ChargeElementModel.query().findById(testRecord.id).withGraphFetched('reviewChargeElements') expect(result).to.be.instanceOf(ChargeElementModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/charge-reference.model.test.js b/test/models/charge-reference.model.test.js index aad84f81c0..db55d31954 100644 --- a/test/models/charge-reference.model.test.js +++ b/test/models/charge-reference.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -60,16 +60,13 @@ describe('Charge Reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeReferenceModel.query() - .innerJoinRelated('billRunVolumes') + const query = await ChargeReferenceModel.query().innerJoinRelated('billRunVolumes') expect(query).to.exist() }) it('can eager load the bills', async () => { - const result = await ChargeReferenceModel.query() - .findById(testRecord.id) - .withGraphFetched('billRunVolumes') + const result = await ChargeReferenceModel.query().findById(testRecord.id).withGraphFetched('billRunVolumes') expect(result).to.be.instanceOf(ChargeReferenceModel) expect(result.id).to.equal(testRecord.id) @@ -93,16 +90,13 @@ describe('Charge Reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeReferenceModel.query() - .innerJoinRelated('chargeCategory') + const query = await ChargeReferenceModel.query().innerJoinRelated('chargeCategory') expect(query).to.exist() }) it('can eager load the charge category', async () => { - const result = await ChargeReferenceModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeCategory') + const result = await ChargeReferenceModel.query().findById(testRecord.id).withGraphFetched('chargeCategory') expect(result).to.be.instanceOf(ChargeReferenceModel) expect(result.id).to.equal(testRecord.id) @@ -127,16 +121,13 @@ describe('Charge Reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeReferenceModel.query() - .innerJoinRelated('chargeElements') + const query = await ChargeReferenceModel.query().innerJoinRelated('chargeElements') expect(query).to.exist() }) it('can eager load the charge elements', async () => { - const result = await ChargeReferenceModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeElements') + const result = await ChargeReferenceModel.query().findById(testRecord.id).withGraphFetched('chargeElements') expect(result).to.be.instanceOf(ChargeReferenceModel) expect(result.id).to.equal(testRecord.id) @@ -160,16 +151,13 @@ describe('Charge Reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeReferenceModel.query() - .innerJoinRelated('chargeVersion') + const query = await ChargeReferenceModel.query().innerJoinRelated('chargeVersion') expect(query).to.exist() }) it('can eager load the charge version', async () => { - const result = await ChargeReferenceModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersion') + const result = await ChargeReferenceModel.query().findById(testRecord.id).withGraphFetched('chargeVersion') expect(result).to.be.instanceOf(ChargeReferenceModel) expect(result.id).to.equal(testRecord.id) @@ -191,16 +179,13 @@ describe('Charge Reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeReferenceModel.query() - .innerJoinRelated('purpose') + const query = await ChargeReferenceModel.query().innerJoinRelated('purpose') expect(query).to.exist() }) it('can eager load the purpose', async () => { - const result = await ChargeReferenceModel.query() - .findById(testRecord.id) - .withGraphFetched('purpose') + const result = await ChargeReferenceModel.query().findById(testRecord.id).withGraphFetched('purpose') expect(result).to.be.instanceOf(ChargeReferenceModel) expect(result.chargePurposeId).to.equal(testRecord.chargePurposeId) @@ -225,8 +210,7 @@ describe('Charge Reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeReferenceModel.query() - .innerJoinRelated('reviewChargeReferences') + const query = await ChargeReferenceModel.query().innerJoinRelated('reviewChargeReferences') expect(query).to.exist() }) @@ -261,16 +245,13 @@ describe('Charge Reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeReferenceModel.query() - .innerJoinRelated('transactions') + const query = await ChargeReferenceModel.query().innerJoinRelated('transactions') expect(query).to.exist() }) it('can eager load the transactions', async () => { - const result = await ChargeReferenceModel.query() - .findById(testRecord.id) - .withGraphFetched('transactions') + const result = await ChargeReferenceModel.query().findById(testRecord.id).withGraphFetched('transactions') expect(result).to.be.instanceOf(ChargeReferenceModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/charge-version-note.model.test.js b/test/models/charge-version-note.model.test.js index 9234e792d0..83f5cd2a5e 100644 --- a/test/models/charge-version-note.model.test.js +++ b/test/models/charge-version-note.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -30,8 +30,7 @@ describe('Charge Version Note model', () => { describe('Basic query', () => { it('can successfully run a basic query', async () => { - const result = await ChargeVersionNoteModel.query() - .findById(testRecord.id) + const result = await ChargeVersionNoteModel.query().findById(testRecord.id) expect(result).to.be.an.instanceOf(ChargeVersionNoteModel) expect(result.id).to.be.equal(testRecord.id) @@ -41,16 +40,13 @@ describe('Charge Version Note model', () => { describe('Relationships', () => { describe('when linking to charge version', () => { it('can successfully run a related query', async () => { - const query = await ChargeVersionNoteModel.query() - .innerJoinRelated('chargeVersion') + const query = await ChargeVersionNoteModel.query().innerJoinRelated('chargeVersion') expect(query).to.exist() }) it('can eager load the charge version', async () => { - const result = await ChargeVersionNoteModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersion') + const result = await ChargeVersionNoteModel.query().findById(testRecord.id).withGraphFetched('chargeVersion') expect(result).to.be.instanceOf(ChargeVersionNoteModel) expect(result.id).to.equal(testRecord.id) @@ -62,16 +58,13 @@ describe('Charge Version Note model', () => { describe('when linking to user', () => { it('can successfully run a related query', async () => { - const query = await ChargeVersionNoteModel.query() - .innerJoinRelated('user') + const query = await ChargeVersionNoteModel.query().innerJoinRelated('user') expect(query).to.exist() }) it('can eager load the user', async () => { - const result = await ChargeVersionNoteModel.query() - .findById(testRecord.id) - .withGraphFetched('user') + const result = await ChargeVersionNoteModel.query().findById(testRecord.id).withGraphFetched('user') expect(result).to.be.instanceOf(ChargeVersionNoteModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/charge-version.model.test.js b/test/models/charge-version.model.test.js index 7086969dda..2e4efe2a37 100644 --- a/test/models/charge-version.model.test.js +++ b/test/models/charge-version.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -69,16 +69,13 @@ describe('Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeVersionModel.query() - .innerJoinRelated('billingAccount') + const query = await ChargeVersionModel.query().innerJoinRelated('billingAccount') expect(query).to.exist() }) it('can eager load the billing account', async () => { - const result = await ChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('billingAccount') + const result = await ChargeVersionModel.query().findById(testRecord.id).withGraphFetched('billingAccount') expect(result).to.be.instanceOf(ChargeVersionModel) expect(result.id).to.equal(testRecord.id) @@ -103,8 +100,7 @@ describe('Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeVersionModel.query() - .innerJoinRelated('billRunChargeVersionYears') + const query = await ChargeVersionModel.query().innerJoinRelated('billRunChargeVersionYears') expect(query).to.exist() }) @@ -132,16 +128,13 @@ describe('Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeVersionModel.query() - .innerJoinRelated('changeReason') + const query = await ChargeVersionModel.query().innerJoinRelated('changeReason') expect(query).to.exist() }) it('can eager load the change reason', async () => { - const result = await ChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('changeReason') + const result = await ChargeVersionModel.query().findById(testRecord.id).withGraphFetched('changeReason') expect(result).to.be.instanceOf(ChargeVersionModel) expect(result.id).to.equal(testRecord.id) @@ -166,16 +159,13 @@ describe('Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeVersionModel.query() - .innerJoinRelated('chargeReferences') + const query = await ChargeVersionModel.query().innerJoinRelated('chargeReferences') expect(query).to.exist() }) it('can eager load the charge references', async () => { - const result = await ChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeReferences') + const result = await ChargeVersionModel.query().findById(testRecord.id).withGraphFetched('chargeReferences') expect(result).to.be.instanceOf(ChargeVersionModel) expect(result.id).to.equal(testRecord.id) @@ -199,16 +189,13 @@ describe('Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeVersionModel.query() - .innerJoinRelated('chargeVersionNote') + const query = await ChargeVersionModel.query().innerJoinRelated('chargeVersionNote') expect(query).to.exist() }) it('can eager load the note', async () => { - const result = await ChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersionNote') + const result = await ChargeVersionModel.query().findById(testRecord.id).withGraphFetched('chargeVersionNote') expect(result).to.be.instanceOf(ChargeVersionModel) expect(result.id).to.equal(testRecord.id) @@ -230,16 +217,13 @@ describe('Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeVersionModel.query() - .innerJoinRelated('licence') + const query = await ChargeVersionModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await ChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await ChargeVersionModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(ChargeVersionModel) expect(result.id).to.equal(testRecord.id) @@ -258,7 +242,8 @@ describe('Charge Version model', () => { testModLogs = [] for (let i = 0; i < 2; i++) { const modLog = await ModLogHelper.add({ - chargeVersionId: testRecord.id, licenceRef: testRecord.licenceRef + chargeVersionId: testRecord.id, + licenceRef: testRecord.licenceRef }) testModLogs.push(modLog) @@ -266,16 +251,13 @@ describe('Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeVersionModel.query() - .innerJoinRelated('modLogs') + const query = await ChargeVersionModel.query().innerJoinRelated('modLogs') expect(query).to.exist() }) it('can eager load the mod logs', async () => { - const result = await ChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('modLogs') + const result = await ChargeVersionModel.query().findById(testRecord.id).withGraphFetched('modLogs') expect(result).to.be.instanceOf(ChargeVersionModel) expect(result.id).to.equal(testRecord.id) @@ -302,16 +284,13 @@ describe('Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ChargeVersionModel.query() - .innerJoinRelated('reviewChargeVersions') + const query = await ChargeVersionModel.query().innerJoinRelated('reviewChargeVersions') expect(query).to.exist() }) it('can eager load the review charge versions', async () => { - const result = await ChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewChargeVersions') + const result = await ChargeVersionModel.query().findById(testRecord.id).withGraphFetched('reviewChargeVersions') expect(result).to.be.instanceOf(ChargeVersionModel) expect(result.id).to.equal(testRecord.id) @@ -349,10 +328,14 @@ describe('Charge Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, naldDate: new Date('2012-06-01'), chargeVersionId + externalId: `${regionCode}:${firstNaldId}`, + naldDate: new Date('2012-06-01'), + chargeVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, naldDate: new Date('2012-06-02'), chargeVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + naldDate: new Date('2012-06-02'), + chargeVersionId }) testRecord = await ChargeVersionModel.query().findById(chargeVersionId).modify('history') @@ -505,10 +488,14 @@ describe('Charge Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, note: null, chargeVersionId + externalId: `${regionCode}:${firstNaldId}`, + note: null, + chargeVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, note: null, chargeVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + note: null, + chargeVersionId }) testRecord = await ChargeVersionModel.query().findById(chargeVersionId).modify('history') @@ -528,10 +515,14 @@ describe('Charge Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, note: null, chargeVersionId + externalId: `${regionCode}:${firstNaldId}`, + note: null, + chargeVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, note: 'Transfer per app 12-DEF', chargeVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + note: 'Transfer per app 12-DEF', + chargeVersionId }) testRecord = await ChargeVersionModel.query().findById(chargeVersionId).modify('history') @@ -588,10 +579,14 @@ describe('Charge Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, reasonDescription: null, chargeVersionId + externalId: `${regionCode}:${firstNaldId}`, + reasonDescription: null, + chargeVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, reasonDescription: 'Transferred', chargeVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + reasonDescription: 'Transferred', + chargeVersionId }) testRecord = await ChargeVersionModel.query().findById(chargeVersionId).modify('history') @@ -611,10 +606,14 @@ describe('Charge Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, reasonDescription: 'Formal Variation', chargeVersionId + externalId: `${regionCode}:${firstNaldId}`, + reasonDescription: 'Formal Variation', + chargeVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, reasonDescription: 'Transferred', chargeVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + reasonDescription: 'Transferred', + chargeVersionId }) testRecord = await ChargeVersionModel.query().findById(chargeVersionId).modify('history') diff --git a/test/models/company-address.model.test.js b/test/models/company-address.model.test.js index d4b02bd2b0..6fa7064b77 100644 --- a/test/models/company-address.model.test.js +++ b/test/models/company-address.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,16 +48,13 @@ describe('Company Address model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyAddressModel.query() - .innerJoinRelated('address') + const query = await CompanyAddressModel.query().innerJoinRelated('address') expect(query).to.exist() }) it('can eager load the address', async () => { - const result = await CompanyAddressModel.query() - .findById(testRecord.id) - .withGraphFetched('address') + const result = await CompanyAddressModel.query().findById(testRecord.id).withGraphFetched('address') expect(result).to.be.instanceOf(CompanyAddressModel) expect(result.id).to.equal(testRecord.id) @@ -79,16 +76,13 @@ describe('Company Address model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyAddressModel.query() - .innerJoinRelated('company') + const query = await CompanyAddressModel.query().innerJoinRelated('company') expect(query).to.exist() }) it('can eager load the company', async () => { - const result = await CompanyAddressModel.query() - .findById(testRecord.id) - .withGraphFetched('company') + const result = await CompanyAddressModel.query().findById(testRecord.id).withGraphFetched('company') expect(result).to.be.instanceOf(CompanyAddressModel) expect(result.id).to.equal(testRecord.id) @@ -110,16 +104,13 @@ describe('Company Address model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyAddressModel.query() - .innerJoinRelated('licenceRole') + const query = await CompanyAddressModel.query().innerJoinRelated('licenceRole') expect(query).to.exist() }) it('can eager load the licence role', async () => { - const result = await CompanyAddressModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceRole') + const result = await CompanyAddressModel.query().findById(testRecord.id).withGraphFetched('licenceRole') expect(result).to.be.instanceOf(CompanyAddressModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/company-contact.model.test.js b/test/models/company-contact.model.test.js index 6ba158df58..1e4acae426 100644 --- a/test/models/company-contact.model.test.js +++ b/test/models/company-contact.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,16 +48,13 @@ describe('Company Contacts model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyContactModel.query() - .innerJoinRelated('company') + const query = await CompanyContactModel.query().innerJoinRelated('company') expect(query).to.exist() }) it('can eager load the company', async () => { - const result = await CompanyContactModel.query() - .findById(testRecord.id) - .withGraphFetched('company') + const result = await CompanyContactModel.query().findById(testRecord.id).withGraphFetched('company') expect(result).to.be.instanceOf(CompanyContactModel) expect(result.id).to.equal(testRecord.id) @@ -79,16 +76,13 @@ describe('Company Contacts model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyContactModel.query() - .innerJoinRelated('contact') + const query = await CompanyContactModel.query().innerJoinRelated('contact') expect(query).to.exist() }) it('can eager load the contact', async () => { - const result = await CompanyContactModel.query() - .findById(testRecord.id) - .withGraphFetched('contact') + const result = await CompanyContactModel.query().findById(testRecord.id).withGraphFetched('contact') expect(result).to.be.instanceOf(CompanyContactModel) expect(result.id).to.equal(testRecord.id) @@ -110,16 +104,13 @@ describe('Company Contacts model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyContactModel.query() - .innerJoinRelated('licenceRole') + const query = await CompanyContactModel.query().innerJoinRelated('licenceRole') expect(query).to.exist() }) it('can eager load the licence role', async () => { - const result = await CompanyContactModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceRole') + const result = await CompanyContactModel.query().findById(testRecord.id).withGraphFetched('licenceRole') expect(result).to.be.instanceOf(CompanyContactModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/company.model.test.js b/test/models/company.model.test.js index b07e731b86..ac3da30fbc 100644 --- a/test/models/company.model.test.js +++ b/test/models/company.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -59,16 +59,13 @@ describe('Company model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyModel.query() - .innerJoinRelated('billingAccountAddresses') + const query = await CompanyModel.query().innerJoinRelated('billingAccountAddresses') expect(query).to.exist() }) it('can eager load the billing account addresses', async () => { - const result = await CompanyModel.query() - .findById(testRecord.id) - .withGraphFetched('billingAccountAddresses') + const result = await CompanyModel.query().findById(testRecord.id).withGraphFetched('billingAccountAddresses') expect(result).to.be.instanceOf(CompanyModel) expect(result.id).to.equal(testRecord.id) @@ -96,16 +93,13 @@ describe('Company model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyModel.query() - .innerJoinRelated('billingAccounts') + const query = await CompanyModel.query().innerJoinRelated('billingAccounts') expect(query).to.exist() }) it('can eager load the billing accounts', async () => { - const result = await CompanyModel.query() - .findById(testRecord.id) - .withGraphFetched('billingAccounts') + const result = await CompanyModel.query().findById(testRecord.id).withGraphFetched('billingAccounts') expect(result).to.be.instanceOf(CompanyModel) expect(result.id).to.equal(testRecord.id) @@ -134,16 +128,13 @@ describe('Company model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyModel.query() - .innerJoinRelated('companyAddresses') + const query = await CompanyModel.query().innerJoinRelated('companyAddresses') expect(query).to.exist() }) it('can eager load the company addresses', async () => { - const result = await CompanyModel.query() - .findById(testRecord.id) - .withGraphFetched('companyAddresses') + const result = await CompanyModel.query().findById(testRecord.id).withGraphFetched('companyAddresses') expect(result).to.be.instanceOf(CompanyModel) expect(result.id).to.equal(testRecord.id) @@ -172,16 +163,13 @@ describe('Company model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyModel.query() - .innerJoinRelated('companyContacts') + const query = await CompanyModel.query().innerJoinRelated('companyContacts') expect(query).to.exist() }) it('can eager load the company contacts', async () => { - const result = await CompanyModel.query() - .findById(testRecord.id) - .withGraphFetched('companyContacts') + const result = await CompanyModel.query().findById(testRecord.id).withGraphFetched('companyContacts') expect(result).to.be.instanceOf(CompanyModel) expect(result.id).to.equal(testRecord.id) @@ -210,16 +198,13 @@ describe('Company model', () => { }) it('can successfully run a related query', async () => { - const query = await CompanyModel.query() - .innerJoinRelated('licenceDocumentRoles') + const query = await CompanyModel.query().innerJoinRelated('licenceDocumentRoles') expect(query).to.exist() }) it('can eager load the licence document roles', async () => { - const result = await CompanyModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceDocumentRoles') + const result = await CompanyModel.query().findById(testRecord.id).withGraphFetched('licenceDocumentRoles') expect(result).to.be.instanceOf(CompanyModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/contact.model.test.js b/test/models/contact.model.test.js index d837eb3db6..74efeb5627 100644 --- a/test/models/contact.model.test.js +++ b/test/models/contact.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -55,16 +55,13 @@ describe('Contact model', () => { }) it('can successfully run a related query', async () => { - const query = await ContactModel.query() - .innerJoinRelated('billingAccountAddresses') + const query = await ContactModel.query().innerJoinRelated('billingAccountAddresses') expect(query).to.exist() }) it('can eager load the billing account addresses', async () => { - const result = await ContactModel.query() - .findById(testRecord.id) - .withGraphFetched('billingAccountAddresses') + const result = await ContactModel.query().findById(testRecord.id).withGraphFetched('billingAccountAddresses') expect(result).to.be.instanceOf(ContactModel) expect(result.id).to.equal(testRecord.id) @@ -93,16 +90,13 @@ describe('Contact model', () => { }) it('can successfully run a related query', async () => { - const query = await ContactModel.query() - .innerJoinRelated('companyContacts') + const query = await ContactModel.query().innerJoinRelated('companyContacts') expect(query).to.exist() }) it('can eager load the company contacts', async () => { - const result = await ContactModel.query() - .findById(testRecord.id) - .withGraphFetched('companyContacts') + const result = await ContactModel.query().findById(testRecord.id).withGraphFetched('companyContacts') expect(result).to.be.instanceOf(ContactModel) expect(result.id).to.equal(testRecord.id) @@ -131,16 +125,13 @@ describe('Contact model', () => { }) it('can successfully run a related query', async () => { - const query = await ContactModel.query() - .innerJoinRelated('licenceDocumentRoles') + const query = await ContactModel.query().innerJoinRelated('licenceDocumentRoles') expect(query).to.exist() }) it('can eager load the licence document roles', async () => { - const result = await ContactModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceDocumentRoles') + const result = await ContactModel.query().findById(testRecord.id).withGraphFetched('licenceDocumentRoles') expect(result).to.be.instanceOf(ContactModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/event.model.test.js b/test/models/event.model.test.js index 2b783f2c3c..6e5f572d24 100644 --- a/test/models/event.model.test.js +++ b/test/models/event.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/models/financial-agreement.model.test.js b/test/models/financial-agreement.model.test.js index 3124bde97d..ae339a3c19 100644 --- a/test/models/financial-agreement.model.test.js +++ b/test/models/financial-agreement.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,8 +47,7 @@ describe('Financial Agreement model', () => { }) it('can successfully run a related query', async () => { - const query = await FinancialAgreementModel.query() - .innerJoinRelated('licenceAgreements') + const query = await FinancialAgreementModel.query().innerJoinRelated('licenceAgreements') expect(query).to.exist() }) diff --git a/test/models/group-role.model.test.js b/test/models/group-role.model.test.js index 710d0d90f0..7d9e5fb522 100644 --- a/test/models/group-role.model.test.js +++ b/test/models/group-role.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -35,8 +35,7 @@ describe('Group Role model', () => { describe('Basic query', () => { it('can successfully run a basic query', async () => { - const result = await GroupRoleModel.query() - .findById(testRecord.id) + const result = await GroupRoleModel.query().findById(testRecord.id) expect(result).to.be.an.instanceOf(GroupRoleModel) expect(result.id).to.equal(testRecord.id) @@ -46,16 +45,13 @@ describe('Group Role model', () => { describe('Relationships', () => { describe('when linking to role', () => { it('can successfully run a related query', async () => { - const query = await GroupRoleModel.query() - .innerJoinRelated('role') + const query = await GroupRoleModel.query().innerJoinRelated('role') expect(query).to.exist() }) it('can eager load the role', async () => { - const result = await GroupRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('role') + const result = await GroupRoleModel.query().findById(testRecord.id).withGraphFetched('role') expect(result).to.be.instanceOf(GroupRoleModel) expect(result.id).to.equal(testRecord.id) @@ -67,16 +63,13 @@ describe('Group Role model', () => { describe('when linking to group', () => { it('can successfully run a related query', async () => { - const query = await GroupRoleModel.query() - .innerJoinRelated('group') + const query = await GroupRoleModel.query().innerJoinRelated('group') expect(query).to.exist() }) it('can eager load the group', async () => { - const result = await GroupRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('group') + const result = await GroupRoleModel.query().findById(testRecord.id).withGraphFetched('group') expect(result).to.be.instanceOf(GroupRoleModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/group.model.test.js b/test/models/group.model.test.js index 60ad69076f..deb243ab48 100644 --- a/test/models/group.model.test.js +++ b/test/models/group.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -55,16 +55,13 @@ describe('Group model', () => { describe('Relationships', () => { describe('when linking to group roles', () => { it('can successfully run a related query', async () => { - const query = await GroupModel.query() - .innerJoinRelated('groupRoles') + const query = await GroupModel.query().innerJoinRelated('groupRoles') expect(query).to.exist() }) it('can eager load the group roles', async () => { - const result = await GroupModel.query() - .findById(testRecord.id) - .withGraphFetched('groupRoles') + const result = await GroupModel.query().findById(testRecord.id).withGraphFetched('groupRoles') expect(result).to.be.instanceOf(GroupModel) expect(result.id).to.equal(testRecord.id) @@ -78,16 +75,13 @@ describe('Group model', () => { describe('when linking through group roles to roles', () => { it('can successfully run a related query', async () => { - const query = await GroupModel.query() - .innerJoinRelated('roles') + const query = await GroupModel.query().innerJoinRelated('roles') expect(query).to.exist() }) it('can eager load the roles', async () => { - const result = await GroupModel.query() - .findById(testRecord.id) - .withGraphFetched('roles') + const result = await GroupModel.query().findById(testRecord.id).withGraphFetched('roles') expect(result).to.be.instanceOf(GroupModel) expect(result.id).to.equal(testRecord.id) @@ -101,16 +95,13 @@ describe('Group model', () => { describe('when linking to user groups', () => { it('can successfully run a related query', async () => { - const query = await GroupModel.query() - .innerJoinRelated('userGroups') + const query = await GroupModel.query().innerJoinRelated('userGroups') expect(query).to.exist() }) it('can eager load the user groups', async () => { - const result = await GroupModel.query() - .findById(testRecord.id) - .withGraphFetched('userGroups') + const result = await GroupModel.query().findById(testRecord.id).withGraphFetched('userGroups') expect(result).to.be.instanceOf(GroupModel) expect(result.id).to.equal(testRecord.id) @@ -124,16 +115,13 @@ describe('Group model', () => { describe('when linking through user groups to users', () => { it('can successfully run a related query', async () => { - const query = await GroupModel.query() - .innerJoinRelated('users') + const query = await GroupModel.query().innerJoinRelated('users') expect(query).to.exist() }) it('can eager load the users', async () => { - const result = await GroupModel.query() - .findById(testRecord.id) - .withGraphFetched('users') + const result = await GroupModel.query().findById(testRecord.id).withGraphFetched('users') expect(result).to.be.instanceOf(GroupModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/licence-agreement.model.test.js b/test/models/licence-agreement.model.test.js index 95be0ee1ce..0cb83ceb7d 100644 --- a/test/models/licence-agreement.model.test.js +++ b/test/models/licence-agreement.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,8 +48,7 @@ describe('Licence Agreement model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceAgreementModel.query() - .innerJoinRelated('financialAgreement') + const query = await LicenceAgreementModel.query().innerJoinRelated('financialAgreement') expect(query).to.exist() }) @@ -79,16 +78,13 @@ describe('Licence Agreement model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceAgreementModel.query() - .innerJoinRelated('licence') + const query = await LicenceAgreementModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await LicenceAgreementModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await LicenceAgreementModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(LicenceAgreementModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/licence-document-header.model.test.js b/test/models/licence-document-header.model.test.js index c51dd1b8dd..38e64b74d8 100644 --- a/test/models/licence-document-header.model.test.js +++ b/test/models/licence-document-header.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -44,16 +44,13 @@ describe('Licence Document Header model', () => { describe('Relationships', () => { describe('when linking to licence', () => { it('can successfully run a related query', async () => { - const query = await LicenceDocumentHeaderModel.query() - .innerJoinRelated('licence') + const query = await LicenceDocumentHeaderModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await LicenceDocumentHeaderModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await LicenceDocumentHeaderModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(LicenceDocumentHeaderModel) expect(result.id).to.equal(testRecord.id) @@ -65,8 +62,7 @@ describe('Licence Document Header model', () => { describe('when linking to licence entity role', () => { it('can successfully run a related query', async () => { - const query = await LicenceDocumentHeaderModel.query() - .innerJoinRelated('licenceEntityRole') + const query = await LicenceDocumentHeaderModel.query().innerJoinRelated('licenceEntityRole') expect(query).to.exist() }) diff --git a/test/models/licence-document-role.model.test.js b/test/models/licence-document-role.model.test.js index 92e714c8be..704a051922 100644 --- a/test/models/licence-document-role.model.test.js +++ b/test/models/licence-document-role.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -52,16 +52,13 @@ describe('Licence Document Role model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceDocumentRoleModel.query() - .innerJoinRelated('address') + const query = await LicenceDocumentRoleModel.query().innerJoinRelated('address') expect(query).to.exist() }) it('can eager load the address', async () => { - const result = await LicenceDocumentRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('address') + const result = await LicenceDocumentRoleModel.query().findById(testRecord.id).withGraphFetched('address') expect(result).to.be.instanceOf(LicenceDocumentRoleModel) expect(result.id).to.equal(testRecord.id) @@ -83,16 +80,13 @@ describe('Licence Document Role model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceDocumentRoleModel.query() - .innerJoinRelated('company') + const query = await LicenceDocumentRoleModel.query().innerJoinRelated('company') expect(query).to.exist() }) it('can eager load the company', async () => { - const result = await LicenceDocumentRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('company') + const result = await LicenceDocumentRoleModel.query().findById(testRecord.id).withGraphFetched('company') expect(result).to.be.instanceOf(LicenceDocumentRoleModel) expect(result.id).to.equal(testRecord.id) @@ -114,16 +108,13 @@ describe('Licence Document Role model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceDocumentRoleModel.query() - .innerJoinRelated('contact') + const query = await LicenceDocumentRoleModel.query().innerJoinRelated('contact') expect(query).to.exist() }) it('can eager load the contact', async () => { - const result = await LicenceDocumentRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('contact') + const result = await LicenceDocumentRoleModel.query().findById(testRecord.id).withGraphFetched('contact') expect(result).to.be.instanceOf(LicenceDocumentRoleModel) expect(result.id).to.equal(testRecord.id) @@ -145,8 +136,7 @@ describe('Licence Document Role model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceDocumentRoleModel.query() - .innerJoinRelated('licenceDocument') + const query = await LicenceDocumentRoleModel.query().innerJoinRelated('licenceDocument') expect(query).to.exist() }) @@ -176,16 +166,13 @@ describe('Licence Document Role model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceDocumentRoleModel.query() - .innerJoinRelated('licenceRole') + const query = await LicenceDocumentRoleModel.query().innerJoinRelated('licenceRole') expect(query).to.exist() }) it('can eager load the licence role', async () => { - const result = await LicenceDocumentRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceRole') + const result = await LicenceDocumentRoleModel.query().findById(testRecord.id).withGraphFetched('licenceRole') expect(result).to.be.instanceOf(LicenceDocumentRoleModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/licence-document.model.test.js b/test/models/licence-document.model.test.js index 4c369b0ca9..d9bd86b10d 100644 --- a/test/models/licence-document.model.test.js +++ b/test/models/licence-document.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -46,16 +46,13 @@ describe('Licence Document model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceDocumentModel.query() - .innerJoinRelated('licence') + const query = await LicenceDocumentModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await LicenceDocumentModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await LicenceDocumentModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(LicenceDocumentModel) expect(result.id).to.equal(testRecord.id) @@ -82,8 +79,7 @@ describe('Licence Document model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceDocumentModel.query() - .innerJoinRelated('licenceDocumentRoles') + const query = await LicenceDocumentModel.query().innerJoinRelated('licenceDocumentRoles') expect(query).to.exist() }) diff --git a/test/models/licence-entity-role.model.test.js b/test/models/licence-entity-role.model.test.js index 1ce0915a15..28de8fddc6 100644 --- a/test/models/licence-entity-role.model.test.js +++ b/test/models/licence-entity-role.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -49,16 +49,13 @@ describe('Licence Entity Role model', () => { describe('Relationships', () => { describe('when linking to company entity', () => { it('can successfully run a related query', async () => { - const query = await LicenceEntityRoleModel.query() - .innerJoinRelated('companyEntity') + const query = await LicenceEntityRoleModel.query().innerJoinRelated('companyEntity') expect(query).to.exist() }) it('can eager load the company entity', async () => { - const result = await LicenceEntityRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('companyEntity') + const result = await LicenceEntityRoleModel.query().findById(testRecord.id).withGraphFetched('companyEntity') expect(result).to.be.instanceOf(LicenceEntityRoleModel) expect(result.id).to.equal(testRecord.id) @@ -70,8 +67,7 @@ describe('Licence Entity Role model', () => { describe('when linking to licence document header', () => { it('can successfully run a related query', async () => { - const query = await LicenceEntityRoleModel.query() - .innerJoinRelated('licenceDocumentHeader') + const query = await LicenceEntityRoleModel.query().innerJoinRelated('licenceDocumentHeader') expect(query).to.exist() }) @@ -91,16 +87,13 @@ describe('Licence Entity Role model', () => { describe('when linking to licence entity', () => { it('can successfully run a related query', async () => { - const query = await LicenceEntityRoleModel.query() - .innerJoinRelated('licenceEntity') + const query = await LicenceEntityRoleModel.query().innerJoinRelated('licenceEntity') expect(query).to.exist() }) it('can eager load the licence entity', async () => { - const result = await LicenceEntityRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceEntity') + const result = await LicenceEntityRoleModel.query().findById(testRecord.id).withGraphFetched('licenceEntity') expect(result).to.be.instanceOf(LicenceEntityRoleModel) expect(result.id).to.equal(testRecord.id) @@ -112,16 +105,13 @@ describe('Licence Entity Role model', () => { describe('when linking to regime entity', () => { it('can successfully run a related query', async () => { - const query = await LicenceEntityRoleModel.query() - .innerJoinRelated('regimeEntity') + const query = await LicenceEntityRoleModel.query().innerJoinRelated('regimeEntity') expect(query).to.exist() }) it('can eager load the regime entity', async () => { - const result = await LicenceEntityRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('regimeEntity') + const result = await LicenceEntityRoleModel.query().findById(testRecord.id).withGraphFetched('regimeEntity') expect(result).to.be.instanceOf(LicenceEntityRoleModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/licence-entity.model.test.js b/test/models/licence-entity.model.test.js index b1fb27ef7b..c6f8d8b9a8 100644 --- a/test/models/licence-entity.model.test.js +++ b/test/models/licence-entity.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -49,16 +49,13 @@ describe('Licence Entity model', () => { describe('Relationships', () => { describe('when linking to licence entity roles', () => { it('can successfully run a related query', async () => { - const query = await LicenceEntityModel.query() - .innerJoinRelated('licenceEntityRoles') + const query = await LicenceEntityModel.query().innerJoinRelated('licenceEntityRoles') expect(query).to.exist() }) it('can eager load the licence entity roles', async () => { - const result = await LicenceEntityModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceEntityRoles') + const result = await LicenceEntityModel.query().findById(testRecord.id).withGraphFetched('licenceEntityRoles') expect(result).to.be.instanceOf(LicenceEntityModel) expect(result.id).to.equal(testRecord.id) @@ -72,16 +69,13 @@ describe('Licence Entity model', () => { describe('when linking to user', () => { it('can successfully run a related query', async () => { - const query = await LicenceEntityModel.query() - .innerJoinRelated('user') + const query = await LicenceEntityModel.query().innerJoinRelated('user') expect(query).to.exist() }) it('can eager load the user', async () => { - const result = await LicenceEntityModel.query() - .findById(testRecord.id) - .withGraphFetched('user') + const result = await LicenceEntityModel.query().findById(testRecord.id).withGraphFetched('user') expect(result).to.be.instanceOf(LicenceEntityModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/licence-monitoring-station.model.test.js b/test/models/licence-monitoring-station.model.test.js index 50b31514c1..8c805b6813 100644 --- a/test/models/licence-monitoring-station.model.test.js +++ b/test/models/licence-monitoring-station.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -49,8 +49,7 @@ describe('Licence Monitoring Station model', () => { describe('Relationships', () => { describe('when linking to monitoring station', () => { it('can successfully run a related query', async () => { - const query = await LicenceMonitoringStationModel.query() - .innerJoinRelated('monitoringStation') + const query = await LicenceMonitoringStationModel.query().innerJoinRelated('monitoringStation') expect(query).to.exist() }) @@ -70,16 +69,13 @@ describe('Licence Monitoring Station model', () => { describe('when linking to licence', () => { it('can successfully run a related query', async () => { - const query = await LicenceMonitoringStationModel.query() - .innerJoinRelated('licence') + const query = await LicenceMonitoringStationModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await LicenceMonitoringStationModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await LicenceMonitoringStationModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(LicenceMonitoringStationModel) expect(result.id).to.equal(testRecord.id) @@ -91,8 +87,7 @@ describe('Licence Monitoring Station model', () => { describe('when linking to licence version purpose condition', () => { it('can successfully run a related query', async () => { - const query = await LicenceMonitoringStationModel.query() - .innerJoinRelated('licenceVersionPurposeCondition') + const query = await LicenceMonitoringStationModel.query().innerJoinRelated('licenceVersionPurposeCondition') expect(query).to.exist() }) diff --git a/test/models/licence-role.model.test.js b/test/models/licence-role.model.test.js index b71270da2b..4ec24acedb 100644 --- a/test/models/licence-role.model.test.js +++ b/test/models/licence-role.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -53,16 +53,13 @@ describe('Licence Role model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceRoleModel.query() - .innerJoinRelated('companyAddresses') + const query = await LicenceRoleModel.query().innerJoinRelated('companyAddresses') expect(query).to.exist() }) it('can eager load the company addresses', async () => { - const result = await LicenceRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('companyAddresses') + const result = await LicenceRoleModel.query().findById(testRecord.id).withGraphFetched('companyAddresses') expect(result).to.be.instanceOf(LicenceRoleModel) expect(result.id).to.equal(testRecord.id) @@ -91,16 +88,13 @@ describe('Licence Role model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceRoleModel.query() - .innerJoinRelated('companyContacts') + const query = await LicenceRoleModel.query().innerJoinRelated('companyContacts') expect(query).to.exist() }) it('can eager load the company contacts', async () => { - const result = await LicenceRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('companyContacts') + const result = await LicenceRoleModel.query().findById(testRecord.id).withGraphFetched('companyContacts') expect(result).to.be.instanceOf(LicenceRoleModel) expect(result.id).to.equal(testRecord.id) @@ -129,16 +123,13 @@ describe('Licence Role model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceRoleModel.query() - .innerJoinRelated('licenceDocumentRoles') + const query = await LicenceRoleModel.query().innerJoinRelated('licenceDocumentRoles') expect(query).to.exist() }) it('can eager load the licence document roles', async () => { - const result = await LicenceRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceDocumentRoles') + const result = await LicenceRoleModel.query().findById(testRecord.id).withGraphFetched('licenceDocumentRoles') expect(result).to.be.instanceOf(LicenceRoleModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/licence-supplementary-year.model.test.js b/test/models/licence-supplementary-year.model.test.js index 179c421136..19b8460f8a 100644 --- a/test/models/licence-supplementary-year.model.test.js +++ b/test/models/licence-supplementary-year.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -44,16 +44,13 @@ describe('Licence Supplementary Year model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceSupplementaryYearModel.query() - .innerJoinRelated('licence') + const query = await LicenceSupplementaryYearModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await LicenceSupplementaryYearModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await LicenceSupplementaryYearModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(LicenceSupplementaryYearModel) expect(result.id).to.equal(testRecord.id) @@ -73,16 +70,13 @@ describe('Licence Supplementary Year model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceSupplementaryYearModel.query() - .innerJoinRelated('billRun') + const query = await LicenceSupplementaryYearModel.query().innerJoinRelated('billRun') expect(query).to.exist() }) it('can eager load the bill run', async () => { - const result = await LicenceSupplementaryYearModel.query() - .findById(testRecord.id) - .withGraphFetched('billRun') + const result = await LicenceSupplementaryYearModel.query().findById(testRecord.id).withGraphFetched('billRun') expect(result).to.be.instanceOf(LicenceSupplementaryYearModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/licence-version-purpose-condition-type.model.test.js b/test/models/licence-version-purpose-condition-type.model.test.js index 928edd639c..88e104f886 100644 --- a/test/models/licence-version-purpose-condition-type.model.test.js +++ b/test/models/licence-version-purpose-condition-type.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -20,8 +20,9 @@ describe('Licence Version Purposes Condition Type model', () => { describe('Basic query', () => { it('can successfully run a basic query', async () => { - const result = await LicenceVersionPurposeConditionTypeModel - .query().findById(licenceVersionPurposeConditionType.id) + const result = await LicenceVersionPurposeConditionTypeModel.query().findById( + licenceVersionPurposeConditionType.id + ) expect(result).to.be.an.instanceOf(LicenceVersionPurposeConditionTypeModel) expect(result.id).to.equal(licenceVersionPurposeConditionType.id) @@ -39,8 +40,9 @@ describe('Licence Version Purposes Condition Type model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeConditionTypeModel.query() - .innerJoinRelated('licenceVersionPurposeConditions') + const query = await LicenceVersionPurposeConditionTypeModel.query().innerJoinRelated( + 'licenceVersionPurposeConditions' + ) expect(query).to.exist() }) diff --git a/test/models/licence-version-purpose-condition.model.test.js b/test/models/licence-version-purpose-condition.model.test.js index 1cb3cdbcee..1f470a2ab2 100644 --- a/test/models/licence-version-purpose-condition.model.test.js +++ b/test/models/licence-version-purpose-condition.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -56,8 +56,7 @@ describe('Licence Version Purpose Condition model', () => { describe('Relationships', () => { describe('when linking to licence monitoring stations', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeConditionModel.query() - .innerJoinRelated('licenceMonitoringStations') + const query = await LicenceVersionPurposeConditionModel.query().innerJoinRelated('licenceMonitoringStations') expect(query).to.exist() }) @@ -79,8 +78,7 @@ describe('Licence Version Purpose Condition model', () => { describe('when linking to licence version purpose', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeConditionModel.query() - .innerJoinRelated('licenceVersionPurpose') + const query = await LicenceVersionPurposeConditionModel.query().innerJoinRelated('licenceVersionPurpose') expect(query).to.exist() }) @@ -100,8 +98,9 @@ describe('Licence Version Purpose Condition model', () => { describe('when linking to licence version purpose condition type', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeConditionModel.query() - .innerJoinRelated('licenceVersionPurposeConditionType') + const query = await LicenceVersionPurposeConditionModel.query().innerJoinRelated( + 'licenceVersionPurposeConditionType' + ) expect(query).to.exist() }) @@ -115,10 +114,9 @@ describe('Licence Version Purpose Condition model', () => { expect(result.id).to.equal(testRecord.id) expect(result.licenceVersionPurposeConditionType).to.be.an.instanceOf(LicenceVersionPurposeConditionTypeModel) - expect(result.licenceVersionPurposeConditionType).to.equal( - testLicenceVersionPurposeConditionType, - { skip: ['createdAt', 'updatedAt'] } - ) + expect(result.licenceVersionPurposeConditionType).to.equal(testLicenceVersionPurposeConditionType, { + skip: ['createdAt', 'updatedAt'] + }) }) }) }) diff --git a/test/models/licence-version-purpose-point.model.test.js b/test/models/licence-version-purpose-point.model.test.js index 29ed6f538b..3232c69c07 100644 --- a/test/models/licence-version-purpose-point.model.test.js +++ b/test/models/licence-version-purpose-point.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -27,7 +27,8 @@ describe('Licence Version Purpose Point model', () => { testPoint = await PointHelper.add() testRecord = await LicenceVersionPurposePointHelper.add({ - licenceVersionPurposeId: testLicenceVersionPurpose.id, pointId: testPoint.id + licenceVersionPurposeId: testLicenceVersionPurpose.id, + pointId: testPoint.id }) }) @@ -43,8 +44,7 @@ describe('Licence Version Purpose Point model', () => { describe('Relationships', () => { describe('when linking to licence version purpose', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposePointModel.query() - .innerJoinRelated('licenceVersionPurpose') + const query = await LicenceVersionPurposePointModel.query().innerJoinRelated('licenceVersionPurpose') expect(query).to.exist() }) @@ -64,16 +64,13 @@ describe('Licence Version Purpose Point model', () => { describe('when linking to point', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposePointModel.query() - .innerJoinRelated('point') + const query = await LicenceVersionPurposePointModel.query().innerJoinRelated('point') expect(query).to.exist() }) it('can eager load the point', async () => { - const result = await LicenceVersionPurposePointModel.query() - .findById(testRecord.id) - .withGraphFetched('point') + const result = await LicenceVersionPurposePointModel.query().findById(testRecord.id).withGraphFetched('point') expect(result).to.be.instanceOf(LicenceVersionPurposePointModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/licence-version-purpose.model.test.js b/test/models/licence-version-purpose.model.test.js index 77f2c73a16..e60fb40ee1 100644 --- a/test/models/licence-version-purpose.model.test.js +++ b/test/models/licence-version-purpose.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -46,7 +46,10 @@ describe('Licence Version Purpose model', () => { testLicenceVersion = await LicenceVersionHelper.add() testRecord = await LicenceVersionPurposeHelper.add({ - licenceVersionId: testLicenceVersion.id, primaryPurposeId, purposeId, secondaryPurposeId + licenceVersionId: testLicenceVersion.id, + primaryPurposeId, + purposeId, + secondaryPurposeId }) testPoint = await PointHelper.add() @@ -81,8 +84,7 @@ describe('Licence Version Purpose model', () => { describe('Relationships', () => { describe('when linking to licence version', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeModel.query() - .innerJoinRelated('licenceVersion') + const query = await LicenceVersionPurposeModel.query().innerJoinRelated('licenceVersion') expect(query).to.exist() }) @@ -102,8 +104,7 @@ describe('Licence Version Purpose model', () => { describe('when linking to licence version purpose conditions', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeModel.query() - .innerJoinRelated('licenceVersionPurposeConditions') + const query = await LicenceVersionPurposeModel.query().innerJoinRelated('licenceVersionPurposeConditions') expect(query).to.exist() }) @@ -125,8 +126,7 @@ describe('Licence Version Purpose model', () => { describe('when linking to licence version purpose points', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeModel.query() - .innerJoinRelated('licenceVersionPurposePoints') + const query = await LicenceVersionPurposeModel.query().innerJoinRelated('licenceVersionPurposePoints') expect(query).to.exist() }) @@ -148,16 +148,13 @@ describe('Licence Version Purpose model', () => { describe('when linking through licence version purpose points to points', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeModel.query() - .innerJoinRelated('points') + const query = await LicenceVersionPurposeModel.query().innerJoinRelated('points') expect(query).to.exist() }) it('can eager load the points', async () => { - const result = await LicenceVersionPurposeModel.query() - .findById(testRecord.id) - .withGraphFetched('points') + const result = await LicenceVersionPurposeModel.query().findById(testRecord.id).withGraphFetched('points') expect(result).to.be.instanceOf(LicenceVersionPurposeModel) expect(result.id).to.equal(testRecord.id) @@ -171,8 +168,7 @@ describe('Licence Version Purpose model', () => { describe('when linking to primary purpose', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeModel.query() - .innerJoinRelated('primaryPurpose') + const query = await LicenceVersionPurposeModel.query().innerJoinRelated('primaryPurpose') expect(query).to.exist() }) @@ -192,16 +188,13 @@ describe('Licence Version Purpose model', () => { describe('when linking to purpose', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeModel.query() - .innerJoinRelated('purpose') + const query = await LicenceVersionPurposeModel.query().innerJoinRelated('purpose') expect(query).to.exist() }) it('can eager load the purpose', async () => { - const result = await LicenceVersionPurposeModel.query() - .findById(testRecord.id) - .withGraphFetched('purpose') + const result = await LicenceVersionPurposeModel.query().findById(testRecord.id).withGraphFetched('purpose') expect(result).to.be.instanceOf(LicenceVersionPurposeModel) expect(result.id).to.equal(testRecord.id) @@ -213,8 +206,7 @@ describe('Licence Version Purpose model', () => { describe('when linking to secondary purpose', () => { it('can successfully run a related query', async () => { - const query = await LicenceVersionPurposeModel.query() - .innerJoinRelated('secondaryPurpose') + const query = await LicenceVersionPurposeModel.query().innerJoinRelated('secondaryPurpose') expect(query).to.exist() }) diff --git a/test/models/licence-version.model.test.js b/test/models/licence-version.model.test.js index a566b93158..a4f2fc7f33 100644 --- a/test/models/licence-version.model.test.js +++ b/test/models/licence-version.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -53,16 +53,13 @@ describe('Licence Version model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceVersionModel.query() - .innerJoinRelated('licence') + const query = await LicenceVersionModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await LicenceVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await LicenceVersionModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(LicenceVersionModel) expect(result.id).to.equal(testRecord.id) @@ -87,16 +84,13 @@ describe('Licence Version model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceVersionModel.query() - .innerJoinRelated('modLogs') + const query = await LicenceVersionModel.query().innerJoinRelated('modLogs') expect(query).to.exist() }) it('can eager load the mod logs', async () => { - const result = await LicenceVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('modLogs') + const result = await LicenceVersionModel.query().findById(testRecord.id).withGraphFetched('modLogs') expect(result).to.be.instanceOf(LicenceVersionModel) expect(result.id).to.equal(testRecord.id) @@ -124,16 +118,13 @@ describe('Licence Version model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceVersionModel.query() - .innerJoinRelated('purposes') + const query = await LicenceVersionModel.query().innerJoinRelated('purposes') expect(query).to.exist() }) it('can eager load the purposes', async () => { - const result = await LicenceVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('purposes') + const result = await LicenceVersionModel.query().findById(testRecord.id).withGraphFetched('purposes') expect(result).to.be.instanceOf(LicenceVersionModel) expect(result.id).to.equal(testRecord.id) @@ -163,10 +154,14 @@ describe('Licence Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, naldDate: new Date('2012-06-01'), licenceVersionId + externalId: `${regionCode}:${firstNaldId}`, + naldDate: new Date('2012-06-01'), + licenceVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, naldDate: new Date('2012-06-02'), licenceVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + naldDate: new Date('2012-06-02'), + licenceVersionId }) testRecord = await LicenceVersionModel.query().findById(licenceVersionId).modify('history') @@ -233,10 +228,14 @@ describe('Licence Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, note: null, licenceVersionId + externalId: `${regionCode}:${firstNaldId}`, + note: null, + licenceVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, note: null, licenceVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + note: null, + licenceVersionId }) testRecord = await LicenceVersionModel.query().findById(licenceVersionId).modify('history') @@ -256,10 +255,14 @@ describe('Licence Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, note: null, licenceVersionId + externalId: `${regionCode}:${firstNaldId}`, + note: null, + licenceVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, note: 'Transfer per app 12-DEF', licenceVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + note: 'Transfer per app 12-DEF', + licenceVersionId }) testRecord = await LicenceVersionModel.query().findById(licenceVersionId).modify('history') @@ -294,10 +297,14 @@ describe('Licence Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, reasonDescription: null, licenceVersionId + externalId: `${regionCode}:${firstNaldId}`, + reasonDescription: null, + licenceVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, reasonDescription: 'New licence', licenceVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + reasonDescription: 'New licence', + licenceVersionId }) testRecord = await LicenceVersionModel.query().findById(licenceVersionId).modify('history') @@ -316,10 +323,14 @@ describe('Licence Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, reasonDescription: 'New licence', licenceVersionId + externalId: `${regionCode}:${firstNaldId}`, + reasonDescription: 'New licence', + licenceVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, reasonDescription: 'Transferred', licenceVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + reasonDescription: 'Transferred', + licenceVersionId }) testRecord = await LicenceVersionModel.query().findById(licenceVersionId).modify('history') diff --git a/test/models/licence.model.test.js b/test/models/licence.model.test.js index 8b67f8b6da..61d1ce03bb 100644 --- a/test/models/licence.model.test.js +++ b/test/models/licence.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -76,7 +76,8 @@ describe('Licence model', () => { testBillLicences = [] for (let i = 0; i < 2; i++) { const billLicence = await BillLicenceHelper.add({ - licenceRef: testRecord.licenceRef, licenceId: testRecord.id + licenceRef: testRecord.licenceRef, + licenceId: testRecord.id }) testBillLicences.push(billLicence) @@ -84,16 +85,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('billLicences') + const query = await LicenceModel.query().innerJoinRelated('billLicences') expect(query).to.exist() }) it('can eager load the bill licences', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('billLicences') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('billLicences') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -114,7 +112,8 @@ describe('Licence model', () => { testChargeVersions = [] for (let i = 0; i < 2; i++) { const chargeVersion = await ChargeVersionHelper.add({ - licenceRef: testRecord.licenceRef, licenceId: testRecord.id + licenceRef: testRecord.licenceRef, + licenceId: testRecord.id }) testChargeVersions.push(chargeVersion) @@ -122,16 +121,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('chargeVersions') + const query = await LicenceModel.query().innerJoinRelated('chargeVersions') expect(query).to.exist() }) it('can eager load the charge versions', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersions') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('chargeVersions') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -158,16 +154,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('licenceAgreements') + const query = await LicenceModel.query().innerJoinRelated('licenceAgreements') expect(query).to.exist() }) it('can eager load the licence agreements', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceAgreements') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('licenceAgreements') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -191,16 +184,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('licenceDocument') + const query = await LicenceModel.query().innerJoinRelated('licenceDocument') expect(query).to.exist() }) it('can eager load the licence document', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceDocument') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('licenceDocument') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -222,16 +212,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('licenceDocumentHeader') + const query = await LicenceModel.query().innerJoinRelated('licenceDocumentHeader') expect(query).to.exist() }) it('can eager load the licence document header', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceDocumentHeader') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('licenceDocumentHeader') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -256,16 +243,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('licenceMonitoringStations') + const query = await LicenceModel.query().innerJoinRelated('licenceMonitoringStations') expect(query).to.exist() }) it('can eager load the licence monitoring stations', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceMonitoringStations') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('licenceMonitoringStations') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -292,16 +276,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('licenceSupplementaryYears') + const query = await LicenceModel.query().innerJoinRelated('licenceSupplementaryYears') expect(query).to.exist() }) it('can eager load the licence supplementary years', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceSupplementaryYears') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('licenceSupplementaryYears') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -328,16 +309,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('licenceVersions') + const query = await LicenceModel.query().innerJoinRelated('licenceVersions') expect(query).to.exist() }) it('can eager load the licence versions', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceVersions') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('licenceVersions') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -358,7 +336,8 @@ describe('Licence model', () => { testModLogs = [] for (let i = 0; i < 2; i++) { const modLog = await ModLogHelper.add({ - licenceRef: testRecord.licenceRef, licenceId: testRecord.id + licenceRef: testRecord.licenceRef, + licenceId: testRecord.id }) testModLogs.push(modLog) @@ -366,16 +345,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('modLogs') + const query = await LicenceModel.query().innerJoinRelated('modLogs') expect(query).to.exist() }) it('can eager load the mod logs', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('modLogs') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('modLogs') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -399,16 +375,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('region') + const query = await LicenceModel.query().innerJoinRelated('region') expect(query).to.exist() }) it('can eager load the region', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('region') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('region') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -433,16 +406,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('returnLogs') + const query = await LicenceModel.query().innerJoinRelated('returnLogs') expect(query).to.exist() }) it('can eager load the return logs', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('returnLogs') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('returnLogs') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -469,16 +439,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('returnVersions') + const query = await LicenceModel.query().innerJoinRelated('returnVersions') expect(query).to.exist() }) it('can eager load the return versions', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('returnVersions') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('returnVersions') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -505,16 +472,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('reviewLicences') + const query = await LicenceModel.query().innerJoinRelated('reviewLicences') expect(query).to.exist() }) it('can eager load the workflows', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewLicences') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('reviewLicences') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -541,16 +505,13 @@ describe('Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await LicenceModel.query() - .innerJoinRelated('workflows') + const query = await LicenceModel.query().innerJoinRelated('workflows') expect(query).to.exist() }) it('can eager load the workflows', async () => { - const result = await LicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('workflows') + const result = await LicenceModel.query().findById(testRecord.id).withGraphFetched('workflows') expect(result).to.be.instanceOf(LicenceModel) expect(result.id).to.equal(testRecord.id) @@ -902,7 +863,8 @@ describe('Licence model', () => { const licence = await LicenceHelper.add() await LicenceDocumentHeaderHelper.add({ - licenceRef: licence.licenceRef, licenceName: 'My custom licence name' + licenceRef: licence.licenceRef, + licenceName: 'My custom licence name' }) testRecord = await LicenceModel.query().findById(licence.id).modify('licenceName') @@ -939,11 +901,15 @@ describe('Licence model', () => { primaryUser = await UserHelper.add({ application: 'water_vml', licenceEntityId: licenceEntity.id, username }) await LicenceEntityRoleHelper.add({ - companyEntityId, licenceEntityId: licenceEntity.id, role: 'primary_user' + companyEntityId, + licenceEntityId: licenceEntity.id, + role: 'primary_user' }) await LicenceDocumentHeaderHelper.add({ - companyEntityId, licenceRef: licence.licenceRef, licenceName: 'My custom licence name' + companyEntityId, + licenceRef: licence.licenceRef, + licenceName: 'My custom licence name' }) testRecord = await LicenceModel.query().findById(licence.id).modify('primaryUser') diff --git a/test/models/mod-log.model.test.js b/test/models/mod-log.model.test.js index 2bb5b4c1ea..920f1c67e9 100644 --- a/test/models/mod-log.model.test.js +++ b/test/models/mod-log.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -31,7 +31,8 @@ describe('Mod Log model', () => { before(async () => { testLicence = await LicenceHelper.add() testChargeVersion = await ChargeVersionHelper.add({ - licenceId: testLicence.id, licenceRef: testLicence.licenceRef + licenceId: testLicence.id, + licenceRef: testLicence.licenceRef }) testLicenceVersion = await LicenceVersionHelper.add({ licenceId: testLicence.id }) testReturnVersion = await ReturnVersionHelper.add({ licenceId: testLicence.id }) @@ -60,16 +61,13 @@ describe('Mod Log model', () => { describe('Relationships', () => { describe('when linking to charge version', () => { it('can successfully run a related query', async () => { - const query = await ModLogModel.query() - .innerJoinRelated('chargeVersion') + const query = await ModLogModel.query().innerJoinRelated('chargeVersion') expect(query).to.exist() }) it('can eager load the charge version', async () => { - const result = await ModLogModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersion') + const result = await ModLogModel.query().findById(testRecord.id).withGraphFetched('chargeVersion') expect(result).to.be.instanceOf(ModLogModel) expect(result.id).to.equal(testRecord.id) @@ -81,16 +79,13 @@ describe('Mod Log model', () => { describe('when linking to licence', () => { it('can successfully run a related query', async () => { - const query = await ModLogModel.query() - .innerJoinRelated('licence') + const query = await ModLogModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await ModLogModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await ModLogModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(ModLogModel) expect(result.id).to.equal(testRecord.id) @@ -102,16 +97,13 @@ describe('Mod Log model', () => { describe('when linking to licence version', () => { it('can successfully run a related query', async () => { - const query = await ModLogModel.query() - .innerJoinRelated('licenceVersion') + const query = await ModLogModel.query().innerJoinRelated('licenceVersion') expect(query).to.exist() }) it('can eager load the licence version', async () => { - const result = await ModLogModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceVersion') + const result = await ModLogModel.query().findById(testRecord.id).withGraphFetched('licenceVersion') expect(result).to.be.instanceOf(ModLogModel) expect(result.id).to.equal(testRecord.id) @@ -123,16 +115,13 @@ describe('Mod Log model', () => { describe('when linking to return version', () => { it('can successfully run a related query', async () => { - const query = await ModLogModel.query() - .innerJoinRelated('returnVersion') + const query = await ModLogModel.query().innerJoinRelated('returnVersion') expect(query).to.exist() }) it('can eager load the return version', async () => { - const result = await ModLogModel.query() - .findById(testRecord.id) - .withGraphFetched('returnVersion') + const result = await ModLogModel.query().findById(testRecord.id).withGraphFetched('returnVersion') expect(result).to.be.instanceOf(ModLogModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/monitoring-station.model.test.js b/test/models/monitoring-station.model.test.js index 89cbf448cc..c203469e3e 100644 --- a/test/models/monitoring-station.model.test.js +++ b/test/models/monitoring-station.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -24,9 +24,7 @@ describe('Monitoring Station model', () => { testLicenceMonitoringStations = [] for (let i = 0; i < 2; i++) { - const licenceMonitoringStation = await LicenceMonitoringStationHelper.add( - { monitoringStationId: testRecord.id } - ) + const licenceMonitoringStation = await LicenceMonitoringStationHelper.add({ monitoringStationId: testRecord.id }) testLicenceMonitoringStations.push(licenceMonitoringStation) } @@ -44,8 +42,7 @@ describe('Monitoring Station model', () => { describe('Relationships', () => { describe('when linking to licence monitoring stations', () => { it('can successfully run a related query', async () => { - const query = await MonitoringStationModel.query() - .innerJoinRelated('licenceMonitoringStations') + const query = await MonitoringStationModel.query().innerJoinRelated('licenceMonitoringStations') expect(query).to.exist() }) diff --git a/test/models/point.model.test.js b/test/models/point.model.test.js index 0863b3eee7..471e6c6b38 100644 --- a/test/models/point.model.test.js +++ b/test/models/point.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -33,12 +33,14 @@ describe('Point model', () => { testReturnRequirement = await ReturnRequirementHelper.add() await ReturnRequirementPointHelper.add({ - pointId: testRecord.id, returnRequirementId: testReturnRequirement.id + pointId: testRecord.id, + returnRequirementId: testReturnRequirement.id }) testLicenceVersionPurpose = await LicenceVersionPurposeHelper.add() await LicenceVersionPurposePointHelper.add({ - licenceVersionPurposeId: testLicenceVersionPurpose.id, pointId: testRecord.id + licenceVersionPurposeId: testLicenceVersionPurpose.id, + pointId: testRecord.id }) }) @@ -54,16 +56,13 @@ describe('Point model', () => { describe('Relationships', () => { describe('when linking through licence version purpose points to licence version purposes', () => { it('can successfully run a related query', async () => { - const query = await PointModel.query() - .innerJoinRelated('licenceVersionPurposes') + const query = await PointModel.query().innerJoinRelated('licenceVersionPurposes') expect(query).to.exist() }) it('can eager load the licence version purposes', async () => { - const result = await PointModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceVersionPurposes') + const result = await PointModel.query().findById(testRecord.id).withGraphFetched('licenceVersionPurposes') expect(result).to.be.instanceOf(PointModel) expect(result.id).to.equal(testRecord.id) @@ -71,24 +70,21 @@ describe('Point model', () => { expect(result.licenceVersionPurposes).to.be.an.array() expect(result.licenceVersionPurposes).to.have.length(1) expect(result.licenceVersionPurposes[0]).to.be.an.instanceOf(LicenceVersionPurposeModel) - expect(result.licenceVersionPurposes[0]).to.equal( - testLicenceVersionPurpose, { skip: ['createdAt', 'updatedAt'] } - ) + expect(result.licenceVersionPurposes[0]).to.equal(testLicenceVersionPurpose, { + skip: ['createdAt', 'updatedAt'] + }) }) }) describe('when linking through return requirement points to return requirements', () => { it('can successfully run a related query', async () => { - const query = await PointModel.query() - .innerJoinRelated('returnRequirements') + const query = await PointModel.query().innerJoinRelated('returnRequirements') expect(query).to.exist() }) it('can eager load the return requirements', async () => { - const result = await PointModel.query() - .findById(testRecord.id) - .withGraphFetched('returnRequirements') + const result = await PointModel.query().findById(testRecord.id).withGraphFetched('returnRequirements') expect(result).to.be.instanceOf(PointModel) expect(result.id).to.equal(testRecord.id) @@ -102,16 +98,13 @@ describe('Point model', () => { describe('when linking to source', () => { it('can successfully run a related query', async () => { - const query = await PointModel.query() - .innerJoinRelated('source') + const query = await PointModel.query().innerJoinRelated('source') expect(query).to.exist() }) it('can eager load the source', async () => { - const result = await PointModel.query() - .findById(testRecord.id) - .withGraphFetched('source') + const result = await PointModel.query().findById(testRecord.id).withGraphFetched('source') expect(result).to.be.instanceOf(PointModel) expect(result.id).to.equal(testRecord.id) @@ -178,7 +171,10 @@ describe('Point model', () => { describe('when the instance represents an "area" (4 grid references)', () => { beforeEach(() => { testRecord = PointModel.fromJson({ - ngr1: 'ST 58212 72697', ngr2: 'ST 58151 72683', ngr3: 'ST 58145 72727', ngr4: 'ST 58222 72744' + ngr1: 'ST 58212 72697', + ngr2: 'ST 58151 72683', + ngr3: 'ST 58145 72727', + ngr4: 'ST 58222 72744' }) }) @@ -190,7 +186,9 @@ describe('Point model', () => { it('returns an "area" description including the supplementary', () => { const result = testRecord.$describe() - expect(result).to.equal('Within the area formed by the straight lines running between National Grid References ST 58212 72697, ST 58151 72683, ST 58145 72727 and ST 58222 72744 (Head office)') + expect(result).to.equal( + 'Within the area formed by the straight lines running between National Grid References ST 58212 72697, ST 58151 72683, ST 58145 72727 and ST 58222 72744 (Head office)' + ) }) }) @@ -198,7 +196,9 @@ describe('Point model', () => { it('returns just the "area" description', () => { const result = testRecord.$describe() - expect(result).to.equal('Within the area formed by the straight lines running between National Grid References ST 58212 72697, ST 58151 72683, ST 58145 72727 and ST 58222 72744') + expect(result).to.equal( + 'Within the area formed by the straight lines running between National Grid References ST 58212 72697, ST 58151 72683, ST 58145 72727 and ST 58222 72744' + ) }) }) }) diff --git a/test/models/primary-purpose.model.test.js b/test/models/primary-purpose.model.test.js index 2763431d08..7b47bee36b 100644 --- a/test/models/primary-purpose.model.test.js +++ b/test/models/primary-purpose.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -43,7 +43,8 @@ describe('Primary Purpose model', () => { testLicenceVersionPurposes = [] for (let i = 0; i < 2; i++) { const licenceVersionPurpose = await LicenceVersionPurposeHelper.add({ - notes: `TEST licence Version purpose ${i}`, primaryPurposeId: testRecord.id + notes: `TEST licence Version purpose ${i}`, + primaryPurposeId: testRecord.id }) testLicenceVersionPurposes.push(licenceVersionPurpose) @@ -51,8 +52,7 @@ describe('Primary Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await PrimaryPurposeModel.query() - .innerJoinRelated('licenceVersionPurposes') + const query = await PrimaryPurposeModel.query().innerJoinRelated('licenceVersionPurposes') expect(query).to.exist() }) @@ -81,7 +81,8 @@ describe('Primary Purpose model', () => { testReturnRequirementPurposes = [] for (let i = 0; i < 2; i++) { const returnRequirementPurpose = await ReturnRequirementPurposeHelper.add({ - alias: `TEST return requirement purpose ${i}`, primaryPurposeId: testRecord.id + alias: `TEST return requirement purpose ${i}`, + primaryPurposeId: testRecord.id }) testReturnRequirementPurposes.push(returnRequirementPurpose) @@ -89,8 +90,7 @@ describe('Primary Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await PrimaryPurposeModel.query() - .innerJoinRelated('returnRequirementPurposes') + const query = await PrimaryPurposeModel.query().innerJoinRelated('returnRequirementPurposes') expect(query).to.exist() }) diff --git a/test/models/purpose.model.test.js b/test/models/purpose.model.test.js index a7b3a78b79..b7fc77a578 100644 --- a/test/models/purpose.model.test.js +++ b/test/models/purpose.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -53,16 +53,13 @@ describe('Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await PurposeModel.query() - .innerJoinRelated('chargeElements') + const query = await PurposeModel.query().innerJoinRelated('chargeElements') expect(query).to.exist() }) it('can eager load the charge elements', async () => { - const result = await PurposeModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeElements') + const result = await PurposeModel.query().findById(testRecord.id).withGraphFetched('chargeElements') expect(result).to.be.instanceOf(PurposeModel) expect(result.id).to.equal(testRecord.id) @@ -89,16 +86,13 @@ describe('Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await PurposeModel.query() - .innerJoinRelated('chargeReferences') + const query = await PurposeModel.query().innerJoinRelated('chargeReferences') expect(query).to.exist() }) it('can eager load the charge references', async () => { - const result = await PurposeModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeReferences') + const result = await PurposeModel.query().findById(testRecord.id).withGraphFetched('chargeReferences') expect(result).to.be.instanceOf(PurposeModel) expect(result.id).to.equal(testRecord.id) @@ -125,16 +119,13 @@ describe('Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await PurposeModel.query() - .innerJoinRelated('licenceVersionPurposes') + const query = await PurposeModel.query().innerJoinRelated('licenceVersionPurposes') expect(query).to.exist() }) it('can eager load the licence version purposes', async () => { - const result = await PurposeModel.query() - .findById(testRecord.id) - .withGraphFetched('licenceVersionPurposes') + const result = await PurposeModel.query().findById(testRecord.id).withGraphFetched('licenceVersionPurposes') expect(result).to.be.instanceOf(PurposeModel) expect(result.id).to.equal(testRecord.id) @@ -161,16 +152,13 @@ describe('Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await PurposeModel.query() - .innerJoinRelated('returnRequirementPurposes') + const query = await PurposeModel.query().innerJoinRelated('returnRequirementPurposes') expect(query).to.exist() }) it('can eager load the return requirement purposes', async () => { - const result = await PurposeModel.query() - .findById(testRecord.id) - .withGraphFetched('returnRequirementPurposes') + const result = await PurposeModel.query().findById(testRecord.id).withGraphFetched('returnRequirementPurposes') expect(result).to.be.instanceOf(PurposeModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/region.model.test.js b/test/models/region.model.test.js index b96fad7027..9de4139d5f 100644 --- a/test/models/region.model.test.js +++ b/test/models/region.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -49,16 +49,13 @@ describe('Region model', () => { }) it('can successfully run a related query', async () => { - const query = await RegionModel.query() - .innerJoinRelated('billRuns') + const query = await RegionModel.query().innerJoinRelated('billRuns') expect(query).to.exist() }) it('can eager load the bill runs', async () => { - const result = await RegionModel.query() - .findById(testRecord.id) - .withGraphFetched('billRuns') + const result = await RegionModel.query().findById(testRecord.id).withGraphFetched('billRuns') expect(result).to.be.instanceOf(RegionModel) expect(result.id).to.equal(testRecord.id) @@ -85,16 +82,13 @@ describe('Region model', () => { }) it('can successfully run a related query', async () => { - const query = await RegionModel.query() - .innerJoinRelated('licences') + const query = await RegionModel.query().innerJoinRelated('licences') expect(query).to.exist() }) it('can eager load the licences', async () => { - const result = await RegionModel.query() - .findById(testRecord.id) - .withGraphFetched('licences') + const result = await RegionModel.query().findById(testRecord.id).withGraphFetched('licences') expect(result).to.be.instanceOf(RegionModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/return-cycle.model.test.js b/test/models/return-cycle.model.test.js index 36f0f80e8c..aa9a11e715 100644 --- a/test/models/return-cycle.model.test.js +++ b/test/models/return-cycle.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -42,16 +42,13 @@ describe('Return Cycle model', () => { describe('Relationships', () => { describe('when linking to return log', () => { it('can successfully run a related query', async () => { - const query = await ReturnCycleModel.query() - .innerJoinRelated('returnLogs') + const query = await ReturnCycleModel.query().innerJoinRelated('returnLogs') expect(query).to.exist() }) it('can eager load the return log', async () => { - const result = await ReturnCycleModel.query() - .findById(testRecord.id) - .withGraphFetched('returnLogs') + const result = await ReturnCycleModel.query().findById(testRecord.id).withGraphFetched('returnLogs') expect(result).to.be.instanceOf(ReturnCycleModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/return-log.model.test.js b/test/models/return-log.model.test.js index 9fa4c28039..def7f035a9 100644 --- a/test/models/return-log.model.test.js +++ b/test/models/return-log.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach, before } = exports.lab = Lab.script() +const { describe, it, beforeEach, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,16 +48,13 @@ describe('Return Log model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnLogModel.query() - .innerJoinRelated('licence') + const query = await ReturnLogModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await ReturnLogModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await ReturnLogModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(ReturnLogModel) expect(result.id).to.equal(testRecord.id) @@ -83,16 +80,13 @@ describe('Return Log model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnLogModel.query() - .innerJoinRelated('returnSubmissions') + const query = await ReturnLogModel.query().innerJoinRelated('returnSubmissions') expect(query).to.exist() }) it('can eager load the return submissions', async () => { - const result = await ReturnLogModel.query() - .findById(testRecord.id) - .withGraphFetched('returnSubmissions') + const result = await ReturnLogModel.query().findById(testRecord.id).withGraphFetched('returnSubmissions') expect(result).to.be.instanceOf(ReturnLogModel) expect(result.id).to.equal(testRecord.id) @@ -114,16 +108,13 @@ describe('Return Log model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnLogModel.query() - .innerJoinRelated('returnCycle') + const query = await ReturnLogModel.query().innerJoinRelated('returnCycle') expect(query).to.exist() }) it('can eager load the return submissions', async () => { - const result = await ReturnLogModel.query() - .findById(testRecord.id) - .withGraphFetched('returnCycle') + const result = await ReturnLogModel.query().findById(testRecord.id).withGraphFetched('returnCycle') expect(result).to.be.instanceOf(ReturnLogModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/return-requirement-point.model.test.js b/test/models/return-requirement-point.model.test.js index 709ba76800..9d4c94affb 100644 --- a/test/models/return-requirement-point.model.test.js +++ b/test/models/return-requirement-point.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -27,7 +27,8 @@ describe('Return Requirement Point model', () => { testReturnRequirement = await ReturnRequirementHelper.add() testRecord = await ReturnRequirementPointHelper.add({ - pointId: testPoint.id, returnRequirementId: testReturnRequirement.id + pointId: testPoint.id, + returnRequirementId: testReturnRequirement.id }) }) @@ -43,16 +44,13 @@ describe('Return Requirement Point model', () => { describe('Relationships', () => { describe('when linking to point', () => { it('can successfully run a related query', async () => { - const query = await ReturnRequirementPointModel.query() - .innerJoinRelated('point') + const query = await ReturnRequirementPointModel.query().innerJoinRelated('point') expect(query).to.exist() }) it('can eager load the point', async () => { - const result = await ReturnRequirementPointModel.query() - .findById(testRecord.id) - .withGraphFetched('point') + const result = await ReturnRequirementPointModel.query().findById(testRecord.id).withGraphFetched('point') expect(result).to.be.instanceOf(ReturnRequirementPointModel) expect(result.id).to.equal(testRecord.id) @@ -64,8 +62,7 @@ describe('Return Requirement Point model', () => { describe('when linking to return requirement', () => { it('can successfully run a related query', async () => { - const query = await ReturnRequirementPointModel.query() - .innerJoinRelated('returnRequirement') + const query = await ReturnRequirementPointModel.query().innerJoinRelated('returnRequirement') expect(query).to.exist() }) diff --git a/test/models/return-requirement-purpose.model.test.js b/test/models/return-requirement-purpose.model.test.js index 0fb80fe7dd..7855510883 100644 --- a/test/models/return-requirement-purpose.model.test.js +++ b/test/models/return-requirement-purpose.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,8 +48,7 @@ describe('Return Requirement Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnRequirementPurposeModel.query() - .innerJoinRelated('primaryPurpose') + const query = await ReturnRequirementPurposeModel.query().innerJoinRelated('primaryPurpose') expect(query).to.exist() }) @@ -79,16 +78,13 @@ describe('Return Requirement Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnRequirementPurposeModel.query() - .innerJoinRelated('purpose') + const query = await ReturnRequirementPurposeModel.query().innerJoinRelated('purpose') expect(query).to.exist() }) it('can eager load the purpose', async () => { - const result = await ReturnRequirementPurposeModel.query() - .findById(testRecord.id) - .withGraphFetched('purpose') + const result = await ReturnRequirementPurposeModel.query().findById(testRecord.id).withGraphFetched('purpose') expect(result).to.be.instanceOf(ReturnRequirementPurposeModel) expect(result.id).to.equal(testRecord.id) @@ -110,8 +106,7 @@ describe('Return Requirement Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnRequirementPurposeModel.query() - .innerJoinRelated('returnRequirement') + const query = await ReturnRequirementPurposeModel.query().innerJoinRelated('returnRequirement') expect(query).to.exist() }) @@ -142,8 +137,7 @@ describe('Return Requirement Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnRequirementPurposeModel.query() - .innerJoinRelated('secondaryPurpose') + const query = await ReturnRequirementPurposeModel.query().innerJoinRelated('secondaryPurpose') expect(query).to.exist() }) diff --git a/test/models/return-requirement.model.test.js b/test/models/return-requirement.model.test.js index 20973e3a46..629ea5c852 100644 --- a/test/models/return-requirement.model.test.js +++ b/test/models/return-requirement.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -36,9 +36,10 @@ describe('Return Requirement model', () => { testReturnRequirementPurposes = [] for (let i = 0; i < 2; i++) { - const returnRequirementPurpose = await ReturnRequirementPurposeHelper.add( - { alias: `TEST RET REQ ${i}`, returnRequirementId: testRecord.id } - ) + const returnRequirementPurpose = await ReturnRequirementPurposeHelper.add({ + alias: `TEST RET REQ ${i}`, + returnRequirementId: testRecord.id + }) testReturnRequirementPurposes.push(returnRequirementPurpose) } @@ -56,16 +57,13 @@ describe('Return Requirement model', () => { describe('Relationships', () => { describe('when linking through return requirement points to points', () => { it('can successfully run a related query', async () => { - const query = await ReturnRequirementModel.query() - .innerJoinRelated('points') + const query = await ReturnRequirementModel.query().innerJoinRelated('points') expect(query).to.exist() }) it('can eager load the points', async () => { - const result = await ReturnRequirementModel.query() - .findById(testRecord.id) - .withGraphFetched('points') + const result = await ReturnRequirementModel.query().findById(testRecord.id).withGraphFetched('points') expect(result).to.be.instanceOf(ReturnRequirementModel) expect(result.id).to.equal(testRecord.id) @@ -79,8 +77,7 @@ describe('Return Requirement model', () => { describe('when linking to return requirement purposes', () => { it('can successfully run a related query', async () => { - const query = await ReturnRequirementModel.query() - .innerJoinRelated('returnRequirementPurposes') + const query = await ReturnRequirementModel.query().innerJoinRelated('returnRequirementPurposes') expect(query).to.exist() }) @@ -102,16 +99,13 @@ describe('Return Requirement model', () => { describe('when linking to return version', () => { it('can successfully run a related query', async () => { - const query = await ReturnRequirementModel.query() - .innerJoinRelated('returnVersion') + const query = await ReturnRequirementModel.query().innerJoinRelated('returnVersion') expect(query).to.exist() }) it('can eager load the charge version', async () => { - const result = await ReturnRequirementModel.query() - .findById(testRecord.id) - .withGraphFetched('returnVersion') + const result = await ReturnRequirementModel.query().findById(testRecord.id).withGraphFetched('returnVersion') expect(result).to.be.instanceOf(ReturnRequirementModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/return-submission-line.model.test.js b/test/models/return-submission-line.model.test.js index 2796e741ec..72eeb10d38 100644 --- a/test/models/return-submission-line.model.test.js +++ b/test/models/return-submission-line.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -41,8 +41,7 @@ describe('Return Submission Line model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnSubmissionLineModel.query() - .innerJoinRelated('returnSubmission') + const query = await ReturnSubmissionLineModel.query().innerJoinRelated('returnSubmission') expect(query).to.exist() }) diff --git a/test/models/return-submission.model.test.js b/test/models/return-submission.model.test.js index 839b3e6db3..f34824c0c9 100644 --- a/test/models/return-submission.model.test.js +++ b/test/models/return-submission.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -43,16 +43,13 @@ describe('Return Submission model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnSubmissionModel.query() - .innerJoinRelated('returnLog') + const query = await ReturnSubmissionModel.query().innerJoinRelated('returnLog') expect(query).to.exist() }) it('can eager load the return log', async () => { - const result = await ReturnSubmissionModel.query() - .findById(testRecord.id) - .withGraphFetched('returnLog') + const result = await ReturnSubmissionModel.query().findById(testRecord.id).withGraphFetched('returnLog') expect(result).to.be.instanceOf(ReturnSubmissionModel) expect(result.id).to.equal(testRecord.id) @@ -84,8 +81,7 @@ describe('Return Submission model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnSubmissionModel.query() - .innerJoinRelated('returnSubmissionLines') + const query = await ReturnSubmissionModel.query().innerJoinRelated('returnSubmissionLines') expect(query).to.exist() }) diff --git a/test/models/return-version.model.test.js b/test/models/return-version.model.test.js index 3ae629e85c..6bcf2fe058 100644 --- a/test/models/return-version.model.test.js +++ b/test/models/return-version.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -52,16 +52,13 @@ describe('Return Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnVersionModel.query() - .innerJoinRelated('licence') + const query = await ReturnVersionModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await ReturnVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await ReturnVersionModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(ReturnVersionModel) expect(result.id).to.equal(testRecord.id) @@ -86,16 +83,13 @@ describe('Return Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnVersionModel.query() - .innerJoinRelated('modLogs') + const query = await ReturnVersionModel.query().innerJoinRelated('modLogs') expect(query).to.exist() }) it('can eager load the mod logs', async () => { - const result = await ReturnVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('modLogs') + const result = await ReturnVersionModel.query().findById(testRecord.id).withGraphFetched('modLogs') expect(result).to.be.instanceOf(ReturnVersionModel) expect(result.id).to.equal(testRecord.id) @@ -115,25 +109,23 @@ describe('Return Version model', () => { testReturnRequirements = [] for (let i = 0; i < 2; i++) { - const returnRequirement = await ReturnRequirementHelper.add( - { siteDescription: `TEST RTN REQ ${i}`, returnVersionId: testRecord.id } - ) + const returnRequirement = await ReturnRequirementHelper.add({ + siteDescription: `TEST RTN REQ ${i}`, + returnVersionId: testRecord.id + }) testReturnRequirements.push(returnRequirement) } }) it('can successfully run a related query', async () => { - const query = await ReturnVersionModel.query() - .innerJoinRelated('returnRequirements') + const query = await ReturnVersionModel.query().innerJoinRelated('returnRequirements') expect(query).to.exist() }) it('can eager load the return requirements', async () => { - const result = await ReturnVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('returnRequirements') + const result = await ReturnVersionModel.query().findById(testRecord.id).withGraphFetched('returnRequirements') expect(result).to.be.instanceOf(ReturnVersionModel) expect(result.id).to.equal(testRecord.id) @@ -157,16 +149,13 @@ describe('Return Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ReturnVersionModel.query() - .innerJoinRelated('user') + const query = await ReturnVersionModel.query().innerJoinRelated('user') expect(query).to.exist() }) it('can eager load the user', async () => { - const result = await ReturnVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('user') + const result = await ReturnVersionModel.query().findById(testRecord.id).withGraphFetched('user') expect(result).to.be.instanceOf(ReturnVersionModel) expect(result.id).to.equal(testRecord.id) @@ -202,10 +191,14 @@ describe('Return Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, naldDate: new Date('2012-06-01'), returnVersionId + externalId: `${regionCode}:${firstNaldId}`, + naldDate: new Date('2012-06-01'), + returnVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, naldDate: new Date('2012-06-02'), returnVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + naldDate: new Date('2012-06-02'), + returnVersionId }) testRecord = await ReturnVersionModel.query().findById(returnVersionId).modify('history') @@ -347,10 +340,14 @@ describe('Return Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, note: null, returnVersionId + externalId: `${regionCode}:${firstNaldId}`, + note: null, + returnVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, note: null, returnVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + note: null, + returnVersionId }) testRecord = await ReturnVersionModel.query().findById(returnVersionId).modify('history') @@ -370,10 +367,14 @@ describe('Return Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, note: null, returnVersionId + externalId: `${regionCode}:${firstNaldId}`, + note: null, + returnVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, note: 'Transfer per app 12-DEF', returnVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + note: 'Transfer per app 12-DEF', + returnVersionId }) testRecord = await ReturnVersionModel.query().findById(returnVersionId).modify('history') @@ -398,10 +399,14 @@ describe('Return Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, note: 'New Licence per app 9-ABC', returnVersionId + externalId: `${regionCode}:${firstNaldId}`, + note: 'New Licence per app 9-ABC', + returnVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, note: 'Transfer per app 12-DEF', returnVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + note: 'Transfer per app 12-DEF', + returnVersionId }) testRecord = await ReturnVersionModel.query().findById(returnVersionId).modify('history') @@ -466,10 +471,14 @@ describe('Return Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, reasonDescription: null, returnVersionId + externalId: `${regionCode}:${firstNaldId}`, + reasonDescription: null, + returnVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, reasonDescription: 'New licence', returnVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + reasonDescription: 'New licence', + returnVersionId }) testRecord = await ReturnVersionModel.query().findById(returnVersionId).modify('history') @@ -488,10 +497,14 @@ describe('Return Version model', () => { const firstNaldId = randomInteger(100, 99998) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId}`, reasonDescription: 'New licence', returnVersionId + externalId: `${regionCode}:${firstNaldId}`, + reasonDescription: 'New licence', + returnVersionId }) await ModLogHelper.add({ - externalId: `${regionCode}:${firstNaldId + 1}`, reasonDescription: 'Transferred', returnVersionId + externalId: `${regionCode}:${firstNaldId + 1}`, + reasonDescription: 'Transferred', + returnVersionId }) testRecord = await ReturnVersionModel.query().findById(returnVersionId).modify('history') diff --git a/test/models/review-charge-element-return.model.test.js b/test/models/review-charge-element-return.model.test.js index 1b06208d4a..4af424059a 100644 --- a/test/models/review-charge-element-return.model.test.js +++ b/test/models/review-charge-element-return.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -22,8 +22,7 @@ describe('Review Charge Element Return model', () => { }) it('can successfully run a basic query', async () => { - const result = await ReviewChargeElementReturnModel.query() - .findById(testRecord.id) + const result = await ReviewChargeElementReturnModel.query().findById(testRecord.id) expect(result).to.be.an.instanceOf(ReviewChargeElementReturnModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/review-charge-element.model.test.js b/test/models/review-charge-element.model.test.js index 6712aa94ce..12f6660105 100644 --- a/test/models/review-charge-element.model.test.js +++ b/test/models/review-charge-element.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -49,8 +49,7 @@ describe('Review Charge Element model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeElementModel.query() - .innerJoinRelated('reviewChargeReference') + const query = await ReviewChargeElementModel.query().innerJoinRelated('reviewChargeReference') expect(query).to.exist() }) @@ -89,16 +88,13 @@ describe('Review Charge Element model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeElementModel.query() - .innerJoinRelated('reviewReturns') + const query = await ReviewChargeElementModel.query().innerJoinRelated('reviewReturns') expect(query).to.exist() }) it('can eager load the review returns', async () => { - const result = await ReviewChargeElementModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewReturns') + const result = await ReviewChargeElementModel.query().findById(testRecord.id).withGraphFetched('reviewReturns') expect(result).to.be.instanceOf(ReviewChargeElementModel) expect(result.id).to.equal(testRecord.id) @@ -122,16 +118,13 @@ describe('Review Charge Element model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeElementModel.query() - .innerJoinRelated('chargeElement') + const query = await ReviewChargeElementModel.query().innerJoinRelated('chargeElement') expect(query).to.exist() }) it('can eager load the charge element', async () => { - const result = await ReviewChargeElementModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeElement') + const result = await ReviewChargeElementModel.query().findById(testRecord.id).withGraphFetched('chargeElement') expect(result).to.be.instanceOf(ReviewChargeElementModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/review-charge-reference.model.test.js b/test/models/review-charge-reference.model.test.js index 5bd9a2f21d..297d21860e 100644 --- a/test/models/review-charge-reference.model.test.js +++ b/test/models/review-charge-reference.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -45,8 +45,7 @@ describe('Review Charge reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeReferenceModel.query() - .innerJoinRelated('reviewChargeElements') + const query = await ReviewChargeReferenceModel.query().innerJoinRelated('reviewChargeElements') expect(query).to.exist() }) @@ -75,8 +74,7 @@ describe('Review Charge reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeReferenceModel.query() - .innerJoinRelated('reviewChargeVersion') + const query = await ReviewChargeReferenceModel.query().innerJoinRelated('reviewChargeVersion') expect(query).to.exist() }) @@ -103,8 +101,7 @@ describe('Review Charge reference model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeReferenceModel.query() - .innerJoinRelated('chargeReference') + const query = await ReviewChargeReferenceModel.query().innerJoinRelated('chargeReference') expect(query).to.exist() }) diff --git a/test/models/review-charge-version.model.test.js b/test/models/review-charge-version.model.test.js index 2275e3ac31..f0b159c087 100644 --- a/test/models/review-charge-version.model.test.js +++ b/test/models/review-charge-version.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -45,8 +45,7 @@ describe('Review Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeVersionModel.query() - .innerJoinRelated('reviewChargeReferences') + const query = await ReviewChargeVersionModel.query().innerJoinRelated('reviewChargeReferences') expect(query).to.exist() }) @@ -75,16 +74,13 @@ describe('Review Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeVersionModel.query() - .innerJoinRelated('reviewLicence') + const query = await ReviewChargeVersionModel.query().innerJoinRelated('reviewLicence') expect(query).to.exist() }) it('can eager load the review licence', async () => { - const result = await ReviewChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewLicence') + const result = await ReviewChargeVersionModel.query().findById(testRecord.id).withGraphFetched('reviewLicence') expect(result).to.be.instanceOf(ReviewChargeVersionModel) expect(result.id).to.equal(testRecord.id) @@ -103,16 +99,13 @@ describe('Review Charge Version model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewChargeVersionModel.query() - .innerJoinRelated('chargeVersion') + const query = await ReviewChargeVersionModel.query().innerJoinRelated('chargeVersion') expect(query).to.exist() }) it('can eager load the charge version', async () => { - const result = await ReviewChargeVersionModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersion') + const result = await ReviewChargeVersionModel.query().findById(testRecord.id).withGraphFetched('chargeVersion') expect(result).to.be.instanceOf(ReviewChargeVersionModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/review-licence.model.test.js b/test/models/review-licence.model.test.js index d5f3c934ec..9b7a1902b4 100644 --- a/test/models/review-licence.model.test.js +++ b/test/models/review-licence.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,16 +48,13 @@ describe('Review Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewLicenceModel.query() - .innerJoinRelated('billRun') + const query = await ReviewLicenceModel.query().innerJoinRelated('billRun') expect(query).to.exist() }) it('can eager load the bill run', async () => { - const result = await ReviewLicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('billRun') + const result = await ReviewLicenceModel.query().findById(testRecord.id).withGraphFetched('billRun') expect(result).to.be.instanceOf(ReviewLicenceModel) expect(result.id).to.equal(testRecord.id) @@ -77,16 +74,13 @@ describe('Review Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewLicenceModel.query() - .innerJoinRelated('licence') + const query = await ReviewLicenceModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await ReviewLicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await ReviewLicenceModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(ReviewLicenceModel) expect(result.id).to.equal(testRecord.id) @@ -112,16 +106,13 @@ describe('Review Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewLicenceModel.query() - .innerJoinRelated('reviewChargeVersions') + const query = await ReviewLicenceModel.query().innerJoinRelated('reviewChargeVersions') expect(query).to.exist() }) it('can eager load the review charge version', async () => { - const result = await ReviewLicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewChargeVersions') + const result = await ReviewLicenceModel.query().findById(testRecord.id).withGraphFetched('reviewChargeVersions') expect(result).to.be.instanceOf(ReviewLicenceModel) expect(result.id).to.equal(testRecord.id) @@ -149,16 +140,13 @@ describe('Review Licence model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewLicenceModel.query() - .innerJoinRelated('reviewReturns') + const query = await ReviewLicenceModel.query().innerJoinRelated('reviewReturns') expect(query).to.exist() }) it('can eager load the review returns', async () => { - const result = await ReviewLicenceModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewReturns') + const result = await ReviewLicenceModel.query().findById(testRecord.id).withGraphFetched('reviewReturns') expect(result).to.be.instanceOf(ReviewLicenceModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/review-return.model.test.js b/test/models/review-return.model.test.js index 5a56b1e048..8f6fbfe5d9 100644 --- a/test/models/review-return.model.test.js +++ b/test/models/review-return.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -49,16 +49,13 @@ describe('Review Return model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewReturnModel.query() - .innerJoinRelated('reviewLicence') + const query = await ReviewReturnModel.query().innerJoinRelated('reviewLicence') expect(query).to.exist() }) it('can eager load the review licence', async () => { - const result = await ReviewReturnModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewLicence') + const result = await ReviewReturnModel.query().findById(testRecord.id).withGraphFetched('reviewLicence') expect(result).to.be.instanceOf(ReviewReturnModel) expect(result.id).to.equal(testRecord.id) @@ -80,16 +77,13 @@ describe('Review Return model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewReturnModel.query() - .innerJoinRelated('returnLog') + const query = await ReviewReturnModel.query().innerJoinRelated('returnLog') expect(query).to.exist() }) it('can eager load the return log', async () => { - const result = await ReviewReturnModel.query() - .findById(testRecord.id) - .withGraphFetched('returnLog') + const result = await ReviewReturnModel.query().findById(testRecord.id).withGraphFetched('returnLog') expect(result).to.be.instanceOf(ReviewReturnModel) expect(result.id).to.equal(testRecord.id) @@ -120,16 +114,13 @@ describe('Review Return model', () => { }) it('can successfully run a related query', async () => { - const query = await ReviewReturnModel.query() - .innerJoinRelated('reviewChargeElements') + const query = await ReviewReturnModel.query().innerJoinRelated('reviewChargeElements') expect(query).to.exist() }) it('can eager load the review charge elements', async () => { - const result = await ReviewReturnModel.query() - .findById(testRecord.id) - .withGraphFetched('reviewChargeElements') + const result = await ReviewReturnModel.query().findById(testRecord.id).withGraphFetched('reviewChargeElements') expect(result).to.be.instanceOf(ReviewReturnModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/role.model.test.js b/test/models/role.model.test.js index 46015d8a9d..c4eb697c44 100644 --- a/test/models/role.model.test.js +++ b/test/models/role.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -54,16 +54,13 @@ describe('Role model', () => { describe('Relationships', () => { describe('when linking to group roles', () => { it('can successfully run a related query', async () => { - const query = await RoleModel.query() - .innerJoinRelated('groupRoles') + const query = await RoleModel.query().innerJoinRelated('groupRoles') expect(query).to.exist() }) it('can eager load the group roles', async () => { - const result = await RoleModel.query() - .findById(testRecord.id) - .withGraphFetched('groupRoles') + const result = await RoleModel.query().findById(testRecord.id).withGraphFetched('groupRoles') expect(result).to.be.instanceOf(RoleModel) expect(result.id).to.equal(testRecord.id) @@ -77,16 +74,13 @@ describe('Role model', () => { describe('when linking to user roles', () => { it('can successfully run a related query', async () => { - const query = await RoleModel.query() - .innerJoinRelated('userRoles') + const query = await RoleModel.query().innerJoinRelated('userRoles') expect(query).to.exist() }) it('can eager load the user roles', async () => { - const result = await RoleModel.query() - .findById(testRecord.id) - .withGraphFetched('userRoles') + const result = await RoleModel.query().findById(testRecord.id).withGraphFetched('userRoles') expect(result).to.be.instanceOf(RoleModel) expect(result.id).to.equal(testRecord.id) @@ -100,16 +94,13 @@ describe('Role model', () => { describe('when linking through group roles to groups', () => { it('can successfully run a related query', async () => { - const query = await RoleModel.query() - .innerJoinRelated('groups') + const query = await RoleModel.query().innerJoinRelated('groups') expect(query).to.exist() }) it('can eager load the groups', async () => { - const result = await RoleModel.query() - .findById(testRecord.id) - .withGraphFetched('groups') + const result = await RoleModel.query().findById(testRecord.id).withGraphFetched('groups') expect(result).to.be.instanceOf(RoleModel) expect(result.id).to.equal(testRecord.id) @@ -123,16 +114,13 @@ describe('Role model', () => { describe('when linking through user roles to users', () => { it('can successfully run a related query', async () => { - const query = await RoleModel.query() - .innerJoinRelated('users') + const query = await RoleModel.query().innerJoinRelated('users') expect(query).to.exist() }) it('can eager load the users', async () => { - const result = await RoleModel.query() - .findById(testRecord.id) - .withGraphFetched('users') + const result = await RoleModel.query().findById(testRecord.id).withGraphFetched('users') expect(result).to.be.instanceOf(RoleModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/scheduled-notification.model.test.js b/test/models/scheduled-notification.model.test.js index a6d89875e3..d8ecdb3bdd 100644 --- a/test/models/scheduled-notification.model.test.js +++ b/test/models/scheduled-notification.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -42,16 +42,13 @@ describe('Scheduled Notification model', () => { }) it('can successfully run a related query', async () => { - const query = await ScheduledNotificationModel.query() - .innerJoinRelated('event') + const query = await ScheduledNotificationModel.query().innerJoinRelated('event') expect(query).to.exist() }) it('can eager load the event', async () => { - const result = await ScheduledNotificationModel.query() - .findById(testRecord.id) - .withGraphFetched('event') + const result = await ScheduledNotificationModel.query().findById(testRecord.id).withGraphFetched('event') expect(result).to.be.instanceOf(ScheduledNotificationModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/secondary-purpose.model.test.js b/test/models/secondary-purpose.model.test.js index 5ee598d896..bba68f54c0 100644 --- a/test/models/secondary-purpose.model.test.js +++ b/test/models/secondary-purpose.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -37,7 +37,8 @@ describe('Secondary Purpose model', () => { testLicenceVersionPurposes = [] for (let i = 0; i < 2; i++) { const licenceVersionPurpose = await LicenceVersionPurposeHelper.add({ - notes: `TEST licence Version purpose ${i}`, secondaryPurposeId: testRecordId + notes: `TEST licence Version purpose ${i}`, + secondaryPurposeId: testRecordId }) testLicenceVersionPurposes.push(licenceVersionPurpose) @@ -45,8 +46,7 @@ describe('Secondary Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await SecondaryPurposeModel.query() - .innerJoinRelated('licenceVersionPurposes') + const query = await SecondaryPurposeModel.query().innerJoinRelated('licenceVersionPurposes') expect(query).to.exist() }) @@ -73,7 +73,8 @@ describe('Secondary Purpose model', () => { testReturnRequirementPurposes = [] for (let i = 0; i < 2; i++) { const returnRequirementPurpose = await ReturnRequirementPurposeHelper.add({ - alias: `TEST return requirement purpose ${i}`, secondaryPurposeId: testRecordId + alias: `TEST return requirement purpose ${i}`, + secondaryPurposeId: testRecordId }) testReturnRequirementPurposes.push(returnRequirementPurpose) @@ -81,8 +82,7 @@ describe('Secondary Purpose model', () => { }) it('can successfully run a related query', async () => { - const query = await SecondaryPurposeModel.query() - .innerJoinRelated('returnRequirementPurposes') + const query = await SecondaryPurposeModel.query().innerJoinRelated('returnRequirementPurposes') expect(query).to.exist() }) diff --git a/test/models/session.model.test.js b/test/models/session.model.test.js index b362de374c..6f5e6c5f3f 100644 --- a/test/models/session.model.test.js +++ b/test/models/session.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/models/source.model.test.js b/test/models/source.model.test.js index 4faa9000f0..72726bfc4c 100644 --- a/test/models/source.model.test.js +++ b/test/models/source.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,16 +47,13 @@ describe('Source model', () => { }) it('can successfully run a related query', async () => { - const query = await SourceModel.query() - .innerJoinRelated('points') + const query = await SourceModel.query().innerJoinRelated('points') expect(query).to.exist() }) it('can eager load the points', async () => { - const result = await SourceModel.query() - .findById(testRecord.id) - .withGraphFetched('points') + const result = await SourceModel.query().findById(testRecord.id).withGraphFetched('points') expect(result).to.be.instanceOf(SourceModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/transaction.model.test.js b/test/models/transaction.model.test.js index 14da44d509..105e2d21a2 100644 --- a/test/models/transaction.model.test.js +++ b/test/models/transaction.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -46,16 +46,13 @@ describe('Transaction model', () => { }) it('can successfully run a related query', async () => { - const query = await TransactionModel.query() - .innerJoinRelated('billLicence') + const query = await TransactionModel.query().innerJoinRelated('billLicence') expect(query).to.exist() }) it('can eager load the bill licence', async () => { - const result = await TransactionModel.query() - .findById(testRecord.id) - .withGraphFetched('billLicence') + const result = await TransactionModel.query().findById(testRecord.id).withGraphFetched('billLicence') expect(result).to.be.instanceOf(TransactionModel) expect(result.id).to.equal(testRecord.id) @@ -77,16 +74,13 @@ describe('Transaction model', () => { }) it('can successfully run a related query', async () => { - const query = await TransactionModel.query() - .innerJoinRelated('chargeReference') + const query = await TransactionModel.query().innerJoinRelated('chargeReference') expect(query).to.exist() }) it('can eager load the charge reference', async () => { - const result = await TransactionModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeReference') + const result = await TransactionModel.query().findById(testRecord.id).withGraphFetched('chargeReference') expect(result).to.be.instanceOf(TransactionModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/user-group.model.test.js b/test/models/user-group.model.test.js index 9718b041f4..10512dace2 100644 --- a/test/models/user-group.model.test.js +++ b/test/models/user-group.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -45,16 +45,13 @@ describe('User Group model', () => { describe('Relationships', () => { describe('when linking to group', () => { it('can successfully run a related query', async () => { - const query = await UserGroupModel.query() - .innerJoinRelated('group') + const query = await UserGroupModel.query().innerJoinRelated('group') expect(query).to.exist() }) it('can eager load the group', async () => { - const result = await UserGroupModel.query() - .findById(testRecord.id) - .withGraphFetched('group') + const result = await UserGroupModel.query().findById(testRecord.id).withGraphFetched('group') expect(result).to.be.instanceOf(UserGroupModel) expect(result.id).to.equal(testRecord.id) @@ -66,16 +63,13 @@ describe('User Group model', () => { describe('when linking to user', () => { it('can successfully run a related query', async () => { - const query = await UserGroupModel.query() - .innerJoinRelated('user') + const query = await UserGroupModel.query().innerJoinRelated('user') expect(query).to.exist() }) it('can eager load the user', async () => { - const result = await UserGroupModel.query() - .findById(testRecord.id) - .withGraphFetched('user') + const result = await UserGroupModel.query().findById(testRecord.id).withGraphFetched('user') expect(result).to.be.instanceOf(UserGroupModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/user-role.model.test.js b/test/models/user-role.model.test.js index a609d93081..f6d0851de7 100644 --- a/test/models/user-role.model.test.js +++ b/test/models/user-role.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -43,16 +43,13 @@ describe('User Role model', () => { describe('Relationships', () => { describe('when linking to role', () => { it('can successfully run a related query', async () => { - const query = await UserRoleModel.query() - .innerJoinRelated('role') + const query = await UserRoleModel.query().innerJoinRelated('role') expect(query).to.exist() }) it('can eager load the role', async () => { - const result = await UserRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('role') + const result = await UserRoleModel.query().findById(testRecord.id).withGraphFetched('role') expect(result).to.be.instanceOf(UserRoleModel) expect(result.id).to.equal(testRecord.id) @@ -64,16 +61,13 @@ describe('User Role model', () => { describe('when linking to user', () => { it('can successfully run a related query', async () => { - const query = await UserRoleModel.query() - .innerJoinRelated('user') + const query = await UserRoleModel.query().innerJoinRelated('user') expect(query).to.exist() }) it('can eager load the user', async () => { - const result = await UserRoleModel.query() - .findById(testRecord.id) - .withGraphFetched('user') + const result = await UserRoleModel.query().findById(testRecord.id).withGraphFetched('user') expect(result).to.be.instanceOf(UserRoleModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/user.model.test.js b/test/models/user.model.test.js index 429bfcadff..f81d804d77 100644 --- a/test/models/user.model.test.js +++ b/test/models/user.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -65,21 +65,20 @@ describe('User model', () => { describe('Relationships', () => { describe('when linking to charge version notes', () => { it('can successfully run a related query', async () => { - const query = await UserModel.query() - .innerJoinRelated('chargeVersionNotes') + const query = await UserModel.query().innerJoinRelated('chargeVersionNotes') expect(query).to.exist() }) it('can eager load the charge version notes', async () => { - const result = await UserModel.query() - .findById(testRecord.id) - .withGraphFetched('chargeVersionNotes') + const result = await UserModel.query().findById(testRecord.id).withGraphFetched('chargeVersionNotes') - const foundChargeVersionNoteOne = result.chargeVersionNotes - .find((chargeVersionNote) => { return chargeVersionNote.id === testChargeVersionNoteOne.id }) - const foundChargeVersionNoteTwo = result.chargeVersionNotes - .find((chargeVersionNote) => { return chargeVersionNote.id === testChargeVersionNoteTwo.id }) + const foundChargeVersionNoteOne = result.chargeVersionNotes.find((chargeVersionNote) => { + return chargeVersionNote.id === testChargeVersionNoteOne.id + }) + const foundChargeVersionNoteTwo = result.chargeVersionNotes.find((chargeVersionNote) => { + return chargeVersionNote.id === testChargeVersionNoteTwo.id + }) expect(result).to.be.instanceOf(UserModel) expect(result.id).to.equal(testRecord.id) @@ -93,16 +92,13 @@ describe('User model', () => { describe('when linking through user groups to groups', () => { it('can successfully run a related query', async () => { - const query = await UserModel.query() - .innerJoinRelated('groups') + const query = await UserModel.query().innerJoinRelated('groups') expect(query).to.exist() }) it('can eager load the groups', async () => { - const result = await UserModel.query() - .findById(testRecord.id) - .withGraphFetched('groups') + const result = await UserModel.query().findById(testRecord.id).withGraphFetched('groups') expect(result).to.be.instanceOf(UserModel) expect(result.id).to.equal(testRecord.id) @@ -132,16 +128,13 @@ describe('User model', () => { }) it('can successfully run a related query', async () => { - const query = await UserModel.query() - .innerJoinRelated('licenceEntity') + const query = await UserModel.query().innerJoinRelated('licenceEntity') expect(query).to.exist() }) it('can eager load the licence entity', async () => { - const result = await UserModel.query() - .findById(testAddedRecord.id) - .withGraphFetched('licenceEntity') + const result = await UserModel.query().findById(testAddedRecord.id).withGraphFetched('licenceEntity') expect(result).to.be.instanceOf(UserModel) expect(result.id).to.equal(testAddedRecord.id) @@ -164,16 +157,13 @@ describe('User model', () => { }) it('can successfully run a related query', async () => { - const query = await UserModel.query() - .innerJoinRelated('returnVersions') + const query = await UserModel.query().innerJoinRelated('returnVersions') expect(query).to.exist() }) it('can eager load the return versions', async () => { - const result = await UserModel.query() - .findById(testRecord.id) - .withGraphFetched('returnVersions') + const result = await UserModel.query().findById(testRecord.id).withGraphFetched('returnVersions') expect(result).to.be.instanceOf(UserModel) expect(result.id).to.equal(testRecord.id) @@ -187,16 +177,13 @@ describe('User model', () => { describe('when linking through user roles to roles', () => { it('can successfully run a related query', async () => { - const query = await UserModel.query() - .innerJoinRelated('roles') + const query = await UserModel.query().innerJoinRelated('roles') expect(query).to.exist() }) it('can eager load the roles', async () => { - const result = await UserModel.query() - .findById(testRecord.id) - .withGraphFetched('roles') + const result = await UserModel.query().findById(testRecord.id).withGraphFetched('roles') expect(result).to.be.instanceOf(UserModel) expect(result.id).to.equal(testRecord.id) @@ -210,16 +197,13 @@ describe('User model', () => { describe('when linking to user groups', () => { it('can successfully run a related query', async () => { - const query = await UserModel.query() - .innerJoinRelated('userGroups') + const query = await UserModel.query().innerJoinRelated('userGroups') expect(query).to.exist() }) it('can eager load the user groups', async () => { - const result = await UserModel.query() - .findById(testRecord.id) - .withGraphFetched('userGroups') + const result = await UserModel.query().findById(testRecord.id).withGraphFetched('userGroups') expect(result).to.be.instanceOf(UserModel) expect(result.id).to.equal(testRecord.id) @@ -233,16 +217,13 @@ describe('User model', () => { describe('when linking to user roles', () => { it('can successfully run a related query', async () => { - const query = await UserModel.query() - .innerJoinRelated('userRoles') + const query = await UserModel.query().innerJoinRelated('userRoles') expect(query).to.exist() }) it('can eager load the user roles', async () => { - const result = await UserModel.query() - .findById(testRecord.id) - .withGraphFetched('userRoles') + const result = await UserModel.query().findById(testRecord.id).withGraphFetched('userRoles') expect(result).to.be.instanceOf(UserModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/models/workflow.model.test.js b/test/models/workflow.model.test.js index cbcd3faeaf..65be25f8eb 100644 --- a/test/models/workflow.model.test.js +++ b/test/models/workflow.model.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -44,16 +44,13 @@ describe('Workflow model', () => { }) it('can successfully run a related query', async () => { - const query = await WorkflowModel.query() - .innerJoinRelated('licence') + const query = await WorkflowModel.query().innerJoinRelated('licence') expect(query).to.exist() }) it('can eager load the licence', async () => { - const result = await WorkflowModel.query() - .findById(testRecord.id) - .withGraphFetched('licence') + const result = await WorkflowModel.query().findById(testRecord.id).withGraphFetched('licence') expect(result).to.be.instanceOf(WorkflowModel) expect(result.id).to.equal(testRecord.id) diff --git a/test/plugins/charging-module-token-cache.plugin.test.js b/test/plugins/charging-module-token-cache.plugin.test.js index 942b846136..b22af3e6f4 100644 --- a/test/plugins/charging-module-token-cache.plugin.test.js +++ b/test/plugins/charging-module-token-cache.plugin.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -33,8 +33,10 @@ describe('Charging Module Token Cache plugin', () => { describe('and the second request is made before the cache expires', () => { before(() => { Sinon.stub(ChargingModuleTokenRequest, 'send') - .onFirstCall().resolves({ accessToken: 'FIRST_TOKEN', expiresIn: LONG_EXPIRY_TIME }) - .onSecondCall().resolves({ accessToken: 'SECOND_TOKEN', expiresIn: LONG_EXPIRY_TIME }) + .onFirstCall() + .resolves({ accessToken: 'FIRST_TOKEN', expiresIn: LONG_EXPIRY_TIME }) + .onSecondCall() + .resolves({ accessToken: 'SECOND_TOKEN', expiresIn: LONG_EXPIRY_TIME }) }) it('returns the cached token', async () => { @@ -49,8 +51,10 @@ describe('Charging Module Token Cache plugin', () => { describe('and the second request is made after the cache expires', () => { before(() => { Sinon.stub(ChargingModuleTokenRequest, 'send') - .onFirstCall().resolves({ accessToken: 'FIRST_TOKEN', expiresIn: SHORT_EXPIRY_TIME }) - .onSecondCall().resolves({ accessToken: 'SECOND_TOKEN', expiresIn: LONG_EXPIRY_TIME }) + .onFirstCall() + .resolves({ accessToken: 'FIRST_TOKEN', expiresIn: SHORT_EXPIRY_TIME }) + .onSecondCall() + .resolves({ accessToken: 'SECOND_TOKEN', expiresIn: LONG_EXPIRY_TIME }) }) it('returns a new token', async () => { @@ -65,8 +69,10 @@ describe('Charging Module Token Cache plugin', () => { describe('When the first call returns an invalid token', () => { beforeEach(() => { Sinon.stub(ChargingModuleTokenRequest, 'send') - .onFirstCall().resolves({ accessToken: null, expiresIn: null }) - .onSecondCall().resolves({ accessToken: 'VALID_TOKEN', expiresIn: LONG_EXPIRY_TIME }) + .onFirstCall() + .resolves({ accessToken: null, expiresIn: null }) + .onSecondCall() + .resolves({ accessToken: 'VALID_TOKEN', expiresIn: LONG_EXPIRY_TIME }) }) it('returns a null token', async () => { diff --git a/test/plugins/error-pages.plugin.test.js b/test/plugins/error-pages.plugin.test.js index bb2b79461d..6f6eb2d983 100644 --- a/test/plugins/error-pages.plugin.test.js +++ b/test/plugins/error-pages.plugin.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/plugins/global-notifier.plugin.test.js b/test/plugins/global-notifier.plugin.test.js index 65a2d7cccb..f5f03b647d 100644 --- a/test/plugins/global-notifier.plugin.test.js +++ b/test/plugins/global-notifier.plugin.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/base.presenter.test.js b/test/presenters/base.presenter.test.js index 43262bf0f4..fc830c5529 100644 --- a/test/presenters/base.presenter.test.js +++ b/test/presenters/base.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/bill-licences/remove-bill-licence.presenter.test.js b/test/presenters/bill-licences/remove-bill-licence.presenter.test.js index 67368efda6..1804a9e72d 100644 --- a/test/presenters/bill-licences/remove-bill-licence.presenter.test.js +++ b/test/presenters/bill-licences/remove-bill-licence.presenter.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -79,7 +79,7 @@ describe('Remove Bill Licence presenter', () => { }) }) -function _billLicenceSummary () { +function _billLicenceSummary() { return { id: 'a4fbaa27-a91c-4328-a1b8-774ade11027b', licenceId: '2eaa831d-7bd6-4b0a-aaf1-3aacafec6bf2', @@ -95,22 +95,24 @@ function _billLicenceSummary () { name: 'Example Trading Ltd', type: 'organisation' }, - billingAccountAddresses: [{ - id: '1d440029-745a-47ec-a43e-9f4a36014126', - company: null, - contact: { - id: '95ba53be-543f-415b-90b1-08f58f63ff74', - contactType: 'person', - dataSource: 'wrls', - department: null, - firstName: 'Amara', - initials: null, - lastName: 'Gupta', - middleInitials: null, - salutation: null, - suffix: null + billingAccountAddresses: [ + { + id: '1d440029-745a-47ec-a43e-9f4a36014126', + company: null, + contact: { + id: '95ba53be-543f-415b-90b1-08f58f63ff74', + contactType: 'person', + dataSource: 'wrls', + department: null, + firstName: 'Amara', + initials: null, + lastName: 'Gupta', + middleInitials: null, + salutation: null, + suffix: null + } } - }] + ] }, billRun: { id: '0e61c36f-f22f-4534-8247-b73a97f551b5', diff --git a/test/presenters/bill-licences/view-bill-licence.presenter.test.js b/test/presenters/bill-licences/view-bill-licence.presenter.test.js index 7721238bb8..c2c8e78a82 100644 --- a/test/presenters/bill-licences/view-bill-licence.presenter.test.js +++ b/test/presenters/bill-licences/view-bill-licence.presenter.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -171,7 +171,7 @@ describe('View Bill Licence presenter', () => { }) }) -function _testBillLicence () { +function _testBillLicence() { return { id: 'a4fbaa27-a91c-4328-a1b8-774ade11027b', licenceId: '2eaa831d-7bd6-4b0a-aaf1-3aacafec6bf2', diff --git a/test/presenters/bill-licences/view-compensation-charge-transaction.presenter.test.js b/test/presenters/bill-licences/view-compensation-charge-transaction.presenter.test.js index 1ac958b921..903fccfdfd 100644 --- a/test/presenters/bill-licences/view-compensation-charge-transaction.presenter.test.js +++ b/test/presenters/bill-licences/view-compensation-charge-transaction.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/bill-licences/view-minimum-charge-transaction.presenter.test.js b/test/presenters/bill-licences/view-minimum-charge-transaction.presenter.test.js index 5a534e5ee8..cc357b7106 100644 --- a/test/presenters/bill-licences/view-minimum-charge-transaction.presenter.test.js +++ b/test/presenters/bill-licences/view-minimum-charge-transaction.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/bill-licences/view-standard-charge-transaction.presenter.test.js b/test/presenters/bill-licences/view-standard-charge-transaction.presenter.test.js index 0929e9058d..c0822146c7 100644 --- a/test/presenters/bill-licences/view-standard-charge-transaction.presenter.test.js +++ b/test/presenters/bill-licences/view-standard-charge-transaction.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -82,7 +82,9 @@ describe('View Standard Charge Transaction presenter', () => { it('returns "Supported source Candover (£14567.00), Public Water Supply (£2498.00)"', () => { const result = ViewStandardChargeTransactionPresenter.go(transaction) - expect(result.additionalCharges).to.equal('Supported source Candover (£14567.00), Public Water Supply (£2498.00)') + expect(result.additionalCharges).to.equal( + 'Supported source Candover (£14567.00), Public Water Supply (£2498.00)' + ) }) }) }) @@ -328,7 +330,7 @@ describe('View Standard Charge Transaction presenter', () => { }) }) -function _baseTransaction () { +function _baseTransaction() { return { billingTransactionId: '3ca5221c-94c4-4246-8e96-41084cad1429', authorisedDays: 214, @@ -346,7 +348,7 @@ function _baseTransaction () { } } -function _presrocTransaction () { +function _presrocTransaction() { const transaction = { ..._baseTransaction(), loss: 'high', @@ -369,7 +371,7 @@ function _presrocTransaction () { return transaction } -function _srocTransaction () { +function _srocTransaction() { const transaction = { ..._baseTransaction(), aggregateFactor: 1, diff --git a/test/presenters/bill-runs/create-bill-run-event.presenter.test.js b/test/presenters/bill-runs/create-bill-run-event.presenter.test.js index 034d034ff2..1a623793e0 100644 --- a/test/presenters/bill-runs/create-bill-run-event.presenter.test.js +++ b/test/presenters/bill-runs/create-bill-run-event.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -23,9 +23,7 @@ describe('Create Bill Run Event presenter', () => { const region = RegionHelper.select() const testBillRun = await BillRunHelper.add({ regionId: region.id }) - billRun = await BillRunModel.query() - .findById(testBillRun.id) - .withGraphFetched('region') + billRun = await BillRunModel.query().findById(testBillRun.id).withGraphFetched('region') }) it('correctly presents the data', () => { diff --git a/test/presenters/bill-runs/create-bill-run.presenter.test.js b/test/presenters/bill-runs/create-bill-run.presenter.test.js index e60b43c8a8..523a557a1f 100644 --- a/test/presenters/bill-runs/create-bill-run.presenter.test.js +++ b/test/presenters/bill-runs/create-bill-run.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/bill-runs/empty-bill-run.presenter.test.js b/test/presenters/bill-runs/empty-bill-run.presenter.test.js index d16c07aebb..366df7ce65 100644 --- a/test/presenters/bill-runs/empty-bill-run.presenter.test.js +++ b/test/presenters/bill-runs/empty-bill-run.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -36,7 +36,7 @@ describe('Empty Bill Run presenter', () => { }) }) -function _testBillRun () { +function _testBillRun() { return { id: '420e948f-1992-437e-8a47-74c0066cb017', batchType: 'supplementary', diff --git a/test/presenters/bill-runs/errored-bill-run.presenter.test.js b/test/presenters/bill-runs/errored-bill-run.presenter.test.js index 03bf83391a..3c2dd346ab 100644 --- a/test/presenters/bill-runs/errored-bill-run.presenter.test.js +++ b/test/presenters/bill-runs/errored-bill-run.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -56,14 +56,16 @@ describe('Errored Bill Run presenter', () => { it('returns the generic error message', () => { const result = ErroredBillRunPresenter.go(billRun) - expect(result.errorMessage).to.equal('No error code was assigned. We have no further information at this time.') + expect(result.errorMessage).to.equal( + 'No error code was assigned. We have no further information at this time.' + ) }) }) }) }) }) -function _testBillRun () { +function _testBillRun() { return { id: '420e948f-1992-437e-8a47-74c0066cb017', batchType: 'supplementary', diff --git a/test/presenters/bill-runs/index-bill-runs.presenter.test.js b/test/presenters/bill-runs/index-bill-runs.presenter.test.js index fef530e55c..0bb64a487a 100644 --- a/test/presenters/bill-runs/index-bill-runs.presenter.test.js +++ b/test/presenters/bill-runs/index-bill-runs.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -133,7 +133,9 @@ describe('Index Bill Runs presenter', () => { it('generates the href needed to link to the old bill run review', () => { const results = IndexBillRunsPresenter.go(billRuns) - expect(results[0].link).to.equal('/billing/batch/31fec553-f2de-40cf-a8d7-a5fb65f5761b/two-part-tariff-review') + expect(results[0].link).to.equal( + '/billing/batch/31fec553-f2de-40cf-a8d7-a5fb65f5761b/two-part-tariff-review' + ) expect(results[1].link).to.equal('/system/bill-runs/dfdde4c9-9a0e-440d-b297-7143903c6734') }) }) @@ -194,7 +196,7 @@ describe('Index Bill Runs presenter', () => { }) }) -function _billRuns () { +function _billRuns() { return [ { id: '31fec553-f2de-40cf-a8d7-a5fb65f5761b', diff --git a/test/presenters/bill-runs/review/authorised.presenter.test.js b/test/presenters/bill-runs/review/authorised.presenter.test.js index 725c3ac7e7..a8c6fab4f7 100644 --- a/test/presenters/bill-runs/review/authorised.presenter.test.js +++ b/test/presenters/bill-runs/review/authorised.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/bill-runs/review/base-review.presenter.test.js b/test/presenters/bill-runs/review/base-review.presenter.test.js index 707588366a..8b0fc06ebd 100644 --- a/test/presenters/bill-runs/review/base-review.presenter.test.js +++ b/test/presenters/bill-runs/review/base-review.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/bill-runs/review/edit.presenter.test.js b/test/presenters/bill-runs/review/edit.presenter.test.js index 9dc4b6907f..a43f556fb2 100644 --- a/test/presenters/bill-runs/review/edit.presenter.test.js +++ b/test/presenters/bill-runs/review/edit.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/bill-runs/review/factors.presenter.test.js b/test/presenters/bill-runs/review/factors.presenter.test.js index 10cc08c063..b969494e6c 100644 --- a/test/presenters/bill-runs/review/factors.presenter.test.js +++ b/test/presenters/bill-runs/review/factors.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/bill-runs/review/remove.presenter.test.js b/test/presenters/bill-runs/review/remove.presenter.test.js index 0302481be8..dd52d66be8 100644 --- a/test/presenters/bill-runs/review/remove.presenter.test.js +++ b/test/presenters/bill-runs/review/remove.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/bill-runs/review/review-bill-run.presenter.test.js b/test/presenters/bill-runs/review/review-bill-run.presenter.test.js index 7d082f6f07..a5505e79f6 100644 --- a/test/presenters/bill-runs/review/review-bill-run.presenter.test.js +++ b/test/presenters/bill-runs/review/review-bill-run.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { beforeEach, describe, it } = exports.lab = Lab.script() +const { beforeEach, describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -51,7 +51,8 @@ describe('Bill Runs Review - Review Bill Run presenter', () => { billRunType: 'two-part tariff', numberOfLicencesDisplayed: 3, numberOfLicencesToReview: 1, - reviewMessage: 'You need to review 1 licence with returns data issues. You can then continue and send the bill run.', + reviewMessage: + 'You need to review 1 licence with returns data issues. You can then continue and send the bill run.', totalNumberOfLicences: 3, preparedLicences: [ { @@ -174,7 +175,7 @@ describe('Bill Runs Review - Review Bill Run presenter', () => { }) }) -function _testBillRun () { +function _testBillRun() { return { id: 'b21bd372-cd04-405d-824e-5180d854121c', createdAt: new Date('2024-01-17'), @@ -188,7 +189,7 @@ function _testBillRun () { } } -function _testLicences () { +function _testLicences() { return [ // Licence with no issues { diff --git a/test/presenters/bill-runs/review/review-charge-element.presenter.test.js b/test/presenters/bill-runs/review/review-charge-element.presenter.test.js index 54dd22a55c..08cdd92257 100644 --- a/test/presenters/bill-runs/review/review-charge-element.presenter.test.js +++ b/test/presenters/bill-runs/review/review-charge-element.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/bill-runs/review/review-charge-reference.presenter.test.js b/test/presenters/bill-runs/review/review-charge-reference.presenter.test.js index daffa75b5c..0c1d9f5bf5 100644 --- a/test/presenters/bill-runs/review/review-charge-reference.presenter.test.js +++ b/test/presenters/bill-runs/review/review-charge-reference.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -66,10 +66,7 @@ describe('Bill Runs Review - Review Charge Reference presenter', () => { it('adds it to the ""adjustments" property and displays both amended and original values', () => { const result = ReviewChargeReferencePresenter.go(reviewChargeReference) - expect(result.adjustments).to.equal([ - 'Aggregate factor (0.6 / 0.5)', - 'Charge adjustment (1 / 1)' - ]) + expect(result.adjustments).to.equal(['Aggregate factor (0.6 / 0.5)', 'Charge adjustment (1 / 1)']) }) }) @@ -82,10 +79,7 @@ describe('Bill Runs Review - Review Charge Reference presenter', () => { it('adds it to the ""adjustments" property and displays both amended and original values', () => { const result = ReviewChargeReferencePresenter.go(reviewChargeReference) - expect(result.adjustments).to.equal([ - 'Aggregate factor (1 / 1)', - 'Charge adjustment (0.8 / 0.7)' - ]) + expect(result.adjustments).to.equal(['Aggregate factor (1 / 1)', 'Charge adjustment (0.8 / 0.7)']) }) }) diff --git a/test/presenters/bill-runs/review/review-licence.presenter.test.js b/test/presenters/bill-runs/review/review-licence.presenter.test.js index 919212c8b4..457bb8aa65 100644 --- a/test/presenters/bill-runs/review/review-licence.presenter.test.js +++ b/test/presenters/bill-runs/review/review-licence.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -165,11 +165,7 @@ describe('Bill Runs Review - Review Licence presenter', () => { describe("when the sum allocated to a charge reference's charge elements equal to its authorised volume", () => { beforeEach(() => { - reviewLicence - .reviewChargeVersions[0] - .reviewChargeReferences[0] - .reviewChargeElements[0] - .amendedAllocated = 9.092 + reviewLicence.reviewChargeVersions[0].reviewChargeReferences[0].reviewChargeElements[0].amendedAllocated = 9.092 }) it('returns false', () => { @@ -181,11 +177,7 @@ describe('Bill Runs Review - Review Licence presenter', () => { describe("when the sum allocated to a charge reference's charge elements is greater than its authorised volume", () => { beforeEach(() => { - reviewLicence - .reviewChargeVersions[0] - .reviewChargeReferences[0] - .reviewChargeElements[0] - .amendedAllocated = 10 + reviewLicence.reviewChargeVersions[0].reviewChargeReferences[0].reviewChargeElements[0].amendedAllocated = 10 }) it('returns true', () => { diff --git a/test/presenters/bill-runs/setup/create.presenter.test.js b/test/presenters/bill-runs/setup/create.presenter.test.js index c52ff79b7b..3b644d6d03 100644 --- a/test/presenters/bill-runs/setup/create.presenter.test.js +++ b/test/presenters/bill-runs/setup/create.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -127,7 +127,9 @@ describe('Bill Runs Setup Create presenter', () => { it('returns a link to the PRESROC review page', () => { const result = CreatePresenter.go(session, matchingBillRun) - expect(result.billRunLink).to.equal('/billing/batch/c0608545-9870-4605-a407-5ff49f8a5182/two-part-tariff-review') + expect(result.billRunLink).to.equal( + '/billing/batch/c0608545-9870-4605-a407-5ff49f8a5182/two-part-tariff-review' + ) }) }) }) @@ -142,7 +144,9 @@ describe('Bill Runs Setup Create presenter', () => { it('returns the "You need to confirm or cancel this [..]" message', () => { const result = CreatePresenter.go(session, matchingBillRun) - expect(result.warningMessage).to.equal('You need to confirm or cancel this bill run before you can create a new one') + expect(result.warningMessage).to.equal( + 'You need to confirm or cancel this bill run before you can create a new one' + ) }) }) @@ -159,7 +163,9 @@ describe('Bill Runs Setup Create presenter', () => { it('returns the "You can only have one [..]" message', () => { const result = CreatePresenter.go(session, matchingBillRun) - expect(result.warningMessage).to.equal('You can only have one Two-part tariff per region in a financial year') + expect(result.warningMessage).to.equal( + 'You can only have one Two-part tariff per region in a financial year' + ) }) }) diff --git a/test/presenters/bill-runs/setup/region.presenter.test.js b/test/presenters/bill-runs/setup/region.presenter.test.js index 364af313f2..14da2a91d6 100644 --- a/test/presenters/bill-runs/setup/region.presenter.test.js +++ b/test/presenters/bill-runs/setup/region.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/bill-runs/setup/season.presenter.test.js b/test/presenters/bill-runs/setup/season.presenter.test.js index d6443b84c8..7344c5915b 100644 --- a/test/presenters/bill-runs/setup/season.presenter.test.js +++ b/test/presenters/bill-runs/setup/season.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/bill-runs/setup/type.presenter.test.js b/test/presenters/bill-runs/setup/type.presenter.test.js index e7c736b1f9..197225ecc7 100644 --- a/test/presenters/bill-runs/setup/type.presenter.test.js +++ b/test/presenters/bill-runs/setup/type.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/bill-runs/setup/year.presenter.test.js b/test/presenters/bill-runs/setup/year.presenter.test.js index 381b4776ae..2deb63dc41 100644 --- a/test/presenters/bill-runs/setup/year.presenter.test.js +++ b/test/presenters/bill-runs/setup/year.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -114,7 +114,7 @@ describe('Bill Runs Setup Year presenter', () => { }) }) -function _financialYearsData (selectedYear) { +function _financialYearsData(selectedYear) { return [ { text: '2023 to 2024', diff --git a/test/presenters/bill-runs/view-bill-run.presenter.test.js b/test/presenters/bill-runs/view-bill-run.presenter.test.js index 5ba8bd738b..e2d6c5a7f2 100644 --- a/test/presenters/bill-runs/view-bill-run.presenter.test.js +++ b/test/presenters/bill-runs/view-bill-run.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -203,7 +203,7 @@ describe('View Bill Run presenter', () => { }) }) -function _testBillRun () { +function _testBillRun() { return { id: '420e948f-1992-437e-8a47-74c0066cb017', batchType: 'supplementary', @@ -227,7 +227,7 @@ function _testBillRun () { } } -function _testBillSummaries () { +function _testBillSummaries() { return [ { id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', diff --git a/test/presenters/bill-runs/view-bill-summaries.presenter.test.js b/test/presenters/bill-runs/view-bill-summaries.presenter.test.js index aa5e5aba35..b3e9cba34d 100644 --- a/test/presenters/bill-runs/view-bill-summaries.presenter.test.js +++ b/test/presenters/bill-runs/view-bill-summaries.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -176,7 +176,7 @@ describe('View Bill Summaries presenter', () => { }) }) -function _testBillSummaries () { +function _testBillSummaries() { return [ { id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', diff --git a/test/presenters/bill-runs/view-cancel-bill-run.presenter.test.js b/test/presenters/bill-runs/view-cancel-bill-run.presenter.test.js index bd6e04d7c2..0742fe7578 100644 --- a/test/presenters/bill-runs/view-cancel-bill-run.presenter.test.js +++ b/test/presenters/bill-runs/view-cancel-bill-run.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -56,7 +56,9 @@ describe('Bill Runs - View Cancel Bill Run presenter', () => { it('returns a link to the PRESROC review page', () => { const result = ViewCancelBillRunPresenter.go(billRun) - expect(result.backLink).to.equal('/billing/batch/420e948f-1992-437e-8a47-74c0066cb017/two-part-tariff-review') + expect(result.backLink).to.equal( + '/billing/batch/420e948f-1992-437e-8a47-74c0066cb017/two-part-tariff-review' + ) }) }) }) @@ -72,7 +74,7 @@ describe('Bill Runs - View Cancel Bill Run presenter', () => { }) }) -function _testBillRun () { +function _testBillRun() { return { id: '420e948f-1992-437e-8a47-74c0066cb017', batchType: 'supplementary', diff --git a/test/presenters/bill-runs/view-send-bill-run.presenter.test.js b/test/presenters/bill-runs/view-send-bill-run.presenter.test.js index 61b333715c..c06364fb63 100644 --- a/test/presenters/bill-runs/view-send-bill-run.presenter.test.js +++ b/test/presenters/bill-runs/view-send-bill-run.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -35,7 +35,7 @@ describe('Bill Runs - View Send Bill Run presenter', () => { }) }) -function _testBillRun () { +function _testBillRun() { return { id: '420e948f-1992-437e-8a47-74c0066cb017', batchType: 'supplementary', diff --git a/test/presenters/bills/remove-bill.presenter.test.js b/test/presenters/bills/remove-bill.presenter.test.js index 66b1981033..ed95e4d87e 100644 --- a/test/presenters/bills/remove-bill.presenter.test.js +++ b/test/presenters/bills/remove-bill.presenter.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -150,7 +150,7 @@ describe('Remove Bill presenter', () => { }) }) -function _billSummary () { +function _billSummary() { const billingAccount = BillingAccountModel.fromJson({ id: 'e2b35a4a-7368-425f-9990-faa23efc0a25', accountNumber: 'T65757520A', @@ -159,22 +159,24 @@ function _billSummary () { name: 'Example Trading Ltd', type: 'organisation' }, - billingAccountAddresses: [{ - id: '1d440029-745a-47ec-a43e-9f4a36014126', - company: null, - contact: { - id: '95ba53be-543f-415b-90b1-08f58f63ff74', - contactType: 'person', - dataSource: 'wrls', - department: null, - firstName: 'Amara', - initials: null, - lastName: 'Gupta', - middleInitials: null, - salutation: null, - suffix: null + billingAccountAddresses: [ + { + id: '1d440029-745a-47ec-a43e-9f4a36014126', + company: null, + contact: { + id: '95ba53be-543f-415b-90b1-08f58f63ff74', + contactType: 'person', + dataSource: 'wrls', + department: null, + firstName: 'Amara', + initials: null, + lastName: 'Gupta', + middleInitials: null, + salutation: null, + suffix: null + } } - }] + ] }) return { diff --git a/test/presenters/bills/view-bill.presenter.test.js b/test/presenters/bills/view-bill.presenter.test.js index bdcd2120c4..67799fd0b8 100644 --- a/test/presenters/bills/view-bill.presenter.test.js +++ b/test/presenters/bills/view-bill.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -295,7 +295,7 @@ describe('View Bill presenter', () => { }) }) -function _testBill () { +function _testBill() { return { id: '64924759-8142-4a08-9d1e-1e902cd9d316', creditNoteValue: 0, @@ -327,7 +327,7 @@ function _testBill () { } } -function _testBillingAccount () { +function _testBillingAccount() { const data = { id: 'ee3f5562-26ad-4d58-9b59-5c388a13d7d0', accountNumber: 'E88888888A', diff --git a/test/presenters/bills/view-licence-summaries.presenter.test.js b/test/presenters/bills/view-licence-summaries.presenter.test.js index aa9e683678..9c4b5c68d8 100644 --- a/test/presenters/bills/view-licence-summaries.presenter.test.js +++ b/test/presenters/bills/view-licence-summaries.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -69,7 +69,7 @@ describe('View Licence Summaries presenter', () => { }) }) -function _testLicenceSummaries () { +function _testLicenceSummaries() { return [ { id: 'e37320ba-10c8-4954-8bc4-6982e56ded41', diff --git a/test/presenters/charging-module/create-customer-change.presenter.test.js b/test/presenters/charging-module/create-customer-change.presenter.test.js index 3aad0339ec..ea5b36f3e4 100644 --- a/test/presenters/charging-module/create-customer-change.presenter.test.js +++ b/test/presenters/charging-module/create-customer-change.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/charging-module/create-transaction.presenter.test.js b/test/presenters/charging-module/create-transaction.presenter.test.js index d9ae535535..3a19764c84 100644 --- a/test/presenters/charging-module/create-transaction.presenter.test.js +++ b/test/presenters/charging-module/create-transaction.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -46,10 +46,7 @@ describe('Charging Module Create Transaction presenter', () => { ]) .withGraphFetched('region') .modifyGraph('licence.region', (builder) => { - builder.select([ - 'id', - 'chargeRegionId' - ]) + builder.select(['id', 'chargeRegionId']) }) // NOTE: The transaction object the presenter expects is what `FormatSrocTransactionLineService` returns rather @@ -86,7 +83,9 @@ describe('Charging Module Create Transaction presenter', () => { expect(result.compensationCharge).to.equal(false) expect(result.customerReference).to.equal(accountNumber) expect(result.licenceNumber).to.equal(licence.licenceRef) - expect(result.lineDescription).to.equal('Water abstraction charge: Agriculture other than spray irrigation at East Rudham') + expect(result.lineDescription).to.equal( + 'Water abstraction charge: Agriculture other than spray irrigation at East Rudham' + ) expect(result.loss).to.equal('medium') expect(result.region).to.equal(region.chargeRegionId) expect(result.regionalChargingArea).to.equal('Southern') diff --git a/test/presenters/import/legacy/address.presenter.test.js b/test/presenters/import/legacy/address.presenter.test.js index 5ce550f79b..665f59e071 100644 --- a/test/presenters/import/legacy/address.presenter.test.js +++ b/test/presenters/import/legacy/address.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -43,7 +43,7 @@ describe('Import Legacy Address presenter', () => { }) }) -function _legacyAddress () { +function _legacyAddress() { return { address1: '4 Privet Drive', address2: null, diff --git a/test/presenters/import/legacy/company-address.presenter.test.js b/test/presenters/import/legacy/company-address.presenter.test.js index ed87b50442..5e362c246c 100644 --- a/test/presenters/import/legacy/company-address.presenter.test.js +++ b/test/presenters/import/legacy/company-address.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -121,7 +121,7 @@ describe('Import Legacy Company Address presenter', () => { }) }) -function _legacyLicenceHolderCompanyAddress (licenceRoleId) { +function _legacyLicenceHolderCompanyAddress(licenceRoleId) { return { company_external_id: '1:007', external_id: '7:777', diff --git a/test/presenters/import/legacy/company-contact.presenter.test.js b/test/presenters/import/legacy/company-contact.presenter.test.js index 2ea5a1acca..f43fc4b5bd 100644 --- a/test/presenters/import/legacy/company-contact.presenter.test.js +++ b/test/presenters/import/legacy/company-contact.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,7 +32,7 @@ describe('Import Legacy Company Contact presenter', () => { }) }) -function _legacyContact (licenceRoleId) { +function _legacyContact(licenceRoleId) { return { salutation: 'Mr', initials: 'H', diff --git a/test/presenters/import/legacy/company.presenter.test.js b/test/presenters/import/legacy/company.presenter.test.js index 02f8abec95..ae8b9790fb 100644 --- a/test/presenters/import/legacy/company.presenter.test.js +++ b/test/presenters/import/legacy/company.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -30,7 +30,7 @@ describe('Import Legacy Company presenter', () => { }) }) -function _legacyCompany () { +function _legacyCompany() { return { name: 'ACME', type: 'organisation', diff --git a/test/presenters/import/legacy/contact.presenter.test.js b/test/presenters/import/legacy/contact.presenter.test.js index 770af60fd6..7523505e4d 100644 --- a/test/presenters/import/legacy/contact.presenter.test.js +++ b/test/presenters/import/legacy/contact.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -30,7 +30,7 @@ describe('Import Legacy Contact presenter', () => { }) }) -function _legacyContact () { +function _legacyContact() { return { salutation: 'Mr', initials: 'H', diff --git a/test/presenters/import/legacy/licence-document-role.presenter.test.js b/test/presenters/import/legacy/licence-document-role.presenter.test.js index e3338793c0..8222af842a 100644 --- a/test/presenters/import/legacy/licence-document-role.presenter.test.js +++ b/test/presenters/import/legacy/licence-document-role.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,7 +47,7 @@ describe('Import Legacy Licence Document role presenter', () => { }) }) -function _legacyLicenceDocumentRole (licenceRef, licenceRoleId) { +function _legacyLicenceDocumentRole(licenceRef, licenceRoleId) { return { address_id: '1:007', company_id: '1:007', diff --git a/test/presenters/import/legacy/licence-document.presenter.test.js b/test/presenters/import/legacy/licence-document.presenter.test.js index eace2af7e4..eb4fd07429 100644 --- a/test/presenters/import/legacy/licence-document.presenter.test.js +++ b/test/presenters/import/legacy/licence-document.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -35,7 +35,7 @@ describe('Import Legacy Licence Document presenter', () => { }) }) -function _legacyLicenceDocument (licenceRef) { +function _legacyLicenceDocument(licenceRef) { return { end_date: null, start_date: new Date('1999-01-01'), diff --git a/test/presenters/import/legacy/licence-version-purpose-condition.presenter.test.js b/test/presenters/import/legacy/licence-version-purpose-condition.presenter.test.js index 132639eed8..6e1ea642bb 100644 --- a/test/presenters/import/legacy/licence-version-purpose-condition.presenter.test.js +++ b/test/presenters/import/legacy/licence-version-purpose-condition.presenter.test.js @@ -4,12 +4,11 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test -const LicenceVersionPurposeConditionsPresenter = - require('../../../../app/presenters/import/legacy/licence-version-purpose-condition.presenter.js') +const LicenceVersionPurposeConditionsPresenter = require('../../../../app/presenters/import/legacy/licence-version-purpose-condition.presenter.js') describe('Import Legacy Licence Version Purpose Conditions presenter', () => { let legacyLicenceVersionPurposeCondition @@ -31,7 +30,7 @@ describe('Import Legacy Licence Version Purpose Conditions presenter', () => { }) }) -function _legacyLicenceVersionPurposeCondition () { +function _legacyLicenceVersionPurposeCondition() { return { external_id: '172640:6:10000004', licence_version_purpose_condition_type_id: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', diff --git a/test/presenters/import/legacy/licence-version-purpose.presenter.test.js b/test/presenters/import/legacy/licence-version-purpose.presenter.test.js index 3663fe17d1..1052234581 100644 --- a/test/presenters/import/legacy/licence-version-purpose.presenter.test.js +++ b/test/presenters/import/legacy/licence-version-purpose.presenter.test.js @@ -4,12 +4,11 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test -const LicenceVersionPurposePresenter = - require('../../../../app/presenters/import/legacy/licence-version-purpose.presenter.js') +const LicenceVersionPurposePresenter = require('../../../../app/presenters/import/legacy/licence-version-purpose.presenter.js') describe('Import Legacy Licence Version Purpose presenter', () => { let legacyLicenceVersionPurpose @@ -42,7 +41,7 @@ describe('Import Legacy Licence Version Purpose presenter', () => { }) }) -function _legacyLicenceVersionPurpose () { +function _legacyLicenceVersionPurpose() { return { abstraction_period_end_day: 31, abstraction_period_end_month: 3, diff --git a/test/presenters/import/legacy/licence-version.presenter.test.js b/test/presenters/import/legacy/licence-version.presenter.test.js index 42a6a7bc06..56325a2945 100644 --- a/test/presenters/import/legacy/licence-version.presenter.test.js +++ b/test/presenters/import/legacy/licence-version.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -54,7 +54,7 @@ describe('Import Legacy Licence Version presenter', () => { }) }) -function _legacyLicenceVersion () { +function _legacyLicenceVersion() { return { effective_end_date: null, effective_start_date: new Date('1999-01-01'), diff --git a/test/presenters/import/legacy/licence.presenter.test.js b/test/presenters/import/legacy/licence.presenter.test.js index 0871ac9f65..bda715f060 100644 --- a/test/presenters/import/legacy/licence.presenter.test.js +++ b/test/presenters/import/legacy/licence.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -103,7 +103,7 @@ describe('Import Legacy Licence presenter', () => { }) }) -function _legacyLicence () { +function _legacyLicence() { return { historical_area_code: 'KAEA', environmental_improvement_unit_charge_code: 'SOOTH', diff --git a/test/presenters/licences/customer-contacts.presenter.test.js b/test/presenters/licences/customer-contacts.presenter.test.js index 98ce2acc8c..5d7d763474 100644 --- a/test/presenters/licences/customer-contacts.presenter.test.js +++ b/test/presenters/licences/customer-contacts.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/licences/licence-contacts.presenter.test.js b/test/presenters/licences/licence-contacts.presenter.test.js index afdfd13ab3..d7cec66e6d 100644 --- a/test/presenters/licences/licence-contacts.presenter.test.js +++ b/test/presenters/licences/licence-contacts.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -40,20 +40,22 @@ describe('Licence Contacts presenter', () => { expect(result).to.equal({ customerId: 'ebe95a21-c6f6-4f15-8856-a48ffc737731', - licenceContacts: [{ - address: { - address1: '34 Eastgate', - address2: null, - address3: null, - address4: null, - address5: null, - address6: null, - country: 'United Kingdom', - postcode: 'CF71 7DG' - }, - communicationType: 'Licence Holder', - name: 'Acme ltd' - }] + licenceContacts: [ + { + address: { + address1: '34 Eastgate', + address2: null, + address3: null, + address4: null, + address5: null, + address6: null, + country: 'United Kingdom', + postcode: 'CF71 7DG' + }, + communicationType: 'Licence Holder', + name: 'Acme ltd' + } + ] }) }) diff --git a/test/presenters/licences/supplementary/mark-for-supplementary-billing.presenter.test.js b/test/presenters/licences/supplementary/mark-for-supplementary-billing.presenter.test.js index 213a2e0114..42f65656ff 100644 --- a/test/presenters/licences/supplementary/mark-for-supplementary-billing.presenter.test.js +++ b/test/presenters/licences/supplementary/mark-for-supplementary-billing.presenter.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -52,7 +52,12 @@ describe('Mark For Supplementary Billing presenter', () => { financialYears: [ { text: '2023 to 2024', value: 2024, attributes: { 'data-test': 'sroc-years-2024' } }, { text: '2022 to 2023', value: 2023, attributes: { 'data-test': 'sroc-years-2023' } }, - { text: 'Before 2022', value: 'preSroc', hint: { text: 'Old charge scheme' }, attributes: { 'data-test': 'pre-sroc-years' } } + { + text: 'Before 2022', + value: 'preSroc', + hint: { text: 'Old charge scheme' }, + attributes: { 'data-test': 'pre-sroc-years' } + } ] }) }) diff --git a/test/presenters/licences/view-licence-bills.presenter.test.js b/test/presenters/licences/view-licence-bills.presenter.test.js index 8c730ed928..aa774fd3c6 100644 --- a/test/presenters/licences/view-licence-bills.presenter.test.js +++ b/test/presenters/licences/view-licence-bills.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -22,17 +22,19 @@ describe('View Licence Bills presenter', () => { const result = ViewLicenceBillsPresenter.go([bill]) expect(result).to.equal({ - bills: [{ - accountNumber: 'BA1234443S', - billingAccountId: '2563bda0-73d8-4055-b3e7-421cf188d4dc', - billId: 'dfed8cdd-05c0-4f03-9a95-a7bae74fe7be', - billNumber: 'WAC0003872T', - billRunType: 'Annual', - credit: false, - dateCreated: '1 January 2020', - financialYearEnding: '2021', - total: '£1,234,567.89' - }] + bills: [ + { + accountNumber: 'BA1234443S', + billingAccountId: '2563bda0-73d8-4055-b3e7-421cf188d4dc', + billId: 'dfed8cdd-05c0-4f03-9a95-a7bae74fe7be', + billNumber: 'WAC0003872T', + billRunType: 'Annual', + credit: false, + dateCreated: '1 January 2020', + financialYearEnding: '2021', + total: '£1,234,567.89' + } + ] }) }) @@ -101,7 +103,7 @@ describe('View Licence Bills presenter', () => { }) }) -function _bill () { +function _bill() { return { accountNumber: 'BA1234443S', billRun: { batchType: 'annual', scheme: 'sroc', summer: false }, diff --git a/test/presenters/licences/view-licence-communications.presenter.test.js b/test/presenters/licences/view-licence-communications.presenter.test.js index db3387f317..0da933c186 100644 --- a/test/presenters/licences/view-licence-communications.presenter.test.js +++ b/test/presenters/licences/view-licence-communications.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -14,23 +14,24 @@ describe('View Licence Communications presenter', () => { let communications beforeEach(() => { - communications = [{ - id: '3ce7d0b6-610f-4cb2-9d4c-9761db797141', - messageType: 'letter', - messageRef: 'returns_invitation_licence_holder_letter', - event: { - createdAt: '2024-05-15T10:27:15.000Z', - metadata: { - name: 'Returns: invitation', - options: { - } - }, - type: 'notification', - subtype: 'returnInvitation', - status: 'processed', - issuer: 'admin-internal@wrls.gov.uk' + communications = [ + { + id: '3ce7d0b6-610f-4cb2-9d4c-9761db797141', + messageType: 'letter', + messageRef: 'returns_invitation_licence_holder_letter', + event: { + createdAt: '2024-05-15T10:27:15.000Z', + metadata: { + name: 'Returns: invitation', + options: {} + }, + type: 'notification', + subtype: 'returnInvitation', + status: 'processed', + issuer: 'admin-internal@wrls.gov.uk' + } } - }] + ] }) describe('when provided with populated communications data', () => { @@ -38,17 +39,18 @@ describe('View Licence Communications presenter', () => { const result = ViewLicenceCommunicationsPresenter.go(communications) expect(result).to.equal({ - communications: [{ - id: '3ce7d0b6-610f-4cb2-9d4c-9761db797141', - method: 'Letter', - sender: 'admin-internal@wrls.gov.uk', - sent: '15 May 2024', - type: { - label: 'Returns: invitation', - pdf: false, - sentVia: 'sent 15 May 2024 via letter' + communications: [ + { + id: '3ce7d0b6-610f-4cb2-9d4c-9761db797141', + method: 'Letter', + sender: 'admin-internal@wrls.gov.uk', + sent: '15 May 2024', + type: { + label: 'Returns: invitation', + pdf: false, + sentVia: 'sent 15 May 2024 via letter' + } } - } ] }) }) diff --git a/test/presenters/licences/view-licence-contact-details.presenter.test.js b/test/presenters/licences/view-licence-contact-details.presenter.test.js index 8e987bd4a0..b9fd439e97 100644 --- a/test/presenters/licences/view-licence-contact-details.presenter.test.js +++ b/test/presenters/licences/view-licence-contact-details.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -27,39 +27,21 @@ describe('View Licence Contact Details presenter', () => { pageTitle: 'Licence contact details', licenceContactDetails: [ { - address: [ - 'ENVIRONMENT AGENCY', - 'HORIZON HOUSE', - 'DEANERY ROAD', - 'BRISTOL', - 'BS1 5AH', - 'United Kingdom' - ], + address: ['ENVIRONMENT AGENCY', 'HORIZON HOUSE', 'DEANERY ROAD', 'BRISTOL', 'BS1 5AH', 'United Kingdom'], role: 'Licence holder', name: 'Acme ltd' }, { - address: [ - 'Furland', - 'Crewkerne', - 'Somerset', - 'TA18 7TT', - 'United Kingdom' - ], + address: ['Furland', 'Crewkerne', 'Somerset', 'TA18 7TT', 'United Kingdom'], role: 'Licence contact', name: 'Furland Farm' }, { - address: [ - 'Crinkley Bottom', - 'Cricket St Thomas', - 'Somerset', - 'TA20 1KL', - 'United Kingdom' - ], + address: ['Crinkley Bottom', 'Cricket St Thomas', 'Somerset', 'TA20 1KL', 'United Kingdom'], role: 'Returns to', name: 'Mr N Edmonds' - }] + } + ] }) }) @@ -118,7 +100,7 @@ describe('View Licence Contact Details presenter', () => { }) }) -function _testFetchLicenceContactDetailsData () { +function _testFetchLicenceContactDetailsData() { return { id: '0a4ebb93-2e90-4e35-acd5-a5aa73466508', licenceRef: '00/111/222', diff --git a/test/presenters/licences/view-licence-history.presenter.test.js b/test/presenters/licences/view-licence-history.presenter.test.js index f2496961eb..5047a39ad6 100644 --- a/test/presenters/licences/view-licence-history.presenter.test.js +++ b/test/presenters/licences/view-licence-history.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -115,7 +115,9 @@ describe('View Licence History presenter', () => { it('returns the charge version link', () => { const result = ViewLicenceHistoryPresenter.go(licence) - expect(result.entries[0].link).to.equal('/licences/761bc44f-80d5-49ae-ab46-0a90495417b5/charge-information/dfe3d0d7-5e53-4e51-9748-169d01816642/view') + expect(result.entries[0].link).to.equal( + '/licences/761bc44f-80d5-49ae-ab46-0a90495417b5/charge-information/dfe3d0d7-5e53-4e51-9748-169d01816642/view' + ) }) }) @@ -149,9 +151,11 @@ describe('View Licence History presenter', () => { describe('and the reason does not map to a WRLS reason', () => { beforeEach(() => { licence.returnVersions[0].reason = null - licence.returnVersions[0].modLogs = [ModLogModel.fromJson({ - reasonDescription: 'This is a reason' - })] + licence.returnVersions[0].modLogs = [ + ModLogModel.fromJson({ + reasonDescription: 'This is a reason' + }) + ] }) it("returns the entry's reason", () => { @@ -191,7 +195,7 @@ describe('View Licence History presenter', () => { }) }) -function _testLicence () { +function _testLicence() { const changeReason = ChangeReasonModel.fromJson({ id: '0dee4596-0867-4997-8a00-e0998cfcefc0', description: 'Major change' @@ -206,9 +210,11 @@ function _testLicence () { id: '761bc44f-80d5-49ae-ab46-0a90495417b5', licenceRef: '01/123', licenceDocument: { - licenceDocumentRoles: [{ - id: '3b903973-2143-47fe-b7a2-b205aa8eb933' - }] + licenceDocumentRoles: [ + { + id: '3b903973-2143-47fe-b7a2-b205aa8eb933' + } + ] } }) @@ -248,14 +254,8 @@ function _testLicence () { return { id: testLicence.id, licenceRef: testLicence.licenceRef, - licenceVersions: [ - licenceVersions - ], - chargeVersions: [ - chargeVersions - ], - returnVersions: [ - returnVersions - ] + licenceVersions: [licenceVersions], + chargeVersions: [chargeVersions], + returnVersions: [returnVersions] } } diff --git a/test/presenters/licences/view-licence-points.presenter.test.js b/test/presenters/licences/view-licence-points.presenter.test.js index 82770d649f..88c658c903 100644 --- a/test/presenters/licences/view-licence-points.presenter.test.js +++ b/test/presenters/licences/view-licence-points.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -33,7 +33,8 @@ describe('View Licence Point presenter', () => { category: 'Single Point', depth: '123', description: 'RIVER OUSE AT BLETSOE', - gridReference: 'Within the area formed by the straight lines running between National Grid References SD 963 193, SD 963 193, SD 963 193 and SD 963 193 (RIVER OUSE AT BLETSOE)', + gridReference: + 'Within the area formed by the straight lines running between National Grid References SD 963 193, SD 963 193, SD 963 193 and SD 963 193 (RIVER OUSE AT BLETSOE)', hydroInterceptDistance: '8.01', hydroOffsetDistance: '5.56', hydroReference: 'TL 14/133', @@ -131,7 +132,9 @@ describe('View Licence Point presenter', () => { it('returns the point grid reference', () => { const result = ViewLicencePointPresenter.go(data) - expect(result.licencePoints[0].gridReference).to.equal('Within the area formed by the straight lines running between National Grid References SD 963 193, SD 963 193, SD 963 193 and SD 963 193 (RIVER OUSE AT BLETSOE)') + expect(result.licencePoints[0].gridReference).to.equal( + 'Within the area formed by the straight lines running between National Grid References SD 963 193, SD 963 193, SD 963 193 and SD 963 193 (RIVER OUSE AT BLETSOE)' + ) }) }) @@ -329,7 +332,7 @@ describe('View Licence Point presenter', () => { }) }) -function _testData () { +function _testData() { const point = PointModel.fromJson({ bgsReference: 'TL 14/123', category: 'Single Point', diff --git a/test/presenters/licences/view-licence-purposes.presenter.test.js b/test/presenters/licences/view-licence-purposes.presenter.test.js index 9bb249e488..a6c6f87062 100644 --- a/test/presenters/licences/view-licence-purposes.presenter.test.js +++ b/test/presenters/licences/view-licence-purposes.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -39,9 +39,7 @@ describe('View Licence Purpose presenter', () => { abstractionMethods: 'Unspecified Pump', abstractionMethodsTitle: 'Method of abstraction', abstractionPeriod: '1 April to 31 October', - abstractionPoints: [ - 'At National Grid Reference TL 23198 88603' - ], + abstractionPoints: ['At National Grid Reference TL 23198 88603'], abstractionPointsTitle: 'Abstraction point', purposeDescription: 'Spray Irrigation - Storage' } @@ -126,7 +124,9 @@ describe('View Licence Purpose presenter', () => { it('return the values display text joined with an ", and" (Unspecified Pump, Submersible Pump (Fixed), and Gravity & Sluice (Adjustable))', () => { const result = ViewLicencePurposePresenter.go(licence) - expect(result.licencePurposes[0].abstractionMethods).to.equal('Unspecified Pump, Submersible Pump (Fixed), and Gravity & Sluice (Adjustable)') + expect(result.licencePurposes[0].abstractionMethods).to.equal( + 'Unspecified Pump, Submersible Pump (Fixed), and Gravity & Sluice (Adjustable)' + ) }) }) @@ -266,7 +266,7 @@ describe('View Licence Purpose presenter', () => { }) }) -function _testLicence () { +function _testLicence() { const point = PointModel.fromJson({ id: 'ab80acd6-7c2a-4f51-87f5-2c397829a0bb', description: null, @@ -283,31 +283,37 @@ 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, - licenceVersionPurposePoints: [{ - abstractionMethod: 'Unspecified Pump' - }], - purpose: { - id: '0316229a-e76d-4785-bc2c-65075a1a8f50', - description: 'Spray Irrigation - Storage' - }, - points: [point] - }] - }] + 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, + licenceVersionPurposePoints: [ + { + abstractionMethod: 'Unspecified Pump' + } + ], + purpose: { + id: '0316229a-e76d-4785-bc2c-65075a1a8f50', + description: 'Spray Irrigation - Storage' + }, + points: [point] + } + ] + } + ] }) } diff --git a/test/presenters/licences/view-licence-returns.presenter.test.js b/test/presenters/licences/view-licence-returns.presenter.test.js index da7f622c7a..9053fc0789 100644 --- a/test/presenters/licences/view-licence-returns.presenter.test.js +++ b/test/presenters/licences/view-licence-returns.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -108,7 +108,9 @@ describe('View Licence returns presenter', () => { it('returns a link to the edit return log page', () => { const result = ViewLicenceReturnsPresenter.go(returnLogs, hasRequirements, auth) - expect(result.returns[1].link).to.equal('/return/internal?returnId=v1:1:01/123:10046820:2020-01-02:2020-02-01') + expect(result.returns[1].link).to.equal( + '/return/internal?returnId=v1:1:01/123:10046820:2020-01-02:2020-02-01' + ) }) }) @@ -134,7 +136,9 @@ describe('View Licence returns presenter', () => { it('returns a link to the edit return log page', () => { const result = ViewLicenceReturnsPresenter.go(returnLogs, hasRequirements, auth) - expect(result.returns[1].link).to.equal('/return/internal?returnId=v1:1:01/123:10046820:2020-01-02:2020-02-01') + expect(result.returns[1].link).to.equal( + '/return/internal?returnId=v1:1:01/123:10046820:2020-01-02:2020-02-01' + ) }) }) @@ -280,7 +284,7 @@ describe('View Licence returns presenter', () => { }) }) -function _returnLogs () { +function _returnLogs() { const returnLog = { id: 'v1:1:01/123:10046821:2020-01-02:2020-02-01', dueDate: new Date('2012-11-28'), diff --git a/test/presenters/licences/view-licence-set-up.presenter.test.js b/test/presenters/licences/view-licence-set-up.presenter.test.js index eaf44f9209..52b045653f 100644 --- a/test/presenters/licences/view-licence-set-up.presenter.test.js +++ b/test/presenters/licences/view-licence-set-up.presenter.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, afterEach, beforeEach } = exports.lab = Lab.script() +const { describe, it, afterEach, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -83,10 +83,12 @@ describe('View Licence Set Up presenter', () => { endDate: null, status: 'current', reason: 'change-to-special-agreement', - modLogs: [{ - id: '956a876a-2a51-4e86-bb39-3101395a741b', - reasonDescription: 'Special Agreement - Change' - }] + modLogs: [ + { + id: '956a876a-2a51-4e86-bb39-3101395a741b', + reasonDescription: 'Special Agreement - Change' + } + ] }) agreements = [] @@ -119,7 +121,12 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the agreements data', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements).to.equal([ @@ -149,7 +156,12 @@ describe('View Licence Set Up presenter', () => { describe('when all the actions are available for an agreement', () => { it('shows delete, end and recalculate bills actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].action).to.equal([ @@ -177,7 +189,12 @@ describe('View Licence Set Up presenter', () => { it('there are no actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].action).to.equal([]) @@ -191,7 +208,12 @@ describe('View Licence Set Up presenter', () => { it('there is no action link to delete', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].action).to.equal([ @@ -214,7 +236,12 @@ describe('View Licence Set Up presenter', () => { it('there is no action link to end the agreement', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].action).to.equal([ @@ -233,7 +260,12 @@ describe('View Licence Set Up presenter', () => { it('there is no action link to Recalculate bills', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].action).to.equal([ @@ -254,7 +286,12 @@ describe('View Licence Set Up presenter', () => { describe('is for Two-part tariff ', () => { it('correctly maps the code to the description', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].description).to.equal('Two-part tariff') @@ -268,7 +305,12 @@ describe('View Licence Set Up presenter', () => { it('correctly maps the code to the description', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].description).to.equal('Canal and Rivers Trust, supported source (S130S)') @@ -282,7 +324,12 @@ describe('View Licence Set Up presenter', () => { it('correctly maps the code to the description', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].description).to.equal('Canal and Rivers Trust, unsupported source (S130U)') @@ -294,8 +341,14 @@ describe('View Licence Set Up presenter', () => { agreement.financialAgreement.code = 'S126' }) it('correctly maps the code to the description', () => { - const result = ViewLicenceSetUpPresenter - .go(chargeVersions, workflows, agreements, returnVersions, auth, commonData) + const result = ViewLicenceSetUpPresenter.go( + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData + ) expect(result.agreements[0].description).to.equal('Abatement') }) @@ -309,7 +362,12 @@ describe('View Licence Set Up presenter', () => { it('shows delete, end and recalculate bills actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].action).to.equal([ @@ -343,7 +401,12 @@ describe('View Licence Set Up presenter', () => { it('shows delete, end and recalculate bills actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.agreements[0].action).to.equal([]) @@ -360,7 +423,12 @@ describe('View Licence Set Up presenter', () => { it('groups both types of data into the "chargeInformation" property', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.chargeInformation).to.equal([ @@ -373,11 +441,14 @@ describe('View Licence Set Up presenter', () => { reason: 'changed something' }, { - action: [{ - link: '/licences/' + - 'f91bf145-ce8e-481c-a842-4da90348062b/charge-information/0d514aa4-1550-46b1-8195-878957f2a5f8/view', - text: 'View' - }], + action: [ + { + link: + '/licences/' + + 'f91bf145-ce8e-481c-a842-4da90348062b/charge-information/0d514aa4-1550-46b1-8195-878957f2a5f8/view', + text: 'View' + } + ], id: '0d514aa4-1550-46b1-8195-878957f2a5f8', startDate: '1 January 2020', endDate: '', @@ -402,21 +473,31 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the data with a dash for the end date', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.chargeInformation).to.equal([{ - action: [{ - link: '/licences/' + - 'f91bf145-ce8e-481c-a842-4da90348062b/charge-information/0d514aa4-1550-46b1-8195-878957f2a5f8/view', - text: 'View' - }], - id: '0d514aa4-1550-46b1-8195-878957f2a5f8', - startDate: '1 January 2020', - endDate: '', - status: 'current', - reason: 'Major change' - }]) + expect(result.chargeInformation).to.equal([ + { + action: [ + { + link: + '/licences/' + + 'f91bf145-ce8e-481c-a842-4da90348062b/charge-information/0d514aa4-1550-46b1-8195-878957f2a5f8/view', + text: 'View' + } + ], + id: '0d514aa4-1550-46b1-8195-878957f2a5f8', + startDate: '1 January 2020', + endDate: '', + status: 'current', + reason: 'Major change' + } + ]) }) }) @@ -428,21 +509,31 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the data with the end date', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.chargeInformation).to.equal([{ - action: [{ - link: '/licences' + - '/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/0d514aa4-1550-46b1-8195-878957f2a5f8/view', - text: 'View' - }], - id: '0d514aa4-1550-46b1-8195-878957f2a5f8', - startDate: '1 January 2020', - endDate: '31 March 2024', - status: 'current', - reason: 'Major change' - }]) + expect(result.chargeInformation).to.equal([ + { + action: [ + { + link: + '/licences' + + '/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/0d514aa4-1550-46b1-8195-878957f2a5f8/view', + text: 'View' + } + ], + id: '0d514aa4-1550-46b1-8195-878957f2a5f8', + startDate: '1 January 2020', + endDate: '31 March 2024', + status: 'current', + reason: 'Major change' + } + ]) }) }) }) @@ -464,38 +555,55 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the data and workflow actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.chargeInformation).to.equal([{ - action: [{ - link: '/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/' + - 'f547f465-0a62-45ff-9909-38825f05e0c4/review', - text: 'Review' - }], - id: 'f547f465-0a62-45ff-9909-38825f05e0c4', - startDate: '1 April 2022', - endDate: '', - status: 'review', - reason: 'changed something' - }]) + expect(result.chargeInformation).to.equal([ + { + action: [ + { + link: + '/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/' + + 'f547f465-0a62-45ff-9909-38825f05e0c4/review', + text: 'Review' + } + ], + id: 'f547f465-0a62-45ff-9909-38825f05e0c4', + startDate: '1 April 2022', + endDate: '', + status: 'review', + reason: 'changed something' + } + ]) }) }) describe('and the user is not permitted to review workflow records', () => { it('correctly presents the data and workflow actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.chargeInformation).to.equal([{ - action: [], - id: 'f547f465-0a62-45ff-9909-38825f05e0c4', - startDate: '1 April 2022', - endDate: '', - status: 'review', - reason: 'changed something' - }]) + expect(result.chargeInformation).to.equal([ + { + action: [], + id: 'f547f465-0a62-45ff-9909-38825f05e0c4', + startDate: '1 April 2022', + endDate: '', + status: 'review', + reason: 'changed something' + } + ]) }) }) }) @@ -513,38 +621,55 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the data and workflow actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.chargeInformation).to.equal([{ - action: [{ - link: '/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/' + - 'f547f465-0a62-45ff-9909-38825f05e0c4/review', - text: 'Review' - }], - id: 'f547f465-0a62-45ff-9909-38825f05e0c4', - startDate: '1 April 2022', - endDate: '', - status: 'changes_requested', - reason: 'changed something' - }]) + expect(result.chargeInformation).to.equal([ + { + action: [ + { + link: + '/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/' + + 'f547f465-0a62-45ff-9909-38825f05e0c4/review', + text: 'Review' + } + ], + id: 'f547f465-0a62-45ff-9909-38825f05e0c4', + startDate: '1 April 2022', + endDate: '', + status: 'changes_requested', + reason: 'changed something' + } + ]) }) }) describe('and the user is not permitted to review workflow records', () => { it('correctly presents the data and workflow actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.chargeInformation).to.equal([{ - action: [], - id: 'f547f465-0a62-45ff-9909-38825f05e0c4', - startDate: '1 April 2022', - endDate: '', - status: 'changes_requested', - reason: 'changed something' - }]) + expect(result.chargeInformation).to.equal([ + { + action: [], + id: 'f547f465-0a62-45ff-9909-38825f05e0c4', + startDate: '1 April 2022', + endDate: '', + status: 'changes_requested', + reason: 'changed something' + } + ]) }) }) }) @@ -562,21 +687,31 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the data and workflow actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.chargeInformation).to.equal([{ - action: [{ - link: '/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/' + - 'f547f465-0a62-45ff-9909-38825f05e0c4/review', - text: 'Review' - }], - id: 'f547f465-0a62-45ff-9909-38825f05e0c4', - startDate: '', - endDate: '', - status: 'to_setup', - reason: 'changed something' - }]) + expect(result.chargeInformation).to.equal([ + { + action: [ + { + link: + '/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/' + + 'f547f465-0a62-45ff-9909-38825f05e0c4/review', + text: 'Review' + } + ], + id: 'f547f465-0a62-45ff-9909-38825f05e0c4', + startDate: '', + endDate: '', + status: 'to_setup', + reason: 'changed something' + } + ]) }) }) @@ -587,17 +722,24 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the data and workflow actions', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.chargeInformation).to.equal([{ - action: [], - id: 'f547f465-0a62-45ff-9909-38825f05e0c4', - startDate: '', - endDate: '', - status: 'to_setup', - reason: 'changed something' - }]) + expect(result.chargeInformation).to.equal([ + { + action: [], + id: 'f547f465-0a62-45ff-9909-38825f05e0c4', + startDate: '', + endDate: '', + status: 'to_setup', + reason: 'changed something' + } + ]) }) }) }) @@ -610,7 +752,12 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the returns versions data', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.returnVersions).to.equal([ @@ -638,7 +785,12 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the returns versions data with the missing data defaults', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.returnVersions).to.equal([ @@ -682,7 +834,8 @@ describe('View Licence Set Up presenter', () => { agreements, returnVersions, auth, - commonData) + commonData + ) expect(result.links.agreements.setUpAgreement).to.equal( '/licences/f91bf145-ce8e-481c-a842-4da90348062b/agreements/select-type' @@ -700,8 +853,14 @@ describe('View Licence Set Up presenter', () => { }) it('the agreement link is not present', () => { - const result = ViewLicenceSetUpPresenter - .go(chargeVersions, workflows, agreements, returnVersions, auth, commonData) + const result = ViewLicenceSetUpPresenter.go( + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData + ) expect(result.links.agreements.setUpAgreement).to.be.undefined() }) @@ -728,7 +887,8 @@ describe('View Licence Set Up presenter', () => { agreements, returnVersions, auth, - commonData) + commonData + ) expect(result.setUpAgreement).to.be.undefined() }) @@ -746,13 +906,15 @@ describe('View Licence Set Up presenter', () => { agreements, returnVersions, auth, - commonData) + commonData + ) - expect(result.links.chargeInformation.makeLicenceNonChargeable).to - .equal('/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/' + - 'non-chargeable-reason?start=1') - expect(result.links.chargeInformation.setupNewCharge).to - .equal('/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/create') + expect(result.links.chargeInformation.makeLicenceNonChargeable).to.equal( + '/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/' + 'non-chargeable-reason?start=1' + ) + expect(result.links.chargeInformation.setupNewCharge).to.equal( + '/licences/f91bf145-ce8e-481c-a842-4da90348062b/charge-information/create' + ) }) }) describe('and the licence "ends" more than 6 years ago', () => { @@ -778,7 +940,8 @@ describe('View Licence Set Up presenter', () => { agreements, returnVersions, auth, - commonData) + commonData + ) expect(result.links.chargeInformation.makeLicenceNonChargeable).to.be.undefined() expect(result.links.chargeInformation.setupNewCharge).to.be.undefined() @@ -791,13 +954,20 @@ describe('View Licence Set Up presenter', () => { describe('and the "enableRequirementsForReturns" feature toggle is true', () => { it('return the associated links', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) - expect(result.links.returnVersions.returnsRequired).to - .equal('/system/licences/f91bf145-ce8e-481c-a842-4da90348062b/returns-required') - expect(result.links.returnVersions.noReturnsRequired).to - .equal('/system/licences/f91bf145-ce8e-481c-a842-4da90348062b/no-returns-required') + expect(result.links.returnVersions.returnsRequired).to.equal( + '/system/licences/f91bf145-ce8e-481c-a842-4da90348062b/returns-required' + ) + expect(result.links.returnVersions.noReturnsRequired).to.equal( + '/system/licences/f91bf145-ce8e-481c-a842-4da90348062b/no-returns-required' + ) }) }) @@ -808,7 +978,12 @@ describe('View Licence Set Up presenter', () => { it('return no returnVersions links', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.links.returnVersions).to.equal({}) @@ -834,7 +1009,12 @@ describe('View Licence Set Up presenter', () => { it('correctly presents the recalculate bills link', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.links.recalculateBills.markForSupplementaryBilling).to.equal( @@ -853,7 +1033,12 @@ describe('View Licence Set Up presenter', () => { it('the recalculate bills link is not present', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.recalculateBills).to.be.undefined() @@ -870,7 +1055,12 @@ describe('View Licence Set Up presenter', () => { it('the recalculate bills link is not present', () => { const result = ViewLicenceSetUpPresenter.go( - chargeVersions, workflows, agreements, returnVersions, auth, commonData + chargeVersions, + workflows, + agreements, + returnVersions, + auth, + commonData ) expect(result.recalculateBills).to.be.undefined() diff --git a/test/presenters/licences/view-licence-summary.presenter.test.js b/test/presenters/licences/view-licence-summary.presenter.test.js index 49af061241..bc01d033e5 100644 --- a/test/presenters/licences/view-licence-summary.presenter.test.js +++ b/test/presenters/licences/view-licence-summary.presenter.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,10 +47,12 @@ describe('View Licence Summary presenter', () => { endDate: null, licenceHolder: 'Unregistered licence', licenceId: 'f1288f6c-8503-4dc1-b114-75c408a14bd0', - monitoringStations: [{ - id: 'ac075651-4781-4e24-a684-b943b98607ca', - label: 'MEVAGISSEY FIRE STATION' - }], + monitoringStations: [ + { + id: 'ac075651-4781-4e24-a684-b943b98607ca', + label: 'MEVAGISSEY FIRE STATION' + } + ], purposes: { caption: 'Purposes', data: ['Spray Irrigation - Storage', 'Spray Irrigation - Direct'] @@ -78,36 +80,40 @@ describe('View Licence Summary presenter', () => { describe('when the there is one licence version purpose', () => { beforeEach(() => { - licence.licenceVersions[0].licenceVersionPurposes = [{ - id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 10, - annualQuantity: null, - dailyQuantity: null, - hourlyQuantity: null, - instantQuantity: null, - purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, - points: [PointModel.fromJson({ - 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' } - })], - licenceVersionPurposeConditions: [ - { - id: '3844bf76-107d-49f1-b3fb-54619ac8d300', - licenceVersionPurposeConditionType: { - id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', - displayTitle: 'General conditions' + licence.licenceVersions[0].licenceVersionPurposes = [ + { + id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 10, + annualQuantity: null, + dailyQuantity: null, + hourlyQuantity: null, + instantQuantity: null, + purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, + points: [ + PointModel.fromJson({ + 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' } + }) + ], + licenceVersionPurposeConditions: [ + { + id: '3844bf76-107d-49f1-b3fb-54619ac8d300', + licenceVersionPurposeConditionType: { + id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', + displayTitle: 'General conditions' + } } - } - ] - }] + ] + } + ] }) describe('but it has no abstraction amounts', () => { @@ -189,26 +195,28 @@ describe('View Licence Summary presenter', () => { source: { id: 'b0b12db5-e95c-44a7-8008-2389fdbba9db', description: 'SURFACE WATER SOURCE OF SUPPLY' } }) - licence.licenceVersions[0].licenceVersionPurposes = [{ - id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 10, - points: [point], - purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, - licenceVersionPurposeConditions: [] - }, - { - id: 'da6cbb9b-edcb-4b5b-8d3a-fab22ce6ee8b', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 11, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3, - points: [point], - purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, - licenceVersionPurposeConditions: [] - }] + licence.licenceVersions[0].licenceVersionPurposes = [ + { + id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 10, + points: [point], + purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, + licenceVersionPurposeConditions: [] + }, + { + id: 'da6cbb9b-edcb-4b5b-8d3a-fab22ce6ee8b', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 11, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3, + points: [point], + purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, + licenceVersionPurposeConditions: [] + } + ] }) describe('and each contains a condition with a different display title', () => { @@ -266,42 +274,48 @@ describe('View Licence Summary presenter', () => { describe('when there is a single licence version purpose', () => { beforeEach(() => { - licence.licenceVersions[0].licenceVersionPurposes = [{ - id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 10, - points: [PointModel.fromJson({ - 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' } - })], - purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, - licenceVersionPurposeConditions: [] - }] + licence.licenceVersions[0].licenceVersionPurposes = [ + { + id: '7f5e0838-d87a-4c2e-8e9b-09d6814b9ec4', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 10, + points: [ + PointModel.fromJson({ + 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' } + }) + ], + purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, + licenceVersionPurposeConditions: [] + } + ] }) describe('with conditions with different display titles', () => { beforeEach(() => { - licence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions.push({ - id: '3844bf76-107d-49f1-b3fb-54619ac8d300', - licenceVersionPurposeConditionType: { - id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', - displayTitle: 'General conditions' - } - }, - { - id: '0c466bc8-c79c-44e0-b6ca-b95e0bfffddf', - licenceVersionPurposeConditionType: { - id: '7ee108f1-268d-4ded-81c7-d397c075e7db', - displayTitle: 'Derogation clause' + licence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions.push( + { + id: '3844bf76-107d-49f1-b3fb-54619ac8d300', + licenceVersionPurposeConditionType: { + id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', + displayTitle: 'General conditions' + } + }, + { + id: '0c466bc8-c79c-44e0-b6ca-b95e0bfffddf', + licenceVersionPurposeConditionType: { + id: '7ee108f1-268d-4ded-81c7-d397c075e7db', + displayTitle: 'Derogation clause' + } } - }) + ) }) it('returns an array containing all the titles in alphabetical order', () => { @@ -313,20 +327,22 @@ describe('View Licence Summary presenter', () => { describe('with conditions with the same display titles', () => { beforeEach(() => { - licence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions.push({ - id: '3844bf76-107d-49f1-b3fb-54619ac8d300', - licenceVersionPurposeConditionType: { - id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', - displayTitle: 'General conditions' - } - }, - { - id: '0c466bc8-c79c-44e0-b6ca-b95e0bfffddf', - licenceVersionPurposeConditionType: { - id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', - displayTitle: 'General conditions' + licence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions.push( + { + id: '3844bf76-107d-49f1-b3fb-54619ac8d300', + licenceVersionPurposeConditionType: { + id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', + displayTitle: 'General conditions' + } + }, + { + id: '0c466bc8-c79c-44e0-b6ca-b95e0bfffddf', + licenceVersionPurposeConditionType: { + id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', + displayTitle: 'General conditions' + } } - }) + ) }) it('returns an array containing only the distinct title', () => { @@ -440,9 +456,9 @@ describe('View Licence Summary presenter', () => { it('returns the singular version of the link (period and purpose)', () => { const result = ViewLicenceSummaryPresenter.go(licence) - expect(result.abstractionPeriodsAndPurposesLinkText) - .to - .equal('View details of your purpose, period and amounts') + expect(result.abstractionPeriodsAndPurposesLinkText).to.equal( + 'View details of your purpose, period and amounts' + ) }) }) @@ -456,9 +472,9 @@ describe('View Licence Summary presenter', () => { it('returns a mixed version of the link (periods and purpose)', () => { const result = ViewLicenceSummaryPresenter.go(licence) - expect(result.abstractionPeriodsAndPurposesLinkText) - .to - .equal('View details of your purpose, periods and amounts') + expect(result.abstractionPeriodsAndPurposesLinkText).to.equal( + 'View details of your purpose, periods and amounts' + ) }) }) @@ -466,16 +482,17 @@ describe('View Licence Summary presenter', () => { beforeEach(() => { licence.licenceVersions[0].licenceVersionPurposes.pop() licence.licenceVersions[0].licenceVersionPurposes[1].purpose = { - id: 'd1fc1c6f-bff0-4da2-a41a-033f151fddc7', description: 'Spray Irrigation - Direct' + id: 'd1fc1c6f-bff0-4da2-a41a-033f151fddc7', + description: 'Spray Irrigation - Direct' } }) it('returns the plural version of the link (periods and purposes)', () => { const result = ViewLicenceSummaryPresenter.go(licence) - expect(result.abstractionPeriodsAndPurposesLinkText) - .to - .equal('View details of your purposes, periods and amounts') + expect(result.abstractionPeriodsAndPurposesLinkText).to.equal( + 'View details of your purposes, periods and amounts' + ) }) }) }) @@ -488,16 +505,17 @@ describe('View Licence Summary presenter', () => { describe('and the same purpose', () => { beforeEach(() => { licence.licenceVersions[0].licenceVersionPurposes[1].purpose = { - id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' + id: '0316229a-e76d-4785-bc2c-65075a1a8f50', + description: 'Spray Irrigation - Storage' } }) it('returns the singular version of the link (period and purpose)', () => { const result = ViewLicenceSummaryPresenter.go(licence) - expect(result.abstractionPeriodsAndPurposesLinkText) - .to - .equal('View details of your purpose, period and amounts') + expect(result.abstractionPeriodsAndPurposesLinkText).to.equal( + 'View details of your purpose, period and amounts' + ) }) }) @@ -505,9 +523,9 @@ describe('View Licence Summary presenter', () => { it('returns a mixed version of the link (period and purposes)', () => { const result = ViewLicenceSummaryPresenter.go(licence) - expect(result.abstractionPeriodsAndPurposesLinkText) - .to - .equal('View details of your purposes, period and amounts') + expect(result.abstractionPeriodsAndPurposesLinkText).to.equal( + 'View details of your purposes, period and amounts' + ) }) }) }) @@ -591,15 +609,17 @@ describe('View Licence Summary presenter', () => { describe('that has multiple points', () => { beforeEach(() => { - licence.licenceVersions[0].licenceVersionPurposes[0].points.push(PointModel.fromJson({ - description: 'RIVER MEDWAY AT YALDING INTAKE', - id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', - ngr1: 'TQ 69212 50394', - ngr2: null, - ngr3: null, - ngr4: null, - source: { id: 'b0b12db5-e95c-44a7-8008-2389fdbba9db', description: 'SURFACE WATER SOURCE OF SUPPLY' } - })) + licence.licenceVersions[0].licenceVersionPurposes[0].points.push( + PointModel.fromJson({ + description: 'RIVER MEDWAY AT YALDING INTAKE', + id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', + ngr1: 'TQ 69212 50394', + ngr2: null, + ngr3: null, + ngr4: null, + source: { id: 'b0b12db5-e95c-44a7-8008-2389fdbba9db', description: 'SURFACE WATER SOURCE OF SUPPLY' } + }) + ) }) it('returns the abstraction points formatted for display', () => { @@ -820,7 +840,9 @@ describe('View Licence Summary presenter', () => { // instance method $name() would return the contact's name. We pretend in order to test the logic in the // presenter const contact = { - $name: () => { return 'Barbara Liskov' } + $name: () => { + return 'Barbara Liskov' + } } licence.licenceDocument = { @@ -853,10 +875,12 @@ describe('View Licence Summary presenter', () => { it("will return an array with the monitoring station's details", async () => { const result = await ViewLicenceSummaryPresenter.go(licence) - expect(result.monitoringStations).to.equal([{ - id: 'ac075651-4781-4e24-a684-b943b98607ca', - label: 'MEVAGISSEY FIRE STATION' - }]) + expect(result.monitoringStations).to.equal([ + { + id: 'ac075651-4781-4e24-a684-b943b98607ca', + label: 'MEVAGISSEY FIRE STATION' + } + ]) }) }) @@ -896,10 +920,12 @@ describe('View Licence Summary presenter', () => { it("will return an array with just the one monitoring station's details", async () => { const result = await ViewLicenceSummaryPresenter.go(licence) - expect(result.monitoringStations).to.equal([{ - id: 'ac075651-4781-4e24-a684-b943b98607ca', - label: 'MEVAGISSEY FIRE STATION' - }]) + expect(result.monitoringStations).to.equal([ + { + id: 'ac075651-4781-4e24-a684-b943b98607ca', + label: 'MEVAGISSEY FIRE STATION' + } + ]) }) }) }) @@ -1028,7 +1054,7 @@ describe('View Licence Summary presenter', () => { }) }) -function _licence () { +function _licence() { const point = PointModel.fromJson({ id: 'ab80acd6-7c2a-4f51-87f5-2c397829a0bb', description: null, @@ -1047,93 +1073,97 @@ function _licence () { id: '740375f0-5add-4335-8ed5-b21b55b4a228', displayName: 'Avalon' }, - licenceVersions: [{ - id: 'ac9a8a56-c9ae-43d0-a003-296b4aa7481d', - startDate: new Date('2022-04-01'), - status: 'current', - 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: [point], - licenceVersionPurposeConditions: [ - { - id: '3844bf76-107d-49f1-b3fb-54619ac8d300', - licenceVersionPurposeConditionType: { - id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', - displayTitle: 'General conditions' - } - }, - { - id: '0c466bc8-c79c-44e0-b6ca-b95e0bfffddf', - licenceVersionPurposeConditionType: { - id: '7ee108f1-268d-4ded-81c7-d397c075e7db', - displayTitle: 'Derogation clause' + licenceVersions: [ + { + id: 'ac9a8a56-c9ae-43d0-a003-296b4aa7481d', + startDate: new Date('2022-04-01'), + status: 'current', + 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: [point], + licenceVersionPurposeConditions: [ + { + id: '3844bf76-107d-49f1-b3fb-54619ac8d300', + licenceVersionPurposeConditionType: { + id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', + displayTitle: 'General conditions' + } + }, + { + id: '0c466bc8-c79c-44e0-b6ca-b95e0bfffddf', + licenceVersionPurposeConditionType: { + id: '7ee108f1-268d-4ded-81c7-d397c075e7db', + displayTitle: 'Derogation clause' + } } - } - ] - }, - { - id: 'da6cbb9b-edcb-4b5b-8d3a-fab22ce6ee8b', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 11, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3, - annualQuantity: null, - dailyQuantity: null, - hourlyQuantity: null, - instantQuantity: null, - purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, - points: [point], - licenceVersionPurposeConditions: [ - { - id: '999d98b0-ba6a-4a82-8cb6-03253a6722aa', - licenceVersionPurposeConditionType: { - id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', - displayTitle: 'General conditions' + ] + }, + { + id: 'da6cbb9b-edcb-4b5b-8d3a-fab22ce6ee8b', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 11, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3, + annualQuantity: null, + dailyQuantity: null, + hourlyQuantity: null, + instantQuantity: null, + purpose: { id: '0316229a-e76d-4785-bc2c-65075a1a8f50', description: 'Spray Irrigation - Storage' }, + points: [point], + licenceVersionPurposeConditions: [ + { + id: '999d98b0-ba6a-4a82-8cb6-03253a6722aa', + licenceVersionPurposeConditionType: { + id: '2bfb0c37-5bcb-4f15-b017-27bc0afff1a0', + displayTitle: 'General conditions' + } } - } - ] - }, - { - id: 'f68ed9a0-4a2b-42da-8f5b-c5c897113121', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 10, - annualQuantity: null, - dailyQuantity: null, - hourlyQuantity: null, - instantQuantity: null, - purpose: { id: 'd1fc1c6f-bff0-4da2-a41a-033f151fddc7', description: 'Spray Irrigation - Direct' }, - points: [point], - licenceVersionPurposeConditions: [ - { - id: 'd5f30ba6-8170-4596-9276-362efb2175fa', - licenceVersionPurposeConditionType: { - id: '923846ea-da9a-4687-bb66-6dd11411afb9', - displayTitle: 'Non standard quantities' + ] + }, + { + id: 'f68ed9a0-4a2b-42da-8f5b-c5c897113121', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 10, + annualQuantity: null, + dailyQuantity: null, + hourlyQuantity: null, + instantQuantity: null, + purpose: { id: 'd1fc1c6f-bff0-4da2-a41a-033f151fddc7', description: 'Spray Irrigation - Direct' }, + points: [point], + licenceVersionPurposeConditions: [ + { + id: 'd5f30ba6-8170-4596-9276-362efb2175fa', + licenceVersionPurposeConditionType: { + id: '923846ea-da9a-4687-bb66-6dd11411afb9', + displayTitle: 'Non standard quantities' + } } - } - ] + ] + } + ] + } + ], + licenceMonitoringStations: [ + { + id: 'f775f2cf-9b7c-4f1e-bb6f-6e81b34b1a8d', + monitoringStation: { + id: 'ac075651-4781-4e24-a684-b943b98607ca', + label: 'MEVAGISSEY FIRE STATION' } - ] - }], - licenceMonitoringStations: [{ - id: 'f775f2cf-9b7c-4f1e-bb6f-6e81b34b1a8d', - monitoringStation: { - id: 'ac075651-4781-4e24-a684-b943b98607ca', - label: 'MEVAGISSEY FIRE STATION' } - }], + ], licenceDocument: null, licenceDocumentHeader: { id: '28665d16-eba3-4c9a-aa55-7ab671b0c4fb' } }) diff --git a/test/presenters/licences/view-licence.presenter.test.js b/test/presenters/licences/view-licence.presenter.test.js index e1388adbb4..cbf6e9a6d0 100644 --- a/test/presenters/licences/view-licence.presenter.test.js +++ b/test/presenters/licences/view-licence.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -99,7 +99,9 @@ describe('View Licence presenter', () => { it('returns a notification just for the "old charge scheme"', () => { const result = ViewLicencePresenter.go(licence, auth) - expect(result.notification).to.equal('This licence has been marked for the next supplementary bill run for the old charge scheme.') + expect(result.notification).to.equal( + 'This licence has been marked for the next supplementary bill run for the old charge scheme.' + ) }) }) @@ -124,7 +126,9 @@ describe('View Licence presenter', () => { it('returns a notification just for both charge schemes', () => { const result = ViewLicencePresenter.go(licence, auth) - expect(result.notification).to.equal('This licence has been marked for the next supplementary bill runs for the current and old charge schemes.') + expect(result.notification).to.equal( + 'This licence has been marked for the next supplementary bill runs for the current and old charge schemes.' + ) }) }) @@ -136,7 +140,9 @@ describe('View Licence presenter', () => { it('returns a notification just for TPT supplementary', () => { const result = ViewLicencePresenter.go(licence, auth) - expect(result.notification).to.equal('This licence has been marked for the next two-part tariff supplementary bill run.') + expect(result.notification).to.equal( + 'This licence has been marked for the next two-part tariff supplementary bill run.' + ) }) }) @@ -149,7 +155,9 @@ describe('View Licence presenter', () => { it('returns a notification for TPT & PRESROC supplementary', () => { const result = ViewLicencePresenter.go(licence, auth) - expect(result.notification).to.equal('This licence has been marked for the next two-part tariff supplementary bill run and the supplementary bill run for the old charge scheme.') + expect(result.notification).to.equal( + 'This licence has been marked for the next two-part tariff supplementary bill run and the supplementary bill run for the old charge scheme.' + ) }) }) @@ -162,7 +170,9 @@ describe('View Licence presenter', () => { it('returns a notification for TPT & SROC supplementary', () => { const result = ViewLicencePresenter.go(licence, auth) - expect(result.notification).to.equal('This licence has been marked for the next two-part tariff supplementary bill run and the supplementary bill run.') + expect(result.notification).to.equal( + 'This licence has been marked for the next two-part tariff supplementary bill run and the supplementary bill run.' + ) }) }) @@ -176,7 +186,9 @@ describe('View Licence presenter', () => { it('returns a notification for TPT, PRESROC & SROC supplementary', () => { const result = ViewLicencePresenter.go(licence, auth) - expect(result.notification).to.equal('This licence has been marked for the next two-part tariff supplementary bill run and supplementary bill runs for the current and old charge schemes.') + expect(result.notification).to.equal( + 'This licence has been marked for the next two-part tariff supplementary bill run and supplementary bill runs for the current and old charge schemes.' + ) }) }) }) @@ -300,7 +312,7 @@ describe('View Licence presenter', () => { }) }) -function _auth () { +function _auth() { return { credentials: { roles: [ @@ -323,7 +335,7 @@ function _auth () { } } -function _licence () { +function _licence() { const licence = LicenceModel.fromJson({ id: 'f1288f6c-8503-4dc1-b114-75c408a14bd0', expiredDate: null, diff --git a/test/presenters/monitoring-stations/view.presenter.test.js b/test/presenters/monitoring-stations/view.presenter.test.js index cf1a941416..7c541c36a2 100644 --- a/test/presenters/monitoring-stations/view.presenter.test.js +++ b/test/presenters/monitoring-stations/view.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -17,11 +17,7 @@ describe('Monitoring Stations - View presenter', () => { beforeEach(() => { auth = { credentials: { - scope: [ - 'billing', - 'hof_notifications', - 'manage_gauging_station_licence_links' - ] + scope: ['billing', 'hof_notifications', 'manage_gauging_station_licence_links'] } } @@ -118,10 +114,7 @@ describe('Monitoring Stations - View presenter', () => { describe('when a user does not have the "manage_gauging_station_licence_links" role', () => { beforeEach(() => { - auth.credentials.scope = [ - 'billing', - 'hof_notifications' - ] + auth.credentials.scope = ['billing', 'hof_notifications'] }) it('returns false for "permissionToManageLinks"', () => { @@ -143,10 +136,7 @@ describe('Monitoring Stations - View presenter', () => { describe('when a user does not have the "hof_notifications" role', () => { beforeEach(() => { - auth.credentials.scope = [ - 'billing', - 'manage_gauging_station_licence_links' - ] + auth.credentials.scope = ['billing', 'manage_gauging_station_licence_links'] }) it('returns false for "permissionToSendAlerts"', () => { diff --git a/test/presenters/paginator.presenter.test.js b/test/presenters/paginator.presenter.test.js index f9867bf6fe..a957c96644 100644 --- a/test/presenters/paginator.presenter.test.js +++ b/test/presenters/paginator.presenter.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, after } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, after } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/presenters/return-versions/setup/abstraction-period.presenter.test.js b/test/presenters/return-versions/setup/abstraction-period.presenter.test.js index 22362fa758..2ef982e1f5 100644 --- a/test/presenters/return-versions/setup/abstraction-period.presenter.test.js +++ b/test/presenters/return-versions/setup/abstraction-period.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/return-versions/setup/additional-submission-options.presenter.test.js b/test/presenters/return-versions/setup/additional-submission-options.presenter.test.js index f156638bd2..683e32edc1 100644 --- a/test/presenters/return-versions/setup/additional-submission-options.presenter.test.js +++ b/test/presenters/return-versions/setup/additional-submission-options.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/return-versions/setup/agreements-exceptions.presenter.test.js b/test/presenters/return-versions/setup/agreements-exceptions.presenter.test.js index dd115ff322..6543593dc1 100644 --- a/test/presenters/return-versions/setup/agreements-exceptions.presenter.test.js +++ b/test/presenters/return-versions/setup/agreements-exceptions.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -87,7 +87,9 @@ describe('Return Versions Setup - Agreements Exceptions presenter', () => { it('returns a link back to the "frequency-reported" page', () => { const result = AgreementsExceptionsPresenter.go(session, requirementIndex) - expect(result.backLink).to.equal('/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/frequency-reported/0') + expect(result.backLink).to.equal( + '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/frequency-reported/0' + ) }) }) }) diff --git a/test/presenters/return-versions/setup/cancel.presenter.test.js b/test/presenters/return-versions/setup/cancel.presenter.test.js index bcb7e406aa..9216cfa190 100644 --- a/test/presenters/return-versions/setup/cancel.presenter.test.js +++ b/test/presenters/return-versions/setup/cancel.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -26,27 +26,23 @@ describe('Return Versions Setup - Cancel presenter', () => { startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', - requirements: [{ - points: [ - 'At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)' - ], - purposes: [ - 'Mineral Washing' - ], - returnsCycle: 'winter-and-all-year', - siteDescription: 'Bore hole in rear field', - abstractionPeriod: { - 'end-abstraction-period-day': '31', - 'end-abstraction-period-month': '10', - 'start-abstraction-period-day': '1', - 'start-abstraction-period-month': '4' - }, - frequencyReported: 'month', - frequencyCollected: 'month', - agreementsExceptions: [ - 'none' - ] - }], + requirements: [ + { + points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], + purposes: ['Mineral Washing'], + returnsCycle: 'winter-and-all-year', + siteDescription: 'Bore hole in rear field', + abstractionPeriod: { + 'end-abstraction-period-day': '31', + 'end-abstraction-period-month': '10', + 'start-abstraction-period-day': '1', + 'start-abstraction-period-month': '4' + }, + frequencyReported: 'month', + frequencyCollected: 'month', + agreementsExceptions: ['none'] + } + ], startDateOptions: 'licenceStartDate', reason: 'major-change' } diff --git a/test/presenters/return-versions/setup/check/check.presenter.test.js b/test/presenters/return-versions/setup/check/check.presenter.test.js index 07ff952731..e146f73cc6 100644 --- a/test/presenters/return-versions/setup/check/check.presenter.test.js +++ b/test/presenters/return-versions/setup/check/check.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -219,7 +219,9 @@ describe('Return Versions Setup - Check presenter', () => { it('returns a link to the "no-returns-required" page', () => { const result = CheckPresenter.go(session) - expect(result.reasonLink).to.equal('/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/no-returns-required') + expect(result.reasonLink).to.equal( + '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/no-returns-required' + ) }) }) }) diff --git a/test/presenters/return-versions/setup/check/returns-requirements.presenter.test.js b/test/presenters/return-versions/setup/check/returns-requirements.presenter.test.js index 6287f151c4..5fcb5e6505 100644 --- a/test/presenters/return-versions/setup/check/returns-requirements.presenter.test.js +++ b/test/presenters/return-versions/setup/check/returns-requirements.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -35,21 +35,19 @@ describe('Return Versions Setup - Return Requirements presenter', () => { expect(result).to.equal({ returnsRequired: true, - requirements: [{ - abstractionPeriod: 'From 1 June to 1 March', - agreementsExceptions: 'Gravity fill', - frequencyCollected: 'daily', - frequencyReported: 'daily', - index: 0, - points: [ - 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' - ], - purposes: [ - 'Spray irrigation' - ], - returnsCycle: 'Summer', - siteDescription: 'A place in the sun' - }] + requirements: [ + { + abstractionPeriod: 'From 1 June to 1 March', + agreementsExceptions: 'Gravity fill', + frequencyCollected: 'daily', + frequencyReported: 'daily', + index: 0, + points: ['At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)'], + purposes: ['Spray irrigation'], + returnsCycle: 'Summer', + siteDescription: 'A place in the sun' + } + ] }) }) @@ -104,7 +102,12 @@ describe('Return Versions Setup - Return Requirements presenter', () => { describe('when more than two options were selected', () => { beforeEach(() => { - requirement.agreementsExceptions = ['gravity-fill', 'transfer-re-abstraction-scheme', 'two-part-tariff', '56-returns-exception'] + requirement.agreementsExceptions = [ + 'gravity-fill', + 'transfer-re-abstraction-scheme', + 'two-part-tariff', + '56-returns-exception' + ] }) it('returns the options display text joined with an ", and" (Gravity fill, Transfer re-abstraction scheme, Two-part tariff, and 56 returns exception)', () => { @@ -112,7 +115,9 @@ describe('Return Versions Setup - Return Requirements presenter', () => { const { agreementsExceptions } = result.requirements[0] - expect(agreementsExceptions).to.equal('Gravity fill, Transfer re-abstraction scheme, Two-part tariff, and 56 returns exception') + expect(agreementsExceptions).to.equal( + 'Gravity fill, Transfer re-abstraction scheme, Two-part tariff, and 56 returns exception' + ) }) }) }) @@ -199,7 +204,7 @@ describe('Return Versions Setup - Return Requirements presenter', () => { }) }) -function _point () { +function _point() { return PointModel.fromJson({ description: 'RIVER MEDWAY AT YALDING INTAKE', id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', @@ -210,7 +215,7 @@ function _point () { }) } -function _requirement () { +function _requirement() { return { abstractionPeriod: { 'end-abstraction-period-day': '01', @@ -218,17 +223,17 @@ function _requirement () { 'start-abstraction-period-day': '01', 'start-abstraction-period-month': '06' }, - agreementsExceptions: [ - 'gravity-fill' - ], + agreementsExceptions: ['gravity-fill'], frequencyCollected: 'day', frequencyReported: 'day', points: ['d03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6'], - purposes: [{ - id: '772136d1-9184-417b-90cd-91053287d1df', - alias: '', - description: 'Spray irrigation' - }], + purposes: [ + { + id: '772136d1-9184-417b-90cd-91053287d1df', + alias: '', + description: 'Spray irrigation' + } + ], returnsCycle: 'summer', siteDescription: 'A place in the sun' } diff --git a/test/presenters/return-versions/setup/existing.presenter.test.js b/test/presenters/return-versions/setup/existing.presenter.test.js index 5e31d2d4fd..bbd247d15b 100644 --- a/test/presenters/return-versions/setup/existing.presenter.test.js +++ b/test/presenters/return-versions/setup/existing.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -23,12 +23,14 @@ describe('Return Versions Setup - Existing presenter', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -104,7 +106,9 @@ describe('Return Versions Setup - Existing presenter', () => { describe('when the return versions contain a "reason"', () => { beforeEach(() => { session.licence.returnVersions.unshift({ - id: '22ecef19-3a13-44a0-a55e-8f4d34dd59a5', reason: 'major-change', startDate: '2024-05-07T00:00:00.000Z' + id: '22ecef19-3a13-44a0-a55e-8f4d34dd59a5', + reason: 'major-change', + startDate: '2024-05-07T00:00:00.000Z' }) }) diff --git a/test/presenters/return-versions/setup/frequency-collected.presenter.test.js b/test/presenters/return-versions/setup/frequency-collected.presenter.test.js index c798a0916d..b6afc7cf98 100644 --- a/test/presenters/return-versions/setup/frequency-collected.presenter.test.js +++ b/test/presenters/return-versions/setup/frequency-collected.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -65,7 +65,9 @@ describe('Return Versions Setup - Frequency Collected presenter', () => { it('returns a link back to the "site-description" page', () => { const result = FrequencyCollectedPresenter.go(session, requirementIndex) - expect(result.backLink).to.equal('/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/site-description/0') + expect(result.backLink).to.equal( + '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/site-description/0' + ) }) }) }) diff --git a/test/presenters/return-versions/setup/frequency-reported.presenter.test.js b/test/presenters/return-versions/setup/frequency-reported.presenter.test.js index 1638c3dc10..77c7604bfc 100644 --- a/test/presenters/return-versions/setup/frequency-reported.presenter.test.js +++ b/test/presenters/return-versions/setup/frequency-reported.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -65,7 +65,9 @@ describe('Return Versions Setup - Frequency Reported presenter', () => { it('returns a link back to the "frequency-collected" page', () => { const result = FrequencyReportedPresenter.go(session, requirementIndex) - expect(result.backLink).to.equal('/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/frequency-collected/0') + expect(result.backLink).to.equal( + '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/frequency-collected/0' + ) }) }) }) diff --git a/test/presenters/return-versions/setup/method.presenter.test.js b/test/presenters/return-versions/setup/method.presenter.test.js index fe553da941..195afb3a2e 100644 --- a/test/presenters/return-versions/setup/method.presenter.test.js +++ b/test/presenters/return-versions/setup/method.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -23,11 +23,13 @@ describe('Return Versions Setup - Method presenter', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', diff --git a/test/presenters/return-versions/setup/no-returns-required.presenter.test.js b/test/presenters/return-versions/setup/no-returns-required.presenter.test.js index 151e78ad92..3ae9d7268d 100644 --- a/test/presenters/return-versions/setup/no-returns-required.presenter.test.js +++ b/test/presenters/return-versions/setup/no-returns-required.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -61,7 +61,9 @@ describe('Return Versions Setup - No Returns Required presenter', () => { it('returns a link back to the "start-date" page', () => { const result = NoReturnsRequiredPresenter.go(session) - expect(result.backLink).to.equal('/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/start-date') + expect(result.backLink).to.equal( + '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/start-date' + ) }) }) }) diff --git a/test/presenters/return-versions/setup/note.presenter.test.js b/test/presenters/return-versions/setup/note.presenter.test.js index d0859dc277..0483af27c4 100644 --- a/test/presenters/return-versions/setup/note.presenter.test.js +++ b/test/presenters/return-versions/setup/note.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/return-versions/setup/points.presenter.test.js b/test/presenters/return-versions/setup/points.presenter.test.js index c51f2b88e4..6fa06c1034 100644 --- a/test/presenters/return-versions/setup/points.presenter.test.js +++ b/test/presenters/return-versions/setup/points.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,16 +47,22 @@ describe('Return Versions Setup - Points presenter', () => { expect(result).to.equal({ backLink: '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/purpose/0', licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licencePoints: [{ - id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', - description: 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' - }, { - id: '07820640-c95a-497b-87d6-9e0d3ef322db', - description: 'Between National Grid References SO 524 692 and SO 531 689 (KIRKENEL FARM ASHFORD CARBONEL - RIVER TEME)' - }, { - id: '1c925e6c-a788-4a56-9c1e-ebb46c83ef73', - description: 'Within the area formed by the straight lines running between National Grid References NZ 892 055, NZ 895 054, NZ 893 053 and NZ 892 053 (AREA D)' - }], + licencePoints: [ + { + id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', + description: 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' + }, + { + id: '07820640-c95a-497b-87d6-9e0d3ef322db', + description: + 'Between National Grid References SO 524 692 and SO 531 689 (KIRKENEL FARM ASHFORD CARBONEL - RIVER TEME)' + }, + { + id: '1c925e6c-a788-4a56-9c1e-ebb46c83ef73', + description: + 'Within the area formed by the straight lines running between National Grid References NZ 892 055, NZ 895 054, NZ 893 053 and NZ 892 053 (AREA D)' + } + ], licenceRef: '01/ABC', selectedPointIds: '', sessionId: '61e07498-f309-4829-96a9-72084a54996d' @@ -95,10 +101,12 @@ describe('Return Versions Setup - Points presenter', () => { it('returns a At "National Grid Reference ..." point', () => { const result = PointsPresenter.go(session, requirementIndex, points) - expect(result.licencePoints).to.equal([{ - id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', - description: 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' - }]) + expect(result.licencePoints).to.equal([ + { + id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', + description: 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' + } + ]) }) }) @@ -110,10 +118,13 @@ describe('Return Versions Setup - Points presenter', () => { it('returns a "Between National Grid References ..." point', () => { const result = PointsPresenter.go(session, requirementIndex, points) - expect(result.licencePoints).to.equal([{ - id: '07820640-c95a-497b-87d6-9e0d3ef322db', - description: 'Between National Grid References SO 524 692 and SO 531 689 (KIRKENEL FARM ASHFORD CARBONEL - RIVER TEME)' - }]) + expect(result.licencePoints).to.equal([ + { + id: '07820640-c95a-497b-87d6-9e0d3ef322db', + description: + 'Between National Grid References SO 524 692 and SO 531 689 (KIRKENEL FARM ASHFORD CARBONEL - RIVER TEME)' + } + ]) }) }) @@ -125,10 +136,13 @@ describe('Return Versions Setup - Points presenter', () => { it('returns a "Within the area formed by the straight lines running between National Grid References ..." point', () => { const result = PointsPresenter.go(session, requirementIndex, points) - expect(result.licencePoints).to.equal([{ - id: '1c925e6c-a788-4a56-9c1e-ebb46c83ef73', - description: 'Within the area formed by the straight lines running between National Grid References NZ 892 055, NZ 895 054, NZ 893 053 and NZ 892 053 (AREA D)' - }]) + expect(result.licencePoints).to.equal([ + { + id: '1c925e6c-a788-4a56-9c1e-ebb46c83ef73', + description: + 'Within the area formed by the straight lines running between National Grid References NZ 892 055, NZ 895 054, NZ 893 053 and NZ 892 053 (AREA D)' + } + ]) }) }) }) @@ -161,35 +175,41 @@ describe('Return Versions Setup - Points presenter', () => { }) }) -function _points () { +function _points() { const points = [] - points.push(PointModel.fromJson({ - description: 'RIVER MEDWAY AT YALDING INTAKE', - id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', - ngr1: 'TQ 69212 50394', - ngr2: null, - ngr3: null, - ngr4: null - })) - - points.push(PointModel.fromJson({ - description: 'KIRKENEL FARM ASHFORD CARBONEL - RIVER TEME', - id: '07820640-c95a-497b-87d6-9e0d3ef322db', - ngr1: 'SO 524 692', - ngr2: 'SO 531 689', - ngr3: null, - ngr4: null - })) - - points.push(PointModel.fromJson({ - description: 'AREA D', - id: '1c925e6c-a788-4a56-9c1e-ebb46c83ef73', - ngr1: 'NZ 892 055', - ngr2: 'NZ 895 054', - ngr3: 'NZ 893 053', - ngr4: 'NZ 892 053' - })) + points.push( + PointModel.fromJson({ + description: 'RIVER MEDWAY AT YALDING INTAKE', + id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', + ngr1: 'TQ 69212 50394', + ngr2: null, + ngr3: null, + ngr4: null + }) + ) + + points.push( + PointModel.fromJson({ + description: 'KIRKENEL FARM ASHFORD CARBONEL - RIVER TEME', + id: '07820640-c95a-497b-87d6-9e0d3ef322db', + ngr1: 'SO 524 692', + ngr2: 'SO 531 689', + ngr3: null, + ngr4: null + }) + ) + + points.push( + PointModel.fromJson({ + description: 'AREA D', + id: '1c925e6c-a788-4a56-9c1e-ebb46c83ef73', + ngr1: 'NZ 892 055', + ngr2: 'NZ 895 054', + ngr3: 'NZ 893 053', + ngr4: 'NZ 892 053' + }) + ) return points } diff --git a/test/presenters/return-versions/setup/purpose.presenter.test.js b/test/presenters/return-versions/setup/purpose.presenter.test.js index a5b81a346e..8478b66fa3 100644 --- a/test/presenters/return-versions/setup/purpose.presenter.test.js +++ b/test/presenters/return-versions/setup/purpose.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -52,7 +52,12 @@ describe('Return Versions Setup - Purpose presenter', () => { licenceRef: '01/ABC', purposes: [ { alias: '', checked: false, description: 'Heat Pump', id: '14794d57-1acf-4c91-8b48-4b1ec68bfd6f' }, - { alias: '', checked: false, description: 'Horticultural Watering', id: '49088608-ee9f-491a-8070-6831240945ac' }, + { + alias: '', + checked: false, + description: 'Horticultural Watering', + id: '49088608-ee9f-491a-8070-6831240945ac' + }, { alias: '', checked: false, description: 'Hydraulic Rams', id: '1d03c79b-da97-4838-a68c-ccb613d54367' }, { alias: '', checked: false, description: 'Hydraulic Testing', id: '02036782-81d2-43be-b6af-bf20898653e1' } ], diff --git a/test/presenters/return-versions/setup/reason.presenter.test.js b/test/presenters/return-versions/setup/reason.presenter.test.js index 77a3c0f1f1..ea9a069e30 100644 --- a/test/presenters/return-versions/setup/reason.presenter.test.js +++ b/test/presenters/return-versions/setup/reason.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -61,7 +61,9 @@ describe('Return Versions Setup - Reason presenter', () => { it('returns a link back to the "start-date" page', () => { const result = ReasonPresenter.go(session) - expect(result.backLink).to.equal('/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/start-date') + expect(result.backLink).to.equal( + '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/start-date' + ) }) }) }) diff --git a/test/presenters/return-versions/setup/remove.presenter.test.js b/test/presenters/return-versions/setup/remove.presenter.test.js index 5799481c3c..e81b5ea9a5 100644 --- a/test/presenters/return-versions/setup/remove.presenter.test.js +++ b/test/presenters/return-versions/setup/remove.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -28,27 +28,23 @@ describe('Return Versions Setup - Remove presenter', () => { startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', - requirements: [{ - points: [ - 'At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)' - ], - purposes: [ - 'Mineral Washing' - ], - returnsCycle: 'winter-and-all-year', - siteDescription: 'Bore hole in rear field', - abstractionPeriod: { - 'end-abstraction-period-day': '31', - 'end-abstraction-period-month': '10', - 'start-abstraction-period-day': '1', - 'start-abstraction-period-month': '4' - }, - frequencyReported: 'month', - frequencyCollected: 'month', - agreementsExceptions: [ - 'none' - ] - }], + requirements: [ + { + points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], + purposes: ['Mineral Washing'], + returnsCycle: 'winter-and-all-year', + siteDescription: 'Bore hole in rear field', + abstractionPeriod: { + 'end-abstraction-period-day': '31', + 'end-abstraction-period-month': '10', + 'start-abstraction-period-day': '1', + 'start-abstraction-period-month': '4' + }, + frequencyReported: 'month', + frequencyCollected: 'month', + agreementsExceptions: ['none'] + } + ], startDateOptions: 'licenceStartDate', reason: 'major-change' } @@ -93,10 +89,7 @@ describe('Return Versions Setup - Remove presenter', () => { }, frequencyReported: 'month', frequencyCollected: 'week', - agreementsExceptions: [ - 'transfer-re-abstraction-scheme', - 'two-part-tariff' - ] + agreementsExceptions: ['transfer-re-abstraction-scheme', 'two-part-tariff'] } }) diff --git a/test/presenters/return-versions/setup/returns-cycle.presenter.test.js b/test/presenters/return-versions/setup/returns-cycle.presenter.test.js index 360bc5c0e1..faa03a0e4d 100644 --- a/test/presenters/return-versions/setup/returns-cycle.presenter.test.js +++ b/test/presenters/return-versions/setup/returns-cycle.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -65,7 +65,9 @@ describe('Return Versions Setup - Returns Cycle presenter', () => { it('returns a link back to the "abstraction-period" page', () => { const result = ReturnsCyclePresenter.go(session, requirementIndex) - expect(result.backLink).to.equal('/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/abstraction-period/0') + expect(result.backLink).to.equal( + '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/abstraction-period/0' + ) }) }) }) diff --git a/test/presenters/return-versions/setup/site-description.presenter.test.js b/test/presenters/return-versions/setup/site-description.presenter.test.js index 0d538130b3..916e0d6860 100644 --- a/test/presenters/return-versions/setup/site-description.presenter.test.js +++ b/test/presenters/return-versions/setup/site-description.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -65,7 +65,9 @@ describe('Return Versions Setup - Site Description presenter', () => { it('returns a link back to the "returns-cycle" page', () => { const result = SiteDescriptionPresenter.go(session, requirementIndex) - expect(result.backLink).to.equal('/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/returns-cycle/0') + expect(result.backLink).to.equal( + '/system/return-versions/setup/61e07498-f309-4829-96a9-72084a54996d/returns-cycle/0' + ) }) }) }) diff --git a/test/presenters/return-versions/setup/start-date.presenter.test.js b/test/presenters/return-versions/setup/start-date.presenter.test.js index 96c4e2511e..294b42f03e 100644 --- a/test/presenters/return-versions/setup/start-date.presenter.test.js +++ b/test/presenters/return-versions/setup/start-date.presenter.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/presenters/return-versions/view.presenter.test.js b/test/presenters/return-versions/view.presenter.test.js index 66853d41ae..8ae67faeb0 100644 --- a/test/presenters/return-versions/view.presenter.test.js +++ b/test/presenters/return-versions/view.presenter.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -184,12 +184,14 @@ describe('Return Versions - View presenter', () => { describe('but there is a mod log entry with a reason', () => { beforeEach(() => { - returnVersion.modLogs = [{ - naldDate: new Date('2019-03-01'), - note: null, - reasonDescription: 'Record loaded during migration', - userId: 'TTESTER' - }] + returnVersion.modLogs = [ + { + naldDate: new Date('2019-03-01'), + note: null, + reasonDescription: 'Record loaded during migration', + userId: 'TTESTER' + } + ] }) it('returns reason from the mod log', () => { @@ -265,7 +267,9 @@ describe('Return Versions - View presenter', () => { const { agreementsExceptions } = result.requirements[0] - expect(agreementsExceptions).to.equal('Gravity fill, Transfer re-abstraction scheme, Two-part tariff, and 56 returns exception') + expect(agreementsExceptions).to.equal( + 'Gravity fill, Transfer re-abstraction scheme, Two-part tariff, and 56 returns exception' + ) }) }) }) @@ -387,7 +391,7 @@ describe('Return Versions - View presenter', () => { }) }) -function _returnVersion () { +function _returnVersion() { const contact = ContactModel.fromJson({ firstName: 'Annie', middleInitials: 'J', @@ -399,10 +403,12 @@ function _returnVersion () { id: '761bc44f-80d5-49ae-ab46-0a90495417b5', licenceRef: '01/123', licenceDocument: { - licenceDocumentRoles: [{ - id: '3b903973-2143-47fe-b7a2-b205aa8eb933', - contact - }] + licenceDocumentRoles: [ + { + id: '3b903973-2143-47fe-b7a2-b205aa8eb933', + contact + } + ] } }) @@ -426,28 +432,32 @@ function _returnVersion () { modLogs: [], user: { id: 1, username: 'carol.shaw@atari.com' }, licence, - returnRequirements: [{ - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 10, - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - collectionFrequency: 'month', - fiftySixException: false, - gravityFill: false, - id: 'fa0c6032-7031-4aa2-be95-4a2edf1753ac', - legacyId: 10012345, - reabstraction: false, - reportingFrequency: 'month', - siteDescription: 'Borehole in field', - summer: false, - twoPartTariff: false, - points: [point], - returnRequirementPurposes: [{ - alias: null, - id: '7a2e3a5a-b10d-4a0f-b115-42b7551c4e8c', - purpose: { description: 'Spray Irrigation - Direct', id: 'e0bd8bd4-cfb8-44ba-b76b-2b722fcc2207' } - }] - }] + returnRequirements: [ + { + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 10, + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + collectionFrequency: 'month', + fiftySixException: false, + gravityFill: false, + id: 'fa0c6032-7031-4aa2-be95-4a2edf1753ac', + legacyId: 10012345, + reabstraction: false, + reportingFrequency: 'month', + siteDescription: 'Borehole in field', + summer: false, + twoPartTariff: false, + points: [point], + returnRequirementPurposes: [ + { + alias: null, + id: '7a2e3a5a-b10d-4a0f-b115-42b7551c4e8c', + purpose: { description: 'Spray Irrigation - Direct', id: 'e0bd8bd4-cfb8-44ba-b76b-2b722fcc2207' } + } + ] + } + ] } return ReturnVersionModel.fromJson(returnVersionData) diff --git a/test/requests/base.request.test.js b/test/requests/base.request.test.js index 5bbc9a8e3a..0c8ca7a061 100644 --- a/test/requests/base.request.test.js +++ b/test/requests/base.request.test.js @@ -6,7 +6,7 @@ const Code = require('@hapi/code') const Sinon = require('sinon') const Nock = require('nock') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/requests/charging-module.request.test.js b/test/requests/charging-module.request.test.js index baccc34960..6d8beb9805 100644 --- a/test/requests/charging-module.request.test.js +++ b/test/requests/charging-module.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, after, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, after, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/calculate-charge.request.test.js b/test/requests/charging-module/calculate-charge.request.test.js index a4b97354a7..f2e2a1b013 100644 --- a/test/requests/charging-module/calculate-charge.request.test.js +++ b/test/requests/charging-module/calculate-charge.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -128,7 +128,7 @@ describe('Charging Module Calculate Charge request', () => { }) }) -function _transactionData () { +function _transactionData() { return { abatementFactor: 1.0, actualVolume: 1.0, diff --git a/test/requests/charging-module/create-bill-run.request.test.js b/test/requests/charging-module/create-bill-run.request.test.js index 6907749a67..bd066a179b 100644 --- a/test/requests/charging-module/create-bill-run.request.test.js +++ b/test/requests/charging-module/create-bill-run.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/requests/charging-module/create-customer-change.request.test.js b/test/requests/charging-module/create-customer-change.request.test.js index f5a1f3e2bb..5c987d2261 100644 --- a/test/requests/charging-module/create-customer-change.request.test.js +++ b/test/requests/charging-module/create-customer-change.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/create-transaction.request.test.js b/test/requests/charging-module/create-transaction.request.test.js index 35ed9f75e7..364297583c 100644 --- a/test/requests/charging-module/create-transaction.request.test.js +++ b/test/requests/charging-module/create-transaction.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/delete-bill-run.request.test.js b/test/requests/charging-module/delete-bill-run.request.test.js index f2bc68f1f6..9671b05f3d 100644 --- a/test/requests/charging-module/delete-bill-run.request.test.js +++ b/test/requests/charging-module/delete-bill-run.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/generate-bill-run.request.test.js b/test/requests/charging-module/generate-bill-run.request.test.js index d0a12e3af4..253d6e189c 100644 --- a/test/requests/charging-module/generate-bill-run.request.test.js +++ b/test/requests/charging-module/generate-bill-run.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/reissue-bill.request.test.js b/test/requests/charging-module/reissue-bill.request.test.js index 1839779863..a88589aa41 100644 --- a/test/requests/charging-module/reissue-bill.request.test.js +++ b/test/requests/charging-module/reissue-bill.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/send-bill-run.request.test.js b/test/requests/charging-module/send-bill-run.request.test.js index 3a984d37c5..f0e06b2831 100644 --- a/test/requests/charging-module/send-bill-run.request.test.js +++ b/test/requests/charging-module/send-bill-run.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/requests/charging-module/token.request.test.js b/test/requests/charging-module/token.request.test.js index 818c4bb6cd..490f208b8b 100644 --- a/test/requests/charging-module/token.request.test.js +++ b/test/requests/charging-module/token.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/view-bill-run-status.request.test.js b/test/requests/charging-module/view-bill-run-status.request.test.js index da28c968d0..d3a296e1a2 100644 --- a/test/requests/charging-module/view-bill-run-status.request.test.js +++ b/test/requests/charging-module/view-bill-run-status.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/view-bill-run.request.test.js b/test/requests/charging-module/view-bill-run.request.test.js index 64ba6a1670..24ef9a25c9 100644 --- a/test/requests/charging-module/view-bill-run.request.test.js +++ b/test/requests/charging-module/view-bill-run.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/view-bill.request.test.js b/test/requests/charging-module/view-bill.request.test.js index 3cde579163..65d4f21068 100644 --- a/test/requests/charging-module/view-bill.request.test.js +++ b/test/requests/charging-module/view-bill.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/charging-module/wait-for-status.request.test.js b/test/requests/charging-module/wait-for-status.request.test.js index 4cc4154dcf..d3598061a2 100644 --- a/test/requests/charging-module/wait-for-status.request.test.js +++ b/test/requests/charging-module/wait-for-status.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -148,7 +148,7 @@ describe('Charging Module Wait For Status request', () => { }) }) -function _testResponse (status = 'processing') { +function _testResponse(status = 'processing') { return { succeeded: true, response: { diff --git a/test/requests/legacy.request.test.js b/test/requests/legacy.request.test.js index fb87e142e6..429f521c04 100644 --- a/test/requests/legacy.request.test.js +++ b/test/requests/legacy.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -115,9 +115,10 @@ describe('Legacy Request', () => { describe('when the request is to an unknown legacy service', () => { it('throws an error', async () => { - await expect(LegacyRequest.delete('foobar', testPath)) - .to - .reject(Error, 'Request to unknown legacy service foobar') + await expect(LegacyRequest.delete('foobar', testPath)).to.reject( + Error, + 'Request to unknown legacy service foobar' + ) }) }) }) @@ -215,9 +216,7 @@ describe('Legacy Request', () => { describe('when the request is to an unknown legacy service', () => { it('throws an error', async () => { - await expect(LegacyRequest.get('foobar', testPath)) - .to - .reject(Error, 'Request to unknown legacy service foobar') + await expect(LegacyRequest.get('foobar', testPath)).to.reject(Error, 'Request to unknown legacy service foobar') }) }) }) @@ -317,9 +316,10 @@ describe('Legacy Request', () => { describe('when the request is to an unknown legacy service', () => { it('throws an error', async () => { - await expect(LegacyRequest.post('foobar', testPath, null, true, requestBody)) - .to - .reject(Error, 'Request to unknown legacy service foobar') + await expect(LegacyRequest.post('foobar', testPath, null, true, requestBody)).to.reject( + Error, + 'Request to unknown legacy service foobar' + ) }) }) }) diff --git a/test/requests/legacy/create-bill-run.request.test.js b/test/requests/legacy/create-bill-run.request.test.js index 64b98f29aa..146985ea10 100644 --- a/test/requests/legacy/create-bill-run.request.test.js +++ b/test/requests/legacy/create-bill-run.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/legacy/delete-bill-licence.request.test.js b/test/requests/legacy/delete-bill-licence.request.test.js index 6e2c763cb3..1755b78446 100644 --- a/test/requests/legacy/delete-bill-licence.request.test.js +++ b/test/requests/legacy/delete-bill-licence.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/legacy/delete-bill.request.test.js b/test/requests/legacy/delete-bill.request.test.js index cbe9d3a284..f0282b47ab 100644 --- a/test/requests/legacy/delete-bill.request.test.js +++ b/test/requests/legacy/delete-bill.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/requests/legacy/refresh-bill-run.request.test.js b/test/requests/legacy/refresh-bill-run.request.test.js index 3c30e6f9a0..39fe61df34 100644 --- a/test/requests/legacy/refresh-bill-run.request.test.js +++ b/test/requests/legacy/refresh-bill-run.request.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/bill-licences/fetch-bill-licence-summary.service.test.js b/test/services/bill-licences/fetch-bill-licence-summary.service.test.js index 70d40e6596..ed32d5b636 100644 --- a/test/services/bill-licences/fetch-bill-licence-summary.service.test.js +++ b/test/services/bill-licences/fetch-bill-licence-summary.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -60,13 +60,19 @@ describe('Fetch Bill Licence Summary service', () => { contactId = contact.id const billingAccountAddress = await BillingAccountAddressHelper.add({ - billingAccountId, companyId: agentCompanyId, contactId, endDate: null + billingAccountId, + companyId: agentCompanyId, + contactId, + endDate: null }) billingAccountAddressId = billingAccountAddress.id const billRun = await BillRunHelper.add({ - billRunNumber: 1075, createdAt: new Date('2023-05-01'), status: 'ready', regionId + billRunNumber: 1075, + createdAt: new Date('2023-05-01'), + status: 'ready', + regionId }) billRunId = billRun.id @@ -77,7 +83,7 @@ describe('Fetch Bill Licence Summary service', () => { billLicence = await BillLicenceHelper.add({ billId, licenceRef }) - const transaction = await TransactionHelper.add({ billLicenceId: billLicence.id, netAmount: 1000.10 }) + const transaction = await TransactionHelper.add({ billLicenceId: billLicence.id, netAmount: 1000.1 }) transactionId = transaction.id }) @@ -103,26 +109,28 @@ describe('Fetch Bill Licence Summary service', () => { name: 'Example Trading Ltd', type: 'organisation' }, - billingAccountAddresses: [{ - id: billingAccountAddressId, - company: { - id: agentCompanyId, - name: 'Agent Company Ltd', - type: 'organisation' - }, - contact: { - id: contactId, - contactType: 'person', - dataSource: 'wrls', - department: null, - firstName: 'Amara', - initials: null, - lastName: 'Gupta', - middleInitials: null, - salutation: null, - suffix: null + billingAccountAddresses: [ + { + id: billingAccountAddressId, + company: { + id: agentCompanyId, + name: 'Agent Company Ltd', + type: 'organisation' + }, + contact: { + id: contactId, + contactType: 'person', + dataSource: 'wrls', + department: null, + firstName: 'Amara', + initials: null, + lastName: 'Gupta', + middleInitials: null, + salutation: null, + suffix: null + } } - }] + ] }, billRun: { id: billRunId, @@ -143,7 +151,7 @@ describe('Fetch Bill Licence Summary service', () => { { id: transactionId, credit: false, - netAmount: 1000.10 + netAmount: 1000.1 } ] }) diff --git a/test/services/bill-licences/fetch-bill-licence.service.test.js b/test/services/bill-licences/fetch-bill-licence.service.test.js index 86096e19d5..57aacd7aba 100644 --- a/test/services/bill-licences/fetch-bill-licence.service.test.js +++ b/test/services/bill-licences/fetch-bill-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -104,16 +104,32 @@ describe('Fetch Bill Licence service', () => { await Promise.all([ TransactionHelper.add({ - billLicenceId, chargeReferenceId, description: '3', chargeCategoryCode: '4.3.1', billableDays: 10 + billLicenceId, + chargeReferenceId, + description: '3', + chargeCategoryCode: '4.3.1', + billableDays: 10 }), TransactionHelper.add({ - billLicenceId, chargeReferenceId, description: '1', chargeCategoryCode: '4.3.2', createdAt: new Date('2023-02-02') + billLicenceId, + chargeReferenceId, + description: '1', + chargeCategoryCode: '4.3.2', + createdAt: new Date('2023-02-02') }), TransactionHelper.add({ - billLicenceId, chargeReferenceId, description: '2', chargeCategoryCode: '4.3.1', billableDays: 20 + billLicenceId, + chargeReferenceId, + description: '2', + chargeCategoryCode: '4.3.1', + billableDays: 20 }), TransactionHelper.add({ - billLicenceId, chargeReferenceId, description: '0', chargeCategoryCode: '4.3.2', createdAt: new Date('2023-02-01') + billLicenceId, + chargeReferenceId, + description: '0', + chargeCategoryCode: '4.3.2', + createdAt: new Date('2023-02-01') }) ]) }) @@ -167,16 +183,32 @@ describe('Fetch Bill Licence service', () => { await Promise.all([ TransactionHelper.add({ - billLicenceId, chargeReferenceId, description: '3', chargeCategoryCode: null, billableDays: 10 + billLicenceId, + chargeReferenceId, + description: '3', + chargeCategoryCode: null, + billableDays: 10 }), TransactionHelper.add({ - billLicenceId, chargeReferenceId, description: '1', chargeCategoryCode: null, createdAt: new Date('2023-02-02') + billLicenceId, + chargeReferenceId, + description: '1', + chargeCategoryCode: null, + createdAt: new Date('2023-02-02') }), TransactionHelper.add({ - billLicenceId, chargeReferenceId, description: '2', chargeCategoryCode: null, billableDays: 20 + billLicenceId, + chargeReferenceId, + description: '2', + chargeCategoryCode: null, + billableDays: 20 }), TransactionHelper.add({ - billLicenceId, chargeReferenceId, description: '0', chargeCategoryCode: null, createdAt: new Date('2023-02-01') + billLicenceId, + chargeReferenceId, + description: '0', + chargeCategoryCode: null, + createdAt: new Date('2023-02-01') }) ]) }) diff --git a/test/services/bill-licences/remove-bill-licence.service.test.js b/test/services/bill-licences/remove-bill-licence.service.test.js index f5ae50206f..e53e9117b2 100644 --- a/test/services/bill-licences/remove-bill-licence.service.test.js +++ b/test/services/bill-licences/remove-bill-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -48,7 +48,7 @@ describe('Remove Bill Licence service', () => { }) }) -function _billLicenceSummary () { +function _billLicenceSummary() { return { id: 'a4fbaa27-a91c-4328-a1b8-774ade11027b', licenceId: '2eaa831d-7bd6-4b0a-aaf1-3aacafec6bf2', @@ -64,22 +64,24 @@ function _billLicenceSummary () { name: 'Example Trading Ltd', type: 'organisation' }, - billingAccountAddresses: [{ - id: '1d440029-745a-47ec-a43e-9f4a36014126', - company: null, - contact: { - id: '95ba53be-543f-415b-90b1-08f58f63ff74', - contactType: 'person', - dataSource: 'wrls', - department: null, - firstName: 'Amara', - initials: null, - lastName: 'Gupta', - middleInitials: null, - salutation: null, - suffix: null + billingAccountAddresses: [ + { + id: '1d440029-745a-47ec-a43e-9f4a36014126', + company: null, + contact: { + id: '95ba53be-543f-415b-90b1-08f58f63ff74', + contactType: 'person', + dataSource: 'wrls', + department: null, + firstName: 'Amara', + initials: null, + lastName: 'Gupta', + middleInitials: null, + salutation: null, + suffix: null + } } - }] + ] }, billRun: { id: '0e61c36f-f22f-4534-8247-b73a97f551b5', diff --git a/test/services/bill-licences/submit-remove-bill-licence.service.test.js b/test/services/bill-licences/submit-remove-bill-licence.service.test.js index 2fcd4a722a..8a08a0416f 100644 --- a/test/services/bill-licences/submit-remove-bill-licence.service.test.js +++ b/test/services/bill-licences/submit-remove-bill-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-licences/view-bill-licence.service.test.js b/test/services/bill-licences/view-bill-licence.service.test.js index 62f466cd71..a4039ad4a3 100644 --- a/test/services/bill-licences/view-bill-licence.service.test.js +++ b/test/services/bill-licences/view-bill-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -46,9 +46,7 @@ describe('View Bill Licence service', () => { describe('when a bill with a matching ID does not exist', () => { it('throws an exception', async () => { - await expect(ViewBillLicenceService.go('testId')) - .to - .reject() + await expect(ViewBillLicenceService.go('testId')).to.reject() }) }) }) diff --git a/test/services/bill-runs/annual/fetch-billing-accounts.service.test.js b/test/services/bill-runs/annual/fetch-billing-accounts.service.test.js index ef684c1998..b77e079e36 100644 --- a/test/services/bill-runs/annual/fetch-billing-accounts.service.test.js +++ b/test/services/bill-runs/annual/fetch-billing-accounts.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -203,19 +203,18 @@ describe('Fetch Billing Accounts service', () => { licence = await LicenceHelper.add({ regionId: region.id }) billingAccount = await BillingAccountHelper.add() - chargeVersion = await ChargeVersionHelper.add( - { - startDate: new Date('2023-11-01'), - changeReasonId: minimumChargeChangeReason.id, - billingAccountId: billingAccount.id, - licenceId: licence.id, - licenceRef: licence.licenceRef - } - ) + chargeVersion = await ChargeVersionHelper.add({ + startDate: new Date('2023-11-01'), + changeReasonId: minimumChargeChangeReason.id, + billingAccountId: billingAccount.id, + licenceId: licence.id, + licenceRef: licence.licenceRef + }) chargeCategory = ChargeCategoryHelper.select() chargeReference = await ChargeReferenceHelper.add({ - chargeVersionId: chargeVersion.id, chargeCategoryId: chargeCategory.id + chargeVersionId: chargeVersion.id, + chargeCategoryId: chargeCategory.id }) chargeElement = await ChargeElementHelper.add({ chargeReferenceId: chargeReference.id }) }) @@ -297,7 +296,12 @@ describe('Fetch Billing Accounts service', () => { loss: 'low', volume: 6.819, adjustments: { - s126: null, s127: false, s130: false, charge: null, winter: false, aggregate: '0.562114443' + s126: null, + s127: false, + s130: false, + charge: null, + winter: false, + aggregate: '0.562114443' }, additionalCharges: { isSupplyPublicWater: true }, description: 'Mineral washing', @@ -306,13 +310,15 @@ describe('Fetch Billing Accounts service', () => { reference: chargeCategory.reference, shortDescription: chargeCategory.shortDescription }, - chargeElements: [{ - id: chargeElement.id, - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3 - }] + chargeElements: [ + { + id: chargeElement.id, + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3 + } + ] }) }) }) diff --git a/test/services/bill-runs/annual/process-bill-run.service.test.js b/test/services/bill-runs/annual/process-bill-run.service.test.js index 6eda12173a..f23459503f 100644 --- a/test/services/bill-runs/annual/process-bill-run.service.test.js +++ b/test/services/bill-runs/annual/process-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -34,7 +34,9 @@ describe('Annual Process Bill Run service', () => { const financialYearEnd = billingPeriod.startDate.getFullYear() billRun = await BillRunHelper.add({ - batchType: 'annual', fromFinancialYearEnding: financialYearEnd, toFinancialYearEnding: financialYearEnd + batchType: 'annual', + fromFinancialYearEnding: financialYearEnd, + toFinancialYearEnding: financialYearEnd }) // BaseRequest depends on the GlobalNotifier to have been set. This happens in app/plugins/global-notifier.plugin.js diff --git a/test/services/bill-runs/annual/process-billing-period.service.test.js b/test/services/bill-runs/annual/process-billing-period.service.test.js index 5b2664247e..765594a6f8 100644 --- a/test/services/bill-runs/annual/process-billing-period.service.test.js +++ b/test/services/bill-runs/annual/process-billing-period.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -146,9 +146,7 @@ describe('Annual Process billing period service', () => { }) it('throws a BillRunError with the correct code', async () => { - const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, [billingAccount])) - .to - .reject() + const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, [billingAccount])).to.reject() expect(error).to.be.an.instanceOf(BillRunError) expect(error.code).to.equal(BillRunModel.errorCodes.failedToPrepareTransactions) @@ -161,9 +159,7 @@ describe('Annual Process billing period service', () => { }) it('throws a BillRunError with the correct code', async () => { - const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, [billingAccount])) - .to - .reject() + const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, [billingAccount])).to.reject() expect(error).to.be.an.instanceOf(BillRunError) expect(error.code).to.equal(BillRunModel.errorCodes.failedToCreateCharge) @@ -172,7 +168,7 @@ describe('Annual Process billing period service', () => { }) }) -function _chargingModuleResponse (transactionId) { +function _chargingModuleResponse(transactionId) { return { succeeded: true, response: { @@ -181,14 +177,14 @@ function _chargingModuleResponse (transactionId) { } } -function _testBillingAccount () { +function _testBillingAccount() { return { id: '973a5852-9c06-4c14-b1e2-d32b88d3e878', accountNumber: 'T71117364A' } } -function _testChargeVersion (billingAccountId) { +function _testChargeVersion(billingAccountId) { return { id: generateUUID(), scheme: 'sroc', @@ -222,7 +218,12 @@ function _testChargeVersion (billingAccountId) { loss: 'low', volume: '6.819', adjustments: { - s126: null, s127: false, s130: false, charge: null, winter: false, aggregate: '0.562114443' + s126: null, + s127: false, + s130: false, + charge: null, + winter: false, + aggregate: '0.562114443' }, additionalCharges: { isSupplyPublicWater: true }, description: 'Mineral washing', @@ -240,7 +241,9 @@ function _testChargeVersion (billingAccountId) { abstractionPeriodEndMonth: 10, // NOTE: We are faking an Objection model which comes with a toJSON() method that gets called as part // of processing the billing account. - toJSON: () => { return '{}' } + toJSON: () => { + return '{}' + } } ] } diff --git a/test/services/bill-runs/calculate-authorised-and-billable-days.service.test.js b/test/services/bill-runs/calculate-authorised-and-billable-days.service.test.js index 5723d95fc3..b3f003ba6b 100644 --- a/test/services/bill-runs/calculate-authorised-and-billable-days.service.test.js +++ b/test/services/bill-runs/calculate-authorised-and-billable-days.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/cancel/cancel-bill-run.service.test.js b/test/services/bill-runs/cancel/cancel-bill-run.service.test.js index 0b61c2b22f..de4f88ae4a 100644 --- a/test/services/bill-runs/cancel/cancel-bill-run.service.test.js +++ b/test/services/bill-runs/cancel/cancel-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -41,8 +41,7 @@ describe('Bill Runs - Cancel Bill Run service', () => { beforeEach(() => { queryStub.onFirstCall().returns({ findById: Sinon.stub().withArgs(billRunId).returnsThis(), - select: Sinon - .stub() + select: Sinon.stub() .withArgs('id', 'externalId', 'status') .resolves({ id: billRunId, externalId, status: 'ready' }) }) @@ -68,8 +67,7 @@ describe('Bill Runs - Cancel Bill Run service', () => { beforeEach(async () => { queryStub.onFirstCall().returns({ findById: Sinon.stub().withArgs(billRunId).returnsThis(), - select: Sinon - .stub() + select: Sinon.stub() .withArgs('id', 'externalId', 'status') .resolves({ id: billRunId, externalId, status: 'sent' }) }) @@ -92,9 +90,7 @@ describe('Bill Runs - Cancel Bill Run service', () => { describe('when the bill run does not exist', () => { it('throws as error', async () => { - await expect(CancelBillBunService.go('47e66de7-f05f-42d2-8fef-640b55150919')) - .to - .reject() + await expect(CancelBillBunService.go('47e66de7-f05f-42d2-8fef-640b55150919')).to.reject() }) }) }) diff --git a/test/services/bill-runs/cancel/delete-bill-run.service.test.js b/test/services/bill-runs/cancel/delete-bill-run.service.test.js index 55e44afd4a..7e5b481d3f 100644 --- a/test/services/bill-runs/cancel/delete-bill-run.service.test.js +++ b/test/services/bill-runs/cancel/delete-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code const BillHelper = require('../../../support/helpers/bill.helper.js') @@ -103,9 +103,7 @@ describe('Bill Runs - Delete Bill Run service', () => { const logDataArg = notifierStub.omg.args[0][1] - expect( - notifierStub.omg.calledWith('Delete bill run complete') - ).to.be.true() + expect(notifierStub.omg.calledWith('Delete bill run complete')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.billRun).to.equal(billRun) @@ -171,9 +169,7 @@ describe('Bill Runs - Delete Bill Run service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Delete bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Delete bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(Error) }) @@ -195,9 +191,7 @@ describe('Bill Runs - Delete Bill Run service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Delete bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Delete bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(Error) }) @@ -223,9 +217,7 @@ describe('Bill Runs - Delete Bill Run service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Delete bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Delete bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(Error) }) @@ -251,9 +243,7 @@ describe('Bill Runs - Delete Bill Run service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Delete bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Delete bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(Error) }) @@ -277,9 +267,7 @@ describe('Bill Runs - Delete Bill Run service', () => { const logDataArg = notifierStub.omg.args[0][1] - expect( - notifierStub.omg.calledWith('Delete bill run complete') - ).to.be.true() + expect(notifierStub.omg.calledWith('Delete bill run complete')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.billRun).to.equal(billRun) @@ -291,7 +279,7 @@ describe('Bill Runs - Delete Bill Run service', () => { }) }) -function _billRun () { +function _billRun() { return { id: 'dafe5048-24b1-485a-8289-2e584bb7ba68', externalId: 'ef6a17f2-412f-4502-a73d-b74c8b92ff19', diff --git a/test/services/bill-runs/cancel/submit-cancel-bill-run.service.test.js b/test/services/bill-runs/cancel/submit-cancel-bill-run.service.test.js index 39611bd930..4c69c18633 100644 --- a/test/services/bill-runs/cancel/submit-cancel-bill-run.service.test.js +++ b/test/services/bill-runs/cancel/submit-cancel-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/cancel/view-cancel-bill-run.service.test.js b/test/services/bill-runs/cancel/view-cancel-bill-run.service.test.js index 787e8b4643..2abe37acf2 100644 --- a/test/services/bill-runs/cancel/view-cancel-bill-run.service.test.js +++ b/test/services/bill-runs/cancel/view-cancel-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -70,9 +70,7 @@ describe('Bill Runs - View Cancel Bill Run service', () => { describe('when a bill run with a matching ID does not exist', () => { it('throws an exception', async () => { - await expect(ViewCancelBillRunService.go('testId')) - .to - .reject() + await expect(ViewCancelBillRunService.go('testId')).to.reject() }) }) }) diff --git a/test/services/bill-runs/check-busy-bill-runs.service.test.js b/test/services/bill-runs/check-busy-bill-runs.service.test.js index 84b495b6b2..2dd9872c58 100644 --- a/test/services/bill-runs/check-busy-bill-runs.service.test.js +++ b/test/services/bill-runs/check-busy-bill-runs.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/bill-runs/consolidate-date-ranges.service.test.js b/test/services/bill-runs/consolidate-date-ranges.service.test.js index 9c278b6120..c943e0e314 100644 --- a/test/services/bill-runs/consolidate-date-ranges.service.test.js +++ b/test/services/bill-runs/consolidate-date-ranges.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/bill-runs/create-bill-run-event.service.test.js b/test/services/bill-runs/create-bill-run-event.service.test.js index 8c961d6e93..979614db39 100644 --- a/test/services/bill-runs/create-bill-run-event.service.test.js +++ b/test/services/bill-runs/create-bill-run-event.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -40,9 +40,7 @@ describe('Create Bill Run Event service', () => { const region = RegionHelper.select() const testBillRun = await BillRunHelper.add({ regionId: region.id }) - billRun = await BillRunModel.query() - .findById(testBillRun.id) - .withGraphFetched('region') + billRun = await BillRunModel.query().findById(testBillRun.id).withGraphFetched('region') }) it('creates an event record', async () => { diff --git a/test/services/bill-runs/create-bill-run.service.test.js b/test/services/bill-runs/create-bill-run.service.test.js index c8c1463cc4..965d60ba33 100644 --- a/test/services/bill-runs/create-bill-run.service.test.js +++ b/test/services/bill-runs/create-bill-run.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -52,11 +52,14 @@ describe('Create Bill Run service', () => { const errorCode = 50 it('returns the new bill run instance containing the provided values', async () => { - const result = await CreateBillRunService.go( - region.id, - financialYearEndings, - { batchType, scheme, source, externalId, status, errorCode } - ) + const result = await CreateBillRunService.go(region.id, financialYearEndings, { + batchType, + scheme, + source, + externalId, + status, + errorCode + }) expect(result).to.be.an.instanceOf(BillRunModel) diff --git a/test/services/bill-runs/determine-abstraction-periods.service.test.js b/test/services/bill-runs/determine-abstraction-periods.service.test.js index e8da64f461..23a0296dd5 100644 --- a/test/services/bill-runs/determine-abstraction-periods.service.test.js +++ b/test/services/bill-runs/determine-abstraction-periods.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/bill-runs/determine-billing-periods.service.test.js b/test/services/bill-runs/determine-billing-periods.service.test.js index 5a6d2e3bad..bfba70dcba 100644 --- a/test/services/bill-runs/determine-billing-periods.service.test.js +++ b/test/services/bill-runs/determine-billing-periods.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/determine-blocking-bill-run.service.test.js b/test/services/bill-runs/determine-blocking-bill-run.service.test.js index e6a0981da0..afa1777ce4 100644 --- a/test/services/bill-runs/determine-blocking-bill-run.service.test.js +++ b/test/services/bill-runs/determine-blocking-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/determine-charge-period.service.test.js b/test/services/bill-runs/determine-charge-period.service.test.js index fe7a052492..407fdc0675 100644 --- a/test/services/bill-runs/determine-charge-period.service.test.js +++ b/test/services/bill-runs/determine-charge-period.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/bill-runs/determine-minimum-charge.service.test.js b/test/services/bill-runs/determine-minimum-charge.service.test.js index ae3e754994..ba67317b69 100644 --- a/test/services/bill-runs/determine-minimum-charge.service.test.js +++ b/test/services/bill-runs/determine-minimum-charge.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/fetch-bill-run.service.test.js b/test/services/bill-runs/fetch-bill-run.service.test.js index cf693ad6d6..8307099837 100644 --- a/test/services/bill-runs/fetch-bill-run.service.test.js +++ b/test/services/bill-runs/fetch-bill-run.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -72,7 +72,6 @@ describe('Fetch Bill Run service', () => { BillingAccountAddressHelper.add({ billingAccountId: linkedBillingAccounts[0].id, addressId: address.id - }), BillingAccountAddressHelper.add({ billingAccountId: linkedBillingAccounts[1].id, diff --git a/test/services/bill-runs/fetch-bill-runs.service.test.js b/test/services/bill-runs/fetch-bill-runs.service.test.js index bae158e04e..6be358d770 100644 --- a/test/services/bill-runs/fetch-bill-runs.service.test.js +++ b/test/services/bill-runs/fetch-bill-runs.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -127,7 +127,7 @@ describe('Fetch Bill Runs service', () => { }) }) -function _addBillRun (billRunNumber, createdAt, netTotal, creditNoteCount, invoiceCount, regionId) { +function _addBillRun(billRunNumber, createdAt, netTotal, creditNoteCount, invoiceCount, regionId) { return BillRunHelper.add({ billRunNumber, createdAt, diff --git a/test/services/bill-runs/fetch-live-bill-runs.service.test.js b/test/services/bill-runs/fetch-live-bill-runs.service.test.js index bf207dceb3..f17bc588ba 100644 --- a/test/services/bill-runs/fetch-live-bill-runs.service.test.js +++ b/test/services/bill-runs/fetch-live-bill-runs.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach, after } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, after } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/fetch-matching-bill-run.service.test.js b/test/services/bill-runs/fetch-matching-bill-run.service.test.js index f521a018a7..eee881da10 100644 --- a/test/services/bill-runs/fetch-matching-bill-run.service.test.js +++ b/test/services/bill-runs/fetch-matching-bill-run.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -29,7 +29,12 @@ describe('Fetch Matching Bill Run service', () => { describe('and the batch type is "annual"', () => { describe('and a bill run for the same financial year exists', () => { beforeEach(async () => { - const billRun = await BillRunHelper.add({ regionId, batchType: 'annual', status: 'sent', toFinancialYearEnding: 2024 }) + const billRun = await BillRunHelper.add({ + regionId, + batchType: 'annual', + status: 'sent', + toFinancialYearEnding: 2024 + }) matchingBillRunId = billRun.id }) @@ -49,10 +54,18 @@ describe('Fetch Matching Bill Run service', () => { beforeEach(async () => { const billRuns = await Promise.all([ BillRunHelper.add({ - regionId, batchType: 'supplementary', status: 'ready', toFinancialYearEnding: 2024, scheme: 'alcs' + regionId, + batchType: 'supplementary', + status: 'ready', + toFinancialYearEnding: 2024, + scheme: 'alcs' }), BillRunHelper.add({ - regionId, batchType: 'supplementary', status: 'queued', toFinancialYearEnding: 2024, scheme: 'sroc' + regionId, + batchType: 'supplementary', + status: 'queued', + toFinancialYearEnding: 2024, + scheme: 'sroc' }) ]) @@ -74,7 +87,10 @@ describe('Fetch Matching Bill Run service', () => { describe('and a bill run for the same financial year exists', () => { beforeEach(async () => { const billRun = await BillRunHelper.add({ - regionId, batchType: 'two_part_tariff', status: 'sent', toFinancialYearEnding: 2023 + regionId, + batchType: 'two_part_tariff', + status: 'sent', + toFinancialYearEnding: 2023 }) matchingBillRunId = billRun.id @@ -94,13 +110,21 @@ describe('Fetch Matching Bill Run service', () => { beforeEach(async () => { let billRun = await BillRunHelper.add({ - regionId, batchType: 'two_part_tariff', status: 'sent', toFinancialYearEnding: 2022, summer: true + regionId, + batchType: 'two_part_tariff', + status: 'sent', + toFinancialYearEnding: 2022, + summer: true }) matchingSummerBillRunId = billRun.id billRun = await BillRunHelper.add({ - regionId, batchType: 'two_part_tariff', status: 'sent', toFinancialYearEnding: 2022, summer: false + regionId, + batchType: 'two_part_tariff', + status: 'sent', + toFinancialYearEnding: 2022, + summer: false }) matchingWinterBillRunId = billRun.id }) diff --git a/test/services/bill-runs/fetch-region.service.test.js b/test/services/bill-runs/fetch-region.service.test.js index fc80ea921c..5856c466b5 100644 --- a/test/services/bill-runs/fetch-region.service.test.js +++ b/test/services/bill-runs/fetch-region.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/generate-transactions.service.test.js b/test/services/bill-runs/generate-transactions.service.test.js index 2213d19dd5..2c14f9a1d7 100644 --- a/test/services/bill-runs/generate-transactions.service.test.js +++ b/test/services/bill-runs/generate-transactions.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -41,7 +41,8 @@ describe('Generate Transactions service', () => { const baseChargeReference = await ChargeReferenceHelper.add({ chargeCategoryId }) chargeElement = await ChargeElementHelper.add({ chargeReferenceId: baseChargeReference.id }) - chargeReference = await baseChargeReference.$query() + chargeReference = await baseChargeReference + .$query() .withGraphFetched('chargeCategory') .withGraphFetched('chargeElements') }) @@ -104,7 +105,12 @@ describe('Generate Transactions service', () => { it('returns an array of one transaction containing the expected data', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) // Should only return the 'standard' charge transaction line @@ -121,7 +127,12 @@ describe('Generate Transactions service', () => { it('returns the charge element as JSON in the transaction line "purposes" property', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) const parsedElements = JSON.parse(results[0].purposes) @@ -133,7 +144,12 @@ describe('Generate Transactions service', () => { describe('and is not a water undertaker', () => { it('returns an array of two transactions containing the expected data', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) // Should return both a 'standard' charge and 'compensation' charge transaction line @@ -150,7 +166,12 @@ describe('Generate Transactions service', () => { it('returns a second compensation charge transaction', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) expect(results[1]).to.equal( @@ -158,7 +179,8 @@ describe('Generate Transactions service', () => { ...expectedStandardChargeResult, waterUndertaker, chargeType: 'compensation', - description: 'Compensation charge: calculated from the charge reference, activity description and regional environmental improvement charge; excludes any supported source additional charge and two-part tariff charge agreement' + description: + 'Compensation charge: calculated from the charge reference, activity description and regional environmental improvement charge; excludes any supported source additional charge and two-part tariff charge agreement' }, { skip: ['purposes', 'id'] } ) @@ -166,7 +188,12 @@ describe('Generate Transactions service', () => { it('returns the charge element as JSON in both transaction lines "purposes" property', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) const parsedStandardElements = JSON.parse(results[0].purposes) @@ -187,7 +214,12 @@ describe('Generate Transactions service', () => { it('returns "newLicence" as true in the results', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) expect(results[0].newLicence).to.be.true() @@ -197,7 +229,12 @@ describe('Generate Transactions service', () => { describe('and is not a new licence', () => { it('returns "newLicence" as false in the results', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) expect(results[0].newLicence).to.be.false() @@ -208,7 +245,12 @@ describe('Generate Transactions service', () => { describe('has not applied', () => { it('returns the standard description', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) expect(results[0].description).to.equal(`Water abstraction charge: ${chargeReference.description}`) @@ -222,10 +264,17 @@ describe('Generate Transactions service', () => { it('returns the two-part tariff prefixed description', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) - expect(results[0].description).to.equal(`Two-part tariff basic water abstraction charge: ${chargeReference.description}`) + expect(results[0].description).to.equal( + `Two-part tariff basic water abstraction charge: ${chargeReference.description}` + ) }) }) }) @@ -243,7 +292,12 @@ describe('Generate Transactions service', () => { it('returns an empty array', () => { const results = GenerateTransactionsService.go( - billLicenceId, chargeReference, billingPeriod, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + billingPeriod, + chargePeriod, + newLicence, + waterUndertaker ) expect(results).to.be.empty() diff --git a/test/services/bill-runs/handle-errored-bill-run.service.test.js b/test/services/bill-runs/handle-errored-bill-run.service.test.js index a8e5dc7d2e..6d9f8403f0 100644 --- a/test/services/bill-runs/handle-errored-bill-run.service.test.js +++ b/test/services/bill-runs/handle-errored-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/index-bill-runs.service.test.js b/test/services/bill-runs/index-bill-runs.service.test.js index 38feeb750d..0f56cd0533 100644 --- a/test/services/bill-runs/index-bill-runs.service.test.js +++ b/test/services/bill-runs/index-bill-runs.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -106,7 +106,7 @@ describe('Index Bill Runs service', () => { }) }) -function _fetchedBillRuns () { +function _fetchedBillRuns() { return [ { id: '31fec553-f2de-40cf-a8d7-a5fb65f5761b', diff --git a/test/services/bill-runs/initiate-bill-run.service.test.js b/test/services/bill-runs/initiate-bill-run.service.test.js index 9ca5fd7e8b..551bc8c099 100644 --- a/test/services/bill-runs/initiate-bill-run.service.test.js +++ b/test/services/bill-runs/initiate-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/match/allocate-returns-to-charge-element.service.test.js b/test/services/bill-runs/match/allocate-returns-to-charge-element.service.test.js index 4730a56c8e..d9851df33f 100644 --- a/test/services/bill-runs/match/allocate-returns-to-charge-element.service.test.js +++ b/test/services/bill-runs/match/allocate-returns-to-charge-element.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -476,7 +476,7 @@ describe('Allocate Returns to Charge Element Service', () => { }) }) -function _generateTestData (returnStatus = 'completed') { +function _generateTestData(returnStatus = 'completed') { // Data not required for the tests has been excluded from the generated data const chargeElement = { authorisedAnnualQuantity: 32, diff --git a/test/services/bill-runs/match/determine-licence-issues.service.test.js b/test/services/bill-runs/match/determine-licence-issues.service.test.js index 66ef2862c3..d244542e89 100644 --- a/test/services/bill-runs/match/determine-licence-issues.service.test.js +++ b/test/services/bill-runs/match/determine-licence-issues.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -105,7 +105,13 @@ describe('Determine Licence Issues Service', () => { it('sets all the issues on the returns object', () => { DetermineLicenceIssuesService.go(licence) - expect(licence.returnLogs[0].issues).to.equal(['Abstraction outside period', 'Checking query', 'Over abstraction', 'Returns received late', 'Return split over charge references']) + expect(licence.returnLogs[0].issues).to.equal([ + 'Abstraction outside period', + 'Checking query', + 'Over abstraction', + 'Returns received late', + 'Return split over charge references' + ]) expect(licence.returnLogs[1].issues).to.equal(['No returns received']) expect(licence.returnLogs[2].issues).to.equal(['Returns received but not processed']) }) @@ -115,8 +121,15 @@ describe('Determine Licence Issues Service', () => { it('sets all the issues on the element object', () => { DetermineLicenceIssuesService.go(licence) - expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[0].issues).to.equal(['Aggregate', 'Overlap of charge dates', 'Some returns not received']) - expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[1].issues).to.equal(['Aggregate', 'Unable to match return']) + expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[0].issues).to.equal([ + 'Aggregate', + 'Overlap of charge dates', + 'Some returns not received' + ]) + expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[1].issues).to.equal([ + 'Aggregate', + 'Unable to match return' + ]) }) it('sets the status of the charge element to "review"', () => { @@ -138,7 +151,9 @@ describe('Determine Licence Issues Service', () => { it('sets the issue "No returns received" on the charge element', () => { DetermineLicenceIssuesService.go(licence) - expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[0].issues).to.equal(['No returns received']) + expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[0].issues).to.equal([ + 'No returns received' + ]) }) }) }) @@ -166,7 +181,9 @@ describe('Determine Licence Issues Service', () => { it('sets the issue "Some returns not received" on the charge element', () => { DetermineLicenceIssuesService.go(licence) - expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[0].issues).to.equal(['Some returns not received']) + expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[0].issues).to.equal([ + 'Some returns not received' + ]) }) }) @@ -178,7 +195,9 @@ describe('Determine Licence Issues Service', () => { it('sets the issue "No returns received" on the charge element', () => { DetermineLicenceIssuesService.go(licence) - expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[0].issues).to.equal(['No returns received']) + expect(licence.chargeVersions[0].chargeReferences[0].chargeElements[0].issues).to.equal([ + 'No returns received' + ]) }) }) }) @@ -246,7 +265,7 @@ describe('Determine Licence Issues Service', () => { }) }) -function _generateNoIssuesLicenceData () { +function _generateNoIssuesLicenceData() { return { chargeVersions: [ { @@ -282,7 +301,7 @@ function _generateNoIssuesLicenceData () { } } -function _generateOneIssueLicenceData (status) { +function _generateOneIssueLicenceData(status) { if (status === 'review') { return { chargeVersions: [ @@ -354,7 +373,7 @@ function _generateOneIssueLicenceData (status) { } } -function _generateMultipleIssuesLicenceData () { +function _generateMultipleIssuesLicenceData() { return { chargeVersions: [ { @@ -430,7 +449,7 @@ function _generateMultipleIssuesLicenceData () { } } -function _generateMultipleReadyIssuesLicenceData () { +function _generateMultipleReadyIssuesLicenceData() { return { chargeVersions: [ { @@ -479,7 +498,7 @@ function _generateMultipleReadyIssuesLicenceData () { } } -function _generateMultipleReviewIssuesLicenceData () { +function _generateMultipleReviewIssuesLicenceData() { return { chargeVersions: [ { diff --git a/test/services/bill-runs/match/fetch-charge-versions.service.test.js b/test/services/bill-runs/match/fetch-charge-versions.service.test.js index 6fdf6ee6a7..be60af48fb 100644 --- a/test/services/bill-runs/match/fetch-charge-versions.service.test.js +++ b/test/services/bill-runs/match/fetch-charge-versions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach, after, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, after, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -57,13 +57,17 @@ describe('Fetch Charge Versions service', () => { beforeEach(async () => { licence = await LicenceHelper.add({ regionId: region.id }) - chargeVersion = await ChargeVersionHelper.add( - { licenceId: licence.id, licenceRef: licence.licenceRef, scheme: 'alcs' } - ) - - chargeReference = await ChargeReferenceHelper.add( - { adjustments: { s127: true }, chargeVersionId: chargeVersion.id, chargeCategory: chargeCategory.id } - ) + chargeVersion = await ChargeVersionHelper.add({ + licenceId: licence.id, + licenceRef: licence.licenceRef, + scheme: 'alcs' + }) + + chargeReference = await ChargeReferenceHelper.add({ + adjustments: { s127: true }, + chargeVersionId: chargeVersion.id, + chargeCategory: chargeCategory.id + }) }) afterEach(async () => { @@ -83,13 +87,17 @@ describe('Fetch Charge Versions service', () => { beforeEach(async () => { licence = await LicenceHelper.add({ regionId: region.id }) - chargeVersion = await ChargeVersionHelper.add( - { licenceId: licence.id, licenceRef: licence.licenceRef, startDate: new Date('2024-04-01') } - ) - - chargeReference = await ChargeReferenceHelper.add( - { adjustments: { s127: true }, chargeVersionId: chargeVersion.id, chargeCategory: chargeCategory.id } - ) + chargeVersion = await ChargeVersionHelper.add({ + licenceId: licence.id, + licenceRef: licence.licenceRef, + startDate: new Date('2024-04-01') + }) + + chargeReference = await ChargeReferenceHelper.add({ + adjustments: { s127: true }, + chargeVersionId: chargeVersion.id, + chargeCategory: chargeCategory.id + }) }) afterEach(async () => { @@ -109,13 +117,17 @@ describe('Fetch Charge Versions service', () => { beforeEach(async () => { licence = await LicenceHelper.add({ regionId: region.id }) - chargeVersion = await ChargeVersionHelper.add( - { endDate: new Date('2023-03-31'), licenceId: licence.id, licenceRef: licence.licenceRef } - ) - - chargeReference = await ChargeReferenceHelper.add( - { adjustments: { s127: true }, chargeVersionId: chargeVersion.id, chargeCategory: chargeCategory.id } - ) + chargeVersion = await ChargeVersionHelper.add({ + endDate: new Date('2023-03-31'), + licenceId: licence.id, + licenceRef: licence.licenceRef + }) + + chargeReference = await ChargeReferenceHelper.add({ + adjustments: { s127: true }, + chargeVersionId: chargeVersion.id, + chargeCategory: chargeCategory.id + }) }) afterEach(async () => { @@ -135,13 +147,17 @@ describe('Fetch Charge Versions service', () => { beforeEach(async () => { licence = await LicenceHelper.add({ regionId: region.id }) - chargeVersion = await ChargeVersionHelper.add( - { licenceId: licence.id, licenceRef: licence.licenceRef, status: 'superseded' } - ) - - chargeReference = await ChargeReferenceHelper.add( - { adjustments: { s127: true }, chargeVersionId: chargeVersion.id, chargeCategory: chargeCategory.id } - ) + chargeVersion = await ChargeVersionHelper.add({ + licenceId: licence.id, + licenceRef: licence.licenceRef, + status: 'superseded' + }) + + chargeReference = await ChargeReferenceHelper.add({ + adjustments: { s127: true }, + chargeVersionId: chargeVersion.id, + chargeCategory: chargeCategory.id + }) }) afterEach(async () => { @@ -163,9 +179,11 @@ describe('Fetch Charge Versions service', () => { chargeVersion = await ChargeVersionHelper.add({ licenceId: licence.id, licenceRef: licence.licenceRef }) - chargeReference = await ChargeReferenceHelper.add( - { adjustments: { s127: true }, chargeVersionId: chargeVersion.id, chargeCategory: chargeCategory.id } - ) + chargeReference = await ChargeReferenceHelper.add({ + adjustments: { s127: true }, + chargeVersionId: chargeVersion.id, + chargeCategory: chargeCategory.id + }) }) afterEach(async () => { @@ -185,13 +203,13 @@ describe('Fetch Charge Versions service', () => { beforeEach(async () => { licence = await LicenceHelper.add({ regionId: region.id }) - chargeVersion = await ChargeVersionHelper.add( - { licenceId: licence.id, licenceRef: licence.licenceRef } - ) + chargeVersion = await ChargeVersionHelper.add({ licenceId: licence.id, licenceRef: licence.licenceRef }) - chargeReference = await ChargeReferenceHelper.add( - { adjustments: { s127: true }, chargeVersionId: chargeVersion.id, chargeCategory: chargeCategory.id } - ) + chargeReference = await ChargeReferenceHelper.add({ + adjustments: { s127: true }, + chargeVersionId: chargeVersion.id, + chargeCategory: chargeCategory.id + }) await WorkflowHelper.add({ licenceId: licence.id }) }) @@ -214,17 +232,19 @@ describe('Fetch Charge Versions service', () => { // NOTE: To make things spicy (!) we have the licence expire _after_ the billing period starts but revoked // before it. Where the licence has dates in more than one of these fields, it is considered ended on the // earliest of them (we have found real examples that confirm this is possible) - licence = await LicenceHelper.add( - { expiredDate: new Date('2019-05-01'), regionId: region.id, revokedDate: new Date('2022-06-01') } - ) + licence = await LicenceHelper.add({ + expiredDate: new Date('2019-05-01'), + regionId: region.id, + revokedDate: new Date('2022-06-01') + }) - chargeVersion = await ChargeVersionHelper.add( - { licenceId: licence.id, licenceRef: licence.licenceRef } - ) + chargeVersion = await ChargeVersionHelper.add({ licenceId: licence.id, licenceRef: licence.licenceRef }) - chargeReference = await ChargeReferenceHelper.add( - { adjustments: { s127: true }, chargeVersionId: chargeVersion.id, chargeCategory: chargeCategory.id } - ) + chargeReference = await ChargeReferenceHelper.add({ + adjustments: { s127: true }, + chargeVersionId: chargeVersion.id, + chargeCategory: chargeCategory.id + }) }) afterEach(async () => { @@ -249,7 +269,9 @@ describe('Fetch Charge Versions service', () => { // second part is to create another charge version with a different licence ref so we can test the order of the // results chargeVersion = await ChargeVersionHelper.add({ - changeReasonId: changeReason.id, licenceId: licence.id, licenceRef: licence.licenceRef + changeReasonId: changeReason.id, + licenceId: licence.id, + licenceRef: licence.licenceRef }) chargeReference = await ChargeReferenceHelper.add({ @@ -275,9 +297,11 @@ describe('Fetch Charge Versions service', () => { // Second charge version to test ordering otherLicence = await LicenceHelper.add({ licenceRef: '01/130', regionId: region.id }) - otherChargeVersion = await ChargeVersionHelper.add( - { changeReasonId: changeReason.id, licenceId: otherLicence.id, licenceRef: otherLicence.licenceRef } - ) + otherChargeVersion = await ChargeVersionHelper.add({ + changeReasonId: changeReason.id, + licenceId: otherLicence.id, + licenceRef: otherLicence.licenceRef + }) otherChargeReference = await ChargeReferenceHelper.add({ chargeVersionId: otherChargeVersion.id, chargeCategoryId: chargeCategory.id, @@ -331,52 +355,54 @@ describe('Fetch Charge Versions service', () => { ] } }, - chargeReferences: [{ - id: chargeReference.id, - volume: 6.819, - description: 'Mineral washing', - aggregate: 0.562114443, - s126: null, - s127: 'true', - s130: null, - winter: null, - charge: null, - chargeCategory: { - reference: chargeCategory.reference, - shortDescription: chargeCategory.shortDescription, - subsistenceCharge: chargeCategory.subsistenceCharge - }, - chargeElements: [ - { - id: chargeElement2.id, - description: 'Trickle Irrigation - Direct', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3, - authorisedAnnualQuantity: 200, - purpose: { - id: purpose.id, - legacyId: purpose.legacyId, - description: purpose.description - } + chargeReferences: [ + { + id: chargeReference.id, + volume: 6.819, + description: 'Mineral washing', + aggregate: 0.562114443, + s126: null, + s127: 'true', + s130: null, + winter: null, + charge: null, + chargeCategory: { + reference: chargeCategory.reference, + shortDescription: chargeCategory.shortDescription, + subsistenceCharge: chargeCategory.subsistenceCharge }, - { - id: chargeElement1.id, - description: 'Trickle Irrigation - Direct', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3, - authorisedAnnualQuantity: 100, - purpose: { - id: purpose.id, - legacyId: purpose.legacyId, - description: purpose.description + chargeElements: [ + { + id: chargeElement2.id, + description: 'Trickle Irrigation - Direct', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3, + authorisedAnnualQuantity: 200, + purpose: { + id: purpose.id, + legacyId: purpose.legacyId, + description: purpose.description + } + }, + { + id: chargeElement1.id, + description: 'Trickle Irrigation - Direct', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3, + authorisedAnnualQuantity: 100, + purpose: { + id: purpose.id, + legacyId: purpose.legacyId, + description: purpose.description + } } - } - ] - }], + ] + } + ], changeReason: { description: changeReason.description } diff --git a/test/services/bill-runs/match/fetch-licences.service.test.js b/test/services/bill-runs/match/fetch-licences.service.test.js index 6e610a6300..b1caf6304d 100644 --- a/test/services/bill-runs/match/fetch-licences.service.test.js +++ b/test/services/bill-runs/match/fetch-licences.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -40,17 +40,15 @@ describe('Fetch Licences service', () => { describe('and there is a single licence linked to a single charge version', () => { beforeEach(() => { - Sinon.stub(FetchChargeVersionsService, 'go').resolves( - [ - { - id: '9407b74d-816c-44a2-9926-73a89a9da985', - startDate: '2022-04-01T00:00:00.000Z', - endDate: null, - status: 'current', - licence: licenceOne - } - ] - ) + Sinon.stub(FetchChargeVersionsService, 'go').resolves([ + { + id: '9407b74d-816c-44a2-9926-73a89a9da985', + startDate: '2022-04-01T00:00:00.000Z', + endDate: null, + status: 'current', + licence: licenceOne + } + ]) }) it('will fetch the data, format it and group the charge version by the licence', async () => { @@ -86,31 +84,29 @@ describe('Fetch Licences service', () => { } beforeEach(() => { - Sinon.stub(FetchChargeVersionsService, 'go').resolves( - [ - { - id: '9407b74d-816c-44a2-9926-73a89a9da985', - startDate: '2022-10-01T00:00:00.000Z', - endDate: null, - status: 'current', - licence: licenceOne - }, - { - id: 'cbab5668-21db-4fe5-9af8-9bb823d9294f', - startDate: '2022-04-01T00:00:00.000Z', - endDate: '2022-09-30T00:00:00.000Z', - status: 'current', - licence: licenceOne - }, - { - id: 'efe652ba-f42c-4113-a190-f3d9d829a640', - startDate: '2022-04-01T00:00:00.000Z', - endDate: null, - status: 'current', - licence: licenceTwo - } - ] - ) + Sinon.stub(FetchChargeVersionsService, 'go').resolves([ + { + id: '9407b74d-816c-44a2-9926-73a89a9da985', + startDate: '2022-10-01T00:00:00.000Z', + endDate: null, + status: 'current', + licence: licenceOne + }, + { + id: 'cbab5668-21db-4fe5-9af8-9bb823d9294f', + startDate: '2022-04-01T00:00:00.000Z', + endDate: '2022-09-30T00:00:00.000Z', + status: 'current', + licence: licenceOne + }, + { + id: 'efe652ba-f42c-4113-a190-f3d9d829a640', + startDate: '2022-04-01T00:00:00.000Z', + endDate: null, + status: 'current', + licence: licenceTwo + } + ]) }) it('will fetch the data, format it and group the charge versions by the licences', async () => { diff --git a/test/services/bill-runs/match/fetch-return-logs-for-licence.service.test.js b/test/services/bill-runs/match/fetch-return-logs-for-licence.service.test.js index 1b895e5681..d582dc74d3 100644 --- a/test/services/bill-runs/match/fetch-return-logs-for-licence.service.test.js +++ b/test/services/bill-runs/match/fetch-return-logs-for-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -226,7 +226,7 @@ describe('Fetch Return Logs for Licence service', () => { }) }) -function _metadata (isTwoPartTariff) { +function _metadata(isTwoPartTariff) { return { nald: { periodEndDay: '31', diff --git a/test/services/bill-runs/match/match-and-allocate.service.test.js b/test/services/bill-runs/match/match-and-allocate.service.test.js index 66095fa3ea..0b22a94275 100644 --- a/test/services/bill-runs/match/match-and-allocate.service.test.js +++ b/test/services/bill-runs/match/match-and-allocate.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -161,7 +161,7 @@ describe('Match And Allocate Service', () => { }) }) -function _generateMatchingReturnsData () { +function _generateMatchingReturnsData() { return [ { id: 'v1:1:5/31/14/*S/0116A:10021668:2022-04-01:2023-03-31', @@ -220,7 +220,7 @@ function _generateMatchingReturnsData () { ] } -function _generateLicencesData () { +function _generateLicencesData() { return [ { id: 'fdae33da-9195-4b97-976a-9791bc4f6b66', @@ -255,13 +255,15 @@ function _generateLicencesData () { s127: 'true', chargeCategory: { reference: '4.6.12', - shortDescription: 'High loss, non-tidal, restricted water, greater than 15 up to and including 50 ML/yr, Tier 2 model', + shortDescription: + 'High loss, non-tidal, restricted water, greater than 15 up to and including 50 ML/yr, Tier 2 model', subsistenceCharge: 68400 }, chargeElements: [ { id: '8eac5976-d16c-4818-8bc8-384d958ce863', - description: 'Spray irrigation at Welland and Deepings Internal Drainage Board drains and the River Glen at West Pinchbeck', + description: + 'Spray irrigation at Welland and Deepings Internal Drainage Board drains and the River Glen at West Pinchbeck', abstractionPeriodStartDay: 1, abstractionPeriodStartMonth: 3, abstractionPeriodEndDay: 31, @@ -275,7 +277,8 @@ function _generateLicencesData () { }, { id: '5713d337-0d52-4d7f-8ecc-0e77d8d63444', - description: 'Spray irrigation at Welland and Deepings Internal Drainage Board drains and the River Glen at West Pinchbeck', + description: + 'Spray irrigation at Welland and Deepings Internal Drainage Board drains and the River Glen at West Pinchbeck', abstractionPeriodStartDay: 1, abstractionPeriodStartMonth: 3, abstractionPeriodEndDay: 31, diff --git a/test/services/bill-runs/match/match-returns-to-charge-element.service.test.js b/test/services/bill-runs/match/match-returns-to-charge-element.service.test.js index 0815a10844..dee7d36294 100644 --- a/test/services/bill-runs/match/match-returns-to-charge-element.service.test.js +++ b/test/services/bill-runs/match/match-returns-to-charge-element.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -15,8 +15,7 @@ describe('Match Returns To Charge Element Service', () => { let returnLogs beforeEach(() => { - chargeElement = - { + chargeElement = { id: '8eac5976-d16c-4818-8bc8-384d958ce863', purpose: { id: 'f3872a42-b91b-4c58-887a-ef09dda686fd', @@ -159,7 +158,7 @@ describe('Match Returns To Charge Element Service', () => { }) // All data not required for the tests has been excluded from the generated data -function _testReturnLogs () { +function _testReturnLogs() { return [ { id: 'v1:6:11/42/18.6.3/295:10055412:2021-11-01:2022-10-31', diff --git a/test/services/bill-runs/match/persist-allocated-licence-to-results.service.test.js b/test/services/bill-runs/match/persist-allocated-licence-to-results.service.test.js index 08bb0d54fa..23e2fa3118 100644 --- a/test/services/bill-runs/match/persist-allocated-licence-to-results.service.test.js +++ b/test/services/bill-runs/match/persist-allocated-licence-to-results.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -226,7 +226,7 @@ describe('Persist Allocated Licence to Results service', () => { }) }) -function _generateData (returnMatched = true) { +function _generateData(returnMatched = true) { const returnId = generateReturnLogId() const chargeElementReturnLogs = [ @@ -237,8 +237,7 @@ function _generateData (returnMatched = true) { ] // All data not required for the tests has been excluded from the generated data - const dataToPersist = - { + const dataToPersist = { id: generateUUID(), licenceRef: '1/11/10/*S/0084', licenceHolder: 'A licence holder', diff --git a/test/services/bill-runs/match/prepare-charge-version.service.test.js b/test/services/bill-runs/match/prepare-charge-version.service.test.js index 5854c56bf1..7b6bb2f7fd 100644 --- a/test/services/bill-runs/match/prepare-charge-version.service.test.js +++ b/test/services/bill-runs/match/prepare-charge-version.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -58,7 +58,7 @@ describe('Prepare Charge Version Service', () => { }) // All data not required for the tests has been excluded from the generated data -function _testChargeVersion () { +function _testChargeVersion() { return { id: 'aad7de5b-d684-4980-bcb7-e3b631d3036f', startDate: new Date('2022-04-01'), @@ -73,7 +73,8 @@ function _testChargeVersion () { id: '4e7f1824-3680-4df0-806f-c6d651ba4771', chargeCategory: { reference: '4.5.12', - shortDescription: 'Medium loss, non-tidal, restricted water, greater than 25 up to and including 83 ML/yr, Tier 2 model', + shortDescription: + 'Medium loss, non-tidal, restricted water, greater than 25 up to and including 83 ML/yr, Tier 2 model', subsistenceCharge: 68400 }, chargeElements: [ @@ -91,7 +92,8 @@ function _testChargeVersion () { id: '6e7f1824-3680-4df0-806f-c6d651ba4771', chargeCategory: { reference: '4.5.12', - shortDescription: 'Medium loss, non-tidal, restricted water, greater than 25 up to and including 83 ML/yr, Tier 2 model', + shortDescription: + 'Medium loss, non-tidal, restricted water, greater than 25 up to and including 83 ML/yr, Tier 2 model', subsistenceCharge: 70000 }, chargeElements: [ diff --git a/test/services/bill-runs/match/prepare-return-logs.service.test.js b/test/services/bill-runs/match/prepare-return-logs.service.test.js index 0cad876518..94b80717ff 100644 --- a/test/services/bill-runs/match/prepare-return-logs.service.test.js +++ b/test/services/bill-runs/match/prepare-return-logs.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -140,7 +140,7 @@ describe('Prepare Return Logs Service', () => { }) }) -function _testLicence () { +function _testLicence() { return { id: 'fdae33da-9195-4b97-976a-9791bc4f6b66', licenceRef: '5/31/14/*S/0116A', @@ -171,7 +171,8 @@ function _testLicence () { s127: 'true', chargeCategory: { reference: '4.5.12', - shortDescription: 'Medium loss, non-tidal, restricted water, greater than 25 up to and including 83 ML/yr, Tier 2 model', + shortDescription: + 'Medium loss, non-tidal, restricted water, greater than 25 up to and including 83 ML/yr, Tier 2 model', subsistenceCharge: 68400 }, chargeElements: [ @@ -199,7 +200,8 @@ function _testLicence () { s127: 'true', chargeCategory: { reference: '4.5.12', - shortDescription: 'Medium loss, non-tidal, restricted water, greater than 25 up to and including 83 ML/yr, Tier 2 model', + shortDescription: + 'Medium loss, non-tidal, restricted water, greater than 25 up to and including 83 ML/yr, Tier 2 model', subsistenceCharge: 70000 }, chargeElements: [ @@ -225,7 +227,7 @@ function _testLicence () { } } -function _testReturnLog () { +function _testReturnLog() { return { id: 'v1:1:01/977:14959864:2022-04-01:2023-03-31', returnReference: '14959864', diff --git a/test/services/bill-runs/reissue/fetch-bills-to-be-reissued.service.test.js b/test/services/bill-runs/reissue/fetch-bills-to-be-reissued.service.test.js index b146f58fac..c7e23a034f 100644 --- a/test/services/bill-runs/reissue/fetch-bills-to-be-reissued.service.test.js +++ b/test/services/bill-runs/reissue/fetch-bills-to-be-reissued.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -79,11 +79,7 @@ describe('Fetch Bills To Be Reissued service', () => { const result = Object.keys(billLicences[0]) - expect(result).to.only.include([ - 'licenceRef', - 'licenceId', - 'transactions' - ]) + expect(result).to.only.include(['licenceRef', 'licenceId', 'transactions']) }) describe('and there are alcs bills to be reissued', () => { diff --git a/test/services/bill-runs/reissue/reissue-bill.service.test.js b/test/services/bill-runs/reissue/reissue-bill.service.test.js index de18c98162..6a78f1066f 100644 --- a/test/services/bill-runs/reissue/reissue-bill.service.test.js +++ b/test/services/bill-runs/reissue/reissue-bill.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -234,13 +234,16 @@ describe('Reissue Bill service', () => { beforeEach(() => { ChargingModuleViewBillRunStatusRequest.send.restore() - billRunStatusStub = Sinon - .stub(ChargingModuleViewBillRunStatusRequest, 'send') - .onFirstCall().resolves({ - succeeded: true, response: { body: { status: 'pending' } } + billRunStatusStub = Sinon.stub(ChargingModuleViewBillRunStatusRequest, 'send') + .onFirstCall() + .resolves({ + succeeded: true, + response: { body: { status: 'pending' } } }) - .onSecondCall().resolves({ - succeeded: true, response: { body: { status: 'initialised' } } + .onSecondCall() + .resolves({ + succeeded: true, + response: { body: { status: 'initialised' } } }) }) @@ -269,8 +272,10 @@ describe('Reissue Bill service', () => { }) it('throws an error', async () => { - await expect(ReissueBillService.go(sourceBill, reissueBillRun)) - .to.reject(Error, 'Charging Module reissue request failed') + await expect(ReissueBillService.go(sourceBill, reissueBillRun)).to.reject( + Error, + 'Charging Module reissue request failed' + ) }) it('includes the bill run and source bill external ids', async () => { @@ -284,7 +289,9 @@ describe('Reissue Bill service', () => { const errorResult = await expect(ReissueBillService.go(sourceBill, reissueBillRun)).to.reject() expect(errorResult.responseBody.error).to.equal('Conflict') - expect(errorResult.responseBody.message).to.equal('Invoice 2274cd48-2a61-4b73-a9c0-bc5696c5218d has already been rebilled.') + expect(errorResult.responseBody.message).to.equal( + 'Invoice 2274cd48-2a61-4b73-a9c0-bc5696c5218d has already been rebilled.' + ) expect(errorResult.responseBody.statusCode).to.equal(409) }) }) @@ -305,8 +312,10 @@ describe('Reissue Bill service', () => { }) it('throws an error', async () => { - await expect(ReissueBillService.go(sourceBill, reissueBillRun)) - .to.reject(Error, 'Charging Module view bill request failed') + await expect(ReissueBillService.go(sourceBill, reissueBillRun)).to.reject( + Error, + 'Charging Module view bill request failed' + ) }) it('includes the bill run and reissue bill external ids', async () => { @@ -322,14 +331,16 @@ describe('Reissue Bill service', () => { const errorResult = await expect(ReissueBillService.go(sourceBill, reissueBillRun)).to.reject() expect(errorResult.responseBody.error).to.equal('Conflict') - expect(errorResult.responseBody.message).to.equal('Invoice 2274cd48-2a61-4b73-a9c0-bc5696c5218d has already been rebilled.') + expect(errorResult.responseBody.message).to.equal( + 'Invoice 2274cd48-2a61-4b73-a9c0-bc5696c5218d has already been rebilled.' + ) expect(errorResult.responseBody.statusCode).to.equal(409) }) }) }) }) -function _generateCMTransaction (credit, rebilledTransactionId) { +function _generateCMTransaction(credit, rebilledTransactionId) { return { id: generateUUID(), chargeValue: 1000, diff --git a/test/services/bill-runs/reissue/reissue-bills.service.test.js b/test/services/bill-runs/reissue/reissue-bills.service.test.js index fb5ff19369..1245d334b0 100644 --- a/test/services/bill-runs/reissue/reissue-bills.service.test.js +++ b/test/services/bill-runs/reissue/reissue-bills.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -91,12 +91,11 @@ describe('Reissue Bills service', () => { it('persists all bills', async () => { await ReissueBillsService.go(reissueBillRun) - const result = await BillModel.query() - .whereIn('billRunId', [ - reissueBillOne.bills[0].billRunId, - reissueBillTwo.bills[0].billRunId, - reissueBillThree.bills[0].billRunId - ]) + const result = await BillModel.query().whereIn('billRunId', [ + reissueBillOne.bills[0].billRunId, + reissueBillTwo.bills[0].billRunId, + reissueBillThree.bills[0].billRunId + ]) expect(result).to.have.length(3) }) @@ -104,12 +103,11 @@ describe('Reissue Bills service', () => { it('persists all bill licences', async () => { await ReissueBillsService.go(reissueBillRun) - const result = await BillLicenceModel.query() - .whereIn('billId', [ - reissueBillOne.billLicences[0].billId, - reissueBillTwo.billLicences[0].billId, - reissueBillThree.billLicences[0].billId - ]) + const result = await BillLicenceModel.query().whereIn('billId', [ + reissueBillOne.billLicences[0].billId, + reissueBillTwo.billLicences[0].billId, + reissueBillThree.billLicences[0].billId + ]) expect(result).to.have.length(3) }) @@ -117,12 +115,11 @@ describe('Reissue Bills service', () => { it('persists all transactions', async () => { await ReissueBillsService.go(reissueBillRun) - const result = await TransactionModel.query() - .whereIn('billLicenceId', [ - reissueBillOne.transactions[0].billLicenceId, - reissueBillTwo.transactions[0].billLicenceId, - reissueBillThree.transactions[0].billLicenceId - ]) + const result = await TransactionModel.query().whereIn('billLicenceId', [ + reissueBillOne.transactions[0].billLicenceId, + reissueBillTwo.transactions[0].billLicenceId, + reissueBillThree.transactions[0].billLicenceId + ]) expect(result).to.have.length(3) }) @@ -130,19 +127,23 @@ describe('Reissue Bills service', () => { }) }) -function _reissueBillServiceResponse () { +function _reissueBillServiceResponse() { return { bills: [BillModel.fromJson(BillHelper.defaults())], billLicences: [BillLicenceModel.fromJson(BillLicenceHelper.defaults())], - transactions: [TransactionModel.fromJson({ - ...TransactionHelper.defaults(), - purposes: [{ - id: '01adfc33-4ba9-4215-bbe0-97014730991b', - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3, - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4 - }] - })] + transactions: [ + TransactionModel.fromJson({ + ...TransactionHelper.defaults(), + purposes: [ + { + id: '01adfc33-4ba9-4215-bbe0-97014730991b', + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3, + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4 + } + ] + }) + ] } } diff --git a/test/services/bill-runs/review/authorised.service.test.js b/test/services/bill-runs/review/authorised.service.test.js index 8e02639e90..e4d8518e1a 100644 --- a/test/services/bill-runs/review/authorised.service.test.js +++ b/test/services/bill-runs/review/authorised.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/edit.service.test.js b/test/services/bill-runs/review/edit.service.test.js index 91f7f8f98d..c356569f73 100644 --- a/test/services/bill-runs/review/edit.service.test.js +++ b/test/services/bill-runs/review/edit.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/factors.service.test.js b/test/services/bill-runs/review/factors.service.test.js index 6d611995f6..7de3e5c5f6 100644 --- a/test/services/bill-runs/review/factors.service.test.js +++ b/test/services/bill-runs/review/factors.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/fetch-bill-run-licences.service.test.js b/test/services/bill-runs/review/fetch-bill-run-licences.service.test.js index 4e07006003..569dfbe698 100644 --- a/test/services/bill-runs/review/fetch-bill-run-licences.service.test.js +++ b/test/services/bill-runs/review/fetch-bill-run-licences.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/fetch-remove-review-licence.service.test.js b/test/services/bill-runs/review/fetch-remove-review-licence.service.test.js index 387fbb15ef..f0c68f70fc 100644 --- a/test/services/bill-runs/review/fetch-remove-review-licence.service.test.js +++ b/test/services/bill-runs/review/fetch-remove-review-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/fetch-review-charge-element.service.test.js b/test/services/bill-runs/review/fetch-review-charge-element.service.test.js index b5a7e80337..6d205a8651 100644 --- a/test/services/bill-runs/review/fetch-review-charge-element.service.test.js +++ b/test/services/bill-runs/review/fetch-review-charge-element.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -42,11 +42,13 @@ describe('Bill Runs Review - Fetch Review Charge Element service', () => { reviewLicence = await ReviewLicenceHelper.add({ billRunId: billRun.id }) reviewReturn = await ReviewReturnHelper.add({ - purposes: [{ - primary: { code: 'A', description: 'Agriculture' }, - tertiary: { code: '400', description: 'Spray Irrigation - Direct' }, - secondary: { code: 'AGR', description: 'General Agriculture' } - }], + purposes: [ + { + primary: { code: 'A', description: 'Agriculture' }, + tertiary: { code: '400', description: 'Spray Irrigation - Direct' }, + secondary: { code: 'AGR', description: 'General Agriculture' } + } + ], returnId: returnLog.id, returnReference: returnLog.returnReference, reviewLicenceId: reviewLicence.id @@ -55,11 +57,13 @@ describe('Bill Runs Review - Fetch Review Charge Element service', () => { reviewChargeVersion = await ReviewChargeVersionHelper.add({ reviewLicenceId: reviewLicence.id }) reviewChargeReference = await ReviewChargeReferenceHelper.add({ reviewChargeVersionId: reviewChargeVersion.id }) reviewChargeElement = await ReviewChargeElementHelper.add({ - chargeElementId: chargeElement.id, reviewChargeReferenceId: reviewChargeReference.id + chargeElementId: chargeElement.id, + reviewChargeReferenceId: reviewChargeReference.id }) await ReviewChargeElementReturnHelper.add({ - reviewChargeElementId: reviewChargeElement.id, reviewReturnId: reviewReturn.id + reviewChargeElementId: reviewChargeElement.id, + reviewReturnId: reviewReturn.id }) }) diff --git a/test/services/bill-runs/review/fetch-review-charge-reference.test.js b/test/services/bill-runs/review/fetch-review-charge-reference.test.js index a0fee11f5e..8d8254a0ed 100644 --- a/test/services/bill-runs/review/fetch-review-charge-reference.test.js +++ b/test/services/bill-runs/review/fetch-review-charge-reference.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,7 +47,9 @@ describe('Bill Runs Review - Fetch Review Charge Reference service', () => { licence = await LicenceHelper.add() reviewLicence = await ReviewLicenceHelper.add({ - billRunId: billRun.id, licenceId: licence.id, licenceRef: licence.licenceRef + billRunId: billRun.id, + licenceId: licence.id, + licenceRef: licence.licenceRef }) reviewChargeVersion = await ReviewChargeVersionHelper.add({ reviewLicenceId: reviewLicence.id }) @@ -56,7 +58,8 @@ describe('Bill Runs Review - Fetch Review Charge Reference service', () => { reviewChargeVersionId: reviewChargeVersion.id }) reviewChargeElement = await ReviewChargeElementHelper.add({ - chargeElementId: chargeElement.id, reviewChargeReferenceId: reviewChargeReference.id + chargeElementId: chargeElement.id, + reviewChargeReferenceId: reviewChargeReference.id }) }) diff --git a/test/services/bill-runs/review/fetch-review-licence.service.test.js b/test/services/bill-runs/review/fetch-review-licence.service.test.js index 2bfa1a7b62..3daca1b0a7 100644 --- a/test/services/bill-runs/review/fetch-review-licence.service.test.js +++ b/test/services/bill-runs/review/fetch-review-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -73,24 +73,31 @@ describe('Bill Runs Review - Fetch Review Licence service', () => { returnLog = await ReturnLogHelper.add() chargeVersion = await ChargeVersionHelper.add({ - billingAccountId: billingAccount.id, licenceId: licence.id, licenceRef: licence.licenceRef + billingAccountId: billingAccount.id, + licenceId: licence.id, + licenceRef: licence.licenceRef }) chargeCategory = ChargeCategoryHelper.select() chargeReference = await ChargeReferenceHelper.add({ - chargeCategoryId: chargeCategory.id, chargeVersionId: chargeVersion.id + chargeCategoryId: chargeCategory.id, + chargeVersionId: chargeVersion.id }) purpose = PurposeHelper.select() chargeElement = await ChargeElementHelper.add({ chargeReferenceId: chargeReference.id, purposeId: purpose.id }) reviewLicence = await ReviewLicenceHelper.add({ - billRunId: billRun.id, licenceId: licence.id, licenceRef: licence.licenceRef + billRunId: billRun.id, + licenceId: licence.id, + licenceRef: licence.licenceRef }) reviewReturn = await ReviewReturnHelper.add({ - purposes: [{ - primary: { code: 'A', description: 'Agriculture' }, - tertiary: { code: '400', description: 'Spray Irrigation - Direct' }, - secondary: { code: 'AGR', description: 'General Agriculture' } - }], + purposes: [ + { + primary: { code: 'A', description: 'Agriculture' }, + tertiary: { code: '400', description: 'Spray Irrigation - Direct' }, + secondary: { code: 'AGR', description: 'General Agriculture' } + } + ], returnId: returnLog.id, reviewLicenceId: reviewLicence.id }) @@ -109,7 +116,8 @@ describe('Bill Runs Review - Fetch Review Licence service', () => { }) await ReviewChargeElementReturnHelper.add({ - reviewChargeElementId: reviewChargeElement.id, reviewReturnId: reviewReturn.id + reviewChargeElementId: reviewChargeElement.id, + reviewReturnId: reviewReturn.id }) }) diff --git a/test/services/bill-runs/review/preview.service.test.js b/test/services/bill-runs/review/preview.service.test.js index d96565629f..ec24c52eb1 100644 --- a/test/services/bill-runs/review/preview.service.test.js +++ b/test/services/bill-runs/review/preview.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/process-bill-run-post-remove.service.test.js b/test/services/bill-runs/review/process-bill-run-post-remove.service.test.js index 7bb65334c1..6988e87b23 100644 --- a/test/services/bill-runs/review/process-bill-run-post-remove.service.test.js +++ b/test/services/bill-runs/review/process-bill-run-post-remove.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/bill-runs/review/remove-review-licence.service.test.js b/test/services/bill-runs/review/remove-review-licence.service.test.js index f7d5ddfb7e..8168cfc340 100644 --- a/test/services/bill-runs/review/remove-review-licence.service.test.js +++ b/test/services/bill-runs/review/remove-review-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/remove.service.test.js b/test/services/bill-runs/review/remove.service.test.js index 79e50e65d1..c17f50887b 100644 --- a/test/services/bill-runs/review/remove.service.test.js +++ b/test/services/bill-runs/review/remove.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/review-bill-run.service.test.js b/test/services/bill-runs/review/review-bill-run.service.test.js index 253e46dc5c..e6ae730c97 100644 --- a/test/services/bill-runs/review/review-bill-run.service.test.js +++ b/test/services/bill-runs/review/review-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/review-charge-element.service.test.js b/test/services/bill-runs/review/review-charge-element.service.test.js index 634c890293..54e691d3d2 100644 --- a/test/services/bill-runs/review/review-charge-element.service.test.js +++ b/test/services/bill-runs/review/review-charge-element.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -36,7 +36,9 @@ describe('Bill Runs Review - Review Charge Element Service', () => { describe('when called', () => { describe('and there is a flash message to display', () => { beforeEach(() => { - yarStub = { flash: Sinon.stub().withArgs('banner').returns(['The billable returns for this licence have been updated']) } + yarStub = { + flash: Sinon.stub().withArgs('banner').returns(['The billable returns for this licence have been updated']) + } }) it('returns page data for the view', async () => { diff --git a/test/services/bill-runs/review/review-charge-reference.service.test.js b/test/services/bill-runs/review/review-charge-reference.service.test.js index 0053d2b1eb..efa7f45138 100644 --- a/test/services/bill-runs/review/review-charge-reference.service.test.js +++ b/test/services/bill-runs/review/review-charge-reference.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/review-licence.service.test.js b/test/services/bill-runs/review/review-licence.service.test.js index eb40b3aba5..79308ff161 100644 --- a/test/services/bill-runs/review/review-licence.service.test.js +++ b/test/services/bill-runs/review/review-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -65,7 +65,8 @@ describe('Bill Runs Review - Review Licence Service', () => { { billableReturnsWarning: false, chargeCategory: 'Charge reference 4.6.5', - chargeDescription: 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model', + chargeDescription: + 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model', id: '6c70461b-3f83-47b1-9538-8305e82b34eb', chargeElements: [ { @@ -162,7 +163,8 @@ describe('Bill Runs Review - Review Licence Service', () => { { billableReturnsWarning: false, chargeCategory: 'Charge reference 4.6.5', - chargeDescription: 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model', + chargeDescription: + 'High loss, non-tidal, restricted water, up to and including 15 ML/yr, Tier 1 model', id: '6c70461b-3f83-47b1-9538-8305e82b34eb', chargeElements: [ { diff --git a/test/services/bill-runs/review/submit-authorised.service.test.js b/test/services/bill-runs/review/submit-authorised.service.test.js index 3d45221399..98d580f776 100644 --- a/test/services/bill-runs/review/submit-authorised.service.test.js +++ b/test/services/bill-runs/review/submit-authorised.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/submit-edit.service.test.js b/test/services/bill-runs/review/submit-edit.service.test.js index 0db8ea9496..179f6d35f8 100644 --- a/test/services/bill-runs/review/submit-edit.service.test.js +++ b/test/services/bill-runs/review/submit-edit.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/submit-factors.service.test.js b/test/services/bill-runs/review/submit-factors.service.test.js index f70e88ca21..7e661a24c2 100644 --- a/test/services/bill-runs/review/submit-factors.service.test.js +++ b/test/services/bill-runs/review/submit-factors.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/review/submit-remove.service.test.js b/test/services/bill-runs/review/submit-remove.service.test.js index f1f0b0168d..14284d41af 100644 --- a/test/services/bill-runs/review/submit-remove.service.test.js +++ b/test/services/bill-runs/review/submit-remove.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -31,13 +31,9 @@ describe('Bill Runs Review - Submit Remove service', () => { Sinon.stub(FetchRemoveReviewLicenceService, 'go').resolves(removeReviewLicence) - removeReviewLicenceStub = Sinon - .stub(RemoveReviewLicenceService, 'go') - .withArgs(removeReviewLicence.id) - .resolves() + removeReviewLicenceStub = Sinon.stub(RemoveReviewLicenceService, 'go').withArgs(removeReviewLicence.id).resolves() - createLicenceSupplementaryYearStub = Sinon - .stub(CreateLicenceSupplementaryYearService, 'go') + createLicenceSupplementaryYearStub = Sinon.stub(CreateLicenceSupplementaryYearService, 'go') .withArgs(removeReviewLicence.licenceId, [removeReviewLicence.billRun.toFinancialYearEnding], true) .resolves() diff --git a/test/services/bill-runs/review/submit-review-bill-run.service.test.js b/test/services/bill-runs/review/submit-review-bill-run.service.test.js index 985abf4380..6423945356 100644 --- a/test/services/bill-runs/review/submit-review-bill-run.service.test.js +++ b/test/services/bill-runs/review/submit-review-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/bill-runs/review/submit-review-licence.service.test.js b/test/services/bill-runs/review/submit-review-licence.service.test.js index a3be9a2384..d9adce4503 100644 --- a/test/services/bill-runs/review/submit-review-licence.service.test.js +++ b/test/services/bill-runs/review/submit-review-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/send-transactions.service.test.js b/test/services/bill-runs/send-transactions.service.test.js index 1d9e0108bb..04714874ce 100644 --- a/test/services/bill-runs/send-transactions.service.test.js +++ b/test/services/bill-runs/send-transactions.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -76,9 +76,7 @@ describe('Send Transactions service', () => { it('throws a BillRunError with the correct code', async () => { const error = await expect( SendTransactionsService.go(transactions, billRunExternalId, accountNumber, licence) - ) - .to - .reject() + ).to.reject() expect(error).to.be.an.instanceOf(BillRunError) expect(error.code).to.equal(BillRunModel.errorCodes.failedToCreateCharge) @@ -86,7 +84,7 @@ describe('Send Transactions service', () => { }) }) -function _transaction (transactionId) { +function _transaction(transactionId) { return { id: transactionId, chargeReferenceId: '32058a19-4813-4ee7-808b-a0559deb8469', @@ -122,7 +120,7 @@ function _transaction (transactionId) { } } -function _chargingModuleResponse (transactionId) { +function _chargingModuleResponse(transactionId) { return { succeeded: true, response: { diff --git a/test/services/bill-runs/send/send-bill-run.service.test.js b/test/services/bill-runs/send/send-bill-run.service.test.js index 86000d2090..1df92cd614 100644 --- a/test/services/bill-runs/send/send-bill-run.service.test.js +++ b/test/services/bill-runs/send/send-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -89,14 +89,12 @@ describe('Bill Runs - Send Bill Run service', () => { describe('when the bill run does not exist', () => { it('throws as error', async () => { - await expect(SendBillBunService.go('47e66de7-f05f-42d2-8fef-640b55150919')) - .to - .reject() + await expect(SendBillBunService.go('47e66de7-f05f-42d2-8fef-640b55150919')).to.reject() }) }) }) -function _billRun () { +function _billRun() { return { batchType: 'annual', createdAt: new Date('2024-05-07'), diff --git a/test/services/bill-runs/send/submit-send-bill-run.service.test.js b/test/services/bill-runs/send/submit-send-bill-run.service.test.js index e6db4c3162..6a739f8dfe 100644 --- a/test/services/bill-runs/send/submit-send-bill-run.service.test.js +++ b/test/services/bill-runs/send/submit-send-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -80,7 +80,7 @@ describe('Bill Runs - Submit Cancel Bill Run service', () => { }) }) -function _billRun () { +function _billRun() { return { batchType: 'annual', createdAt: new Date('2024-05-07'), diff --git a/test/services/bill-runs/send/update-invoice-numbers.service.test.js b/test/services/bill-runs/send/update-invoice-numbers.service.test.js index f810389a6b..908470d81e 100644 --- a/test/services/bill-runs/send/update-invoice-numbers.service.test.js +++ b/test/services/bill-runs/send/update-invoice-numbers.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code const BillModel = require('../../../../app/models/bill.model.js') @@ -106,7 +106,8 @@ describe('Bill Runs - Update Invoice Numbers service', () => { expect(billRunPatchStub.calledOnce).to.be.true() expect(billRunPatchStub.firstCall.firstArg).to.equal( - { status: 'sent', transactionFileReference: 'nalwi50031' }, { skip: ['updatedAt'] } + { status: 'sent', transactionFileReference: 'nalwi50031' }, + { skip: ['updatedAt'] } ) }) @@ -115,9 +116,7 @@ describe('Bill Runs - Update Invoice Numbers service', () => { const logDataArg = notifierStub.omg.args[0][1] - expect( - notifierStub.omg.calledWith('Send bill run complete') - ).to.be.true() + expect(notifierStub.omg.calledWith('Send bill run complete')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.billRun).to.equal(billRun) @@ -159,9 +158,7 @@ describe('Bill Runs - Update Invoice Numbers service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Send bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Send bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(Error) }) @@ -171,9 +168,7 @@ describe('Bill Runs - Update Invoice Numbers service', () => { beforeEach(async () => { billRun = _billRun() - chargingModuleSendBillRunRequestStub.rejects( - new ExpandedError('Charging Module send request failed', {}) - ) + chargingModuleSendBillRunRequestStub.rejects(new ExpandedError('Charging Module send request failed', {})) }) it('does not throw an error', async () => { @@ -185,9 +180,7 @@ describe('Bill Runs - Update Invoice Numbers service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Send bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Send bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(ExpandedError) }) @@ -210,9 +203,7 @@ describe('Bill Runs - Update Invoice Numbers service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Send bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Send bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(ExpandedError) }) @@ -240,9 +231,7 @@ describe('Bill Runs - Update Invoice Numbers service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Send bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Send bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(Error) }) @@ -256,10 +245,12 @@ describe('Bill Runs - Update Invoice Numbers service', () => { chargingModuleViewBillRunRequestStub.resolves() Sinon.stub(BillModel, 'query').returns({ - patch: Sinon.stub().returnsThis(), where: Sinon.stub().resolves() + patch: Sinon.stub().returnsThis(), + where: Sinon.stub().resolves() }) Sinon.stub(BillRunModel, 'query').returns({ - findById: Sinon.stub().returnsThis(), patch: Sinon.stub().rejects() + findById: Sinon.stub().returnsThis(), + patch: Sinon.stub().rejects() }) }) @@ -272,9 +263,7 @@ describe('Bill Runs - Update Invoice Numbers service', () => { const errorLogArgs = notifierStub.omfg.firstCall.args - expect( - notifierStub.omfg.calledWith('Send bill run failed') - ).to.be.true() + expect(notifierStub.omfg.calledWith('Send bill run failed')).to.be.true() expect(errorLogArgs[1]).to.equal(billRun) expect(errorLogArgs[2]).to.be.instanceOf(Error) }) @@ -283,7 +272,7 @@ describe('Bill Runs - Update Invoice Numbers service', () => { }) }) -function _billRun () { +function _billRun() { return { batchType: 'annual', createdAt: new Date('2024-05-07'), diff --git a/test/services/bill-runs/send/view-send-bill-run.service.test.js b/test/services/bill-runs/send/view-send-bill-run.service.test.js index 00c0d98c5b..e841337241 100644 --- a/test/services/bill-runs/send/view-send-bill-run.service.test.js +++ b/test/services/bill-runs/send/view-send-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -70,9 +70,7 @@ describe('Bill Runs - View Send Bill Run service', () => { describe('when a bill run with a matching ID does not exist', () => { it('throws an exception', async () => { - await expect(ViewSendBillRunService.go('testId')) - .to - .reject() + await expect(ViewSendBillRunService.go('testId')).to.reject() }) }) }) diff --git a/test/services/bill-runs/setup/create.service.test.js b/test/services/bill-runs/setup/create.service.test.js index 97f000c2ac..7b94f322e2 100644 --- a/test/services/bill-runs/setup/create.service.test.js +++ b/test/services/bill-runs/setup/create.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -76,12 +76,7 @@ describe('Bill Runs Setup Create service', () => { await CreateService.go(user, existsResults) expect(legacyCreateBillRunRequestStub.called).to.be.false() - expect(startBillRunProcessServiceStub.calledWith( - region.id, - 'annual', - 'carol.shaw@atari.com', - 2024) - ).to.be.true() + expect(startBillRunProcessServiceStub.calledWith(region.id, 'annual', 'carol.shaw@atari.com', 2024)).to.be.true() }) }) @@ -102,11 +97,8 @@ describe('Bill Runs Setup Create service', () => { await CreateService.go(user, existsResults) expect(legacyCreateBillRunRequestStub.called).to.be.true() - expect(startBillRunProcessServiceStub.calledWith( - region.id, - 'supplementary', - 'carol.shaw@atari.com', - 2024) + expect( + startBillRunProcessServiceStub.calledWith(region.id, 'supplementary', 'carol.shaw@atari.com', 2024) ).to.be.true() }) }) @@ -120,11 +112,8 @@ describe('Bill Runs Setup Create service', () => { await CreateService.go(user, existsResults) expect(legacyCreateBillRunRequestStub.called).to.be.false() - expect(startBillRunProcessServiceStub.calledWith( - region.id, - 'supplementary', - 'carol.shaw@atari.com', - 2024) + expect( + startBillRunProcessServiceStub.calledWith(region.id, 'supplementary', 'carol.shaw@atari.com', 2024) ).to.be.true() }) }) @@ -185,11 +174,8 @@ describe('Bill Runs Setup Create service', () => { await CreateService.go(user, existsResults) expect(legacyCreateBillRunRequestStub.called).to.be.false() - expect(startBillRunProcessServiceStub.calledWith( - region.id, - 'two_part_tariff', - 'carol.shaw@atari.com', - 2023) + expect( + startBillRunProcessServiceStub.calledWith(region.id, 'two_part_tariff', 'carol.shaw@atari.com', 2023) ).to.be.true() }) }) diff --git a/test/services/bill-runs/setup/determine-financial-year-end.service.test.js b/test/services/bill-runs/setup/determine-financial-year-end.service.test.js index 27720b6395..ae9f74ac7a 100644 --- a/test/services/bill-runs/setup/determine-financial-year-end.service.test.js +++ b/test/services/bill-runs/setup/determine-financial-year-end.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -56,7 +56,10 @@ describe('Bill Runs Setup Determine Financial Year End service', () => { beforeEach(async () => { billRun = await BillRunHelper.add({ - batchType: 'annual', regionId, status: 'sent', toFinancialYearEnding: currentFinancialYearEnd + batchType: 'annual', + regionId, + status: 'sent', + toFinancialYearEnding: currentFinancialYearEnd }) }) @@ -76,7 +79,10 @@ describe('Bill Runs Setup Determine Financial Year End service', () => { beforeEach(async () => { billRun = await BillRunHelper.add({ - batchType: 'annual', regionId, status: 'sent', toFinancialYearEnding: currentFinancialYearEnd - 1 + batchType: 'annual', + regionId, + status: 'sent', + toFinancialYearEnding: currentFinancialYearEnd - 1 }) }) @@ -100,10 +106,16 @@ describe('Bill Runs Setup Determine Financial Year End service', () => { beforeEach(async () => { billRunOne = await BillRunHelper.add({ - batchType: 'annual', regionId, status: 'sent', toFinancialYearEnding: currentFinancialYearEnd + batchType: 'annual', + regionId, + status: 'sent', + toFinancialYearEnding: currentFinancialYearEnd }) billRunTwo = await BillRunHelper.add({ - batchType: 'annual', regionId, status: 'sent', toFinancialYearEnding: currentFinancialYearEnd + 1 + batchType: 'annual', + regionId, + status: 'sent', + toFinancialYearEnding: currentFinancialYearEnd + 1 }) }) @@ -125,10 +137,16 @@ describe('Bill Runs Setup Determine Financial Year End service', () => { beforeEach(async () => { billRunOne = await BillRunHelper.add({ - batchType: 'two_part_tariff', regionId, status: 'sent', toFinancialYearEnding: currentFinancialYearEnd + batchType: 'two_part_tariff', + regionId, + status: 'sent', + toFinancialYearEnding: currentFinancialYearEnd }) billRunTwo = await BillRunHelper.add({ - batchType: 'annual', regionId, status: 'sent', toFinancialYearEnding: currentFinancialYearEnd - 1 + batchType: 'annual', + regionId, + status: 'sent', + toFinancialYearEnding: currentFinancialYearEnd - 1 }) }) diff --git a/test/services/bill-runs/setup/exists.service.test.js b/test/services/bill-runs/setup/exists.service.test.js index 29d5177677..7a004949b4 100644 --- a/test/services/bill-runs/setup/exists.service.test.js +++ b/test/services/bill-runs/setup/exists.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -71,17 +71,19 @@ describe('Bill Runs Setup Exists service', () => { describe('and a matching bill run exists', () => { beforeEach(async () => { - Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([{ - id: 'dfbbc7ac-b15b-483a-afcf-a7c01ac377d1', - batchType: 'two_part_tariff', - billRunNumber: 12345, - createdAt: new Date('2022-05-01'), - region, - scheme: 'alcs', - status: 'sent', - summer: true, - toFinancialYearEnding: 2022 - }]) + Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([ + { + id: 'dfbbc7ac-b15b-483a-afcf-a7c01ac377d1', + batchType: 'two_part_tariff', + billRunNumber: 12345, + createdAt: new Date('2022-05-01'), + region, + scheme: 'alcs', + status: 'sent', + summer: true, + toFinancialYearEnding: 2022 + } + ]) }) it('returns an object with "matchResults:" set, a populated "pageData:" property and year to use is as selected', async () => { @@ -133,17 +135,19 @@ describe('Bill Runs Setup Exists service', () => { describe('and a matching bill run exists', () => { beforeEach(async () => { - Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([{ - id: '5612815f-9f67-4ac1-b697-d9ab7789274c', - batchType: 'annual', - billRunNumber: 12345, - createdAt: new Date('2023-05-01'), - region, - scheme: 'sroc', - status: 'sent', - summer: false, - toFinancialYearEnding: 2024 - }]) + Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([ + { + id: '5612815f-9f67-4ac1-b697-d9ab7789274c', + batchType: 'annual', + billRunNumber: 12345, + createdAt: new Date('2023-05-01'), + region, + scheme: 'sroc', + status: 'sent', + summer: false, + toFinancialYearEnding: 2024 + } + ]) }) it('returns an object with "matchResults:" set, a populated "pageData:" property and year to use is as selected', async () => { @@ -195,17 +199,19 @@ describe('Bill Runs Setup Exists service', () => { describe('and one matching bill run exists', () => { beforeEach(async () => { - Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([{ - id: '7b8a518b-ee0c-4c12-acfe-3b99f99d4c53', - batchType: 'supplementary', - billRunNumber: 12345, - createdAt: new Date('2023-05-01'), - region, - scheme: 'sroc', - status: 'ready', - summer: false, - toFinancialYearEnding: 2024 - }]) + Sinon.stub(DetermineBlockingBillRunService, 'go').resolves([ + { + id: '7b8a518b-ee0c-4c12-acfe-3b99f99d4c53', + batchType: 'supplementary', + billRunNumber: 12345, + createdAt: new Date('2023-05-01'), + region, + scheme: 'sroc', + status: 'ready', + summer: false, + toFinancialYearEnding: 2024 + } + ]) }) // NOTE: If there is only one match for supplementary we don't populate the pageData because we won't show the @@ -258,8 +264,12 @@ describe('Bill Runs Setup Exists service', () => { const { matchResults, pageData, session, yearToUse } = result - expect(['7b8a518b-ee0c-4c12-acfe-3b99f99d4c53', '5be625b3-a954-465d-8ab8-cde1b2f052ce']).includes(matchResults[0].id) - expect(['7b8a518b-ee0c-4c12-acfe-3b99f99d4c53', '5be625b3-a954-465d-8ab8-cde1b2f052ce']).includes(matchResults[1].id) + expect(['7b8a518b-ee0c-4c12-acfe-3b99f99d4c53', '5be625b3-a954-465d-8ab8-cde1b2f052ce']).includes( + matchResults[0].id + ) + expect(['7b8a518b-ee0c-4c12-acfe-3b99f99d4c53', '5be625b3-a954-465d-8ab8-cde1b2f052ce']).includes( + matchResults[1].id + ) expect(pageData.billRunId).to.equal(matchResults[0].id) expect(session).to.equal(session) expect(yearToUse).to.equal(currentFinancialEndYear) diff --git a/test/services/bill-runs/setup/fetch-licence-supplementary-years.service.test.js b/test/services/bill-runs/setup/fetch-licence-supplementary-years.service.test.js index 0308793c8a..aaa95e01ee 100644 --- a/test/services/bill-runs/setup/fetch-licence-supplementary-years.service.test.js +++ b/test/services/bill-runs/setup/fetch-licence-supplementary-years.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach, after, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, after, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/fetch-regions.service.test.js b/test/services/bill-runs/setup/fetch-regions.service.test.js index 0891bb27f5..43d097b6ea 100644 --- a/test/services/bill-runs/setup/fetch-regions.service.test.js +++ b/test/services/bill-runs/setup/fetch-regions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Test helper @@ -29,7 +29,9 @@ describe('Bill Runs Setup - Fetch Regions service', () => { // This should be removed and do an exact check when the others tests have been migrated to use the seeded regions expectedRegions.forEach((expectedRegion) => { - const region = results.find((region) => { return region.id === expectedRegion.id }) + const region = results.find((region) => { + return region.id === expectedRegion.id + }) expect(region).to.equal(expectedRegion) }) diff --git a/test/services/bill-runs/setup/initialise-session.service.test.js b/test/services/bill-runs/setup/initialise-session.service.test.js index 2afb1f6990..0c845b2f7a 100644 --- a/test/services/bill-runs/setup/initialise-session.service.test.js +++ b/test/services/bill-runs/setup/initialise-session.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/no-licences.service.test.js b/test/services/bill-runs/setup/no-licences.service.test.js index 22e389d856..5d426e401e 100644 --- a/test/services/bill-runs/setup/no-licences.service.test.js +++ b/test/services/bill-runs/setup/no-licences.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/region.service.test.js b/test/services/bill-runs/setup/region.service.test.js index 1f0be2cd5f..43f0065afb 100644 --- a/test/services/bill-runs/setup/region.service.test.js +++ b/test/services/bill-runs/setup/region.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/season.service.test.js b/test/services/bill-runs/setup/season.service.test.js index 8c24de33a0..f3c865a01d 100644 --- a/test/services/bill-runs/setup/season.service.test.js +++ b/test/services/bill-runs/setup/season.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/submit-region.service.test.js b/test/services/bill-runs/setup/submit-region.service.test.js index 1d877e9ba7..0d98a82a30 100644 --- a/test/services/bill-runs/setup/submit-region.service.test.js +++ b/test/services/bill-runs/setup/submit-region.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/submit-season.service.test.js b/test/services/bill-runs/setup/submit-season.service.test.js index e594989a06..089a2a817f 100644 --- a/test/services/bill-runs/setup/submit-season.service.test.js +++ b/test/services/bill-runs/setup/submit-season.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/submit-type.service.test.js b/test/services/bill-runs/setup/submit-type.service.test.js index 246c402a9b..dbcf8f3b6b 100644 --- a/test/services/bill-runs/setup/submit-type.service.test.js +++ b/test/services/bill-runs/setup/submit-type.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/submit-year.service.test.js b/test/services/bill-runs/setup/submit-year.service.test.js index 165fd0917b..0b829cba1e 100644 --- a/test/services/bill-runs/setup/submit-year.service.test.js +++ b/test/services/bill-runs/setup/submit-year.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/type.service.test.js b/test/services/bill-runs/setup/type.service.test.js index ba6cb0ad3e..6775ea4654 100644 --- a/test/services/bill-runs/setup/type.service.test.js +++ b/test/services/bill-runs/setup/type.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/setup/year.service.test.js b/test/services/bill-runs/setup/year.service.test.js index a92e9bd92d..77e643f859 100644 --- a/test/services/bill-runs/setup/year.service.test.js +++ b/test/services/bill-runs/setup/year.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/start-bill-run-process.service.test.js b/test/services/bill-runs/start-bill-run-process.service.test.js index 18fc9afe28..69146da622 100644 --- a/test/services/bill-runs/start-bill-run-process.service.test.js +++ b/test/services/bill-runs/start-bill-run-process.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/supplementary/fetch-billing-accounts.service.test.js b/test/services/bill-runs/supplementary/fetch-billing-accounts.service.test.js index 11625f0f4d..5153a6bf21 100644 --- a/test/services/bill-runs/supplementary/fetch-billing-accounts.service.test.js +++ b/test/services/bill-runs/supplementary/fetch-billing-accounts.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/supplementary/fetch-charge-versions.service.test.js b/test/services/bill-runs/supplementary/fetch-charge-versions.service.test.js index bc9c9735ca..7891780b52 100644 --- a/test/services/bill-runs/supplementary/fetch-charge-versions.service.test.js +++ b/test/services/bill-runs/supplementary/fetch-charge-versions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -52,7 +52,9 @@ describe('Fetch Charge Versions service', () => { // This creates an SROC charge version with a start date after the billing period. This will be picked in // next years bill runs await ChargeVersionHelper.add({ - licenceId: licence.id, licenceRef: licence.licenceRef, startDate: new Date('2025-04-01') + licenceId: licence.id, + licenceRef: licence.licenceRef, + startDate: new Date('2025-04-01') }) }) @@ -67,7 +69,8 @@ describe('Fetch Charge Versions service', () => { describe('because the licences flagged for supplementary billing are linked to a different region', () => { beforeEach(async () => { licence = await LicenceHelper.add({ - regionId: 'e117b501-e3c1-4337-ad35-21c60ed9ad73', includeInSrocBilling: true + regionId: 'e117b501-e3c1-4337-ad35-21c60ed9ad73', + includeInSrocBilling: true }) // This creates an SROC charge version linked to a licence with an different region than selected @@ -186,29 +189,48 @@ describe('Fetch Charge Versions service', () => { const billingAccountId = '77483323-daec-443e-912f-b87e1e9d0721' // This creates a 'current' SROC charge version which covers only FYE 2024 - const sroc2024ChargeVersion = await ChargeVersionHelper.add( - { startDate: new Date('2023-11-01'), changeReasonId: changeReason.id, billingAccountId, licenceId, licenceRef } - ) + const sroc2024ChargeVersion = await ChargeVersionHelper.add({ + startDate: new Date('2023-11-01'), + changeReasonId: changeReason.id, + billingAccountId, + licenceId, + licenceRef + }) // This creates a 'current' SROC charge version which covers both FYE 2023 and 2024 - const sroc2023And24ChargeVersion = await ChargeVersionHelper.add( - { endDate: new Date('2023-10-31'), changeReasonId: changeReason.id, billingAccountId, licenceId, licenceRef } - ) + const sroc2023And24ChargeVersion = await ChargeVersionHelper.add({ + endDate: new Date('2023-10-31'), + changeReasonId: changeReason.id, + billingAccountId, + licenceId, + licenceRef + }) // This creates a 'current' SROC charge version which covers only FYE 2023 - const sroc2023ChargeVersion = await ChargeVersionHelper.add( - { endDate: new Date('2022-10-31'), changeReasonId: changeReason.id, billingAccountId, licenceId, licenceRef } - ) + const sroc2023ChargeVersion = await ChargeVersionHelper.add({ + endDate: new Date('2022-10-31'), + changeReasonId: changeReason.id, + billingAccountId, + licenceId, + licenceRef + }) // This creates a 'superseded' SROC charge version - const srocSupersededChargeVersion = await ChargeVersionHelper.add( - { changeReasonId: changeReason.id, status: 'superseded', billingAccountId, licenceId, licenceRef } - ) + const srocSupersededChargeVersion = await ChargeVersionHelper.add({ + changeReasonId: changeReason.id, + status: 'superseded', + billingAccountId, + licenceId, + licenceRef + }) // This creates an ALCS (presroc) charge version - const alcsChargeVersion = await ChargeVersionHelper.add( - { scheme: 'alcs', billingAccountId, licenceId, licenceRef } - ) + const alcsChargeVersion = await ChargeVersionHelper.add({ + scheme: 'alcs', + billingAccountId, + licenceId, + licenceRef + }) testRecords = [ sroc2024ChargeVersion, @@ -325,13 +347,15 @@ describe('Fetch Charge Versions service', () => { reference: chargeCategory.reference, shortDescription: chargeCategory.shortDescription }, - chargeElements: [{ - id: chargeElement2024.id, - abstractionPeriodStartDay: chargeElement2024.abstractionPeriodStartDay, - abstractionPeriodStartMonth: chargeElement2024.abstractionPeriodStartMonth, - abstractionPeriodEndDay: chargeElement2024.abstractionPeriodEndDay, - abstractionPeriodEndMonth: chargeElement2024.abstractionPeriodEndMonth - }] + chargeElements: [ + { + id: chargeElement2024.id, + abstractionPeriodStartDay: chargeElement2024.abstractionPeriodStartDay, + abstractionPeriodStartMonth: chargeElement2024.abstractionPeriodStartMonth, + abstractionPeriodEndDay: chargeElement2024.abstractionPeriodEndDay, + abstractionPeriodEndMonth: chargeElement2024.abstractionPeriodEndMonth + } + ] } const expectedResult2023And24 = { @@ -346,13 +370,15 @@ describe('Fetch Charge Versions service', () => { reference: chargeCategory.reference, shortDescription: chargeCategory.shortDescription }, - chargeElements: [{ - id: chargeElement2023And24.id, - abstractionPeriodStartDay: chargeElement2023And24.abstractionPeriodStartDay, - abstractionPeriodStartMonth: chargeElement2023And24.abstractionPeriodStartMonth, - abstractionPeriodEndDay: chargeElement2023And24.abstractionPeriodEndDay, - abstractionPeriodEndMonth: chargeElement2023And24.abstractionPeriodEndMonth - }] + chargeElements: [ + { + id: chargeElement2023And24.id, + abstractionPeriodStartDay: chargeElement2023And24.abstractionPeriodStartDay, + abstractionPeriodStartMonth: chargeElement2023And24.abstractionPeriodStartMonth, + abstractionPeriodEndDay: chargeElement2023And24.abstractionPeriodEndDay, + abstractionPeriodEndMonth: chargeElement2023And24.abstractionPeriodEndMonth + } + ] } const expectedResult2023 = { @@ -367,13 +393,15 @@ describe('Fetch Charge Versions service', () => { reference: chargeCategory.reference, shortDescription: chargeCategory.shortDescription }, - chargeElements: [{ - id: chargeElement2023.id, - abstractionPeriodStartDay: chargeElement2023.abstractionPeriodStartDay, - abstractionPeriodStartMonth: chargeElement2023.abstractionPeriodStartMonth, - abstractionPeriodEndDay: chargeElement2023.abstractionPeriodEndDay, - abstractionPeriodEndMonth: chargeElement2023.abstractionPeriodEndMonth - }] + chargeElements: [ + { + id: chargeElement2023.id, + abstractionPeriodStartDay: chargeElement2023.abstractionPeriodStartDay, + abstractionPeriodStartMonth: chargeElement2023.abstractionPeriodStartMonth, + abstractionPeriodEndDay: chargeElement2023.abstractionPeriodEndDay, + abstractionPeriodEndMonth: chargeElement2023.abstractionPeriodEndMonth + } + ] } expect(result.chargeVersions[0].chargeReferences[0]).to.equal(expectedResult2024) diff --git a/test/services/bill-runs/supplementary/fetch-previous-transactions.service.test.js b/test/services/bill-runs/supplementary/fetch-previous-transactions.service.test.js index 21ff9d86ff..38ea06703a 100644 --- a/test/services/bill-runs/supplementary/fetch-previous-transactions.service.test.js +++ b/test/services/bill-runs/supplementary/fetch-previous-transactions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -160,12 +160,16 @@ describe('Fetch Previous Transactions service', () => { ) expect(results).to.have.length(2) - expect(results.every((transaction) => { - return !transaction.credit - })).to.be.true() - expect(results.find((transaction) => { - return transaction.description === 'follow up' - })).to.exist() + expect( + results.every((transaction) => { + return !transaction.credit + }) + ).to.be.true() + expect( + results.find((transaction) => { + return transaction.description === 'follow up' + }) + ).to.exist() }) }) }) @@ -208,7 +212,7 @@ describe('Fetch Previous Transactions service', () => { }) }) -async function _createBillRunAndBillAndBillLicence (billRunSetupValues) { +async function _createBillRunAndBillAndBillLicence(billRunSetupValues) { const { billingAccountId, accountNumber, licenceId, licenceRef } = billRunSetupValues const { id: billRunId } = await BillRunHelper.add({ status: 'sent' }) const { id: billId } = await BillHelper.add({ billRunId, billingAccountId, accountNumber }) diff --git a/test/services/bill-runs/supplementary/pre-generate-billing-data.service.test.js b/test/services/bill-runs/supplementary/pre-generate-billing-data.service.test.js index 6070088371..f3303caba9 100644 --- a/test/services/bill-runs/supplementary/pre-generate-billing-data.service.test.js +++ b/test/services/bill-runs/supplementary/pre-generate-billing-data.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -106,7 +106,8 @@ describe('Pre-generate billing data service', () => { const { billLicences: result } = await PreGenerateBillingDataService.go( chargeVersions, billRunId, - billingPeriod) + billingPeriod + ) const entries = Object.entries(result) diff --git a/test/services/bill-runs/supplementary/process-bill-run.service.test.js b/test/services/bill-runs/supplementary/process-bill-run.service.test.js index 564f1782ca..627842b9bd 100644 --- a/test/services/bill-runs/supplementary/process-bill-run.service.test.js +++ b/test/services/bill-runs/supplementary/process-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bill-runs/supplementary/process-billing-period.service.test.js b/test/services/bill-runs/supplementary/process-billing-period.service.test.js index dc4086e19d..bdb8907b94 100644 --- a/test/services/bill-runs/supplementary/process-billing-period.service.test.js +++ b/test/services/bill-runs/supplementary/process-billing-period.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -79,17 +79,16 @@ describe('Supplementary Process billing period service', () => { describe('but none of them are billable', () => { describe('because the billable days calculated as 0', () => { beforeEach(async () => { - const { id: chargeVersionId } = await ChargeVersionHelper.add( - { - changeReasonId: changeReason.id, - billingAccountId: billingAccount.id, - startDate: new Date(2022, 7, 1, 9), - licenceId: licence.id - } - ) - const { id: chargeReferenceId } = await ChargeReferenceHelper.add( - { chargeCategoryId: chargeCategory.id, chargeVersionId } - ) + const { id: chargeVersionId } = await ChargeVersionHelper.add({ + changeReasonId: changeReason.id, + billingAccountId: billingAccount.id, + startDate: new Date(2022, 7, 1, 9), + licenceId: licence.id + }) + const { id: chargeReferenceId } = await ChargeReferenceHelper.add({ + chargeCategoryId: chargeCategory.id, + chargeVersionId + }) await ChargeElementHelper.add({ chargeReferenceId, @@ -116,18 +115,17 @@ describe('Supplementary Process billing period service', () => { describe('because the charge version status is "superseded"', () => { describe('and there are no previously billed transactions', () => { beforeEach(async () => { - const { id: chargeVersionId } = await ChargeVersionHelper.add( - { - changeReasonId: changeReason.id, - billingAccountId: billingAccount.id, - startDate: new Date(2022, 7, 1, 9), - licenceId: licence.id, - status: 'superseded' - } - ) - const { chargeElementId } = await ChargeReferenceHelper.add( - { chargeCategoryId: chargeCategory.id, chargeVersionId } - ) + const { id: chargeVersionId } = await ChargeVersionHelper.add({ + changeReasonId: changeReason.id, + billingAccountId: billingAccount.id, + startDate: new Date(2022, 7, 1, 9), + licenceId: licence.id, + status: 'superseded' + }) + const { chargeElementId } = await ChargeReferenceHelper.add({ + chargeCategoryId: chargeCategory.id, + chargeVersionId + }) await ChargeElementHelper.add({ chargeElementId, @@ -153,17 +151,16 @@ describe('Supplementary Process billing period service', () => { describe('and they are billable', () => { beforeEach(async () => { - const { id: chargeVersionId } = await ChargeVersionHelper.add( - { - changeReasonId: changeReason.id, - billingAccountId: billingAccount.id, - startDate: new Date(2022, 7, 1, 9), - licenceId: licence.id - } - ) - const { id: chargeReferenceId } = await ChargeReferenceHelper.add( - { chargeCategoryId: chargeCategory.id, chargeVersionId } - ) + const { id: chargeVersionId } = await ChargeVersionHelper.add({ + changeReasonId: changeReason.id, + billingAccountId: billingAccount.id, + startDate: new Date(2022, 7, 1, 9), + licenceId: licence.id + }) + const { id: chargeReferenceId } = await ChargeReferenceHelper.add({ + chargeCategoryId: chargeCategory.id, + chargeVersionId + }) await ChargeElementHelper.add({ chargeReferenceId, @@ -177,42 +174,45 @@ describe('Supplementary Process billing period service', () => { chargeVersions = chargeVersionData.chargeVersions - const sentTransactions = [{ - id: '9b092372-1a26-436a-bf1f-b5eb3f9aca44', - billLicenceId: '594fc25e-99c1-440a-8b88-b507ee17738a', - chargeReferenceId: '32058a19-4813-4ee7-808b-a0559deb8469', - startDate: new Date('2022-04-01'), - endDate: new Date('2022-10-31'), - source: 'non-tidal', - season: 'all year', - loss: 'low', - credit: false, - chargeType: 'standard', - authorisedQuantity: 6.82, - billableQuantity: 6.82, - authorisedDays: 365, - billableDays: 214, - status: 'charge_created', - description: 'Water abstraction charge: Mineral washing', - volume: 6.82, - section126Factor: 1, - section127Agreement: false, - section130Agreement: false, - newLicence: false, - secondPartCharge: false, - scheme: 'sroc', - aggregateFactor: 0.562114443, - adjustmentFactor: 1, - chargeCategoryCode: '4.4.5', - chargeCategoryDescription: 'Low loss, non-tidal, restricted water, up to and including 5,000 ML/yr, Tier 1 model', - supportedSource: false, - supportedSourceName: null, - waterCompanyCharge: true, - winterOnly: false, - waterUndertaker: false, - externalId: '7e752fa6-a19c-4779-b28c-6e536f028795', - purposes: [{}] - }] + const sentTransactions = [ + { + id: '9b092372-1a26-436a-bf1f-b5eb3f9aca44', + billLicenceId: '594fc25e-99c1-440a-8b88-b507ee17738a', + chargeReferenceId: '32058a19-4813-4ee7-808b-a0559deb8469', + startDate: new Date('2022-04-01'), + endDate: new Date('2022-10-31'), + source: 'non-tidal', + season: 'all year', + loss: 'low', + credit: false, + chargeType: 'standard', + authorisedQuantity: 6.82, + billableQuantity: 6.82, + authorisedDays: 365, + billableDays: 214, + status: 'charge_created', + description: 'Water abstraction charge: Mineral washing', + volume: 6.82, + section126Factor: 1, + section127Agreement: false, + section130Agreement: false, + newLicence: false, + secondPartCharge: false, + scheme: 'sroc', + aggregateFactor: 0.562114443, + adjustmentFactor: 1, + chargeCategoryCode: '4.4.5', + chargeCategoryDescription: + 'Low loss, non-tidal, restricted water, up to and including 5,000 ML/yr, Tier 1 model', + supportedSource: false, + supportedSourceName: null, + waterCompanyCharge: true, + winterOnly: false, + waterUndertaker: false, + externalId: '7e752fa6-a19c-4779-b28c-6e536f028795', + purposes: [{}] + } + ] Sinon.stub(SendTransactionsService, 'go').resolves(sentTransactions) Sinon.stub(ChargingModuleGenerateBillRunRequest, 'send').resolves({ @@ -237,9 +237,10 @@ describe('Supplementary Process billing period service', () => { billingAccountId: billingAccount.id, licenceId: licence.id }) - const { id: chargeReferenceId } = await ChargeReferenceHelper.add( - { chargeCategoryId: chargeCategory.id, chargeVersionId } - ) + const { id: chargeReferenceId } = await ChargeReferenceHelper.add({ + chargeCategoryId: chargeCategory.id, + chargeVersionId + }) await ChargeElementHelper.add({ chargeReferenceId }) @@ -254,9 +255,7 @@ describe('Supplementary Process billing period service', () => { }) it('throws a BillRunError with the correct code', async () => { - const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, chargeVersions)) - .to - .reject() + const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, chargeVersions)).to.reject() expect(error).to.be.an.instanceOf(BillRunError) expect(error.code).to.equal(BillRunModel.errorCodes.failedToPrepareTransactions) @@ -271,9 +270,7 @@ describe('Supplementary Process billing period service', () => { }) it('throws a BillRunError with the correct code', async () => { - const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, chargeVersions)) - .to - .reject() + const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, chargeVersions)).to.reject() expect(error).to.be.an.instanceOf(BillRunError) expect(error.code).to.equal(BillRunModel.errorCodes.failedToCreateCharge) diff --git a/test/services/bill-runs/supplementary/process-transactions.service.test.js b/test/services/bill-runs/supplementary/process-transactions.service.test.js index baea512a63..fdd8f5e076 100644 --- a/test/services/bill-runs/supplementary/process-transactions.service.test.js +++ b/test/services/bill-runs/supplementary/process-transactions.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -102,12 +102,7 @@ describe('Process Transactions service', () => { }) it('returns only the previous transactions', async () => { - const result = await ProcessTransactionsService.go( - [], - billingAccountId, - billLicence, - billingPeriod - ) + const result = await ProcessTransactionsService.go([], billingAccountId, billLicence, billingPeriod) expect(result).to.have.length(2) expect(result[0].purposes).to.equal(['I_WILL_NOT_BE_REMOVED_1']) @@ -165,7 +160,7 @@ describe('Process Transactions service', () => { }) }) -function _generateCalculatedTransaction (chargeCategoryCode, billableDays, testReference, changes = {}) { +function _generateCalculatedTransaction(chargeCategoryCode, billableDays, testReference, changes = {}) { const defaultProperties = { id: '61abdc15-7859-4783-9622-6cb8de7f2461', billLicenceId: '110ab2e2-6076-4d5a-a56f-b17a048eb269', @@ -192,7 +187,7 @@ function _generateCalculatedTransaction (chargeCategoryCode, billableDays, testR } } -function _generatePreviousTransaction (chargeCategoryCode, billableDays, testReference, changes = {}) { +function _generatePreviousTransaction(chargeCategoryCode, billableDays, testReference, changes = {}) { const defaultProperties = { id: '8d68eb26-d054-47a7-aee8-cd93a24fa860', billLicenceId: 'a76b3ab3-d70d-4fb0-8d72-2e2cdd334729', diff --git a/test/services/bill-runs/supplementary/reverse-transactions.service.test.js b/test/services/bill-runs/supplementary/reverse-transactions.service.test.js index ec7fa8cc98..4aeb523ec0 100644 --- a/test/services/bill-runs/supplementary/reverse-transactions.service.test.js +++ b/test/services/bill-runs/supplementary/reverse-transactions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -16,13 +16,15 @@ describe('Reverse Transactions service', () => { name: 'DEBIT', credit: false, status: 'TO_BE_OVERWRITTEN', - purposes: [{ - id: '04cbede8-45cf-433e-b4f5-f33dc911ced0', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3 - }] + purposes: [ + { + id: '04cbede8-45cf-433e-b4f5-f33dc911ced0', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3 + } + ] } ] @@ -42,13 +44,15 @@ describe('Reverse Transactions service', () => { expect(result[0].status).to.equal('candidate') expect(result[0].billLicenceId).to.equal('8affaa71-c185-4b6c-9814-4c615c235611') expect(result[0].id).to.exist().and.to.be.a.string() - expect(result[0].purposes).to.equal([{ - id: '04cbede8-45cf-433e-b4f5-f33dc911ced0', - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3 - }]) + expect(result[0].purposes).to.equal([ + { + id: '04cbede8-45cf-433e-b4f5-f33dc911ced0', + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3 + } + ]) }) }) }) diff --git a/test/services/bill-runs/supplementary/unflag-billed-licences.service.test.js b/test/services/bill-runs/supplementary/unflag-billed-licences.service.test.js index bdbea07bb5..ccf2f7e8db 100644 --- a/test/services/bill-runs/supplementary/unflag-billed-licences.service.test.js +++ b/test/services/bill-runs/supplementary/unflag-billed-licences.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -33,18 +33,26 @@ describe('Unflag Billed Licences service', () => { const updatedAt = new Date('2024-02-02') licenceNotInRegion = await LicenceHelper.add({ - includeInPresrocBilling: 'yes', regionId: otherRegionId, updatedAt + includeInPresrocBilling: 'yes', + regionId: otherRegionId, + updatedAt }) licenceInWorkflow = await LicenceHelper.add({ - includeInPresrocBilling: 'yes', regionId, updatedAt + includeInPresrocBilling: 'yes', + regionId, + updatedAt }) await WorkflowHelper.add({ licenceId: licenceInWorkflow.id, deletedAt: null }) licenceFlaggedAfterBillRunCreated = await LicenceHelper.add({ - includeInPresrocBilling: 'yes', regionId, updatedAt: new Date('2099-01-01') + includeInPresrocBilling: 'yes', + regionId, + updatedAt: new Date('2099-01-01') }) licenceFlaggedBeforeBillRunCreated = await LicenceHelper.add({ - includeInPresrocBilling: 'yes', regionId, updatedAt + includeInPresrocBilling: 'yes', + regionId, + updatedAt }) billRun = { @@ -93,7 +101,8 @@ describe('Unflag Billed Licences service', () => { await WorkflowHelper.add({ licenceId: licenceInBillRunAndWorkflow.id, deletedAt: null }) licenceInBillRunAndFlaggedAfterBillRunCreated = await LicenceHelper.add({ - includeInSrocBilling: true, updatedAt: new Date('2099-01-01') + includeInSrocBilling: true, + updatedAt: new Date('2099-01-01') }) billRun = { diff --git a/test/services/bill-runs/supplementary/unflag-unbilled-licences.service.test.js b/test/services/bill-runs/supplementary/unflag-unbilled-licences.service.test.js index 5a921b043e..baf22d178e 100644 --- a/test/services/bill-runs/supplementary/unflag-unbilled-licences.service.test.js +++ b/test/services/bill-runs/supplementary/unflag-unbilled-licences.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -35,7 +35,8 @@ describe('Unflag unbilled licences service', () => { await WorkflowHelper.add({ licenceId: licenceNotBilledInBillRunAndWorkflow.id, deletedAt: null }) licenceNotBilledInBillRunAndUpdated = await LicenceHelper.add({ - includeInSrocBilling: true, updatedAt: new Date('2099-01-01') + includeInSrocBilling: true, + updatedAt: new Date('2099-01-01') }) licenceBilledInBillRun = await LicenceHelper.add({ includeInSrocBilling: true }) diff --git a/test/services/bill-runs/two-part-tariff/fetch-billing-accounts.service.test.js b/test/services/bill-runs/two-part-tariff/fetch-billing-accounts.service.test.js index 24dba03061..e438a2bd74 100644 --- a/test/services/bill-runs/two-part-tariff/fetch-billing-accounts.service.test.js +++ b/test/services/bill-runs/two-part-tariff/fetch-billing-accounts.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -130,7 +130,12 @@ describe('Fetch Billing Accounts service', () => { expect(chargeReferences[0].loss).to.equal('low') expect(chargeReferences[0].volume).to.equal(6.819) expect(chargeReferences[0].adjustments).to.equal({ - s126: null, s127: false, s130: false, charge: null, winter: false, aggregate: '0.562114443' + s126: null, + s127: false, + s130: false, + charge: null, + winter: false, + aggregate: '0.562114443' }) expect(chargeReferences[0].additionalCharges).to.equal({ isSupplyPublicWater: true }) expect(chargeReferences[0].description).to.equal('Mineral washing') @@ -174,10 +179,8 @@ describe('Fetch Billing Accounts service', () => { it('includes the review charge elements', async () => { const results = await FetchBillingAccountsService.go(billRun.id) - const { reviewChargeElements: result } = results[0] - .chargeVersions[0] - .chargeReferences[0] - .chargeElements[0] + const { reviewChargeElements: result } = + results[0].chargeVersions[0].chargeReferences[0].chargeElements[0] expect(result[0].id).to.equal(reviewChargeElement.id) expect(result[0].amendedAllocated).to.equal(reviewChargeElement.amendedAllocated) diff --git a/test/services/bill-runs/two-part-tariff/generate-bill-run.service.test.js b/test/services/bill-runs/two-part-tariff/generate-bill-run.service.test.js index 724308c0cf..f56121e308 100644 --- a/test/services/bill-runs/two-part-tariff/generate-bill-run.service.test.js +++ b/test/services/bill-runs/two-part-tariff/generate-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -33,7 +33,9 @@ describe('Generate Bill Run Service', () => { const delay = 500 const billRunDetails = { - batchType: 'two_part_tariff', fromFinancialYearEnding: 2023, toFinancialYearEnding: 2023 + batchType: 'two_part_tariff', + fromFinancialYearEnding: 2023, + toFinancialYearEnding: 2023 } let billRun @@ -66,9 +68,7 @@ describe('Generate Bill Run Service', () => { }) it('throws an error', async () => { - const error = await expect(GenerateBillRunService.go(billRun.id)) - .to - .reject() + const error = await expect(GenerateBillRunService.go(billRun.id)).to.reject() expect(error).to.be.an.instanceOf(ExpandedErrorError) expect(error.message).to.equal('Cannot process a two-part tariff bill run that is not in review') diff --git a/test/services/bill-runs/two-part-tariff/generate-transaction.service.test.js b/test/services/bill-runs/two-part-tariff/generate-transaction.service.test.js index 91e0c83718..e661c56f6a 100644 --- a/test/services/bill-runs/two-part-tariff/generate-transaction.service.test.js +++ b/test/services/bill-runs/two-part-tariff/generate-transaction.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -33,48 +33,55 @@ describe('Generate Transaction service', () => { describe('with a charge reference that has volume to be billed', () => { it('returns a two-part tariff transaction ready to be persisted', () => { const result = GenerateTransactionService.go( - billLicenceId, chargeReference, chargePeriod, newLicence, waterUndertaker - ) - - expect(result).to.equal({ billLicenceId, - authorisedDays: 0, - billableDays: 0, + chargeReference, + chargePeriod, newLicence, - waterUndertaker, - chargeReferenceId: '89450220-0f7f-4280-a946-1fdbe9b789c1', - startDate: chargePeriod.startDate, - endDate: chargePeriod.endDate, - source: 'non-tidal', - season: 'all year', - loss: 'low', - credit: false, - chargeType: 'standard', - authorisedQuantity: 20, - billableQuantity: 15, - status: 'candidate', - description: 'Water abstraction charge: Lower Queenstown - Pittisham', - volume: 15, - section126Factor: 1, - section127Agreement: false, - section130Agreement: false, - secondPartCharge: true, - scheme: 'sroc', - aggregateFactor: 0.75, - adjustmentFactor: 0.6, - chargeCategoryCode: '4.4.5', - chargeCategoryDescription: 'Low loss, non-tidal, restricted water, up to and including 5,000 ML/yr, Tier 1 model', - supportedSource: false, - supportedSourceName: null, - waterCompanyCharge: false, - winterOnly: false - }, - { - // We skip the ID because it is a UUID generated by the service. We skip purposes because it is the result of - // calling `toJSON()` on the charge references child ChargeElementModel instances. Including it would just be - // us testing Objection - skip: ['id', 'purposes'] - }) + waterUndertaker + ) + + expect(result).to.equal( + { + billLicenceId, + authorisedDays: 0, + billableDays: 0, + newLicence, + waterUndertaker, + chargeReferenceId: '89450220-0f7f-4280-a946-1fdbe9b789c1', + startDate: chargePeriod.startDate, + endDate: chargePeriod.endDate, + source: 'non-tidal', + season: 'all year', + loss: 'low', + credit: false, + chargeType: 'standard', + authorisedQuantity: 20, + billableQuantity: 15, + status: 'candidate', + description: 'Water abstraction charge: Lower Queenstown - Pittisham', + volume: 15, + section126Factor: 1, + section127Agreement: false, + section130Agreement: false, + secondPartCharge: true, + scheme: 'sroc', + aggregateFactor: 0.75, + adjustmentFactor: 0.6, + chargeCategoryCode: '4.4.5', + chargeCategoryDescription: + 'Low loss, non-tidal, restricted water, up to and including 5,000 ML/yr, Tier 1 model', + supportedSource: false, + supportedSourceName: null, + waterCompanyCharge: false, + winterOnly: false + }, + { + // We skip the ID because it is a UUID generated by the service. We skip purposes because it is the result of + // calling `toJSON()` on the charge references child ChargeElementModel instances. Including it would just be + // us testing Objection + skip: ['id', 'purposes'] + } + ) }) describe('and the charge reference has a two-part tariff agreement (section 127)', () => { @@ -84,10 +91,16 @@ describe('Generate Transaction service', () => { it('returns the two-part tariff prefixed description', () => { const result = GenerateTransactionService.go( - billLicenceId, chargeReference, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + chargePeriod, + newLicence, + waterUndertaker ) - expect(result.description).to.equal('Two-part tariff basic water abstraction charge: Lower Queenstown - Pittisham') + expect(result.description).to.equal( + 'Two-part tariff basic water abstraction charge: Lower Queenstown - Pittisham' + ) }) }) }) @@ -100,7 +113,11 @@ describe('Generate Transaction service', () => { it('returns null', () => { const result = GenerateTransactionService.go( - billLicenceId, chargeReference, chargePeriod, newLicence, waterUndertaker + billLicenceId, + chargeReference, + chargePeriod, + newLicence, + waterUndertaker ) expect(result).to.be.null() @@ -109,16 +126,23 @@ describe('Generate Transaction service', () => { }) }) -function _chargeReference () { +function _chargeReference() { // NOTE: We are faking an Objection model which comes with a toJSON() method that gets called as part // of processing the billing account. - const toJSON = () => { return '{}' } + const toJSON = () => { + return '{}' + } return { id: '89450220-0f7f-4280-a946-1fdbe9b789c1', additionalCharges: { isSupplyPublicWater: false }, adjustments: { - s126: null, s127: false, s130: false, charge: null, winter: false, aggregate: '0.562114443' + s126: null, + s127: false, + s130: false, + charge: null, + winter: false, + aggregate: '0.562114443' }, chargeCategory: { id: 'b270718a-12c0-4fca-884b-3f8612dbe2f5', @@ -147,12 +171,14 @@ function _chargeReference () { ], description: 'Lower Queenstown - Pittisham', loss: 'low', - reviewChargeReferences: [{ - id: '3dd04348-2c06-4559-9343-dd7dd76276ef', - amendedAggregate: 0.75, - amendedAuthorisedVolume: 20, - amendedChargeAdjustment: 0.6 - }], + reviewChargeReferences: [ + { + id: '3dd04348-2c06-4559-9343-dd7dd76276ef', + amendedAggregate: 0.75, + amendedAuthorisedVolume: 20, + amendedChargeAdjustment: 0.6 + } + ], source: 'non-tidal', volume: 20 } diff --git a/test/services/bill-runs/two-part-tariff/process-bill-run.service.test.js b/test/services/bill-runs/two-part-tariff/process-bill-run.service.test.js index 9f77e5583d..989dd1435e 100644 --- a/test/services/bill-runs/two-part-tariff/process-bill-run.service.test.js +++ b/test/services/bill-runs/two-part-tariff/process-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -20,9 +20,7 @@ const MatchAndAllocateService = require('../../../../app/services/bill-runs/matc const TwoPartTariffProcessBillRunService = require('../../../../app/services/bill-runs/two-part-tariff/process-bill-run.service.js') describe('Two Part Tariff Process Bill Run service', () => { - const billingPeriods = [ - { startDate: new Date('2022-04-01'), endDate: new Date('2023-03-31') } - ] + const billingPeriods = [{ startDate: new Date('2022-04-01'), endDate: new Date('2023-03-31') }] let billRun let notifierStub diff --git a/test/services/bill-runs/two-part-tariff/process-billing-period.service.test.js b/test/services/bill-runs/two-part-tariff/process-billing-period.service.test.js index 9cd440cdc3..b8b3283d4c 100644 --- a/test/services/bill-runs/two-part-tariff/process-billing-period.service.test.js +++ b/test/services/bill-runs/two-part-tariff/process-billing-period.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -91,19 +91,25 @@ describe('Two-part Tariff - Process Billing Period service', () => { const bills = await _fetchPersistedBill(billRun.id) expect(bills).to.have.length(1) - expect(bills[0]).to.equal({ - accountNumber: billingAccount.accountNumber, - address: {}, // Address is set to an empty object for SROC billing invoices - billingAccountId: billingAccount.id, - credit: false, - financialYearEnding: billingPeriod.endDate.getFullYear() - }, { skip: ['billLicences'] }) + expect(bills[0]).to.equal( + { + accountNumber: billingAccount.accountNumber, + address: {}, // Address is set to an empty object for SROC billing invoices + billingAccountId: billingAccount.id, + credit: false, + financialYearEnding: billingPeriod.endDate.getFullYear() + }, + { skip: ['billLicences'] } + ) expect(bills[0].billLicences).to.have.length(1) - expect(bills[0].billLicences[0]).to.equal({ - licenceId: licence.id, - licenceRef: licence.licenceRef - }, { skip: ['transactions'] }) + expect(bills[0].billLicences[0]).to.equal( + { + licenceId: licence.id, + licenceRef: licence.licenceRef + }, + { skip: ['transactions'] } + ) expect(bills[0].billLicences[0].transactions).to.have.length(2) }) @@ -136,19 +142,25 @@ describe('Two-part Tariff - Process Billing Period service', () => { const bills = await _fetchPersistedBill(billRun.id) expect(bills).to.have.length(1) - expect(bills[0]).to.equal({ - accountNumber: billingAccount.accountNumber, - address: {}, // Address is set to an empty object for SROC billing invoices - billingAccountId: billingAccount.id, - credit: false, - financialYearEnding: billingPeriod.endDate.getFullYear() - }, { skip: ['billLicences'] }) + expect(bills[0]).to.equal( + { + accountNumber: billingAccount.accountNumber, + address: {}, // Address is set to an empty object for SROC billing invoices + billingAccountId: billingAccount.id, + credit: false, + financialYearEnding: billingPeriod.endDate.getFullYear() + }, + { skip: ['billLicences'] } + ) expect(bills[0].billLicences).to.have.length(1) - expect(bills[0].billLicences[0]).to.equal({ - licenceId: licence.id, - licenceRef: licence.licenceRef - }, { skip: ['transactions'] }) + expect(bills[0].billLicences[0]).to.equal( + { + licenceId: licence.id, + licenceRef: licence.licenceRef + }, + { skip: ['transactions'] } + ) expect(bills[0].billLicences[0].transactions).to.have.length(2) }) @@ -190,9 +202,7 @@ describe('Two-part Tariff - Process Billing Period service', () => { }) it('throws a BillRunError with the correct code', async () => { - const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, [billingAccount])) - .to - .reject() + const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, [billingAccount])).to.reject() expect(error).to.be.an.instanceOf(BillRunError) expect(error.code).to.equal(BillRunModel.errorCodes.failedToPrepareTransactions) @@ -205,9 +215,7 @@ describe('Two-part Tariff - Process Billing Period service', () => { }) it('throws a BillRunError with the correct code', async () => { - const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, [billingAccount])) - .to - .reject() + const error = await expect(ProcessBillingPeriodService.go(billRun, billingPeriod, [billingAccount])).to.reject() expect(error).to.be.an.instanceOf(BillRunError) expect(error.code).to.equal(BillRunModel.errorCodes.failedToCreateCharge) @@ -216,14 +224,14 @@ describe('Two-part Tariff - Process Billing Period service', () => { }) }) -function _billingAccount () { +function _billingAccount() { return { id: generateUUID(), accountNumber: generateAccountNumber() } } -function _chargingModuleResponse (transactionId) { +function _chargingModuleResponse(transactionId) { return { succeeded: true, response: { @@ -232,10 +240,12 @@ function _chargingModuleResponse (transactionId) { } } -function _chargeVersion (billingAccountId, licence) { +function _chargeVersion(billingAccountId, licence) { // NOTE: We are faking an Objection model which comes with a toJSON() method that gets called as part // of processing the billing account. - const toJSON = () => { return '{}' } + const toJSON = () => { + return '{}' + } return { id: generateUUID(), @@ -250,7 +260,12 @@ function _chargeVersion (billingAccountId, licence) { id: generateUUID(), additionalCharges: { isSupplyPublicWater: false }, adjustments: { - s126: null, s127: false, s130: false, charge: null, winter: false, aggregate: '0.562114443' + s126: null, + s127: false, + s130: false, + charge: null, + winter: false, + aggregate: '0.562114443' }, chargeCategory: { id: 'b270718a-12c0-4fca-884b-3f8612dbe2f5', @@ -279,12 +294,14 @@ function _chargeVersion (billingAccountId, licence) { ], description: 'Lower Queenstown - Pittisham', loss: 'low', - reviewChargeReferences: [{ - id: '3dd04348-2c06-4559-9343-dd7dd76276ef', - amendedAggregate: 0.75, - amendedAuthorisedVolume: 20, - amendedChargeAdjustment: 0.6 - }], + reviewChargeReferences: [ + { + id: '3dd04348-2c06-4559-9343-dd7dd76276ef', + amendedAggregate: 0.75, + amendedAuthorisedVolume: 20, + amendedChargeAdjustment: 0.6 + } + ], source: 'non-tidal', volume: 20 } @@ -292,7 +309,7 @@ function _chargeVersion (billingAccountId, licence) { } } -async function _fetchPersistedBill (billRunId) { +async function _fetchPersistedBill(billRunId) { return BillModel.query() .select(['accountNumber', 'address', 'billingAccountId', 'credit', 'financialYearEnding']) .where('billRunId', billRunId) @@ -306,7 +323,7 @@ async function _fetchPersistedBill (billRunId) { }) } -function _licence () { +function _licence() { const region = RegionHelper.select() return { diff --git a/test/services/bill-runs/view-bill-run.service.test.js b/test/services/bill-runs/view-bill-run.service.test.js index 353150d0de..8766f7d409 100644 --- a/test/services/bill-runs/view-bill-run.service.test.js +++ b/test/services/bill-runs/view-bill-run.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -109,28 +109,32 @@ describe('View Bill Run service', () => { { type: 'water-companies', caption: '1 water company', - bills: [{ - id: '64924759-8142-4a08-9d1e-1e902cd9d316', - accountNumber: 'E22288888A', - billingContact: 'Acme Water Services Ltd', - licences: ['17/53/001/A/101', '17/53/002/B/205', '17/53/002/C/308'], - licencesCount: 3, - financialYear: 2023, - total: '£213,178.00' - }] + bills: [ + { + id: '64924759-8142-4a08-9d1e-1e902cd9d316', + accountNumber: 'E22288888A', + billingContact: 'Acme Water Services Ltd', + licences: ['17/53/001/A/101', '17/53/002/B/205', '17/53/002/C/308'], + licencesCount: 3, + financialYear: 2023, + total: '£213,178.00' + } + ] }, { type: 'other-abstractors', caption: '1 other abstractor', - bills: [{ - id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', - accountNumber: 'E11101999A', - billingContact: 'Geordie Leforge', - licences: ['17/53/001/G/782'], - licencesCount: 1, - financialYear: 2023, - total: '£97.00' - }] + bills: [ + { + id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', + accountNumber: 'E11101999A', + billingContact: 'Geordie Leforge', + licences: ['17/53/001/G/782'], + licencesCount: 1, + financialYear: 2023, + total: '£97.00' + } + ] } ], view: 'bill-runs/view.njk' @@ -170,15 +174,17 @@ describe('View Bill Run service', () => { { type: 'other-abstractors', caption: '1 other abstractor', - bills: [{ - id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', - accountNumber: 'E11101999A', - billingContact: 'Geordie Leforge', - licences: ['17/53/001/G/782'], - licencesCount: 1, - financialYear: 2023, - total: '£97.00' - }] + bills: [ + { + id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', + accountNumber: 'E11101999A', + billingContact: 'Geordie Leforge', + licences: ['17/53/001/G/782'], + licencesCount: 1, + financialYear: 2023, + total: '£97.00' + } + ] } ], view: 'bill-runs/view.njk' @@ -190,23 +196,19 @@ describe('View Bill Run service', () => { describe('when a bill run with a matching ID does not exist', () => { beforeEach(() => { - Sinon.stub(FetchBillRunService, 'go').resolves( - { - billRun: undefined, - billSummaries: [] - } - ) + Sinon.stub(FetchBillRunService, 'go').resolves({ + billRun: undefined, + billSummaries: [] + }) }) it('throws an exception', async () => { - await expect(ViewBillRunService.go('testId')) - .to - .reject() + await expect(ViewBillRunService.go('testId')).to.reject() }) }) }) -function _multipleGroupBillRun () { +function _multipleGroupBillRun() { const billSummaries = _billSummariesData() return { @@ -236,7 +238,7 @@ function _multipleGroupBillRun () { } } -function _singleGroupBillRun () { +function _singleGroupBillRun() { const billSummaries = _billSummariesData() delete billSummaries[1] @@ -268,7 +270,7 @@ function _singleGroupBillRun () { } } -function _billSummariesData () { +function _billSummariesData() { return [ { id: '7c8a248c-b71e-463c-bea8-bc5e0a5d95e2', diff --git a/test/services/billing-accounts/change-address.service.test.js b/test/services/billing-accounts/change-address.service.test.js index f6f9cce2a6..d9c14fbf70 100644 --- a/test/services/billing-accounts/change-address.service.test.js +++ b/test/services/billing-accounts/change-address.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -265,7 +265,8 @@ describe('Change address service', () => { describe('is a department', () => { beforeEach(() => { contact = { - type: 'department', department: 'Humanoid Risk Assessment' + type: 'department', + department: 'Humanoid Risk Assessment' } }) @@ -289,7 +290,9 @@ describe('Change address service', () => { describe('is an individual', () => { beforeEach(() => { contact = { - type: 'person', firstName: 'Margarita', lastName: 'Villa' + type: 'person', + firstName: 'Margarita', + lastName: 'Villa' } }) @@ -345,8 +348,9 @@ describe('Change address service', () => { it('overwrites the existing record and ensures the end date is null', async () => { const result = await ChangeAddressService.go(billingAccount.id, address, agentCompany, contact) - const newBillingAccountAddress = await BillingAccountAddressModel.query() - .findById(result.billingAccountAddress.id) + const newBillingAccountAddress = await BillingAccountAddressModel.query().findById( + result.billingAccountAddress.id + ) expect(newBillingAccountAddress.id).to.equal(existingBillingAccountAddress.id) expect(newBillingAccountAddress.addressId).not.to.equal(existingBillingAccountAddress.addressId) @@ -372,8 +376,9 @@ describe('Change address service', () => { it('creates a new billing account record with a null end date', async () => { const result = await ChangeAddressService.go(billingAccount.id, address, agentCompany, contact) - const newBillingAccountAddress = await BillingAccountAddressModel.query() - .findById(result.billingAccountAddress.id) + const newBillingAccountAddress = await BillingAccountAddressModel.query().findById( + result.billingAccountAddress.id + ) expect(newBillingAccountAddress.id).not.to.equal(existingBillingAccountAddress.id) expect(newBillingAccountAddress.addressId).not.to.equal(existingBillingAccountAddress.addressId) @@ -415,7 +420,8 @@ describe('Change address service', () => { organisationType: 'limitedCompany' } contact = { - type: 'department', department: 'Bean Counting' + type: 'department', + department: 'Bean Counting' } // We just need something within the transaction to go bang. `fromJson() is ideal because a) we can stub it!, and diff --git a/test/services/billing-accounts/send-customer-change.service.test.js b/test/services/billing-accounts/send-customer-change.service.test.js index e12f092396..3de2fcd112 100644 --- a/test/services/billing-accounts/send-customer-change.service.test.js +++ b/test/services/billing-accounts/send-customer-change.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bills/fetch-bill-summary.service.test.js b/test/services/bills/fetch-bill-summary.service.test.js index c581416fa4..2659e762c2 100644 --- a/test/services/bills/fetch-bill-summary.service.test.js +++ b/test/services/bills/fetch-bill-summary.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -51,7 +51,10 @@ describe('Fetch Bill Summary service', () => { contactId = contact.id const billingAccountAddress = await BillingAccountAddressHelper.add({ - billingAccountId, companyId: agentCompanyId, contactId, endDate: null + billingAccountId, + companyId: agentCompanyId, + contactId, + endDate: null }) billingAccountAddressId = billingAccountAddress.id @@ -59,13 +62,20 @@ describe('Fetch Bill Summary service', () => { region = RegionHelper.select() const billRun = await BillRunHelper.add({ - billRunNumber: 1075, createdAt: new Date('2023-05-01'), status: 'ready', regionId: region.id + billRunNumber: 1075, + createdAt: new Date('2023-05-01'), + status: 'ready', + regionId: region.id }) billRunId = billRun.id - bill = await BillHelper - .add({ accountNumber: billingAccount.accountNumber, billingAccountId, billRunId, netAmount: 1045 }) + bill = await BillHelper.add({ + accountNumber: billingAccount.accountNumber, + billingAccountId, + billRunId, + netAmount: 1045 + }) const billId = bill.id @@ -91,27 +101,29 @@ describe('Fetch Bill Summary service', () => { name: 'Example Trading Ltd', type: 'organisation' }, - billingAccountAddresses: [{ - id: billingAccountAddressId, - address: null, - company: { - id: agentCompanyId, - name: 'Agent Company Ltd', - type: 'organisation' - }, - contact: { - id: contactId, - contactType: 'person', - dataSource: 'wrls', - department: null, - firstName: 'Amara', - initials: null, - lastName: 'Gupta', - middleInitials: null, - salutation: null, - suffix: null + billingAccountAddresses: [ + { + id: billingAccountAddressId, + address: null, + company: { + id: agentCompanyId, + name: 'Agent Company Ltd', + type: 'organisation' + }, + contact: { + id: contactId, + contactType: 'person', + dataSource: 'wrls', + department: null, + firstName: 'Amara', + initials: null, + lastName: 'Gupta', + middleInitials: null, + salutation: null, + suffix: null + } } - }] + ] }, billLicences: [ { id: billLicences[0].id, licenceRef: billLicences[0].licenceRef }, diff --git a/test/services/bills/fetch-bill.service.test.js b/test/services/bills/fetch-bill.service.test.js index 7d8f0dd7b7..f95521847e 100644 --- a/test/services/bills/fetch-bill.service.test.js +++ b/test/services/bills/fetch-bill.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bills/remove-bill.service.test.js b/test/services/bills/remove-bill.service.test.js index ba08f2fd0a..c546277b53 100644 --- a/test/services/bills/remove-bill.service.test.js +++ b/test/services/bills/remove-bill.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -53,7 +53,7 @@ describe('Remove Bill service', () => { }) }) -function _billSummary () { +function _billSummary() { const billingAccount = BillingAccountModel.fromJson({ id: 'e2b35a4a-7368-425f-9990-faa23efc0a25', accountNumber: 'T65757520A', @@ -62,22 +62,24 @@ function _billSummary () { name: 'Example Trading Ltd', type: 'organisation' }, - billingAccountAddresses: [{ - id: '1d440029-745a-47ec-a43e-9f4a36014126', - company: null, - contact: { - id: '95ba53be-543f-415b-90b1-08f58f63ff74', - contactType: 'person', - dataSource: 'wrls', - department: null, - firstName: 'Amara', - initials: null, - lastName: 'Gupta', - middleInitials: null, - salutation: null, - suffix: null + billingAccountAddresses: [ + { + id: '1d440029-745a-47ec-a43e-9f4a36014126', + company: null, + contact: { + id: '95ba53be-543f-415b-90b1-08f58f63ff74', + contactType: 'person', + dataSource: 'wrls', + department: null, + firstName: 'Amara', + initials: null, + lastName: 'Gupta', + middleInitials: null, + salutation: null, + suffix: null + } } - }] + ] }) return { diff --git a/test/services/bills/submit-remove-bill.services.test.js b/test/services/bills/submit-remove-bill.services.test.js index 7e25f16113..9b2f8394bb 100644 --- a/test/services/bills/submit-remove-bill.services.test.js +++ b/test/services/bills/submit-remove-bill.services.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/bills/view-bill.service.test.js b/test/services/bills/view-bill.service.test.js index 46261820ab..e71824be68 100644 --- a/test/services/bills/view-bill.service.test.js +++ b/test/services/bills/view-bill.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -28,18 +28,16 @@ describe('View Bill service', () => { describe('when a bill with a matching ID exists', () => { describe('and it is linked to multiple licences', () => { beforeEach(() => { - Sinon.stub(FetchBillService, 'go').resolves( - { - bill: { - id: 'a102d2b4-d0d5-4b26-82e2-d74a66e2cdc3', - billingAccountId: '34183769-40d8-4d23-8bbb-f28e4d00c737' - }, - licenceSummaries: [ - { id: '82c106dd-ee90-4566-b06b-a66d9e56b4b1' }, - { id: '5bf9a7f0-c769-486d-a685-f032799e42d9' } - ] - } - ) + Sinon.stub(FetchBillService, 'go').resolves({ + bill: { + id: 'a102d2b4-d0d5-4b26-82e2-d74a66e2cdc3', + billingAccountId: '34183769-40d8-4d23-8bbb-f28e4d00c737' + }, + licenceSummaries: [ + { id: '82c106dd-ee90-4566-b06b-a66d9e56b4b1' }, + { id: '5bf9a7f0-c769-486d-a685-f032799e42d9' } + ] + }) Sinon.stub(BillingAccountModel, 'query').returns({ findById: Sinon.stub().returnsThis(), @@ -50,23 +48,21 @@ describe('View Bill service', () => { billingAccountId: '34183769-40d8-4d23-8bbb-f28e4d00c737' }) - Sinon.stub(ViewLicenceSummariesPresenter, 'go').returns( - { - billLicences: [ - { - id: 'e37320ba-10c8-4954-8bc4-6982e56ded41', - reference: '01/735', - total: '£6,222.18' - }, - { - id: '127377ea-24ea-4578-8b96-ef9a8625a313', - reference: '01/466', - total: '£7,066.55' - } - ], - tableCaption: '3 licences' - } - ) + Sinon.stub(ViewLicenceSummariesPresenter, 'go').returns({ + billLicences: [ + { + id: 'e37320ba-10c8-4954-8bc4-6982e56ded41', + reference: '01/735', + total: '£6,222.18' + }, + { + id: '127377ea-24ea-4578-8b96-ef9a8625a313', + reference: '01/466', + total: '£7,066.55' + } + ], + tableCaption: '3 licences' + }) }) it('will fetch the data and format it using the bill and licence summaries presenters', async () => { @@ -93,31 +89,22 @@ describe('View Bill service', () => { describe('and it is linked to a single licence', () => { beforeEach(() => { - Sinon.stub(FetchBillService, 'go').resolves( - { - bill: { - id: 'a102d2b4-d0d5-4b26-82e2-d74a66e2cdc3', - billingAccountId: '34183769-40d8-4d23-8bbb-f28e4d00c737' - }, - licenceSummaries: [ - { id: '82c106dd-ee90-4566-b06b-a66d9e56b4b1' } - ] - } - ) + Sinon.stub(FetchBillService, 'go').resolves({ + bill: { + id: 'a102d2b4-d0d5-4b26-82e2-d74a66e2cdc3', + billingAccountId: '34183769-40d8-4d23-8bbb-f28e4d00c737' + }, + licenceSummaries: [{ id: '82c106dd-ee90-4566-b06b-a66d9e56b4b1' }] + }) Sinon.stub(ViewBillPresenter, 'go').returns({ billingAccountId: '34183769-40d8-4d23-8bbb-f28e4d00c737' }) - Sinon.stub(ViewBillLicencePresenter, 'go').returns( - { - tableCaption: '2 transactions', - transactions: [ - { chargeType: 'standard' }, - { chargeType: 'compensation' } - ] - } - ) + Sinon.stub(ViewBillLicencePresenter, 'go').returns({ + tableCaption: '2 transactions', + transactions: [{ chargeType: 'standard' }, { chargeType: 'compensation' }] + }) }) it('will fetch the data and format it using the bill and view bill licence presenters', async () => { @@ -126,10 +113,7 @@ describe('View Bill service', () => { expect(result).to.equal({ billingAccountId: '34183769-40d8-4d23-8bbb-f28e4d00c737', tableCaption: '2 transactions', - transactions: [ - { chargeType: 'standard' }, - { chargeType: 'compensation' } - ] + transactions: [{ chargeType: 'standard' }, { chargeType: 'compensation' }] }) }) }) @@ -137,12 +121,10 @@ describe('View Bill service', () => { describe('when a bill with a matching ID does not exist', () => { beforeEach(() => { - Sinon.stub(FetchBillService, 'go').resolves( - { - bill: undefined, - licenceSummaries: [] - } - ) + Sinon.stub(FetchBillService, 'go').resolves({ + bill: undefined, + licenceSummaries: [] + }) Sinon.stub(BillingAccountModel, 'query').returns({ findById: Sinon.stub().returnsThis(), @@ -151,9 +133,7 @@ describe('View Bill service', () => { }) it('throws an exception', async () => { - await expect(ViewBillService.go('testId')) - .to - .reject() + await expect(ViewBillService.go('testId')).to.reject() }) }) }) diff --git a/test/services/data/deduplicate/de-duplicate-licence.service.test.js b/test/services/data/deduplicate/de-duplicate-licence.service.test.js index acd8bf5aff..8d0b488767 100644 --- a/test/services/data/deduplicate/de-duplicate-licence.service.test.js +++ b/test/services/data/deduplicate/de-duplicate-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/data/deduplicate/submit-deduplicate.service.test.js b/test/services/data/deduplicate/submit-deduplicate.service.test.js index 191b6a5542..dcee475554 100644 --- a/test/services/data/deduplicate/submit-deduplicate.service.test.js +++ b/test/services/data/deduplicate/submit-deduplicate.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/data/load/load.service.test.js b/test/services/data/load/load.service.test.js index 204bc209a2..e1ca5fedc1 100644 --- a/test/services/data/load/load.service.test.js +++ b/test/services/data/load/load.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -116,7 +116,10 @@ describe('Load service', () => { it('sets the "is_test" flag on the entity instance as part of loading it', async () => { const result = await LoadService.go(payload) - const licence = await db('licences').withSchema('water').first('isTest').where('licenceId', result.licences[0]) + const licence = await db('licences') + .withSchema('water') + .first('isTest') + .where('licenceId', result.licences[0]) expect(licence.isTest).to.be.true() }) diff --git a/test/services/data/seed/seed.service.test.js b/test/services/data/seed/seed.service.test.js index 08ebba2022..5570eba752 100644 --- a/test/services/data/seed/seed.service.test.js +++ b/test/services/data/seed/seed.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/data/tear-down/tear-down.service.test.js b/test/services/data/tear-down/tear-down.service.test.js index 375190bf89..2ebd16773f 100644 --- a/test/services/data/tear-down/tear-down.service.test.js +++ b/test/services/data/tear-down/tear-down.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/health/database-health-check.service.test.js b/test/services/health/database-health-check.service.test.js index e910631c1a..d06670ee7a 100644 --- a/test/services/health/database-health-check.service.test.js +++ b/test/services/health/database-health-check.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/health/fetch-system-info.service.test.js b/test/services/health/fetch-system-info.service.test.js index 42469cbaf9..067fe4ca40 100644 --- a/test/services/health/fetch-system-info.service.test.js +++ b/test/services/health/fetch-system-info.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/health/info.service.test.js b/test/services/health/info.service.test.js index aafacf6233..fb597ed875 100644 --- a/test/services/health/info.service.test.js +++ b/test/services/health/info.service.test.js @@ -6,7 +6,7 @@ const Code = require('@hapi/code') const Sinon = require('sinon') const Proxyquire = require('proxyquire') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -62,9 +62,7 @@ describe('Info service', () => { legacyRequestStub.withArgs('permits', 'health/info', null, false).resolves(goodRequestResults.app) legacyRequestStub.withArgs('returns', 'health/info', null, false).resolves(goodRequestResults.app) - chargingModuleRequestStub - .withArgs('status') - .resolves(goodRequestResults.chargingModule) + chargingModuleRequestStub.withArgs('status').resolves(goodRequestResults.chargingModule) }) afterEach(() => { @@ -87,13 +85,10 @@ describe('Info service', () => { // stub the util library's `promisify()` method and tell it to call our anonymous stub when invoked. The bit that // makes all this work is the fact we use Proxyquire to load our stubbed util instead of the real one when we load // our module under test - const execStub = Sinon - .stub() - .withArgs('clamdscan --version') - .resolves({ - stdout: 'ClamAV 9.99.9/26685/Mon Oct 10 08:00:01 2022\n', - stderror: null - }) + const execStub = Sinon.stub().withArgs('clamdscan --version').resolves({ + stdout: 'ClamAV 9.99.9/26685/Mon Oct 10 08:00:01 2022\n', + stderror: null + }) const utilStub = { promisify: Sinon.stub().callsFake(() => { return execStub @@ -107,7 +102,11 @@ describe('Info service', () => { const result = await InfoService.go() expect(result).to.include([ - 'virusScannerData', 'redisConnectivityData', 'addressFacadeData', 'chargingModuleData', 'appData' + 'virusScannerData', + 'redisConnectivityData', + 'addressFacadeData', + 'chargingModuleData', + 'appData' ]) expect(result.appData).to.have.length(10) @@ -129,13 +128,10 @@ describe('Info service', () => { .resolves(goodRequestResults.addressFacade) legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(goodRequestResults.app) - const execStub = Sinon - .stub() - .withArgs('clamdscan --version') - .resolves({ - stdout: 'ClamAV 9.99.9/26685/Mon Oct 10 08:00:01 2022\n', - stderror: null - }) + const execStub = Sinon.stub().withArgs('clamdscan --version').resolves({ + stdout: 'ClamAV 9.99.9/26685/Mon Oct 10 08:00:01 2022\n', + stderror: null + }) const utilStub = { promisify: Sinon.stub().callsFake(() => { return execStub @@ -157,7 +153,11 @@ describe('Info service', () => { const result = await InfoService.go() expect(result).to.include([ - 'virusScannerData', 'redisConnectivityData', 'addressFacadeData', 'chargingModuleData', 'appData' + 'virusScannerData', + 'redisConnectivityData', + 'addressFacadeData', + 'chargingModuleData', + 'appData' ]) expect(result.appData).to.have.length(10) expect(result.appData[0].version).to.equal('9.0.99') @@ -183,13 +183,10 @@ describe('Info service', () => { beforeEach(async () => { // We tweak our anonymous stub so that it returns stderr populated, which is what happens if the shell call // returns a non-zero exit code. - const execStub = Sinon - .stub() - .withArgs('clamdscan --version') - .resolves({ - stdout: null, - stderr: 'Could not connect to clamd' - }) + const execStub = Sinon.stub().withArgs('clamdscan --version').resolves({ + stdout: null, + stderr: 'Could not connect to clamd' + }) const utilStub = { promisify: Sinon.stub().callsFake(() => { return execStub @@ -203,7 +200,11 @@ describe('Info service', () => { const result = await InfoService.go() expect(result).to.include([ - 'virusScannerData', 'redisConnectivityData', 'addressFacadeData', 'chargingModuleData', 'appData' + 'virusScannerData', + 'redisConnectivityData', + 'addressFacadeData', + 'chargingModuleData', + 'appData' ]) expect(result.appData).to.have.length(10) expect(result.appData[0].version).to.equal('9.0.99') @@ -217,8 +218,7 @@ describe('Info service', () => { beforeEach(async () => { // In this tweak we tell our anonymous stub to throw an exception when invoked. Not sure when this would happen // but we've coded for the eventuality so we need to test it - const execStub = Sinon - .stub() + const execStub = Sinon.stub() .withArgs('clamdscan --version') .throwsException(new Error('ClamAV check went boom')) const utilStub = { @@ -234,7 +234,11 @@ describe('Info service', () => { const result = await InfoService.go() expect(result).to.include([ - 'virusScannerData', 'redisConnectivityData', 'addressFacadeData', 'chargingModuleData', 'appData' + 'virusScannerData', + 'redisConnectivityData', + 'addressFacadeData', + 'chargingModuleData', + 'appData' ]) expect(result.appData).to.have.length(10) expect(result.appData[0].version).to.equal('9.0.99') @@ -248,13 +252,10 @@ describe('Info service', () => { describe('when a service we check via http request', () => { beforeEach(async () => { // In these scenarios everything is hunky-dory with clamav and redis. So, we go back to our original stubbing - const execStub = Sinon - .stub() - .withArgs('clamdscan --version') - .resolves({ - stdout: 'ClamAV 9.99.9/26685/Mon Oct 10 08:00:01 2022\n', - stderror: null - }) + const execStub = Sinon.stub().withArgs('clamdscan --version').resolves({ + stdout: 'ClamAV 9.99.9/26685/Mon Oct 10 08:00:01 2022\n', + stderror: null + }) const utilStub = { promisify: Sinon.stub().callsFake(() => { return execStub @@ -270,9 +271,7 @@ describe('Info service', () => { beforeEach(async () => { const badResult = { succeeded: false, response: new Error('Kaboom') } - baseRequestStub - .withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`) - .resolves(badResult) + baseRequestStub.withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`).resolves(badResult) legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(badResult) }) @@ -280,7 +279,11 @@ describe('Info service', () => { const result = await InfoService.go() expect(result).to.include([ - 'virusScannerData', 'redisConnectivityData', 'addressFacadeData', 'chargingModuleData', 'appData' + 'virusScannerData', + 'redisConnectivityData', + 'addressFacadeData', + 'chargingModuleData', + 'appData' ]) expect(result.appData).to.have.length(10) expect(result.appData[0].version).to.equal('9.0.99') @@ -296,9 +299,7 @@ describe('Info service', () => { beforeEach(async () => { const badResult = { succeeded: false, response: { statusCode: 500, body: { message: 'Kaboom' } } } - baseRequestStub - .withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`) - .resolves(badResult) + baseRequestStub.withArgs(`${servicesConfig.addressFacade.url}/address-service/hola`).resolves(badResult) legacyRequestStub.withArgs('water', 'health/info', null, false).resolves(badResult) }) @@ -306,7 +307,11 @@ describe('Info service', () => { const result = await InfoService.go() expect(result).to.include([ - 'virusScannerData', 'redisConnectivityData', 'addressFacadeData', 'chargingModuleData', 'appData' + 'virusScannerData', + 'redisConnectivityData', + 'addressFacadeData', + 'chargingModuleData', + 'appData' ]) expect(result.appData).to.have.length(10) expect(result.appData[0].version).to.equal('9.0.99') diff --git a/test/services/idm/fetch-user-roles-and-groups.service.test.js b/test/services/idm/fetch-user-roles-and-groups.service.test.js index 7534c76c36..254cebe876 100644 --- a/test/services/idm/fetch-user-roles-and-groups.service.test.js +++ b/test/services/idm/fetch-user-roles-and-groups.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/import/determine-supplementary-billing-flags.service.test.js b/test/services/import/determine-supplementary-billing-flags.service.test.js index 66805d9e55..5dc7266474 100644 --- a/test/services/import/determine-supplementary-billing-flags.service.test.js +++ b/test/services/import/determine-supplementary-billing-flags.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/import/legacy/process-licence.service.test.js b/test/services/import/legacy/process-licence.service.test.js index 1dee9b3e93..96e4a6f957 100644 --- a/test/services/import/legacy/process-licence.service.test.js +++ b/test/services/import/legacy/process-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -74,7 +74,12 @@ describe('Import Legacy Process Licence service', () => { describe('when there is a valid NALD licence to import with an existing licence', () => { beforeEach(() => { - Sinon.stub(TransformLicenceService, 'go').resolves({ naldLicenceId, regionCode, transformedLicence, wrlsLicenceId }) + Sinon.stub(TransformLicenceService, 'go').resolves({ + naldLicenceId, + regionCode, + transformedLicence, + wrlsLicenceId + }) PersistImportServiceStub = Sinon.stub(PersistImportService, 'go').resolves(licenceId) processLicenceReturnLogsServiceStub = Sinon.stub(ProcessLicenceReturnLogsService, 'go').resolves() }) @@ -91,9 +96,7 @@ describe('Import Legacy Process Licence service', () => { const logDataArg = notifierStub.omg.firstCall.args[1] - expect( - notifierStub.omg.calledWith('Legacy licence import complete') - ).to.be.true() + expect(notifierStub.omg.calledWith('Legacy licence import complete')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.licenceId).to.equal(licenceId) @@ -135,21 +138,23 @@ describe('Import Legacy Process Licence service', () => { // NOTE: This is an incomplete transformed licence. But this minimum valid structure saves us having to also stub // the LicenceStructureValidator -function _transformedLicence (licenceRef) { +function _transformedLicence(licenceRef) { return { licenceRef, - licenceVersions: [{ - externalId: '6:2113:100:0', - licenceVersionPurposes: [ - { - externalId: '6:10000004', - licenceVersionPurposeConditions: [] - }, - { - externalId: '6:10000005', - licenceVersionPurposeConditions: [] - } - ] - }] + licenceVersions: [ + { + externalId: '6:2113:100:0', + licenceVersionPurposes: [ + { + externalId: '6:10000004', + licenceVersionPurposeConditions: [] + }, + { + externalId: '6:10000005', + licenceVersionPurposeConditions: [] + } + ] + } + ] } } diff --git a/test/services/import/legacy/transform-addresses.service.test.js b/test/services/import/legacy/transform-addresses.service.test.js index 1be029f440..f0569f66ab 100644 --- a/test/services/import/legacy/transform-addresses.service.test.js +++ b/test/services/import/legacy/transform-addresses.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things to stub @@ -37,8 +37,7 @@ describe('Import Legacy Transform Addresses service', () => { }) it('attaches the record transformed and validated for WRLS to the transformed company', async () => { - await TransformAddressesService - .go(regionCode, naldLicenceId, transformedCompanies) + await TransformAddressesService.go(regionCode, naldLicenceId, transformedCompanies) expect(transformedCompanies[0]).to.equal({ addresses: [ @@ -76,7 +75,7 @@ describe('Import Legacy Transform Addresses service', () => { }) }) -function _legacyAddress () { +function _legacyAddress() { return { address1: '4 Privet Drive', address2: null, diff --git a/test/services/import/legacy/transform-companies.service.test.js b/test/services/import/legacy/transform-companies.service.test.js index 1610712510..3a74da9663 100644 --- a/test/services/import/legacy/transform-companies.service.test.js +++ b/test/services/import/legacy/transform-companies.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things to stub @@ -55,7 +55,6 @@ describe('Import Legacy Transform Companies service', () => { type: 'organisation', addresses: [], companyAddresses: [] - } ] }) @@ -81,7 +80,7 @@ describe('Import Legacy Transform Companies service', () => { }) }) -function _legacyCompany () { +function _legacyCompany() { return { name: 'ACME', type: 'organisation', diff --git a/test/services/import/legacy/transform-company-addresses.service.test.js b/test/services/import/legacy/transform-company-addresses.service.test.js index d2e99dec68..1e2b04fea6 100644 --- a/test/services/import/legacy/transform-company-addresses.service.test.js +++ b/test/services/import/legacy/transform-company-addresses.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -41,8 +41,7 @@ describe('Import Legacy Transform Company Addresses service', () => { }) it('attaches the record transformed and validated for WRLS to the transformed company', async () => { - await TransformCompanyAddressesService - .go(regionCode, naldLicenceId, transformedCompanies) + await TransformCompanyAddressesService.go(regionCode, naldLicenceId, transformedCompanies) expect(transformedCompanies[0]).to.equal({ companyAddresses: [ @@ -72,7 +71,7 @@ describe('Import Legacy Transform Company Addresses service', () => { }) }) -function _legacyLicenceHolderCompanyAddress (licenceRoleId) { +function _legacyLicenceHolderCompanyAddress(licenceRoleId) { return { company_external_id: '1:007', external_id: '7:777', diff --git a/test/services/import/legacy/transform-contacts.service.test.js b/test/services/import/legacy/transform-contacts.service.test.js index 650a74ba16..dd70444bd5 100644 --- a/test/services/import/legacy/transform-contacts.service.test.js +++ b/test/services/import/legacy/transform-contacts.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -75,7 +75,7 @@ describe('Import Legacy Transform Contact service', () => { }) }) -function _legacyContact (licenceRoleId) { +function _legacyContact(licenceRoleId) { return { external_id: '1:007', first_name: 'James', diff --git a/test/services/import/legacy/transform-licence-document-role.service.test.js b/test/services/import/legacy/transform-licence-document-role.service.test.js index 888ef2b434..1c0ee57858 100644 --- a/test/services/import/legacy/transform-licence-document-role.service.test.js +++ b/test/services/import/legacy/transform-licence-document-role.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -16,8 +16,7 @@ const FetchLicenceDocumentRolesService = require('../../../../app/services/impor const { generateUUID } = require('../../../../app/lib/general.lib.js') // Thing under test -const TransformLicenceDocumentRolesService = - require('../../../../app/services/import/legacy/transform-licence-document-roles.service.js') +const TransformLicenceDocumentRolesService = require('../../../../app/services/import/legacy/transform-licence-document-roles.service.js') describe('Import Legacy Transform Licence Document Role service', () => { // NOTE: Clearly this is an incomplete representation of the licence returned from TransformedLicenceService. But for @@ -70,13 +69,14 @@ describe('Import Legacy Transform Licence Document Role service', () => { }) it('throws an error', async () => { - await expect(TransformLicenceDocumentRolesService.go(regionCode, naldLicenceId, transformedLicence, licenceRef)) - .to.reject() + await expect( + TransformLicenceDocumentRolesService.go(regionCode, naldLicenceId, transformedLicence, licenceRef) + ).to.reject() }) }) }) -function _legacyLicenceDocumentRole (licenceRoleId) { +function _legacyLicenceDocumentRole(licenceRoleId) { return { address_id: '1:007', company_id: '1:007', diff --git a/test/services/import/legacy/transform-licence-document.service.test.js b/test/services/import/legacy/transform-licence-document.service.test.js index 8c71484572..0043474b10 100644 --- a/test/services/import/legacy/transform-licence-document.service.test.js +++ b/test/services/import/legacy/transform-licence-document.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -15,8 +15,7 @@ const { generateLicenceRef } = require('../../../support/helpers/licence.helper. const FetchLicenceDocumentService = require('../../../../app/services/import/legacy/fetch-licence-document.service.js') // Thing under test -const TransformLicenceDocumentService = - require('../../../../app/services/import/legacy/transform-licence-document.service.js') +const TransformLicenceDocumentService = require('../../../../app/services/import/legacy/transform-licence-document.service.js') describe('Import Legacy Transform Licence Document service', () => { // NOTE: Clearly this is an incomplete representation of the licence returned from TransformedLicenceService. But for @@ -67,7 +66,7 @@ describe('Import Legacy Transform Licence Document service', () => { }) }) -function _legacyLicenceDocument (licenceRef) { +function _legacyLicenceDocument(licenceRef) { return { end_date: null, start_date: new Date('1999-01-01'), diff --git a/test/services/import/legacy/transform-licence-version-purpose-conditions.service.test.js b/test/services/import/legacy/transform-licence-version-purpose-conditions.service.test.js index 2fed5d16df..8324397a8a 100644 --- a/test/services/import/legacy/transform-licence-version-purpose-conditions.service.test.js +++ b/test/services/import/legacy/transform-licence-version-purpose-conditions.service.test.js @@ -5,16 +5,14 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things to stub -const FetchLicenceVersionPurposeConditionsService = - require('../../../../app/services/import/legacy/fetch-licence-version-purpose-conditions.service.js') +const FetchLicenceVersionPurposeConditionsService = require('../../../../app/services/import/legacy/fetch-licence-version-purpose-conditions.service.js') // Thing under test -const TransformLicenceVersionPurposeConditionsService = - require('../../../../app/services/import/legacy/transform-licence-version-purpose-conditions.service.js') +const TransformLicenceVersionPurposeConditionsService = require('../../../../app/services/import/legacy/transform-licence-version-purpose-conditions.service.js') describe('Import Legacy Transform Licence Version Purpose conditions service', () => { // NOTE: Clearly this is an incomplete representation of the licence returned from TransformedLicenceService. But for @@ -29,10 +27,12 @@ describe('Import Legacy Transform Licence Version Purpose conditions service', ( beforeEach(() => { transformedLicence = { - licenceVersions: [{ - externalId: '6:2113:100:0', - licenceVersionPurposes: [_legacyLicenceVersionPurpose()] - }] + licenceVersions: [ + { + externalId: '6:2113:100:0', + licenceVersionPurposes: [_legacyLicenceVersionPurpose()] + } + ] } legacyLicenceVersionPurposeConditions = _legacyLicenceVersionPurposeCondition() @@ -50,16 +50,15 @@ describe('Import Legacy Transform Licence Version Purpose conditions service', ( it('attaches the record transformed and validated for WRLS to the transformed licence', async () => { await TransformLicenceVersionPurposeConditionsService.go(regionCode, naldLicenceId, transformedLicence) - expect(transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions) - .to.equal([ - { - externalId: '172640:6:10000004', - licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', - notes: 'At each abstraction borehole', - param1: null, - param2: null - } - ]) + expect(transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions).to.equal([ + { + externalId: '172640:6:10000004', + licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', + notes: 'At each abstraction borehole', + param1: null, + param2: null + } + ]) }) }) @@ -67,37 +66,39 @@ describe('Import Legacy Transform Licence Version Purpose conditions service', ( const externalId = '1:1' beforeEach(() => { - transformedLicence.licenceVersions[0].licenceVersionPurposes - .push({ ..._legacyLicenceVersionPurpose(), externalId }) + transformedLicence.licenceVersions[0].licenceVersionPurposes.push({ + ..._legacyLicenceVersionPurpose(), + externalId + }) - Sinon.stub(FetchLicenceVersionPurposeConditionsService, 'go').resolves([legacyLicenceVersionPurposeConditions, - { ...legacyLicenceVersionPurposeConditions, purpose_external_id: externalId }]) + Sinon.stub(FetchLicenceVersionPurposeConditionsService, 'go').resolves([ + legacyLicenceVersionPurposeConditions, + { ...legacyLicenceVersionPurposeConditions, purpose_external_id: externalId } + ]) }) it('attaches the record transformed and validated for WRLS to the transformed licence', async () => { await TransformLicenceVersionPurposeConditionsService.go(regionCode, naldLicenceId, transformedLicence) - expect(transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions) - .to.equal([ - { - externalId: '172640:6:10000004', - licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', - notes: 'At each abstraction borehole', - param1: null, - param2: null - } - ]) - - expect(transformedLicence.licenceVersions[0].licenceVersionPurposes[1].licenceVersionPurposeConditions) - .to.equal([ - { - externalId: '172640:6:10000004', - licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', - notes: 'At each abstraction borehole', - param1: null, - param2: null - } - ]) + expect(transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions).to.equal([ + { + externalId: '172640:6:10000004', + licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', + notes: 'At each abstraction borehole', + param1: null, + param2: null + } + ]) + + expect(transformedLicence.licenceVersions[0].licenceVersionPurposes[1].licenceVersionPurposeConditions).to.equal([ + { + externalId: '172640:6:10000004', + licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', + notes: 'At each abstraction borehole', + param1: null, + param2: null + } + ]) }) }) @@ -110,25 +111,24 @@ describe('Import Legacy Transform Licence Version Purpose conditions service', ( licenceVersionPurposes: [{ ..._legacyLicenceVersionPurpose(), externalId }] }) - Sinon.stub(FetchLicenceVersionPurposeConditionsService, 'go').resolves([legacyLicenceVersionPurposeConditions, - { ...legacyLicenceVersionPurposeConditions, purpose_external_id: externalId }]) + Sinon.stub(FetchLicenceVersionPurposeConditionsService, 'go').resolves([ + legacyLicenceVersionPurposeConditions, + { ...legacyLicenceVersionPurposeConditions, purpose_external_id: externalId } + ]) }) it('attaches the record transformed and validated for WRLS to the transformed licence', async () => { await TransformLicenceVersionPurposeConditionsService.go(regionCode, naldLicenceId, transformedLicence) - expect(transformedLicence.licenceVersions[1].licenceVersionPurposes[0].licenceVersionPurposeConditions) - .to.equal( - [ - { - externalId: '172640:6:10000004', - licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', - notes: 'At each abstraction borehole', - param1: null, - param2: null - } - ] - ) + expect(transformedLicence.licenceVersions[1].licenceVersionPurposes[0].licenceVersionPurposeConditions).to.equal([ + { + externalId: '172640:6:10000004', + licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', + notes: 'At each abstraction borehole', + param1: null, + param2: null + } + ]) }) }) @@ -140,13 +140,14 @@ describe('Import Legacy Transform Licence Version Purpose conditions service', ( it('there are no licence version purpose conditions for a licence version purpose', async () => { await TransformLicenceVersionPurposeConditionsService.go(regionCode, naldLicenceId, transformedLicence) - expect(transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions) - .to.equal([]) + expect(transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions).to.equal( + [] + ) }) }) }) -function _legacyLicenceVersionPurposeCondition () { +function _legacyLicenceVersionPurposeCondition() { return { external_id: '172640:6:10000004', licence_version_purpose_condition_type_id: 'b10cc9d1-d46f-465d-a74a-26b2e567c699', @@ -157,7 +158,7 @@ function _legacyLicenceVersionPurposeCondition () { } } -function _legacyLicenceVersionPurpose () { +function _legacyLicenceVersionPurpose() { return { externalId: '6:10000004', licenceVersionPurposeConditions: [] diff --git a/test/services/import/legacy/transform-licence-version-purposes.service.test.js b/test/services/import/legacy/transform-licence-version-purposes.service.test.js index 43b06456b9..8289812335 100644 --- a/test/services/import/legacy/transform-licence-version-purposes.service.test.js +++ b/test/services/import/legacy/transform-licence-version-purposes.service.test.js @@ -5,26 +5,26 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things to stub -const FetchLicenceVersionPurposesService = - require('../../../../app/services/import/legacy/fetch-licence-version-purposes.service.js') +const FetchLicenceVersionPurposesService = require('../../../../app/services/import/legacy/fetch-licence-version-purposes.service.js') // Thing under test -const TransformLicenceVersionPurposesService = - require('../../../../app/services/import/legacy/transform-licence-version-purposes.service.js') +const TransformLicenceVersionPurposesService = require('../../../../app/services/import/legacy/transform-licence-version-purposes.service.js') describe('Import Legacy Transform Licence Version Purposes service', () => { // NOTE: Clearly this is an incomplete representation of the licence returned from TransformedLicenceService. But for // the purposes of this service it is all that is needed. The externalId is used to match the licence version to the // fetched purpose const transformedLicence = { - licenceVersions: [{ - externalId: '6:2113:100:0', - licenceVersionPurposes: [] - }] + licenceVersions: [ + { + externalId: '6:2113:100:0', + licenceVersionPurposes: [] + } + ] } const naldLicenceId = '2113' @@ -104,7 +104,7 @@ describe('Import Legacy Transform Licence Version Purposes service', () => { }) }) -function _legacyLicenceVersionPurpose () { +function _legacyLicenceVersionPurpose() { return { abstraction_period_end_day: 31, abstraction_period_end_month: 3, diff --git a/test/services/import/legacy/transform-licence-versions.service.test.js b/test/services/import/legacy/transform-licence-versions.service.test.js index a08d08ab9b..5da046758d 100644 --- a/test/services/import/legacy/transform-licence-versions.service.test.js +++ b/test/services/import/legacy/transform-licence-versions.service.test.js @@ -5,15 +5,14 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things to stub const FetchLicenceVersionsService = require('../../../../app/services/import/legacy/fetch-licence-versions.service.js') // Thing under test -const TransformLicenceVersionsService = - require('../../../../app/services/import/legacy/transform-licence-versions.service.js') +const TransformLicenceVersionsService = require('../../../../app/services/import/legacy/transform-licence-versions.service.js') describe('Import Legacy Transform Licence Versions service', () => { // NOTE: Clearly this is an incomplete representation of the licence returned from TransformedLicenceService. But for @@ -76,7 +75,7 @@ describe('Import Legacy Transform Licence Versions service', () => { }) }) -function _legacyLicenceVersion () { +function _legacyLicenceVersion() { return { effective_end_date: null, effective_start_date: new Date('1999-01-01'), diff --git a/test/services/import/legacy/transform-licence.service.test.js b/test/services/import/legacy/transform-licence.service.test.js index 781106ca32..a39b9dae06 100644 --- a/test/services/import/legacy/transform-licence.service.test.js +++ b/test/services/import/legacy/transform-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -83,7 +83,7 @@ describe('Import Legacy Transform Licence service', () => { }) }) -function _legacyLicence (licenceRef) { +function _legacyLicence(licenceRef) { return { historical_area_code: 'KAEA', environmental_improvement_unit_charge_code: 'SOOTH', diff --git a/test/services/import/persist-import.service.test.js b/test/services/import/persist-import.service.test.js index 6df431f3ed..b8d9f897fa 100644 --- a/test/services/import/persist-import.service.test.js +++ b/test/services/import/persist-import.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/import/persist/persist-company.service.test.js b/test/services/import/persist/persist-company.service.test.js index c06af81251..54c579234a 100644 --- a/test/services/import/persist/persist-company.service.test.js +++ b/test/services/import/persist/persist-company.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, afterEach, beforeEach } = exports.lab = Lab.script() +const { describe, it, afterEach, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -124,29 +124,33 @@ describe('Persist company service', () => { existingCompany = existing.company exisitngContact = existing.contact - transformedCompanies = [{ - ...existingCompany, - contact: exisitngContact, - companyContact: { - externalId: existingCompany.externalId, - startDate: companyContactStartDate, - licenceRoleId: licenceHolderRoleId - }, - addresses: [{ - address1: 'ENVIRONMENT AGENCY', - externalId: addressExternalId, - dataSource: 'nald' - }], - companyAddresses: [ - { - addressId: addressExternalId, - companyId: existingCompany.externalId, - startDate: new Date('2020-03-03'), - endDate: new Date('2022-02-02'), + transformedCompanies = [ + { + ...existingCompany, + contact: exisitngContact, + companyContact: { + externalId: existingCompany.externalId, + startDate: companyContactStartDate, licenceRoleId: licenceHolderRoleId - } - ] - }] + }, + addresses: [ + { + address1: 'ENVIRONMENT AGENCY', + externalId: addressExternalId, + dataSource: 'nald' + } + ], + companyAddresses: [ + { + addressId: addressExternalId, + companyId: existingCompany.externalId, + startDate: new Date('2020-03-03'), + endDate: new Date('2022-02-02'), + licenceRoleId: licenceHolderRoleId + } + ] + } + ] }) it('should return the updated company', async () => { @@ -199,29 +203,19 @@ describe('Persist company service', () => { }) }) -async function _fetchPersistedAddress (externalId) { +async function _fetchPersistedAddress(externalId) { return AddressModel.query().where('externalId', externalId).limit(1).first().withGraphFetched('companyAddresses') } -async function _fetchPersistedCompany (externalId) { - return CompanyModel - .query() - .where('externalId', externalId) - .withGraphFetched('companyContacts') - .limit(1) - .first() +async function _fetchPersistedCompany(externalId) { + return CompanyModel.query().where('externalId', externalId).withGraphFetched('companyContacts').limit(1).first() } -async function _fetchPersistedContact (externalId) { - return ContactModel - .query() - .where('externalId', externalId) - .withGraphFetched('companyContacts') - .limit(1) - .first() +async function _fetchPersistedContact(externalId) { + return ContactModel.query().where('externalId', externalId).withGraphFetched('companyContacts').limit(1).first() } -function _transformedCompany (licenceHolderRoleId, addressExternalId) { +function _transformedCompany(licenceHolderRoleId, addressExternalId) { const externalId = CompanyHelper.generateExternalId() return { @@ -267,7 +261,7 @@ function _transformedCompany (licenceHolderRoleId, addressExternalId) { } } -async function _createExistingRecords (transformedCompany, licenceHolderRoleId, companyContactStartDate) { +async function _createExistingRecords(transformedCompany, licenceHolderRoleId, companyContactStartDate) { const address = await AddressHelper.add({ ...transformedCompany.addresses[0] }) diff --git a/test/services/import/persist/persist-licence-document.service.test.js b/test/services/import/persist/persist-licence-document.service.test.js index cc4afedc0f..8d06430b99 100644 --- a/test/services/import/persist/persist-licence-document.service.test.js +++ b/test/services/import/persist/persist-licence-document.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, afterEach, beforeEach } = exports.lab = Lab.script() +const { describe, it, afterEach, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -70,7 +70,12 @@ describe('Persist licence document service', () => { licenceRef = generateLicenceRef() licenceDocumentRole = _transformedLicenceDocumentRole( - licenceRef, licenceRoleId, company.externalId, address.externalId, contact.externalId) + licenceRef, + licenceRoleId, + company.externalId, + address.externalId, + contact.externalId + ) licenceDocument = _transformedLicenceDocument(licenceRef) @@ -104,10 +109,14 @@ describe('Persist licence document service', () => { licenceRef = generateLicenceRef() licenceDocumentRole = _transformedLicenceDocumentRole( - licenceRef, licenceRoleId, company.externalId, address.externalId, contact.externalId) + licenceRef, + licenceRoleId, + company.externalId, + address.externalId, + contact.externalId + ) - await _createExistingRecords( - licenceRef, licenceRoleId, company, address, contact) + await _createExistingRecords(licenceRef, licenceRoleId, company, address, contact) transformedLicence.licenceDocument = { ..._transformedLicenceDocument(licenceRef), @@ -124,8 +133,9 @@ describe('Persist licence document service', () => { await trx.commit() // Get the persisted data - const updatedLicenceDocument = await - _fetchPersistedLicenceDocument(transformedLicence.licenceDocument.licenceRef) + const updatedLicenceDocument = await _fetchPersistedLicenceDocument( + transformedLicence.licenceDocument.licenceRef + ) // Check the updated licence expect(updatedLicenceDocument.licenceRef).to.equal(transformedLicence.licenceDocument.licenceRef) @@ -144,9 +154,8 @@ describe('Persist licence document service', () => { }) }) -async function _fetchPersistedLicenceDocument (licenceRef) { - return LicenceDocumentModel - .query() +async function _fetchPersistedLicenceDocument(licenceRef) { + return LicenceDocumentModel.query() .where('licenceRef', licenceRef) .withGraphFetched('licenceDocumentRoles') .select('*') @@ -154,7 +163,7 @@ async function _fetchPersistedLicenceDocument (licenceRef) { .first() } -function _transformedLicenceDocument (licenceRef) { +function _transformedLicenceDocument(licenceRef) { return { licenceRef, startDate: new Date('1992-08-19'), @@ -162,7 +171,7 @@ function _transformedLicenceDocument (licenceRef) { } } -function _transformedLicenceDocumentRole (licenceRef, licenceRoleId, companyId, addressId, contactId) { +function _transformedLicenceDocumentRole(licenceRef, licenceRoleId, companyId, addressId, contactId) { return { addressId, companyId, @@ -174,7 +183,7 @@ function _transformedLicenceDocumentRole (licenceRef, licenceRoleId, companyId, } } -async function _createExistingRecords (licenceRef, licenceRoleId, company, address, contact) { +async function _createExistingRecords(licenceRef, licenceRoleId, company, address, contact) { const licenceDocument = await LicenceDocumentHelper.add({ licenceRef, endDate: new Date('2001-01-01') diff --git a/test/services/import/persist/persist-licence-versions.service.test.js b/test/services/import/persist/persist-licence-versions.service.test.js index 28012e7e2e..4282c4b222 100644 --- a/test/services/import/persist/persist-licence-versions.service.test.js +++ b/test/services/import/persist/persist-licence-versions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, afterEach, beforeEach } = exports.lab = Lab.script() +const { describe, it, afterEach, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -58,8 +58,13 @@ describe('Persist licence versions service', () => { let transformedLicence beforeEach(async () => { - transformedLicence = _transformedLicence(region.id, primaryPurpose.id, purpose.id, secondaryPurpose.id, - licenceVersionPurposeConditionType.id) + transformedLicence = _transformedLicence( + region.id, + primaryPurpose.id, + purpose.id, + secondaryPurpose.id, + licenceVersionPurposeConditionType.id + ) // Licence const licence = await LicenceHelper.add({ @@ -102,12 +107,12 @@ describe('Persist licence versions service', () => { ) // Licence Version Purpose Condition - const newLicenceVersionPurposeCondition = newLicence.licenceVersions[0] - .licenceVersionPurposes[0].licenceVersionPurposeConditions[0] + const newLicenceVersionPurposeCondition = + newLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions[0] expect(newLicenceVersionPurposeCondition.externalId).to.equal( - transformedLicence.licenceVersions[0].licenceVersionPurposes[0] - .licenceVersionPurposeConditions[0].externalId) + transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions[0].externalId + ) }) }) @@ -120,8 +125,13 @@ describe('Persist licence versions service', () => { let updatedLicence beforeEach(async () => { - transformedLicence = _transformedLicence(region.id, primaryPurpose.id, purpose.id, secondaryPurpose.id, - licenceVersionPurposeConditionType.id) + transformedLicence = _transformedLicence( + region.id, + primaryPurpose.id, + purpose.id, + secondaryPurpose.id, + licenceVersionPurposeConditionType.id + ) const existing = await _createExistingRecords(transformedLicence) @@ -158,8 +168,7 @@ describe('Persist licence versions service', () => { expect(updatedLicVerPur.abstractionPeriodEndDay).to.equal(transformedLicVerPur.abstractionPeriodEndDay) expect(updatedLicVerPur.abstractionPeriodEndMonth).to.equal(transformedLicVerPur.abstractionPeriodEndMonth) expect(updatedLicVerPur.abstractionPeriodStartDay).to.equal(transformedLicVerPur.abstractionPeriodStartDay) - expect(updatedLicVerPur.abstractionPeriodStartMonth).to - .equal(transformedLicVerPur.abstractionPeriodStartMonth) + expect(updatedLicVerPur.abstractionPeriodStartMonth).to.equal(transformedLicVerPur.abstractionPeriodStartMonth) expect(updatedLicVerPur.annualQuantity).to.equal(transformedLicVerPur.annualQuantity) expect(updatedLicVerPur.dailyQuantity).to.equal(transformedLicVerPur.dailyQuantity) expect(updatedLicVerPur.hourlyQuantity).to.equal(transformedLicVerPur.hourlyQuantity) @@ -172,15 +181,16 @@ describe('Persist licence versions service', () => { expect(updatedLicVerPur.timeLimitedStartDate).to.equal(transformedLicVerPur.timeLimitedStartDate) // Licence Version Purpose Conditions - const updatedLicVerPurCon = updatedLicence.licenceVersions[0] - .licenceVersionPurposes[0].licenceVersionPurposeConditions[0] - const transformedLicVerPurCon = transformedLicence.licenceVersions[0] - .licenceVersionPurposes[0].licenceVersionPurposeConditions[0] + const updatedLicVerPurCon = + updatedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions[0] + const transformedLicVerPurCon = + transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions[0] expect(updatedLicVerPurCon.id).to.equal(existingLicenceVersionPurposeCondition.id) expect(updatedLicVerPurCon.externalId).to.equal(transformedLicVerPurCon.externalId) - expect(updatedLicVerPurCon.licenceVersionPurposeConditionTypeId) - .to.equal(transformedLicVerPurCon.licenceVersionPurposeConditionTypeId) + expect(updatedLicVerPurCon.licenceVersionPurposeConditionTypeId).to.equal( + transformedLicVerPurCon.licenceVersionPurposeConditionTypeId + ) expect(updatedLicVerPurCon.notes).to.equal(transformedLicVerPurCon.notes) expect(updatedLicVerPurCon.param1).to.equal(transformedLicVerPurCon.param1) expect(updatedLicVerPurCon.param2).to.equal(transformedLicVerPurCon.param2) @@ -190,9 +200,8 @@ describe('Persist licence versions service', () => { }) }) -async function _fetchPersistedLicence (licenceRef) { - return LicenceModel - .query() +async function _fetchPersistedLicence(licenceRef) { + return LicenceModel.query() .where('licenceRef', licenceRef) .withGraphFetched('licenceVersions') .withGraphFetched('licenceVersions.licenceVersionPurposes') @@ -201,8 +210,13 @@ async function _fetchPersistedLicence (licenceRef) { .first() } -function _transformedLicence (regionId, primaryPurposeId, purposeId, secondaryPurposeId, - licenceVersionPurposeConditionTypeId) { +function _transformedLicence( + regionId, + primaryPurposeId, + purposeId, + secondaryPurposeId, + licenceVersionPurposeConditionTypeId +) { return { expiredDate: null, lapsedDate: null, @@ -259,7 +273,7 @@ function _transformedLicence (regionId, primaryPurposeId, purposeId, secondaryPu } } -async function _createExistingRecords (transformedLicence) { +async function _createExistingRecords(transformedLicence) { const licence = await LicenceHelper.add({ expiredDate: new Date('2052-06-23'), lapsedDate: new Date('2050-07-24'), @@ -305,8 +319,8 @@ async function _createExistingRecords (transformedLicence) { const licenceVersionPurposeCondition = await LicenceVersionPurposeConditionHelper.add({ licenceVersionPurposeId: licenceVersionPurpose.id, licenceVersionPurposeConditionTypeId: LicenceVersionPurposeConditionTypeHelper.select().id, - externalId: transformedLicence.licenceVersions[0].licenceVersionPurposes[0] - .licenceVersionPurposeConditions[0].externalId, + externalId: + transformedLicence.licenceVersions[0].licenceVersionPurposes[0].licenceVersionPurposeConditions[0].externalId, source: 'nald' }) diff --git a/test/services/import/persist/persist-licence.service.test.js b/test/services/import/persist/persist-licence.service.test.js index 44bb9c4dd3..f70d110e48 100644 --- a/test/services/import/persist/persist-licence.service.test.js +++ b/test/services/import/persist/persist-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, afterEach, beforeEach } = exports.lab = Lab.script() +const { describe, it, afterEach, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -91,16 +91,11 @@ describe('Persist licence service', () => { }) }) -async function _fetchPersistedLicence (licenceRef) { - return LicenceModel - .query() - .where('licenceRef', licenceRef) - .select('*') - .limit(1) - .first() +async function _fetchPersistedLicence(licenceRef) { + return LicenceModel.query().where('licenceRef', licenceRef).select('*').limit(1).first() } -function _transformedLicence (regionId) { +function _transformedLicence(regionId) { return { expiredDate: null, lapsedDate: null, @@ -119,7 +114,7 @@ function _transformedLicence (regionId) { } } -async function _createExistingRecords (region) { +async function _createExistingRecords(region) { const licence = await LicenceHelper.add({ expiredDate: new Date('2052-06-23'), lapsedDate: new Date('2050-07-24'), diff --git a/test/services/jobs/export/compress-schema-folder.service.test.js b/test/services/jobs/export/compress-schema-folder.service.test.js index 208e43e045..886e065a96 100644 --- a/test/services/jobs/export/compress-schema-folder.service.test.js +++ b/test/services/jobs/export/compress-schema-folder.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/jobs/export/convert-to-csv.service.test.js b/test/services/jobs/export/convert-to-csv.service.test.js index 8f61bd4047..52b0b1082a 100644 --- a/test/services/jobs/export/convert-to-csv.service.test.js +++ b/test/services/jobs/export/convert-to-csv.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -51,31 +51,33 @@ const billingChargeCategoriesColumnInfo = [ 'maxVolume' ] -const csvHeaders = '"billingChargeCategoryId",' + -'"reference",' + -'"subsistenceCharge",' + -'"description",' + -'"shortDescription",' + -'"dateCreated",' + -'"dateUpdated",' + -'"isTidal",' + -'"lossFactor",' + -'"modelTier",' + -'"isRestrictedSource",' + -'"minVolume",' + -'"maxVolume"\n' +const csvHeaders = + '"billingChargeCategoryId",' + + '"reference",' + + '"subsistenceCharge",' + + '"description",' + + '"shortDescription",' + + '"dateCreated",' + + '"dateUpdated",' + + '"isTidal",' + + '"lossFactor",' + + '"modelTier",' + + '"isRestrictedSource",' + + '"minVolume",' + + '"maxVolume"\n' -const csvValues = '"20146cdc-9b40-4769-aa78-b51c17080d56",' + -'"4.1.1",9700,' + -'"Low loss tidal abstraction of water up to and ""including"" 25,002 megalitres a year where no model applies",' + -'"Low loss, tidal, up to and including 25,002 ML/yr",' + -'2022-12-14T18:39:45.000Z,2022-12-14T18:39:45.000Z,' + -'true,' + -',' + -',' + -'false,' + -',' + -'25002\n' +const csvValues = + '"20146cdc-9b40-4769-aa78-b51c17080d56",' + + '"4.1.1",9700,' + + '"Low loss tidal abstraction of water up to and ""including"" 25,002 megalitres a year where no model applies",' + + '"Low loss, tidal, up to and including 25,002 ML/yr",' + + '2022-12-14T18:39:45.000Z,2022-12-14T18:39:45.000Z,' + + 'true,' + + ',' + + ',' + + 'false,' + + ',' + + '25002\n' describe('Convert to CSV service', () => { describe('when given a row of data to convert', () => { diff --git a/test/services/jobs/export/delete-files.service.test.js b/test/services/jobs/export/delete-files.service.test.js index afcf8aa755..14a015e606 100644 --- a/test/services/jobs/export/delete-files.service.test.js +++ b/test/services/jobs/export/delete-files.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -90,7 +90,7 @@ describe('Delete Files service', () => { await DeleteFilesService.go(noFile) - expect(notifierStub.omfg.calledWith(('Delete file service errored'))).to.be.true() + expect(notifierStub.omfg.calledWith('Delete file service errored')).to.be.true() }) }) }) diff --git a/test/services/jobs/export/export-table.service.test.js b/test/services/jobs/export/export-table.service.test.js index 9044fbfae7..bd5390d0f4 100644 --- a/test/services/jobs/export/export-table.service.test.js +++ b/test/services/jobs/export/export-table.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/jobs/export/export.service.test.js b/test/services/jobs/export/export.service.test.js index f1f895556c..f9cea24126 100644 --- a/test/services/jobs/export/export.service.test.js +++ b/test/services/jobs/export/export.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/jobs/export/fetch-table-names.service.test.js b/test/services/jobs/export/fetch-table-names.service.test.js index 4ef9e8dcee..0879618385 100644 --- a/test/services/jobs/export/fetch-table-names.service.test.js +++ b/test/services/jobs/export/fetch-table-names.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/jobs/export/fetch-table.service.test.js b/test/services/jobs/export/fetch-table.service.test.js index 14def32cff..442140da7d 100644 --- a/test/services/jobs/export/fetch-table.service.test.js +++ b/test/services/jobs/export/fetch-table.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/jobs/export/schema-export.service.test.js b/test/services/jobs/export/schema-export.service.test.js index 633e5a96bc..42e2986e11 100644 --- a/test/services/jobs/export/schema-export.service.test.js +++ b/test/services/jobs/export/schema-export.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -96,7 +96,7 @@ describe('Schema export service', () => { await SchemaExportService.go('water') - expect(notifierStub.omfg.calledWith(('Error: Failed to export schema water'))).to.be.true() + expect(notifierStub.omfg.calledWith('Error: Failed to export schema water')).to.be.true() expect(SendToS3BucketServiceStub.called).to.be.false() expect(CompressSchemaFolderServiceStub.called).to.be.false() }) diff --git a/test/services/jobs/export/send-to-s3-bucket.service.test.js b/test/services/jobs/export/send-to-s3-bucket.service.test.js index c1c7a24343..a8c05026c5 100644 --- a/test/services/jobs/export/send-to-s3-bucket.service.test.js +++ b/test/services/jobs/export/send-to-s3-bucket.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/jobs/export/write-table-to-file.service.test.js b/test/services/jobs/export/write-table-to-file.service.test.js index cf2337c09c..3d12c3614e 100644 --- a/test/services/jobs/export/write-table-to-file.service.test.js +++ b/test/services/jobs/export/write-table-to-file.service.test.js @@ -5,7 +5,7 @@ const Code = require('@hapi/code') const Lab = require('@hapi/lab') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -35,29 +35,31 @@ const headers = [ 'maxVolume' ] -const csvValues = '"b13a469a-aa38-48c8-b899-da7536b44e37",' + -'"4.1.1",' + -'9700,' + -'"Low loss tidal abstraction of water up to and including 25,002 megalitres a year where no model applies",' + -'"Low loss, tidal, up to and including 25,002 ML/yr",' + -'true,' + -'"low",' + -'"no model",' + -'false,' + -',' + -'25002\n' - -const csvHeaders = '"billingChargeCategoryId",' + -'"reference",' + -'"subsistenceCharge",' + -'"description",' + -'"shortDescription",' + -'"isTidal",' + -'"lossFactor",' + -'"modelTier",' + -'"isRestrictedSource",' + -'"minVolume",' + -'"maxVolume"\n' +const csvValues = + '"b13a469a-aa38-48c8-b899-da7536b44e37",' + + '"4.1.1",' + + '9700,' + + '"Low loss tidal abstraction of water up to and including 25,002 megalitres a year where no model applies",' + + '"Low loss, tidal, up to and including 25,002 ML/yr",' + + 'true,' + + '"low",' + + '"no model",' + + 'false,' + + ',' + + '25002\n' + +const csvHeaders = + '"billingChargeCategoryId",' + + '"reference",' + + '"subsistenceCharge",' + + '"description",' + + '"shortDescription",' + + '"isTidal",' + + '"lossFactor",' + + '"modelTier",' + + '"isRestrictedSource",' + + '"minVolume",' + + '"maxVolume"\n' describe('Write table to file service', () => { let filePath diff --git a/test/services/jobs/licence-updates/fetch-licence-updates.service.test.js b/test/services/jobs/licence-updates/fetch-licence-updates.service.test.js index e645efe358..b92c1d3de6 100644 --- a/test/services/jobs/licence-updates/fetch-licence-updates.service.test.js +++ b/test/services/jobs/licence-updates/fetch-licence-updates.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -35,7 +35,9 @@ describe('Fetch Licence Updates service', () => { it('returns the expected result', async () => { const results = await FetchLicenceUpdatesService.go() - const result = results.find((l) => { return l.id === licenceVersion.id }) + const result = results.find((l) => { + return l.id === licenceVersion.id + }) expect(result.id).to.be.equal(licenceVersion.id) expect(result.licenceId).to.be.equal(licence.id) @@ -51,7 +53,9 @@ describe('Fetch Licence Updates service', () => { it('returns the expected result', async () => { const results = await FetchLicenceUpdatesService.go() - const result = results.find((l) => { return l.id === licenceVersion.id }) + const result = results.find((l) => { + return l.id === licenceVersion.id + }) expect(result.id).to.be.equal(licenceVersion.id) expect(result.licenceId).to.be.equal(licence.id) @@ -69,7 +73,9 @@ describe('Fetch Licence Updates service', () => { it('returns no results', async () => { const data = await FetchLicenceUpdatesService.go() - const results = data.filter((l) => { return l.licenceId === licence.id }) + const results = data.filter((l) => { + return l.licenceId === licence.id + }) expect(results).to.be.empty() }) @@ -84,7 +90,9 @@ describe('Fetch Licence Updates service', () => { it('returns no results', async () => { const data = await FetchLicenceUpdatesService.go() - const results = data.filter((l) => { return l.licenceId === licence.id }) + const results = data.filter((l) => { + return l.licenceId === licence.id + }) expect(results).to.be.empty() }) @@ -95,7 +103,9 @@ describe('Fetch Licence Updates service', () => { licenceVersion = await LicenceVersionHelper.add({ licenceId: licence.id }) const chargeVersion = await ChargeVersionHelper.add({ - licenceId: licence.id, licenceRef: licence.licenceRef, scheme: 'alcs' + licenceId: licence.id, + licenceRef: licence.licenceRef, + scheme: 'alcs' }) const billRun = await BillRunHelper.add({ scheme: 'alcs' }) @@ -105,7 +115,9 @@ describe('Fetch Licence Updates service', () => { it('returns no results', async () => { const data = await FetchLicenceUpdatesService.go() - const results = data.filter((l) => { return l.licenceId === licence.id }) + const results = data.filter((l) => { + return l.licenceId === licence.id + }) expect(results).to.be.empty() }) @@ -119,7 +131,9 @@ describe('Fetch Licence Updates service', () => { it('returns no results', async () => { const data = await FetchLicenceUpdatesService.go() - const results = data.filter((l) => { return l.licenceId === licence.id }) + const results = data.filter((l) => { + return l.licenceId === licence.id + }) expect(results).to.be.empty() }) @@ -127,7 +141,7 @@ describe('Fetch Licence Updates service', () => { }) }) -function _threeMonthsAgo () { +function _threeMonthsAgo() { const today = new Date() today.setMonth(today.getMonth() - 3) diff --git a/test/services/jobs/licence-updates/process-licence-updates.service.test.js b/test/services/jobs/licence-updates/process-licence-updates.service.test.js index 5e4fdccaa9..5591b13b01 100644 --- a/test/services/jobs/licence-updates/process-licence-updates.service.test.js +++ b/test/services/jobs/licence-updates/process-licence-updates.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -77,9 +77,7 @@ describe('Process Licence Updates service', () => { const logDataArg = notifierStub.omg.firstCall.args[1] - expect( - notifierStub.omg.calledWith('Licence updates job complete') - ).to.be.true() + expect(notifierStub.omg.calledWith('Licence updates job complete')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.count).to.exist() @@ -108,9 +106,7 @@ describe('Process Licence Updates service', () => { const logDataArg = notifierStub.omg.firstCall.args[1] - expect( - notifierStub.omg.calledWith('Licence updates job complete') - ).to.be.true() + expect(notifierStub.omg.calledWith('Licence updates job complete')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.count).to.exist() diff --git a/test/services/jobs/return-logs/fetch-licence-return-requirements.service.test.js b/test/services/jobs/return-logs/fetch-licence-return-requirements.service.test.js index b0b1ced730..ac3117b164 100644 --- a/test/services/jobs/return-logs/fetch-licence-return-requirements.service.test.js +++ b/test/services/jobs/return-logs/fetch-licence-return-requirements.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -99,21 +99,24 @@ describe('Fetch licence return requirements service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal( + secondaryPurpose.description + ) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) }) @@ -191,21 +194,24 @@ describe('Fetch licence return requirements service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal( + secondaryPurpose.description + ) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) expect(result[1].id).to.equal(returnRequirement2.id) @@ -239,21 +245,24 @@ describe('Fetch licence return requirements service', () => { expect(result[1].points[0].ngr3).to.equal(point2.ngr3) expect(result[1].points[0].ngr4).to.equal(point2.ngr4) expect(result[1].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose2.id) - expect(result[1].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose2.returnRequirementId) - expect(result[1].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose2.primaryPurposeId) - expect(result[1].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose2.secondaryPurposeId) + expect(result[1].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose2.returnRequirementId + ) + expect(result[1].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose2.primaryPurposeId + ) + expect(result[1].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose2.secondaryPurposeId + ) expect(result[1].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose2.purposeId) expect(result[1].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose2.alias) expect(result[1].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose2.externalId) expect(result[1].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose2.legacyId) - expect(result[1].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose2.description) + expect(result[1].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose2.description) expect(result[1].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose2.legacyId) - expect(result[1].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose2.description) + expect(result[1].returnRequirementPurposes[0].secondaryPurpose.description).to.equal( + secondaryPurpose2.description + ) expect(result[1].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose2.legacyId) expect(result[1].returnRequirementPurposes[0].purpose.description).to.equal(purpose2.description) }) diff --git a/test/services/jobs/return-logs/fetch-return-cycle.service.test.js b/test/services/jobs/return-logs/fetch-return-cycle.service.test.js index 5b377d8a67..bd154b3403 100644 --- a/test/services/jobs/return-logs/fetch-return-cycle.service.test.js +++ b/test/services/jobs/return-logs/fetch-return-cycle.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, afterEach } = exports.lab = Lab.script() +const { describe, it, before, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/jobs/return-logs/fetch-return-requirements.service.test.js b/test/services/jobs/return-logs/fetch-return-requirements.service.test.js index 0b755e6b7c..fd6da7d9c7 100644 --- a/test/services/jobs/return-logs/fetch-return-requirements.service.test.js +++ b/test/services/jobs/return-logs/fetch-return-requirements.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -110,21 +110,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) }) @@ -185,21 +186,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) }) @@ -273,21 +275,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) expect(result[1].id).to.equal(returnRequirement2.id) @@ -321,21 +324,24 @@ describe('Fetch return logs service', () => { expect(result[1].points[0].ngr3).to.equal(point2.ngr3) expect(result[1].points[0].ngr4).to.equal(point2.ngr4) expect(result[1].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose2.id) - expect(result[1].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose2.returnRequirementId) - expect(result[1].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose2.primaryPurposeId) - expect(result[1].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose2.secondaryPurposeId) + expect(result[1].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose2.returnRequirementId + ) + expect(result[1].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose2.primaryPurposeId + ) + expect(result[1].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose2.secondaryPurposeId + ) expect(result[1].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose2.purposeId) expect(result[1].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose2.alias) expect(result[1].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose2.externalId) expect(result[1].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose2.legacyId) - expect(result[1].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose2.description) + expect(result[1].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose2.description) expect(result[1].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose2.legacyId) - expect(result[1].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose2.description) + expect(result[1].returnRequirementPurposes[0].secondaryPurpose.description).to.equal( + secondaryPurpose2.description + ) expect(result[1].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose2.legacyId) expect(result[1].returnRequirementPurposes[0].purpose.description).to.equal(purpose2.description) }) @@ -409,21 +415,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) expect(result[1].id).to.equal(returnRequirement2.id) @@ -457,21 +464,24 @@ describe('Fetch return logs service', () => { expect(result[1].points[0].ngr3).to.equal(point2.ngr3) expect(result[1].points[0].ngr4).to.equal(point2.ngr4) expect(result[1].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose2.id) - expect(result[1].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose2.returnRequirementId) - expect(result[1].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose2.primaryPurposeId) - expect(result[1].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose2.secondaryPurposeId) + expect(result[1].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose2.returnRequirementId + ) + expect(result[1].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose2.primaryPurposeId + ) + expect(result[1].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose2.secondaryPurposeId + ) expect(result[1].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose2.purposeId) expect(result[1].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose2.alias) expect(result[1].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose2.externalId) expect(result[1].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose2.legacyId) - expect(result[1].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose2.description) + expect(result[1].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose2.description) expect(result[1].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose2.legacyId) - expect(result[1].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose2.description) + expect(result[1].returnRequirementPurposes[0].secondaryPurpose.description).to.equal( + secondaryPurpose2.description + ) expect(result[1].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose2.legacyId) expect(result[1].returnRequirementPurposes[0].purpose.description).to.equal(purpose2.description) }) @@ -533,21 +543,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) }) @@ -609,21 +620,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) }) @@ -685,21 +697,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) }) @@ -761,21 +774,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) }) @@ -836,21 +850,22 @@ describe('Fetch return logs service', () => { expect(result[0].points[0].ngr3).to.equal(point.ngr3) expect(result[0].points[0].ngr4).to.equal(point.ngr4) expect(result[0].returnRequirementPurposes[0].id).to.equal(returnRequirementPurpose.id) - expect(result[0].returnRequirementPurposes[0].returnRequirementId) - .to.equal(returnRequirementPurpose.returnRequirementId) - expect(result[0].returnRequirementPurposes[0] - .primaryPurposeId).to.equal(returnRequirementPurpose.primaryPurposeId) - expect(result[0].returnRequirementPurposes[0] - .secondaryPurposeId).to.equal(returnRequirementPurpose.secondaryPurposeId) + expect(result[0].returnRequirementPurposes[0].returnRequirementId).to.equal( + returnRequirementPurpose.returnRequirementId + ) + expect(result[0].returnRequirementPurposes[0].primaryPurposeId).to.equal( + returnRequirementPurpose.primaryPurposeId + ) + expect(result[0].returnRequirementPurposes[0].secondaryPurposeId).to.equal( + returnRequirementPurpose.secondaryPurposeId + ) expect(result[0].returnRequirementPurposes[0].purposeId).to.equal(returnRequirementPurpose.purposeId) expect(result[0].returnRequirementPurposes[0].alias).to.equal(returnRequirementPurpose.alias) expect(result[0].returnRequirementPurposes[0].externalId).to.equal(returnRequirementPurpose.externalId) expect(result[0].returnRequirementPurposes[0].primaryPurpose.legacyId).to.equal(primaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].primaryPurpose.description) - .to.equal(primaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].primaryPurpose.description).to.equal(primaryPurpose.description) expect(result[0].returnRequirementPurposes[0].secondaryPurpose.legacyId).to.equal(secondaryPurpose.legacyId) - expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description) - .to.equal(secondaryPurpose.description) + expect(result[0].returnRequirementPurposes[0].secondaryPurpose.description).to.equal(secondaryPurpose.description) expect(result[0].returnRequirementPurposes[0].purpose.legacyId).to.equal(purpose.legacyId) expect(result[0].returnRequirementPurposes[0].purpose.description).to.equal(purpose.description) }) @@ -864,7 +879,11 @@ describe('Fetch return logs service', () => { return returnLog.legacyId }) - expect(allYearReturns.every((result) => { return returnRequirementExternalId.includes(result) })).to.equal(true) + expect( + allYearReturns.every((result) => { + return returnRequirementExternalId.includes(result) + }) + ).to.equal(true) }) }) @@ -876,7 +895,11 @@ describe('Fetch return logs service', () => { return returnLog.legacyId }) - expect(summerReturns.every((result) => { return returnRequirementExternalId.includes(result) })).to.equal(true) + expect( + summerReturns.every((result) => { + return returnRequirementExternalId.includes(result) + }) + ).to.equal(true) }) }) }) diff --git a/test/services/jobs/return-logs/generate-return-cycle.service.test.js b/test/services/jobs/return-logs/generate-return-cycle.service.test.js index 6f7973632d..fa63e24fa5 100644 --- a/test/services/jobs/return-logs/generate-return-cycle.service.test.js +++ b/test/services/jobs/return-logs/generate-return-cycle.service.test.js @@ -4,11 +4,15 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Test Helpers -const { cycleDueDateAsISO, cycleEndDateAsISO, cycleStartDateAsISO } = require('../../../../app/lib/return-cycle-dates.lib.js') +const { + cycleDueDateAsISO, + cycleEndDateAsISO, + cycleStartDateAsISO +} = require('../../../../app/lib/return-cycle-dates.lib.js') const ReturnCycleModel = require('../../../../app/models/return-cycle.model.js') // Thing under test diff --git a/test/services/jobs/return-logs/generate-return-logs.service.test.js b/test/services/jobs/return-logs/generate-return-logs.service.test.js index 494af9f9d5..f42a291ef9 100644 --- a/test/services/jobs/return-logs/generate-return-logs.service.test.js +++ b/test/services/jobs/return-logs/generate-return-logs.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, after } = exports.lab = Lab.script() +const { describe, it, before, after } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -90,8 +90,10 @@ describe('Generate return logs service', () => { describe('when return cycle exists', () => { before(async () => { Sinon.stub(FetchReturnCycleService, 'go') - .withArgs(todayAsIso, false).returns(allYearReturnCycleId) - .withArgs(todayAsIso, true).returns(summerReturnCycleId) + .withArgs(todayAsIso, false) + .returns(allYearReturnCycleId) + .withArgs(todayAsIso, true) + .returns(summerReturnCycleId) }) describe('when summer is false', () => { @@ -129,7 +131,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(allYearDueDate) expect(result[0].endDate).to.equal(allYearEndDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -147,27 +151,31 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 } - }], + ], + purposes: [ + { + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } + } + ], version: 1 }) expect(result[0].returnCycleId).to.equal(allYearReturnCycleId) @@ -220,7 +228,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(2) expect(result[0].dueDate).to.equal(allYearDueDate) expect(result[0].endDate).to.equal(allYearEndDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -238,28 +248,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 } - }], + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } + } + ], version: 1 }) expect(result[0].returnCycleId).to.equal(allYearReturnCycleId) @@ -269,7 +283,9 @@ describe('Generate return logs service', () => { expect(result[0].source).to.equal('WRLS') expect(result[1].dueDate).to.equal(allYearDueDate) expect(result[1].endDate).to.equal(allYearEndDate) - expect(result[1].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement2.legacyId}:${allYearStartDate}:${allYearEndDate}`) + expect(result[1].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement2.legacyId}:${allYearStartDate}:${allYearEndDate}` + ) expect(result[1].licenceRef).to.equal(licence.licenceRef) expect(result[1].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -287,28 +303,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement2.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement2.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point2.description, - ngr1: point2.ngr1, - ngr2: point2.ngr2, - ngr3: point2.ngr3, - ngr4: point2.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose2.alias, - primary: { - code: primaryPurpose2.legacyId, - description: primaryPurpose2.description - }, - secondary: { - code: secondaryPurpose2.legacyId, - description: secondaryPurpose2.description - }, - tertiary: { - code: purpose2.legacyId, - description: purpose2.description + points: [ + { + name: point2.description, + ngr1: point2.ngr1, + ngr2: point2.ngr2, + ngr3: point2.ngr3, + ngr4: point2.ngr4 } - }], + ], + purposes: [ + { + alias: returnRequirementPurpose2.alias, + primary: { + code: primaryPurpose2.legacyId, + description: primaryPurpose2.description + }, + secondary: { + code: secondaryPurpose2.legacyId, + description: secondaryPurpose2.description + }, + tertiary: { + code: purpose2.legacyId, + description: purpose2.description + } + } + ], version: 1 }) expect(result[1].returnCycleId).to.equal(allYearReturnCycleId) @@ -349,7 +369,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(allYearDueDate) expect(result[0].endDate).to.equal(expiredDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${expiredDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${expiredDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -367,28 +389,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 } - }], + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } + } + ], version: 1 }) expect(result[0].returnCycleId).to.equal(allYearReturnCycleId) @@ -429,7 +455,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(allYearDueDate) expect(result[0].endDate).to.equal(allYearEndDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -447,28 +475,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 } - }], + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } + } + ], version: 1 }) expect(result[0].returnCycleId).to.equal(allYearReturnCycleId) @@ -488,9 +520,11 @@ describe('Generate return logs service', () => { return returnLog.returnReference }) - expect(allYearReturns.every((result) => { - return returnRequirementExternalId.includes(result) - })).to.equal(true) + expect( + allYearReturns.every((result) => { + return returnRequirementExternalId.includes(result) + }) + ).to.equal(true) }) }) }) @@ -529,7 +563,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(summerDueDate) expect(result[0].endDate).to.equal(summerEndDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${summerEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${summerEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -547,28 +583,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 } - }], + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } + } + ], version: 1 }) expect(result[0].returnCycleId).to.equal(summerReturnCycleId) @@ -622,7 +662,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(2) expect(result[0].dueDate).to.equal(summerDueDate) expect(result[0].endDate).to.equal(summerEndDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${summerEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${summerEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -640,28 +682,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 + } + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } } - }], + ], version: 1 }) expect(result[0].returnCycleId).to.equal(summerReturnCycleId) @@ -671,7 +717,9 @@ describe('Generate return logs service', () => { expect(result[0].source).to.equal('WRLS') expect(result[1].dueDate).to.equal(summerDueDate) expect(result[1].endDate).to.equal(summerEndDate) - expect(result[1].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement2.legacyId}:${summerStartDate}:${summerEndDate}`) + expect(result[1].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement2.legacyId}:${summerStartDate}:${summerEndDate}` + ) expect(result[1].licenceRef).to.equal(licence.licenceRef) expect(result[1].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -689,28 +737,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement2.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement2.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point2.description, - ngr1: point2.ngr1, - ngr2: point2.ngr2, - ngr3: point2.ngr3, - ngr4: point2.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose2.alias, - primary: { - code: primaryPurpose2.legacyId, - description: primaryPurpose2.description - }, - secondary: { - code: secondaryPurpose2.legacyId, - description: secondaryPurpose2.description - }, - tertiary: { - code: purpose2.legacyId, - description: purpose2.description + points: [ + { + name: point2.description, + ngr1: point2.ngr1, + ngr2: point2.ngr2, + ngr3: point2.ngr3, + ngr4: point2.ngr4 + } + ], + purposes: [ + { + alias: returnRequirementPurpose2.alias, + primary: { + code: primaryPurpose2.legacyId, + description: primaryPurpose2.description + }, + secondary: { + code: secondaryPurpose2.legacyId, + description: secondaryPurpose2.description + }, + tertiary: { + code: purpose2.legacyId, + description: purpose2.description + } } - }], + ], version: 1 }) expect(result[1].returnCycleId).to.equal(summerReturnCycleId) @@ -750,7 +802,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(summerDueDate) expect(result[0].endDate).to.equal(lapsedDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${lapsedDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${lapsedDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -768,28 +822,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 + } + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } } - }], + ], version: 1 }) expect(result[0].returnCycleId).to.equal(summerReturnCycleId) @@ -830,7 +888,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(summerDueDate) expect(result[0].endDate).to.equal(summerEndDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${summerEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${summerEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -848,28 +908,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 + } + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } } - }], + ], version: 1 }) expect(result[0].returnCycleId).to.equal(summerReturnCycleId) @@ -909,7 +973,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(summerDueDate) expect(result[0].endDate).to.equal(summerEndDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${startDate}:${summerEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${startDate}:${summerEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -927,28 +993,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 + } + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } } - }], + ], version: 1 }) expect(result[0].returnCycleId).to.equal(summerReturnCycleId) @@ -968,9 +1038,11 @@ describe('Generate return logs service', () => { return returnLog.returnReference }) - expect(summerReturns.every((result) => { - return returnRequirementExternalId.includes(result) - })).to.equal(true) + expect( + summerReturns.every((result) => { + return returnRequirementExternalId.includes(result) + }) + ).to.equal(true) }) }) }) @@ -983,11 +1055,15 @@ describe('Generate return logs service', () => { describe('when return cycle does not exist', () => { before(async () => { Sinon.stub(FetchReturnCycleService, 'go') - .withArgs(todayAsIso, false).returns(undefined) - .withArgs(todayAsIso, true).returns(undefined) + .withArgs(todayAsIso, false) + .returns(undefined) + .withArgs(todayAsIso, true) + .returns(undefined) Sinon.stub(GenerateReturnCycleService, 'go') - .withArgs(false).returns(allYearReturnCycleId) - .withArgs(true).returns(summerReturnCycleId) + .withArgs(false) + .returns(allYearReturnCycleId) + .withArgs(true) + .returns(summerReturnCycleId) }) describe('has one return requirement and a licenceRef provided', () => { @@ -1019,7 +1095,9 @@ describe('Generate return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(summerDueDate) expect(result[0].endDate).to.equal(summerEndDate) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${summerEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${summerStartDate}:${summerEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].metadata).to.equal({ description: 'BOREHOLE AT AVALON', @@ -1037,28 +1115,32 @@ describe('Generate return logs service', () => { periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - alias: returnRequirementPurpose.alias, - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description - }, - tertiary: { - code: purpose.legacyId, - description: purpose.description + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 + } + ], + purposes: [ + { + alias: returnRequirementPurpose.alias, + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } } - }], + ], version: 1 }) expect(result[0].returnCycleId).to.equal(summerReturnCycleId) diff --git a/test/services/jobs/return-logs/process-licence-return-logs.service.test.js b/test/services/jobs/return-logs/process-licence-return-logs.service.test.js index c8e37e36db..3f8f52f5b1 100644 --- a/test/services/jobs/return-logs/process-licence-return-logs.service.test.js +++ b/test/services/jobs/return-logs/process-licence-return-logs.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, after } = exports.lab = Lab.script() +const { describe, it, before, after } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -65,59 +65,65 @@ describe('Process licence return logs service', () => { // As we're not creating an instance of Hapi server in this test we recreate the condition by setting // it directly with our own stub notifierStub = { omg: Sinon.stub(), omfg: Sinon.stub() } - Sinon.stub(GenerateReturnLogsService, 'go').resolves([{ - createdAt: new Date(), - updatedAt: new Date(), - dueDate: allYearDueDate, - endDate: allYearEndDate, - id: `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`, - licenceRef: licence.licenceRef, - metadata: { - description: 'BOREHOLE AT AVALON', - isCurrent: true, - isFinal: false, - isSummer: false, - isTwoPartTariff: false, - isUpload: false, - nald: { - regionCode: region.naldRegionId, - areaCode: licence.regions.historicalAreaCode, - formatId: returnRequirement.legacyId, - periodStartDay: returnRequirement.abstractionPeriodStartDay.toString(), - periodStartMonth: returnRequirement.abstractionPeriodStartMonth.toString(), - periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), - periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() - }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description + Sinon.stub(GenerateReturnLogsService, 'go').resolves([ + { + createdAt: new Date(), + updatedAt: new Date(), + dueDate: allYearDueDate, + endDate: allYearEndDate, + id: `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`, + licenceRef: licence.licenceRef, + metadata: { + description: 'BOREHOLE AT AVALON', + isCurrent: true, + isFinal: false, + isSummer: false, + isTwoPartTariff: false, + isUpload: false, + nald: { + regionCode: region.naldRegionId, + areaCode: licence.regions.historicalAreaCode, + formatId: returnRequirement.legacyId, + periodStartDay: returnRequirement.abstractionPeriodStartDay.toString(), + periodStartMonth: returnRequirement.abstractionPeriodStartMonth.toString(), + periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), + periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - tertiary: { - code: purpose.legacyId, - description: purpose.description - } - }], - version: 1 - }, - returnCycleId, - returnsFrequency: 'day', - returnReference: returnRequirement.legacyId.toString(), - startDate: allYearStartDate, - status: 'due', - source: 'WRLS' - }]) + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 + } + ], + purposes: [ + { + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } + } + ], + version: 1 + }, + returnCycleId, + returnsFrequency: 'day', + returnReference: returnRequirement.legacyId.toString(), + startDate: allYearStartDate, + status: 'due', + source: 'WRLS' + } + ]) global.GlobalNotifier = notifierStub }) @@ -129,7 +135,9 @@ describe('Process licence return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(new Date(allYearDueDate)) expect(result[0].endDate).to.equal(new Date(allYearEndDate)) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].returnsFrequency).to.equal('day') expect(result[0].startDate).to.equal(new Date(allYearStartDate)) diff --git a/test/services/jobs/return-logs/process-return-logs.service.test.js b/test/services/jobs/return-logs/process-return-logs.service.test.js index 45dc65bda7..585656d97d 100644 --- a/test/services/jobs/return-logs/process-return-logs.service.test.js +++ b/test/services/jobs/return-logs/process-return-logs.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, afterEach } = exports.lab = Lab.script() +const { describe, it, before, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -75,59 +75,65 @@ describe('Process return logs service', () => { // As we're not creating an instance of Hapi server in this test we recreate the condition by setting // it directly with our own stub notifierStub = { omg: Sinon.stub(), omfg: Sinon.stub() } - Sinon.stub(GenerateReturnLogsService, 'go').resolves([{ - createdAt: new Date(), - updatedAt: new Date(), - dueDate: allYearDueDate, - endDate: allYearEndDate, - id: `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`, - licenceRef: licence.licenceRef, - metadata: { - description: 'BOREHOLE AT AVALON', - isCurrent: true, - isFinal: false, - isSummer: false, - isTwoPartTariff: false, - isUpload: false, - nald: { - regionCode: region.naldRegionId, - areaCode: licence.regions.historicalAreaCode, - formatId: returnRequirement.legacyId, - periodStartDay: returnRequirement.abstractionPeriodStartDay.toString(), - periodStartMonth: returnRequirement.abstractionPeriodStartMonth.toString(), - periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), - periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() - }, - points: [{ - name: point.description, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4 - }], - purposes: [{ - primary: { - code: primaryPurpose.legacyId, - description: primaryPurpose.description - }, - secondary: { - code: secondaryPurpose.legacyId, - description: secondaryPurpose.description + Sinon.stub(GenerateReturnLogsService, 'go').resolves([ + { + createdAt: new Date(), + updatedAt: new Date(), + dueDate: allYearDueDate, + endDate: allYearEndDate, + id: `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`, + licenceRef: licence.licenceRef, + metadata: { + description: 'BOREHOLE AT AVALON', + isCurrent: true, + isFinal: false, + isSummer: false, + isTwoPartTariff: false, + isUpload: false, + nald: { + regionCode: region.naldRegionId, + areaCode: licence.regions.historicalAreaCode, + formatId: returnRequirement.legacyId, + periodStartDay: returnRequirement.abstractionPeriodStartDay.toString(), + periodStartMonth: returnRequirement.abstractionPeriodStartMonth.toString(), + periodEndDay: returnRequirement.abstractionPeriodEndDay.toString(), + periodEndMonth: returnRequirement.abstractionPeriodEndMonth.toString() }, - tertiary: { - code: purpose.legacyId, - description: purpose.description - } - }], - version: 1 - }, - returnCycleId: allYearReturnCycleId, - returnsFrequency: 'day', - returnReference: returnRequirement.legacyId.toString(), - startDate: allYearStartDate, - status: 'due', - source: 'WRLS' - }]) + points: [ + { + name: point.description, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4 + } + ], + purposes: [ + { + primary: { + code: primaryPurpose.legacyId, + description: primaryPurpose.description + }, + secondary: { + code: secondaryPurpose.legacyId, + description: secondaryPurpose.description + }, + tertiary: { + code: purpose.legacyId, + description: purpose.description + } + } + ], + version: 1 + }, + returnCycleId: allYearReturnCycleId, + returnsFrequency: 'day', + returnReference: returnRequirement.legacyId.toString(), + startDate: allYearStartDate, + status: 'due', + source: 'WRLS' + } + ]) global.GlobalNotifier = notifierStub }) @@ -139,7 +145,9 @@ describe('Process return logs service', () => { expect(result.length).to.equal(1) expect(result[0].dueDate).to.equal(new Date(allYearDueDate)) expect(result[0].endDate).to.equal(new Date(allYearEndDate)) - expect(result[0].id).to.equal(`v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}`) + expect(result[0].id).to.equal( + `v1:${region.naldRegionId}:${licence.licenceRef}:${returnRequirement.legacyId}:${allYearStartDate}:${allYearEndDate}` + ) expect(result[0].licenceRef).to.equal(licence.licenceRef) expect(result[0].returnsFrequency).to.equal('day') expect(result[0].startDate).to.equal(new Date(allYearStartDate)) diff --git a/test/services/jobs/session-cleanup/process-session-storage-cleanup.service.test.js b/test/services/jobs/session-cleanup/process-session-storage-cleanup.service.test.js index 5cdf3c9043..6e6b6e98ad 100644 --- a/test/services/jobs/session-cleanup/process-session-storage-cleanup.service.test.js +++ b/test/services/jobs/session-cleanup/process-session-storage-cleanup.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/jobs/time-limited/fetch-time-limited-licences.service.test.js b/test/services/jobs/time-limited/fetch-time-limited-licences.service.test.js index 54228e47df..e04a438bd4 100644 --- a/test/services/jobs/time-limited/fetch-time-limited-licences.service.test.js +++ b/test/services/jobs/time-limited/fetch-time-limited-licences.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -424,7 +424,7 @@ describe('Fetch Time Limited Licences service', () => { }) }) -function _offSetCurrentDateByDays (days) { +function _offSetCurrentDateByDays(days) { const date = new Date() date.setDate(date.getDate() + days) diff --git a/test/services/jobs/time-limited/process-time-limited-licences.service.test.js b/test/services/jobs/time-limited/process-time-limited-licences.service.test.js index 67dc8ff24a..58f412e6f5 100644 --- a/test/services/jobs/time-limited/process-time-limited-licences.service.test.js +++ b/test/services/jobs/time-limited/process-time-limited-licences.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -83,9 +83,7 @@ describe('Process Time Limited Licences service', () => { const logDataArg = notifierStub.omg.firstCall.args[1] - expect( - notifierStub.omg.calledWith('Time limited job complete') - ).to.be.true() + expect(notifierStub.omg.calledWith('Time limited job complete')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.count).to.exist() @@ -115,9 +113,7 @@ describe('Process Time Limited Licences service', () => { const logDataArg = notifierStub.omg.firstCall.args[1] - expect( - notifierStub.omg.calledWith('Time limited job complete') - ).to.be.true() + expect(notifierStub.omg.calledWith('Time limited job complete')).to.be.true() expect(logDataArg.timeTakenMs).to.exist() expect(logDataArg.timeTakenSs).to.exist() expect(logDataArg.count).to.exist() diff --git a/test/services/licences/determine-licence-has-return-versions.service.test.js b/test/services/licences/determine-licence-has-return-versions.service.test.js index 65054d080c..e5228e0974 100644 --- a/test/services/licences/determine-licence-has-return-versions.service.test.js +++ b/test/services/licences/determine-licence-has-return-versions.service.test.js @@ -4,15 +4,14 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers const ReturnVersionHelper = require('../../support/helpers/return-version.helper.js') // Thing under test -const FetchLicenceHasRequirementsService = - require('../../../app/services/licences/determine-licence-has-return-versions.service.js') +const FetchLicenceHasRequirementsService = require('../../../app/services/licences/determine-licence-has-return-versions.service.js') describe('Fetch Licence Has Requirements service', () => { const licenceId = 'e004c0c9-0316-42fc-a6e3-5ae9a271b3c6' diff --git a/test/services/licences/fetch-agreements.service.test.js b/test/services/licences/fetch-agreements.service.test.js index ad28cc24ee..86720e2091 100644 --- a/test/services/licences/fetch-agreements.service.test.js +++ b/test/services/licences/fetch-agreements.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -42,15 +42,18 @@ describe('Fetch Agreements service', () => { it('returns the matching agreements data', async () => { const results = await FetchAgreementsService.go(licenceAgreement.licenceRef) - expect(results[0]).to.equal({ - endDate, - financialAgreement: { - id: financialAgreement.id, - code: financialAgreement.code + expect(results[0]).to.equal( + { + endDate, + financialAgreement: { + id: financialAgreement.id, + code: financialAgreement.code + }, + startDate, + signedOn }, - startDate, - signedOn - }, { skip: ['id'] }) + { skip: ['id'] } + ) }) }) diff --git a/test/services/licences/fetch-charge-versions.service.test.js b/test/services/licences/fetch-charge-versions.service.test.js index 3dac09ae69..310dc209da 100644 --- a/test/services/licences/fetch-charge-versions.service.test.js +++ b/test/services/licences/fetch-charge-versions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -13,8 +13,7 @@ const ChangeReasonHelper = require('../../support/helpers/change-reason.helper.j const { generateUUID } = require('../../../app/lib/general.lib.js') // Thing under test -const FetchChargeVersionsService = - require('../../../app/services/licences/fetch-charge-versions.service.js') +const FetchChargeVersionsService = require('../../../app/services/licences/fetch-charge-versions.service.js') describe('Fetch Charge Versions service', () => { const licenceId = generateUUID() diff --git a/test/services/licences/fetch-communications.service.test.js b/test/services/licences/fetch-communications.service.test.js index 420e1ddd98..81b215bf96 100644 --- a/test/services/licences/fetch-communications.service.test.js +++ b/test/services/licences/fetch-communications.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -13,8 +13,7 @@ const ScheduledNotificationModel = require('../../support/helpers/scheduled-noti const { generateLicenceRef } = require('../../support/helpers/licence.helper.js') // Thing under test -const FetchCommunicationsService = - require('../../../app/services/licences/fetch-communications.service.js') +const FetchCommunicationsService = require('../../../app/services/licences/fetch-communications.service.js') describe('Fetch Communications service', () => { const licenceRef = generateLicenceRef() @@ -47,8 +46,8 @@ describe('Fetch Communications service', () => { total: 1 }) - expect(result.communications).to.equal( - [{ + expect(result.communications).to.equal([ + { event: { createdAt: new Date('2024-06-01'), issuer: 'test.user@defra.gov.uk', @@ -60,8 +59,8 @@ describe('Fetch Communications service', () => { id: scheduledNotification.id, messageRef: null, messageType: null - }] - ) + } + ]) }) }) diff --git a/test/services/licences/fetch-customer-contacts.service.test.js b/test/services/licences/fetch-customer-contacts.service.test.js index d3f21ca2b6..a5c93ba69f 100644 --- a/test/services/licences/fetch-customer-contacts.service.test.js +++ b/test/services/licences/fetch-customer-contacts.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -17,8 +17,7 @@ const LicenceHelper = require('../../support/helpers/licence.helper.js') const LicenceRoleHelper = require('../../support/helpers/licence-role.helper.js') // Thing under test -const FetchCustomerContactDetailsService = - require('../../../app/services/licences/fetch-customer-contacts.service.js') +const FetchCustomerContactDetailsService = require('../../../app/services/licences/fetch-customer-contacts.service.js') describe('Fetch Customer Contacts service', () => { let companyId diff --git a/test/services/licences/fetch-licence-bills.service.test.js b/test/services/licences/fetch-licence-bills.service.test.js index ef853e51fe..48e7e174d5 100644 --- a/test/services/licences/fetch-licence-bills.service.test.js +++ b/test/services/licences/fetch-licence-bills.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -43,16 +43,15 @@ describe('Fetch Licence Bills service', () => { beforeEach(async () => { await BillRunHelper.add({ id: billRunId, status: 'sent' }) - await BillHelper.add( - { - id: billId, - billRunId, - invoiceNumber: '123', - accountNumber: 'T21404193A', - netAmount: 12345, - billingAccountId, - createdAt: createdDate - }) + await BillHelper.add({ + id: billId, + billRunId, + invoiceNumber: '123', + accountNumber: 'T21404193A', + netAmount: 12345, + billingAccountId, + createdAt: createdDate + }) // Add an extra bill linked to the same bill run to test only bills for the licence are retrieved await BillHelper.add({ billRunId }) @@ -65,8 +64,8 @@ describe('Fetch Licence Bills service', () => { total: 1 }) - expect(result.bills).to.equal( - [{ + expect(result.bills).to.equal([ + { accountNumber: 'T21404193A', billRun: { id: billRunId, @@ -83,8 +82,8 @@ describe('Fetch Licence Bills service', () => { invoiceNumber: '123', legacyId: null, netAmount: 12345 - }] - ) + } + ]) }) }) @@ -92,16 +91,15 @@ describe('Fetch Licence Bills service', () => { beforeEach(async () => { await BillRunHelper.add({ id: billRunId }) - await BillHelper.add( - { - id: billId, - billRunId, - invoiceNumber: '123', - accountNumber: 'T21404193A', - netAmount: 12345, - billingAccountId, - createdAt: createdDate - }) + await BillHelper.add({ + id: billId, + billRunId, + invoiceNumber: '123', + accountNumber: 'T21404193A', + netAmount: 12345, + billingAccountId, + createdAt: createdDate + }) // Add an extra bill linked to the same bill run to test only bills for the licence are retrieved await BillHelper.add({ billRunId }) diff --git a/test/services/licences/fetch-licence-contact-details.service.test.js b/test/services/licences/fetch-licence-contact-details.service.test.js index fa26f19150..7d30f19a44 100644 --- a/test/services/licences/fetch-licence-contact-details.service.test.js +++ b/test/services/licences/fetch-licence-contact-details.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/fetch-licence-contacts.service.test.js b/test/services/licences/fetch-licence-contacts.service.test.js index 74d47b989f..a925b2505b 100644 --- a/test/services/licences/fetch-licence-contacts.service.test.js +++ b/test/services/licences/fetch-licence-contacts.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/fetch-licence-history.service.test.js b/test/services/licences/fetch-licence-history.service.test.js index c49b7025dc..abb15f21c2 100644 --- a/test/services/licences/fetch-licence-history.service.test.js +++ b/test/services/licences/fetch-licence-history.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/fetch-licence-points.service.test.js b/test/services/licences/fetch-licence-points.service.test.js index 383b9317ca..f9456fd381 100644 --- a/test/services/licences/fetch-licence-points.service.test.js +++ b/test/services/licences/fetch-licence-points.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/fetch-licence-purposes.service.test.js b/test/services/licences/fetch-licence-purposes.service.test.js index 84209fcdce..a0c3517b1a 100644 --- a/test/services/licences/fetch-licence-purposes.service.test.js +++ b/test/services/licences/fetch-licence-purposes.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -61,40 +61,43 @@ describe('Fetch Licence Purposes service', () => { 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, - licenceVersionPurposePoints: [ - { - abstractionMethod: 'Unspecified Pump' - } - ], - points: [ - { - description: point.description, - id: point.id, - ngr1: point.ngr1, - ngr2: null, - ngr3: null, - ngr4: null, - source: { - description: source.description, - id: source.id + licenceVersionPurposes: [ + { + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3, + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 1, + annualQuantity: null, + dailyQuantity: null, + hourlyQuantity: null, + instantQuantity: null, + licenceVersionPurposePoints: [ + { + abstractionMethod: 'Unspecified Pump' + } + ], + 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 } - ], - purpose: { - description: purpose.description, - id: purpose.id } - }] - }] + ] + } + ] }) }) }) diff --git a/test/services/licences/fetch-licence-returns.service.test.js b/test/services/licences/fetch-licence-returns.service.test.js index 62e78df396..c4edcfc134 100644 --- a/test/services/licences/fetch-licence-returns.service.test.js +++ b/test/services/licences/fetch-licence-returns.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -59,28 +59,26 @@ describe('Fetch licence returns service', () => { total: 2 }) // This should be ordered by due date - expect(result.returns).to.equal( - [ - { - dueDate: latestDueDate, - endDate, - id: latestReturn.id, - metadata: 323, - returnReference: '123', - startDate, - status: '32' - }, - { - dueDate, - endDate, - id: firstReturn.id, - metadata: 323, - returnReference: '32', - startDate, - status: '32' - } - ] - ) + expect(result.returns).to.equal([ + { + dueDate: latestDueDate, + endDate, + id: latestReturn.id, + metadata: 323, + returnReference: '123', + startDate, + status: '32' + }, + { + dueDate, + endDate, + id: firstReturn.id, + metadata: 323, + returnReference: '32', + startDate, + status: '32' + } + ]) }) }) }) diff --git a/test/services/licences/fetch-licence-summary.service.test.js b/test/services/licences/fetch-licence-summary.service.test.js index 6ac08b7072..3430b22c45 100644 --- a/test/services/licences/fetch-licence-summary.service.test.js +++ b/test/services/licences/fetch-licence-summary.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -60,10 +60,13 @@ describe('Fetch Licence Summary service', () => { // Create 2 licence versions so we can test the service only gets the 'current' version await LicenceVersionHelper.add({ - licenceId: licence.id, startDate: new Date('2021-10-11'), status: 'superseded' + licenceId: licence.id, + startDate: new Date('2021-10-11'), + status: 'superseded' }) licenceVersion = await LicenceVersionHelper.add({ - licenceId: licence.id, startDate: new Date('2022-05-01') + licenceId: licence.id, + startDate: new Date('2022-05-01') }) purpose = PurposeHelper.select() @@ -118,57 +121,67 @@ describe('Fetch Licence Summary service', () => { id: licenceVersion.id, startDate: new Date('2022-05-01'), status: 'current', - licenceVersionPurposes: [{ - id: licenceVersionPurpose.id, - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 1, - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 3, - annualQuantity: null, - dailyQuantity: null, - hourlyQuantity: null, - instantQuantity: null, - purpose: { - id: purpose.id, - description: purpose.description - }, - points: [{ - description: point.description, - id: point.id, - ngr1: point.ngr1, - ngr2: point.ngr2, - ngr3: point.ngr3, - ngr4: point.ngr4, - source: { description: source.description, id: source.id } - }], - licenceVersionPurposeConditions: [{ - id: licenceVersionPurposeCondition.id, - licenceVersionPurposeConditionType: { - id: licenceVersionPurposeConditionType.id, - displayTitle: 'Aggregate condition link between licences' - } - }] - }] + licenceVersionPurposes: [ + { + id: licenceVersionPurpose.id, + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 1, + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 3, + annualQuantity: null, + dailyQuantity: null, + hourlyQuantity: null, + instantQuantity: null, + purpose: { + id: purpose.id, + description: purpose.description + }, + points: [ + { + description: point.description, + id: point.id, + ngr1: point.ngr1, + ngr2: point.ngr2, + ngr3: point.ngr3, + ngr4: point.ngr4, + source: { description: source.description, id: source.id } + } + ], + licenceVersionPurposeConditions: [ + { + id: licenceVersionPurposeCondition.id, + licenceVersionPurposeConditionType: { + id: licenceVersionPurposeConditionType.id, + displayTitle: 'Aggregate condition link between licences' + } + } + ] + } + ] } ], - licenceMonitoringStations: [{ - id: licenceMonitoringStation.id, - monitoringStation: { - id: monitoringStation.id, - label: 'MONITOR PLACE' + licenceMonitoringStations: [ + { + id: licenceMonitoringStation.id, + monitoringStation: { + id: monitoringStation.id, + label: 'MONITOR PLACE' + } } - }], + ], licenceDocument: { id: licenceHolderSeed.licenceDocumentId, - licenceDocumentRoles: [{ - id: licenceHolderSeed.licenceDocumentRoleId, - contact: null, - company: { - id: licenceHolderSeed.companyId, - name: 'Licence Holder Ltd', - type: 'organisation' + licenceDocumentRoles: [ + { + id: licenceHolderSeed.licenceDocumentRoleId, + contact: null, + company: { + id: licenceHolderSeed.companyId, + name: 'Licence Holder Ltd', + type: 'organisation' + } } - }] + ] }, licenceDocumentHeader: { id: licenceDocumentHeader.id diff --git a/test/services/licences/fetch-licence.service.test.js b/test/services/licences/fetch-licence.service.test.js index 4682c13b34..ef13a436e3 100644 --- a/test/services/licences/fetch-licence.service.test.js +++ b/test/services/licences/fetch-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -52,13 +52,17 @@ describe('Fetch Licence service', () => { revokedDate: null, lapsedDate: null, licenceDocumentHeader: null, - licenceSupplementaryYears: [{ - id: licenceSupplementaryYearId - }], - workflows: [{ - id: workflow.id, - status: workflow.status - }] + licenceSupplementaryYears: [ + { + id: licenceSupplementaryYearId + } + ], + workflows: [ + { + id: workflow.id, + status: workflow.status + } + ] }) }) }) diff --git a/test/services/licences/fetch-return-versions.service.test.js b/test/services/licences/fetch-return-versions.service.test.js index ed55dfdc26..91617c6265 100644 --- a/test/services/licences/fetch-return-versions.service.test.js +++ b/test/services/licences/fetch-return-versions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -12,8 +12,7 @@ const ModLogHelper = require('../../support/helpers/mod-log.helper.js') const ReturnVersionHelper = require('../../support/helpers/return-version.helper.js') // Thing under test -const FetchReturnVersionsService = - require('../../../app/services/licences/fetch-return-versions.service.js') +const FetchReturnVersionsService = require('../../../app/services/licences/fetch-return-versions.service.js') describe('Fetch Return Versions service', () => { const startDate = new Date('2022-04-01') @@ -26,19 +25,28 @@ describe('Fetch Return Versions service', () => { beforeEach(async () => { // NOTE: We add these 2, both with the same start date to ensure the order that they are returned as expected supersededReturnVersion = await ReturnVersionHelper.add({ - startDate, status: 'superseded', version: 100 + startDate, + status: 'superseded', + version: 100 }) currentReturnVersion = await ReturnVersionHelper.add({ - licenceId: supersededReturnVersion.licenceId, startDate, status: 'current', version: 101 + licenceId: supersededReturnVersion.licenceId, + startDate, + status: 'current', + version: 101 }) // We add this 3rd one with a status of draft to ensure it is not included await ReturnVersionHelper.add({ - licenceId: supersededReturnVersion.licenceId, startDate: new Date('2022-05-01'), status: 'draft', version: 102 + licenceId: supersededReturnVersion.licenceId, + startDate: new Date('2022-05-01'), + status: 'draft', + version: 102 }) currentReturnVersionModLog = await ModLogHelper.add({ - reasonDescription: 'Record Loaded During Migration', returnVersionId: currentReturnVersion.id + reasonDescription: 'Record Loaded During Migration', + returnVersionId: currentReturnVersion.id }) }) @@ -52,10 +60,12 @@ describe('Fetch Return Versions service', () => { endDate: null, status: 'current', reason: 'new-licence', - modLogs: [{ - id: currentReturnVersionModLog.id, - reasonDescription: 'Record Loaded During Migration' - }] + modLogs: [ + { + id: currentReturnVersionModLog.id, + reasonDescription: 'Record Loaded During Migration' + } + ] }, { id: supersededReturnVersion.id, diff --git a/test/services/licences/fetch-workflows.service.test.js b/test/services/licences/fetch-workflows.service.test.js index 0a74b3bd35..26ced0e508 100644 --- a/test/services/licences/fetch-workflows.service.test.js +++ b/test/services/licences/fetch-workflows.service.test.js @@ -4,15 +4,14 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers const WorkflowHelper = require('../../support/helpers/workflow.helper.js') // Thing under test -const FetchWorkflowsService = - require('../../../app/services/licences/fetch-workflows.service.js') +const FetchWorkflowsService = require('../../../app/services/licences/fetch-workflows.service.js') describe('Fetch Workflows service', () => { let testRecord @@ -39,8 +38,8 @@ describe('Fetch Workflows service', () => { id: testRecord.id, licenceId: testRecord.licenceId, status: 'to_setup' - }] - ) + } + ]) }) }) }) diff --git a/test/services/licences/supplementary/create-licence-supplementary-year.service.test.js b/test/services/licences/supplementary/create-licence-supplementary-year.service.test.js index 7a1356e73a..486e86ad18 100644 --- a/test/services/licences/supplementary/create-licence-supplementary-year.service.test.js +++ b/test/services/licences/supplementary/create-licence-supplementary-year.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -34,12 +34,15 @@ describe('Create Licence Supplementary Years Service', () => { const result = await _fetchLicenceSupplementaryYears(licenceId) expect(result).to.have.length(1) - expect(result[0]).to.equal({ - licenceId, - billRunId: null, - financialYearEnd: financialYearEnds[0], - twoPartTariff - }, { skip: ['id'] }) + expect(result[0]).to.equal( + { + licenceId, + billRunId: null, + financialYearEnd: financialYearEnds[0], + twoPartTariff + }, + { skip: ['id'] } + ) }) }) @@ -85,14 +88,8 @@ describe('Create Licence Supplementary Years Service', () => { }) }) -function _fetchLicenceSupplementaryYears (licenceId) { +function _fetchLicenceSupplementaryYears(licenceId) { return LicenceSupplementaryYearModel.query() - .select([ - 'id', - 'licenceId', - 'billRunId', - 'financialYearEnd', - 'twoPartTariff' - ]) + .select(['id', 'licenceId', 'billRunId', 'financialYearEnd', 'twoPartTariff']) .where('licenceId', licenceId) } diff --git a/test/services/licences/supplementary/determine-billing-years.service.test.js b/test/services/licences/supplementary/determine-billing-years.service.test.js index 41b3f84866..acf34b79d3 100644 --- a/test/services/licences/supplementary/determine-billing-years.service.test.js +++ b/test/services/licences/supplementary/determine-billing-years.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/licences/supplementary/determine-charge-version-flags.service.test.js b/test/services/licences/supplementary/determine-charge-version-flags.service.test.js index 11591d88f6..e94c03cc8f 100644 --- a/test/services/licences/supplementary/determine-charge-version-flags.service.test.js +++ b/test/services/licences/supplementary/determine-charge-version-flags.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/supplementary/determine-existing-bill-run-years.service.test.js b/test/services/licences/supplementary/determine-existing-bill-run-years.service.test.js index dfaebc2bb2..de1aba6b4e 100644 --- a/test/services/licences/supplementary/determine-existing-bill-run-years.service.test.js +++ b/test/services/licences/supplementary/determine-existing-bill-run-years.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,7 +48,12 @@ describe('Determine Existing Bill Run Years Service', () => { describe('when an annual two-part tariff bill run has been created for those years', () => { beforeEach(async () => { billRun = await BillRunHelper.add({ batchType: 'two_part_tariff', status: 'sent', regionId }) - billRunTwo = await BillRunHelper.add({ batchType: 'two_part_tariff', status: 'review', regionId, toFinancialYearEnding: 2024 }) + billRunTwo = await BillRunHelper.add({ + batchType: 'two_part_tariff', + status: 'review', + regionId, + toFinancialYearEnding: 2024 + }) }) afterEach(async () => { @@ -89,7 +94,12 @@ describe('Determine Existing Bill Run Years Service', () => { describe('when an annual bill run has been created for those years', () => { beforeEach(async () => { billRun = await BillRunHelper.add({ batchType: 'annual', status: 'sent', regionId }) - billRunTwo = await BillRunHelper.add({ batchType: 'annual', status: 'review', regionId, toFinancialYearEnding: 2024 }) + billRunTwo = await BillRunHelper.add({ + batchType: 'annual', + status: 'review', + regionId, + toFinancialYearEnding: 2024 + }) }) afterEach(async () => { diff --git a/test/services/licences/supplementary/determine-return-log-flags.service.test.js b/test/services/licences/supplementary/determine-return-log-flags.service.test.js index f275bb48f9..83fc8ac108 100644 --- a/test/services/licences/supplementary/determine-return-log-flags.service.test.js +++ b/test/services/licences/supplementary/determine-return-log-flags.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/supplementary/determine-workflow-flags.service.test.js b/test/services/licences/supplementary/determine-workflow-flags.service.test.js index 49d69d49db..639eda7eb3 100644 --- a/test/services/licences/supplementary/determine-workflow-flags.service.test.js +++ b/test/services/licences/supplementary/determine-workflow-flags.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, afterEach } = exports.lab = Lab.script() +const { describe, it, before, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/supplementary/fetch-existing-licence-details.service.test.js b/test/services/licences/supplementary/fetch-existing-licence-details.service.test.js index b3d4e68154..5875a2df54 100644 --- a/test/services/licences/supplementary/fetch-existing-licence-details.service.test.js +++ b/test/services/licences/supplementary/fetch-existing-licence-details.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -61,9 +61,10 @@ describe('Fetch Existing Licence Details Service', () => { const chargeVersion = await ChargeVersionHelper.add({ licenceId: licence.id }) // two-part tariff indicators - const chargeReference = await ChargeReferenceHelper.add( - { chargeVersionId: chargeVersion.id, adjustments: { s127: true } } - ) + const chargeReference = await ChargeReferenceHelper.add({ + chargeVersionId: chargeVersion.id, + adjustments: { s127: true } + }) await ChargeElementHelper.add({ chargeReferenceId: chargeReference.id }) }) diff --git a/test/services/licences/supplementary/fetch-licence.service.test.js b/test/services/licences/supplementary/fetch-licence.service.test.js index ff04ab6d12..f91aab84f5 100644 --- a/test/services/licences/supplementary/fetch-licence.service.test.js +++ b/test/services/licences/supplementary/fetch-licence.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,9 +32,10 @@ describe('Fetch Licence Service', () => { const chargeVersion = await ChargeVersionHelper.add({ licenceId: licence.id }) // two-part tariff indicators - const chargeReference = await ChargeReferenceHelper.add( - { chargeVersionId: chargeVersion.id, adjustments: { s127: true } } - ) + const chargeReference = await ChargeReferenceHelper.add({ + chargeVersionId: chargeVersion.id, + adjustments: { s127: true } + }) await ChargeElementHelper.add({ chargeReferenceId: chargeReference.id }) }) diff --git a/test/services/licences/supplementary/mark-for-supplementary-billing.service.test.js b/test/services/licences/supplementary/mark-for-supplementary-billing.service.test.js index d7323c423d..3298d61ab7 100644 --- a/test/services/licences/supplementary/mark-for-supplementary-billing.service.test.js +++ b/test/services/licences/supplementary/mark-for-supplementary-billing.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/supplementary/marked-for-supplementary-billing.service.test.js b/test/services/licences/supplementary/marked-for-supplementary-billing.service.test.js index ea9151a6f9..ba7f1fe87c 100644 --- a/test/services/licences/supplementary/marked-for-supplementary-billing.service.test.js +++ b/test/services/licences/supplementary/marked-for-supplementary-billing.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/licences/supplementary/persist-supplementary-billing-flags.service.test.js b/test/services/licences/supplementary/persist-supplementary-billing-flags.service.test.js index a6bfa2c86c..9cd163dcef 100644 --- a/test/services/licences/supplementary/persist-supplementary-billing-flags.service.test.js +++ b/test/services/licences/supplementary/persist-supplementary-billing-flags.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -47,7 +47,10 @@ describe('Persist Supplementary Billing Flags Service', () => { it('persists the flags on the licence', async () => { await PersistSupplementaryBillingFlagsService.go( - twoPartTariffFinancialYears, preSrocFlag, srocFlag, testLicence.id + twoPartTariffFinancialYears, + preSrocFlag, + srocFlag, + testLicence.id ) const licence = await LicenceModel.query().findById(testLicence.id) @@ -59,7 +62,10 @@ describe('Persist Supplementary Billing Flags Service', () => { it('calls `CreateLicenceSupplementaryYearsService` to handle persisting the financial years', async () => { await PersistSupplementaryBillingFlagsService.go( - twoPartTariffFinancialYears, preSrocFlag, srocFlag, testLicence.id + twoPartTariffFinancialYears, + preSrocFlag, + srocFlag, + testLicence.id ) expect(CreateLicenceSupplementaryYearService.go.called).to.be.true() @@ -75,7 +81,10 @@ describe('Persist Supplementary Billing Flags Service', () => { it('persists the flags on the licence', async () => { await PersistSupplementaryBillingFlagsService.go( - twoPartTariffFinancialYears, preSrocFlag, srocFlag, testLicence.id + twoPartTariffFinancialYears, + preSrocFlag, + srocFlag, + testLicence.id ) const licence = await LicenceModel.query().findById(testLicence.id) @@ -87,7 +96,10 @@ describe('Persist Supplementary Billing Flags Service', () => { it('does not call `CreateLicenceSupplementaryYearsService`', async () => { await PersistSupplementaryBillingFlagsService.go( - twoPartTariffFinancialYears, preSrocFlag, srocFlag, testLicence.id + twoPartTariffFinancialYears, + preSrocFlag, + srocFlag, + testLicence.id ) expect(CreateLicenceSupplementaryYearService.go.called).to.be.false() diff --git a/test/services/licences/supplementary/process-billing-flag.service.test.js b/test/services/licences/supplementary/process-billing-flag.service.test.js index 47a9695926..2a08f1b1d8 100644 --- a/test/services/licences/supplementary/process-billing-flag.service.test.js +++ b/test/services/licences/supplementary/process-billing-flag.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, before, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -296,7 +296,7 @@ describe('Process Billing Flag Service', () => { }) }) -function _licenceData (twoPartTariff) { +function _licenceData(twoPartTariff) { return { licenceId: 'aad74a3d-59ea-4c18-8091-02b0f8b0a147', regionId: 'ff92e0b1-3934-430b-8b16-5b89a3ea258f', diff --git a/test/services/licences/supplementary/process-imported-licence.service.test.js b/test/services/licences/supplementary/process-imported-licence.service.test.js index cbccfd9370..0e41489091 100644 --- a/test/services/licences/supplementary/process-imported-licence.service.test.js +++ b/test/services/licences/supplementary/process-imported-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -55,12 +55,7 @@ describe('Process Imported Licence Service', () => { await ProcessImportedLicenceService.go(importedLicence, licence.id) expect(PersistSupplementaryBillingFlagsServiceStub.called).to.be.true() - expect(PersistSupplementaryBillingFlagsServiceStub.calledWith( - [], - true, - false, - licence.id - )).to.be.true() + expect(PersistSupplementaryBillingFlagsServiceStub.calledWith([], true, false, licence.id)).to.be.true() }) }) @@ -74,12 +69,7 @@ describe('Process Imported Licence Service', () => { await ProcessImportedLicenceService.go(importedLicence, licence.id) expect(PersistSupplementaryBillingFlagsServiceStub.called).to.be.true() - expect(PersistSupplementaryBillingFlagsServiceStub.calledWith( - [], - true, - false, - licence.id - )).to.be.true() + expect(PersistSupplementaryBillingFlagsServiceStub.calledWith([], true, false, licence.id)).to.be.true() }) }) @@ -93,12 +83,9 @@ describe('Process Imported Licence Service', () => { await ProcessImportedLicenceService.go(importedLicence, licence.id) expect(PersistSupplementaryBillingFlagsServiceStub.called).to.be.true() - expect(PersistSupplementaryBillingFlagsServiceStub.calledWith( - [2023, 2024, 2025], - false, - true, - licence.id - )).to.be.true() + expect( + PersistSupplementaryBillingFlagsServiceStub.calledWith([2023, 2024, 2025], false, true, licence.id) + ).to.be.true() }) }) @@ -111,12 +98,7 @@ describe('Process Imported Licence Service', () => { await ProcessImportedLicenceService.go(importedLicence, licence.id) expect(PersistSupplementaryBillingFlagsServiceStub.called).to.be.true() - expect(PersistSupplementaryBillingFlagsServiceStub.calledWith( - [], - false, - true, - licence.id - )).to.be.true() + expect(PersistSupplementaryBillingFlagsServiceStub.calledWith([], false, true, licence.id)).to.be.true() }) }) @@ -130,30 +112,22 @@ describe('Process Imported Licence Service', () => { await ProcessImportedLicenceService.go(importedLicence, licence.id) expect(PersistSupplementaryBillingFlagsServiceStub.called).to.be.true() - expect(PersistSupplementaryBillingFlagsServiceStub.calledWith( - [], - false, - true, - licence.id - )).to.be.true() + expect(PersistSupplementaryBillingFlagsServiceStub.calledWith([], false, true, licence.id)).to.be.true() }) }) describe('with null revoked date and two-part tariff charge versions', () => { beforeEach(() => { - Sinon.stub(FetchExistingLicenceDetailsService, 'go').resolves(_srocTwoPartTariffLicence(licence.id, '2024-04-01')) + Sinon.stub(FetchExistingLicenceDetailsService, 'go').resolves( + _srocTwoPartTariffLicence(licence.id, '2024-04-01') + ) }) it('flags the licence for sroc supplementary billing', async () => { await ProcessImportedLicenceService.go(importedLicence, licence.id) expect(PersistSupplementaryBillingFlagsServiceStub.called).to.be.true() - expect(PersistSupplementaryBillingFlagsServiceStub.calledWith( - [2025], - false, - true, - licence.id - )).to.be.true() + expect(PersistSupplementaryBillingFlagsServiceStub.calledWith([2025], false, true, licence.id)).to.be.true() }) }) @@ -167,12 +141,7 @@ describe('Process Imported Licence Service', () => { await ProcessImportedLicenceService.go(importedLicence, licence.id) expect(PersistSupplementaryBillingFlagsServiceStub.called).to.be.true() - expect(PersistSupplementaryBillingFlagsServiceStub.calledWith( - [2025], - false, - true, - licence.id - )).to.be.true() + expect(PersistSupplementaryBillingFlagsServiceStub.calledWith([2025], false, true, licence.id)).to.be.true() }) }) @@ -192,7 +161,7 @@ describe('Process Imported Licence Service', () => { }) }) -function _flaggedPreSrocLicence (id) { +function _flaggedPreSrocLicence(id) { return { id, expired_date: null, @@ -206,7 +175,7 @@ function _flaggedPreSrocLicence (id) { } } -function _futureRevokedDate () { +function _futureRevokedDate() { return { expired_date: null, lapsed_date: null, @@ -214,7 +183,7 @@ function _futureRevokedDate () { } } -function _preSrocLicence (id) { +function _preSrocLicence(id) { return { id, expired_date: new Date('2021-04-01'), @@ -228,7 +197,7 @@ function _preSrocLicence (id) { } } -function _preSrocTwoPartTariffLicence (id) { +function _preSrocTwoPartTariffLicence(id) { return { id, expired_date: null, @@ -242,7 +211,7 @@ function _preSrocTwoPartTariffLicence (id) { } } -function _srocLicence (id, date) { +function _srocLicence(id, date) { return { id, expired_date: null, @@ -256,7 +225,7 @@ function _srocLicence (id, date) { } } -function _srocTwoPartTariffLicence (id, date) { +function _srocTwoPartTariffLicence(id, date) { return { id, expired_date: null, diff --git a/test/services/licences/supplementary/submit-mark-for-supplementary-billing.service.test.js b/test/services/licences/supplementary/submit-mark-for-supplementary-billing.service.test.js index bbcf0a0738..fb28315af2 100644 --- a/test/services/licences/supplementary/submit-mark-for-supplementary-billing.service.test.js +++ b/test/services/licences/supplementary/submit-mark-for-supplementary-billing.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -59,21 +59,22 @@ describe('Submit Mark For Supplementary Billing Service', () => { const licenceSupplementaryYears = await LicenceSupplementaryYearModel.query().where('licenceId', licence.id) expect(result).to.equal({ error: null }) - expect(licenceSupplementaryYears[0]).to.equal({ - licenceId: licence.id, - billRunId: null, - twoPartTariff: true, - financialYearEnd: 2023 - }, { skip: ['id', 'createdAt', 'updatedAt'] }) + expect(licenceSupplementaryYears[0]).to.equal( + { + licenceId: licence.id, + billRunId: null, + twoPartTariff: true, + financialYearEnd: 2023 + }, + { skip: ['id', 'createdAt', 'updatedAt'] } + ) }) it('flags the licence for supplementary billing for the pre sroc years', async () => { await SubmitMarkForSupplementaryBillingService.go(licence.id, payload, user) - expect(LegacyRequest.post.calledWith( - 'water', - `licences/${licence.id}/mark-for-supplementary-billing`, - user.id) + expect( + LegacyRequest.post.calledWith('water', `licences/${licence.id}/mark-for-supplementary-billing`, user.id) ).to.be.true() }) }) @@ -91,10 +92,8 @@ describe('Submit Mark For Supplementary Billing Service', () => { const result = await SubmitMarkForSupplementaryBillingService.go(licence.id, payload, user) expect(result).to.equal({ error: null }) - expect(LegacyRequest.post.calledWith( - 'water', - `licences/${licence.id}/mark-for-supplementary-billing`, - user.id) + expect( + LegacyRequest.post.calledWith('water', `licences/${licence.id}/mark-for-supplementary-billing`, user.id) ).to.be.true() }) }) @@ -114,12 +113,15 @@ describe('Submit Mark For Supplementary Billing Service', () => { const licenceSupplementaryYears = await LicenceSupplementaryYearModel.query().where('licenceId', licence.id) expect(result).to.equal({ error: null }) - expect(licenceSupplementaryYears[0]).to.equal({ - licenceId: licence.id, - billRunId: null, - twoPartTariff: true, - financialYearEnd: 2023 - }, { skip: ['id', 'createdAt', 'updatedAt'] }) + expect(licenceSupplementaryYears[0]).to.equal( + { + licenceId: licence.id, + billRunId: null, + twoPartTariff: true, + financialYearEnd: 2023 + }, + { skip: ['id', 'createdAt', 'updatedAt'] } + ) }) it('does not flag the licence for supplementary billing for the pre sroc years', async () => { diff --git a/test/services/licences/view-licence-bills.service.test.js b/test/services/licences/view-licence-bills.service.test.js index 2d88a9a91f..9d198b18c5 100644 --- a/test/services/licences/view-licence-bills.service.test.js +++ b/test/services/licences/view-licence-bills.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -44,11 +44,11 @@ describe('View Licence service bills', () => { }) }) -function _licence () { +function _licence() { return { licenceName: 'fake licence' } } -function _billsFetchService () { +function _billsFetchService() { return { bills: [], pagination: { total: 1 } diff --git a/test/services/licences/view-licence-communications.service.test.js b/test/services/licences/view-licence-communications.service.test.js index 4c0a6d5fd2..ce8947bdee 100644 --- a/test/services/licences/view-licence-communications.service.test.js +++ b/test/services/licences/view-licence-communications.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/licences/view-licence-contact-details.service.test.js b/test/services/licences/view-licence-contact-details.service.test.js index 92e7eb7f6b..24c0b3023f 100644 --- a/test/services/licences/view-licence-contact-details.service.test.js +++ b/test/services/licences/view-licence-contact-details.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -29,14 +29,7 @@ describe('View Licence Contact Details service', () => { activeNavBar: 'search', licenceContactDetails: [ { - address: [ - 'ENVIRONMENT AGENCY', - 'HORIZON HOUSE', - 'DEANERY ROAD', - 'BRISTOL', - 'AVON', - 'BS1 5AH' - ], + address: ['ENVIRONMENT AGENCY', 'HORIZON HOUSE', 'DEANERY ROAD', 'BRISTOL', 'AVON', 'BS1 5AH'], name: 'A GUPTA', role: 'Licence holder' } @@ -49,7 +42,7 @@ describe('View Licence Contact Details service', () => { }) }) -function _testFetchLicenceContactDetailsData () { +function _testFetchLicenceContactDetailsData() { return { id: 'fea88a95-d81f-4c5c-b497-00e5891a5861', licenceRef: '01/123', diff --git a/test/services/licences/view-licence-contacts.service.test.js b/test/services/licences/view-licence-contacts.service.test.js index 3982c6fd2d..7afbc7a67d 100644 --- a/test/services/licences/view-licence-contacts.service.test.js +++ b/test/services/licences/view-licence-contacts.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -21,33 +21,37 @@ describe('View Licence Contacts service', () => { const testId = '2c80bd22-a005-4cf4-a2a2-73812a9861de' beforeEach(() => { - Sinon.stub(FetchLicenceContactsService, 'go').returns([{ - communicationType: 'Licence Holder', - companyId: 'ebe95a21-c6f6-4f15-8856-a48ffc737731', - companyName: 'Acme ltd', - contactId: null, - firstName: null, - lastName: null, - address1: '34 Eastgate', - address2: null, - address3: null, - address4: null, - address5: null, - address6: null, - postcode: 'CF71 7DG', - country: 'United Kingdom' - }]) + Sinon.stub(FetchLicenceContactsService, 'go').returns([ + { + communicationType: 'Licence Holder', + companyId: 'ebe95a21-c6f6-4f15-8856-a48ffc737731', + companyName: 'Acme ltd', + contactId: null, + firstName: null, + lastName: null, + address1: '34 Eastgate', + address2: null, + address3: null, + address4: null, + address5: null, + address6: null, + postcode: 'CF71 7DG', + country: 'United Kingdom' + } + ]) - Sinon.stub(FetchCustomerContactsService, 'go').returns([{ - communicationType: 'Additional Contact', - email: 'dfd@email.com', - firstName: 'Donald', - initials: null, - lastName: 'Duck', - middleInitials: null, - salutation: null, - suffix: null - }]) + Sinon.stub(FetchCustomerContactsService, 'go').returns([ + { + communicationType: 'Additional Contact', + email: 'dfd@email.com', + firstName: 'Donald', + initials: null, + lastName: 'Duck', + middleInitials: null, + salutation: null, + suffix: null + } + ]) Sinon.stub(ViewLicenceService, 'go').resolves({ licenceName: 'fake licence' }) }) @@ -62,27 +66,31 @@ describe('View Licence Contacts service', () => { expect(result).to.equal({ activeTab: 'contact-details', - customerContacts: [{ - communicationType: 'Additional Contact', - email: 'dfd@email.com', - name: 'Donald Duck' - }], + customerContacts: [ + { + communicationType: 'Additional Contact', + email: 'dfd@email.com', + name: 'Donald Duck' + } + ], licenceName: 'fake licence', customerId: 'ebe95a21-c6f6-4f15-8856-a48ffc737731', - licenceContacts: [{ - address: { - address1: '34 Eastgate', - address2: null, - address3: null, - address4: null, - address5: null, - address6: null, - country: 'United Kingdom', - postcode: 'CF71 7DG' - }, - communicationType: 'Licence Holder', - name: 'Acme ltd' - }] + licenceContacts: [ + { + address: { + address1: '34 Eastgate', + address2: null, + address3: null, + address4: null, + address5: null, + address6: null, + country: 'United Kingdom', + postcode: 'CF71 7DG' + }, + communicationType: 'Licence Holder', + name: 'Acme ltd' + } + ] }) }) }) diff --git a/test/services/licences/view-licence-history.service.test.js b/test/services/licences/view-licence-history.service.test.js index 069013271c..6abc8e39a9 100644 --- a/test/services/licences/view-licence-history.service.test.js +++ b/test/services/licences/view-licence-history.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -76,7 +76,7 @@ describe('View Licence History service', () => { }) }) -function _testFetchLicenceHistory () { +function _testFetchLicenceHistory() { const changeReason = ChangeReasonModel.fromJson({ id: '0dee4596-0867-4997-8a00-e0998cfcefc0', description: 'Major change' @@ -91,9 +91,11 @@ function _testFetchLicenceHistory () { id: '761bc44f-80d5-49ae-ab46-0a90495417b5', licenceRef: '01/123', licenceDocument: { - licenceDocumentRoles: [{ - id: '3b903973-2143-47fe-b7a2-b205aa8eb933' - }] + licenceDocumentRoles: [ + { + id: '3b903973-2143-47fe-b7a2-b205aa8eb933' + } + ] } }) @@ -141,14 +143,8 @@ function _testFetchLicenceHistory () { return { id: testLicence.id, licenceRef: testLicence.licenceRef, - licenceVersions: [ - licenceVersions - ], - chargeVersions: [ - chargeVersions - ], - returnVersions: [ - returnVersions - ] + licenceVersions: [licenceVersions], + chargeVersions: [chargeVersions], + returnVersions: [returnVersions] } } diff --git a/test/services/licences/view-licence-points.service.test.js b/test/services/licences/view-licence-points.service.test.js index 1a15a83f6d..196e86b8b1 100644 --- a/test/services/licences/view-licence-points.service.test.js +++ b/test/services/licences/view-licence-points.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -36,7 +36,8 @@ describe('View Licence Points service', () => { category: 'Single Point', depth: '123', description: 'RIVER OUSE AT BLETSOE', - gridReference: 'Within the area formed by the straight lines running between National Grid References SD 963 193, SD 963 193, SD 963 193 and SD 963 193 (RIVER OUSE AT BLETSOE)', + gridReference: + 'Within the area formed by the straight lines running between National Grid References SD 963 193, SD 963 193, SD 963 193 and SD 963 193 (RIVER OUSE AT BLETSOE)', hydroInterceptDistance: '8.01', hydroOffsetDistance: '5.56', hydroReference: 'TL 14/133', @@ -56,7 +57,7 @@ describe('View Licence Points service', () => { }) }) -function _testFetchLicencePoints () { +function _testFetchLicencePoints() { const point = PointModel.fromJson({ bgsReference: 'TL 14/123', category: 'Single Point', diff --git a/test/services/licences/view-licence-purposes.service.test.js b/test/services/licences/view-licence-purposes.service.test.js index 368a8b6770..15184894ec 100644 --- a/test/services/licences/view-licence-purposes.service.test.js +++ b/test/services/licences/view-licence-purposes.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -41,9 +41,7 @@ describe('View Licence Purposes service', () => { abstractionMethods: 'Unspecified Pump', abstractionMethodsTitle: 'Method of abstraction', abstractionPeriod: '1 April to 31 October', - abstractionPoints: [ - 'At National Grid Reference TL 23198 88603' - ], + abstractionPoints: ['At National Grid Reference TL 23198 88603'], abstractionPointsTitle: 'Abstraction point', purposeDescription: 'Spray Irrigation - Storage' } @@ -55,46 +53,54 @@ describe('View Licence Purposes service', () => { }) }) -function _testFetchLicencePurposes () { +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, - licenceVersionPurposePoints: [{ - abstractionMethod: 'Unspecified Pump' - }], - 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' + 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, + licenceVersionPurposePoints: [ + { + abstractionMethod: 'Unspecified Pump' + } + ], + 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/view-licence-returns.service.test.js b/test/services/licences/view-licence-returns.service.test.js index 618a8abbeb..374aac09c0 100644 --- a/test/services/licences/view-licence-returns.service.test.js +++ b/test/services/licences/view-licence-returns.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub diff --git a/test/services/licences/view-licence-set-up.service.test.js b/test/services/licences/view-licence-set-up.service.test.js index 4631f9f8f7..1bab7aa4a2 100644 --- a/test/services/licences/view-licence-set-up.service.test.js +++ b/test/services/licences/view-licence-set-up.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -142,7 +142,8 @@ describe('View Licence Set Up service', () => { links: { agreements: {}, chargeInformation: { - makeLicenceNonChargeable: '/licences/2c80bd22-a005-4cf4-a2a2-73812a9861de/charge-information/non-chargeable-reason?start=1', + makeLicenceNonChargeable: + '/licences/2c80bd22-a005-4cf4-a2a2-73812a9861de/charge-information/non-chargeable-reason?start=1', setupNewCharge: '/licences/2c80bd22-a005-4cf4-a2a2-73812a9861de/charge-information/create' }, recalculateBills: {}, diff --git a/test/services/licences/view-licence-summary.service.test.js b/test/services/licences/view-licence-summary.service.test.js index d988400696..83531be10f 100644 --- a/test/services/licences/view-licence-summary.service.test.js +++ b/test/services/licences/view-licence-summary.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -62,10 +62,12 @@ describe('View Licence Summary service', () => { endDate: null, licenceId: 'f1288f6c-8503-4dc1-b114-75c408a14bd0', licenceHolder: 'Unregistered licence', - monitoringStations: [{ - id: 'ac075651-4781-4e24-a684-b943b98607ca', - label: 'MEVAGISSEY FIRE STATION' - }], + monitoringStations: [ + { + id: 'ac075651-4781-4e24-a684-b943b98607ca', + label: 'MEVAGISSEY FIRE STATION' + } + ], licenceName: 'fake licence', purposes: null, purposesCount: 0, @@ -78,7 +80,7 @@ describe('View Licence Summary service', () => { }) }) -function _testLicence () { +function _testLicence() { return LicenceModel.fromJson({ id: 'f1288f6c-8503-4dc1-b114-75c408a14bd0', expiredDate: null, @@ -88,13 +90,15 @@ function _testLicence () { displayName: 'Avalon' }, licenceVersions: [], - licenceMonitoringStations: [{ - id: 'f775f2cf-9b7c-4f1e-bb6f-6e81b34b1a8d', - monitoringStation: { - id: 'ac075651-4781-4e24-a684-b943b98607ca', - label: 'MEVAGISSEY FIRE STATION' + licenceMonitoringStations: [ + { + id: 'f775f2cf-9b7c-4f1e-bb6f-6e81b34b1a8d', + monitoringStation: { + id: 'ac075651-4781-4e24-a684-b943b98607ca', + label: 'MEVAGISSEY FIRE STATION' + } } - }], + ], licenceDocument: null, licenceDocumentHeader: { id: '28665d16-eba3-4c9a-aa55-7ab671b0c4fb' } }) diff --git a/test/services/licences/view-licence.service.test.js b/test/services/licences/view-licence.service.test.js index 3903b778a4..f3bb1d9c30 100644 --- a/test/services/licences/view-licence.service.test.js +++ b/test/services/licences/view-licence.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -61,14 +61,12 @@ describe('View Licence service', () => { describe('when a licence with a matching ID does not exist', () => { it('throws an exception', async () => { - await expect(ViewLicenceService.go('a45341d0-82c7-4a00-975c-e978a6f776eb', auth)) - .to - .reject() + await expect(ViewLicenceService.go('a45341d0-82c7-4a00-975c-e978a6f776eb', auth)).to.reject() }) }) }) -function _auth () { +function _auth() { return { credentials: { roles: [ @@ -91,7 +89,7 @@ function _auth () { } } -function _licence () { +function _licence() { const licence = LicenceModel.fromJson({ id: 'f1288f6c-8503-4dc1-b114-75c408a14bd0', expiredDate: null, diff --git a/test/services/monitoring-stations/fetch-monitoring-station.service.test.js b/test/services/monitoring-stations/fetch-monitoring-station.service.test.js index 29f102e3fa..ddfc0d7e67 100644 --- a/test/services/monitoring-stations/fetch-monitoring-station.service.test.js +++ b/test/services/monitoring-stations/fetch-monitoring-station.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/monitoring-stations/view.service.test.js b/test/services/monitoring-stations/view.service.test.js index cc4486ca62..ac6bf94844 100644 --- a/test/services/monitoring-stations/view.service.test.js +++ b/test/services/monitoring-stations/view.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -21,11 +21,7 @@ describe('Monitoring Stations - View service', () => { beforeEach(() => { auth = auth = { credentials: { - scope: [ - 'billing', - 'hof_notifications', - 'manage_gauging_station_licence_links' - ] + scope: ['billing', 'hof_notifications', 'manage_gauging_station_licence_links'] } } diff --git a/test/services/plugins/auth.service.test.js b/test/services/plugins/auth.service.test.js index 5957a2b0df..9f19af9299 100644 --- a/test/services/plugins/auth.service.test.js +++ b/test/services/plugins/auth.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things to stub @@ -21,12 +21,11 @@ describe('Auth service', () => { describe('when the user id is found', () => { beforeEach(() => { - Sinon.stub(FetchUserRolesAndGroupsService, 'go') - .resolves({ - user: { name: 'User' }, - roles: [{ role: 'Role' }], - groups: [{ group: 'Group' }] - }) + Sinon.stub(FetchUserRolesAndGroupsService, 'go').resolves({ + user: { name: 'User' }, + roles: [{ role: 'Role' }], + groups: [{ group: 'Group' }] + }) }) it('returns isValid as `true`', async () => { @@ -69,12 +68,11 @@ describe('Auth service', () => { describe('when the user has a top-level permission role', () => { describe('such as "ar_user"', () => { beforeEach(() => { - Sinon.stub(FetchUserRolesAndGroupsService, 'go') - .resolves({ - user: { name: 'User' }, - roles: [{ role: 'ar_user' }], - groups: [{ group: 'Group' }] - }) + Sinon.stub(FetchUserRolesAndGroupsService, 'go').resolves({ + user: { name: 'User' }, + roles: [{ role: 'ar_user' }], + groups: [{ group: 'Group' }] + }) }) it('returns the matching top level permission as true', async () => { @@ -86,12 +84,11 @@ describe('Auth service', () => { describe('such as "billing"', () => { beforeEach(() => { - Sinon.stub(FetchUserRolesAndGroupsService, 'go') - .resolves({ - user: { name: 'User' }, - roles: [{ role: 'billing' }], - groups: [{ group: 'Group' }] - }) + Sinon.stub(FetchUserRolesAndGroupsService, 'go').resolves({ + user: { name: 'User' }, + roles: [{ role: 'billing' }], + groups: [{ group: 'Group' }] + }) }) it('returns the matching top level permission as true', async () => { @@ -105,12 +102,11 @@ describe('Auth service', () => { describe('such as "returns"', () => { beforeEach(() => { - Sinon.stub(FetchUserRolesAndGroupsService, 'go') - .resolves({ - user: { name: 'User' }, - roles: [{ role: 'returns' }], - groups: [{ group: 'Group' }] - }) + Sinon.stub(FetchUserRolesAndGroupsService, 'go').resolves({ + user: { name: 'User' }, + roles: [{ role: 'returns' }], + groups: [{ group: 'Group' }] + }) }) it('returns the matching top level permission as true', async () => { @@ -123,12 +119,11 @@ describe('Auth service', () => { describe('when the user id is not found', () => { beforeEach(() => { - Sinon.stub(FetchUserRolesAndGroupsService, 'go') - .resolves({ - user: null, - roles: [], - groups: [] - }) + Sinon.stub(FetchUserRolesAndGroupsService, 'go').resolves({ + user: null, + roles: [], + groups: [] + }) }) it('returns isValid as "false"', async () => { diff --git a/test/services/plugins/error-pages.service.test.js b/test/services/plugins/error-pages.service.test.js index 76c557b9f0..6d8948afb6 100644 --- a/test/services/plugins/error-pages.service.test.js +++ b/test/services/plugins/error-pages.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -55,7 +55,7 @@ describe('Error pages service', () => { beforeEach(() => { request = { response: boom500Response, - route: { settings: { } }, + route: { settings: {} }, path } }) @@ -103,7 +103,7 @@ describe('Error pages service', () => { beforeEach(() => { request = { response: boom404Response, - route: { settings: { } }, + route: { settings: {} }, path } }) @@ -145,7 +145,7 @@ describe('Error pages service', () => { beforeEach(() => { request = { response: boom403Response, - route: { settings: { } }, + route: { settings: {} }, path } }) @@ -193,7 +193,7 @@ describe('Error pages service', () => { beforeEach(() => { request = { response: standardResponse, - route: { settings: { } }, + route: { settings: {} }, path } }) diff --git a/test/services/plugins/filter-routes.service.test.js b/test/services/plugins/filter-routes.service.test.js index 2f26953b8a..59bd08bdcd 100644 --- a/test/services/plugins/filter-routes.service.test.js +++ b/test/services/plugins/filter-routes.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code const Hoek = require('@hapi/hoek') diff --git a/test/services/plugins/hapi-pino-ignore-request.service.test.js b/test/services/plugins/hapi-pino-ignore-request.service.test.js index d7f7763489..8300fed5fe 100644 --- a/test/services/plugins/hapi-pino-ignore-request.service.test.js +++ b/test/services/plugins/hapi-pino-ignore-request.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -38,7 +38,10 @@ describe('Hapi Pino Ignore Request service', () => { describe('when the request is for an asset', () => { describe('and LOG_ASSET_REQUESTS is false', () => { it('returns true', () => { - const result = HapiPinoIgnoreRequestService.go({ logAssetRequests: false }, { path: '/assets/stylesheets/application.css' }) + const result = HapiPinoIgnoreRequestService.go( + { logAssetRequests: false }, + { path: '/assets/stylesheets/application.css' } + ) expect(result).to.be.true() }) @@ -46,7 +49,10 @@ describe('Hapi Pino Ignore Request service', () => { describe('and LOG_ASSET_REQUESTS is true', () => { it('returns false', () => { - const result = HapiPinoIgnoreRequestService.go({ logAssetRequests: true }, { path: '/assets/stylesheets/application.css' }) + const result = HapiPinoIgnoreRequestService.go( + { logAssetRequests: true }, + { path: '/assets/stylesheets/application.css' } + ) expect(result).to.be.false() }) diff --git a/test/services/plugins/hapi-pino-log-in-test.service.test.js b/test/services/plugins/hapi-pino-log-in-test.service.test.js index ad3dc11ebd..0d389c3bd5 100644 --- a/test/services/plugins/hapi-pino-log-in-test.service.test.js +++ b/test/services/plugins/hapi-pino-log-in-test.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/plugins/payload-cleaning.service.test.js b/test/services/plugins/payload-cleaning.service.test.js index 70e83cb238..8cb1f61325 100644 --- a/test/services/plugins/payload-cleaning.service.test.js +++ b/test/services/plugins/payload-cleaning.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/services/return-versions/fetch-return-version.service.test.js b/test/services/return-versions/fetch-return-version.service.test.js index 37469d9c6d..480322081c 100644 --- a/test/services/return-versions/fetch-return-version.service.test.js +++ b/test/services/return-versions/fetch-return-version.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/return-versions/setup/abstraction-period.service.test.js b/test/services/return-versions/setup/abstraction-period.service.test.js index b74408486e..78b8236792 100644 --- a/test/services/return-versions/setup/abstraction-period.service.test.js +++ b/test/services/return-versions/setup/abstraction-period.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,14 +48,17 @@ describe('Return Versions Setup - Abstraction Period service', () => { it('returns page data for the view', async () => { const result = await AbstractionPeriodService.go(session.id, requirementIndex) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Enter the abstraction period for the requirements for returns', - abstractionPeriod: null, - backLink: `/system/return-versions/setup/${session.id}/points/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC' - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Enter the abstraction period for the requirements for returns', + abstractionPeriod: null, + backLink: `/system/return-versions/setup/${session.id}/points/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC' + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/add.service.test.js b/test/services/return-versions/setup/add.service.test.js index 7cfded55f4..ee6cd6bea3 100644 --- a/test/services/return-versions/setup/add.service.test.js +++ b/test/services/return-versions/setup/add.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/return-versions/setup/additional-submission-options.service.test.js b/test/services/return-versions/setup/additional-submission-options.service.test.js index 659a66282d..27a6fd6d19 100644 --- a/test/services/return-versions/setup/additional-submission-options.service.test.js +++ b/test/services/return-versions/setup/additional-submission-options.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,17 +48,20 @@ describe('Return Versions Setup - Additional Submission Options service', () => it('returns page data for the view', async () => { const result = await AdditionalSubmissionOptionsService.go(session.id) - expect(result).to.equal({ - multipleUpload: false, - noAdditionalOptions: undefined, - quarterlyReturnSubmissions: false, - quarterlyReturns: undefined, - activeNavBar: 'search', - backLink: `/system/return-versions/setup/${session.id}/check`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC', - pageTitle: 'Select any additional submission options for the return requirements' - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + multipleUpload: false, + noAdditionalOptions: undefined, + quarterlyReturnSubmissions: false, + quarterlyReturns: undefined, + activeNavBar: 'search', + backLink: `/system/return-versions/setup/${session.id}/check`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC', + pageTitle: 'Select any additional submission options for the return requirements' + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/agreements-exceptions.service.test.js b/test/services/return-versions/setup/agreements-exceptions.service.test.js index c45c54c753..f37820a346 100644 --- a/test/services/return-versions/setup/agreements-exceptions.service.test.js +++ b/test/services/return-versions/setup/agreements-exceptions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -48,14 +48,17 @@ describe('Return Versions Setup - Agreements Exceptions service', () => { it('returns page data for the view', async () => { const result = await AgreementsExceptionsService.go(session.id, requirementIndex) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select agreements and exceptions for the requirements for returns', - agreementsExceptions: null, - backLink: `/system/return-versions/setup/${session.id}/frequency-reported/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC' - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select agreements and exceptions for the requirements for returns', + agreementsExceptions: null, + backLink: `/system/return-versions/setup/${session.id}/frequency-reported/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC' + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/cancel.service.test.js b/test/services/return-versions/setup/cancel.service.test.js index 432bd35992..344dd9dcf7 100644 --- a/test/services/return-versions/setup/cancel.service.test.js +++ b/test/services/return-versions/setup/cancel.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -31,23 +31,23 @@ describe('Return Versions Setup - Cancel service', () => { startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', - requirements: [{ - points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], - purposes: [{ alias: '', description: 'Mineral Washing', id: '3a865331-d2f3-4acc-ac85-527fa2b0d2dd' }], - returnsCycle: 'winter-and-all-year', - siteDescription: 'Bore hole in rear field', - abstractionPeriod: { - 'end-abstraction-period-day': '31', - 'end-abstraction-period-month': '10', - 'start-abstraction-period-day': '1', - 'start-abstraction-period-month': '4' - }, - frequencyReported: 'month', - frequencyCollected: 'month', - agreementsExceptions: [ - 'none' - ] - }], + requirements: [ + { + points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], + purposes: [{ alias: '', description: 'Mineral Washing', id: '3a865331-d2f3-4acc-ac85-527fa2b0d2dd' }], + returnsCycle: 'winter-and-all-year', + siteDescription: 'Bore hole in rear field', + abstractionPeriod: { + 'end-abstraction-period-day': '31', + 'end-abstraction-period-month': '10', + 'start-abstraction-period-day': '1', + 'start-abstraction-period-month': '4' + }, + frequencyReported: 'month', + frequencyCollected: 'month', + agreementsExceptions: ['none'] + } + ], startDateOptions: 'licenceStartDate', reason: 'major-change' } diff --git a/test/services/return-versions/setup/check/check.service.test.js b/test/services/return-versions/setup/check/check.service.test.js index 4b52e9eb74..240652660b 100644 --- a/test/services/return-versions/setup/check/check.service.test.js +++ b/test/services/return-versions/setup/check/check.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -59,29 +59,32 @@ describe('Return Versions Setup - Check service', () => { it('returns page data for the view', async () => { const result = await CheckService.go(session.id, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - licenceRef: '01/ABC', - multipleUpload: false, - note: { - actions: [ - { - href: 'note', - text: 'Add a note' - } - ], - text: 'No notes added' + expect(result).to.equal( + { + activeNavBar: 'search', + licenceRef: '01/ABC', + multipleUpload: false, + note: { + actions: [ + { + href: 'note', + text: 'Add a note' + } + ], + text: 'No notes added' + }, + notification: undefined, + pageTitle: 'Check the requirements for returns for Turbo Kid', + quarterlyReturnSubmissions: false, + quarterlyReturns: undefined, + reason: 'Major change', + reasonLink: `/system/return-versions/setup/${session.id}/reason`, + requirements: [], + returnsRequired: true, + startDate: '1 January 2023' }, - notification: undefined, - pageTitle: 'Check the requirements for returns for Turbo Kid', - quarterlyReturnSubmissions: false, - quarterlyReturns: undefined, - reason: 'Major change', - reasonLink: `/system/return-versions/setup/${session.id}/reason`, - requirements: [], - returnsRequired: true, - startDate: '1 January 2023' - }, { skip: ['sessionId'] }) + { skip: ['sessionId'] } + ) }) it('updates the session record to indicate user has visited the "check" page', async () => { diff --git a/test/services/return-versions/setup/check/generate-return-version-requirements.service.test.js b/test/services/return-versions/setup/check/generate-return-version-requirements.service.test.js index a31f92efb3..102c99e0e6 100644 --- a/test/services/return-versions/setup/check/generate-return-version-requirements.service.test.js +++ b/test/services/return-versions/setup/check/generate-return-version-requirements.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -170,12 +170,10 @@ describe('Return Versions Setup - Generate Return Version Requirements service', }) }) -function _generateRequirements (purposeOneId, purposeTwoId) { +function _generateRequirements(purposeOneId, purposeTwoId) { const requirements = [ { - points: [ - '796f83bb-d50d-446f-bc47-28daff6bcb78' - ], + points: ['796f83bb-d50d-446f-bc47-28daff6bcb78'], purposes: [ { id: purposeOneId, @@ -192,17 +190,12 @@ function _generateRequirements (purposeOneId, purposeTwoId) { }, frequencyReported: 'month', frequencyCollected: 'week', - agreementsExceptions: [ - 'none' - ] + agreementsExceptions: ['none'] } ] const additionalRequirements = { - points: [ - '30070341-ef94-4df8-87dd-31d51a046b8b', - '916a1320-0f57-43b2-bddc-b609218abf1c' - ], + points: ['30070341-ef94-4df8-87dd-31d51a046b8b', '916a1320-0f57-43b2-bddc-b609218abf1c'], purposes: [ { id: purposeOneId, @@ -225,12 +218,7 @@ function _generateRequirements (purposeOneId, purposeTwoId) { }, frequencyReported: 'day', frequencyCollected: 'day', - agreementsExceptions: [ - 'gravity-fill', - 'transfer-re-abstraction-scheme', - 'two-part-tariff', - '56-returns-exception' - ] + agreementsExceptions: ['gravity-fill', 'transfer-re-abstraction-scheme', 'two-part-tariff', '56-returns-exception'] } if (purposeTwoId) { diff --git a/test/services/return-versions/setup/check/generate-return-version.service.test.js b/test/services/return-versions/setup/check/generate-return-version.service.test.js index 321a856081..79eee99ceb 100644 --- a/test/services/return-versions/setup/check/generate-return-version.service.test.js +++ b/test/services/return-versions/setup/check/generate-return-version.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/return-versions/setup/check/persist-return-version.service.test.js b/test/services/return-versions/setup/check/persist-return-version.service.test.js index 3c2b093669..02485c7111 100644 --- a/test/services/return-versions/setup/check/persist-return-version.service.test.js +++ b/test/services/return-versions/setup/check/persist-return-version.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -30,8 +30,10 @@ describe('Return Versions Setup - Persist Return Version service', () => { it('persists the data to the tables required to create a new Return Version', async () => { await PersistReturnVersionService.go(returnVersionData) - const returnVersion = await ReturnVersionModel.query() - .where('licenceId', returnVersionData.returnVersion.licenceId) + const returnVersion = await ReturnVersionModel.query().where( + 'licenceId', + returnVersionData.returnVersion.licenceId + ) expect(returnVersion).to.have.length(1) expect(returnVersion[0].createdBy).to.equal(returnVersionData.returnVersion.createdBy) @@ -65,15 +67,19 @@ describe('Return Versions Setup - Persist Return Version service', () => { expect(returnRequirement[0].summer).to.equal(requirementData.summer) expect(returnRequirement[0].twoPartTariff).to.equal(requirementData.twoPartTariff) - const returnRequirementPoint = await ReturnRequirementPointModel.query() - .where('returnRequirementId', returnRequirement[0].id) + const returnRequirementPoint = await ReturnRequirementPointModel.query().where( + 'returnRequirementId', + returnRequirement[0].id + ) const pointData = returnVersionData.returnRequirements[0].points[0] expect(returnRequirementPoint).to.have.length(1) expect(returnRequirementPoint[0].pointId).to.equal(pointData) - const returnRequirementPurpose = await ReturnRequirementPurposeModel.query() - .where('returnRequirementId', returnRequirement[0].id) + const returnRequirementPurpose = await ReturnRequirementPurposeModel.query().where( + 'returnRequirementId', + returnRequirement[0].id + ) const purposeData = returnVersionData.returnRequirements[0].returnRequirementPurposes[0] expect(returnRequirementPurpose).to.have.length(1) @@ -85,7 +91,7 @@ describe('Return Versions Setup - Persist Return Version service', () => { }) }) -function _generateReturnVersionData () { +function _generateReturnVersionData() { return { returnRequirements: [ { diff --git a/test/services/return-versions/setup/check/process-existing-return-versions.service.test.js b/test/services/return-versions/setup/check/process-existing-return-versions.service.test.js index 75f1e30aba..1ed8bc58c9 100644 --- a/test/services/return-versions/setup/check/process-existing-return-versions.service.test.js +++ b/test/services/return-versions/setup/check/process-existing-return-versions.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/return-versions/setup/check/submit-check.service.test.js b/test/services/return-versions/setup/check/submit-check.service.test.js index bbdb054ff9..ef1e436a3c 100644 --- a/test/services/return-versions/setup/check/submit-check.service.test.js +++ b/test/services/return-versions/setup/check/submit-check.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/return-versions/setup/delete-note.service.test.js b/test/services/return-versions/setup/delete-note.service.test.js index a0742bf75f..c95dafaa67 100644 --- a/test/services/return-versions/setup/delete-note.service.test.js +++ b/test/services/return-versions/setup/delete-note.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/return-versions/setup/existing/existing.service.test.js b/test/services/return-versions/setup/existing/existing.service.test.js index 27294de92c..ea783c5d0b 100644 --- a/test/services/return-versions/setup/existing/existing.service.test.js +++ b/test/services/return-versions/setup/existing/existing.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -26,12 +26,14 @@ describe('Return Versions Setup - Existing service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -51,13 +53,16 @@ describe('Return Versions Setup - Existing service', () => { it('returns page data for the view', async () => { const result = await ExistingService.go(session.id) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Use previous requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/method`, - existingOptions: [{ value: '60b5d10d-1372-4fb2-b222-bfac81da69ab', text: '1 January 2023' }], - licenceRef: '01/ABC' - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Use previous requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/method`, + existingOptions: [{ value: '60b5d10d-1372-4fb2-b222-bfac81da69ab', text: '1 January 2023' }], + licenceRef: '01/ABC' + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/existing/fetch-existing-requirements.service.test.js b/test/services/return-versions/setup/existing/fetch-existing-requirements.service.test.js index 06098bf2f4..285230a64b 100644 --- a/test/services/return-versions/setup/existing/fetch-existing-requirements.service.test.js +++ b/test/services/return-versions/setup/existing/fetch-existing-requirements.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/return-versions/setup/existing/generate-from-existing-requirements.service.test.js b/test/services/return-versions/setup/existing/generate-from-existing-requirements.service.test.js index 714119e733..aef02386df 100644 --- a/test/services/return-versions/setup/existing/generate-from-existing-requirements.service.test.js +++ b/test/services/return-versions/setup/existing/generate-from-existing-requirements.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Things we need to stub @@ -37,11 +37,13 @@ describe('Return Versions Setup - Generate From Existing Requirements service', expect(result).to.equal([ { points: [fetchResult.returnRequirements[0].points[0].id], - purposes: [{ - alias: fetchResult.returnRequirements[0].returnRequirementPurposes[0].alias, - description: 'Spray Irrigation - Storage', - id: fetchResult.returnRequirements[0].returnRequirementPurposes[0].purposeId - }], + purposes: [ + { + alias: fetchResult.returnRequirements[0].returnRequirementPurposes[0].alias, + description: 'Spray Irrigation - Storage', + id: fetchResult.returnRequirements[0].returnRequirementPurposes[0].purposeId + } + ], returnsCycle: 'winter-and-all-year', siteDescription: 'FIRST BOREHOLE AT AVALON', abstractionPeriod: { @@ -56,11 +58,13 @@ describe('Return Versions Setup - Generate From Existing Requirements service', }, { points: [fetchResult.returnRequirements[1].points[0].id], - purposes: [{ - alias: '', - description: 'Spray Irrigation - Storage', - id: fetchResult.returnRequirements[1].returnRequirementPurposes[0].purposeId - }], + purposes: [ + { + alias: '', + description: 'Spray Irrigation - Storage', + id: fetchResult.returnRequirements[1].returnRequirementPurposes[0].purposeId + } + ], returnsCycle: 'summer', siteDescription: 'SECOND BOREHOLE AT AVALON', abstractionPeriod: { @@ -96,11 +100,13 @@ describe('Return Versions Setup - Generate From Existing Requirements service', expect(result).to.equal([ { points: [fetchResult.returnRequirements[0].points[0].id], - purposes: [{ - alias: fetchResult.returnRequirements[0].returnRequirementPurposes[0].alias, - description: 'Spray Irrigation - Storage', - id: fetchResult.returnRequirements[0].returnRequirementPurposes[0].purposeId - }], + purposes: [ + { + alias: fetchResult.returnRequirements[0].returnRequirementPurposes[0].alias, + description: 'Spray Irrigation - Storage', + id: fetchResult.returnRequirements[0].returnRequirementPurposes[0].purposeId + } + ], returnsCycle: 'winter-and-all-year', siteDescription: 'FIRST BOREHOLE AT AVALON', abstractionPeriod: { @@ -115,11 +121,13 @@ describe('Return Versions Setup - Generate From Existing Requirements service', }, { points: [fetchResult.returnRequirements[1].points[0].id], - purposes: [{ - alias: '', - description: 'Spray Irrigation - Storage', - id: fetchResult.returnRequirements[1].returnRequirementPurposes[0].purposeId - }], + purposes: [ + { + alias: '', + description: 'Spray Irrigation - Storage', + id: fetchResult.returnRequirements[1].returnRequirementPurposes[0].purposeId + } + ], returnsCycle: 'summer', siteDescription: 'WELL AT WELLINGTON', abstractionPeriod: { @@ -144,14 +152,12 @@ describe('Return Versions Setup - Generate From Existing Requirements service', describe('when a matching return version does not exist', () => { it('throws an error', async () => { - await expect(GenerateFromExistingRequirementsService.go('6d436e7b-c3c9-493c-97f3-b397c899c926')) - .to - .reject() + await expect(GenerateFromExistingRequirementsService.go('6d436e7b-c3c9-493c-97f3-b397c899c926')).to.reject() }) }) }) -function _fetchResult (returnVersionId) { +function _fetchResult(returnVersionId) { return { id: returnVersionId, returnRequirements: [ diff --git a/test/services/return-versions/setup/existing/submit-existing.service.test.js b/test/services/return-versions/setup/existing/submit-existing.service.test.js index a6d1367f2d..7661c78aeb 100644 --- a/test/services/return-versions/setup/existing/submit-existing.service.test.js +++ b/test/services/return-versions/setup/existing/submit-existing.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,12 +32,14 @@ describe('Return Versions Setup - Submit Existing service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -86,13 +88,16 @@ describe('Return Versions Setup - Submit Existing service', () => { it('returns page data for the view', async () => { const result = await SubmitExistingService.go(session.id, payload) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Use previous requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/method`, - existingOptions: [{ value: '60b5d10d-1372-4fb2-b222-bfac81da69ab', text: '1 January 2023' }], - licenceRef: '01/ABC' - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Use previous requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/method`, + existingOptions: [{ value: '60b5d10d-1372-4fb2-b222-bfac81da69ab', text: '1 January 2023' }], + licenceRef: '01/ABC' + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { @@ -106,7 +111,7 @@ describe('Return Versions Setup - Submit Existing service', () => { }) }) -function _transformedReturnRequirement () { +function _transformedReturnRequirement() { return { points: ['1234'], purposes: ['1a1a68cc-b1f5-43db-8d1a-3452425bcc68'], diff --git a/test/services/return-versions/setup/fetch-points.service.test.js b/test/services/return-versions/setup/fetch-points.service.test.js index 839377ff3d..df494d2c57 100644 --- a/test/services/return-versions/setup/fetch-points.service.test.js +++ b/test/services/return-versions/setup/fetch-points.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, before } = exports.lab = Lab.script() +const { describe, it, before } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers diff --git a/test/services/return-versions/setup/fetch-purposes.service.test.js b/test/services/return-versions/setup/fetch-purposes.service.test.js index e49c60c366..b59af78422 100644 --- a/test/services/return-versions/setup/fetch-purposes.service.test.js +++ b/test/services/return-versions/setup/fetch-purposes.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -25,9 +25,21 @@ describe('Return Versions Setup - Fetch Purposes service', () => { // we purposefully don't add them in alphabetical order so we can test they get sorted by the service purposes = [ - { ...PurposeHelper.data.find((purpose) => { return purpose.description === 'Large Garden Watering' }) }, - { ...PurposeHelper.data.find((purpose) => { return purpose.description === 'Heat Pump' }) }, - { ...PurposeHelper.data.find((purpose) => { return purpose.description === 'Horticultural Watering' }) } + { + ...PurposeHelper.data.find((purpose) => { + return purpose.description === 'Large Garden Watering' + }) + }, + { + ...PurposeHelper.data.find((purpose) => { + return purpose.description === 'Heat Pump' + }) + }, + { + ...PurposeHelper.data.find((purpose) => { + return purpose.description === 'Horticultural Watering' + }) + } ] // Create the licenceVersionPurposes. Note - two of them are for the same purpose. This is common in the service diff --git a/test/services/return-versions/setup/frequency-collected.service.test.js b/test/services/return-versions/setup/frequency-collected.service.test.js index 68d2ab4ef4..d52cd8d59d 100644 --- a/test/services/return-versions/setup/frequency-collected.service.test.js +++ b/test/services/return-versions/setup/frequency-collected.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -28,12 +28,14 @@ describe('Return Versions Setup - Frequency Collected service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -54,14 +56,17 @@ describe('Return Versions Setup - Frequency Collected service', () => { it('returns page data for the view', async () => { const result = await FrequencyCollectedService.go(session.id, requirementIndex) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select how often readings or volumes are collected', - backLink: `/system/return-versions/setup/${session.id}/site-description/0`, - frequencyCollected: null, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC' - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select how often readings or volumes are collected', + backLink: `/system/return-versions/setup/${session.id}/site-description/0`, + frequencyCollected: null, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC' + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/frequency-reported.service.test.js b/test/services/return-versions/setup/frequency-reported.service.test.js index 6c5cfc99f9..eb28684a2d 100644 --- a/test/services/return-versions/setup/frequency-reported.service.test.js +++ b/test/services/return-versions/setup/frequency-reported.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -28,12 +28,14 @@ describe('Return Versions Setup - Frequency Reported service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -54,14 +56,17 @@ describe('Return Versions Setup - Frequency Reported service', () => { it('returns page data for the view', async () => { const result = await FrequencyReportedService.go(session.id, requirementIndex) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select how often readings or volumes are reported', - backLink: `/system/return-versions/setup/${session.id}/frequency-collected/0`, - frequencyReported: null, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC' - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select how often readings or volumes are reported', + backLink: `/system/return-versions/setup/${session.id}/frequency-collected/0`, + frequencyReported: null, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC' + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/initiate-session.service.test.js b/test/services/return-versions/setup/initiate-session.service.test.js index 1422819d7e..9a1830ed99 100644 --- a/test/services/return-versions/setup/initiate-session.service.test.js +++ b/test/services/return-versions/setup/initiate-session.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -40,10 +40,13 @@ describe('Return Versions Setup - Initiate Session service', () => { // Create two licence versions so we can test the service only gets the 'current' version await LicenceVersionHelper.add({ - licenceId: licence.id, startDate: new Date('2021-10-11'), status: 'superseded' + licenceId: licence.id, + startDate: new Date('2021-10-11'), + status: 'superseded' }) await LicenceVersionHelper.add({ - licenceId: licence.id, startDate: new Date('2022-05-01') + licenceId: licence.id, + startDate: new Date('2022-05-01') }) // Create a licence holder for the licence with the default name 'Licence Holder Ltd' @@ -55,28 +58,32 @@ describe('Return Versions Setup - Initiate Session service', () => { const { data } = result - expect(data).to.equal({ - checkPageVisited: false, - licence: { - id: licence.id, - currentVersionStartDate: new Date('2022-05-01'), - endDate: new Date('2024-08-10'), - licenceRef, - licenceHolder: 'Licence Holder Ltd', - returnVersions: [], - startDate: new Date('2022-01-01'), - waterUndertaker: false + expect(data).to.equal( + { + checkPageVisited: false, + licence: { + id: licence.id, + currentVersionStartDate: new Date('2022-05-01'), + endDate: new Date('2024-08-10'), + licenceRef, + licenceHolder: 'Licence Holder Ltd', + returnVersions: [], + startDate: new Date('2022-01-01'), + waterUndertaker: false + }, + multipleUpload: false, + journey: 'returns-required', + requirements: [{}] }, - multipleUpload: false, - journey: 'returns-required', - requirements: [{}] - }, { skip: ['id'] }) + { skip: ['id'] } + ) }) describe('and has return versions with return requirements to copy from', () => { beforeEach(async () => { const returnVersion = await ReturnVersionHelper.add({ - licenceId: licence.id, startDate: new Date('2022-05-01') + licenceId: licence.id, + startDate: new Date('2022-05-01') }) returnVersionId = returnVersion.id @@ -90,19 +97,23 @@ describe('Return Versions Setup - Initiate Session service', () => { const { returnVersions } = result.data.licence - expect(returnVersions).to.equal([{ - id: returnVersionId, - reason: 'new-licence', - startDate: new Date('2022-05-01'), - modLogs: [{ id: modLog.id, reasonDescription: modLog.reasonDescription }] - }]) + expect(returnVersions).to.equal([ + { + id: returnVersionId, + reason: 'new-licence', + startDate: new Date('2022-05-01'), + modLogs: [{ id: modLog.id, reasonDescription: modLog.reasonDescription }] + } + ]) }) }) describe('and has return versions but they are not "current" (so cannot be copied from)', () => { beforeEach(async () => { const returnVersion = await ReturnVersionHelper.add({ - licenceId: licence.id, startDate: new Date('2021-10-11'), status: 'superseded' + licenceId: licence.id, + startDate: new Date('2021-10-11'), + status: 'superseded' }) returnVersionId = returnVersion.id @@ -122,7 +133,10 @@ describe('Return Versions Setup - Initiate Session service', () => { describe('and has return versions but they do not have requirements (so cannot be copied from)', () => { beforeEach(async () => { await ReturnVersionHelper.add({ - licenceId: licence.id, reason: 'returns-exception', startDate: new Date('2021-10-11'), status: 'current' + licenceId: licence.id, + reason: 'returns-exception', + startDate: new Date('2021-10-11'), + status: 'current' }) }) @@ -148,7 +162,9 @@ describe('Return Versions Setup - Initiate Session service', () => { describe('but the licence does not exist', () => { it('throws a Boom not found error', async () => { - const error = await expect(InitiateSessionService.go('e456e538-4d55-4552-84f7-6a7636eb1945', 'journey')).to.reject() + const error = await expect( + InitiateSessionService.go('e456e538-4d55-4552-84f7-6a7636eb1945', 'journey') + ).to.reject() expect(error.isBoom).to.be.true() expect(error.data).to.equal({ id: 'e456e538-4d55-4552-84f7-6a7636eb1945' }) diff --git a/test/services/return-versions/setup/method/fetch-abstraction-data.service.test.js b/test/services/return-versions/setup/method/fetch-abstraction-data.service.test.js index bfda20ae7d..66b0d22ccb 100644 --- a/test/services/return-versions/setup/method/fetch-abstraction-data.service.test.js +++ b/test/services/return-versions/setup/method/fetch-abstraction-data.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -44,8 +44,16 @@ describe('Return Versions Setup - Fetch Abstraction Data service', () => { dailyQuantity: 455, externalId: seedData.licenceVersionPurposes.electricity.externalId, primaryPurpose: { id: seedData.allPurposes.primaryPurposes.primaryElectricityId, legacyId: 'P' }, - purpose: { description: 'Heat Pump', id: seedData.allPurposes.purposes.heatPumpId, legacyId: '200', twoPartTariff: false }, - secondaryPurpose: { id: seedData.allPurposes.secondaryPurposes.secondaryElectricityId, legacyId: 'ELC' }, + purpose: { + description: 'Heat Pump', + id: seedData.allPurposes.purposes.heatPumpId, + legacyId: '200', + twoPartTariff: false + }, + secondaryPurpose: { + id: seedData.allPurposes.secondaryPurposes.secondaryElectricityId, + legacyId: 'ELC' + }, points: [ { description: 'INTAKE POINT', @@ -66,8 +74,16 @@ describe('Return Versions Setup - Fetch Abstraction Data service', () => { dailyQuantity: 2675, externalId: seedData.licenceVersionPurposes.standard.externalId, primaryPurpose: { id: seedData.allPurposes.primaryPurposes.primaryAgricultureId, legacyId: 'A' }, - purpose: { description: 'Vegetable Washing', id: seedData.allPurposes.purposes.vegetableWashingId, legacyId: '460', twoPartTariff: false }, - secondaryPurpose: { id: seedData.allPurposes.secondaryPurposes.secondaryAgricultureId, legacyId: 'AGR' }, + purpose: { + description: 'Vegetable Washing', + id: seedData.allPurposes.purposes.vegetableWashingId, + legacyId: '460', + twoPartTariff: false + }, + secondaryPurpose: { + id: seedData.allPurposes.secondaryPurposes.secondaryAgricultureId, + legacyId: 'AGR' + }, points: [ { description: 'SOUTH BOREHOLE', @@ -84,8 +100,16 @@ describe('Return Versions Setup - Fetch Abstraction Data service', () => { dailyQuantity: 300, externalId: seedData.licenceVersionPurposes.twoPartTariff.externalId, primaryPurpose: { id: seedData.allPurposes.primaryPurposes.primaryAgricultureId, legacyId: 'A' }, - purpose: { description: 'Spray Irrigation - Direct', id: seedData.allPurposes.purposes.sprayIrrigationDirectId, legacyId: '400', twoPartTariff: true }, - secondaryPurpose: { id: seedData.allPurposes.secondaryPurposes.secondaryAgricultureId, legacyId: 'AGR' }, + purpose: { + description: 'Spray Irrigation - Direct', + id: seedData.allPurposes.purposes.sprayIrrigationDirectId, + legacyId: '400', + twoPartTariff: true + }, + secondaryPurpose: { + id: seedData.allPurposes.secondaryPurposes.secondaryAgricultureId, + legacyId: 'AGR' + }, points: [ { description: 'MAIN INTAKE', diff --git a/test/services/return-versions/setup/method/generate-from-abstraction-data.service.test.js b/test/services/return-versions/setup/method/generate-from-abstraction-data.service.test.js index fc91ca3954..e9519014a3 100644 --- a/test/services/return-versions/setup/method/generate-from-abstraction-data.service.test.js +++ b/test/services/return-versions/setup/method/generate-from-abstraction-data.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -39,9 +39,13 @@ describe('Return Versions Setup - Generate From Abstraction Data service', () => expect(result).to.equal([ { points: ['d60b0dfe-ef2b-4bc2-a963-b74b25433127', '6c664140-f7ee-4e98-aa88-74590d3fd8fb'], - purposes: [{ - alias: '', description: 'Heat Pump', id: '24939b40-a187-4bd1-9222-f552a3af6368' - }], + purposes: [ + { + alias: '', + description: 'Heat Pump', + id: '24939b40-a187-4bd1-9222-f552a3af6368' + } + ], returnsCycle: 'summer', siteDescription: 'INTAKE POINT', abstractionPeriod: { @@ -56,11 +60,13 @@ describe('Return Versions Setup - Generate From Abstraction Data service', () => }, { points: ['554cd6c5-5bfe-4133-9828-2f10aa6ac5f8'], - purposes: [{ - alias: '', - description: 'Spray Irrigation - Direct', - id: '76c8c08c-4fef-421a-83d6-16d8000311a4' - }], + purposes: [ + { + alias: '', + description: 'Spray Irrigation - Direct', + id: '76c8c08c-4fef-421a-83d6-16d8000311a4' + } + ], returnsCycle: 'winter-and-all-year', siteDescription: 'MAIN INTAKE', abstractionPeriod: { @@ -75,11 +81,13 @@ describe('Return Versions Setup - Generate From Abstraction Data service', () => }, { points: ['bf6a409e-7882-4c5d-9e49-2ebae2936576'], - purposes: [{ - alias: '', - description: 'Vegetable Washing', - id: 'e5b3b9bc-59c5-46d3-b019-5cf5467d4f0f' - }], + purposes: [ + { + alias: '', + description: 'Vegetable Washing', + id: 'e5b3b9bc-59c5-46d3-b019-5cf5467d4f0f' + } + ], returnsCycle: 'winter-and-all-year', siteDescription: 'SOUTH BOREHOLE', abstractionPeriod: { @@ -158,14 +166,12 @@ describe('Return Versions Setup - Generate From Abstraction Data service', () => describe('when called with a licence ID that does not exists', () => { it('throws an error', async () => { - await expect(GenerateFromAbstractionDataService.go('fc29a098-c1ab-4a2b-bc31-b713cccc505d')) - .to - .reject() + await expect(GenerateFromAbstractionDataService.go('fc29a098-c1ab-4a2b-bc31-b713cccc505d')).to.reject() }) }) }) -function _fetchResult (licenceId) { +function _fetchResult(licenceId) { return LicenceModel.fromJson({ id: licenceId, waterUndertaker: false, @@ -215,9 +221,7 @@ function _fetchResult (licenceId) { twoPartTariff: false }, secondaryPurpose: { id: '827f5181-1acc-452a-aea3-a1d72a21604b', legacyId: 'AGR' }, - points: [ - { description: 'SOUTH BOREHOLE', id: 'bf6a409e-7882-4c5d-9e49-2ebae2936576' } - ] + points: [{ description: 'SOUTH BOREHOLE', id: 'bf6a409e-7882-4c5d-9e49-2ebae2936576' }] }), LicenceVersionPurposeModel.fromJson({ id: '1255bf65-fcfd-4b28-a48a-b8ec2e7820b0', @@ -235,9 +239,7 @@ function _fetchResult (licenceId) { twoPartTariff: true }, secondaryPurpose: { id: '827f5181-1acc-452a-aea3-a1d72a21604b', legacyId: 'AGR' }, - points: [ - { description: 'MAIN INTAKE', id: '554cd6c5-5bfe-4133-9828-2f10aa6ac5f8' } - ] + points: [{ description: 'MAIN INTAKE', id: '554cd6c5-5bfe-4133-9828-2f10aa6ac5f8' }] }) ] } diff --git a/test/services/return-versions/setup/method/method.service.test.js b/test/services/return-versions/setup/method/method.service.test.js index 09a51881e0..1d219279c3 100644 --- a/test/services/return-versions/setup/method/method.service.test.js +++ b/test/services/return-versions/setup/method/method.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -26,11 +26,13 @@ describe('Return Versions Setup - Method service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -51,14 +53,17 @@ describe('Return Versions Setup - Method service', () => { it('returns page data for the view', async () => { const result = await MethodService.go(session.id) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'How do you want to set up the requirements for returns?', - backLink: `/system/return-versions/setup/${session.id}/reason`, - displayCopyExisting: true, - licenceRef: '01/ABC', - method: null - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'How do you want to set up the requirements for returns?', + backLink: `/system/return-versions/setup/${session.id}/reason`, + displayCopyExisting: true, + licenceRef: '01/ABC', + method: null + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/method/submit-method.service.test.js b/test/services/return-versions/setup/method/submit-method.service.test.js index 19f072d435..669cc024c0 100644 --- a/test/services/return-versions/setup/method/submit-method.service.test.js +++ b/test/services/return-versions/setup/method/submit-method.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -31,11 +31,13 @@ describe('Return Versions Setup - Submit Method service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -121,14 +123,17 @@ describe('Return Versions Setup - Submit Method service', () => { it('returns page data for the view', async () => { const result = await SubmitMethodService.go(session.id, payload) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'How do you want to set up the requirements for returns?', - backLink: `/system/return-versions/setup/${session.id}/reason`, - displayCopyExisting: true, - licenceRef: '01/ABC', - method: null - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'How do you want to set up the requirements for returns?', + backLink: `/system/return-versions/setup/${session.id}/reason`, + displayCopyExisting: true, + licenceRef: '01/ABC', + method: null + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { @@ -144,7 +149,7 @@ describe('Return Versions Setup - Submit Method service', () => { }) }) -function _generatedReturnRequirements () { +function _generatedReturnRequirements() { return [ { points: ['12345'], diff --git a/test/services/return-versions/setup/no-returns-required.service.test.js b/test/services/return-versions/setup/no-returns-required.service.test.js index ee07169929..6374b1d06b 100644 --- a/test/services/return-versions/setup/no-returns-required.service.test.js +++ b/test/services/return-versions/setup/no-returns-required.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -26,12 +26,14 @@ describe('Return Versions Setup - No Returns Required service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'no-returns-required', @@ -51,13 +53,16 @@ describe('Return Versions Setup - No Returns Required service', () => { it('returns page data for the view', async () => { const result = await NoReturnsRequiredService.go(session.id) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Why are no returns required?', - backLink: `/system/return-versions/setup/${session.id}/start-date`, - licenceRef: '01/ABC', - reason: null - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Why are no returns required?', + backLink: `/system/return-versions/setup/${session.id}/start-date`, + licenceRef: '01/ABC', + reason: null + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/note.service.test.js b/test/services/return-versions/setup/note.service.test.js index c9471b7a11..d928295921 100644 --- a/test/services/return-versions/setup/note.service.test.js +++ b/test/services/return-versions/setup/note.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -26,12 +26,14 @@ describe('Return Versions Setup - Note service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -52,13 +54,16 @@ describe('Return Versions Setup - Note service', () => { it('returns page data for the view', async () => { const result = await NoteService.go(session.id) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Add a note', - backLink: `/system/return-versions/setup/${session.id}/check`, - licenceRef: '01/ABC', - note: null - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Add a note', + backLink: `/system/return-versions/setup/${session.id}/check`, + licenceRef: '01/ABC', + note: null + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/points.service.test.js b/test/services/return-versions/setup/points.service.test.js index be35f1cc7b..fac0c19093 100644 --- a/test/services/return-versions/setup/points.service.test.js +++ b/test/services/return-versions/setup/points.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -33,12 +33,14 @@ describe('Return Versions Setup - Points service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -74,20 +76,23 @@ describe('Return Versions Setup - Points service', () => { it('returns page data for the view', async () => { const result = await SelectPointsService.go(session.id, requirementIndex) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select the points for the requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/purpose/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licencePoints: [ - { - id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', - description: 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' - } - ], - licenceRef: '01/ABC', - selectedPointIds: '' - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select the points for the requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/purpose/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licencePoints: [ + { + id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', + description: 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' + } + ], + licenceRef: '01/ABC', + selectedPointIds: '' + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/purpose.service.test.js b/test/services/return-versions/setup/purpose.service.test.js index e91516770c..cec7107e87 100644 --- a/test/services/return-versions/setup/purpose.service.test.js +++ b/test/services/return-versions/setup/purpose.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -37,12 +37,14 @@ describe('Return Versions Setup - Purpose service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -75,7 +77,12 @@ describe('Return Versions Setup - Purpose service', () => { licenceRef: '01/ABC', purposes: [ { alias: '', checked: false, description: 'Heat Pump', id: '14794d57-1acf-4c91-8b48-4b1ec68bfd6f' }, - { alias: '', checked: false, description: 'Horticultural Watering', id: '49088608-ee9f-491a-8070-6831240945ac' } + { + alias: '', + checked: false, + description: 'Horticultural Watering', + id: '49088608-ee9f-491a-8070-6831240945ac' + } ], sessionId: session.id }) diff --git a/test/services/return-versions/setup/reason.service.test.js b/test/services/return-versions/setup/reason.service.test.js index 5d70d0515a..93ec2caf13 100644 --- a/test/services/return-versions/setup/reason.service.test.js +++ b/test/services/return-versions/setup/reason.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -26,12 +26,14 @@ describe('Return Versions Setup - Reason service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -51,13 +53,16 @@ describe('Return Versions Setup - Reason service', () => { it('returns page data for the view', async () => { const result = await ReasonService.go(session.id) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select the reason for the requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/start-date`, - licenceRef: '01/ABC', - reason: null - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select the reason for the requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/start-date`, + licenceRef: '01/ABC', + reason: null + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/remove.service.test.js b/test/services/return-versions/setup/remove.service.test.js index f844150738..8b9800cb24 100644 --- a/test/services/return-versions/setup/remove.service.test.js +++ b/test/services/return-versions/setup/remove.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -30,32 +30,34 @@ describe('Return Versions Setup - Remove service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', - requirements: [{ - points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], - purposes: [{ alias: '', description: 'Mineral Washing', id: '3a865331-d2f3-4acc-ac85-527fa2b0d2dd' }], - returnsCycle: 'winter-and-all-year', - siteDescription: 'Bore hole in rear field', - abstractionPeriod: { - 'end-abstraction-period-day': '31', - 'end-abstraction-period-month': '10', - 'start-abstraction-period-day': '1', - 'start-abstraction-period-month': '4' - }, - frequencyReported: 'month', - frequencyCollected: 'month', - agreementsExceptions: [ - 'none' - ] - }], + requirements: [ + { + points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], + purposes: [{ alias: '', description: 'Mineral Washing', id: '3a865331-d2f3-4acc-ac85-527fa2b0d2dd' }], + returnsCycle: 'winter-and-all-year', + siteDescription: 'Bore hole in rear field', + abstractionPeriod: { + 'end-abstraction-period-day': '31', + 'end-abstraction-period-month': '10', + 'start-abstraction-period-day': '1', + 'start-abstraction-period-month': '4' + }, + frequencyReported: 'month', + frequencyCollected: 'month', + agreementsExceptions: ['none'] + } + ], startDateOptions: 'licenceStartDate' } }) diff --git a/test/services/return-versions/setup/returns-cycle.service.test.js b/test/services/return-versions/setup/returns-cycle.service.test.js index ea4a923637..e5f6edacdc 100644 --- a/test/services/return-versions/setup/returns-cycle.service.test.js +++ b/test/services/return-versions/setup/returns-cycle.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -28,12 +28,14 @@ describe('Return Versions Setup - Returns Cycle service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -54,14 +56,17 @@ describe('Return Versions Setup - Returns Cycle service', () => { it('returns page data for the view', async () => { const result = await ReturnsCycleService.go(session.id, requirementIndex) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select the returns cycle for the requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/abstraction-period/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC', - returnsCycle: null - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select the returns cycle for the requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/abstraction-period/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC', + returnsCycle: null + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/site-description.service.test.js b/test/services/return-versions/setup/site-description.service.test.js index 0865a0a4dd..f9d48c39d3 100644 --- a/test/services/return-versions/setup/site-description.service.test.js +++ b/test/services/return-versions/setup/site-description.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -28,12 +28,14 @@ describe('Return Versions Setup - Site Description service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -54,14 +56,17 @@ describe('Return Versions Setup - Site Description service', () => { it('returns page data for the view', async () => { const result = await SiteDescriptionService.go(session.id, requirementIndex) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Enter a site description for the requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/returns-cycle/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC', - siteDescription: null - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Enter a site description for the requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/returns-cycle/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC', + siteDescription: null + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/start-date.service.test.js b/test/services/return-versions/setup/start-date.service.test.js index 584af64204..4d88929d99 100644 --- a/test/services/return-versions/setup/start-date.service.test.js +++ b/test/services/return-versions/setup/start-date.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -28,12 +28,14 @@ describe('Return Versions Setup - Start Date service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -54,18 +56,21 @@ describe('Return Versions Setup - Start Date service', () => { it('returns page data for the view', async () => { const result = await StartDateService.go(session.id) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select the start date for the requirements for returns', - anotherStartDateDay: null, - anotherStartDateMonth: null, - anotherStartDateYear: null, - backLink: '/system/licences/8b7f78ba-f3ad-4cb6-a058-78abc4d1383d/set-up', - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC', - licenceVersionStartDate: '1 January 2023', - startDateOption: null - }, { skip: ['sessionId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select the start date for the requirements for returns', + anotherStartDateDay: null, + anotherStartDateMonth: null, + anotherStartDateYear: null, + backLink: '/system/licences/8b7f78ba-f3ad-4cb6-a058-78abc4d1383d/set-up', + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC', + licenceVersionStartDate: '1 January 2023', + startDateOption: null + }, + { skip: ['sessionId'] } + ) }) }) }) diff --git a/test/services/return-versions/setup/submit-abstraction-period.service.test.js b/test/services/return-versions/setup/submit-abstraction-period.service.test.js index 62535a9f47..8b1db2caca 100644 --- a/test/services/return-versions/setup/submit-abstraction-period.service.test.js +++ b/test/services/return-versions/setup/submit-abstraction-period.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,12 +32,14 @@ describe('Return Versions Setup - Submit Abstraction Period service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -118,14 +120,17 @@ describe('Return Versions Setup - Submit Abstraction Period service', () => { it('returns page data for the view', async () => { const result = await SubmitAbstractionPeriodService.go(session.id, requirementIndex, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Enter the abstraction period for the requirements for returns', - abstractionPeriod: null, - backLink: `/system/return-versions/setup/${session.id}/points/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC' - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Enter the abstraction period for the requirements for returns', + abstractionPeriod: null, + backLink: `/system/return-versions/setup/${session.id}/points/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC' + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { diff --git a/test/services/return-versions/setup/submit-additional-submission-options.service.test.js b/test/services/return-versions/setup/submit-additional-submission-options.service.test.js index e76bab36e3..d86e3e3c0d 100644 --- a/test/services/return-versions/setup/submit-additional-submission-options.service.test.js +++ b/test/services/return-versions/setup/submit-additional-submission-options.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -125,16 +125,19 @@ describe('Return Versions Setup - Submit Additional Submission Options service', it('returns page data for the view', async () => { const result = await SubmitAdditionalSubmissionOptionsService.go(session.id, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - backLink: `/system/return-versions/setup/${session.id}/check`, - pageTitle: 'Select any additional submission options for the return requirements', - licenceRef: '01/ABC', - multipleUpload: false, - noAdditionalOptions: undefined, - quarterlyReturnSubmissions: false, - quarterlyReturns: undefined - }, { skip: ['id', 'sessionId', 'error', 'licenceId'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + backLink: `/system/return-versions/setup/${session.id}/check`, + pageTitle: 'Select any additional submission options for the return requirements', + licenceRef: '01/ABC', + multipleUpload: false, + noAdditionalOptions: undefined, + quarterlyReturnSubmissions: false, + quarterlyReturns: undefined + }, + { skip: ['id', 'sessionId', 'error', 'licenceId'] } + ) }) describe('because the user has not checked anything', () => { diff --git a/test/services/return-versions/setup/submit-agreements-exceptions.service.test.js b/test/services/return-versions/setup/submit-agreements-exceptions.service.test.js index 9b6c34b625..2fdde3559d 100644 --- a/test/services/return-versions/setup/submit-agreements-exceptions.service.test.js +++ b/test/services/return-versions/setup/submit-agreements-exceptions.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,12 +32,14 @@ describe('Return Versions Setup - Submit Agreements and Exceptions service', () endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -56,11 +58,7 @@ describe('Return Versions Setup - Submit Agreements and Exceptions service', () describe('with a valid payload', () => { beforeEach(() => { payload = { - agreementsExceptions: [ - 'gravity-fill', - 'two-part-tariff', - '56-returns-exception' - ] + agreementsExceptions: ['gravity-fill', 'two-part-tariff', '56-returns-exception'] } }) @@ -128,14 +126,17 @@ describe('Return Versions Setup - Submit Agreements and Exceptions service', () it('returns page data for the view', async () => { const result = await SubmitAgreementsExceptionsService.go(session.id, requirementIndex, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select agreements and exceptions for the requirements for returns', - agreementsExceptions: null, - backLink: `/system/return-versions/setup/${session.id}/frequency-reported/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC' - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select agreements and exceptions for the requirements for returns', + agreementsExceptions: null, + backLink: `/system/return-versions/setup/${session.id}/frequency-reported/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC' + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { diff --git a/test/services/return-versions/setup/submit-cancel.service.test.js b/test/services/return-versions/setup/submit-cancel.service.test.js index 56fff4ad80..a3cc71d050 100644 --- a/test/services/return-versions/setup/submit-cancel.service.test.js +++ b/test/services/return-versions/setup/submit-cancel.service.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -28,32 +28,34 @@ describe('Return Versions Setup - Submit Cancel service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', - requirements: [{ - points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], - purposes: [{ alias: '', description: 'Mineral Washing', id: '3a865331-d2f3-4acc-ac85-527fa2b0d2dd' }], - returnsCycle: 'winter-and-all-year', - siteDescription: 'Bore hole in rear field', - abstractionPeriod: { - 'end-abstraction-period-day': '31', - 'end-abstraction-period-month': '10', - 'start-abstraction-period-day': '1', - 'start-abstraction-period-month': '4' - }, - frequencyReported: 'month', - frequencyCollected: 'month', - agreementsExceptions: [ - 'none' - ] - }], + requirements: [ + { + points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], + purposes: [{ alias: '', description: 'Mineral Washing', id: '3a865331-d2f3-4acc-ac85-527fa2b0d2dd' }], + returnsCycle: 'winter-and-all-year', + siteDescription: 'Bore hole in rear field', + abstractionPeriod: { + 'end-abstraction-period-day': '31', + 'end-abstraction-period-month': '10', + 'start-abstraction-period-day': '1', + 'start-abstraction-period-month': '4' + }, + frequencyReported: 'month', + frequencyCollected: 'month', + agreementsExceptions: ['none'] + } + ], startDateOptions: 'licenceStartDate', reason: 'major-change' } diff --git a/test/services/return-versions/setup/submit-frequency-collected.service.test.js b/test/services/return-versions/setup/submit-frequency-collected.service.test.js index df6fb87d2e..5c1387a0ad 100644 --- a/test/services/return-versions/setup/submit-frequency-collected.service.test.js +++ b/test/services/return-versions/setup/submit-frequency-collected.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,12 +32,14 @@ describe('Return Versions Setup - Submit Frequency Collected service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -110,14 +112,17 @@ describe('Return Versions Setup - Submit Frequency Collected service', () => { it('returns the page data for the view', async () => { const result = await SubmitFrequencyCollectedService.go(session.id, requirementIndex, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select how often readings or volumes are collected', - backLink: `/system/return-versions/setup/${session.id}/site-description/0`, - frequencyCollected: null, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC' - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select how often readings or volumes are collected', + backLink: `/system/return-versions/setup/${session.id}/site-description/0`, + frequencyCollected: null, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC' + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { diff --git a/test/services/return-versions/setup/submit-frequency-reported.service.test.js b/test/services/return-versions/setup/submit-frequency-reported.service.test.js index 66a04d8cdd..0979e772ec 100644 --- a/test/services/return-versions/setup/submit-frequency-reported.service.test.js +++ b/test/services/return-versions/setup/submit-frequency-reported.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,12 +32,14 @@ describe('Return Versions Setup - Submit Frequency Reported service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -110,14 +112,17 @@ describe('Return Versions Setup - Submit Frequency Reported service', () => { it('returns the page data for the view', async () => { const result = await SubmitFrequencyReportedService.go(session.id, requirementIndex, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select how often readings or volumes are reported', - backLink: `/system/return-versions/setup/${session.id}/frequency-collected/0`, - frequencyReported: null, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC' - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select how often readings or volumes are reported', + backLink: `/system/return-versions/setup/${session.id}/frequency-collected/0`, + frequencyReported: null, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC' + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { diff --git a/test/services/return-versions/setup/submit-no-returns-required.service.test.js b/test/services/return-versions/setup/submit-no-returns-required.service.test.js index dbf0b8aa64..ede3ef6e47 100644 --- a/test/services/return-versions/setup/submit-no-returns-required.service.test.js +++ b/test/services/return-versions/setup/submit-no-returns-required.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, afterEach, beforeEach } = exports.lab = Lab.script() +const { describe, it, afterEach, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -30,12 +30,14 @@ describe('Return Versions Setup - Submit No Returns Required service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'no-returns-required', @@ -108,13 +110,16 @@ describe('Return Versions Setup - Submit No Returns Required service', () => { it('returns page data for the view', async () => { const result = await SubmitNoReturnsRequiredService.go(session.id, payload) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Why are no returns required?', - backLink: `/system/return-versions/setup/${session.id}/start-date`, - licenceRef: '01/ABC', - reason: null - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Why are no returns required?', + backLink: `/system/return-versions/setup/${session.id}/start-date`, + licenceRef: '01/ABC', + reason: null + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not selected anything', () => { diff --git a/test/services/return-versions/setup/submit-note.service.test.js b/test/services/return-versions/setup/submit-note.service.test.js index 4dd52ccd74..36710375a1 100644 --- a/test/services/return-versions/setup/submit-note.service.test.js +++ b/test/services/return-versions/setup/submit-note.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -31,12 +31,14 @@ describe('Return Versions Setup - Submit Note service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -154,13 +156,16 @@ describe('Return Versions Setup - Submit Note service', () => { it('returns page data for the view', async () => { const result = await SubmitNoteService.go(session.id, payload, user, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Add a note', - backLink: `/system/return-versions/setup/${session.id}/check`, - licenceRef: '01/ABC', - note: null - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Add a note', + backLink: `/system/return-versions/setup/${session.id}/check`, + licenceRef: '01/ABC', + note: null + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not entered anything', () => { diff --git a/test/services/return-versions/setup/submit-points.service.test.js b/test/services/return-versions/setup/submit-points.service.test.js index 605a04c5ff..e54098e7f0 100644 --- a/test/services/return-versions/setup/submit-points.service.test.js +++ b/test/services/return-versions/setup/submit-points.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -36,12 +36,14 @@ describe('Return Versions Setup - Submit Points service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -75,9 +77,7 @@ describe('Return Versions Setup - Submit Points service', () => { const refreshedSession = await session.$query() - expect(refreshedSession.requirements[0].points).to.equal([ - 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6' - ]) + expect(refreshedSession.requirements[0].points).to.equal(['d03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6']) }) describe('and the page has been not been visited', () => { @@ -125,18 +125,23 @@ describe('Return Versions Setup - Submit Points service', () => { it('returns page data for the view', async () => { const result = await SubmitPointsService.go(session.id, requirementIndex, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select the points for the requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/purpose/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licencePoints: [{ - id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', - description: 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' - }], - licenceRef: '01/ABC', - selectedPointIds: '' - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select the points for the requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/purpose/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licencePoints: [ + { + id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', + description: 'At National Grid Reference TQ 69212 50394 (RIVER MEDWAY AT YALDING INTAKE)' + } + ], + licenceRef: '01/ABC', + selectedPointIds: '' + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { @@ -151,7 +156,7 @@ describe('Return Versions Setup - Submit Points service', () => { }) }) -function _points () { +function _points() { const point = PointModel.fromJson({ description: 'RIVER MEDWAY AT YALDING INTAKE', id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', diff --git a/test/services/return-versions/setup/submit-purpose.service.test.js b/test/services/return-versions/setup/submit-purpose.service.test.js index 8ee894103f..501afae879 100644 --- a/test/services/return-versions/setup/submit-purpose.service.test.js +++ b/test/services/return-versions/setup/submit-purpose.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -35,12 +35,14 @@ describe('Return Versions Setup - Submit Purpose service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -137,7 +139,12 @@ describe('Return Versions Setup - Submit Purpose service', () => { licenceRef: '01/ABC', purposes: [ { alias: '', checked: false, description: 'Heat Pump', id: '14794d57-1acf-4c91-8b48-4b1ec68bfd6f' }, - { alias: '', checked: false, description: 'Horticultural Watering', id: '49088608-ee9f-491a-8070-6831240945ac' } + { + alias: '', + checked: false, + description: 'Horticultural Watering', + id: '49088608-ee9f-491a-8070-6831240945ac' + } ], sessionId: session.id }) @@ -148,7 +155,8 @@ describe('Return Versions Setup - Submit Purpose service', () => { beforeEach(async () => { payload = { purposes: '14794d57-1acf-4c91-8b48-4b1ec68bfd6f', - 'alias-14794d57-1acf-4c91-8b48-4b1ec68bfd6f': 'THGBk2GM85EyXB54SsfenU2yWiKjDuPTcJCrPfTsSzojNvj6ciVmI3PXJ2fisQgXWfSI4ZPIqV5GLPtR15qbcw3Hamoeit764Cojz' + 'alias-14794d57-1acf-4c91-8b48-4b1ec68bfd6f': + 'THGBk2GM85EyXB54SsfenU2yWiKjDuPTcJCrPfTsSzojNvj6ciVmI3PXJ2fisQgXWfSI4ZPIqV5GLPtR15qbcw3Hamoeit764Cojz' } }) @@ -166,7 +174,8 @@ describe('Return Versions Setup - Submit Purpose service', () => { licenceRef: '01/ABC', purposes: [ { - alias: 'THGBk2GM85EyXB54SsfenU2yWiKjDuPTcJCrPfTsSzojNvj6ciVmI3PXJ2fisQgXWfSI4ZPIqV5GLPtR15qbcw3Hamoeit764Cojz', + alias: + 'THGBk2GM85EyXB54SsfenU2yWiKjDuPTcJCrPfTsSzojNvj6ciVmI3PXJ2fisQgXWfSI4ZPIqV5GLPtR15qbcw3Hamoeit764Cojz', checked: true, description: 'Heat Pump', id: '14794d57-1acf-4c91-8b48-4b1ec68bfd6f' diff --git a/test/services/return-versions/setup/submit-reason.service.test.js b/test/services/return-versions/setup/submit-reason.service.test.js index dacdfce97f..5bdd88eab2 100644 --- a/test/services/return-versions/setup/submit-reason.service.test.js +++ b/test/services/return-versions/setup/submit-reason.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach, afterEach } = exports.lab = Lab.script() +const { describe, it, beforeEach, afterEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -30,12 +30,14 @@ describe('Return Versions Setup - Submit Reason service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -111,13 +113,16 @@ describe('Return Versions Setup - Submit Reason service', () => { it('returns page data for the view', async () => { const result = await SubmitReasonService.go(session.id, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select the reason for the requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/start-date`, - licenceRef: '01/ABC', - reason: null - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select the reason for the requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/start-date`, + licenceRef: '01/ABC', + reason: null + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { diff --git a/test/services/return-versions/setup/submit-remove.service.test.js b/test/services/return-versions/setup/submit-remove.service.test.js index cbdf28142d..14b7906a8e 100644 --- a/test/services/return-versions/setup/submit-remove.service.test.js +++ b/test/services/return-versions/setup/submit-remove.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,32 +32,34 @@ describe('Return Versions Setup - Submit Remove service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', - requirements: [{ - points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], - purposes: [{ alias: '', description: 'Mineral Washing', id: '3a865331-d2f3-4acc-ac85-527fa2b0d2dd' }], - returnsCycle: 'winter-and-all-year', - siteDescription: 'Bore hole in rear field', - abstractionPeriod: { - 'end-abstraction-period-day': '31', - 'end-abstraction-period-month': '10', - 'start-abstraction-period-day': '1', - 'start-abstraction-period-month': '4' - }, - frequencyReported: 'month', - frequencyCollected: 'month', - agreementsExceptions: [ - 'none' - ] - }], + requirements: [ + { + points: ['At National Grid Reference TQ 6520 5937 (POINT A, ADDINGTON SANDPITS)'], + purposes: [{ alias: '', description: 'Mineral Washing', id: '3a865331-d2f3-4acc-ac85-527fa2b0d2dd' }], + returnsCycle: 'winter-and-all-year', + siteDescription: 'Bore hole in rear field', + abstractionPeriod: { + 'end-abstraction-period-day': '31', + 'end-abstraction-period-month': '10', + 'start-abstraction-period-day': '1', + 'start-abstraction-period-month': '4' + }, + frequencyReported: 'month', + frequencyCollected: 'month', + agreementsExceptions: ['none'] + } + ], startDateOptions: 'licenceStartDate', reason: 'major-change' } diff --git a/test/services/return-versions/setup/submit-returns-cycle.service.test.js b/test/services/return-versions/setup/submit-returns-cycle.service.test.js index 12e5e96bf8..43cbd03227 100644 --- a/test/services/return-versions/setup/submit-returns-cycle.service.test.js +++ b/test/services/return-versions/setup/submit-returns-cycle.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,12 +32,14 @@ describe('Return Versions Setup - Submit Returns Cycle service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -110,14 +112,17 @@ describe('Return Versions Setup - Submit Returns Cycle service', () => { it('returns the page data for the view', async () => { const result = await SubmitReturnsCycleService.go(session.id, requirementIndex, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select the returns cycle for the requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/abstraction-period/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC', - returnsCycle: null - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select the returns cycle for the requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/abstraction-period/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC', + returnsCycle: null + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not submitted anything', () => { diff --git a/test/services/return-versions/setup/submit-site-description.service.test.js b/test/services/return-versions/setup/submit-site-description.service.test.js index 1cdde50bee..221a90b993 100644 --- a/test/services/return-versions/setup/submit-site-description.service.test.js +++ b/test/services/return-versions/setup/submit-site-description.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -32,12 +32,14 @@ describe('Return Versions Setup - Submit Site Description service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01T00:00:00.000Z', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01T00:00:00.000Z', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01T00:00:00.000Z' }, journey: 'returns-required', @@ -65,7 +67,9 @@ describe('Return Versions Setup - Submit Site Description service', () => { const refreshedSession = await session.$query() - expect(refreshedSession.requirements[0].siteDescription).to.equal('This is a valid return requirement description') + expect(refreshedSession.requirements[0].siteDescription).to.equal( + 'This is a valid return requirement description' + ) }) describe('and the page has been not been visited', () => { @@ -110,14 +114,17 @@ describe('Return Versions Setup - Submit Site Description service', () => { it('returns page data for the view', async () => { const result = await SubmitSiteDescriptionService.go(session.id, requirementIndex, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Enter a site description for the requirements for returns', - backLink: `/system/return-versions/setup/${session.id}/returns-cycle/0`, - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC', - siteDescription: null - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Enter a site description for the requirements for returns', + backLink: `/system/return-versions/setup/${session.id}/returns-cycle/0`, + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC', + siteDescription: null + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not entered anything', () => { @@ -153,8 +160,9 @@ describe('Return Versions Setup - Submit Site Description service', () => { }) describe('because the user has entered a description more than 100 characters', () => { - const invalidSiteDescription = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit' + - ', sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis.' + const invalidSiteDescription = + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit' + + ', sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis.' beforeEach(() => { payload = { diff --git a/test/services/return-versions/setup/submit-start-date.service.test.js b/test/services/return-versions/setup/submit-start-date.service.test.js index d7d9e03049..47c781237d 100644 --- a/test/services/return-versions/setup/submit-start-date.service.test.js +++ b/test/services/return-versions/setup/submit-start-date.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -31,12 +31,14 @@ describe('Return Versions Setup - Submit Start Date service', () => { endDate: null, licenceRef: '01/ABC', licenceHolder: 'Turbo Kid', - returnVersions: [{ - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', - startDate: '2023-01-01', - reason: null, - modLogs: [] - }], + returnVersions: [ + { + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + startDate: '2023-01-01', + reason: null, + modLogs: [] + } + ], startDate: '2022-04-01', waterUndertaker: true }, @@ -171,18 +173,21 @@ describe('Return Versions Setup - Submit Start Date service', () => { it('returns the page data for the view', async () => { const result = await SubmitStartDateService.go(session.id, payload, yarStub) - expect(result).to.equal({ - activeNavBar: 'search', - pageTitle: 'Select the start date for the requirements for returns', - anotherStartDateDay: null, - anotherStartDateMonth: null, - anotherStartDateYear: null, - backLink: '/system/licences/8b7f78ba-f3ad-4cb6-a058-78abc4d1383d/set-up', - licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', - licenceRef: '01/ABC', - licenceVersionStartDate: '1 January 2023', - startDateOption: null - }, { skip: ['sessionId', 'error'] }) + expect(result).to.equal( + { + activeNavBar: 'search', + pageTitle: 'Select the start date for the requirements for returns', + anotherStartDateDay: null, + anotherStartDateMonth: null, + anotherStartDateYear: null, + backLink: '/system/licences/8b7f78ba-f3ad-4cb6-a058-78abc4d1383d/set-up', + licenceId: '8b7f78ba-f3ad-4cb6-a058-78abc4d1383d', + licenceRef: '01/ABC', + licenceVersionStartDate: '1 January 2023', + startDateOption: null + }, + { skip: ['sessionId', 'error'] } + ) }) describe('because the user has not selected anything', () => { diff --git a/test/services/return-versions/view.service.test.js b/test/services/return-versions/view.service.test.js index 39df8b0d7e..deb23c02dc 100644 --- a/test/services/return-versions/view.service.test.js +++ b/test/services/return-versions/view.service.test.js @@ -5,7 +5,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') const Sinon = require('sinon') -const { describe, it, afterEach, beforeEach } = exports.lab = Lab.script() +const { describe, it, afterEach, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -53,9 +53,7 @@ describe('Return Versions - View service', () => { frequencyCollected: 'monthly', frequencyReported: 'monthly', points: ['At National Grid Reference SE 4044 7262 (Borehole in top field)'], - purposes: [ - 'Spray Irrigation - Direct' - ], + purposes: ['Spray Irrigation - Direct'], returnReference: 10012345, returnsCycle: 'Winter and all year', siteDescription: 'Borehole in field', @@ -69,7 +67,7 @@ describe('Return Versions - View service', () => { }) }) -function _returnVersion () { +function _returnVersion() { const contact = ContactModel.fromJson({ firstName: 'Annie', middleInitials: 'J', @@ -81,10 +79,12 @@ function _returnVersion () { id: '761bc44f-80d5-49ae-ab46-0a90495417b5', licenceRef: '01/123', licenceDocument: { - licenceDocumentRoles: [{ - id: '3b903973-2143-47fe-b7a2-b205aa8eb933', - contact - }] + licenceDocumentRoles: [ + { + id: '3b903973-2143-47fe-b7a2-b205aa8eb933', + contact + } + ] } }) @@ -99,35 +99,41 @@ function _returnVersion () { modLogs: [], user: { id: 1, username: 'carol.shaw@atari.com' }, licence, - returnRequirements: [{ - abstractionPeriodEndDay: 31, - abstractionPeriodEndMonth: 10, - abstractionPeriodStartDay: 1, - abstractionPeriodStartMonth: 4, - collectionFrequency: 'month', - fiftySixException: false, - gravityFill: false, - id: 'fa0c6032-7031-4aa2-be95-4a2edf1753ac', - legacyId: 10012345, - reabstraction: false, - reportingFrequency: 'month', - siteDescription: 'Borehole in field', - summer: false, - twoPartTariff: false, - points: [{ - description: 'Borehole in top field', - id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', - ngr1: 'SE 4044 7262', - ngr2: null, - ngr3: null, - ngr4: null - }], - returnRequirementPurposes: [{ - alias: null, - id: '7a2e3a5a-b10d-4a0f-b115-42b7551c4e8c', - purpose: { description: 'Spray Irrigation - Direct', id: 'e0bd8bd4-cfb8-44ba-b76b-2b722fcc2207' } - }] - }] + returnRequirements: [ + { + abstractionPeriodEndDay: 31, + abstractionPeriodEndMonth: 10, + abstractionPeriodStartDay: 1, + abstractionPeriodStartMonth: 4, + collectionFrequency: 'month', + fiftySixException: false, + gravityFill: false, + id: 'fa0c6032-7031-4aa2-be95-4a2edf1753ac', + legacyId: 10012345, + reabstraction: false, + reportingFrequency: 'month', + siteDescription: 'Borehole in field', + summer: false, + twoPartTariff: false, + points: [ + { + description: 'Borehole in top field', + id: 'd03d7d7c-4e33-4b4d-ac9b-6ebac9a5e5f6', + ngr1: 'SE 4044 7262', + ngr2: null, + ngr3: null, + ngr4: null + } + ], + returnRequirementPurposes: [ + { + alias: null, + id: '7a2e3a5a-b10d-4a0f-b115-42b7551c4e8c', + purpose: { description: 'Spray Irrigation - Direct', id: 'e0bd8bd4-cfb8-44ba-b76b-2b722fcc2207' } + } + ] + } + ] } return ReturnVersionModel.fromJson(returnVersionData) diff --git a/test/support/database.js b/test/support/database.js index ce86c1643d..3a2b0304ac 100644 --- a/test/support/database.js +++ b/test/support/database.js @@ -37,7 +37,7 @@ const LEGACY_SCHEMAS = ['crm', 'crm_v2', 'idm', 'permit', 'returns', 'water'] * Once it has that info it creates a query that tells PostgreSQL to TRUNCATE all the tables and restart their * identity columns. For example, if a table relies on an incrementing ID the query will reset that to 1. */ -async function clean () { +async function clean() { const schemas = ['public', ...LEGACY_SCHEMAS] for (const schema of schemas) { @@ -61,7 +61,7 @@ async function clean () { * of this is it will cause the next migration run to error. That was until we added this function to wipe the test DB * of all tables, views and schemas. If this gets run before the migrations it will be starting with a clean slate. */ -async function wipe () { +async function wipe() { // Drop the public views first const viewNames = await _viewNames('public') @@ -83,11 +83,11 @@ async function wipe () { } } -function _migrationTables () { +function _migrationTables() { return [dbConfig.migrations.tableName, `${dbConfig.migrations.tableName}_lock`] } -async function _seed () { +async function _seed() { // NOTE: Order matches the order they are seeded via Knex seeding. Do not alphabetize! await RegionsSeeder.seed() await PurposesSeeder.seed() @@ -107,7 +107,7 @@ async function _seed () { await ReturnCycleSeeder.seed() } -async function _tableNames (schema) { +async function _tableNames(schema) { const result = await db('pg_tables') .select('tablename') .where('schemaname', schema) @@ -118,10 +118,8 @@ async function _tableNames (schema) { }) } -async function _viewNames (schema) { - const result = await db('pg_views') - .select('viewname') - .where('schemaname', schema) +async function _viewNames(schema) { + const result = await db('pg_views').select('viewname').where('schemaname', schema) return result.map((view) => { return `"${schema}".${view.viewname}` @@ -132,7 +130,7 @@ async function _viewNames (schema) { * Close the connection to the database * */ -async function closeConnection () { +async function closeConnection() { await db.destroy() } diff --git a/test/support/general.js b/test/support/general.js index 12f197ce62..2f137947e8 100644 --- a/test/support/general.js +++ b/test/support/general.js @@ -39,7 +39,7 @@ * * @returns {object} the options to be used in the call to `server.inject()` */ -function postRequestOptions ( +function postRequestOptions( path, payload = {}, scope = ['billing'], @@ -73,7 +73,7 @@ function postRequestOptions ( * * @returns a number between min and max (inclusive) */ -function randomInteger (min, max) { +function randomInteger(min, max) { return Math.floor(Math.random() * (max - min + 1) + min) } @@ -89,7 +89,7 @@ function randomInteger (min, max) { * * @returns a random entry from the data provided */ -function selectRandomEntry (data) { +function selectRandomEntry(data) { const randomIndex = randomInteger(0, data.length - 1) return data[randomIndex] @@ -106,7 +106,7 @@ function selectRandomEntry (data) { * * @returns a random number */ -function randomRegionCode () { +function randomRegionCode() { return randomInteger(1, 999999) } diff --git a/test/support/helpers/address.helper.js b/test/support/helpers/address.helper.js index e6b80ea501..86fe3e60cb 100644 --- a/test/support/helpers/address.helper.js +++ b/test/support/helpers/address.helper.js @@ -25,7 +25,7 @@ const { randomInteger } = require('../general.js') * * @returns {module:AddressModel} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return AddressModel.query() @@ -43,7 +43,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { address1: 'ENVIRONMENT AGENCY', address2: 'HORIZON HOUSE', @@ -66,7 +66,7 @@ function defaults (data = {}) { * * @returns {string} - A random UPRN */ -function generateUprn () { +function generateUprn() { return randomInteger(100, 999999) } @@ -77,7 +77,7 @@ function generateUprn () { * * @returns {string} - A random external id */ -function generateExternalId () { +function generateExternalId() { const regionCode = randomInteger(1, 9) const addressId = randomInteger(100, 99998) diff --git a/test/support/helpers/bill-licence.helper.js b/test/support/helpers/bill-licence.helper.js index 41d42786b1..5ed5971cdd 100644 --- a/test/support/helpers/bill-licence.helper.js +++ b/test/support/helpers/bill-licence.helper.js @@ -21,7 +21,7 @@ const LicenceHelper = require('./licence.helper.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return BillLicenceModel.query() @@ -39,7 +39,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { billId: generateUUID(), licenceRef: LicenceHelper.generateLicenceRef(), diff --git a/test/support/helpers/bill-run-charge-version-year.helper.js b/test/support/helpers/bill-run-charge-version-year.helper.js index 0162f44745..44a701f55e 100644 --- a/test/support/helpers/bill-run-charge-version-year.helper.js +++ b/test/support/helpers/bill-run-charge-version-year.helper.js @@ -22,7 +22,7 @@ const { generateUUID } = require('../../../app/lib/general.lib.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return BillRunChargeVersionYearModel.query() @@ -40,7 +40,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { billRunId: generateUUID(), chargeVersionId: generateUUID(), diff --git a/test/support/helpers/bill-run-volume.helper.js b/test/support/helpers/bill-run-volume.helper.js index 0ba48e16ba..c3435e8d89 100644 --- a/test/support/helpers/bill-run-volume.helper.js +++ b/test/support/helpers/bill-run-volume.helper.js @@ -21,7 +21,7 @@ const { generateUUID } = require('../../../app/lib/general.lib.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return BillRunVolumeModel.query() @@ -39,7 +39,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { chargeReferenceId: generateUUID(), financialYear: 2023, diff --git a/test/support/helpers/bill-run.helper.js b/test/support/helpers/bill-run.helper.js index 3aa008d7c1..ead9676195 100644 --- a/test/support/helpers/bill-run.helper.js +++ b/test/support/helpers/bill-run.helper.js @@ -24,7 +24,7 @@ const RegionHelper = require('./region.helper.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return BillRunModel.query() @@ -42,7 +42,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: regionId } = RegionHelper.select() const defaults = { diff --git a/test/support/helpers/bill.helper.js b/test/support/helpers/bill.helper.js index 4d013c4c8e..b019f8f680 100644 --- a/test/support/helpers/bill.helper.js +++ b/test/support/helpers/bill.helper.js @@ -23,7 +23,7 @@ const { generateAccountNumber } = require('./billing-account.helper.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return BillModel.query() @@ -41,7 +41,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { billingAccountId: generateUUID(), address: {}, diff --git a/test/support/helpers/billing-account-address.helper.js b/test/support/helpers/billing-account-address.helper.js index 47a931eca6..c911080699 100644 --- a/test/support/helpers/billing-account-address.helper.js +++ b/test/support/helpers/billing-account-address.helper.js @@ -20,7 +20,7 @@ const { generateUUID } = require('../../../app/lib/general.lib.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return BillingAccountAddressModel.query() @@ -38,7 +38,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { billingAccountId: generateUUID(), addressId: generateUUID(), diff --git a/test/support/helpers/billing-account.helper.js b/test/support/helpers/billing-account.helper.js index d64f47be04..cfe7489153 100644 --- a/test/support/helpers/billing-account.helper.js +++ b/test/support/helpers/billing-account.helper.js @@ -20,7 +20,7 @@ const { generateUUID } = require('../../../app/lib/general.lib.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return BillingAccountModel.query() @@ -38,7 +38,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { accountNumber: generateAccountNumber(), companyId: generateUUID() @@ -57,7 +57,7 @@ function defaults (data = {}) { * * @returns {string} - The generated account number */ -function generateAccountNumber () { +function generateAccountNumber() { const numbering = randomInteger(10000000, 99999999) return `T${numbering}A` diff --git a/test/support/helpers/change-reason.helper.js b/test/support/helpers/change-reason.helper.js index 90877f5b92..82584531ba 100644 --- a/test/support/helpers/change-reason.helper.js +++ b/test/support/helpers/change-reason.helper.js @@ -21,7 +21,7 @@ const { selectRandomEntry } = require('../general.js') * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return changeReasons[index] } diff --git a/test/support/helpers/charge-category.helper.js b/test/support/helpers/charge-category.helper.js index 86d56e90ab..ac2eaa5803 100644 --- a/test/support/helpers/charge-category.helper.js +++ b/test/support/helpers/charge-category.helper.js @@ -21,7 +21,7 @@ const { selectRandomEntry } = require('../general.js') * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return chargeCategories[index] } diff --git a/test/support/helpers/charge-element.helper.js b/test/support/helpers/charge-element.helper.js index 883a4f8b8f..0082d7f74e 100644 --- a/test/support/helpers/charge-element.helper.js +++ b/test/support/helpers/charge-element.helper.js @@ -36,7 +36,7 @@ const SecondaryPurposeHelper = require('./secondary-purpose.helper.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ChargeElementModel.query() @@ -54,7 +54,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: purposeId } = PurposeHelper.select() const { id: purposePrimaryId } = PrimaryPurposeHelper.select() const { id: purposeSecondaryId } = SecondaryPurposeHelper.select() diff --git a/test/support/helpers/charge-reference.helper.js b/test/support/helpers/charge-reference.helper.js index 1fe3f6543a..80c7e3e654 100644 --- a/test/support/helpers/charge-reference.helper.js +++ b/test/support/helpers/charge-reference.helper.js @@ -35,7 +35,7 @@ const ChargeCategoryHelper = require('./charge-category.helper.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ChargeReferenceModel.query() @@ -53,7 +53,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: chargeCategoryId } = ChargeCategoryHelper.select() const defaults = { diff --git a/test/support/helpers/charge-version-note.helper.js b/test/support/helpers/charge-version-note.helper.js index 1dfda78f36..ecea538636 100644 --- a/test/support/helpers/charge-version-note.helper.js +++ b/test/support/helpers/charge-version-note.helper.js @@ -19,7 +19,7 @@ const ChargeVersionNoteModel = require('../../../app/models/charge-version-note. * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ChargeVersionNoteModel.query() @@ -37,7 +37,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { note: 'This is a test note', userId: generateUserId() diff --git a/test/support/helpers/charge-version.helper.js b/test/support/helpers/charge-version.helper.js index 486a24cf04..93e49eee74 100644 --- a/test/support/helpers/charge-version.helper.js +++ b/test/support/helpers/charge-version.helper.js @@ -27,7 +27,7 @@ const { generateLicenceRef } = require('./licence.helper.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return ChargeVersionModel.query() @@ -45,7 +45,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { licenceRef: generateLicenceRef(), scheme: 'sroc', diff --git a/test/support/helpers/company-address.helper.js b/test/support/helpers/company-address.helper.js index 91f9fe14c9..3fc0410761 100644 --- a/test/support/helpers/company-address.helper.js +++ b/test/support/helpers/company-address.helper.js @@ -21,7 +21,7 @@ const { generateUUID } = require('../../../app/lib/general.lib.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return CompanyAddressModel.query() @@ -39,7 +39,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { addressId: generateUUID(), companyId: generateUUID(), diff --git a/test/support/helpers/company-contact.helper.js b/test/support/helpers/company-contact.helper.js index a02b352617..8b414601cc 100644 --- a/test/support/helpers/company-contact.helper.js +++ b/test/support/helpers/company-contact.helper.js @@ -21,7 +21,7 @@ const { generateUUID } = require('../../../app/lib/general.lib.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return CompanyContactModel.query() @@ -39,7 +39,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { companyId: generateUUID(), contactId: generateUUID(), diff --git a/test/support/helpers/company.helper.js b/test/support/helpers/company.helper.js index 2e6bf44d5c..e46d3ac43a 100644 --- a/test/support/helpers/company.helper.js +++ b/test/support/helpers/company.helper.js @@ -19,7 +19,7 @@ const { randomInteger } = require('../general.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return CompanyModel.query() @@ -37,7 +37,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { name: 'Example Trading Ltd', type: 'organisation' @@ -54,7 +54,7 @@ function defaults (data = {}) { * * @returns {int} - A random company number */ -function generateCompanyNumber () { +function generateCompanyNumber() { return randomInteger(1000000, 9999999).toString() } @@ -65,7 +65,7 @@ function generateCompanyNumber () { * * @returns {string} - A random external id */ -function generateExternalId () { +function generateExternalId() { const regionCode = randomInteger(1, 9) const partyId = randomInteger(100, 9999998) diff --git a/test/support/helpers/contact.helper.js b/test/support/helpers/contact.helper.js index 4c7e1552a5..6b1b1f5569 100644 --- a/test/support/helpers/contact.helper.js +++ b/test/support/helpers/contact.helper.js @@ -21,7 +21,7 @@ const ContactModel = require('../../../app/models/contact.model.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ContactModel.query() @@ -39,7 +39,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { firstName: 'Amara', lastName: 'Gupta', diff --git a/test/support/helpers/event.helper.js b/test/support/helpers/event.helper.js index 5f751d7ce7..acfd0cf2f6 100644 --- a/test/support/helpers/event.helper.js +++ b/test/support/helpers/event.helper.js @@ -32,7 +32,7 @@ const { generateUUID, timestampForPostgres } = require('../../../app/lib/general * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return EventModel.query() @@ -50,7 +50,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const timestamp = timestampForPostgres() const defaults = { diff --git a/test/support/helpers/financial-agreement.helper.js b/test/support/helpers/financial-agreement.helper.js index 174ffc5196..21756b7747 100644 --- a/test/support/helpers/financial-agreement.helper.js +++ b/test/support/helpers/financial-agreement.helper.js @@ -21,7 +21,7 @@ const { selectRandomEntry } = require('../general.js') * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return financialAgreements[index] } diff --git a/test/support/helpers/group-role.helper.js b/test/support/helpers/group-role.helper.js index 1979654fd0..2a9600170d 100644 --- a/test/support/helpers/group-role.helper.js +++ b/test/support/helpers/group-role.helper.js @@ -21,7 +21,7 @@ const GroupRoles = require('../../../db/seeds/data/group-roles.js') * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return GroupRoles.data[index] } diff --git a/test/support/helpers/group.helper.js b/test/support/helpers/group.helper.js index c42710220f..2b9fea84a3 100644 --- a/test/support/helpers/group.helper.js +++ b/test/support/helpers/group.helper.js @@ -21,7 +21,7 @@ const Groups = require('../../../db/seeds/data/groups.js') * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return Groups.data[index] } diff --git a/test/support/helpers/licence-agreement.helper.js b/test/support/helpers/licence-agreement.helper.js index bba839e5ae..e681838274 100644 --- a/test/support/helpers/licence-agreement.helper.js +++ b/test/support/helpers/licence-agreement.helper.js @@ -21,7 +21,7 @@ const LicenceHelper = require('./licence.helper.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceAgreementModel.query() @@ -39,7 +39,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: financialAgreementId } = FinancialAgreementHelper.select() const defaults = { diff --git a/test/support/helpers/licence-document-header.helper.js b/test/support/helpers/licence-document-header.helper.js index 4afa8b9425..9e9514e69c 100644 --- a/test/support/helpers/licence-document-header.helper.js +++ b/test/support/helpers/licence-document-header.helper.js @@ -23,7 +23,7 @@ const LicenceDocumentHeaderModel = require('../../../app/models/licence-document * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceDocumentHeaderModel.query() @@ -41,7 +41,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { regimeEntityId: generateUUID(), naldId: randomInteger(1000, 199999), @@ -55,7 +55,7 @@ function defaults (data = {}) { } } -function _metadata () { +function _metadata() { return { Town: 'BRISTOL', County: 'AVON', diff --git a/test/support/helpers/licence-document-role.helper.js b/test/support/helpers/licence-document-role.helper.js index ec26605d39..8d8c87f1c6 100644 --- a/test/support/helpers/licence-document-role.helper.js +++ b/test/support/helpers/licence-document-role.helper.js @@ -22,7 +22,7 @@ const LicenceDocumentRoleModel = require('../../../app/models/licence-document-r * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceDocumentRoleModel.query() @@ -40,7 +40,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { licenceDocumentId: generateUUID(), companyId: generateUUID(), diff --git a/test/support/helpers/licence-document.helper.js b/test/support/helpers/licence-document.helper.js index b360d9e64f..a8b238aa85 100644 --- a/test/support/helpers/licence-document.helper.js +++ b/test/support/helpers/licence-document.helper.js @@ -19,7 +19,7 @@ const LicenceDocumentModel = require('../../../app/models/licence-document.model * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceDocumentModel.query() @@ -37,7 +37,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { licenceRef: generateLicenceRef(), startDate: new Date('2022-01-01') diff --git a/test/support/helpers/licence-entity-role.helper.js b/test/support/helpers/licence-entity-role.helper.js index c648461b64..ac59a24de8 100644 --- a/test/support/helpers/licence-entity-role.helper.js +++ b/test/support/helpers/licence-entity-role.helper.js @@ -22,7 +22,7 @@ const LicenceEntityRoleModel = require('../../../app/models/licence-entity-role. * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceEntityRoleModel.query() @@ -40,7 +40,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { id: generateUUID(), licenceEntityId: generateUUID(), diff --git a/test/support/helpers/licence-entity.helper.js b/test/support/helpers/licence-entity.helper.js index b0d60b6133..3ba948c36f 100644 --- a/test/support/helpers/licence-entity.helper.js +++ b/test/support/helpers/licence-entity.helper.js @@ -20,7 +20,7 @@ const LicenceEntityModel = require('../../../app/models/licence-entity.model.js' * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceEntityModel.query() @@ -38,7 +38,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { id: generateUUID(), name: 'grace.hopper@example.com', diff --git a/test/support/helpers/licence-monitoring-station.helper.js b/test/support/helpers/licence-monitoring-station.helper.js index 49962a2f5a..38117c4a02 100644 --- a/test/support/helpers/licence-monitoring-station.helper.js +++ b/test/support/helpers/licence-monitoring-station.helper.js @@ -25,7 +25,7 @@ const LicenceMonitoringStationModel = require('../../../app/models/licence-monit * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceMonitoringStationModel.query() @@ -43,7 +43,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const timestamp = timestampForPostgres() const defaults = { diff --git a/test/support/helpers/licence-role.helper.js b/test/support/helpers/licence-role.helper.js index 5d274e9cdb..b53e3835bf 100644 --- a/test/support/helpers/licence-role.helper.js +++ b/test/support/helpers/licence-role.helper.js @@ -19,7 +19,7 @@ const { data: licenceRoles } = require('../../../db/seeds/data/licence-roles.js' * * @returns {object} The selected reference entry or one picked at random */ -function select (name = 'licenceHolder') { +function select(name = 'licenceHolder') { return licenceRoles.find((licenceRole) => { return licenceRole.name === name }) diff --git a/test/support/helpers/licence-supplementary-year.helper.js b/test/support/helpers/licence-supplementary-year.helper.js index 8cb75f5bb9..3c96dd3108 100644 --- a/test/support/helpers/licence-supplementary-year.helper.js +++ b/test/support/helpers/licence-supplementary-year.helper.js @@ -19,7 +19,7 @@ const LicenceSupplementaryYearModel = require('../../../app/models/licence-suppl * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return LicenceSupplementaryYearModel.query() @@ -37,7 +37,7 @@ function add (data = {}) { * * @returns {object} - Returns data from the query */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { licenceId: generateUUID(), financialYearEnd: 2023 diff --git a/test/support/helpers/licence-version-purpose-condition-type.helper.js b/test/support/helpers/licence-version-purpose-condition-type.helper.js index 9258a794f8..c0b497a1ef 100644 --- a/test/support/helpers/licence-version-purpose-condition-type.helper.js +++ b/test/support/helpers/licence-version-purpose-condition-type.helper.js @@ -5,7 +5,9 @@ */ const { selectRandomEntry } = require('../general.js') -const { data: licenceVersionPurposeConditionTypes } = require('../../../db/seeds/data/licence-version-purpose-condition-types.js') +const { + data: licenceVersionPurposeConditionTypes +} = require('../../../db/seeds/data/licence-version-purpose-condition-types.js') /** * Select an entry from the reference data entries seeded at the start of testing @@ -21,7 +23,7 @@ const { data: licenceVersionPurposeConditionTypes } = require('../../../db/seeds * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return licenceVersionPurposeConditionTypes[index] } diff --git a/test/support/helpers/licence-version-purpose-condition.helper.js b/test/support/helpers/licence-version-purpose-condition.helper.js index 6340bd0796..defb566f2e 100644 --- a/test/support/helpers/licence-version-purpose-condition.helper.js +++ b/test/support/helpers/licence-version-purpose-condition.helper.js @@ -26,7 +26,7 @@ const { randomInteger } = require('../general.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceVersionPurposeConditionModel.query() @@ -44,7 +44,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: licenceVersionPurposeConditionTypeId } = LicenceVersionPurposeConditionTypeHelper.select() const timestamp = timestampForPostgres() diff --git a/test/support/helpers/licence-version-purpose-point.helper.js b/test/support/helpers/licence-version-purpose-point.helper.js index fa6090e126..2e183dfeed 100644 --- a/test/support/helpers/licence-version-purpose-point.helper.js +++ b/test/support/helpers/licence-version-purpose-point.helper.js @@ -22,7 +22,7 @@ const PointHelper = require('./point.helper.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return LicenceVersionPurposePointModel.query() @@ -40,7 +40,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { externalId: generateLicenceVersionPurposePointExternalId(), licenceVersionPurposeId: generateUUID(), @@ -62,7 +62,7 @@ function defaults (data = {}) { * * @returns {string} - A randomly generated licence version purpose point external ID */ -function generateLicenceVersionPurposePointExternalId () { +function generateLicenceVersionPurposePointExternalId() { const naldPointId = PointHelper.generateNaldPointId() return `9:${randomInteger(100, 99999)}:${naldPointId}` diff --git a/test/support/helpers/licence-version-purpose.helper.js b/test/support/helpers/licence-version-purpose.helper.js index 3952177a45..763abce5d3 100644 --- a/test/support/helpers/licence-version-purpose.helper.js +++ b/test/support/helpers/licence-version-purpose.helper.js @@ -32,7 +32,7 @@ const SecondaryPurposeHelper = require('./secondary-purpose.helper.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceVersionPurposeModel.query() @@ -50,7 +50,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: primaryPurposeId } = PrimaryPurposeHelper.select() const { id: purposeId } = PurposeHelper.select() const { id: secondaryPurposeId } = SecondaryPurposeHelper.select() @@ -82,7 +82,7 @@ function defaults (data = {}) { * * @returns {string} - A randomly generated external id */ -function generateLicenceVersionPurposeExternalId () { +function generateLicenceVersionPurposeExternalId() { return `${randomInteger(0, 9)}:${randomInteger(10000, 99999)}` } diff --git a/test/support/helpers/licence-version.helper.js b/test/support/helpers/licence-version.helper.js index f6b20c8f8a..711894c3fd 100644 --- a/test/support/helpers/licence-version.helper.js +++ b/test/support/helpers/licence-version.helper.js @@ -26,7 +26,7 @@ const { randomInteger } = require('../general.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceVersionModel.query() @@ -44,7 +44,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const timestamp = timestampForPostgres() const defaults = { @@ -69,7 +69,7 @@ function defaults (data = {}) { * * @returns {string} - A randomly generated externalId */ -function generateLicenceVersionExternalId () { +function generateLicenceVersionExternalId() { return `${randomInteger(0, 9)}:${randomInteger(10000, 99999)}:${randomInteger(1, 100)}:0` } diff --git a/test/support/helpers/licence.helper.js b/test/support/helpers/licence.helper.js index edc63850dd..e90daac825 100644 --- a/test/support/helpers/licence.helper.js +++ b/test/support/helpers/licence.helper.js @@ -23,7 +23,7 @@ const RegionHelper = require('./region.helper.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return LicenceModel.query() @@ -41,7 +41,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: regionId } = RegionHelper.select() const defaults = { @@ -63,7 +63,7 @@ function defaults (data = {}) { * * @returns {string} - A randomly generated licence reference */ -function generateLicenceRef () { +function generateLicenceRef() { const secondPart = randomInteger(10, 99) const thirdPart = randomInteger(10, 99) const fourthPart = randomInteger(1000, 9999) diff --git a/test/support/helpers/mod-log.helper.js b/test/support/helpers/mod-log.helper.js index a4580f6dcf..87ebd5fce2 100644 --- a/test/support/helpers/mod-log.helper.js +++ b/test/support/helpers/mod-log.helper.js @@ -25,7 +25,7 @@ const { generateLicenceRef } = require('./licence.helper.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ModLogModel.query() @@ -43,7 +43,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const regionCode = randomRegionCode() const defaults = { @@ -72,7 +72,7 @@ function defaults (data = {}) { * * @returns {string} The generated external ID */ -function generateRegionNaldPatternExternalId (regionCode = null) { +function generateRegionNaldPatternExternalId(regionCode = null) { const regionCodeToUse = regionCode ?? randomInteger(1, 9) return `${regionCodeToUse}:${randomInteger(100, 99999)}` diff --git a/test/support/helpers/monitoring-station.helper.js b/test/support/helpers/monitoring-station.helper.js index 95f54e75d3..5d94fa2ecf 100644 --- a/test/support/helpers/monitoring-station.helper.js +++ b/test/support/helpers/monitoring-station.helper.js @@ -21,7 +21,7 @@ const MonitoringStationModel = require('../../../app/models/monitoring-station.m * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return MonitoringStationModel.query() @@ -39,7 +39,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const timestamp = timestampForPostgres() const defaults = { diff --git a/test/support/helpers/permit-licence.helper.js b/test/support/helpers/permit-licence.helper.js index 5edafa57a0..2d816591b4 100644 --- a/test/support/helpers/permit-licence.helper.js +++ b/test/support/helpers/permit-licence.helper.js @@ -22,7 +22,7 @@ const { generateLicenceRef } = require('./licence.helper.js') * * @returns {Promise} The instance of the newly created record */ -async function add (data = {}) { +async function add(data = {}) { const insertData = defaults(data) return PermitLicenceModel.query() @@ -40,7 +40,7 @@ async function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const licenceRef = data.licenceRef ? data.licenceRef : generateLicenceRef() const defaults = { licenceStatusId: 1, @@ -74,7 +74,7 @@ function defaults (data = {}) { * with what the legacy apps expect. * @param licenceRef */ -function _licenceDataValue (licenceRef) { +function _licenceDataValue(licenceRef) { return { ID: '9000000', data: { diff --git a/test/support/helpers/point.helper.js b/test/support/helpers/point.helper.js index a4c048ad95..6d903a172b 100644 --- a/test/support/helpers/point.helper.js +++ b/test/support/helpers/point.helper.js @@ -22,7 +22,7 @@ const SourceHelper = require('./source.helper.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return PointModel.query() @@ -40,7 +40,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: sourceId } = SourceHelper.select() const naldPointId = data.naldPointId ? data.naldPointId : generateNaldPointId() const ngr1 = data.ngr1 ? data.ngr1 : generateNationalGridReference() @@ -63,7 +63,7 @@ function defaults (data = {}) { * * @returns {string} - A randomly National Grid Reference NGR */ -function generateNationalGridReference () { +function generateNationalGridReference() { // NOTE: These are taken from https://en.wikipedia.org/wiki/Ordnance_Survey_National_Grid and are the 100KM // square references that cover the majority of the UK (sorry far North!) const codes = ['SD', 'SE', 'SJ', 'SK', 'SO', 'SP', 'ST', 'SU', 'SY', 'SZ', 'TA', 'TF', 'TL', 'TQ', 'TV', 'TG', 'TM'] @@ -76,7 +76,7 @@ function generateNationalGridReference () { * * @returns {string} - A randomly generated point ID */ -function generateNaldPointId () { +function generateNaldPointId() { return randomInteger(1, 99999) } diff --git a/test/support/helpers/primary-purpose.helper.js b/test/support/helpers/primary-purpose.helper.js index ac8b5ed3af..811dedd2bd 100644 --- a/test/support/helpers/primary-purpose.helper.js +++ b/test/support/helpers/primary-purpose.helper.js @@ -21,7 +21,7 @@ const { data: primaryPurposes } = require('../../../db/seeds/data/primary-purpos * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return primaryPurposes[index] } diff --git a/test/support/helpers/purpose.helper.js b/test/support/helpers/purpose.helper.js index 760c2cf66e..dbedb355a7 100644 --- a/test/support/helpers/purpose.helper.js +++ b/test/support/helpers/purpose.helper.js @@ -21,7 +21,7 @@ const { data: purposes } = require('../../../db/seeds/data/purposes.js') * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return purposes[index] } diff --git a/test/support/helpers/region.helper.js b/test/support/helpers/region.helper.js index 5055f27936..87e4b3855d 100644 --- a/test/support/helpers/region.helper.js +++ b/test/support/helpers/region.helper.js @@ -26,7 +26,7 @@ const TEST_REGION_INDEX = 8 * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return regions[index] } diff --git a/test/support/helpers/return-cycle.helper.js b/test/support/helpers/return-cycle.helper.js index 556ce571ae..e7c92497a9 100644 --- a/test/support/helpers/return-cycle.helper.js +++ b/test/support/helpers/return-cycle.helper.js @@ -27,7 +27,7 @@ const ReturnCycleModel = require('../../../app/models/return-cycle.model.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReturnCycleModel.query() @@ -45,7 +45,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const timestamp = timestampForPostgres() const defaults = { @@ -80,7 +80,7 @@ function defaults (data = {}) { * * @returns {object} The selected reference entry or one picked at random */ -async function select (index = -1, summer = false) { +async function select(index = -1, summer = false) { const returnCycles = await ReturnCycleModel.query().where('summer', summer).orderBy('startDate', 'DESC') if (index > -1) { diff --git a/test/support/helpers/return-log.helper.js b/test/support/helpers/return-log.helper.js index f9657a0fef..0e6523e9a1 100644 --- a/test/support/helpers/return-log.helper.js +++ b/test/support/helpers/return-log.helper.js @@ -31,7 +31,7 @@ const { generateLegacyId } = require('./return-requirement.helper.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReturnLogModel.query() @@ -49,7 +49,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const licenceRef = data.licenceRef ? data.licenceRef : generateLicenceRef() const returnReference = data.returnReference ? data.returnReference : generateLegacyId() const timestamp = timestampForPostgres() @@ -115,7 +115,7 @@ function defaults (data = {}) { * * @returns {string} the generated return log ID */ -function generateReturnLogId ( +function generateReturnLogId( startDate = '2022-04-01', endDate = '2023-03-31', version = 1, diff --git a/test/support/helpers/return-requirement-point.helper.js b/test/support/helpers/return-requirement-point.helper.js index 566fbc238a..407dd326ec 100644 --- a/test/support/helpers/return-requirement-point.helper.js +++ b/test/support/helpers/return-requirement-point.helper.js @@ -22,7 +22,7 @@ const ReturnRequirementPointModel = require('../../../app/models/return-requirem * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReturnRequirementPointModel.query() @@ -40,7 +40,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { externalId: generateReturnRequirementPointExternalId(), pointId: generateUUID(), @@ -62,7 +62,7 @@ function defaults (data = {}) { * * @returns {string} - A randomly generated return requirement point external ID */ -function generateReturnRequirementPointExternalId () { +function generateReturnRequirementPointExternalId() { const naldPointId = PointHelper.generateNaldPointId() return `9:${randomInteger(100, 99999)}:${naldPointId}` diff --git a/test/support/helpers/return-requirement-purpose.helper.js b/test/support/helpers/return-requirement-purpose.helper.js index fecd8438ac..cb4f10952e 100644 --- a/test/support/helpers/return-requirement-purpose.helper.js +++ b/test/support/helpers/return-requirement-purpose.helper.js @@ -26,7 +26,7 @@ const SecondaryPurposeHelper = require('../helpers/secondary-purpose.helper.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReturnRequirementPurposeModel.query() @@ -44,7 +44,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const purpose = PurposeHelper.select() const primaryPurpose = PrimaryPurposeHelper.select() const secondaryPurpose = SecondaryPurposeHelper.select() diff --git a/test/support/helpers/return-requirement.helper.js b/test/support/helpers/return-requirement.helper.js index b6f95a8a2d..a488b5e188 100644 --- a/test/support/helpers/return-requirement.helper.js +++ b/test/support/helpers/return-requirement.helper.js @@ -27,7 +27,7 @@ const ReturnRequirementModel = require('../../../app/models/return-requirement.m * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReturnRequirementModel.query() @@ -45,7 +45,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const legacyId = data.legacyId ? data.legacyId : generateLegacyId() const defaults = { @@ -71,7 +71,7 @@ function defaults (data = {}) { * * @returns {number} */ -function generateLegacyId () { +function generateLegacyId() { return randomInteger(100, 19999999) } diff --git a/test/support/helpers/return-submission-line.helper.js b/test/support/helpers/return-submission-line.helper.js index 0e10348554..b0df4a6506 100644 --- a/test/support/helpers/return-submission-line.helper.js +++ b/test/support/helpers/return-submission-line.helper.js @@ -27,7 +27,7 @@ const ReturnSubmissionLineModel = require('../../../app/models/return-submission * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReturnSubmissionLineModel.query() @@ -45,7 +45,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { id: generateUUID(), returnSubmissionId: generateUUID(), diff --git a/test/support/helpers/return-submission.helper.js b/test/support/helpers/return-submission.helper.js index 9bea1afec0..c78bda12a2 100644 --- a/test/support/helpers/return-submission.helper.js +++ b/test/support/helpers/return-submission.helper.js @@ -28,7 +28,7 @@ const ReturnSubmissionModel = require('../../../app/models/return-submission.mod * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReturnSubmissionModel.query() @@ -46,7 +46,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { id: generateUUID(), returnLogId: generateReturnLogId(), diff --git a/test/support/helpers/return-version.helper.js b/test/support/helpers/return-version.helper.js index 0ef157b3b3..cf1e85bd8f 100644 --- a/test/support/helpers/return-version.helper.js +++ b/test/support/helpers/return-version.helper.js @@ -24,7 +24,7 @@ const ReturnVersionModel = require('../../../app/models/return-version.model.js' * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReturnVersionModel.query() @@ -42,7 +42,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const version = data.version ? data.version : 100 const defaults = { diff --git a/test/support/helpers/review-charge-element-return.helper.js b/test/support/helpers/review-charge-element-return.helper.js index 98cc5b0a00..753f702226 100644 --- a/test/support/helpers/review-charge-element-return.helper.js +++ b/test/support/helpers/review-charge-element-return.helper.js @@ -19,7 +19,7 @@ const ReviewChargeElementReturnModel = require('../../../app/models/review-charg * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReviewChargeElementReturnModel.query() @@ -37,7 +37,7 @@ function add (data = {}) { * * @returns {object} - Returns data from the query */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { reviewChargeElementId: generateUUID(), reviewReturnId: generateUUID() diff --git a/test/support/helpers/review-charge-element.helper.js b/test/support/helpers/review-charge-element.helper.js index f85c058192..02ea480ebd 100644 --- a/test/support/helpers/review-charge-element.helper.js +++ b/test/support/helpers/review-charge-element.helper.js @@ -20,7 +20,7 @@ const ReviewChargeElementModel = require('../../../app/models/review-charge-elem * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReviewChargeElementModel.query() @@ -38,7 +38,7 @@ function add (data = {}) { * * @returns {object} - Returns data from the query */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { chargeElementId: generateUUID(), reviewChargeReferenceId: generateUUID(), diff --git a/test/support/helpers/review-charge-reference.helper.js b/test/support/helpers/review-charge-reference.helper.js index 48d5c40bff..09a5abd7bb 100644 --- a/test/support/helpers/review-charge-reference.helper.js +++ b/test/support/helpers/review-charge-reference.helper.js @@ -19,7 +19,7 @@ const ReviewChargeReferenceModel = require('../../../app/models/review-charge-re * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReviewChargeReferenceModel.query() @@ -37,7 +37,7 @@ function add (data = {}) { * * @returns {object} - Returns data from the query */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { reviewChargeVersionId: generateUUID(), chargeReferenceId: generateUUID() diff --git a/test/support/helpers/review-charge-version.helper.js b/test/support/helpers/review-charge-version.helper.js index c2a513ccdc..949a0d3368 100644 --- a/test/support/helpers/review-charge-version.helper.js +++ b/test/support/helpers/review-charge-version.helper.js @@ -22,7 +22,7 @@ const ReviewChargeVersionModel = require('../../../app/models/review-charge-vers * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReviewChargeVersionModel.query() @@ -40,7 +40,7 @@ function add (data = {}) { * * @returns {object} - Returns data from the query */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { reviewLicenceId: generateUUID(), chargeVersionId: generateUUID(), diff --git a/test/support/helpers/review-licence.helper.js b/test/support/helpers/review-licence.helper.js index dd708b238c..3e06e877b9 100644 --- a/test/support/helpers/review-licence.helper.js +++ b/test/support/helpers/review-licence.helper.js @@ -23,7 +23,7 @@ const ReviewLicenceModel = require('../../../app/models/review-licence.model.js' * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReviewLicenceModel.query() @@ -41,7 +41,7 @@ function add (data = {}) { * * @returns {object} - Returns data from the query */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { billRunId: generateUUID(), licenceId: generateUUID(), diff --git a/test/support/helpers/review-return.helper.js b/test/support/helpers/review-return.helper.js index 74de0a867d..a53d0706cf 100644 --- a/test/support/helpers/review-return.helper.js +++ b/test/support/helpers/review-return.helper.js @@ -32,7 +32,7 @@ const ReviewReturnModel = require('../../../app/models/review-return.model.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ReviewReturnModel.query() @@ -50,7 +50,7 @@ function add (data = {}) { * * @returns {object} - Returns data from the query */ -function defaults (data = {}) { +function defaults(data = {}) { const licenceRef = data.licenceRef ? data.licenceRef : generateLicenceRef() const returnReference = data.returnReference ? data.returnReference : generateLegacyId() diff --git a/test/support/helpers/role.helper.js b/test/support/helpers/role.helper.js index dd8c733ec9..fdea88b89d 100644 --- a/test/support/helpers/role.helper.js +++ b/test/support/helpers/role.helper.js @@ -21,7 +21,7 @@ const { data: roles } = require('../../../db/seeds/data/roles.js') * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return roles[index] } diff --git a/test/support/helpers/scheduled-notification.helper.js b/test/support/helpers/scheduled-notification.helper.js index 16e817bde8..1aa6bef044 100644 --- a/test/support/helpers/scheduled-notification.helper.js +++ b/test/support/helpers/scheduled-notification.helper.js @@ -18,7 +18,7 @@ const ScheduledNotificationModel = require('../../../app/models/scheduled-notifi * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return ScheduledNotificationModel.query() @@ -36,7 +36,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { // INFO: The table does not have a default for the createdAt column. createdAt: timestampForPostgres() diff --git a/test/support/helpers/secondary-purpose.helper.js b/test/support/helpers/secondary-purpose.helper.js index cb08a945f2..e8aaf0cbd7 100644 --- a/test/support/helpers/secondary-purpose.helper.js +++ b/test/support/helpers/secondary-purpose.helper.js @@ -21,7 +21,7 @@ const { data: secondaryPurposes } = require('../../../db/seeds/data/secondary-pu * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return secondaryPurposes[index] } diff --git a/test/support/helpers/session.helper.js b/test/support/helpers/session.helper.js index c32d4673d1..c886223679 100644 --- a/test/support/helpers/session.helper.js +++ b/test/support/helpers/session.helper.js @@ -18,7 +18,7 @@ const SessionModel = require('../../../app/models/session.model.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return SessionModel.query() @@ -36,7 +36,7 @@ function add (data = {}) { * * @returns {object} - Returns data from the query */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = {} return { diff --git a/test/support/helpers/source.helper.js b/test/support/helpers/source.helper.js index 4915103399..05b68ea21b 100644 --- a/test/support/helpers/source.helper.js +++ b/test/support/helpers/source.helper.js @@ -21,7 +21,7 @@ const { data: sources } = require('../../../db/seeds/data/sources.js') * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return sources[index] } diff --git a/test/support/helpers/transaction.helper.js b/test/support/helpers/transaction.helper.js index 23302cd9fc..1ef2b5309a 100644 --- a/test/support/helpers/transaction.helper.js +++ b/test/support/helpers/transaction.helper.js @@ -41,7 +41,7 @@ const TransactionModel = require('../../../app/models/transaction.model.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return TransactionModel.query() @@ -59,7 +59,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { startDate, endDate } = determineCurrentFinancialYear() const { reference, shortDescription } = ChargeCategoryHelper.select() diff --git a/test/support/helpers/user-group.helper.js b/test/support/helpers/user-group.helper.js index f57c89a1dc..373371afad 100644 --- a/test/support/helpers/user-group.helper.js +++ b/test/support/helpers/user-group.helper.js @@ -25,7 +25,7 @@ const DEFAULT_INDEX = 4 * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return UserGroupModel.query() @@ -43,7 +43,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: groupId } = GroupHelper.select() const defaults = { @@ -73,7 +73,7 @@ function defaults (data = {}) { * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return userGroups[index] } diff --git a/test/support/helpers/user-role.helper.js b/test/support/helpers/user-role.helper.js index 47a01f932a..5d1048eeb9 100644 --- a/test/support/helpers/user-role.helper.js +++ b/test/support/helpers/user-role.helper.js @@ -21,7 +21,7 @@ const UserRoleModel = require('../../../app/models/user-role.model.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return UserRoleModel.query() @@ -39,7 +39,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const { id: roleId } = RoleHelper.select() const defaults = { diff --git a/test/support/helpers/user.helper.js b/test/support/helpers/user.helper.js index f6351c0b44..2cee78d4d7 100644 --- a/test/support/helpers/user.helper.js +++ b/test/support/helpers/user.helper.js @@ -26,7 +26,7 @@ const DEFAULT_INDEX = 4 * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) // Overwrite the current password with the hashed version we want to persist @@ -47,7 +47,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { username: `${generateUUID()}@wrls.gov.uk`, password: 'P@55word', @@ -67,7 +67,7 @@ function defaults (data = {}) { * * @returns {number} a random integer between 100011 and 199999 */ -function generateUserId () { +function generateUserId() { // The last ID in the pre-seeded users is 100010 return randomInteger(100011, 199999) } @@ -86,7 +86,7 @@ function generateUserId () { * * @returns {object} The selected reference entry or one picked at random */ -function select (index = -1) { +function select(index = -1) { if (index > -1) { return users[index] } diff --git a/test/support/helpers/workflow.helper.js b/test/support/helpers/workflow.helper.js index db3eeefc47..a4dba84766 100644 --- a/test/support/helpers/workflow.helper.js +++ b/test/support/helpers/workflow.helper.js @@ -21,7 +21,7 @@ const WorkflowModel = require('../../../app/models/workflow.model.js') * * @returns {Promise} The instance of the newly created record */ -function add (data = {}) { +function add(data = {}) { const insertData = defaults(data) return WorkflowModel.query() @@ -39,7 +39,7 @@ function add (data = {}) { * * @returns {object} - Returns the set defaults with the override data spread */ -function defaults (data = {}) { +function defaults(data = {}) { const defaults = { licenceId: generateUUID(), status: 'to_setup', diff --git a/test/support/seeders/licence-abstraction-data.seeder.js b/test/support/seeders/licence-abstraction-data.seeder.js index 848e8d6d65..691c2a8dcc 100644 --- a/test/support/seeders/licence-abstraction-data.seeder.js +++ b/test/support/seeders/licence-abstraction-data.seeder.js @@ -37,7 +37,7 @@ const { generateLicenceVersionPurposeExternalId } = require('../helpers/licence- * * @returns {Promise} all the named IDs for then seeded records in an object */ -async function seed (optionalLicenceRef = undefined) { +async function seed(optionalLicenceRef = undefined) { const records = {} let licenceRef = generateLicenceRef() @@ -63,14 +63,14 @@ async function seed (optionalLicenceRef = undefined) { return records } -async function _financialAgreements () { +async function _financialAgreements() { const section126 = FinancialAgreementHelper.select(2) const twoPartTariff = FinancialAgreementHelper.select(3) return { section126Id: section126.id, twoPartTariffId: twoPartTariff.id } } -async function _licenceFinancialAgreement (licenceRef, financialAgreements) { +async function _licenceFinancialAgreement(licenceRef, financialAgreements) { const { id: currentNonTwoPartId } = await LicenceFinancialAgreement.add({ financialAgreementId: financialAgreements.section126Id, licenceRef @@ -85,7 +85,7 @@ async function _licenceFinancialAgreement (licenceRef, financialAgreements) { return { currentNonTwoPartId, endedTwoPartId } } -async function _licenceVersions (licenceId) { +async function _licenceVersions(licenceId) { const { id: supersededId } = await LicenceVersionHelper.add({ endDate: new Date('2022-04-31'), externalId: generateLicenceVersionExternalId(), @@ -106,7 +106,7 @@ async function _licenceVersions (licenceId) { return { currentId, supersededId } } -async function _licenceVersionPurposes (licenceVersionId, allPurposes) { +async function _licenceVersionPurposes(licenceVersionId, allPurposes) { const electricity = await LicenceVersionPurposeHelper.add({ dailyQuantity: 455, externalId: generateLicenceVersionPurposeExternalId(), @@ -137,7 +137,7 @@ async function _licenceVersionPurposes (licenceVersionId, allPurposes) { return { electricity, standard, twoPartTariff } } -async function _points (licenceVersionPurposes) { +async function _points(licenceVersionPurposes) { const { electricity: electricityPurpose, standard: standardPurpose, @@ -150,35 +150,53 @@ async function _points (licenceVersionPurposes) { const twoPartTariff = await PointHelper.add({ description: 'MAIN INTAKE' }) await LicenceVersionPurposePointHelper.add({ - licenceVersionPurposeId: electricityPurpose.id, pointId: electricity1.id + licenceVersionPurposeId: electricityPurpose.id, + pointId: electricity1.id }) await LicenceVersionPurposePointHelper.add({ - licenceVersionPurposeId: electricityPurpose.id, pointId: electricity2.id + licenceVersionPurposeId: electricityPurpose.id, + pointId: electricity2.id }) await LicenceVersionPurposePointHelper.add({ - licenceVersionPurposeId: standardPurpose.id, pointId: standard.id + licenceVersionPurposeId: standardPurpose.id, + pointId: standard.id }) await LicenceVersionPurposePointHelper.add({ - licenceVersionPurposeId: twoPartTariffPurpose.id, pointId: twoPartTariff.id + licenceVersionPurposeId: twoPartTariffPurpose.id, + pointId: twoPartTariff.id }) return { electricity1, electricity2, standard, twoPartTariff } } -async function _purposes () { - const { id: heatPumpId } = PurposeHelper.data.find((purpose) => { return purpose.legacyId === '200' }) +async function _purposes() { + const { id: heatPumpId } = PurposeHelper.data.find((purpose) => { + return purpose.legacyId === '200' + }) - const { id: sprayIrrigationDirectId } = PurposeHelper.data.find((purpose) => { return purpose.legacyId === '400' }) + const { id: sprayIrrigationDirectId } = PurposeHelper.data.find((purpose) => { + return purpose.legacyId === '400' + }) - const { id: vegetableWashingId } = PurposeHelper.data.find((purpose) => { return purpose.legacyId === '460' }) + const { id: vegetableWashingId } = PurposeHelper.data.find((purpose) => { + return purpose.legacyId === '460' + }) - const { id: primaryAgricultureId } = PrimaryPurposeHelper.data.find((purpose) => { return purpose.legacyId === 'A' }) + const { id: primaryAgricultureId } = PrimaryPurposeHelper.data.find((purpose) => { + return purpose.legacyId === 'A' + }) - const { id: primaryElectricityId } = PrimaryPurposeHelper.data.find((purpose) => { return purpose.legacyId === 'P' }) + const { id: primaryElectricityId } = PrimaryPurposeHelper.data.find((purpose) => { + return purpose.legacyId === 'P' + }) - const { id: secondaryAgricultureId } = SecondaryPurposeHelper.data.find((purpose) => { return purpose.legacyId === 'AGR' }) + const { id: secondaryAgricultureId } = SecondaryPurposeHelper.data.find((purpose) => { + return purpose.legacyId === 'AGR' + }) - const { id: secondaryElectricityId } = SecondaryPurposeHelper.data.find((purpose) => { return purpose.legacyId === 'ELC' }) + const { id: secondaryElectricityId } = SecondaryPurposeHelper.data.find((purpose) => { + return purpose.legacyId === 'ELC' + }) return { purposes: { heatPumpId, sprayIrrigationDirectId, vegetableWashingId }, diff --git a/test/support/seeders/licence-holder.seeder.js b/test/support/seeders/licence-holder.seeder.js index 7e23dce805..10ccfcf7f5 100644 --- a/test/support/seeders/licence-holder.seeder.js +++ b/test/support/seeders/licence-holder.seeder.js @@ -18,7 +18,7 @@ const LicenceRoleHelper = require('../helpers/licence-role.helper.js') * @returns {Promise} the licence document role which will link through to all the * entities that make up the licence holder */ -async function seed (licenceRef, name = 'Licence Holder Ltd') { +async function seed(licenceRef, name = 'Licence Holder Ltd') { // Create a licence role (the default is licenceHolder) const { id: licenceRoleId } = await LicenceRoleHelper.select() diff --git a/test/support/seeders/requirements-for-returns.seeder.js b/test/support/seeders/requirements-for-returns.seeder.js index 51a8ca8104..1968bef7a3 100644 --- a/test/support/seeders/requirements-for-returns.seeder.js +++ b/test/support/seeders/requirements-for-returns.seeder.js @@ -31,7 +31,7 @@ const UserHelper = require('../helpers/user.helper.js') * point and a purpose plus an instance of `UserModel` for the user that created it and `LicenceModel` for the licence * it is linked to */ -async function seed () { +async function seed() { // Select a user const user = UserHelper.select() @@ -56,14 +56,7 @@ async function seed () { returnVersion.returnRequirements = [returnRequirement] // Create the second requirement record - returnRequirement = await _returnRequirement( - returnVersion.id, - legacyIds[1], - 'month', - true, - true, - null - ) + returnRequirement = await _returnRequirement(returnVersion.id, legacyIds[1], 'month', true, true, null) returnVersion.returnRequirements.push(returnRequirement) return { licence, returnVersion, user } @@ -82,21 +75,14 @@ async function seed () { * * @private */ -function _legacyIds () { +function _legacyIds() { const legacyId1 = ReturnRequirementHelper.generateLegacyId() const legacyId2 = ReturnRequirementHelper.generateLegacyId() return legacyId1 > legacyId2 ? [legacyId1, legacyId2] : [legacyId2, legacyId1] } -async function _returnRequirement ( - returnVersionId, - legacyId, - reportingFrequency, - summer, - agreements, - alias -) { +async function _returnRequirement(returnVersionId, legacyId, reportingFrequency, summer, agreements, alias) { const returnRequirement = await ReturnRequirementHelper.add({ collectionFrequency: 'week', fiftySixException: agreements, @@ -123,7 +109,9 @@ async function _returnRequirement ( }) const returnRequirementPurpose = await ReturnRequirementPurposeHelper.add({ - purposeId: purpose.id, returnRequirementId, alias + purposeId: purpose.id, + returnRequirementId, + alias }) returnRequirementPurpose.purpose = purpose diff --git a/test/validators/bill-runs/review/authorised.validator.test.js b/test/validators/bill-runs/review/authorised.validator.test.js index 1185d9ed42..a2596d4917 100644 --- a/test/validators/bill-runs/review/authorised.validator.test.js +++ b/test/validators/bill-runs/review/authorised.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -75,7 +75,9 @@ describe('Bill Runs Review - Authorised validator', () => { const result = AuthorisedValidator.go(payload) expect(result.error).to.exist() - expect(result.error.details[0].message).to.equal('The authorised volume must not have more than 6 decimal places') + expect(result.error.details[0].message).to.equal( + 'The authorised volume must not have more than 6 decimal places' + ) }) }) }) diff --git a/test/validators/bill-runs/review/edit.validator.test.js b/test/validators/bill-runs/review/edit.validator.test.js index 4bd022d983..113afc0e5b 100644 --- a/test/validators/bill-runs/review/edit.validator.test.js +++ b/test/validators/bill-runs/review/edit.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -116,7 +116,9 @@ describe('Bill Runs Review - Edit validator', () => { const result = EditValidator.go(payload) expect(result.error).to.exist() - expect(result.error.details[0].message).to.equal('The quantity must be the same as or less than the authorised amount') + expect(result.error.details[0].message).to.equal( + 'The quantity must be the same as or less than the authorised amount' + ) }) }) }) diff --git a/test/validators/bill-runs/review/factors.validator.test.js b/test/validators/bill-runs/review/factors.validator.test.js index b563bbf378..c740e8d9c9 100644 --- a/test/validators/bill-runs/review/factors.validator.test.js +++ b/test/validators/bill-runs/review/factors.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -134,7 +134,9 @@ describe('Bill Runs Review - Factors validator', () => { const result = FactorsValidator.go(payload) expect(result.error).to.exist() - expect(result.error.details[0].message).to.equal('The charge factor must not have more than 15 decimal places') + expect(result.error.details[0].message).to.equal( + 'The charge factor must not have more than 15 decimal places' + ) }) }) diff --git a/test/validators/bill-runs/setup/region.validator.test.js b/test/validators/bill-runs/setup/region.validator.test.js index 6bb3033677..7dc3e16143 100644 --- a/test/validators/bill-runs/setup/region.validator.test.js +++ b/test/validators/bill-runs/setup/region.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/bill-runs/setup/season.validator.test.js b/test/validators/bill-runs/setup/season.validator.test.js index c77aff93d2..cf373f8517 100644 --- a/test/validators/bill-runs/setup/season.validator.test.js +++ b/test/validators/bill-runs/setup/season.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/bill-runs/setup/type.validator.test.js b/test/validators/bill-runs/setup/type.validator.test.js index f65f20367f..59bb2e4224 100644 --- a/test/validators/bill-runs/setup/type.validator.test.js +++ b/test/validators/bill-runs/setup/type.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/bill-runs/setup/year.validator.test.js b/test/validators/bill-runs/setup/year.validator.test.js index d6b55c3186..25937fb6b2 100644 --- a/test/validators/bill-runs/setup/year.validator.test.js +++ b/test/validators/bill-runs/setup/year.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/change-address.validator.test.js b/test/validators/change-address.validator.test.js index 562c67455e..87e54dcac9 100644 --- a/test/validators/change-address.validator.test.js +++ b/test/validators/change-address.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/import/address.validator.test.js b/test/validators/import/address.validator.test.js index 110453a3a0..f7b4afdd70 100644 --- a/test/validators/import/address.validator.test.js +++ b/test/validators/import/address.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -286,7 +286,7 @@ describe('Import Address validator', () => { }) }) -function _transformedAddress () { +function _transformedAddress() { return { address1: '4 Privet Drive', address2: null, diff --git a/test/validators/import/company.validator.test.js b/test/validators/import/company.validator.test.js index dd1766c596..10f5802d75 100644 --- a/test/validators/import/company.validator.test.js +++ b/test/validators/import/company.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -166,7 +166,7 @@ describe('Import Company validator', () => { }) }) -function _transformedCompany () { +function _transformedCompany() { return { name: 'ACME', type: 'person', diff --git a/test/validators/import/contact.validator.test.js b/test/validators/import/contact.validator.test.js index 61aebc3740..363d17b072 100644 --- a/test/validators/import/contact.validator.test.js +++ b/test/validators/import/contact.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -156,7 +156,7 @@ describe('Import Contact validator', () => { }) }) -function _transformedContact () { +function _transformedContact() { return { salutation: 'Mr', initials: 'H', diff --git a/test/validators/import/licence-document-role.validator.test.js b/test/validators/import/licence-document-role.validator.test.js index 18d67139a6..a86b0ea3fe 100644 --- a/test/validators/import/licence-document-role.validator.test.js +++ b/test/validators/import/licence-document-role.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -248,7 +248,7 @@ describe('Import Licence Document role validator', () => { }) }) -function _transformedLicenceDocumentRoleRole () { +function _transformedLicenceDocumentRoleRole() { return { addressId: '1:007', companyId: '1:007', diff --git a/test/validators/import/licence-document.validator.test.js b/test/validators/import/licence-document.validator.test.js index 1bf22056b1..63b6f88a33 100644 --- a/test/validators/import/licence-document.validator.test.js +++ b/test/validators/import/licence-document.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -133,7 +133,7 @@ describe('Import Licence Document validator', () => { }) }) -function _transformedLicenceDocument () { +function _transformedLicenceDocument() { return { licenceRef: generateLicenceRef(), endDate: new Date('2052-06-23'), diff --git a/test/validators/import/licence-structure.validator.test.js b/test/validators/import/licence-structure.validator.test.js index 3c4270756d..bb711f2e35 100644 --- a/test/validators/import/licence-structure.validator.test.js +++ b/test/validators/import/licence-structure.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -102,19 +102,21 @@ describe('Import Licence Structure validator', () => { }) }) -function _transformedLicence () { +function _transformedLicence() { return { licenceRef: '01/123', - licenceVersions: [{ - externalId: '6:2113:100:0', - licenceVersionPurposes: [ - { - externalId: '6:10000004' - }, - { - externalId: '6:10000005' - } - ] - }] + licenceVersions: [ + { + externalId: '6:2113:100:0', + licenceVersionPurposes: [ + { + externalId: '6:10000004' + }, + { + externalId: '6:10000005' + } + ] + } + ] } } diff --git a/test/validators/import/licence-version-purpose-conditions.validator.test.js b/test/validators/import/licence-version-purpose-conditions.validator.test.js index baacb5789f..5dcb335279 100644 --- a/test/validators/import/licence-version-purpose-conditions.validator.test.js +++ b/test/validators/import/licence-version-purpose-conditions.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -168,7 +168,7 @@ describe('Import Licence Version Purpose Conditions validator', () => { }) }) -function _licenceVersionPurposeConditionsValidatorCondition () { +function _licenceVersionPurposeConditionsValidatorCondition() { return { externalId: '6:100004', licenceVersionPurposeConditionTypeId: 'b10cc9d1-d46f-465d-a74a-26b2e567c699' diff --git a/test/validators/import/licence-version-purpose.validator.test.js b/test/validators/import/licence-version-purpose.validator.test.js index a4a68897ea..44cd324a80 100644 --- a/test/validators/import/licence-version-purpose.validator.test.js +++ b/test/validators/import/licence-version-purpose.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -618,7 +618,7 @@ describe('Import Licence Version Purpose validator', () => { }) }) -function _transformedLicenceVersionPurpose () { +function _transformedLicenceVersionPurpose() { return { abstractionPeriodEndDay: 31, abstractionPeriodEndMonth: 3, diff --git a/test/validators/import/licence-version.validator.test.js b/test/validators/import/licence-version.validator.test.js index 841668e318..de1271f301 100644 --- a/test/validators/import/licence-version.validator.test.js +++ b/test/validators/import/licence-version.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -220,7 +220,7 @@ describe('Import Licence Version validator', () => { }) }) -function _transformedLicenceVersion () { +function _transformedLicenceVersion() { return { endDate: new Date('2052-06-23'), externalId: '6:2113:100:0', diff --git a/test/validators/import/licence.validator.test.js b/test/validators/import/licence.validator.test.js index 4dcb52c9c6..f30bb84e6e 100644 --- a/test/validators/import/licence.validator.test.js +++ b/test/validators/import/licence.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Test helpers @@ -387,7 +387,7 @@ describe('Import Licence validator', () => { }) }) -function _transformedLicence () { +function _transformedLicence() { return { expiredDate: new Date('2052-06-23'), lapsedDate: new Date('2050-07-24'), diff --git a/test/validators/licences/supplementary/supplementary-year.validator.test.js b/test/validators/licences/supplementary/supplementary-year.validator.test.js index 98d73622d7..c3faed0173 100644 --- a/test/validators/licences/supplementary/supplementary-year.validator.test.js +++ b/test/validators/licences/supplementary/supplementary-year.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/abstraction-period.validator.test.js b/test/validators/return-versions/setup/abstraction-period.validator.test.js index edbeb6d41f..c1f9b6ace5 100644 --- a/test/validators/return-versions/setup/abstraction-period.validator.test.js +++ b/test/validators/return-versions/setup/abstraction-period.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/additional-submission-options.validator.test.js b/test/validators/return-versions/setup/additional-submission-options.validator.test.js index cabc72c035..9c3eacb6c2 100644 --- a/test/validators/return-versions/setup/additional-submission-options.validator.test.js +++ b/test/validators/return-versions/setup/additional-submission-options.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -13,9 +13,7 @@ const AdditionalSubmissionOptionsValidator = require('../../../../app/validators describe('Return Versions Setup - Additional Submission Options validator', () => { describe('when valid data is provided', () => { const payload = { - additionalSubmissionOptions: [ - 'multiple-upload' - ] + additionalSubmissionOptions: ['multiple-upload'] } it('confirms the data is valid', () => { @@ -28,9 +26,7 @@ describe('Return Versions Setup - Additional Submission Options validator', () = describe('when invalid data is provided', () => { const payload = { - options: [ - 'Invalid option' - ] + options: ['Invalid option'] } it('fails validation', () => { @@ -38,7 +34,9 @@ describe('Return Versions Setup - Additional Submission Options validator', () = expect(result.value).to.exist() expect(result.error).to.exist() - expect(result.error.details[0].message).to.equal('Select additional submission options for the requirements for returns') + expect(result.error.details[0].message).to.equal( + 'Select additional submission options for the requirements for returns' + ) }) }) @@ -50,7 +48,9 @@ describe('Return Versions Setup - Additional Submission Options validator', () = expect(result.value).to.exist() expect(result.error).to.exist() - expect(result.error.details[0].message).to.equal('Select additional submission options for the requirements for returns') + expect(result.error.details[0].message).to.equal( + 'Select additional submission options for the requirements for returns' + ) }) }) }) diff --git a/test/validators/return-versions/setup/agreements-exceptions.validator.test.js b/test/validators/return-versions/setup/agreements-exceptions.validator.test.js index 5c0f471aa0..d1f222a3e7 100644 --- a/test/validators/return-versions/setup/agreements-exceptions.validator.test.js +++ b/test/validators/return-versions/setup/agreements-exceptions.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -16,22 +16,14 @@ describe('Return Versions Setup - Agreements Exception validator', () => { describe('when valid data is provided', () => { beforeEach(() => { payload = { - agreementsExceptions: [ - 'gravity-fill', - 'two-part-tariff', - '56-returns-exception' - ] + agreementsExceptions: ['gravity-fill', 'two-part-tariff', '56-returns-exception'] } }) it('confirms the data is valid', () => { const result = AgreementsExceptionsValidator.go(payload) - expect(result.value.agreementsExceptions).to.equal([ - 'gravity-fill', - 'two-part-tariff', - '56-returns-exception' - ]) + expect(result.value.agreementsExceptions).to.equal(['gravity-fill', 'two-part-tariff', '56-returns-exception']) expect(result.error).not.to.exist() }) diff --git a/test/validators/return-versions/setup/existing.validator.test.js b/test/validators/return-versions/setup/existing.validator.test.js index 1144d5a534..c69c888074 100644 --- a/test/validators/return-versions/setup/existing.validator.test.js +++ b/test/validators/return-versions/setup/existing.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -13,10 +13,14 @@ const ExistingValidator = require('../../../../app/validators/return-versions/se describe('Return Versions Setup - Existing validator', () => { const returnVersions = [ { - id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', reason: null, startDate: '2023-01-01T00:00:00.000Z' + id: '60b5d10d-1372-4fb2-b222-bfac81da69ab', + reason: null, + startDate: '2023-01-01T00:00:00.000Z' }, { - id: '22ecef19-3a13-44a0-a55e-8f4d34dd59a5', reason: 'major-change', startDate: '2024-05-07T00:00:00.000Z' + id: '22ecef19-3a13-44a0-a55e-8f4d34dd59a5', + reason: 'major-change', + startDate: '2024-05-07T00:00:00.000Z' } ] diff --git a/test/validators/return-versions/setup/frequency-collected.validator.test.js b/test/validators/return-versions/setup/frequency-collected.validator.test.js index a0faf21f15..77716c8860 100644 --- a/test/validators/return-versions/setup/frequency-collected.validator.test.js +++ b/test/validators/return-versions/setup/frequency-collected.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/frequency-reported.validator.test.js b/test/validators/return-versions/setup/frequency-reported.validator.test.js index 240153ebb6..6edc1c776a 100644 --- a/test/validators/return-versions/setup/frequency-reported.validator.test.js +++ b/test/validators/return-versions/setup/frequency-reported.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/method.validator.test.js b/test/validators/return-versions/setup/method.validator.test.js index 8d7fa7a588..cc9c947767 100644 --- a/test/validators/return-versions/setup/method.validator.test.js +++ b/test/validators/return-versions/setup/method.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/no-returns-required.validator.test.js b/test/validators/return-versions/setup/no-returns-required.validator.test.js index 76faf8c9a9..469d681572 100644 --- a/test/validators/return-versions/setup/no-returns-required.validator.test.js +++ b/test/validators/return-versions/setup/no-returns-required.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/note.validator.test.js b/test/validators/return-versions/setup/note.validator.test.js index dec806b162..76098a2620 100644 --- a/test/validators/return-versions/setup/note.validator.test.js +++ b/test/validators/return-versions/setup/note.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/points.validator.test.js b/test/validators/return-versions/setup/points.validator.test.js index 7b2391fd52..4ba1d56121 100644 --- a/test/validators/return-versions/setup/points.validator.test.js +++ b/test/validators/return-versions/setup/points.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -12,10 +12,7 @@ const PointsValidator = require('../../../../app/validators/return-versions/setu describe('Return Versions Setup - Point validator', () => { describe('when valid data is provided', () => { - const points = [ - 'c083c0cc-42ca-4917-a929-e1fed906ff66', - '90764459-d9af-4e13-850b-cf4299fd5e8a' - ] + const points = ['c083c0cc-42ca-4917-a929-e1fed906ff66', '90764459-d9af-4e13-850b-cf4299fd5e8a'] it('confirms the data is valid', () => { const result = PointsValidator.go(points) diff --git a/test/validators/return-versions/setup/purpose.validator.test.js b/test/validators/return-versions/setup/purpose.validator.test.js index 637f4dae5d..6aed31dba5 100644 --- a/test/validators/return-versions/setup/purpose.validator.test.js +++ b/test/validators/return-versions/setup/purpose.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -105,9 +105,7 @@ describe('Return Versions Setup - Purpose validator', () => { describe('when invalid data is provided', () => { describe('because it contains an invalid purpose id', () => { beforeEach(() => { - purposes = [ - { id: 'c73399a6-2194-4d50-b4c8-c4fcf225c711', alias: '', description: 'Spray irrigation - direct' } - ] + purposes = [{ id: 'c73399a6-2194-4d50-b4c8-c4fcf225c711', alias: '', description: 'Spray irrigation - direct' }] }) it('fails validation', () => { @@ -121,9 +119,7 @@ describe('Return Versions Setup - Purpose validator', () => { describe('because it does not contain a purpose id', () => { beforeEach(() => { - purposes = [ - { alias: 'Spray irrigation indiscreet', description: 'Spray irrigation - direct' } - ] + purposes = [{ alias: 'Spray irrigation indiscreet', description: 'Spray irrigation - direct' }] }) it('fails validation', () => { @@ -141,7 +137,8 @@ describe('Return Versions Setup - Purpose validator', () => { purposes = [ { id: '14794d57-1acf-4c91-8b48-4b1ec68bfd6f', - alias: 'THGBk2GM85EyXB54SsfenU2yWiKjDuPTcJCrPfTsSzojNvj6ciVmI3PXJ2fisQgXWfSI4ZPIqV5GLPtR15qbcw3Hamoeit764Cojz', + alias: + 'THGBk2GM85EyXB54SsfenU2yWiKjDuPTcJCrPfTsSzojNvj6ciVmI3PXJ2fisQgXWfSI4ZPIqV5GLPtR15qbcw3Hamoeit764Cojz', description: 'Spray irrigation - direct' } ] diff --git a/test/validators/return-versions/setup/reason.validator.test.js b/test/validators/return-versions/setup/reason.validator.test.js index ebb6734ddf..f69a421c28 100644 --- a/test/validators/return-versions/setup/reason.validator.test.js +++ b/test/validators/return-versions/setup/reason.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it } = exports.lab = Lab.script() +const { describe, it } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/returns-cycle.validator.test.js b/test/validators/return-versions/setup/returns-cycle.validator.test.js index 630982f979..20494092e9 100644 --- a/test/validators/return-versions/setup/returns-cycle.validator.test.js +++ b/test/validators/return-versions/setup/returns-cycle.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test diff --git a/test/validators/return-versions/setup/site-description.validator.test.js b/test/validators/return-versions/setup/site-description.validator.test.js index 98e14cad00..1be0c9f073 100644 --- a/test/validators/return-versions/setup/site-description.validator.test.js +++ b/test/validators/return-versions/setup/site-description.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -61,7 +61,8 @@ describe('Return Versions Setup - Site Description validator', () => { }) describe('because the user provided a long site description', () => { - const invalidSiteDescription = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis.' + const invalidSiteDescription = + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis.' beforeEach(() => { payload = { diff --git a/test/validators/return-versions/setup/start-date.validator.test.js b/test/validators/return-versions/setup/start-date.validator.test.js index 5b44f59df6..719aca049e 100644 --- a/test/validators/return-versions/setup/start-date.validator.test.js +++ b/test/validators/return-versions/setup/start-date.validator.test.js @@ -4,7 +4,7 @@ const Lab = require('@hapi/lab') const Code = require('@hapi/code') -const { describe, it, beforeEach } = exports.lab = Lab.script() +const { describe, it, beforeEach } = (exports.lab = Lab.script()) const { expect } = Code // Thing under test @@ -154,7 +154,9 @@ describe('Return Versions Setup - Start Date validator', () => { const result = StartDateValidator.go(payload, licenceStartDate, licenceEndDate) expect(result.error).to.exist() - expect(result.error.details[0].message).to.equal('Start date must be on or after the original licence start date') + expect(result.error.details[0].message).to.equal( + 'Start date must be on or after the original licence start date' + ) }) })