-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display source of supply in view licence page summary tab (#732)
* Display source of supply in view licence page summary tab https://eaflood.atlassian.net/browse/WATER-4327 Migrating the licence summary page from the water-abstraction-ui to the water-abstraction-system. This PR adds the source of the supply onto the summary page
- Loading branch information
1 parent
3aaaa59
commit 0490b87
Showing
12 changed files
with
357 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
|
||
/** | ||
* Model for PermitLicence (permit.licence) | ||
* @module PermitLicenceModel | ||
*/ | ||
|
||
const { Model } = require('objection') | ||
|
||
const BaseModel = require('./base.model.js') | ||
|
||
class PermitLicenceModel extends BaseModel { | ||
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 relationMappings () { | ||
return { | ||
permitLicence: { | ||
relation: Model.HasOneRelation, | ||
modelClass: 'licence.model', | ||
join: { | ||
from: 'permitLicences.licenceRef', | ||
to: 'licences.licenceRef' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
module.exports = PermitLicenceModel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
|
||
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()')) | ||
|
||
// 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 }) | ||
}) | ||
} | ||
|
||
exports.down = function (knex) { | ||
return knex | ||
.schema | ||
.withSchema('permit') | ||
.dropTableIfExists(tableName) | ||
} |
32 changes: 32 additions & 0 deletions
32
db/migrations/public/20240214142212_create-permit-licence-view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict' | ||
|
||
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' | ||
])) | ||
}) | ||
} | ||
|
||
exports.down = function (knex) { | ||
return knex | ||
.schema | ||
.dropViewIfExists(viewName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ const LicenceHolderSeeder = require('../../support/seeders/licence-holder.seeder | |
const LicenceVersionHelper = require('../../support/helpers/licence-version.helper.js') | ||
const LicenceVersionPurposeHelper = require('../../support/helpers/licence-version-purpose.helper.js') | ||
const PurposeHelper = require('../../support/helpers/purpose.helper.js') | ||
const PermitLicenceHelper = require('../../support/helpers/permit-licence.helper.js') | ||
const RegionHelper = require('../../support/helpers/region.helper.js') | ||
|
||
// Thing under test | ||
|
@@ -76,6 +77,7 @@ describe('Fetch licence service', () => { | |
expect(result.region.displayName).to.equal('Avalon') | ||
expect(result.registeredTo).to.equal(null) | ||
expect(result.revokedDate).to.equal(null) | ||
expect(result.permitLicence).to.equal(null) | ||
}) | ||
}) | ||
|
||
|
@@ -104,6 +106,19 @@ describe('Fetch licence service', () => { | |
purposeId: purpose.id | ||
}) | ||
|
||
await PermitLicenceHelper.add({ | ||
licenceRef: licence.licenceRef, | ||
licenceDataValue: { | ||
data: { | ||
current_version: { | ||
purposes: [{ | ||
purposePoints: [{ point_source: { NAME: 'Ground water' } }] | ||
}] | ||
} | ||
} | ||
} | ||
}) | ||
|
||
const licenceRole = await LicenceRoleHelper.add() | ||
const licenceName = 'Test Company Ltd' | ||
const companyEntityId = 'c960a4a1-94f9-4c05-9db1-a70ce5d08738' | ||
|
@@ -140,6 +155,9 @@ describe('Fetch licence service', () => { | |
expect(result.region.displayName).to.equal('Avalon') | ||
expect(result.registeredTo).to.equal('[email protected]') | ||
expect(result.revokedDate).to.equal(null) | ||
expect(result.permitLicence.purposes).to.equal([{ | ||
purposePoints: [{ point_source: { NAME: 'Ground water' } }] | ||
}]) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.