-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2002 from bcgov/feat/ignore-non-carbon-taxed-emis…
…sions Feat: ignore non carbon taxed emissions
- Loading branch information
Showing
9 changed files
with
92 additions
and
33 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
%syntax-version=1.0.0 | ||
%project=mocks | ||
%uri=https://github.com/bcgov/cas-ciip-portal/tree/develop/mocks_schema | ||
|
||
schema_mocks 2020-10-28T17:42:06Z Pierre Bastianelli <[email protected]> # Creating schema for mocked functions | ||
mock_now_method [schema_mocks] 2020-10-28T17:59:38Z Pierre Bastianelli <[email protected]> # Mock method to override the default now() behaviour | ||
|
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
32 changes: 32 additions & 0 deletions
32
schema/deploy/application_validation_functions/[email protected]
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 @@ | ||
-- Deploy ggircs-portal:application_validation_functions/emission_category_missing_fuel to pg | ||
-- requires: tables/application_revision_validation_function | ||
-- requires: computed_columns/application_revision_validation | ||
|
||
begin; | ||
|
||
create or replace function ggircs_portal.emission_category_missing_fuel(app_revision ggircs_portal.application_revision) | ||
returns boolean | ||
as $$ | ||
|
||
with emissions as ( | ||
select distinct(source_type_name) as reported_via_emission | ||
from ggircs_portal.application_revision_emission_form_data(app_revision) ed | ||
where ed.annual_co2e > 0 | ||
), | ||
fuel_data as ( | ||
select * from ggircs_portal.application_revision_fuel_form_data(app_revision) | ||
), | ||
fuels as ( | ||
select distinct(display_name) as reported_via_fuel from ggircs_portal.emission_category ec | ||
join fuel_data | ||
on fuel_data.emission_category_id = ec.id | ||
and fuel_data.quantity > 0 | ||
) select (select count(*) from emissions where reported_via_emission not in (select reported_via_fuel from fuels)) = 0; | ||
|
||
$$ language sql stable; | ||
|
||
grant execute on function ggircs_portal.emission_category_missing_fuel to ciip_administrator, ciip_analyst, ciip_industry_user; | ||
|
||
comment on function ggircs_portal.emission_category_missing_fuel(ggircs_portal.application_revision) is 'This validation function for a CIIP (CleanBC Industrial Incentive Program) application determines if any emission categories have emissions reported in a category, but no corresponding fuels reported for that category'; | ||
|
||
commit; |
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
7 changes: 7 additions & 0 deletions
7
schema/revert/application_validation_functions/[email protected]
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,7 @@ | ||
-- Revert ggircs-portal:application_validation_functions/emission_category_missing_fuel from pg | ||
|
||
begin; | ||
|
||
drop function ggircs_portal.emission_category_missing_fuel; | ||
|
||
commit; |
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 |
---|---|---|
|
@@ -385,3 +385,4 @@ mutations/create_application_revision_mutation_chain [mutations/create_applicati | |
@v2.13.0 2021-09-28T16:52:13Z Dylan Leard <[email protected]> # release v2.13.0 | ||
@v2.13.1 2021-09-28T19:27:43Z Pierre Bastianelli <[email protected]> # release v2.13.1 | ||
@v2.13.2 2021-10-05T19:51:38Z Matthieu Foucault <[email protected]> # release v2.13.2 | ||
application_validation_functions/emission_category_missing_fuel [application_validation_functions/[email protected]] 2021-04-27T21:54:17Z Dylan Leard <[email protected]> # Validation function to determine if there a missing fuels based on the emission categories with reported emissions |
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
7 changes: 7 additions & 0 deletions
7
schema/verify/application_validation_functions/[email protected]
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,7 @@ | ||
-- Verify ggircs-portal:application_validation_functions/emission_category_missing_fuel on pg | ||
|
||
begin; | ||
|
||
select pg_get_functiondef('ggircs_portal.application_revision_ciip_incentive(ggircs_portal.application_revision)'::regprocedure); | ||
|
||
rollback; |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
%syntax-version=1.0.0 | ||
%project=test_helpers | ||
%uri=https://github.com/bcgov/cas-ciip-portal/tree/develop/test_helper_schema | ||
|
||
schema_test_helper 2020-09-24T20:39:13Z Dylan Leard <[email protected]> # schema to house test helper functions | ||
modify_triggers [schema_test_helper] 2020-09-29T17:16:23Z Dylan Leard <[email protected]> # function enables/disables triggers for test setup | ||
|