diff --git a/schema/deploy/functions/handle_default_form_change_commit.sql b/schema/deploy/functions/handle_default_form_change_commit.sql index de46672278..bcab535df5 100644 --- a/schema/deploy/functions/handle_default_form_change_commit.sql +++ b/schema/deploy/functions/handle_default_form_change_commit.sql @@ -93,7 +93,7 @@ begin raise debug '%', query; execute query using fc.form_data_record_id; end if; - +raise notice 'record_id in default handler %:',record_id; return record_id; end; $$ language plpgsql volatile; diff --git a/schema/deploy/functions/handle_project_summary_report_form_change_commit.sql b/schema/deploy/functions/handle_project_summary_report_form_change_commit.sql index d7be220d7c..f4601c2448 100644 --- a/schema/deploy/functions/handle_project_summary_report_form_change_commit.sql +++ b/schema/deploy/functions/handle_project_summary_report_form_change_commit.sql @@ -6,18 +6,21 @@ begin; create or replace function cif_private.handle_project_summary_report_form_change_commit(fc cif.form_change) returns int as $$ declare - reporting_requirement_record_id int; + reporting_requirement_record_id int; begin - -- If there is no change in the form data, return the form_change record and do not touch the associated table. - if (fc.new_form_data = '{}') then - return fc.form_data_record_id; - end if; - if (fc.change_status = 'committed') then - raise exception 'Cannot commit form_change. It has already been committed.'; - end if; + -- If there is no change in the form data, return the form_change record and do not touch the associated table. + if (fc.new_form_data = '{}') then + return fc.form_data_record_id; -- can be null if creating with empty form data...problem? + end if; + + if (fc.change_status = 'committed') then + raise exception 'Cannot commit form_change. It has already been committed.'; + end if; - if fc.operation = 'create' then + reporting_requirement_record_id := fc.form_data_record_id; + + if fc.operation = 'create' then insert into cif.reporting_requirement( project_id, report_type, @@ -48,15 +51,10 @@ begin (fc.new_form_data->>'dateSentToCsnr')::timestamptz ); --- brianna is it this then? it sets it wrong? because it looks like it goes in right so it must be changed later. this is on create so that doesn't make sense - -- raise exception 'reporting_requirement_record_id: %', reporting_requirement_record_id; - update cif.form_change set form_data_record_id = reporting_requirement_record_id where id = fc.id; - - elsif fc.operation = 'update' then - raise notice 'form_data_record_id in handle commit: %', to_json((select form_data_record_id from cif.form_change where id = fc.id order by id desc limit 1)); + -- raise notice 'form_data_record_id in handle commit: %', to_json((select form_data_record_id from cif.form_change where id = fc.id order by id desc limit 1)); -- brianna missing payment notes? @@ -86,7 +84,8 @@ begin update cif.payment set archived_at = now() where reporting_requirement_id = fc.form_data_record_id; end if; - +-- brianna this reporting_requirement_record_id must be null sometimes +raise notice 'reporting_requirement_record_id in commit handler: %',reporting_requirement_record_id; return reporting_requirement_record_id; end; $$ language plpgsql volatile; diff --git a/schema/deploy/mutations/commit_form_change_internal.sql b/schema/deploy/mutations/commit_form_change_internal.sql index 9f3ef57521..2de4ba092c 100644 --- a/schema/deploy/mutations/commit_form_change_internal.sql +++ b/schema/deploy/mutations/commit_form_change_internal.sql @@ -20,10 +20,11 @@ begin 'select "cif_private".%I($1)', (select form_change_commit_handler from cif.form where slug = fc.json_schema_name) ) using fc into recordId; + -- brianna fc replaces $1. could it somehow be the wrong form change? raise notice 'handler %',(select form_change_commit_handler from cif.form where slug = fc.json_schema_name); raise notice 'THIS IS IT recordId: %', recordId; - raise notice 'fc is: %',fc; + -- raise notice 'fc is: %',fc; update cif.form_change set -- BRIANNA THIS IS IT! recordId is null for project summary report diff --git a/schema/deploy/mutations/create_project_revision.sql b/schema/deploy/mutations/create_project_revision.sql index 7bcdce84c7..e688cda0d2 100644 --- a/schema/deploy/mutations/create_project_revision.sql +++ b/schema/deploy/mutations/create_project_revision.sql @@ -166,12 +166,12 @@ begin project_revision_id => revision_row.id, json_schema_name => form_change_record.json_schema_name ) ; - raise notice '!!!!!!!!!!!!!form_change_record.operation:%',form_change_record.operation; - raise notice '!!!!!!!!!!!!!form_change_record.form_data_table_name:%',form_change_record.form_data_table_name; - raise notice '!!!!!!!!!!!!!revision_row.id:%',revision_row.id; - - raise notice '!!!!!!!!!!!!!form_change_record.json_schema_name:%',form_change_record.json_schema_name; - raise notice '!!!!!!!!!!!!!form_change_record.id:%',form_change_record.id; + -- raise notice '!!!!!!!!!!!!!form_change_record.operation:%',form_change_record.operation; + -- raise notice '!!!!!!!!!!!!!form_change_record.form_data_table_name:%',form_change_record.form_data_table_name; + -- raise notice '!!!!!!!!!!!!!revision_row.id:%',revision_row.id; + + -- raise notice '!!!!!!!!!!!!!form_change_record.json_schema_name:%',form_change_record.json_schema_name; + -- raise notice '!!!!!!!!!!!!!form_change_record.id:%',form_change_record.id; end loop; return revision_row; end;