-
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.
feat: updating validation logic on un-required products
- Loading branch information
AlexZorkin
authored and
AlexZorkin
committed
Oct 13, 2021
1 parent
a76dc27
commit 1435b6e
Showing
7 changed files
with
89 additions
and
4 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
27 changes: 27 additions & 0 deletions
27
schema/deploy/application_validation_functions/no_reported_ciip_product@v2.13.0.sql
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,27 @@ | ||
-- Deploy ggircs-portal:application_validation_functions/no_reported_ciip_product to pg | ||
-- requires: tables/application_revision_validation_function | ||
-- requires: computed_columns/application_revision_production_form_data | ||
-- requires: computed_columns/application_revision_validation | ||
|
||
begin; | ||
|
||
create or replace function ggircs_portal.no_reported_ciip_product(app_revision ggircs_portal.application_revision) | ||
returns boolean | ||
as $$ | ||
|
||
select exists ( | ||
select * from ggircs_portal.application_revision_production_form_data(app_revision) pfd | ||
join ggircs_portal.product p | ||
on pfd.product_id = p.id | ||
and p.is_ciip_product = true | ||
and p.is_energy_product = false | ||
and pfd.product_amount > 0 | ||
); | ||
|
||
$$ language sql stable; | ||
|
||
grant execute on function ggircs_portal.no_reported_ciip_product to ciip_administrator, ciip_analyst, ciip_industry_user; | ||
|
||
comment on function ggircs_portal.no_reported_ciip_product(ggircs_portal.application_revision) is 'This validation function for a CIIP (CleanBC Industrial Incentive Program) application determines if it contains at least one valid ciip product reported'; | ||
|
||
commit; |
24 changes: 22 additions & 2 deletions
24
schema/revert/application_validation_functions/no_reported_ciip_product.sql
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,7 +1,27 @@ | ||
-- Revert ggircs-portal:application_validation_functions/no_reported_ciip_product from pg | ||
-- Deploy ggircs-portal:application_validation_functions/no_reported_ciip_product to pg | ||
-- requires: tables/application_revision_validation_function | ||
-- requires: computed_columns/application_revision_production_form_data | ||
-- requires: computed_columns/application_revision_validation | ||
|
||
begin; | ||
|
||
drop function ggircs_portal.no_reported_ciip_product; | ||
create or replace function ggircs_portal.no_reported_ciip_product(app_revision ggircs_portal.application_revision) | ||
returns boolean | ||
as $$ | ||
|
||
select exists ( | ||
select * from ggircs_portal.application_revision_production_form_data(app_revision) pfd | ||
join ggircs_portal.product p | ||
on pfd.product_id = p.id | ||
and p.is_ciip_product = true | ||
and p.is_energy_product = false | ||
and pfd.product_amount > 0 | ||
); | ||
|
||
$$ language sql stable; | ||
|
||
grant execute on function ggircs_portal.no_reported_ciip_product to ciip_administrator, ciip_analyst, ciip_industry_user; | ||
|
||
comment on function ggircs_portal.no_reported_ciip_product(ggircs_portal.application_revision) is 'This validation function for a CIIP (CleanBC Industrial Incentive Program) application determines if it contains at least one valid ciip product reported'; | ||
|
||
commit; |
7 changes: 7 additions & 0 deletions
7
schema/revert/application_validation_functions/no_reported_ciip_product@v2.13.0.sql
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/no_reported_ciip_product from pg | ||
|
||
begin; | ||
|
||
drop function ggircs_portal.no_reported_ciip_product; | ||
|
||
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
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/no_reported_ciip_product@v2.13.0.sql
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/no_reported_ciip_product on pg | ||
|
||
begin; | ||
|
||
select pg_get_functiondef('ggircs_portal.no_reported_ciip_product(ggircs_portal.application_revision)'::regprocedure); | ||
|
||
rollback; |