Skip to content

Commit

Permalink
Remove two-part tariff supplementary billing flag from the Licences
Browse files Browse the repository at this point in the history
… view (#1242)

https://eaflood.atlassian.net/browse/WATER-4587

The PR #1236 has changed how the SROC two-part tariff supplementary billing flag is set. Previously there was a boolean flag in the `licences` table/view to indicate if the licence should be included in the next TPT supplementary bill run. This is no longer sufficient for our needs as we are now required to record the specific year the TPT supplementary bill run is for.

So a new table `licence_supplementary_years` has been built that is now used to record if the licence should go into a supplementary bill run & for which year. As a result, the original flag in the `licences` table is no longer required.

In this PR the `include_in_sroc_tpt_billing` column will be removed from the view. The next PR will be in the `water-abstraction-service` to remove the actual column from the table.

The migrations get upset if I try to remove the column from the legacy migrations at the same time as the view so I'll do another PR.
  • Loading branch information
Jozzey authored Aug 8, 2024
1 parent d64b410 commit 14887bb
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions db/migrations/public/20240807160605_alter-licences-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict'

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([
'licence_id AS id',
'region_id',
'licence_ref',
'is_water_undertaker AS water_undertaker',
'regions',
'start_date',
'expired_date',
'lapsed_date',
'revoked_date',
'suspend_from_billing',
// 'is_test',
'include_in_supplementary_billing AS include_in_presroc_billing',
'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)
.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',
'is_water_undertaker AS water_undertaker',
'regions',
'start_date',
'expired_date',
'lapsed_date',
'revoked_date',
'suspend_from_billing',
// 'is_test',
'include_in_supplementary_billing AS include_in_presroc_billing',
'include_in_sroc_supplementary_billing AS include_in_sroc_billing',
'include_in_sroc_tpt_supplementary_billing AS include_in_sroc_tpt_billing',
'date_created AS created_at',
'date_updated AS updated_at'
]))
})
}

0 comments on commit 14887bb

Please sign in to comment.