Skip to content

Commit

Permalink
chore: zeros for denied and awaiting approval
Browse files Browse the repository at this point in the history
  • Loading branch information
gurjmatharu authored and dleard committed Sep 12, 2023
1 parent 90018ac commit 4051edf
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions schema/deploy/computed_columns/form_change_total_project_value.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ with additional_funding_sources as
),
additional_funding_sources_sum as
(
select sum(amount::numeric) as total from additional_funding_sources where status = 'Approved'
),
additional_funding_sources_exist as
(
select 1 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'
and new_form_data->'additionalFundingSources' is not null
select
sum(case when status = 'Approved' then amount::numeric
when status = 'Denied' then 0
when status = 'Awaiting Approval' then 0
end) as total
from additional_funding_sources
)
select
case
Expand All @@ -33,9 +30,6 @@ select
($1.new_form_data ->> 'proponentCost')::numeric IS NULL
OR
($1.new_form_data ->> 'maxFundingAmount')::numeric IS NULL
OR
((select * from additional_funding_sources_exist) is not null
AND (select total from additional_funding_sources_sum) IS NULL)
) THEN NULL
else
(
Expand Down

0 comments on commit 4051edf

Please sign in to comment.