1 PACKAGE BODY JAI_AP_PSA_TRIGGER_PKG AS
2 /* $Header: jai_ap_psa_t.plb 120.0 2005/09/01 12:34:50 rallamse noship $ */
3 /*
4 REM +======================================================================+
5 REM NAME BRIUD_T1
6 REM
7 REM DESCRIPTION Called from trigger JAI_AP_PSA_BRIUD_T1
8 REM
9 REM NOTES Refers to old trigger JAI_AP_PSA_BRIUD_T1
10 REM
11 REM +======================================================================+
12 */
13 PROCEDURE BRIUD_T1 ( pr_old t_rec%type , pr_new in out t_rec%type , pv_action varchar2 , pv_return_code out nocopy varchar2 , pv_return_message out nocopy varchar2 ) IS
14 cursor c_ap_invoices_all(p_invoice_id number) is
15 select source,
16 invoice_type_lookup_code
17 from ap_invoices_all
18 where invoice_id = p_invoice_id;
19
20 cursor c_jai_ap_tds_thhold_trxs(p_invoice_id number) is
21 select parent_inv_payment_priority
22 from jai_ap_tds_thhold_trxs
23 where invoice_to_vendor_id = p_invoice_id;
24
25 ln_parent_inv_payment_priority jai_ap_tds_thhold_trxs.parent_inv_payment_priority%type;
26 r_ap_invoices_all c_ap_invoices_all%rowtype;
27 ln_org_id ap_invoices_all.org_id%type;
28
29 BEGIN
30 pv_return_code := jai_constants.successful ;
31 /*------------------------------------------------------------------------------------------
32 FILENAME: ja_in_ap_apsa_before_trg.sql
33
34 CHANGE HISTORY:
35 S.No Date Author and Details
36
37 1. 25/03/2004 Aparajita. Bug # 4088186. TDS Clean up. Version#115.0
38
39 This is the only trigger introduced for all the before event
40 on the table on which this is based.
41
42 2. 24/05/2005 Ramananda for bug# 4388958 File Version: 116.1
43 Changed AP Lookup code from 'TDS' to 'INDIA TDS'
44
45 3. 08-Jun-2005 This Object is Modified to refer to New DB Entity names in place of Old
46 DB Entity as required for CASE COMPLAINCE. Version 116.2
47
48 4. 13-Jun-2005 File Version: 116.3
49 Ramananda for bug#4428980. Removal of SQL LITERALs is done
50 Dependency:
51 ----------
52
53 Sl No. Bug Dependent on
54 Bug/Patch set Details
55 -------------------------------------------------------------------------------------------------
56 1 3924692 4033992 Call to jai_cmn_utils_pkg.check_jai_exists, whcih was created thru bug
57 4033992.
58 ja_in_util_pkg_s.sql 115.0
59 ja_in_util_pkg_b.sql 115.0
60 ------------------------------------------------------------------------------------------ */
61 /*if pv_action = jai_constants.inserting or pv_action = jai_constants.updating then
62 ln_org_id := pr_new.org_id;
63 elsif pv_action = jai_constants.deleting then
64 ln_org_id := pr_old.org_id;
65 end if;*/
66
67 --if
68 -- jai_cmn_utils_pkg.check_jai_exists (p_calling_object => 'JA_IN_AP_APSA_BEFORE_TRG',
69 -- p_org_id => ln_org_id
70 -- )
71 -- =
72 -- FALSE
73 --then
74 /* India Localization funtionality is not required */
75 -- return;
76 -- end if;
77
78
79 /* Payment Priority Functionality */
80
81 if pv_action = jai_constants.inserting then
82
83 open c_ap_invoices_all(pr_new.invoice_id);
84 fetch c_ap_invoices_all into r_ap_invoices_all;
85 close c_ap_invoices_all;
86
87 if not (r_ap_invoices_all.invoice_type_lookup_code = 'CREDIT' and r_ap_invoices_all.source = 'INDIA TDS' ) then /*--Ramanand for bug#4388958 --'TDS') then*/
88 goto exit_from_trigger;
89 end if;
90
91 /* Control will come here only when the invoice is a credit memo to the supplier for TDS */
92
93 /* Get the payment priority */
94 open c_jai_ap_tds_thhold_trxs(pr_new.invoice_id);
95 fetch c_jai_ap_tds_thhold_trxs into ln_parent_inv_payment_priority;
96 close c_jai_ap_tds_thhold_trxs;
97
98 if ln_parent_inv_payment_priority is not null then
99 pr_new.payment_priority := ln_parent_inv_payment_priority;
100 end if;
101
102 end if; /* if pv_action = jai_constants.inserting than */
103
104 << exit_from_trigger >>
105 return;
106
107 /* Added an exception block by Ramananda for bug#4570303 */
108 EXCEPTION
109 WHEN OTHERS THEN
110 --raise_application_error(-20000, 'Error - trigger ja_in_ap_apsa_before_trg on ap_payment_schedules_all : ' || sqlerrm);
111 Pv_return_code := jai_constants.unexpected_error;
112 Pv_return_message := 'Encountered an error in JAI_AP_PSA_TRIGGER_PKG.BRIUD_T1 ' ||
113 'Error on ap_payment_schedules_all : ' || substr(sqlerrm,1,1800);
114 END BRIUD_T1 ;
115
116 END JAI_AP_PSA_TRIGGER_PKG ;