1 PACKAGE BODY JL_ZZ_AP_AWT_DEFAULT_PKG AS
2 /* $Header: jlzzpwdb.pls 120.36.12020000.3 2012/12/21 21:03:29 abuissa ship $ */
3 /*
4
5 Copyright (c) 1995 by Oracle Corporation
6
7 NAME
8 JL_ZZ_AP_AWT_DEFAULT_PKG - PL/SQL Package Body Validate the Global Attributes
9 for Import Process.
10 DESCRIPTION
11 This package validate the Global Attributes in the import process.
12 NOTES
13 This package body must be created under Global Applications Development.
14 HISTORY (DD/MM/YY)
15 dbetanco 09/11/98 Creation
16 dbetanco 11/12/98 Update
17 dbetanco 19/01/98 Update Include the Del_Wh_Def Proc.
18
19 */
20
21 -- =====================================================================
22 -- P R I V A T E O B J E C T S
23 -- =====================================================================
24 --
25 -- Insert_AWT_Default insert in jl_zz_ap_inv_dis_wh_all the withholdings after the validation.
26 --
27 -- Define Package Level Debug Variable and Assign the Profile
28 DEBUG_Var varchar2(1) := NVL(FND_PROFILE.value('AFLOG_ENABLED'), 'N');
29 G_CURRENT_RUNTIME_LEVEL NUMBER := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
30 G_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
31 G_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
32 G_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
33 G_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
34 G_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
35 G_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
36 --
37 -- R12 KI
38 --
39
40 PROCEDURE Insert_AWT_Default(
41 P_Invoice_Id IN ap_invoices_all.invoice_id%TYPE,
42 P_Inv_Dist_Id IN ap_invoice_distributions_all.invoice_distribution_id%TYPE,
43 P_Supp_Awt_Code_Id IN jl_zz_ap_sup_awt_cd.supp_awt_code_id%TYPE,
44 p_calling_sequence IN VARCHAR2,
45 P_Org_Id IN jl_zz_ap_sup_awt_cd.org_id%TYPE) IS
46
47 Seq_Inv_Dis_Awt_Id NUMBER;
48 l_debug_loc VARCHAR2(30) := ' Insert_AWT_Default ';
49 l_curr_calling_sequence VARCHAR2(2000);
50 l_debug_info VARCHAR2(100);
51 -- WHO Columns
52 v_last_update_by NUMBER;
53 v_last_update_login NUMBER;
54
55 BEGIN
56 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
57 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default','Start PROCEDURE Insert_AWT_Default');
58 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default','Parameters are :');
59 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' P_Invoice_Id='||P_Invoice_Id);
60 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' P_Inv_Dist_Id='||P_Inv_Dist_Id);
61 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' P_Supp_Awt_Code_Id='||P_Supp_Awt_Code_Id);
62 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' p_calling_sequence='||p_calling_sequence);
63 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' P_Org_Id='||P_Org_Id);
64 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' P_Invoice_Id='||P_Invoice_Id);
65 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' Seq_Inv_Dis_Awt_Id='||Seq_Inv_Dis_Awt_Id);
66 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' l_debug_loc='||l_debug_loc);
67 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' l_curr_calling_sequence='||l_curr_calling_sequence);
68 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' l_debug_info='||l_debug_info);
69 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' v_last_update_by='||v_last_update_by);
70 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default',' v_last_update_login='||v_last_update_login);
71 END IF;
72 -------------------------- DEBUG INFORMATION ------------------------------
73 l_curr_calling_sequence := 'jg_globe_flex_val.'||l_debug_loc||'<-'||p_calling_sequence;
74
75 l_debug_info := 'Insert rejection information to ap_interface_rejections';
76 ---------------------------------------------------------------------------
77
78 -- Get the information of WHO Columns from FND_GLOBAL
79 v_last_update_by := FND_GLOBAL.User_ID;
80 v_last_update_login := FND_GLOBAL.Login_Id;
81
82 -- Select next value from the sequence.
83 SELECT jl_zz_ap_inv_dis_wh_s.nextval
84 INTO Seq_Inv_Dis_Awt_Id
85 FROM dual;
86
87 --
88 -- Insert into JL_ZZ_AP_INV_DIS_WH_ALL
89 --
90 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
91 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default','Inserting this record to JL_ZZ_AP_INV_DIS_WH_ALL with inv_distrib_awt_id='||Seq_Inv_Dis_Awt_Id);
92 END IF;
93
94 INSERT INTO jl_zz_ap_inv_dis_wh (
95 inv_distrib_awt_id
96 ,invoice_id
97 -- Bug 4559472
98 ,distribution_line_number
99 ,invoice_distribution_id
100 ,supp_awt_code_id
101 ,created_by
102 ,creation_date
103 ,last_updated_by
104 ,last_update_date
105 ,last_update_login
106 ,org_id -- Add org_id for MOAC
107 )
108 VALUES (
109 Seq_Inv_Dis_Awt_Id
110 ,P_Invoice_Id
111 -- Bug 4559472
112 --,P_Dis_Line_Number
113 -- Populate distribution_line_number with -99 for R12 records
114 -- as it is NOT NULL column in jl_zz_ap_inv_dis_wh_all
115 ,-99
116 , P_Inv_Dist_Id
117 ,P_Supp_Awt_Code_Id
118 ,v_last_update_by
119 ,sysdate
120 ,v_last_update_by
121 ,sysdate
122 ,v_last_update_login
123 ,P_Org_Id -- Add org_id for MOAC
124 );
125 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
126 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default','End PROCEDURE Insert_AWT_Default');
127 END IF;
128
129 EXCEPTION
130 WHEN OTHERS then
131 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
132 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Insert_AWT_Default','Exception Occured in PROCEDURE Insert_AWT_Default');
133 END IF;
134 IF (SQLCODE <> -20001) THEN
135 FND_MESSAGE.SET_NAME('SQLAP', 'AP_DEBUG');
136 FND_MESSAGE.SET_TOKEN('ERROR', 'SQLERRM');
137 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', l_curr_calling_sequence);
138 FND_MESSAGE.SET_TOKEN('PARAMETERS',
139 ' P_Invoice_ID = '||to_char(P_Invoice_ID)
140 -- Bug 4559472 ||', P_Dis_Line_Number = '||to_char(P_Dis_Line_Number )
141 ||', P_Inv_Dist_Id = '||to_char(P_Inv_Dist_Id)
142 ||', P_Supp_Awt_Code_Id = '||to_char(P_Supp_Awt_Code_Id)
143 ||', Last Updated By = '||to_char(v_last_update_by)
144 ||', Last Update Date = '||to_char(v_last_update_login));
145
146 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
147 END IF;
148 APP_EXCEPTION.RAISE_EXCEPTION;
149 END;
150
151
152
153 /*-------------------------------------------------------------------------
154 Ver_Territorial_Flag return true if the province is territorial.
155 ---------------------------------------------------------------------------*/
156
157 FUNCTION Ver_Territorial_Flag
158 (P_Province_Code jl_ar_ap_provinces.province_code%TYPE
159 ) return boolean is
160 -------------------------------------------------------------------------
161 -- Select the flag for province Territory
162 -------------------------------------------------------------------------
163 CURSOR Province_Territory IS
164 SELECT territorial_flag
165 FROM jl_ar_ap_provinces
166 WHERE province_code = P_Province_Code;
167
168 v_territory boolean;
169 v_province_terr jl_ar_ap_provinces.territorial_flag%TYPE;
170
171 BEGIN
172 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
173 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Ver_Territorial_Flag','Start FUNCTION Ver_Territorial_Flag');
174 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Ver_Territorial_Flag','Parameters are :');
175 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Ver_Territorial_Flag',' P_Province_Code='||P_Province_Code);
176 END IF;
177 v_territory := FALSE;
178 OPEN Province_Territory;
179 LOOP
180 FETCH Province_Territory
181 INTO v_province_terr;
182 EXIT when Province_Territory%NOTFOUND;
183 IF v_province_terr = 'Y' THEN
184 v_territory := TRUE;
185 END IF;
186 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
187 IF v_territory THEN
188 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Ver_Territorial_Flag','FUNCTION Ver_Territorial_Flag returns TRUE');
189 ELSE
190 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Ver_Territorial_Flag','FUNCTION Ver_Territorial_Flag returns FALSE');
191 END IF;
192 END IF;
193 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
194 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Ver_Territorial_Flag','End FUNCTION Ver_Territorial_Flag');
195 END IF;
196 return (v_territory);
197 END LOOP;
198 CLOSE Province_Territory;
199 EXCEPTION
200 WHEN OTHERS THEN
201 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
202 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Ver_Territorial_Flag','Exception in FUNCTION Ver_Territorial_Flag');
203 NULL;
204 END IF;
205 END Ver_Territorial_Flag;
206
207 /*----------------------------------------------------------------------------------------------
208 The Following function return the vendor_id for the Distribution Line.
209 If tax_payerid is not null find the vendor_id for this tax_payerid Else
210 return the vendor id from the invoice.
211 ------------------------------------------------------------------------------------------------*/
212 FUNCTION Get_Vendor_Id ( P_Tax_Payer_Id ap_invoice_distributions_all.global_attribute2%TYPE
213 , P_Invoice_Id ap_invoices_all.invoice_id%TYPE
214 )
215 return number is
216 --------------------------------------------------------------------
217 -- Get the information from po_vendors when tax_payerid is not null
218 --------------------------------------------------------------------
219 CURSOR TaxPayerID_Po_Ven IS
220 SELECT Vendor_Id
221 FROM po_vendors
222 WHERE segment1 = P_Tax_Payer_Id; -- R12 KI : Need to uptake PTP?
223
224 --------------------------------------------------------------------
225 -- Get the information from ap_invoices_all when tax_payerid is null.
226 --------------------------------------------------------------------
227 CURSOR Invoice_Vendor IS
228 SELECT Vendor_Id
229 FROM ap_invoices
230 WHERE invoice_id = P_Invoice_Id;
231
232 v_vendor_id po_vendors.vendor_id%TYPE;
233
234 BEGIN
235 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
236 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id','Start FUNCTION Get_Vendor_Id');
237 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id','Parameters are :');
238 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id',' P_Tax_Payer_Id='||P_Tax_Payer_Id);
239 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id',' P_Invoice_Id='||P_Invoice_Id);
240 END IF;
241 IF P_Tax_Payer_Id IS NOT NULL THEN
242 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
243 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id','Inside IF P_Tax_Payer_Id IS NOT NULL THEN');
244 END IF;
245 OPEN TaxPayerID_Po_Ven;
246 LOOP
247 FETCH TaxPayerID_Po_Ven
248 INTO v_vendor_id;
249 EXIT when TaxPayerID_Po_Ven%NOTFOUND;
250 END LOOP;
251 CLOSE TaxPayerID_Po_Ven;
252 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
253 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id','FUNCTION Get_Vendor_Id returns v_vendor_id='||v_vendor_id);
254 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id','End FUNCTION Get_Vendor_Id');
255 END IF;
256 return (v_vendor_id);
257 ELSE
258 OPEN Invoice_Vendor;
259 LOOP
260 FETCH Invoice_Vendor
261 INTO v_vendor_id;
262 EXIT when Invoice_Vendor%NOTFOUND;
263 END LOOP;
264 CLOSE Invoice_Vendor;
265 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
266 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id','FUNCTION Get_Vendor_Id returns v_vendor_id='||v_vendor_id);
267 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id','End FUNCTION Get_Vendor_Id');
268 END IF;
269 return (v_vendor_id);
270 END IF;
271 EXCEPTION
272 WHEN OTHERS THEN
273 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
274 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Get_Vendor_Id','Exception in FUNCTION Get_Vendor_Id');
275 END IF;
276 END;
277
278 /*----------------------------------------------------------------------------------------------
279 The Following function verify if the company is agent for a withholding type.
280 The function receive the Supplier Withholding Type as parameter.
281 ------------------------------------------------------------------------------------------------*/
282
283 FUNCTION Company_Agent (P_Awt_Type_Code jl_zz_ap_awt_types.awt_type_code%TYPE,
284 P_Invoice_Id ap_invoices_all.invoice_id%TYPE)
285 return boolean is
286 /* bug 16010780
287 Cursor Company_Awt_Types (PC_Legal_Entity_ID xle_entity_profiles.legal_entity_id%TYPE)
288 IS
289 SELECT awt_type_code
290 FROM jl_zz_ap_comp_awt_types
291 WHERE legal_entity_id = PC_Legal_Entity_ID
292 --location_id = PC_Location_ID
293 AND wh_agent_flag = 'Y';
294
295 Cursor legal_entity IS
296 SELECT legal_entity_id
297 FROM ap_invoices
298 WHERE invoice_id = P_Invoice_ID;
299
300 l_legal_entity_id xle_entity_profiles.legal_entity_id%TYPE;
301 */
302
303 find_type boolean;
304 -- v_location hr_locations_all.location_id%TYPE;
305 V_FND_TYPE VARCHAR2(10); --bug 16010780
306
307 BEGIN
308 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
309 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent','Start FUNCTION Company_Agent');
310 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent','Parameters are :');
311 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent',' P_Awt_Type_Code='||P_Awt_Type_Code);
312 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent',' P_Invoice_Id='||P_Invoice_Id);
313 END IF;
314
315 find_type := FALSE;
316
317 /* bug 16010780
318 -----------------------------------------------------------
319 -- Get the Company information from the Legal Entity
320 ----------------------------------------------------------
321 -- v_location := jg_zz_company_info.get_location_id; -- LE
322 SELECT legal_entity_id
323 INTO l_legal_entity_id
324 FROM ap_invoices
325 WHERE invoice_id = P_Invoice_ID;
326 ----------------------------------------------------------
327 -- Loop verify the withholding type.
328 ----------------------------------------------------------
329 FOR db_reg IN Company_Awt_Types (l_legal_entity_id) LOOP
330 IF db_reg.awt_type_code = P_Awt_Type_Code THEN
331 find_type := TRUE;
332 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
333 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent','FUNCTION Company_Agent returns TRUE');
334 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent','End FUNCTION Company_Agent');
335 END IF;
336 return(find_type);
337 END IF;
338 END LOOP;
339 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
340 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent','FUNCTION Company_Agent returns FALSE');
341 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent','End FUNCTION Company_Agent');
342 END IF;
343 */
344 --New code due to performance issues: bug 16010780
345
346 select decode((select 'TRUE'
347 from ap_invoices AP
348 where AP.invoice_id = P_Invoice_ID
349 and EXISTS (select /*+ NO_UNNEST */ 'x'
350 from jl_zz_ap_comp_awt_types
351 where legal_entity_id = AP.legal_entity_id
352 and wh_agent_flag = 'Y'
353 and awt_type_code = P_Awt_Type_Code)
354 and ROWNUM=1), 'TRUE', 'TRUE','FALSE')
355 into V_FND_TYPE
356 from DUAL;
357
358 IF (V_FND_TYPE = 'TRUE') THEN find_type := TRUE;
359 ELSE find_type := FALSE;
360 END IF;
361
362 return(find_type);
363
364 EXCEPTION
365 WHEN OTHERS THEN
366 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
367 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Company_Agent','Exception in FUNCTION Company_Agent');
368 NULL;
369 END IF;
370 END;
371
372 /*------------------------------------------------------
373 The Following function is to find out whether the Tax Name is applicable to the Line_type
374 TAX-ID and Line Type are passed as a parameter for this function.
375 -----------------------------------------------------*/
376
377 FUNCTION Validate_Line_Type
378 (v_dist_type varchar2
379 ,v_tax_id ap_tax_codes_all.tax_id%type)
380 return boolean is
381 v_item_type ap_tax_codes_all.global_attribute8%type;
382 v_freight_type ap_tax_codes_all.global_attribute9%type;
383 v_misc_type ap_tax_codes_all.global_attribute10%type;
384 v_tax_type ap_tax_codes_all.global_attribute11%type;
385 find_type boolean;
386
387 CURSOR cur_validate_line_type is
388 SELECT global_attribute8, -- Type ITEM
389 global_attribute9, -- Type FREIGHT
390 global_attribute10,-- Type MISCELLANEOUS
391 global_attribute11 -- Type TAX
392 FROM ap_tax_codes
393 WHERE tax_id =v_tax_id;
394
395 BEGIN
396 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
397 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','Start FUNCTION Validate_Line_Type');
398 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','Parameters are :');
399 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type',' v_dist_type='||v_dist_type);
400 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type',' v_tax_id='||v_tax_id);
401 END IF;
402 find_type :=false;
403 OPEN cur_validate_line_type ;
404 LOOP
405 FETCH cur_validate_line_type INTO
406 v_item_type,
407 v_freight_type,
408 v_misc_type,
409 v_tax_type;
410 EXIT WHEN cur_validate_line_type%NOTFOUND;
411 --bug 6232172 - v_dist_type = 'ACCRUAL' is added
412 IF (v_dist_type = 'ITEM'
413 OR v_dist_type = 'ACCRUAL'
414 OR v_dist_type = 'IPV'
415 OR v_dist_type = 'ERV') AND (v_item_type='Y') THEN
416 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
417 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','FUNCTION Validate_Line_Type returns TRUE');
418 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','End FUNCTION Validate_Line_Type');
419 END IF;
420 find_type :=true ; return(find_type);
421 ELSIF (v_dist_type = 'FREIGHT') AND (v_freight_type ='Y') THEN
422 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
423 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','FUNCTION Validate_Line_Type returns TRUE');
424 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','End FUNCTION Validate_Line_Type');
425 END IF;
426 find_type :=true ; return(find_type);
427 ELSIF (v_dist_type = 'MISCELLANEOUS') AND (v_misc_type ='Y') THEN
428 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
429 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','FUNCTION Validate_Line_Type returns TRUE');
430 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','End FUNCTION Validate_Line_Type');
431 END IF;
432 find_type :=true ; return(find_type);
433 ELSIF (v_dist_type = 'TAX'
434 OR v_dist_type = 'NONREC_TAX'
435 OR v_dist_type = 'REC_TAX'
436 OR v_dist_type = 'TRV'
437 OR v_dist_type = 'TIPV'
438 OR v_dist_type = 'TERV') AND (v_tax_type ='Y') THEN
439 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
440 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','FUNCTION Validate_Line_Type returns TRUE');
441 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','End FUNCTION Validate_Line_Type');
442 END IF;
443 find_type :=true ; return(find_type);
444 END IF;
445 END LOOP;
446 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
447 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','FUNCTION Validate_Line_Type returns FALSE');
448 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','End FUNCTION Validate_Line_Type');
449 END IF;
450 return(find_type);
451 CLOSE cur_validate_line_type;
452 EXCEPTION
453 WHEN OTHERS THEN
454 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
455 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Validate_Line_Type','Exception in FUNCTION Validate_Line_Type');
456 NULL;
457 END IF;
458 END;
459
460 /*-----------------------------------------------------------------
461 The Procedure Province_zone_city is used to select region_1,region_2,town_or_city from
462 hr_locations for a ship_to_location_id.
463 -------------------------------------------------------------------*/
464 PROCEDURE Province_Zone_City
465 (p_ship_to_location_id hr_locations_all.location_id%TYPE
466 ,v_hr_zone out NOCOPY hr_locations_all.region_1%TYPE
467 ,v_hr_province out NOCOPY hr_locations_all.region_2%TYPE
468 ,v_city_code out NOCOPY hr_locations_all.town_or_city%TYPE) is
469
470 CURSOR cur_province_zone_city IS
471 SELECT region_1, region_2, town_or_city
472 FROM hr_locations_all
473 WHERE location_id = p_ship_to_location_id;
474 BEGIN
475 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
476 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City','Start PROCEDURE Province_Zone_City');
477 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City','Parameters are :');
478 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City',' p_ship_to_location_id='||p_ship_to_location_id);
479 END IF;
480 OPEN cur_province_zone_city ;
481 LOOP
482 FETCH cur_province_zone_city
483 INTO v_hr_zone , v_hr_province, v_city_code;
484 EXIT when cur_province_zone_city%NOTFOUND;
485 END LOOP;
486 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
487 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City','Out Parameters are :');
488 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City',' v_hr_zone='||v_hr_zone);
489 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City',' v_hr_province='||v_hr_province);
490 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City',' v_city_code='||v_city_code);
491 END IF;
492 CLOSE cur_province_zone_city ;
493 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
494 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City','End PROCEDURE Province_Zone_City');
495 END IF;
496 EXCEPTION
497 WHEN OTHERS THEN
498 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
499 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Province_Zone_City','Exception in PROCEDURE Province_Zone_City');
500 NULL;
501 END IF;
502 END;
503
504 /*-----------------------------------------------------------------
505 The Procedure Del_Wh_Def Delete the records in JL_ZZ_AP_INV_DIS_WH
506 for the Invoice_ID Parameter and the Dis_Lin_Number.
507 -------------------------------------------------------------------*/
508 --
509 -- R12 KI
510 --
511 PROCEDURE Del_Wh_Def
512 (
513 p_inv_dist_id ap_invoice_distributions_all.invoice_distribution_id%TYPE
514 ) IS
515 Begin
516 /*
517 DELETE JL_ZZ_AP_INV_DIS_WH
518 WHERE invoice_id = P_Invoice_Id
519 AND invoice_distribution_id = P_Dis_Lin_Num;
520 */
521 -- Bug 4559472
522 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
523 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Del_Wh_Def','Start PROCEDURE Del_Wh_Def');
524 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Del_Wh_Def','Parameters are :');
525 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Del_Wh_Def',' p_inv_dist_id='||p_inv_dist_id);
526 END IF;
527 DELETE jl_zz_ap_inv_dis_wh
528 WHERE invoice_distribution_id = p_inv_dist_id;
529 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
530 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Del_Wh_Def','End PROCEDURE Del_Wh_Def');
531 END IF;
532 EXCEPTION
533 WHEN OTHERS THEN
534 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
535 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Del_Wh_Def','Exception in PROCEDURE Del_Wh_Def');
536 NULL;
537 END IF;
538 End;
539
540
541 -- =====================================================================
542 -- P U B L I C O B J E C T S
543 -- =====================================================================
544 --
545 --
546
547 --
548 -- R12 KI
549 --
550 PROCEDURE Supp_Wh_Def_Line
551 ( p_invoice_id NUMBER,
552 p_inv_dist_id NUMBER,
553 p_tax_payer_id VARCHAR2, --bug 12665313
554 p_ship_to_loc VARCHAR2,
555 p_line_type VARCHAR2,
556 p_vendor_id NUMBER
557 ) IS
558 ---------------------------------------------------------------------
559 -- Cursor Supplier Withholding Types.
560 ---------------------------------------------------------------------
561 CURSOR Supp_Wh_Types(C_Vendor_Id jl_zz_ap_supp_awt_types.vendor_id%TYPE) Is
562 SELECT swt.supp_awt_type_id ,
563 swt.awt_type_code,
564 swc.supp_awt_code_id,
565 swc.org_id, -- Add Org_ID for MOAC
566 tca.tax_id,
567 tca.global_attribute7, -- Zone
568 awt.jurisdiction_type,
569 awt.province_code,
570 awt.city_code
571 FROM jl_zz_ap_supp_awt_types swt,
572 jl_zz_ap_sup_awt_cd swc,
573 ap_tax_codes_ALL tca, -- Add _ALL for MOAC
574 jl_zz_ap_awt_types awt
575 WHERE swt.vendor_id = C_vendor_id -- Select only for this Supplier
576 AND swt.wh_subject_flag = 'Y' -- Supp subject to the withholding tax type
577 AND swc.supp_awt_type_id = swt.supp_awt_type_id -- Join
578 AND swc.tax_id = tca.tax_id -- Join
579 --bug 11666467: Included TRUNC
580 AND (trunc(tca.inactive_date) > trunc(sysdate) -- Verify Tax Name Inactive Date
581 OR tca.inactive_date IS NULL)
582 AND swc.primary_tax_flag = 'Y' -- Verify the Primary Withholding Tax
583 AND awt.awt_type_code = swt.awt_type_code -- Join
584 --bug 11666467: Included TRUNC
585 AND trunc(sysdate) between trunc(nvl(swc.effective_start_date,sysdate))
586 and trunc(nvl(swc.effective_end_date,sysdate))
587 ; -- Argentine AWT ER 6624809
588
589
590 v_provincial_code jl_ar_ap_provinces.province_code%TYPE;
591
592 v_hr_zone hr_locations_all.region_1%TYPE;
593 v_hr_province hr_locations_all.region_2%TYPE;
594 v_hr_city hr_locations_all.town_or_city%TYPE;
595 -- v_hr_city_name hz_geographies.geography_name%TYPE; --Added Bug 6147511
596 v_hr_city_code hz_geographies.geography_code%TYPE; --Added Bug 11724717
597 pc_vendor_id number;
598 p_calling_sequence varchar2(2000):= 'Supp_Wh_Def_Line';
599 v_country_code varchar2(100); --bug 11666467
600
601
602 Begin
603
604 ------------------------------------------------------------------------------------------
605 -- Delete the lines in JL_ZZ_AP_INV_DIS.
606 ------------------------------------------------------------------------------------------
607 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
608 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Start PROCEDURE Supp_Wh_Def_Line');
609 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Parameters are :');
610 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line',' p_invoice_id='||p_invoice_id);
611 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line',' p_inv_dist_id='||p_inv_dist_id);
612 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line',' p_tax_payer_id='||p_tax_payer_id);
613 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line',' p_ship_to_loc='||p_ship_to_loc);
614 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line',' p_line_type='||p_line_type);
615 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line',' p_vendor_id='||p_vendor_id);
616 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Calling Del_Wh_Def');
617 END IF;
618 Del_Wh_Def(
619 /*
620 P_Invoice_Id
621 ,P_Dis_Lin_Num
622 */
623 -- Bug 4559472
624 p_inv_dist_id);
625 ------------------------------------------------------------------------------------------
626 -- Get the Vendor_Id from the Vendor_Num (Taxpayer_ID) or Invoice
627 ------------------------------------------------------------------------------------------
628 IF P_Vendor_Id IS NULL Then
629 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
630 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside IF P_Vendor_Id IS NULL Then');
631 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Calling Get_Vendor_Id');
632 END IF;
633 pc_vendor_id := Get_Vendor_Id (/*
634 v_tax_payer_id,
635 p_invoice_id
636 */
637 p_tax_payer_id,
638 p_invoice_id);
639 Else
640 pc_vendor_id := p_vendor_id;
641 End IF;
642 ------------------------------------------------------------------------------------------
643 -- Loop for each Supplier Withholding Type
644 -----------------------------------------------------------------------------------------
645 FOR db_reg IN Supp_Wh_Types(pc_vendor_id) LOOP
646 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
647 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside db_reg IN Supp_Wh_Types(pc_vendor_id) for pc_vendor_id='||pc_vendor_id);
648 END IF;
649 ---------------------------------------------------------------------------------
650 -- The cursor verify the Supplier Withholding Applicability
651 -- Each Supp Withholding Type in the Cursor needs to be check.
652 -- Company Agent says if the company have to withhold by this Withholding Type.
653 ---------------------------------------------------------------------------------
654 IF ( Company_Agent(db_reg.awt_type_code,
655 -- Added p_invoice_id for R12 LE changes
656 p_invoice_id)) THEN
657 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
658 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside IF ( Company_Agent(db_reg.awt_type_code ..');
659 END IF;
660 ----------------------------------------------------------------------------
661 -- Validate the withholding type is according to distribution line.
662 ----------------------------------------------------------------------------
663 IF Validate_Line_Type(
664 /*
665 v_line_type,
666 db_reg.tax_id
667 */
668 p_line_type,
669 db_reg.tax_id) THEN
670 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
671 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside IF Validate_Line_Type( ..');
672 END IF;
673 -----------------------------------------------------------------------
674 -- Get the information from Zone, Province and City
675 -----------------------------------------------------------------------
676 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
677 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Calling Province_Zone_City');
678 END IF;
679 Province_Zone_City
680 (
681 /*
682 v_ship_to_loc -- IN
683 */
684 p_ship_to_loc -- IN
685 ,v_hr_zone -- OUT NOCOPY
686 ,v_hr_province -- OUT NOCOPY
687 ,v_hr_city
688 ); -- OUT NOCOPY
689 -----------------------------------------------------------------------
690 -- Validate the Jurisdiction
691 -----------------------------------------------------------------------
692 IF ( db_reg.jurisdiction_type = 'PROVINCIAL') THEN
693 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
694 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside IF ( db_reg.jurisdiction_type = PROVINCIAL)');
695 END IF;
696 --------------------------------------------------------------------
697 -- Verify if the Withholding Tax for the Province is TERRITORY
698 --------------------------------------------------------------------
699 IF Ver_Territorial_Flag (db_reg.province_code) THEN
700 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
701 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside IF Ver_Territorial_Flag (db_reg.province_code)');
702 END IF;
703 -----------------------------------------------------------------
704 -- Validate if the Ship to Location from Inv Dis Line is in the province.
705 -----------------------------------------------------------------
706 IF db_reg.province_code = v_hr_province THEN
707 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
708 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside IF db_reg.province_code = v_hr_province THEN');
709 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Calling Insert_AWT_Default - 1');
710 END IF;
711 Insert_AWT_Default
712 (P_Invoice_Id
713 -- Bug 4559472
714 -- ,P_Dis_Lin_Num
715 , p_inv_dist_id
716 , db_reg. supp_awt_code_id
717 , p_calling_sequence
718 , db_reg.org_id ); -- Add org_Id for MOAC
719
720 END IF;
721 ELSE -- v_territorial_flag = 'N' is Country Wide
722 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
723 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside ELSE Ver_Territorial_Flag (db_reg.province_code)');
724 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Calling Insert_AWT_Default - 2');
725 END IF;
726 Insert_AWT_Default
727 (P_Invoice_Id
728 -- Bug 4559472
729 -- ,P_Dis_Lin_Num
730 , p_inv_dist_id
731 , db_reg. supp_awt_code_id
732 , p_calling_sequence
733 , db_reg.org_id ); -- Add org_Id for MOAC
734
735 END IF; -- PROVINCE Class
736 ELSIF db_reg.jurisdiction_type = 'ZONAL' THEN
737 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
738 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside ELSIF db_reg.jurisdiction_type = ZONAL THEN');
739 END IF;
740 ---------------------------------------------------------------
741 -- The name of the zone is taken from AP_TAX_CODES Global Att 7
742 ---------------------------------------------------------------
743 IF db_reg.global_attribute7 = v_hr_zone THEN
744 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
745 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside IF db_reg.global_attribute7 = v_hr_zone THEN');
746 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Calling Insert_AWT_Default - 3');
747 END IF;
748 Insert_AWT_Default
749 (P_Invoice_Id
750 -- Bug 4559472
751 -- ,P_Dis_Lin_Num
752 , p_inv_dist_id
753 , db_reg. supp_awt_code_id
754 , p_calling_sequence
755 , db_reg.org_id ); -- Add org_Id for MOAC
756
757 END IF; --Tax_Zone
758
759 ELSIF db_reg.jurisdiction_type = 'MUNICIPAL' THEN
760 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
761 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside ELSIF db_reg.jurisdiction_type = MUNICIPAL THEN');
762 END IF;
763
764 -- bug 11666467: Getting Country Code
765 v_country_code := JG_ZZ_SHARED_PKG.GET_COUNTRY(db_reg.org_id);
766
767 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
768 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Country_code = '||nvl(v_country_code,'**NULL**'));
769 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Selecting City Code from Geography Model:');
770 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','GEOGRAPHY_NAME = '||nvl(v_hr_city,'**NULL**'));
771 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','GEOGRAPHY_PROVINCE = '||nvl(v_hr_province,'**NULL**'));
772 END IF;
773
774 ---------------------------------------------------------------
775 -- Compare the Withholding Type City with the city in the line
776 ---------------------------------------------------------------
777 --Bug no: 6147511. Added this query to get the city name from geographies table
778 --bug 11724717: Modified query to retrieve Geo Code
779 select geography_code
780 into v_hr_city_code
781 from hz_geographies
782 where geography_name = v_hr_city
783 and geography_element2_code = v_hr_province
784 and geography_type='CITY'
785 --bug 11666467: Start
786 and country_code = v_country_code
787 and trunc(sysdate) between trunc(nvl(start_date,sysdate))
788 and trunc(nvl(end_date,sysdate));
789
790 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
791 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','SHIP TO City Code = '||nvl(v_hr_city_code,'**NULL**'));
792 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','AWT TYPE City Code = '||nvl(db_reg.city_code,'**NULL**'));
793 END IF;
794
795 --bug 11666467: End
796 --Bug no: 6147511, Previous condition : IF db_reg.city_code = v_hr_city THEN
797 IF v_hr_city_code = db_reg.city_code THEN --bug 11724717
798 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
799 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Calling Insert_AWT_Default - 4');
800 END IF;
801 Insert_AWT_Default
802 (P_Invoice_Id
803 -- Bug 4559472
804 -- ,P_Dis_Lin_Num
805 , p_inv_dist_id
806 , db_reg. supp_awt_code_id
807 , p_calling_sequence
808 , db_reg.org_id ); -- Add org_Id for MOAC
809
810 END IF;
811
812 ELSE -- db_reg.jurisdiction_type = 'FEDERAL'
813 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
814 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Inside ELSE FOR db_reg.jurisdiction_type = FEDERAL');
815 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Calling Insert_AWT_Default - 5');
816 END IF;
817 Insert_AWT_Default
818 (P_Invoice_Id
819 -- Bug 4559472
820 -- ,P_Dis_Lin_Num
821 , p_inv_dist_id
822 , db_reg. supp_awt_code_id
823 , p_calling_sequence
824 , db_reg.org_id ); -- Add org_Id for MOAC
825
826 END IF;--jurisdiction type
827 END IF;--validate line_type
828 END IF;--withholding applicability
829 END LOOP; -- Loop for each Supplier Withholding Type
830 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
831 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','End PROCEDURE Supp_Wh_Def_Line');
832 END IF;
833 EXCEPTION
834 WHEN OTHERS THEN
835 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
836 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def_Line','Exception in PROCEDURE Supp_Wh_Def_Line');
837 NULL;
838 END IF;
839 END Supp_Wh_Def_Line;
840
841 /*----------------------------------------------------------------------------------------------
842 Supp_Wh_Def receive as parameters the P_Invoice_Id and P_Dis_Lin_Num
843 If P_Dis_Lin_Num IS NULL this procedure process all the lines in the invoice
844 Else Only process the line that receive as parameter.
845 ------------------------------------------------------------------------------------------------*/
846
847 --
848 -- R12 KI
849 --
850
851 PROCEDURE Supp_Wh_Def
852 ( P_Invoice_Id ap_invoices_all.invoice_id%TYPE
853 , P_Inv_Line_Num ap_invoice_lines_all.line_number%TYPE
854 , P_Inv_Dist_Id ap_invoice_distributions_all.invoice_distribution_id%TYPE
855 , P_Calling_Module VARCHAR2
856 , P_Parent_Dist_ID IN Number Default null
857 ) IS
858
859 --
860 -- R12 KI Changes : 4559472
861 --
862 CURSOR Invoice_Distrib IS
863 SELECT invoice_distribution_id
864 FROM ap_invoice_distributions
865 WHERE invoice_id = P_Invoice_ID
866 AND invoice_line_number = P_Inv_Line_Num;
867
868 -- Added Cursor for bug 6869263
869 CURSOR c_default_wh_dist (p_related_dist_id number) IS
870 SELECT Supp_Awt_Code_Id,
871 org_id
872 FROM jl_zz_ap_inv_dis_wh
873 WHERE invoice_id = p_invoice_id
874 AND invoice_distribution_id = p_related_dist_id;
875
876 -- The following variables are used to get the information from the invoice
877 -- ditribution lines.
878 v_tax_payer_id ap_invoice_distributions_all.global_attribute2%TYPE;
879 v_ship_to_loc ap_invoice_distributions_all.global_attribute3%TYPE;
880 v_line_type ap_invoice_distributions_all.line_type_lookup_code %TYPE;
881 v_last_update_login number := FND_GLOBAL.Login_Id;
882 v_last_update_by number := FND_GLOBAL.User_ID;
883 DistWithholdings Number := 0;
884 -- Variable added for bug 6869263
885 v_related_dist_id ap_invoice_distributions_all.related_id%TYPE;
886
887 Begin
888 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
889 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Start PROCEDURE Supp_Wh_Def');
890 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Parameters are :');
891 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def',' P_Invoice_Id='||P_Invoice_Id);
892 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def',' P_Inv_Line_Num='||P_Inv_Line_Num);
893 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def',' P_Inv_Dist_Id='||P_Inv_Dist_Id);
894 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def',' P_Calling_Module='||P_Calling_Module);
895 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def',' P_Parent_Dist_ID='||P_Parent_Dist_ID);
896 END IF;
897
898 -- Bug 12944204 Start
899 Upd_Dist_GDF( p_invoice_id, p_inv_line_num, p_inv_dist_id);
900 -- Bug 12944204 End
901
902 /*
903 ** R12 KI Changes : Pseudo Logic
904 **
905 **
906 **
907
908
909 -- ***** CALLER *****
910 -- JLZZPIDW for redefault witholding applicability
911 IF p_inv_dist_id IS NOT NULL THEN
912
913
914 -- ***** CALLER *****
915 -- Validation Processes
916 -- APXINWKB (JL.pld) for ship to location change
917 ELSE p_inv_dist_id IS NULL THEN
918
919 -- ***** CALLER *****
920 -- Validate Process in UI
921 IF p_calling_module = 'NO_OVERRIDE' THEN
922 -- Check if extended withholding distribution line exists for this invoice line
923
924 -- ***** CALLER *****
925 -- Validate Process in Invoice Import
926 -- APXINWKB (JL.pld) for ship to location change
927 ELSE
928 -- For each distribution for an invoice line loop
929
930 -- Get ship to location : LINE
931 -- Get taxpayer id : DIST
932 -- Get distribution line type : DIST
933 -- Call supp_wh_def_line
934 -- p_invoice_id
935 -- p_dis_lin_num -> p_dist_line_id
936 -- p_tax_payer_id
937 -- p_ship_to_loc
938 -- p_line_type
939 -- p_vendor_id
940
941 -- End loop
942 END IF;
943
944 END IF;
945
946 **
947 **
948 ** End of Pseudo logic
949 **
950 **
951 */
952 ---------------------------------------------------------------------
953 -- Checking calling point
954 ---------------------------------------------------------------------
955 --Bug no : 6159617 -Removed the IF condition. The P_Calling_Module was
956 -- called with null values and the changes made to the witholdings
957 -- were overridden by default values on validation.
958 -- IF P_Calling_Module = 'NO_OVERRIDE' THEN
959 --Bug no : 6395850 - Added the following code for handling Redefault withholding button.
960 IF p_calling_module = 'JLZZPIDW' THEN
961 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
962 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','IF p_calling_module = JLZZPIDW THEN');
963 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Redefaulting the withholdings for distibution id '||P_Inv_Dist_Id);
964 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Calling Del_Wh_Def');
965 END IF;
966 Del_Wh_Def(P_Inv_Dist_Id);
967 END IF;
968 --Bug no : 6395850 - The existing withholdings are erased and then redefaulted.
969 ------------------------------------------------------------------
970 -- Checking if the distribution line has withholdings
971 ------------------------------------------------------------------
972 --Bug no : 6215810 - Changed the query
973 -- Select 1
974 SELECT COUNT(*)
975 INTO DistWithholdings
976 From jl_zz_ap_inv_dis_wh
977 Where invoice_id = P_Invoice_ID
978 And invoice_distribution_id = P_Inv_Dist_Id;
979 -- And rownum = 1;
980 --Bug no : 6215810 -Commented the above line
981 -- Debug
982 IF (DEBUG_Var = 'Y') THEN
983 JL_ZZ_AP_EXT_AWT_UTIL.Debug ('AWT Defaulting Exist No Override - Returning');
984 END IF;
985 -- End Debug
986 --Bug no : 6159617 - Changed the IF Condition
987 -- IF DistWithholdings = 1 Then
988 IF DistWithholdings <> 0 THEN
989 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
990 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Inside IF DistWithholdings <> 0 THEN');
991 END IF;
992 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
993 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','End PROCEDURE Supp_Wh_Def - 1');
994 END IF;
995 Return;
996 End IF;
997 -- End IF;
998 --Bug no : 6159617 -Removed the IF condition.
999 ---------------------------------------------------------------------
1000 -- Cheking if parent distribution id is not null
1001 --------------------------------------------------------------------
1002 IF P_Parent_Dist_ID IS NOT NULL Then
1003 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1004 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Inside IF P_Parent_Dist_ID IS NOT NULL Then');
1005 END IF;
1006 ----------------------------------------------------------
1007 -- Copy the tax names from the parent distribution line
1008 ----------------------------------------------------------
1009 -- Debug
1010 IF (DEBUG_Var = 'Y') THEN
1011 JL_ZZ_AP_EXT_AWT_UTIL.Debug ('AWT Defaulting from Parent Dist ID');
1012 END IF;
1013 -- End Debug
1014 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1015 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','INSERT INTO jl_zz_ap_inv_dis_wh (...');
1016 END IF;
1017 INSERT INTO jl_zz_ap_inv_dis_wh (
1018 inv_distrib_awt_id
1019 ,invoice_id
1020 -- Bug 4559478
1021 ,invoice_distribution_id
1022 ,distribution_line_number
1023 ,supp_awt_code_id
1024 ,created_by
1025 ,creation_date
1026 ,last_updated_by
1027 ,last_update_date
1028 ,last_update_login
1029 ,org_id
1030 )
1031 SELECT
1032 jl_zz_ap_inv_dis_wh_s.nextval
1033 ,P_Invoice_Id
1034 ,P_Inv_Dist_Id
1035 -- Bug 4559478 : -99 for distribution_line_number
1036 ,-99
1037 ,jlid.Supp_Awt_Code_Id
1038 ,v_last_update_by
1039 ,sysdate
1040 ,v_last_update_by
1041 ,sysdate
1042 ,v_last_update_login
1043 ,jlid.org_id
1044 FROM
1045 jl_zz_ap_inv_dis_wh jlid
1046 WHERE jlid.invoice_distribution_id = P_Parent_Dist_ID
1047 AND jlid.invoice_id = P_Invoice_Id;
1048 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
1049 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','End PROCEDURE Supp_Wh_Def - 2');
1050 END IF;
1051 RETURN;
1052 END IF;
1053 ----------------------------------------------------------------------
1054 -- Validate if the parameter P_Inv_Dis_Id IS NULL
1055 ----------------------------------------------------------------------
1056 IF p_inv_dist_id IS NOT NULL THEN
1057 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1058 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Inside IF p_inv_dist_id IS NOT NULL THEN');
1059 END IF;
1060 -------------------------------------------------------------------
1061 -- Information Invoice Distributions
1062 -------------------------------------------------------------------
1063 -- Bug 4559472
1064 -- Revert changes for R12 - Bug 4674638
1065 -- Debug
1066 IF (DEBUG_Var = 'Y') THEN
1067 JL_ZZ_AP_EXT_AWT_UTIL.Debug ('AWT Defaulting From Param Inv Dist ID');
1068 END IF;
1069 -- End Debug
1070
1071 SELECT apid.global_attribute2 -- Taxpayer Id for Colombia
1072 ,apid.global_attribute3 -- Ship to Location Argentina/Colombia
1073 -- , apil.ship_to_location_id -- Ship to Location Argentina/Colombia
1074 , apid.line_type_lookup_code -- Line Type
1075 INTO v_tax_payer_id,
1076 v_ship_to_loc,
1077 v_line_type
1078 FROM AP_Invoice_Distributions apid,
1079 AP_Invoice_Lines apil
1080 WHERE apid.invoice_id = p_invoice_id
1081 AND apid.invoice_distribution_id = p_inv_dist_id
1082 AND apid.invoice_line_number = apil.line_number
1083 AND apid.invoice_id = apil.invoice_id;
1084 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1085 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Calling Supp_Wh_Def_Line - 1');
1086 END IF;
1087 Supp_Wh_Def_Line( P_Invoice_Id
1088 , P_Inv_Dist_id
1089 , v_tax_payer_id
1090 , v_ship_to_loc
1091 , v_line_type
1092 , null
1093 );
1094
1095 ELSE
1096 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1097 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Inside ELSE p_inv_dist_id IS NOT NULL THEN');
1098 END IF;
1099 -------------------------------------------------------------
1100 -- Loop for each Invoice Distribution Line.
1101 -------------------------------------------------------------
1102 -- Debug
1103 IF (DEBUG_Var = 'Y') THEN
1104 JL_ZZ_AP_EXT_AWT_UTIL.Debug ('AWT Defaulting for distributions');
1105 END IF;
1106 -- End Debug
1107 FOR db_reg IN Invoice_Distrib LOOP
1108 -------------------------------------------------------------------
1109 -- Information Invoice Distribution Lines.
1110 -------------------------------------------------------------------
1111 SELECT apid.global_attribute2 -- Taxpayer Id for Colombia
1112 ,apid.global_attribute3 -- Ship to Location Argentina/Colombia
1113 -- , apil.ship_to_location_id -- Ship to Location Argentina/Colombia
1114 , apid.line_type_lookup_code -- Line Type
1115 INTO v_tax_payer_id,
1116 v_ship_to_loc,
1117 v_line_type
1118 FROM AP_Invoice_Distributions apid,
1119 AP_Invoice_Lines apil
1120 WHERE apid.invoice_id = P_Invoice_Id
1121 AND apid.invoice_distribution_id = db_reg.invoice_distribution_id
1122 AND apid.invoice_line_number = apil.line_number
1123 AND apid.invoice_id = apil.invoice_id;
1124 --bug 6346106 changes - The following code is added
1125 SELECT COUNT(*)
1126 INTO DistWithholdings
1127 FROM jl_zz_ap_inv_dis_wh
1128 WHERE invoice_id = P_Invoice_ID
1129 AND invoice_distribution_id = db_reg.invoice_distribution_id;
1130 IF (DEBUG_Var = 'Y') THEN
1131 JL_ZZ_AP_EXT_AWT_UTIL.Debug ('AWT Defaulting Exist No Override - Returning');
1132 END IF;
1133
1134 IF DistWithholdings <> 0 THEN
1135 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1136 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Inside IF DistWithholdings <> 0 THEN');
1137 END IF;
1138 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
1139 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','End PROCEDURE Supp_Wh_Def - 3');
1140 END IF;
1141 --Return;
1142 --End IF;
1143 ELSE
1144 -- Code added for bug 6869263
1145 IF upper(p_calling_module) = upper('AP_APPROVAL_PKG.Approval<-APXINWKB') and DistWithholdings = 0 AND
1146 v_line_type NOT IN ('IPV','ERV','TRV','TIPV','TERV') THEN
1147
1148 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1149 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Inside call to ap_approval_pkg and Distwith =0 and line type not in variance');
1150 END IF;
1151
1152 ELSIF upper(p_calling_module) = upper('AP_APPROVAL_PKG.Approval<-APXINWKB') and DistWithholdings = 0 AND
1153 v_line_type IN ('IPV','ERV','TRV','TIPV','TERV') THEN
1154
1155 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1156 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Inside call to ap_approval_pkg and Distwith =0 and line type in variance');
1157 END IF;
1158
1159 SELECT related_id
1160 INTO v_related_dist_id
1161 FROM ap_invoice_distributions
1162 WHERE invoice_id = P_Invoice_Id
1163 AND invoice_distribution_id = db_reg.invoice_distribution_id;
1164
1165 FOR l_def_wh_dist IN c_default_wh_dist(v_related_dist_id) LOOP
1166
1167 INSERT INTO jl_zz_ap_inv_dis_wh (
1168 inv_distrib_awt_id
1169 ,invoice_id
1170 ,distribution_line_number
1171 ,invoice_distribution_id
1172 ,supp_awt_code_id
1173 ,created_by
1174 ,creation_date
1175 ,last_updated_by
1176 ,last_update_date
1177 ,last_update_login
1178 ,org_id -- Add org_id for MOAC
1179 )
1180 VALUES (
1181 jl_zz_ap_inv_dis_wh_s.nextval
1182 ,P_Invoice_Id
1183 ,-99
1184 , db_reg.invoice_distribution_id
1185 ,l_def_wh_dist.Supp_Awt_Code_Id
1186 ,v_last_update_by
1187 ,sysdate
1188 ,v_last_update_by
1189 ,sysdate
1190 ,v_last_update_login
1191 ,l_def_wh_dist.Org_Id
1192 );
1193
1194 END LOOP;
1195
1196 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1197 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Inside call to ap_approval_pkg and Distwith =0 and line type in variance, inserted record into jl_zz_ap_inv_dis_wh table ');
1198 END IF;
1199
1200 ELSE
1201 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1202 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Calling Supp_Wh_Def_Line - 2');
1203 END IF;
1204 --bug 6346106 changes end
1205 Supp_Wh_Def_Line(
1206 P_Invoice_Id
1207 , db_reg.invoice_distribution_id
1208 , v_tax_payer_id
1209 , v_ship_to_loc
1210 , v_line_type
1211 , null
1212 );
1213 END IF; -- upper(p_calling_module)
1214 END IF; -- DistWithholings <> 0
1215 END LOOP; -- Invoice Distribution Line
1216 END IF; -- P_Dis_Lin_Num IS NULL
1217 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
1218 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','End PROCEDURE Supp_Wh_Def - 4');
1219 END IF;
1220 EXCEPTION
1221 WHEN OTHERS THEN
1222 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
1223 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_Def','Exception in PROCEDURE Supp_Wh_Def');
1224 NULL;
1225 END IF;
1226 END Supp_Wh_Def;
1227
1228 /*----------------------------------------------------------------------------------------------
1229 Carry_Withholdings_Prepay copy the withholdings from Prepayment Invoice
1230 Item Line to Standard Invoice PREPAY line.
1231 ------------------------------------------------------------------------------------------------*/
1232 --
1233 -- R12 KI
1234 --
1235
1236 PROCEDURE Carry_Withholdings_Prepay
1237 (P_prepay_dist_id Number
1238 ,P_Invoice_Id Number
1239 ,P_inv_dist_id Number
1240 ,P_User_Id Number
1241 ,P_last_update_login Number
1242 ,P_Calling_Sequence Varchar2
1243 ) IS
1244 l_prepay_id Number;
1245
1246 l_prepay_dist_line_num Number;
1247
1248 l_calling_sequence Varchar2(2000);
1249 Begin
1250 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
1251 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay','Start PROCEDURE Carry_Withholdings_Prepay');
1252 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay','Parameters are :');
1253 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay',' P_prepay_dist_id='||P_prepay_dist_id);
1254 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay',' P_Invoice_Id='||P_Invoice_Id);
1255 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay',' P_inv_dist_id='||P_inv_dist_id);
1256 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay',' P_User_Id='||P_User_Id);
1257 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay',' P_last_update_login='||P_last_update_login);
1258 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay',' P_Calling_Sequence='||P_Calling_Sequence);
1259 END IF;
1260 -----------------------------------
1261 -- Value for p_calling_sequence
1262 -----------------------------------
1263 l_calling_sequence := P_calling_sequence||'Carry_Withholdings_Prepay';
1264
1265 ------------------------------------------------------------------------
1266 -- Get invoice_id and invoice_distribution_id from p_prepay_dist_id (PK)
1267 ------------------------------------------------------------------------
1268 /*
1269 ** Bug 4559474
1270 **
1271 ** Commented out the query as invoice_id and invoice_distribution_id
1272 ** for payment_distribution_id is passed from AP through
1273 ** input parameters.
1274 **
1275 SELECT invoice_id,
1276 invoice_distribution_id
1277 INTO l_prepay_id,
1278 l_prepay_dist_line_num
1279 FROM ap_invoice_distributions
1280 WHERE invoice_distribution_id = P_prepay_dist_id;
1281 */
1282
1283 -----------------------------------------------------------------------
1284 -- Copy the withholdings to the new PREPAY line.
1285 -- Insert Withholdings in the table.
1286 ----------------------------------------------------------------------
1287 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1288 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay','INSERT INTO jl_zz_ap_inv_dis_wh ...');
1289 END IF;
1290 INSERT INTO jl_zz_ap_inv_dis_wh
1291 (INV_DISTRIB_AWT_ID,
1292 INVOICE_ID,
1293 distribution_line_number, -- Bug 4559474
1294 invoice_distribution_id, -- Bug 4559474
1295 SUPP_AWT_CODE_ID,
1296 CREATED_BY,
1297 CREATION_DATE,
1298 LAST_UPDATED_BY,
1299 LAST_UPDATE_DATE,
1300 LAST_UPDATE_LOGIN,
1301 ORG_ID,
1302 ATTRIBUTE_CATEGORY,
1303 ATTRIBUTE1,
1304 ATTRIBUTE2,
1305 ATTRIBUTE3,
1306 ATTRIBUTE4,
1307 ATTRIBUTE5,
1308 ATTRIBUTE6,
1309 ATTRIBUTE7,
1310 ATTRIBUTE8,
1311 ATTRIBUTE9,
1312 ATTRIBUTE10,
1313 ATTRIBUTE11,
1314 ATTRIBUTE12,
1315 ATTRIBUTE13,
1316 ATTRIBUTE14,
1317 ATTRIBUTE15)
1318 SELECT
1319 JL_ZZ_AP_INV_DIS_WH_S.nextval,
1320 P_Invoice_Id,
1321 -99, -- Bug 4559474
1322 p_inv_dist_id, -- Bug 4559474
1323 idw.supp_awt_code_id,
1324 P_user_id,
1325 SYSDATE,
1326 DECODE(P_last_update_login,-999,P_user_id,P_last_update_login),
1327 SYSDATE,
1328 DECODE(P_last_update_login,-999,P_user_id,P_last_update_login),
1329 idw.ORG_ID,
1330 idw.ATTRIBUTE_CATEGORY,
1331 idw.ATTRIBUTE1,
1332 idw.ATTRIBUTE2,
1333 idw.ATTRIBUTE3,
1334 idw.ATTRIBUTE4,
1335 idw.ATTRIBUTE5,
1336 idw.ATTRIBUTE6,
1337 idw.ATTRIBUTE7,
1338 idw.ATTRIBUTE8,
1339 idw.ATTRIBUTE9,
1340 idw.ATTRIBUTE10,
1341 idw.ATTRIBUTE11,
1342 idw.ATTRIBUTE12,
1343 idw.ATTRIBUTE13,
1344 idw.ATTRIBUTE14,
1345 idw.ATTRIBUTE15
1346 FROM jl_zz_ap_inv_dis_wh idw
1347 WHERE idw.invoice_distribution_id = p_prepay_dist_id; -- Bug 4559474
1348 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
1349 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay','End PROCEDURE Carry_Withholdings_Prepay');
1350 END IF;
1351 EXCEPTION
1352 WHEN OTHERS THEN
1353 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
1354 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Carry_Withholdings_Prepay','Exception in PROCEDURE Carry_Withholdings_Prepay');
1355 NULL;
1356 END IF;
1357 END Carry_Withholdings_Prepay;
1358 /*----------------------------------------------------------------------------------------------
1359 Supp_Wh_ReDef receive as parameters the P_Invoice_Id and P_Vendor_ID
1360 Bug 3609925
1361 ------------------------------------------------------------------------------------------------*/
1362 PROCEDURE Supp_Wh_ReDefault
1363 ( P_Invoice_Id ap_invoices_all.invoice_id%TYPE
1364 , P_Vendor_ID po_vendors.vendor_id%TYPE
1365 ) IS
1366
1367 CURSOR Invoice_Distrib IS
1368 SELECT invoice_distribution_id
1369 FROM ap_invoice_distributions
1370 WHERE invoice_id = P_Invoice_ID;
1371 -- The following variables are used to get the information from the invoice
1372 -- ditribution lines.
1373 v_tax_payer_id ap_invoice_distributions_all.global_attribute2%TYPE;
1374 v_ship_to_loc ap_invoice_distributions_all.global_attribute3%TYPE;
1375 v_line_type ap_invoice_distributions_all. line_type_lookup_code%TYPE;
1376
1377 Begin
1378 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
1379 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_ReDefault','Start PROCEDURE Supp_Wh_ReDefault');
1380 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_ReDefault','Parameters are :');
1381 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_ReDefault',' P_Invoice_Id='||P_Invoice_Id);
1382 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_ReDefault',' P_Vendor_ID='||P_Vendor_ID);
1383 END IF;
1384 -------------------------------------------------------------
1385 -- Loop for each Invoice Distribution Line.
1386 -------------------------------------------------------------
1387 FOR db_reg IN Invoice_Distrib LOOP
1388 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1389 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_ReDefault','Inside FOR db_reg IN Invoice_Distrib LOOP');
1390 END IF;
1391 -------------------------------------------------------------------
1392 -- Information Invoice Distribution Lines.
1393 -------------------------------------------------------------------
1394 -- Revert changes for R12 - Bug 4674638
1395 SELECT apid.global_attribute2 -- Taxpayer Id for Colombia
1396 ,apid.global_attribute3 -- Ship to Location Argentina/Colombia
1397 ,apid.line_type_lookup_code -- Line Type
1398 INTO v_tax_payer_id,
1399 v_ship_to_loc,
1400 v_line_type
1401 FROM AP_Invoice_Distributions apid,
1402 AP_Invoice_Lines apil
1403 WHERE apid.invoice_id = P_Invoice_Id
1404 AND apid.invoice_distribution_id = db_reg.invoice_distribution_id
1405 AND apil.line_number = apid.invoice_line_number
1406 AND apid.invoice_id = apil.invoice_id;
1407 IF (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1408 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_ReDefault','Calling Supp_Wh_Def_Line');
1409 END IF;
1410 Supp_Wh_Def_Line(P_Invoice_Id
1411 ,db_reg.invoice_distribution_id
1412 ,v_tax_payer_id
1413 ,v_ship_to_loc
1414 ,v_line_type
1415 ,p_vendor_id
1416 );
1417
1418 END LOOP; -- Invoice Distribution Line
1419 IF (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) THEN
1420 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_ReDefault','End PROCEDURE Supp_Wh_ReDefault');
1421 END IF;
1422 EXCEPTION
1423 WHEN OTHERS THEN
1424 IF (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) THEN
1425 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Supp_Wh_ReDefault','Exception in PROCEDURE Supp_Wh_ReDefault');
1426 NULL;
1427 END IF;
1428 END Supp_Wh_ReDefault;
1429
1430 -- Bug12944204 Start
1431 Procedure Upd_Dist_Gdf( P_Invoice_Id ap_invoices.invoice_id%Type
1432 ,P_Inv_Line_Num ap_invoice_lines.line_number%Type
1433 ,P_Inv_Dist_Id ap_invoice_distributions.invoice_distribution_id%Type) Is
1434 l_org_id ap_invoices.org_id%Type;
1435 l_invoice_type_lookup_code ap_invoices.invoice_type_lookup_code%Type;
1436 l_country_code Varchar2(30);
1437 l_gdf_category ap_invoice_distributions.global_attribute_category%Type;
1438 l_ship_to_location ap_invoice_lines.ship_to_location_id%Type;
1439 l_line_type_code ap_invoice_lines.line_type_lookup_code%Type;
1440
1441 Cursor C_Inv (x_invoice_id In ap_invoices.invoice_id%Type) Is
1442 Select org_id, invoice_type_lookup_code
1443 From ap_invoices
1444 Where invoice_id = x_invoice_Id;
1445
1446 Cursor C_Ship_To_Location ( x_invoice_id in ap_invoices.invoice_id%Type
1447 ,x_inv_line_num in ap_invoice_lines.line_number%Type) Is
1448 Select ship_to_location_id, line_type_lookup_code
1449 From ap_invoice_lines
1450 Where invoice_id = x_invoice_id
1451 And line_number = x_inv_line_num;
1452
1453 Begin
1454 If (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) Then
1455 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf',' Start Procedure Upd_Dist_Gdf');
1456 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf',' Parameters are :');
1457 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf',' P_Invoice_Id='|| P_Invoice_Id);
1458 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf',' P_Inv_Line_Num='|| P_Inv_Line_Num);
1459 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf',' P_Inv_Dist_Id='|| p_Inv_Dist_Id);
1460 End If;
1461
1462 For C_Inv_Rec In C_Inv (P_Invoice_Id) Loop
1463 l_org_id := C_Inv_Rec.Org_id;
1464 l_invoice_type_lookup_code := C_Inv_Rec.invoice_type_lookup_code;
1465
1466 Select JG_ZZ_SHARED_PKG.GET_COUNTRY(l_org_id, null)
1467 Into l_country_code
1468 From dual;
1469
1470 If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) Then
1471 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','Org Id : ' || l_org_id);
1472 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','Invoice Type Lookup Code : '||l_invoice_type_lookup_code);
1473 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','Country Code : '||l_country_code);
1474 End If;
1475 End Loop;
1476
1477 If l_country_code = 'AR' Then
1478 l_gdf_category := 'JL.AR.APXINWKB.DISTRIBUTIONS';
1479
1480 If upper(l_invoice_type_lookup_code) <> 'AWT' Then
1481 For C_Ship_To_Location_Rec in C_Ship_To_Location (P_Invoice_Id, P_Inv_Line_Num) Loop
1482 l_ship_to_location := C_Ship_To_Location_Rec.ship_to_location_id;
1483 l_line_type_code := C_Ship_To_Location_Rec.line_type_lookup_code;
1484 If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1485 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','Line Type code : ' || l_line_type_code );
1486 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','l_gdf category : ' || l_gdf_category );
1487 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','Ship to Location Id : ' || l_ship_to_location );
1488 End If;
1489 If upper(l_line_type_code) = 'ITEM' Then
1490 Update ap_invoice_distributions
1491 Set global_attribute3 = l_ship_to_location,
1492 global_attribute_category = l_gdf_category
1493 Where invoice_id = P_Invoice_Id
1494 -- Bug 13960680 Start
1495 And invoice_line_number = P_Inv_Line_Num
1496 -- Bug 13960680 End
1497 And invoice_distribution_id = P_Inv_Dist_Id
1498 And (global_attribute3 is null or global_attribute_category is null);
1499 If Sql%Found Then
1500 If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL ) THEN
1501 FND_LOG.STRING(G_LEVEL_STATEMENT, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','Distribution Updated' );
1502 End If;
1503 End If;
1504 End If;
1505 End Loop;
1506 End if;
1507 End if;
1508 If (G_LEVEL_PROCEDURE >= G_CURRENT_RUNTIME_LEVEL ) Then
1509 FND_LOG.STRING(G_LEVEL_PROCEDURE, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','End Procedure Upd_Dist_Gdf');
1510 End If;
1511 Exception
1512 When Others THEN
1513 If (G_LEVEL_EXCEPTION >= G_CURRENT_RUNTIME_LEVEL ) Then
1514 FND_LOG.STRING(G_LEVEL_EXCEPTION, 'JL.plsql.JL_ZZ_AP_AWT_DEFAULT_PKG.Upd_Dist_Gdf','Exception in Procedure Upd_Dist_Gdf');
1515 End If;
1516 End Upd_Dist_Gdf;
1517 -- Bug12944204 End
1518
1519 END JL_ZZ_AP_AWT_DEFAULT_PKG; -- Package
1520