Sie sind auf Seite 1von 11

award.awards_block_trig ('WHEN-NEW-BLOCK-INSTANCE'); award.awards_block_trig('WHEN-NEW-RECORD-INSTANCE'); award.awards_block_trig ('ON-INSERT'); award.awards_block_trig ('ON-DELETE'); award.awards_block_trig ('ON-UPDATE'); award.awards_block_trig ('KEY-COMMIT'); award.awards_block_trig ('WHEN-VALIDATE-RECORD'); award.awards_block_trig('WHEN-NEW-ITEM-INSTANCE'); award.

award_number('WHEN-VALIDATE-ITEM'); award.funding_source_short_name('WHEN-VALIDATE-ITEM'); award.award_short_name ('WHEN-VALIDATE-ITEM'); award.preaward_date('WHEN-VALIDATE-ITEM'); award.start_date_active('WHEN-VALIDATE-ITEM'); award.close_date('WHEN-VALIDATE-ITEM'); award.idc_schedule_date('WHEN-VALIDATE-ITEM'); award.check_award_number('WHEN-VALIDATE-ITEM'); award.award_number('WHEN-VALIDATE-ITEM'); award.idc_schedule_date('WHEN-VALIDATE-ITEM'); award_blk.boundary_code_dis('WHEN-VALIDATE-ITEM'); GMS_SUMM_FUNDING_PKG.CREATE_GMS_SUMMARY_FUNDING ( X_Installment_Id => :gms_fundings.installment_id, X_Project_Id => :gms_fundings.project_id, X_Task_Id => :gms_fundings.task_id, X_Funding_Amount => :gms_fundings.funding_amount, RETCODE => x_retcode, ERRBUF => x_errbuf ); GMS_SUMM_FUNDING_PKG.UPDATE_GMS_SUMMARY_FUNDING ( X_INSTALLMENT_ID => :gms_fundings.installment_id, X_PROJECT_ID => :gms_fundings.project_id, X_TASK_ID => :gms_fundings.task_id, X_OLD_AMOUNT => :gms_fundings.old_funding_amount, X_NEW_AMOUNT => :gms_fundings.funding_amount, RETCODE => x_retcode, ERRBUF => x_errbuf ); gms_reference_numbers_pkg.insert_row( X_ROWID => :gms_reference_numbers.row_id, X_AWARD_ID => :gms_reference_numbers.award_id, X_TYPE => :gms_reference_numbers.type, X_VALUE => :gms_reference_numbers.value, X_REQUIRED_FLAG => :gms_reference_numbers.required_flag, X_MODE => 'R' ); gms_reference_numbers_pkg.update_row( X_ROW_ID => :gms_reference_numbers.row_id, X_AWARD_ID => :gms_reference_numbers.award_id, X_TYPE => :gms_reference_numbers.type, X_VALUE => :gms_reference_numbers.value, X_REQUIRED_FLAG => :gms_reference_numbers.required_flag, X_MODE => 'R' ); gms_multi_funding.create_award_funding ( X_INSTALLMENT_ID => :gms_fundings.installment_id, X_ALLOCATED_AMOUNT => :gms_fundings.funding_amount, X_DATE_ALLOCATED => :gms_fundings.date_allocated, X_GMS_PROJECT_FUNDING_ID => :gms_fundings.gms_project_funding_id,

X_PROJECT_FUNDING_ID => :gms_fundings.project_funding_id, X_APP_SHORT_NAME => app_name, X_msg_count => msg_count, ERRBUF => temp_3, RETCODE => temp_4 ); gms_multi_funding.update_award_funding ( X_PROJECT_FUNDING_ID => :gms_fundings.project_funding_id, X_INSTALLMENT_ID => :gms_fundings.installment_id, X_OLD_ALLOCATED_AMOUNT => :gms_fundings.old_funding_amount, X_NEW_ALLOCATED_AMOUNT => :gms_fundings.funding_amount, X_OLD_DATE_ALLOCATED => :gms_fundings.old_date_allocated, X_NEW_DATE_ALLOCATED => :gms_fundings.date_allocated, X_APP_SHORT_NAME => app_name, X_msg_count => msg_count, ERRBUF => temp_3, RETCODE => temp_4 ); procedure start_date_active(event varchar2) is begin if event = 'WHEN-VALIDATE-ITEM' then verify_dates(:gms_personnel.start_date_active, :gms_personnel.end_date_active); end if; end start_date_active; procedure end_date_active(event varchar2) is begin if event = 'WHEN-VALIDATE-ITEM' then verify_dates(:gms_personnel.start_date_active, :gms_personnel.end_date_active); -- Bug 2635523 (CAN DECREASE AWD START DATE TO LESS THAN AWARD MGR ACTIVE START DATE) -- commented out the line below. Validation moved to post-forms-commit --VERIFY_AWARD_MANAGER_DATES; end if; end end_date_active; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ PACKAGE BODY GMS_FUNDINGS IS procedure gms_fundings_blk (event varchar2) is l_project_id GMS_PROJECT_FUNDINGS_V.PROJECT_ID%TYPE; begin if event = 'ON-INSERT' then -- BUG:938005 (10.7) - GMSAWEAW PKG get_gms_sum_funding return no rows if prio r -- line eq. zero ---IF CHECK_DUP_FUNDINGS > 0 THEN -- fnd_message.set_name( 'GMS', 'GMS_DUPLICATE_PROJECT_FUNDING') ; -- fnd_message.error ; -- raise form_trigger_failure ; --END IF ; -- End of fix.

-select gms_project_fundings_s.nextval into :gms_fundings.gms_project_funding_id from dual; gms_project_fundings.insert_row; gms_sum_prj_fundings.insert_row; gms_award_fundings.insert_row; -- Bug 2285203 : Added the below code to check the hard_limit_scenario in case of --ve funding If :gms_fundings.funding_amount < 0 and :gms_awards_v.hard_limit_flag = 'Y' T hen :parameter.p_validate_hard_limit := 'Y'; End if; /*Added below if condition for bug 6642901 */ If :gms_fundings.funding_amount < 0 and :gms_awards_v.invoice_limit_flag = 'Y ' Then :parameter.p_validate_invoice_limit := 'Y'; End if; elsif event = 'PRE-INSERT' then if not gms_funding_row_exist then null; elsif gms_funding_level(:gms_fundings.project_id) = 'P' and :gms_fundings.task_number is not NULL then fnd_message.set_name('GMS', 'GMS_PRJ_FUNDING_ONLY'); fnd_message.error; raise form_trigger_failure; elsif gms_funding_level(:gms_fundings.project_id) = 'T' and :gms_fundings.task_number is NULL then fnd_message.set_name('GMS', 'GMS_TASK_FUNDING_ONLY'); fnd_message.error; raise form_trigger_failure; end if; -- Bug Fix 2313606 -- The following code will prevent users from modifying funding for -- projects for which re-baselining is in progress l_project_id := name_in('GMS_FUNDINGS.PROJECT_ID'); if re_baselining(l_project_id) then fnd_message.set_name('GMS','GMS_RE_BASELINING'); fnd_message.set_token('PROJECT_NUM',name_in('GMS_FUNDINGS.PROJECT_NUMBER')); fnd_message.error; raise form_trigger_failure; end if; elsif event = 'PRE-BLOCK' then app_item_property.set_property('gms_fundings.task_number', enterable, property _on);

app_item_property.set_property('gms_fundings.task_number', enabled, property_o n); app_item_property.set_property('gms_fundings.task_number', navigable, property _on); app_item_property.set_property('gms_fundings.task_number', updateable, propert y_on); app_item_property.set_property ('gms_fundings.task_number', required, PROPERTY _off); elsif event = 'ON-UPDATE' then -- Bug Fix 2313606 -- The following code will prevent users from modifying funding for -- projects for which re-baselining is in progress l_project_id := name_in('GMS_FUNDINGS.PROJECT_ID'); if re_baselining(l_project_id) then fnd_message.set_name('GMS','GMS_RE_BASELINING'); fnd_message.set_token('PROJECT_NUM',name_in('GMS_FUNDINGS.PROJECT_NUMBER')); fnd_message.error; raise form_trigger_failure; end if; -- Bug 2285203 : Added the below code to check the hard_limit_scenario if (:gms_awards_v.hard_limit_flag = 'Y') and (:gms_fundings.funding_amount < :gms_fundings.old_funding_amount ) then :parameter.p_validate_hard_limit := 'Y'; end if; /*Added below if condition for bug 6642901 */ if (:gms_awards_v.invoice_limit_flag = 'Y') and (:gms_fundings.funding_amount < :gms_fundings.old_funding_amount ) then :parameter.p_validate_invoice_limit := 'Y'; end if; gms_project_fundings.update_row; gms_sum_prj_fundings.update_row; gms_award_fundings.update_row; :gms_fundings.old_funding_amount := :gms_fundings.funding_amount; :gms_fundings.old_date_allocated := :gms_fundings.date_allocated;

elsif event = 'WHEN-NEW-BLOCK-INSTANCE' then -- Bug 2580597 -- Changed the if condition -- if (:gms_awards_v.update_allowed = 'N') then if ((:gms_awards_v.update_allowed = 'N' or :parameter.calling_form = 'ASI' or (:parameter.mode = 'TEMPLATE' AND :gms_awards_v.award_template_flag = 'DE FERRED')) or -- Bug 2332443 (:gms_awards_v.status = 'CLOSED') Or :parameter.query_only='YES') /* Modif ied for Bug 6055853 */ then set_block_property ('GMS_FUNDINGS', UPDATE_ALLOWED, PROPERTY_FALSE ); set_block_property ('GMS_FUNDINGS', INSERT_ALLOWED, PROPERTY_FALSE );

set_block_property ('GMS_FUNDINGS', DELETE_ALLOWED, PROPERTY_FALSE ); else set_block_property ('GMS_FUNDINGS', UPDATE_ALLOWED, PROPERTY_TRUE ); set_block_property ('GMS_FUNDINGS', INSERT_ALLOWED, PROPERTY_TRUE ); set_block_property ('GMS_FUNDINGS', DELETE_ALLOWED, PROPERTY_TRUE ); end if; elsif event = 'POST-QUERY' then :gms_fundings.old_funding_amount := :gms_fundings.funding_amount; :gms_fundings.old_date_allocated := :gms_fundings.date_allocated; fundings_running_total.post_query; elsif event = 'ON-DELETE' then --start bug # 3194735 if :gms_fundings.total_fundings > :gms_installments.current_cost then fnd_message.set_name('GMS', 'GMS_FUNDING_AMOUNT_EXCEEDED'); fnd_message.error; raise form_trigger_failure; end if; --end bug # 3194735 -- Bug 2338817 (ABLE TO DELETE FUNDING WHEN AWARD BUDGET IS ZERO) check_funding_existence; -- Bug Fix 2313606 -- The following call will check the funding going below the budgeted -- amounts and will stop modifying the project/task for which re-base -- lining is in progress. check_budget_amounts; --adding new procedure shjain 7/30/99 gms_project_fundings.delete_row; gms_sum_prj_fundings.delete_row; gms_award_fundings.delete_row; --fundings_running_total.available_funding_amount('ON-DELETE'); --fundings_running_total.funding_amount('ON-DELETE'); --Bug Fix 1410485 set_budgets_menu; -- Bug 2285203 : Added the below code to check the hard_limit_scenario If :gms_awards_v.hard_limit_flag = 'Y' Then :parameter.p_validate_hard_limit := 'Y'; End if; /*Added below if condition for bug 6642901 */ If :gms_awards_v.invoice_limit_flag = 'Y' Then :parameter.p_validate_invoice_limit := 'Y'; End if; elsif event = 'POST-INSERT' then fundings_running_total.post_insert; --Bug Fix 1410485 set_budgets_menu; elsif event = 'WHEN-VALIDATE-RECORD' then begin select funding_amount into :gms_fundings.old_funding_amount from gms_project_fundings

where gms_project_funding_id = :gms_fundings.gms_project_funding_id; exception when no_data_found then null; end; elsif event = 'KEY-DELREC' then -- bug fix 2494619 check_budget_amounts; -- end bug fix 2494619 -- Bug Fix 2313606 -- Moved the following call to ON-DELETE trigger to avoid deleting multipl e -- funding lines at one shot and then save/commit. fundings_running_total.key_delrec; end if; end gms_fundings_blk; procedure project_number (event varchar2) is begin if event = 'WHEN-VALIDATE-ITEM' then if :gms_fundings.project_number is null then :gms_fundings.project_id := NULL; :gms_fundings.project_name := NULL; end if; :gms_fundings.task_number := NULL; :gms_fundings.task_name := NULL; :gms_fundings.task_id := NULL; check_funding_level; end if; end project_number; procedure task_number (event varchar2) is begin if event = 'WHEN-VALIDATE-ITEM' then if :gms_fundings.task_number is NULL then :gms_fundings.task_ID := NULL; end if; end if; end task_number; procedure funding_amount (event varchar2) is begin if event = 'WHEN-VALIDATE-ITEM' then fundings_running_total.price ('WHEN-VALIDATE-ITEM'); check_project_funding_amount('WHEN-VALIDATE-ITEM'); elsif event = 'UD_SUM_FUNDING_AMOUNT' then

declare lv_funded_amount number := 0 ; begin IF :GMS_FUNDINGS.PROJECT_NUMBER = :GLOBAL.PROJECT_NUMBER THEN lv_funded_amount := NVL(:GMS_FUNDINGS.FUNDING_AMOUNT,0) + to_number(:glob al.funding_amount) ; :global.funding_amount := to_char(lv_funded_amount) ; END IF ; end ; end if; end funding_amount; procedure verify_date (event varchar2) is x_result_start_date date; x_result_end_date date; begin if event = 'WHEN-VALIDATE-ITEM' then x_result_start_date := nvl(:gms_awards_v.preaward_date,:gms_awards_v.start_date _active); x_result_end_date := :gms_awards_v.close_date; -- if :gms_fundings.date_allocated not between x_result_start_date and x_result _end_date then -- Debashis -- Above line has been commented out to solve Bug 2332236. Keep end date valida tion. -- Remove start date validation. if :gms_fundings.date_allocated > x_result_end_date then FND_MESSAGE.SET_NAME('GMS','GMS_INVALID_FUNDING_DATE'); FND_MESSAGE.ERROR; -- if :gms_fundings.date_allocated not between x_result_start_date a nd x_result_end_date then RAISE form_trigger_failure; end if; /* Bug number 1672982 */ end if; end verify_date; -------------------------------------------------------------------------------------- Bug 2338817 (ABLE TO DELETE FUNDING WHEN AWARD BUDGET IS ZERO) --- Bug 2270436 Able to delete installments against which there -exists events. -- Added the select to check if any events exists for that installment -- Project and Task if the funding line is the last one. procedure check_funding_existence is budget_exists varchar2(1) := 'Y'; funding_exists varchar2(1) := 'N'; event_exists VARCHAR2(1) := 'N'; -- Added following cursor to fix bug 2758688 CURSOR budget_funding_exists IS select 'Y' from dual where exists (

select 1 from gms_project_fundings gpf, gms_installments gi where gpf.gms_project_funding_id <> :gms_fundings.gms_project_funding_ id and and and and begin begin select 'Y' into funding_exists from dual where exists ( select 1 from gms_project_fundings gpf, gms_installments gi where -- Bug Fix 2270436 -- gi.award_id = :gms_awards_v.award_id -- and gpf.installment_id = :gms_fundings.installment_id and gpf.project_id = :gms_fundings.project_id and NVL(gpf.task_id,-99) = NVL(:gms_fundings.task_id,-99) and gpf.gms_project_funding_id <> :gms_fundings.gms_project_funding_id ); exception when no_data_found then funding_exists := 'N'; end; if (funding_exists = 'N') then -- Bug Fix 2270436 begin select 'Y' into event_exists from dual where exists ( select 1 from gms_event_attribute where project_id = :gms_awards_v.award_project_id -- Bug Fix 2270436 Added the Installment in the where clause. and installment_id = :gms_fundings.installment_id and actual_project_id = :gms_fundings.project_id -- Commented the following for Bug Fix 2839061. -- and nvl(actual_task_id, -99) = nvl(:gms_fundings.task_id, 99)); -- Added the following for Bug Fix 2839061. and ((:gms_fundings.task_id is NULL) or (( :gms_fundings.task_i d is NOT NULL) and (:gms_fundings.task_id) = (select top_task_id from pa_tasks where task_id = actual_task_id )))); -- End of Bug Fix 2839061. fnd_message.set_name('GMS','GMS_EVENT_EXIST_FOR_PROJ_TASK'); fnd_message.error; raise form_trigger_failure; exception when no_data_found then null; gi.award_id = :gms_awards_v.award_id gpf.installment_id = gi.installment_id gpf.project_id = :gms_fundings.project_id NVL(gpf.task_id,-99) = NVL(:gms_fundings.task_id,-99));

end; -- End of bug Fix 2270436 end if;

begin OPEN budget_funding_exists; FETCH budget_funding_exists INTO funding_exists; CLOSE budget_funding_exists; IF (funding_exists = 'N') THEN IF gms_funding_level(:gms_fundings.project_id) = 'P' THEN SELECT 'Y' INTO budget_exists FROM dual WHERE EXISTS ( SELECT 1 FROM gms_budget_versions WHERE award_id = :gms_awards_v.award_id AND project_id = :gms_fundings.project_id); ELSE SELECT 'Y' INTO budget_exists FROM dual WHERE EXISTS ( SELECT 1 FROM gms_resource_assignments ra, gms_budget_versions bv, pa_tasks pt WHERE bv.award_id = :gms_awards_v.award_id AND bv.project_id = :gms_fundings.project_id AND ra.budget_version_id = bv.budget_version_id AND ra.task_id = pt.task_id AND pt.top_task_id = :gms_fundings.task_id); END IF; FND_MESSAGE.SET_NAME('GMS', 'GMS_CHECK_FUNDING_AMOUNT'); FND_MESSAGE.ERROR; RAISE FORM_TRIGGER_FAILURE; end if; exception when no_data_found then null; end; end check_funding_existence; END; PACKAGE BODY project_funding_amt_validation IS function get_sum_for_all_records( arg_project_id number ) return number is l_currec number ; l_funding_amount number ; begin l_currec := get_block_property('gms_fundings',CURRENT_RECORD ) ; FIRST_RECORD ; LOOP IF :gms_fundings.project_id = arg_project_id THEN

l_funding_amount := l_funding_amount + nvl(:gms_fundings.funding_amount ,0) ; END IF ; IF :SYSTEM.LAST_RECORD = 'TRUE' THEN EXIT ; ELSE NEXT_RECORD ; END IF ; END LOOP ; go_record(l_currec) ; return l_funding_amount ; end ; function project_funded_amount(arg_project_id NUMBER) return number IS l_installment_id NUMBER ; l_funded_amount NUMBER ; begin l_installment_id := :GMS_INSTALLMENTS.INSTALLMENT_ID; select into from where and sum(total_funding_amount) l_funded_amount gms_summary_project_fundings project_id = arg_project_id installment_id in (select installment_id from gms_installments where installment_id <> l_installment_id and award_id = :gms_awards_v.award_id );

return ( get_sum_for_all_records( :gms_fundings.project_number ) + l_fund ed_amount ) ; RETURN NULL; exception WHEN OTHERS then return -1 ; END ; function project_budgeted_amount(arg_project_id number) return number is budgeted_amount number; begin /* Not relevant in 11i as Budgets Module is owned by GMS select sum(burdened_cost) into budgeted_amount from pa_resource_assignments pra, pa_budget_lines pbl where pra.resource_assignment_id = pbl.resource_assignment_id and pra.budget_version_id = (select budget_version_id from pa_budget_versi ons where budget_type_code = to_char(:gms_awards _v.award_id ) and budget_status_code ='B' and current_flag ='Y' and project_id = arg_project_id);

*/ select burdened_cost into budgeted_amount from gms_budget_versions where award_id = :gms_awards_v.award_id and budget_status_code ='B' and current_flag ='Y' and project_id = arg_project_id ; return ( budgeted_amount ) ; RETURN NULL; exception WHEN OTHERS then return -1 ; end ; procedure funding_amount_validation is v_project_id number ; v_award_id number; v_proj_funded_amount NUMBER ; v_budget_amount NUMBER ; begin FIRST_RECORD ; LOOP v_project_id := :gms_fundings.project_id ; v_proj_funded_amount := PROJECT_FUNDED_AMOUNT( :gms_fundings.project_id); IF v_proj_funded_amount < 0 THEN raise form_trigger_failure ; END IF ; v_budget_amount := PROJECT_BUDGETED_AMOUNT(:gms_fundings.project_id);

IF v_budget_amount < 0 THEN raise form_trigger_failure ; END IF ; IF v_proj_funded_amount < v_budget_amount THEN raise form_trigger_failure ; end if ; IF :SYSTEM.LAST_RECORD = 'TRUE' THEN EXIT ; ELSE NEXT_RECORD ; END IF ; END LOOP ; end ; END;

Das könnte Ihnen auch gefallen