DBA Data[Home] [Help]

PACKAGE BODY: APPS.JG_ZZ_AERL_DT_PKG

Source


1 PACKAGE BODY JG_ZZ_AERL_DT_PKG AS
2 /*$Header: jgzzaerlb.pls 120.3.12010000.2 2009/04/14 08:02:55 pakumare ship $*/
3 
4   function cf_batch_name(trx_id in number, source in varchar2) return varchar2 as
5   /*  This function will fetch batch name depending upon transaction source */
6 		cursor c_get_ar_batch_name
7 		is
8 		select rab.name
9 		from   ra_batches rab
10 		      ,ra_customer_trx ract
11 		where  rab.batch_id = ract.batch_id
12 		and    ract.customer_trx_id = trx_id;
13 
14 		cursor c_get_ap_batch_name
15 		is
16 		select apb.batch_name
17 		from   ap_batches  apb
18 		      ,ap_invoices api
19 		where  apb.batch_id = api.batch_id
20 		and    api.invoice_id = trx_id;
21 
22   	cursor c_get_gl_batch_name
23   	is
24     select gjb.name
25     from   gl_je_batches gjb
26           ,gl_je_headers gljh
27     where  gjb.je_batch_id = gljh.je_batch_id
28     and    gljh.je_header_id = trx_id;
29 
30     lv_batch_name varchar2 (240);
31 
32   begin
33 
34   	if source = 'AR' then
35 			open  c_get_ar_batch_name;
36 			fetch c_get_ar_batch_name into lv_batch_name;
37 			close c_get_ar_batch_name;
38   	elsif source = 'AP' then
39   		open  c_get_ap_batch_name;
40   		fetch c_get_ap_batch_name into lv_batch_name;
41   		close c_get_ap_batch_name;
42   	elsif source = 'GL' then
43   		open  c_get_gl_batch_name;
44   		fetch c_get_gl_batch_name into lv_batch_name;
45   		close c_get_gl_batch_name;
46 		end if;
47     return (lv_batch_name);
48 
49   end cf_batch_name;
50   function get_financial_document_type(pn_trx_id in number,pn_trx_type_id in number, pv_source in varchar2 , pv_entity_code in varchar2) return varchar2 as
51   /* This function will fetch Financial Document type to solve the bug 5550600*/
52   lv_fin_doc_type varchar2(20);
53   lv_sl_trx_type ce_statement_lines.trx_type%type;
54   lv_cr_reversal_category ar_cash_receipts_all.reversal_category%type;
55   begin
56     fnd_file.put_line(fnd_file.log, '**Input Params:** ');
57     fnd_file.put_line(fnd_file.log, '1. Trx_id: '||pn_trx_id);
58     fnd_file.put_line(fnd_file.log, '2. Trx_type_id: '||pn_trx_type_id);
59     fnd_file.put_line(fnd_file.log, '3. Source: '||pv_source);
60     fnd_file.put_line(fnd_file.log, '4. Entity Code '||pv_entity_code);
61     begin
62         if pv_source = 'AP' then
63             select invoice_type_lookup_code
64                 into lv_fin_doc_type
65                     from ap_invoices_all
66                         where invoice_id = pn_trx_id;
67         elsif pv_source = 'AR' then
68             if pv_entity_code = 'RECEIPTS' then
69                 select sl.trx_type  into lv_sl_trx_type
70                     from ar_cash_receipt_history_all crh, ce_statement_reconcils_all sr,ce_statement_lines sl
71                         where crh.cash_receipt_id = pn_trx_id
72                             and	crh.cash_receipt_history_id = sr.reference_id
73                             and	sr.statement_line_id = sl.statement_line_id
74 							and	crh.org_id = sr.org_id; -- Bug 8364296
75                 select cr.reversal_category into lv_cr_reversal_category
76                     from ar_cash_receipts_all cr
77                         where cr.cash_receipt_id = pn_trx_id
78                         and   cr.type = 'MISC';
79                 if lv_sl_trx_type in ('CREDIT','MISC_CREDIT') then
80                     if lv_cr_reversal_category = 'REV' then
81                         lv_fin_doc_type := 'MISCREVR';
82                     elsif lv_cr_reversal_category is null then
83                         lv_fin_doc_type := 'MISCREC';
84                     end if;
85                 elsif lv_sl_trx_type in ('DEBIT','MISC_DEBIT') then
86                     if lv_cr_reversal_category = 'REV' then
87                         lv_fin_doc_type := 'MISCREVP';
88                     elsif lv_cr_reversal_category is null then
89                         lv_fin_doc_type := 'MISCPAY';
90                     end if;
91                 end if;
92             elsif pv_entity_code = 'TRANSACTIONS' then
93                 select type
94                     into lv_fin_doc_type
95                         from ra_cust_trx_types --Modified the query for bug 6156524 Used ra_cust_trx_types table instead of ra_cust_trx_types_all table.
96                             where cust_trx_type_id = pn_trx_type_id;
97             end if;
98         elsif pv_source = 'GL' then
99             lv_fin_doc_type := 'N/A';
100         end if;
101     exception
102       when others then
103       -- Don't Error Out (Possible excp are Too_many_rows or No_data_Found)
104       lv_fin_doc_type := null;
105 	fnd_file.put_line(fnd_file.log,'Logging the Error Message encountered: '||sqlerrm);
106     end;
107   fnd_file.put_line(fnd_file.log,'Document Type Returned: '||lv_fin_doc_type);
108   return (lv_fin_doc_type);
109   end get_financial_document_type;
110 END JG_ZZ_AERL_DT_PKG ;