From 4c300dcd40d76e72a49fa9001368379efdda5a6b Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 3 Jun 2024 14:08:45 +0100 Subject: [PATCH 1/4] Tidy up of the Models and comments This PR is a bit of house keeping. This PR focuses on tidying up some of the Models recently created to keep them consistent with out coding conventions and editing an existing comment to update it. From 35c528a220b32ec954022382731c7d94ef863a83 Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 3 Jun 2024 14:20:28 +0100 Subject: [PATCH 2/4] House Keeping --- app/models/financial-agreement.model.js | 6 +++--- app/models/gauging-station.model.js | 6 +++--- app/models/licence-agreement.model.js | 6 +++--- app/models/licence-gauging-station.model.js | 8 ++++---- .../licence-version-purpose-condition-type.model.js | 6 +++--- app/models/licence-version-purpose-condition.model.js | 6 +++--- app/models/licence-version-purpose.model.js | 6 +++--- app/services/licences/fetch-agreements.service.js | 4 ++-- test/support/helpers/bill-run-volume.helper.js | 2 +- .../licence-version-purpose-condition-type.helper.js | 6 +++--- .../helpers/licence-version-purpose-condition.helper.js | 2 +- test/support/helpers/licence-version-purpose.helper.js | 6 +++--- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/app/models/financial-agreement.model.js b/app/models/financial-agreement.model.js index 11fc4727da..0177300611 100644 --- a/app/models/financial-agreement.model.js +++ b/app/models/financial-agreement.model.js @@ -2,14 +2,14 @@ /** * Model for FinancialAgreements (water.financial_agreements) - * @module FinancialAgreements + * @module FinancialAgreementModel */ const { Model } = require('objection') const BaseModel = require('./base.model.js') -class FinancialAgreements extends BaseModel { +class FinancialAgreementModel extends BaseModel { static get tableName () { return 'financialAgreements' } @@ -28,4 +28,4 @@ class FinancialAgreements extends BaseModel { } } -module.exports = FinancialAgreements +module.exports = FinancialAgreementModel diff --git a/app/models/gauging-station.model.js b/app/models/gauging-station.model.js index a63133fa14..7f4b56f242 100644 --- a/app/models/gauging-station.model.js +++ b/app/models/gauging-station.model.js @@ -2,14 +2,14 @@ /** * Model for gaugingStations (water.gauging_stations) - * @module GaugingStationsnModel + * @module GaugingStationModel */ const { Model } = require('objection') const BaseModel = require('./base.model.js') -class GaugingStationsnModel extends BaseModel { +class GaugingStationModel extends BaseModel { static get tableName () { return 'gaugingStations' } @@ -35,4 +35,4 @@ class GaugingStationsnModel extends BaseModel { } } -module.exports = GaugingStationsnModel +module.exports = GaugingStationModel diff --git a/app/models/licence-agreement.model.js b/app/models/licence-agreement.model.js index 58186fa724..9492271b98 100644 --- a/app/models/licence-agreement.model.js +++ b/app/models/licence-agreement.model.js @@ -2,14 +2,14 @@ /** * Model for LicenceAgreements (water.licence_agreements) - * @module LicenceAgreements + * @module LicenceAgreementModel */ const { Model } = require('objection') const BaseModel = require('./base.model.js') -class LicenceAgreements extends BaseModel { +class LicenceAgreementModel extends BaseModel { static get tableName () { return 'licenceAgreements' } @@ -28,4 +28,4 @@ class LicenceAgreements extends BaseModel { } } -module.exports = LicenceAgreements +module.exports = LicenceAgreementModel diff --git a/app/models/licence-gauging-station.model.js b/app/models/licence-gauging-station.model.js index 1dab19c3f2..f37d163f9c 100644 --- a/app/models/licence-gauging-station.model.js +++ b/app/models/licence-gauging-station.model.js @@ -1,15 +1,15 @@ 'use strict' /** - * Model for licenceGauginStations (water.licence_gauging_stations) - * @module GauginStationsnModel + * Model for licenceGaugingStations (water.licence_gauging_stations) + * @module LicenceGaugingStationModel */ const { Model } = require('objection') const BaseModel = require('./base.model.js') -class LicenceGauginStationsnModel extends BaseModel { +class LicenceGaugingStationModel extends BaseModel { static get tableName () { return 'licenceGaugingStations' } @@ -28,4 +28,4 @@ class LicenceGauginStationsnModel extends BaseModel { } } -module.exports = LicenceGauginStationsnModel +module.exports = LicenceGaugingStationModel diff --git a/app/models/licence-version-purpose-condition-type.model.js b/app/models/licence-version-purpose-condition-type.model.js index d5c39b4983..60c102e628 100644 --- a/app/models/licence-version-purpose-condition-type.model.js +++ b/app/models/licence-version-purpose-condition-type.model.js @@ -2,14 +2,14 @@ /** * Model for LicenceVersionPurposeConditionType (water.licence_version_purpose_condition_types) - * @module LicenceVersionPurposeConditionTypes + * @module LicenceVersionPurposeConditionTypeModel */ const { Model } = require('objection') const BaseModel = require('./base.model.js') -class LicenceVersionPurposeConditionTypes extends BaseModel { +class LicenceVersionPurposeConditionTypeModel extends BaseModel { static get tableName () { return 'licenceVersionPurposeConditionTypes' } @@ -28,4 +28,4 @@ class LicenceVersionPurposeConditionTypes extends BaseModel { } } -module.exports = LicenceVersionPurposeConditionTypes +module.exports = LicenceVersionPurposeConditionTypeModel diff --git a/app/models/licence-version-purpose-condition.model.js b/app/models/licence-version-purpose-condition.model.js index b68bf9ec45..5d6a7565d2 100644 --- a/app/models/licence-version-purpose-condition.model.js +++ b/app/models/licence-version-purpose-condition.model.js @@ -2,14 +2,14 @@ /** * Model for LicenceVersionPurposeCondition (water.licence_version_purpose_conditions) - * @module LicenceVersionPurposeConditions + * @module LicenceVersionPurposeConditionModel */ const { Model } = require('objection') const BaseModel = require('./base.model.js') -class LicenceVersionPurposeConditions extends BaseModel { +class LicenceVersionPurposeConditionModel extends BaseModel { static get tableName () { return 'licenceVersionPurposeConditions' } @@ -28,4 +28,4 @@ class LicenceVersionPurposeConditions extends BaseModel { } } -module.exports = LicenceVersionPurposeConditions +module.exports = LicenceVersionPurposeConditionModel diff --git a/app/models/licence-version-purpose.model.js b/app/models/licence-version-purpose.model.js index 3c616c51eb..0da56ee88d 100644 --- a/app/models/licence-version-purpose.model.js +++ b/app/models/licence-version-purpose.model.js @@ -2,14 +2,14 @@ /** * Model for LicenceVersionPurposes (water.licence_version_purposes) - * @module LicenceVersionPurposes + * @module LicenceVersionPurposeModel */ const { Model } = require('objection') const BaseModel = require('./base.model.js') -class LicenceVersionPurposes extends BaseModel { +class LicenceVersionPurposeModel extends BaseModel { static get tableName () { return 'licenceVersionPurposes' } @@ -36,4 +36,4 @@ class LicenceVersionPurposes extends BaseModel { } } -module.exports = LicenceVersionPurposes +module.exports = LicenceVersionPurposeModel diff --git a/app/services/licences/fetch-agreements.service.js b/app/services/licences/fetch-agreements.service.js index a3e31a1b37..4ac2e49205 100644 --- a/app/services/licences/fetch-agreements.service.js +++ b/app/services/licences/fetch-agreements.service.js @@ -5,7 +5,7 @@ * @module FetchAgreementsService */ -const LicenceAgreements = require('../../models/licence-agreement.model.js') +const LicenceAgreementModel = require('../../models/licence-agreement.model.js') /** * Fetches charge version data needed for the view '/licences/{id}/set-up` page @@ -19,7 +19,7 @@ async function go (licenceRef) { } async function _fetch (licenceRef) { - return LicenceAgreements.query() + return LicenceAgreementModel.query() .where('licenceRef', licenceRef) .select([ 'id', diff --git a/test/support/helpers/bill-run-volume.helper.js b/test/support/helpers/bill-run-volume.helper.js index f74890c2e9..88e77ccc23 100644 --- a/test/support/helpers/bill-run-volume.helper.js +++ b/test/support/helpers/bill-run-volume.helper.js @@ -19,7 +19,7 @@ const { generateUUID } = require('../../../app/lib/general.lib.js') * * @param {Object} [data] Any data you want to use instead of the defaults used here or in the database * - * @returns {Promise} The instance of the newly created record + * @returns {Promise} The instance of the newly created record */ function add (data = {}) { const insertData = defaults(data) 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 04ba158da8..5d8b5513c2 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,7 @@ */ const { timestampForPostgres } = require('../../../app/lib/general.lib.js') -const LicenceVersionPurposeConditionTypesModel = require('../../../app/models/licence-version-purpose-condition-type.model.js') +const LicenceVersionPurposeConditionTypeModel = require('../../../app/models/licence-version-purpose-condition-type.model.js') /** * Add a new licence version purpose @@ -22,12 +22,12 @@ const LicenceVersionPurposeConditionTypesModel = require('../../../app/models/li * * @param {Object} [data] Any data you want to use instead of the defaults used here or in the database * - * @returns {Promise} The instance of the newly created record + * @returns {Promise} The instance of the newly created record */ async function add (data = {}) { const insertData = defaults(data) - return LicenceVersionPurposeConditionTypesModel.query() + return LicenceVersionPurposeConditionTypeModel.query() .insert({ ...insertData }) .returning('*') } diff --git a/test/support/helpers/licence-version-purpose-condition.helper.js b/test/support/helpers/licence-version-purpose-condition.helper.js index 53cc046ca0..a72cb1c252 100644 --- a/test/support/helpers/licence-version-purpose-condition.helper.js +++ b/test/support/helpers/licence-version-purpose-condition.helper.js @@ -23,7 +23,7 @@ const { randomInteger } = require('../general.js') * * @param {Object} [data] Any data you want to use instead of the defaults used here or in the database * - * @returns {Promise} The instance of the newly created record + * @returns {Promise} The instance of the newly created record */ async function add (data = {}) { const insertData = defaults(data) diff --git a/test/support/helpers/licence-version-purpose.helper.js b/test/support/helpers/licence-version-purpose.helper.js index 4e7dda61ad..680e345956 100644 --- a/test/support/helpers/licence-version-purpose.helper.js +++ b/test/support/helpers/licence-version-purpose.helper.js @@ -5,7 +5,7 @@ */ const { generateUUID, timestampForPostgres } = require('../../../app/lib/general.lib.js') -const LicenceVersionPurposesModel = require('../../../app/models/licence-version-purpose.model.js') +const LicenceVersionPurposeModel = require('../../../app/models/licence-version-purpose.model.js') const { randomInteger } = require('../general.js') /** @@ -27,12 +27,12 @@ const { randomInteger } = require('../general.js') * * @param {Object} [data] Any data you want to use instead of the defaults used here or in the database * - * @returns {Promise} The instance of the newly created record + * @returns {Promise} The instance of the newly created record */ async function add (data = {}) { const insertData = defaults(data) - return LicenceVersionPurposesModel.query() + return LicenceVersionPurposeModel.query() .insert({ ...insertData }) .returning('*') } From c765f94c28b0e8f49582a992b0d945badf34243a Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 3 Jun 2024 14:22:48 +0100 Subject: [PATCH 3/4] Update comment --- app/services/bill-runs/generate-transactions.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/bill-runs/generate-transactions.service.js b/app/services/bill-runs/generate-transactions.service.js index bc7b8fc712..28285c1122 100644 --- a/app/services/bill-runs/generate-transactions.service.js +++ b/app/services/bill-runs/generate-transactions.service.js @@ -19,7 +19,7 @@ const CalculateAuthorisedAndBillableDaysServiceService = require('./calculate-au * * If the `waterUndertaker` flag was false, it will then generate a second 'compensation' transaction object based on * the first. The only differences are the charge type and description properties. This is something the Charging - * Module expects to receive when the licence is for a water undertaker. + * Module expects to receive when the licence is not for a water undertaker. * * They will then be returned in an array for further processing before being persisted to the DB as * `billing_transactions`. From d9c7da3cd095d6ca6b57402e9e6236e6cc2603e8 Mon Sep 17 00:00:00 2001 From: Rebecca Ransome Date: Mon, 3 Jun 2024 17:25:40 +0100 Subject: [PATCH 4/4] Update model comments to show view name and table name --- app/models/company-contact.model.js | 2 +- app/models/financial-agreement.model.js | 2 +- app/models/gauging-station.model.js | 2 +- app/models/licence-agreement.model.js | 2 +- app/models/licence-gauging-station.model.js | 2 +- app/models/licence-version-purpose-condition-type.model.js | 2 +- app/models/licence-version-purpose-condition.model.js | 2 +- app/models/licence-version-purpose.model.js | 2 +- app/models/licence-version.model.js | 2 +- app/models/permit-licence.model.js | 2 +- app/models/scheduled-notification.model.js | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/models/company-contact.model.js b/app/models/company-contact.model.js index 6d46c450f0..f56044a2c8 100644 --- a/app/models/company-contact.model.js +++ b/app/models/company-contact.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for company contact (crm_v2.company_contacts) + * Model for company_contacts (crm_v2.company_contacts) * @module CompanyContactModel */ diff --git a/app/models/financial-agreement.model.js b/app/models/financial-agreement.model.js index 0177300611..43a6de29a6 100644 --- a/app/models/financial-agreement.model.js +++ b/app/models/financial-agreement.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for FinancialAgreements (water.financial_agreements) + * Model for financial_agreements (water.financial_agreement_types) * @module FinancialAgreementModel */ diff --git a/app/models/gauging-station.model.js b/app/models/gauging-station.model.js index 7f4b56f242..f659d2d86d 100644 --- a/app/models/gauging-station.model.js +++ b/app/models/gauging-station.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for gaugingStations (water.gauging_stations) + * Model for gauging_stations (water.gauging_stations) * @module GaugingStationModel */ diff --git a/app/models/licence-agreement.model.js b/app/models/licence-agreement.model.js index 9492271b98..80ca101666 100644 --- a/app/models/licence-agreement.model.js +++ b/app/models/licence-agreement.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for LicenceAgreements (water.licence_agreements) + * Model for licence_agreements (water.licence_agreements) * @module LicenceAgreementModel */ diff --git a/app/models/licence-gauging-station.model.js b/app/models/licence-gauging-station.model.js index f37d163f9c..9bce13ac8b 100644 --- a/app/models/licence-gauging-station.model.js +++ b/app/models/licence-gauging-station.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for licenceGaugingStations (water.licence_gauging_stations) + * Model for licence_gauging_stations (water.licence_gauging_stations) * @module LicenceGaugingStationModel */ diff --git a/app/models/licence-version-purpose-condition-type.model.js b/app/models/licence-version-purpose-condition-type.model.js index 60c102e628..8fec9b7f2a 100644 --- a/app/models/licence-version-purpose-condition-type.model.js +++ b/app/models/licence-version-purpose-condition-type.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for LicenceVersionPurposeConditionType (water.licence_version_purpose_condition_types) + * Model for licence_version_purpose_condition_types (water.licence_version_purpose_condition_types) * @module LicenceVersionPurposeConditionTypeModel */ diff --git a/app/models/licence-version-purpose-condition.model.js b/app/models/licence-version-purpose-condition.model.js index 5d6a7565d2..13ec130abf 100644 --- a/app/models/licence-version-purpose-condition.model.js +++ b/app/models/licence-version-purpose-condition.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for LicenceVersionPurposeCondition (water.licence_version_purpose_conditions) + * Model for licence_version_purpose_conditions (water.licence_version_purpose_conditions) * @module LicenceVersionPurposeConditionModel */ diff --git a/app/models/licence-version-purpose.model.js b/app/models/licence-version-purpose.model.js index 0da56ee88d..2a2862c818 100644 --- a/app/models/licence-version-purpose.model.js +++ b/app/models/licence-version-purpose.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for LicenceVersionPurposes (water.licence_version_purposes) + * Model for licence_version_purposes (water.licence_version_purposes) * @module LicenceVersionPurposeModel */ diff --git a/app/models/licence-version.model.js b/app/models/licence-version.model.js index 9522be5a17..03d012f073 100644 --- a/app/models/licence-version.model.js +++ b/app/models/licence-version.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for licenceVersions (water.licence_versions) + * Model for licence_versions (water.licence_versions) * @module LicenceVersionModel */ diff --git a/app/models/permit-licence.model.js b/app/models/permit-licence.model.js index dc86bbda7a..7612e9776d 100644 --- a/app/models/permit-licence.model.js +++ b/app/models/permit-licence.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for PermitLicence (permit.licence) + * Model for permit_licences (permit.licence) * @module PermitLicenceModel */ diff --git a/app/models/scheduled-notification.model.js b/app/models/scheduled-notification.model.js index 5e859f3a4e..9829fd3655 100644 --- a/app/models/scheduled-notification.model.js +++ b/app/models/scheduled-notification.model.js @@ -1,7 +1,7 @@ 'use strict' /** - * Model for scheduled notifications (water.scheduled_notification) + * Model for scheduled_notification (water.scheduled_notification) * @module ScheduledNotificationModel */