DBA Data[Home] [Help]

PACKAGE BODY: APPS.APRX_WT

Source


4 /*Bug 9897890 Added the below parameters to enable fnd log */
1 PACKAGE BODY APRX_WT AS
2 /* $Header: aprxwtb.pls 120.15 2011/10/12 06:36:09 tjbhatt ship $ */
3 
5 
6   G_CURRENT_RUNTIME_LEVEL CONSTANT NUMBER       := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
7   G_LEVEL_UNEXPECTED      CONSTANT NUMBER       := FND_LOG.LEVEL_UNEXPECTED;
8   G_LEVEL_ERROR           CONSTANT NUMBER       := FND_LOG.LEVEL_ERROR;
9   G_LEVEL_EXCEPTION       CONSTANT NUMBER       := FND_LOG.LEVEL_EXCEPTION;
10   G_LEVEL_EVENT           CONSTANT NUMBER       := FND_LOG.LEVEL_EVENT;
11   G_LEVEL_PROCEDURE       CONSTANT NUMBER       := FND_LOG.LEVEL_PROCEDURE;
12   G_LEVEL_STATEMENT       CONSTANT NUMBER       := FND_LOG.LEVEL_STATEMENT;
13   G_MODULE_NAME           CONSTANT VARCHAR2(30) := 'AP.PLSQL.APRX_WT.';
14 
18   -- These include parameters which are passed in the core and all the plug-ins
15   DBG_Loc                    VARCHAR2(30) := 'GET_WITHOLDING_TAX';
16   debug_info                 VARCHAR2(20000);
17   -- Structure to hold values of parameters
19   type param_t is record (
20         p_date_from	          varchar2(20),
21         p_date_to                 varchar2(20),
22         p_supplier_from           AP_SUPPLIERS.vendor_name%TYPE,  -- Bug 10021563 varchar2(80),
23         p_supplier_to             AP_SUPPLIERS.vendor_name%TYPE,  -- Bug 10021563 varchar2(80),
24         p_supplier_type           PO_LOOKUP_CODES.lookup_code%TYPE, -- Bug 10021563 varchar2(25),
25         p_system_acct_method      varchar2(240)
26                         );
27   parm param_t;
28 
29   -- Core Report function
30 
31   PROCEDURE GET_WITHOLDING_TAX (
32         request_id      	  in  number,
33         section_name              in varchar2,
34         retcode                   out NOCOPY number,
35         errbuf                    out NOCOPY varchar2
36                       )
37   IS
38 
39   DBG_Loc                    VARCHAR2(30) := 'GET_WITHOLDING_TAX';
40   debug_info                 VARCHAR2(10000);
41 
42   BEGIN
43 
44     fa_rx_util_pkg.debug('aprx_wt.get_witholding_tax()+');
45 
46      -- Initialize request
47 
48      fa_rx_util_pkg.init_request('aprx_wt.get_witholding_tax', request_id);
49 
50      fa_rx_util_pkg.assign_report(section_name,
51                 true,
52                 'aprx_wt.before_report;',
53                 NULL,
54                 NULL,
55                 NULL);
56 
57      fa_rx_util_pkg.run_report('aprx_wt.get_witholding_tax', retcode, errbuf);
58 
59      fa_rx_util_pkg.debug('aprx_wt.get_witholding_tax()-');
60 
61   END GET_WITHOLDING_TAX;
62 
63   -- This  procedure is a plug-in for the (Tax Letter) Report
64 
65   PROCEDURE ap_wht_tax_report  (
66         p_date_from               in varchar2,
67         p_date_to                 in varchar2,
68         p_supplier_from           in varchar2,
69         p_supplier_to             in varchar2,
70         p_supplier_type           in varchar2,
71         request_id                in  number,
72         retcode                   out NOCOPY number,
73         errbuf                    out NOCOPY varchar2
74        )
75   IS
76 
77   DBG_Loc                    VARCHAR2(30) := 'ap_wht_tax_report';
78   debug_info                 VARCHAR2(10000);
79 
80   BEGIN
81      fa_rx_util_pkg.debug('aprx_wt.ap_wht_tax_report()+');
82      fa_rx_util_pkg.debug('p_date_from  '||p_date_from);
83      fa_rx_util_pkg.debug('canonical date from   '||to_char(fnd_date.canonical_to_date(p_date_from)));
84      fa_rx_util_pkg.init_request('aprx_wt.ap_wht_tax_report', request_id);
85       debug_info := 'aprx_wt.ap_wht_tax_report()+';
86 	  IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) THEN
87 	       FND_LOG.STRING(G_LEVEL_STATEMENT,G_MODULE_NAME||DBG_Loc,debug_info);
88 	  END IF;
89       debug_info := 'p_date_from  '||p_date_from;
90 	  IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) THEN
91 	       FND_LOG.STRING(G_LEVEL_STATEMENT,G_MODULE_NAME||DBG_Loc,debug_info);
92 	  END IF;
93       debug_info := 'canonical date from   '||to_char(fnd_date.canonical_to_date(p_date_from));
94 	  IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) THEN
95 	       FND_LOG.STRING(G_LEVEL_STATEMENT,G_MODULE_NAME||DBG_Loc,debug_info);
96 	  END IF;
97 
98 
99       -- Store the paremters in a variable which can be accesed globally accross all procedures
100       parm.p_date_from               := p_date_from;
101       parm.p_date_to                 := p_date_to;
102       parm.p_supplier_from           := p_supplier_from;
103       parm.p_supplier_to             := p_supplier_to;
104       parm.p_supplier_type           := p_supplier_type;
105 
106       -- Call the core report.This executes the core report and the SELECT statement of the core
107       -- is built.Now the plug-in has to add only what is specific to it.
108       -- No data is inserted into the interface table.
109 
110       aprx_wt.get_witholding_tax (
111         request_id,
112         'get_witholding_tax',
113         retcode,
114         errbuf);
115 
116       -- Continue with the execution of the plug-in
117       fa_rx_util_pkg.assign_report('get_witholding_tax',
118                  true,
119                 'aprx_wt.awt_before_report;',
120                 'aprx_wt.awt_bind(:CURSOR_SELECT);',
121                 NULL, null);
122 
123       fa_rx_util_pkg.run_report('aprx_wt.ap_wht_tax_report', retcode, errbuf);
124 
125       fa_rx_util_pkg.debug('aprx_wt.ap_wht_tax_report()-');
126 
127     END ap_wht_tax_report;
128 
129 /*=======================================================================================================
130 
131                                                     CORE REPORT
132 
133 ========================================================================================================*/
134 
135 
136   -- This is the before report trigger for the main Report. The code which is written in the " BEFORE
137   -- REPORT " triggers has been incorporated over here. The code is the common code accross all the
138   -- reports.
139 
140   PROCEDURE before_report
141   IS
142 
143   DBG_Loc                    VARCHAR2(30) := 'before_report';
144   debug_info                 VARCHAR2(10000);
145 
146   BEGIN
147      fa_rx_util_pkg.debug('aprx_wt.before_report()+');
148 
152 
149 /*Bug 9897890 Commented the below code*/
150 /*
151 	fa_rx_util_pkg.debug('GL_SET_OF_BKS_ID');
153 	--
154   	-- Get Profile GL_SET_OF_BKS_ID
155   	--
156 
157     fa_rx_util_pkg.debug('GL_GET_PROFILE_BKS_ID');
158    	fnd_profile.get(
159           		name => 'GL_SET_OF_BKS_ID',
160           		val => var.books_id);
161 
162 	--
163   	-- Get CHART_OF_ACCOUNTS_ID
164   	--
165    	fa_rx_util_pkg.debug('GL_GET_CHART_OF_ACCOUNTS_ID');
166 
167 	select	CURRENCY_CODE,NAME
168    	into 	var.functional_currency_code
169 	,	var.organization_name
170    	from 	GL_SETS_OF_BOOKS
171    	where 	SET_OF_BOOKS_ID = var.books_id;
172 */
173 
174 
175 
176 --  Bug 1759331
177 
178 
179 /*    		SELECT name
180     		INTO var.organization_name
181     		FROM hr_organization_units
182     		WHERE organization_id = FND_PROFILE.GET('ORG_ID');
183 
184     		SELECT currency_code
185     		INTO var.functional_currency_code
186     		FROM gl_sets_of_books
187     		WHERE set_of_books_id = FND_PROFILE.GET('GL_SET_OF_BKS_ID');
188 
189 
190 
191 -- Bug 9897890 Commented the below code
192 
193      -- Get Company Information and store in placeholder variables
194      BEGIN
195        SELECT hrl.address_line_1,
196               hrl.address_line_2,
197 	      hrl.address_line_3,
198               hrl.town_or_city,
199 	      hrl.country,
200               hrl.postal_code,
201               hrl.region_1,
202               hrl.region_2
203         INTO var.Address_line1,
204 	     var.address_line2,
205 	     var.address_line3,
206              var.city,
207              var.country,
208              var.zip,
209              var.province,
210              var.state
211         FROM hr_locations hrl
212         WHERE hrl.location_id = JG_ZZ_COMPANY_INFO.get_location_id;
213 
214 
215       EXCEPTION
216         WHEN NO_DATA_FOUND THEN
217           RAISE_APPLICATION_ERROR(-20010,sqlerrm);
218       END;
219 */
220 
221        --Assign SELECT list
222        -- the Select statement is build over here
223 
224        -- fa_rx_util_pkg.assign_column(#, select, insert, place, type, len);
225 
226        -->>SELECT_START<<--
227 
228        fa_rx_util_pkg.assign_column('1', 'pv1.vendor_name', 'tax_authority','aprx_wt.var.tax_authority','VARCHAR2', 240);
229 
230        fa_rx_util_pkg.assign_column('2', 'pv2.vendor_type_lookup_code', 'supplier_type','aprx_wt.var.supplier_type','VARCHAR2',30); -- Bug 10021563
231 
232        fa_rx_util_pkg.assign_column('3',  'pv2.vendor_name',  'supplier_name', 'aprx_wt.var.supplier_name','VARCHAR2',240);
233 
234        fa_rx_util_pkg.assign_column('4', 'pv2.num_1099', 'taxpayer_id','aprx_wt.var.taxpayer_id','VARCHAR2',30);
235 
236        fa_rx_util_pkg.assign_column('5',  'pv2.segment1',  'supplier_number', 'aprx_wt.var.supplier_number','VARCHAR2',30);
237 
238        fa_rx_util_pkg.assign_column('6',  'pvs.vendor_site_code',  'supplier_site_code', 'aprx_wt.var.supplier_site_code','VARCHAR2',15);
239 
240        fa_rx_util_pkg.assign_column('7',  'pvs.vat_registration_num',  'vat_registration_number', 'aprx_wt.var.vat_registration_number','VARCHAR2',20);
241 
242 
243        fa_rx_util_pkg.assign_column('8',  'pvs.address_line1',  'supplier_address_line1', 'aprx_wt.var.supplier_address_line1','VARCHAR2',240);
244 
245        fa_rx_util_pkg.assign_column('9',  'pvs.address_line2',  'supplier_address_line2', 'aprx_wt.var.supplier_address_line2','VARCHAR2',240);
246 
247        fa_rx_util_pkg.assign_column('10',  'pvs.address_line3',  'supplier_address_line3', 'aprx_wt.var.supplier_address_line3','VARCHAR2',240);
248 
249        fa_rx_util_pkg.assign_column('11',  'pvs.city',  'supplier_city', 'aprx_wt.var.supplier_city','VARCHAR2',25);
250 
251        fa_rx_util_pkg.assign_column('12',  'pvs.state',  'supplier_state', 'aprx_wt.var.supplier_state','VARCHAR2',150);
252 
253        fa_rx_util_pkg.assign_column('13',  'pvs.zip',  'supplier_zip', 'aprx_wt.var.supplier_zip','VARCHAR2',20);
254 
255        fa_rx_util_pkg.assign_column('14',  'pvs.province',  'supplier_province', 'aprx_wt.var.supplier_province','VARCHAR2',150);
256 
257        fa_rx_util_pkg.assign_column('15',  'pvs.country',  'supplier_country', 'aprx_wt.var.supplier_country','VARCHAR2',25);
258 
259        fa_rx_util_pkg.assign_column('16',  'ai.invoice_num',  'invoice_num', 'aprx_wt.var.invoice_num','VARCHAR2',50);
260 
261        fa_rx_util_pkg.assign_column('17',  'ai.invoice_amount',  'invoice_amount', 'aprx_wt.var.invoice_amount','NUMBER');
262 
263        fa_rx_util_pkg.assign_column('18',  'ai.invoice_currency_code',  'invoice_currency_code', 'aprx_wt.var.invoice_currency_code','VARCHAR2',15);
264 
265        fa_rx_util_pkg.assign_column('19',  'ai.invoice_date',  'invoice_date', 'aprx_wt.var.invoice_date','DATE');
266 
267        fa_rx_util_pkg.assign_column('20',  'atr.tax_name',  'awt_code', 'aprx_wt.var.awt_code','VARCHAR2',15);
268 
269        fa_rx_util_pkg.assign_column('21',  'atr.tax_rate',  'awt_rate', 'aprx_wt.var.awt_rate','NUMBER');
270 
271        fa_rx_util_pkg.assign_column('22',  'nvl(aid.amount*(-1),0)',  'awt_amount', 'aprx_wt.var.awt_amount','NUMBER');
272 
273        fa_rx_util_pkg.assign_column('23',  'nvl(aid.base_amount*(-1),aid.amount*(-1))',  'awt_base_amount', 'aprx_wt.var.awt_base_amount','NUMBER');
274 
275        fa_rx_util_pkg.assign_column('24',  'atg.name',  'awt_group_name', 'aprx_wt.var.awt_group_name','VARCHAR2',25);
276 
277        fa_rx_util_pkg.assign_column('25',  'aid.accounting_date',  'awt_gl_date', 'aprx_wt.var.awt_gl_date','DATE');
278 
279 -- bug 8258934
280 /* bug 10080788 Modified the below code to consider all different cases to derive proper awt_gross_amount.
281 Refer to bug for more details */
282 
283 --       fa_rx_util_pkg.assign_column('26',  'aid.awt_gross_amount',  'awt_gross_amount',  'aprx_wt.var.awt_gross_amount','NUMBER');
284  /*   fa_rx_util_pkg.assign_column('26',  'DECODE(aid.reversal_flag,''Y'',aid.awt_gross_amount,nvl(DECODE(atc.awt_rate_type,''R'',aid.awt_gross_amount, '||
285 	                               'DECODE((ROW_NUMBER() OVER (PARTITION BY  aid.invoice_id, aid.awt_origin_group_id, aid.awt_related_id '||
286 								   'ORDER BY aid.awt_group_id, aid.invoice_line_number, aid.distribution_line_number)), 1, aid1.amount , 0))'||
287 								   ',aid.awt_gross_amount))',  'awt_gross_amount', 'aprx_wt.var.awt_gross_amount','NUMBER');
288 
289        Bug 10220008 Commented the above code and replaced it with the following code */
290 
291        fa_rx_util_pkg.assign_column('26',  'DECODE(aid.reversal_flag,''Y'',nvl(aid.awt_gross_amount,0),nvl(DECODE(atc.awt_rate_type,'||
292                                            '''R'',DECODE((ROW_NUMBER() OVER (PARTITION BY  aid.invoice_id,  aid.awt_origin_group_id, '||
293 					   'aid.awt_tax_rate_id ORDER BY nvl(aid.awt_group_id,aid.pay_awt_group_id), aid.invoice_line_number'||
294 					   ', aid.distribution_line_number)), 1, aid.awt_gross_amount , 0),'||
295 					   'DECODE((ROW_NUMBER() OVER (PARTITION BY  aid.invoice_id,  aid.awt_origin_group_id '||
296 					   'ORDER BY nvl(aid.awt_group_id,aid.pay_awt_group_id), aid.invoice_line_number, aid.distribution_line_number))'||
297 					   ', 1, aid.awt_gross_amount , 0)),aid.awt_gross_amount))',  'awt_gross_amount', 'aprx_wt.var.awt_gross_amount','NUMBER');
298 
302 
299 /*Bug 9897890 Modified the below calls and added values like hrl.address_line_1,hrl.address_line_2*/
300 
301        fa_rx_util_pkg.assign_column('27', 'hrl.address_line_1', 'address_line1','aprx_wt.var.address_line1', 'VARCHAR2',240);  --bug9897890
303        fa_rx_util_pkg.assign_column('28', 'hrl.address_line_2', 'address_line2','aprx_wt.var.address_line2', 'VARCHAR2',240);  --bug9897890
304 
305        fa_rx_util_pkg.assign_column('29', 'hrl.address_line_3', 'address_line3','aprx_wt.var.address_line3', 'VARCHAR2',240);  --bug9897890
306 
307        fa_rx_util_pkg.assign_column('30', 'hrl.town_or_city', 'city','aprx_wt.var.city', 'VARCHAR2',30);  --bug9897890
308 
309        fa_rx_util_pkg.assign_column('31', 'hrl.postal_code', 'zip','aprx_wt.var.zip', 'VARCHAR2',30);  --bug9897890
310 
311        fa_rx_util_pkg.assign_column('32', 'hrl.country', 'country','aprx_wt.var.country', 'VARCHAR2',60);  --bug9897890
312 
313        fa_rx_util_pkg.assign_column('33', 'hou.name', 'organization_name','aprx_wt.var.organization_name', 'VARCHAR2',240);    --bug7621919
314 
315        fa_rx_util_pkg.assign_column('34', 'gld.currency_code', 'functional_currency_code','aprx_wt.var.functional_currency_code', 'VARCHAR2',15);  --bug9897890
316 
317        fa_rx_util_pkg.assign_column('35', 'hrl.region_1', 'province','aprx_wt.var.province', 'VARCHAR2',150);
318 
319        fa_rx_util_pkg.assign_column('36', 'hrl.region_2', 'state','aprx_wt.var.state', 'VARCHAR2',150);
320 
321        -->>SELECT_END<<--
322 
323 
324        --
325        -- Assign From Clause
326        --
327 /*Bug 9897890 Added the tables hr_locations, gl_ledgers to the from clause
328 Bug 10080788 Added a self join to table ap_invoice_distributions_all */
329 
330        fa_rx_util_pkg.From_Clause :=
331        	'po_vendors pv2,
332          po_vendors pv1,
333          po_vendor_sites pvs ,
334          ap_invoices ai,
335          ap_invoice_distributions aid,
336          ap_tax_codes atc,
337          ap_awt_groups atg,
338          ap_awt_tax_rates atr,
339 	 hr_organization_units hou,
340 	     hr_locations hrl,
341 		 gl_ledgers gld';   --bug7621919  bug 9897890
342 
343 
344        -- Assign Where Clause
345 
346        -- Bug 2825570. Add filter on invoice_date between start and end dates.
347 
348 /*Bug 9897890 Added joins with tables hr_locations, gl_ledgers to the where clause
349 Bug 10080788 Added a self join to table ap_invoice_distributions_all */
350 
351 --begin bug12694504, changed the fa_rx_util_pkg.where_clase
352 /*
353        fa_rx_util_pkg.Where_Clause :=   'pv2.vendor_id = ai.vendor_id and
354 		  			 pvs.vendor_site_id = ai.vendor_site_id and
355       					 atg.group_id(+)  = aid.awt_origin_group_id and
356       					 ai.invoice_id = aid.invoice_id and
357       					 aid.withholding_tax_code_id  = atc.tax_id and
358                          aid.awt_tax_rate_id = atr.tax_rate_id and
359 					 atc.name = atr.tax_name and
360                                          aid.line_type_lookup_code=''AWT'' and
361                                          ai.invoice_date between NVL(atr.start_date , ai.invoice_date) and NVL(atr.end_date , ai.invoice_date) and
362 					 atc.awt_vendor_id = pv1.vendor_id and
363 					 hou.organization_id = aid.org_id and
364 					ai.set_of_books_id = gld.ledger_id and
365 					hrl.location_id = hou.location_id';    --bug7621919  bug9897890  bug10090309
366 */
367        fa_rx_util_pkg.Where_Clause :=   'pv2.vendor_id = ai.vendor_id and
368 		  			 pvs.vendor_site_id = ai.vendor_site_id and
369       					 atg.group_id(+)  = aid.awt_origin_group_id and
370       					 ai.invoice_id = aid.invoice_id and
371       					 aid.withholding_tax_code_id  = atc.tax_id(+) and
372                          aid.awt_tax_rate_id = atr.tax_rate_id(+) and
373                                          aid.line_type_lookup_code=''AWT'' and
374                                          ai.invoice_date between NVL(atr.start_date , ai.invoice_date) and NVL(atr.end_date , ai.invoice_date) and
375 					 atc.awt_vendor_id = pv1.vendor_id(+) and
376 					 hou.organization_id = aid.org_id and
377 					ai.set_of_books_id = gld.ledger_id and
378 					hrl.location_id = hou.location_id';    --bug7621919  bug9897890  bug10090309
379 --end bug12694504
380 
381         fa_rx_util_pkg.debug('aprx_wt.before_report()-');
382 
383       END BEFORE_REPORT;
384 
385 /*   Bug7376771 -- Modified the tax_code_id to withholding_tax_code_id as in R12
386      withholding functionality is seperated */
387       -- The after fetch trigger fires after the Select statement has executed
388 /*
389       PROCEDURE after_fetch IS
390       BEGIN
391 
392       END;
393 */
394 
395 /*=============================================================================================
396 
397                                                     END OF CORE REPORT
398 
399 ===============================================================================================*/
400 
401 
402 /*===============================================================================================
403 
404                                             AP Witholding Tax Letter Report(Plug-In)
405 
406 ================================================================================================*/
407 
408 
409       -- This is the before report trigger for the Plug-In. The code which is specific to the AP Witholding Tax report and Letter is written here.
410 
411       PROCEDURE awt_before_report IS
412 
413 /*Bug 9897890 Modified the below cursor to refer to SLA_LEDGER_CASH_BASIS_FLAG as accounting_method_option
417                  UPPER(secondary_accounting_method)
414 is no more used in R12*/
415 	  CURSOR c_methods IS
416           SELECT UPPER(gld.SLA_LEDGER_CASH_BASIS_FLAG),
418           FROM   ap_system_parameters asp,
419 		         gl_ledgers gld
420 		  WHERE asp.set_of_books_id = gld.ledger_id;
421 
422         first_acct_method  gl_ledgers.SLA_LEDGER_CASH_BASIS_FLAG%TYPE;
423         second_acct_method ap_system_parameters.secondary_accounting_method%TYPE;
424 
425       BEGIN
426         OPEN  c_methods;
427         FETCH c_methods INTO first_acct_method, second_acct_method;
428         CLOSE c_methods;
429         IF (
430           (first_acct_method = 'N')  --bug9897890
431           and
432           (
433             (second_acct_method = 'ACCRUAL')
434             or
435             (second_acct_method = 'NONE')
436           or
437           (second_acct_method is null)
438           )
439          ) THEN
440         parm.P_System_Acct_Method := 'ACCRUAL';
441         ELSIF (
442           (first_acct_method = 'Y')  --bug9897890
443           and
444           (
445             (second_acct_method = 'CASH')
446           or
447             (second_acct_method = 'NONE')
448           or
449             (second_acct_method is null)
450             )
451            ) THEN
452         parm.P_System_Acct_Method := 'CASH';
453       ELSE
454         parm.P_System_Acct_Method := 'BOTH';
455       END IF;
456 
457 	fa_rx_util_pkg.debug('system_acct_method'||parm.P_System_Acct_Method);
458 
459           -- Add the WHERE clause which is specific to the AP Witholding Report
460 
461         IF parm.p_date_from IS NOT NULL THEN
462           fa_rx_util_pkg.Where_clause := fa_rx_util_pkg.Where_clause || ' and aid.accounting_date >=  fnd_date.canonical_to_date(:b_date_from)' ;
463         END IF;
464 
465        IF parm.p_date_to IS NOT NULL THEN
466          fa_rx_util_pkg.Where_clause := fa_rx_util_pkg.Where_clause || ' and aid.accounting_date <= fnd_date.canonical_to_date(:b_date_to) ';
467        END IF;
468 
469        IF parm.p_supplier_from IS NOT NULL THEN
470          fa_rx_util_pkg.Where_clause := fa_rx_util_pkg.Where_clause || ' and UPPER(pv2.vendor_name) >= UPPER(:b_supplier_from)';
471        END IF;
472 
473        IF parm.p_supplier_to IS NOT NULL THEN
474          fa_rx_util_pkg.Where_clause := fa_rx_util_pkg.Where_clause || ' and UPPER(pv2.vendor_name) <= UPPER(:b_supplier_to)' ;
475        END IF;
476 
477        IF parm.p_supplier_type IS NOT NULL THEN
478          fa_rx_util_pkg.Where_clause := fa_rx_util_pkg.Where_clause || ' and pv2.vendor_type_lookup_code  = :b_supplier_type';
479        END IF;
480 
481       IF parm.p_system_acct_method IS NOT NULL THEN
482         fa_rx_util_pkg.Where_clause := fa_rx_util_pkg.Where_clause ||' and aid.accrual_posted_flag = decode(:b_system_acct_method,''ACCRUAL'',''Y'',''BOTH'',''Y'',aid.accrual_posted_flag)';
483         fa_rx_util_pkg.Where_clause := fa_rx_util_pkg.Where_clause ||' and aid.cash_posted_flag = decode(:b_system_acct_method,''CASH'',''Y'',''BOTH'',''Y'',aid.cash_posted_flag)';
484       END IF;
485 
486         fa_rx_util_pkg.debug('aprx_wt.awt_before_report()-');
487 
488       END awt_before_report;
489 
490       -- This is the bind trigger for the
491       PROCEDURE awt_bind(c in integer)
492       IS
493         b_date_from           varchar2(20);
494         b_date_to             varchar2(20);
495         b_supplier_from       AP_SUPPLIERS.vendor_name%TYPE;  -- Bug 10021563 varchar2(80);
496         b_supplier_to         AP_SUPPLIERS.vendor_name%TYPE;  -- Bug 10021563 varchar2(80);
500         fa_rx_util_pkg.debug('aprx_wt.awt_bind()+');
497         b_supplier_type       PO_LOOKUP_CODES.lookup_code%TYPE; -- Bug 10021563 varchar2(25);
498         b_system_acct_method  varchar2(240);
499       BEGIN
501 
502         IF parm.p_date_from is not null then
503           fa_rx_util_pkg.debug('Binding b_date_from');
504           dbms_sql.bind_variable(c, 'b_date_from', parm.p_date_from);
505         END IF;
506 
507         IF parm.p_date_to is not null then
508           fa_rx_util_pkg.debug('Binding b_date_to');
509           dbms_sql.bind_variable(c, 'b_date_to', parm.p_date_to);
510         END IF;
511 
512         IF parm.p_supplier_from is not null then
513           fa_rx_util_pkg.debug('Binding b_supplier_from');
514           dbms_sql.bind_variable(c, 'b_supplier_from', parm.p_supplier_from);
515         END IF;
516 
517         IF parm.p_supplier_to is not null then
518           fa_rx_util_pkg.debug('Binding b_supplier_to');
519           dbms_sql.bind_variable(c, 'b_supplier_to', parm.p_supplier_to);
520         END IF;
521 
522         IF parm.p_supplier_type is not null then
523           fa_rx_util_pkg.debug('Binding b_supplier_type_from');
524           dbms_sql.bind_variable(c, 'b_supplier_type', parm.p_supplier_type);
525         END IF;
526 
527         IF parm.p_system_acct_method is not null then
528           fa_rx_util_pkg.debug('Binding b_system_acct_method');
529           dbms_sql.bind_variable(c, 'b_system_acct_method', parm.p_system_acct_method);
530         END IF;
531 
532         fa_rx_util_pkg.debug('aprx_wt.awt_bind()-');
533 
534      END awt_bind;
535 
536 
537 /*=============================================================================================
538 
539                                                     END OF AP WITHHOLDING TAX REPORT
540 
541 ===============================================================================================*/
542 
543   END APRX_WT;