DBA Data[Home] [Help]

PACKAGE BODY: APPS.JG_EXTENDED_WITHHOLDING_PKG

Source


6 /**************************************************************************
1 PACKAGE BODY JG_EXTENDED_WITHHOLDING_PKG AS
2 /* $Header: jgexawtb.pls 120.18 2011/05/29 16:42:33 mkandula ship $ */
3 
4 
5 
7  *                          Public Procedures                             *
8  **************************************************************************/
9 
10 
11 /**************************************************************************
12  *                                                                        *
13  * Name       : Jg_Do_Extended_Withholding                                *
14  * Purpose    : Regional Extended Routine for the Withholding Tax         *
15  *              Calculation                                               *
16  *                                                                        *
17  **************************************************************************/
18 FUNCTION JG_DO_EXTENDED_WITHHOLDING
19               (P_Invoice_Id             IN     Number,
20                P_Awt_Date               IN     Date,
21                P_Calling_Module         IN     Varchar2,
22                P_Amount                 IN     Number,
23                P_Payment_Num            IN     Number     Default null,
24                P_Checkrun_Name          IN     Varchar2   Default null,
25                P_Checkrun_id            IN     Number     Default null,
26                P_Last_Updated_By        IN     Number,
27                P_Last_Update_Login      IN     Number,
28                P_Program_Application_Id IN     Number     Default null,
29                P_Program_Id             IN     Number     Default null,
30                P_Request_Id             IN     Number     Default null,
31                P_Invoice_Payment_Id     IN     Number     Default null,
32                P_Check_Id               IN     Number     Default null)
33                RETURN NUMBER
34 IS
35 
36     l_country_code    Varchar2(10);
37     l_awt_success     Varchar2(2000);
38 
39     l_ou_id           NUMBER;
40 
41 BEGIN
42 
43     l_awt_success     := 'SUCCESS';
44 
45     ------------------------
46     -- Get the Country Code
47     ------------------------
48     --fnd_profile.get('ORG_ID',l_ou_id);
49 
50     l_ou_id  :=  MO_GLOBAL.get_current_org_id;				--bug 8501685
51 
52    --Bug 10079561 Start
53      JL_ZZ_AP_EXT_AWT_UTIL.Debug('Current org_id ' || l_ou_id);
54 
55     IF l_ou_id IS NULL THEN
56        JL_ZZ_AP_EXT_AWT_UTIL.Debug('MO_GLOBAL.get_current_org_id returned null, hence this is a PPR process ' ||
57                                    'and not quick payment');
58        Begin
59           -- For Argentian PPR process should be run for one org only
60           -- since the recommended setup is 1 (LE) - 1 (OU) - 1 (SOB/Ledger).
61           -- Hence Checking if the checkrun pays invoices of multiple orgs
62           JL_ZZ_AP_EXT_AWT_UTIL.Debug('Checking for multiple orgs for Checkrun name : ' || P_Checkrun_Name ||
63                                       ' and Checkrun ID : ' || P_Checkrun_ID);
64           SELECT DISTINCT Org_Id
65           into l_ou_id
66           FROM AP_SELECTED_INVOICES_ALL
67           WHERE checkrun_name = P_Checkrun_Name
68           AND   checkrun_id = P_Checkrun_id;
69 
70           -- One distinct org is found, hence setting the policy context for the org and then fetching  the country code
71           JL_ZZ_AP_EXT_AWT_UTIL.Debug('Org id :' || l_ou_id );
72           mo_global.set_policy_context('S', l_ou_id);
73 
74        Exception
75           When others then
76              -- Either multiple orgs are fetched or some other exception is encountered.
77              JL_ZZ_AP_EXT_AWT_UTIL.Debug('Exception encountered, hence setting the country code to Null');
78              l_country_code := NULL;
79        End;
80     End If;
81 
82 	l_country_code := jg_zz_shared_pkg.get_country(l_ou_id, NULL);
83 	 JL_ZZ_AP_EXT_AWT_UTIL.Debug('Org id ' || l_ou_id || ' Country Code : ' || l_country_code);
84 	 --Bug 10079561 End
85     -------------------------------------------------
86     -- Execute the Argentine Withholding Tax Routine
87     -------------------------------------------------
88     IF (l_country_code = 'AR') THEN
89         Jl_Ar_Ap_Withholding_Pkg.Jl_Ar_Ap_Do_Withholding
90                        (P_Invoice_Id,
91                         P_Awt_Date,
92                         P_Calling_Module,
93                         P_Amount,
94                         P_Payment_Num,
95                         P_Checkrun_Name,
96                         p_checkrun_id,
97                         P_Last_Updated_By,
98                         P_Last_Update_Login,
99                         P_Program_Application_Id,
100                         P_Program_Id,
101                         P_Request_Id,
102                         l_awt_success,
103                         P_Invoice_Payment_Id,
104                         P_Check_Id);
105     -------------------------------------------------
106     -- Execute the Colombian Withholding Tax Routine
107     -------------------------------------------------
108     ELSIF (l_country_code = 'CO') THEN
109            Jl_Co_Ap_Withholding_Pkg.Jl_Co_Ap_Do_Withholding
110                        (P_Invoice_Id,
111                         P_Awt_Date,
112                         P_Calling_Module,
113                         P_Amount,
114                         P_Payment_Num,
115                         P_Last_Updated_By,
116                         P_Last_Update_Login,
117                         P_Program_Application_Id,
118                         P_Program_Id,
119                         P_Request_Id,
120                         l_awt_success);
121 
122     END IF;
123 
124     ----------------------------
125     -- Return AWT Success Value
126     ----------------------------
127     IF (l_awt_success = 'SUCCESS') THEN
131     END IF;
128         RETURN Ap_Extended_Withholding_Pkg.TRUE_VALUE;
129     ELSE
130         RETURN Ap_Extended_Withholding_Pkg.FALSE_VALUE;
132 
133 END JG_DO_EXTENDED_WITHHOLDING;
134 
135 
136 /**************************************************************************
137  *                                                                        *
138  * Name       : Jg_Undo_Extended_Withholding                              *
139  * Purpose    : Regional Extended Routine for the Withholding Tax         *
140  *              Reversion                                                 *
141  *                                                                        *
142  **************************************************************************/
143 FUNCTION JG_UNDO_EXTENDED_WITHHOLDING
144               (P_Parent_Id              IN     Number,
145                P_Calling_Module         IN     Varchar2,
146                P_Awt_Date               IN     Date,
147                P_New_Invoice_Payment_Id IN     Number     Default null,
148                P_Last_Updated_By        IN     Number,
149                P_Last_Update_Login      IN     Number,
150                P_Program_Application_Id IN     Number     Default null,
151                P_Program_Id             IN     Number     Default null,
152                P_Request_Id             IN     Number     Default null,
153                P_Dist_Line_No           IN     Number     Default null,
154                P_New_Invoice_Id         IN     Number     Default null,
155                P_New_Dist_Line_No       IN     Number     Default null)
156                RETURN NUMBER
157 IS
158     l_country_code    Varchar2(10);
159     l_awt_success     Varchar2(2000);
160 
161     l_ou_id          NUMBER;
162 
163 BEGIN
164 
165     l_awt_success     := 'SUCCESS';
166 
167     ------------------------
168     -- Get the Country Code
169     ------------------------
170     --fnd_profile.get('ORG_ID',l_ou_id);
171 
172     l_ou_id  :=  MO_GLOBAL.get_current_org_id;				--bug 8501685
173 
174     l_country_code := jg_zz_shared_pkg.get_country(l_ou_id, NULL);
175 
176     -------------------------------------------------
177     -- Execute the Argentine Withholding Tax Routine
178     -------------------------------------------------
179     IF (l_country_code = 'AR') THEN
180         Jl_Ar_Ap_Withholding_Pkg.Jl_Ar_Ap_Undo_Withholding
181                                    (P_Parent_Id,
182                                     P_Calling_Module,
183                                     P_Awt_Date,
184                                     P_Last_Updated_By,
185                                     P_Last_Update_Login,
186                                     P_Program_Application_Id,
187                                     P_Program_Id,
188                                     P_Request_Id);
189 
190     -------------------------------------------------
191     -- Execute the Colombian Withholding Tax Routine
192     -------------------------------------------------
193     ELSIF (l_country_code = 'CO') THEN
194         null;
195 
196     END IF;
197 
198     ----------------------------
199     -- Return AWT Success Value
200     ----------------------------
201     IF (l_AWT_Success = 'SUCCESS') THEN
202         RETURN Ap_Extended_Withholding_Pkg.TRUE_VALUE;
203     ELSE
204         RETURN Ap_Extended_Withholding_Pkg.FALSE_VALUE;
205     END IF;
206 
207 END JG_UNDO_EXTENDED_WITHHOLDING;
208 
209 
210 
211 
212 /**************************************************************************
213  *                                                                        *
214  * Name       : Jg_Undo_Temp_Ext_Withholding                              *
215  * Purpose    : Regional Extended Routine to Reverse Temporary            *
216  *              Withholding Distributions                                 *
217  *                                                                        *
218  **************************************************************************/
219 FUNCTION JG_UNDO_TEMP_EXT_WITHHOLDING
220               (P_Invoice_Id             IN     Number,
221                P_Vendor_Id              IN     Number     Default null,
222                P_Payment_Num            IN     Number,
223                P_Checkrun_Name          IN     Varchar2,
224                P_Checkrun_ID            IN     Number,
225                P_Undo_Awt_Date          IN     Date,
226                P_Calling_Module         IN     Varchar2,
227                P_Last_Updated_By        IN     Number,
228                P_Last_Update_Login      IN     Number,
229                P_Program_Application_Id IN     Number     Default null,
230                P_Program_Id             IN     Number     Default null,
231                P_Request_Id             IN     Number     Default null)
232                RETURN NUMBER
233 IS
234     l_country_code    Varchar2(10);
235     l_awt_success     Varchar2(2000);
236 
237     l_ou_id           NUMBER;
238 
239 BEGIN
240 
241     l_awt_success     := 'SUCCESS';
242 
243     ------------------------
244     -- Get the Country Code
245     ------------------------
246     --fnd_profile.get('ORG_ID',l_ou_id);
247 
248     l_ou_id  :=  MO_GLOBAL.get_current_org_id;				--bug 8501685
249 
250     l_country_code := jg_zz_shared_pkg.get_country(l_ou_id, NULL);
251 
252     -------------------------------------------------
253     -- Execute the Argentine Withholding Tax Routine
254     -------------------------------------------------
255     IF (l_country_code = 'AR') THEN
256         Jl_Ar_Ap_Withholding_Pkg.Jl_Ar_Ap_Undo_Temp_Withholding
257                                    (P_Invoice_Id,
258                                     P_Payment_Num,
262                                     P_Calling_Module,
259                                     P_Checkrun_Name,
260                                     p_Checkrun_id,
261                                     P_Undo_Awt_Date,
263                                     P_Last_Updated_By,
264                                     P_Last_Update_Login,
265                                     P_Program_Application_Id,
266                                     P_Program_Id,
267                                     P_Request_Id);
268     -------------------------------------------------
269     -- Execute the Colombian Withholding Tax Routine
270     -------------------------------------------------
271     ELSIF (l_country_code = 'CO') THEN
272         null;
273 
274     END IF;
275 
276     ----------------------------
277     -- Return AWT Success Value
278     ----------------------------
279     IF (l_AWT_Success = 'SUCCESS') THEN
280         RETURN Ap_Extended_Withholding_Pkg.TRUE_VALUE;
281     ELSE
282         RETURN Ap_Extended_Withholding_Pkg.FALSE_VALUE;
283     END IF;
284 
285 END JG_UNDO_TEMP_EXT_WITHHOLDING;
286 
287 
288 
289 
290 /**************************************************************************
291  *                                                                        *
292  * Name       : Jg_Ext_Withholding_Default                                *
293  * Purpose    : Regional Extended Routine to Default Withholding Tax      *
294  *              Information                                               *
295  *               -- Bug 4559472 : R12 KI                                  *
296  **************************************************************************/
297 FUNCTION JG_EXT_WITHHOLDING_DEFAULT (P_Invoice_Id     IN   Number,
298                                      P_Inv_Line_Num   IN   Number,
299                                      P_Inv_Dist_Id    IN   ap_invoice_distributions_all.invoice_distribution_id%TYPE,
300                                      P_Calling_Module IN   Varchar2,
301                                      P_Parent_Dist_ID IN   Number)
302                                      RETURN NUMBER
303 IS
304 
305     l_country_code    Varchar2(10);
306 
307     l_ou_id           NUMBER;
308 
309 BEGIN
310     ------------------------
311     -- Get the Country Code
312     ------------------------
313     --fnd_profile.get('ORG_ID',l_ou_id);
314 
315     l_ou_id  :=  MO_GLOBAL.get_current_org_id;				--bug 8501685
316 
317     l_country_code := jg_zz_shared_pkg.get_country(l_ou_id, NULL);
318 
319     ------------------------------------------------
320     -- Execute the Argentine/Colombian Withholding
321     -- Tax Defaulting Routine
322     --
323     -- Payment Schedules Defaulting for Brazil
324     -- Validate DUE_DATE for Business Day Calendar for Brazil
325     -- Carry out Bank Transfer CollDoc Association for Brazil
326     ------------------------------------------------
327     IF (l_country_code = 'AR' OR
328         l_country_code = 'CO') THEN
329 
330         --
331         -- Bug 4559472 : R12 KI
332         --
333         Jl_Zz_Ap_Awt_Default_Pkg.Supp_Wh_Def(P_Invoice_Id,
334                                              P_Inv_Line_Num,
335                                              P_Inv_Dist_Id,
336                                              P_Calling_Module,
337                                              P_Parent_Dist_ID);
338     ELSIF (l_country_code = 'BR') THEN
339         Jl_Br_Ap_Pay_Sched_GDF_PKG.Suppl_Def_Pay_Sched_GDF(P_Invoice_Id);
340         -- Brazilian AP/PO Tax has been obsolete in R12
341         -- bug#4535578- obsolete Brazilian AP/PO tax feature
342         -- Jl_Br_Ap_Create_Tax_PKG.call_match_nomatch_proc(P_Invoice_Id);
343     END IF;
344 
345     ----------------------------
346     -- Return AWT Success Value
347     ----------------------------
348     RETURN Ap_Extended_Withholding_Pkg.TRUE_VALUE;
349 
350 END JG_EXT_WITHHOLDING_DEFAULT;
351 
352 
353 /**************************************************************************
354  *                                                                        *
355  * Name       : Jg_Extended_Match                                         *
356  * Purpose    : Regional Extended Routine for Matching                    *
357  *              Bug 4559478 : R12 KI                                      *
358  **************************************************************************/
359 PROCEDURE JG_EXTENDED_MATCH
360                     (P_Credit_Id	      IN     Number,
361                      P_Invoice_Id             IN     Number	Default null,
362                      P_Inv_Line_Num           IN     Number     Default null,
363                      P_Distribution_id        IN     Number     Default null,
364                      P_Parent_Dist_ID         IN     Number     Default null)
365 
366 IS
367 
368     l_country_code    Varchar2(10);
369 
370     l_ou_id           NUMBER;
371 
372 BEGIN
373     ------------------------
374     -- Get the Country Code
375     ------------------------
376     --fnd_profile.get('ORG_ID',l_ou_id);
377 
378     l_ou_id  :=  MO_GLOBAL.get_current_org_id;				--bug 8501685
379 
380     l_country_code := jg_zz_shared_pkg.get_country(l_ou_id, NULL);
381 
382     -------------------------------------------------
383     -- Execute the Extended Matching Routine
384     -------------------------------------------------
385     IF (l_country_code = 'AR' OR l_country_code = 'CO') THEN
386 
387         --
388         -- Bug 4559478 : R12 KI
389         --
390         Jl_Zz_Ap_Withholding_Pkg.Jl_Zz_Ap_Extended_Match
391                     (P_Credit_Id,
392                      P_Invoice_Id,
396                      );
393                      P_Inv_Line_Num,
394                      P_Distribution_id,
395                      P_Parent_Dist_ID
397     END IF;
398 
399 END JG_EXTENDED_MATCH;
400 
401 
402 /**************************************************************************
403  *                                                                        *
404  * Name       : Jg_Extended_Insert_Dist                                   *
405  * Purpose    : Regional Extended Routine for Insertion                   *
406  *                                                                        *
407  **************************************************************************/
408 PROCEDURE JG_EXTENDED_INSERT_DIST
409                     (P_Invoice_Id	      	IN	Number,
410                      P_Invoice_Distribution_id  IN      Number,    -- Add new Column
411                      P_Distribution_Line_Number	IN      Number,
412                      P_Line_Type		IN	Varchar2,
413                      P_GL_Date			IN	Date,
414                      P_Period_Name		IN	Varchar2,
415                      P_Type_1099		IN	Varchar2,
416                      P_Income_Tax_Region	IN	Varchar2,
417                      P_Amount			IN	Number,
418                      P_Tax_Code_ID              IN      Number,   -- Add new Column
419                      P_Code_Combination_Id	IN	Number,
420                      P_PA_Quantity		IN 	Number,
421                      P_Description		IN	Varchar2,
422                      P_tax_recoverable_flag     IN      Varchar2, -- Add new Column
423                      P_tax_recovery_rate        IN      Number,   -- Add new Column
424                      P_tax_code_override_flag   IN      Varchar2, -- Add new Column
425                      P_tax_recovery_override_flag IN    Varchar2, -- Add new Column
426                      P_po_distribution_id       IN      Number,   -- Add new Column
427                      P_Attribute_Category	IN	Varchar2,
428                      P_Attribute1		IN	Varchar2,
429                      P_Attribute2		IN	Varchar2,
430                      P_Attribute3		IN	Varchar2,
431                      P_Attribute4		IN	Varchar2,
432                      P_Attribute5		IN	Varchar2,
433                      P_Attribute6		IN	Varchar2,
434                      P_Attribute7		IN	Varchar2,
435                      P_Attribute8		IN	Varchar2,
436                      P_Attribute9		IN	Varchar2,
437                      P_Attribute10		IN	Varchar2,
438                      P_Attribute11		IN	Varchar2,
439                      P_Attribute12		IN	Varchar2,
440                      P_Attribute13		IN	Varchar2,
441                      P_Attribute14		IN	Varchar2,
442                      P_Attribute15		IN	Varchar2,
443  		     P_Calling_Sequence		IN	Varchar2
444  		     )
445 IS
446     l_country_code    Varchar2(10);
447 
448     l_ou_id           NUMBER;
449 
450 BEGIN
451     -------------------------------------------
452     -- Stubbed out
453     -------------------------------------------
454     NULL;
455     ------------------------
456     -- Get the Country Code
457     ------------------------
458     -- fnd_profile.get('ORG_ID',l_ou_id);
459     -- l_country_code := jg_zz_shared_pkg.get_country(l_ou_id, NULL);
460 
461     -------------------------------------------------
462     -- Execute the Extended Insertion Routine
463     -------------------------------------------------
464     /* Bug 4535582
465     IF (l_country_code = 'AR' OR l_country_code = 'CO') THEN
466         Jl_Zz_Ap_Withholding_Pkg.Jl_Zz_Ap_Ext_Insert_Dist
467                     (P_Invoice_Id,
468                      P_Invoice_Distribution_id,    -- Add new column
469                      P_Distribution_Line_Number,
470                      P_Line_Type,
471                      P_GL_Date,
472                      P_Period_Name,
473                      P_Type_1099,
474                      P_Income_Tax_Region,
475                      P_Amount,
476                      P_Tax_Code_ID,                -- Add new column
477                      P_Code_Combination_Id,
478                      P_PA_Quantity,
479                      P_Description,
480                      P_tax_recoverable_flag,       -- Add new Column
481                      P_tax_recovery_rate,          -- Add new Column
482                      P_tax_code_override_flag,     -- Add new Column
483                      P_tax_recovery_override_flag, -- Add new Column
484                      P_po_distribution_id,         -- Add new Column
485                      P_Attribute_Category,
486                      P_Attribute1,
487                      P_Attribute2,
488                      P_Attribute3,
489                      P_Attribute4,
490                      P_Attribute5,
491                      P_Attribute6,
492                      P_Attribute7,
493                      P_Attribute8,
494                      P_Attribute9,
495                      P_Attribute10,
496                      P_Attribute11,
497                      P_Attribute12,
498                      P_Attribute13,
499                      P_Attribute14,
500                      P_Attribute15,
501  		     P_Calling_Sequence
502  		     );
503     END IF;
504     */
505 END JG_EXTENDED_INSERT_DIST;
506 
507 /**************************************************************************
508  *                                                                        *
509  * Name       : Jg_Withholding_Prepay                                     *
510  * Purpose    : Regional Extended Routine for Insertion on Prepay line    *
511  *                                                                        *
512  **************************************************************************/
513 
514 FUNCTION Jg_Ext_Withholding_Prepay
515                (P_prepay_dist_id      IN Number,
516           	P_invoice_id          IN Number,
517                 -- Bug 4559474 : R12 KI
518                 P_inv_dist_id         IN Number,
519           	P_user_id             IN Number,
520           	P_last_update_login   IN Number,
521                 P_calling_sequence    IN Varchar2
522                 )
523 RETURN NUMBER
524 IS
525 
526 l_country_code            VARCHAR2(10);
527 l_calling_sequence        VARCHAR2(2000);
528 
529 l_ou_id                   NUMBER;
530 
531 BEGIN
532     ------------------------
533      --  Return the value in P_calling_sequece.
534      -----------------------
535      l_calling_sequence := p_calling_sequence||'Jg_Ext_Withholding_Prepay';
536     ------------------------
537     -- Get the Country Code
538     ------------------------
539     --fnd_profile.get('ORG_ID',l_ou_id);
540 
541     l_ou_id  :=  MO_GLOBAL.get_current_org_id;				--bug 8501685
542 
543     l_country_code := jg_zz_shared_pkg.get_country(l_ou_id, NULL);
544 
545     ------------------------------------------------
546     -- Execute the Argentine/Colombian Withholding
547     -- Tax Defaulting Prepayment Routine
548     ------------------------------------------------
549     IF (l_country_code = 'AR' OR
550         l_country_code = 'CO') THEN
551 
552         --
553         -- Bug 4559474 : R12 KI
554         --
555         Jl_Zz_Ap_Awt_Default_PKG.Carry_Withholdings_Prepay(
556                                                            P_prepay_dist_id,
557                                                            P_Invoice_Id,
558                                                            -- Bug 4559474
559                                                            P_inv_dist_id,
560                                                            P_user_id,
561                                                            P_last_update_login,
562                                                            P_calling_sequence
563                                                            );
564     END IF;
565 
566     ----------------------------
567     -- Return AWT Success Value
568     ----------------------------
569     RETURN Ap_Extended_Withholding_Pkg.TRUE_VALUE;
570 
571 END JG_EXT_WITHHOLDING_PREPAY;
572 
573 END JG_EXTENDED_WITHHOLDING_PKG;