-
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.
- Loading branch information
1 parent
0994594
commit f9275dd
Showing
12 changed files
with
119 additions
and
83 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
3 changes: 2 additions & 1 deletion
3
...rm_change_holdback_amount_to_date_001.sql → [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
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
File renamed without changes.
48 changes: 0 additions & 48 deletions
48
schema/deploy/computed_columns/form_change_total_project_value_001.sql
This file was deleted.
Oops, something went wrong.
18 changes: 16 additions & 2 deletions
18
schema/revert/computed_columns/form_change_holdback_amount_to_date.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,21 @@ | ||
-- Revert cif:computed_columns/form_change_holdback_amount_to_date from pg | ||
-- Deploy cif:computed_columns/form_change_holdback_amount_to_date to pg | ||
-- requires: tables/form_change | ||
|
||
begin; | ||
|
||
drop function cif.form_change_holdback_amount_to_date(cif.form_change); | ||
create or replace function cif.form_change_holdback_amount_to_date(parameter_fc cif.form_change) | ||
returns numeric as | ||
$fn$ | ||
|
||
select | ||
round(sum(coalesce((fc.new_form_data->>'adjustedHoldbackAmount')::numeric, (fc.new_form_data->>'calculatedHoldbackAmount')::numeric, 0)), 2) | ||
from cif.form_change fc | ||
where fc.project_revision_id = $1.project_revision_id | ||
and json_schema_name = 'milestone' | ||
and (fc.new_form_data->>'hasExpenses')::boolean = true; | ||
|
||
$fn$ language sql stable; | ||
|
||
comment on function cif.form_change_holdback_amount_to_date(cif.form_change) is 'Computed column returns sum all holdback amounts for a project. Preference for value selection is adjustedHoldbackAmount > calculuatedHoldbackAmount > amount calculated via maximum milestone amount'; | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert cif:computed_columns/form_change_holdback_amount_to_date from pg | ||
|
||
begin; | ||
|
||
drop function cif.form_change_holdback_amount_to_date(cif.form_change); | ||
|
||
commit; |
38 changes: 36 additions & 2 deletions
38
schema/revert/computed_columns/form_change_total_project_value.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,41 @@ | ||
-- Revert cif:computed_columns/form_change_total_project_value from pg | ||
-- Deploy cif:computed_columns/form_change_total_project_value to pg | ||
|
||
begin; | ||
|
||
drop function cif.form_change_total_project_value; | ||
create or replace function cif.form_change_total_project_value(cif.form_change) | ||
returns numeric | ||
as | ||
$computed_column$ | ||
|
||
with additional_funding_sources as | ||
( | ||
select * from jsonb_to_recordset( | ||
(select (new_form_data ->> 'additionalFundingSources') | ||
from cif.form_change fc | ||
where fc.project_revision_id = $1.project_revision_id | ||
and fc.form_data_table_name = 'funding_parameter' | ||
and operation != 'archive' | ||
)::jsonb | ||
) as x(source text, amount numeric, status text) | ||
) | ||
select | ||
( | ||
(select coalesce(($1.new_form_data ->> 'proponentCost')::numeric, 0) + coalesce(($1.new_form_data ->> 'maxFundingAmount')::numeric, 0)) | ||
+ | ||
coalesce((select sum(amount::numeric) | ||
from additional_funding_sources | ||
where status = 'Approved' | ||
), 0) | ||
); | ||
$computed_column$ language sql stable; | ||
|
||
grant execute on function cif.form_change_total_project_value to cif_internal, cif_external, cif_admin; | ||
|
||
comment on function cif.form_change_total_project_value is | ||
$$ | ||
Computed column to return the total project value. | ||
Calculation: | ||
- Total Project Value = Maximum Funding Amount + Proponent Cost + approved Additional Funding Amount(s) | ||
$$; | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert cif:computed_columns/form_change_total_project_value from pg | ||
|
||
begin; | ||
|
||
drop function cif.form_change_total_project_value; | ||
|
||
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 |
---|---|---|
|
@@ -359,3 +359,5 @@ tables/attachment_002_delete_permission 2023-07-31T18:06:38Z Brianna Cerkiewicz | |
mutations/discard_project_attachment_form_change [mutations/[email protected]] 2023-07-31T18:05:23Z Brianna Cerkiewicz <briannacerkiewicz@pop-os> # Remove loop from discard mutation | ||
computed_columns/form_change_total_project_value_001 2023-07-21T00:06:15Z Gurjeet Matharu <[email protected]> # Modified cif.form_change_total_project_value function to return null if any input values are missing | ||
computed_columns/form_change_holdback_amount_to_date_001 2023-07-24T20:08:21Z Gurjeet Matharu <[email protected]># Modified cif.form_change_holdback_amount_to_date function to return null if any input values are missing for any milestone | ||
computed_columns/form_change_holdback_amount_to_date [computed_columns/[email protected]] 2023-07-27T22:18:03Z Gurjeet Matharu <[email protected]># Modified cif.form_change_holdback_amount_to_date function to return null if any input values are missing for any milestone | ||
computed_columns/form_change_total_project_value [computed_columns/[email protected]] 2023-07-27T22:19:30Z Gurjeet Matharu <[email protected]> # Modified cif.form_change_total_project_value function to return null if any input values are missing |
2 changes: 1 addition & 1 deletion
2
...rm_change_holdback_amount_to_date_001.sql → [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
2 changes: 1 addition & 1 deletion
2
...s/form_change_total_project_value_001.sql → [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