[Home] [Help]
PACKAGE BODY: APPS.PA_MULTI_CURRENCY
Source
1 PACKAGE BODY pa_multi_currency AS
2 --$Header: PAXTMCTB.pls 120.2.12000000.2 2007/06/26 11:39:32 sugupta ship $
3
4 P_DEBUG_MODE BOOLEAN := pa_cc_utils.g_debug_mode;
5 ------------------------------------------------------------------------------
6 -- Function pa_multi_currency.check_rate_date_code.
7 -- Comments for the function are at the package specification level
8 ------------------------------------------------------------------------------
9 FUNCTION check_rate_date_code
10 RETURN varchar2 IS
11
12 l_rate_date_code VARCHAR2(1) := 'E';
13
14 BEGIN
15
16 SELECT default_rate_date_code
17 INTO l_rate_date_code
18 FROM pa_implementations ;
19
20 RETURN l_rate_date_code ;
21 END check_rate_date_code ;
22
23 ------------------------------------------------------------------------------
24 -- Function pa_multi_currency.get_rate_type.
25 -- Comments for the function are at the package specification level
26 ------------------------------------------------------------------------------
27 FUNCTION get_rate_type
28 RETURN VARCHAR2 IS
29
30 l_rate_type VARCHAR2(30);
31
32 BEGIN
33
34 SELECT default_rate_type
35 INTO l_rate_type
36 FROM pa_implementations ;
37
38 RETURN l_rate_type ;
39
40 END get_rate_type ;
41
42 ------------------------------------------------------------------------------
43 -- Function pa_multi_currency.get_acct_currency_code.
44 -- Comments for the function are at the package specification level
45 ------------------------------------------------------------------------------
46 FUNCTION get_acct_currency_code
47 RETURN varchar2 IS
48
49 l_acct_currency_code VARCHAR2(15);
50
51 BEGIN
52
53 l_acct_currency_code := PA_CURRENCY.get_currency_code;
54
55 RETURN l_acct_currency_code ;
56
57 END get_acct_currency_code ;
58
59 ------------------------------------------------------------------------------
60 -- Function pa_multi_currency.is_user_rate_type_allowed.
61 -- Comments for the function are at the package specification level
62 ------------------------------------------------------------------------------
63
64 FUNCTION is_user_rate_type_allowed (P_from_currency VARCHAR2,
65 P_to_currency VARCHAR2,
66 P_conversion_date DATE )
67 RETURN VARCHAR2 IS
68
69 l_fixed_rate VARCHAR2(1) ;
70 l_allow_user_rate_type VARCHAR2(1) ;
71 l_mesg VARCHAR2(30) ;
72 invalid_currency EXCEPTION ;
73
74 BEGIN
75 /* Calling GL API which returns 'Y'if a fixed rate exists */
76
77 l_fixed_rate := GL_CURRENCY_API.is_fixed_rate( P_from_currency ,
78 P_to_currency ,
79 P_conversion_date ) ;
80
81 /* The above API raises an INVALID_CURRENCY which is not handled here.
82 It is passed on to the calling program */
83
84 IF l_fixed_rate = 'Y' THEN
85 l_allow_user_rate_type := 'N';
86
87 ELSE l_allow_user_rate_type := 'Y';
88
89 END IF ;
90
91 RETURN l_allow_user_rate_type ;
92
93 EXCEPTION
94 WHEN others THEN
95 RAISE ;
96
97 END is_user_rate_type_allowed ;
98
99 ------------------------------------------------------------------------------
100 -- Function pa_multi_currency.convert_amount.
101 -- Comments for the function are at the package specification level
102 ------------------------------------------------------------------------------
103 PROCEDURE convert_amount (
104 P_from_currency IN VARCHAR2,
105 P_to_currency IN VARCHAR2,
106 P_conversion_date IN OUT NOCOPY DATE ,
107 P_conversion_type IN OUT NOCOPY VARCHAR2,
108 P_amount IN NUMBER,
109 P_user_validate_flag IN VARCHAR2 ,
110 P_handle_exception_flag IN VARCHAR2 ,
111 P_converted_amount IN OUT NOCOPY NUMBER,
112 P_denominator IN OUT NOCOPY NUMBER,
113 P_numerator IN OUT NOCOPY NUMBER,
114 P_rate IN OUT NOCOPY NUMBER,
115 X_status OUT NOCOPY VARCHAR2) IS
116
117 V_allow_user_rate_type VARCHAR2(1) ;
118 V_converted_amount NUMBER ;
119 V_numerator NUMBER ;
120 V_denominator NUMBER ;
121 V_rate NUMBER ;
122
123 /* Added for Bug2419636 */
124 V_factor NUMBER ;
125 V_amount NUMBER ;
126
127 l_call_closest_flag varchar2(1) := 'F';
128
129
130 BEGIN
131
132 X_status := null ;
133 P_conversion_date := NVL(P_conversion_date, sysdate);
134
135 IF (P_from_currency = P_to_currency) THEN
136
137 P_conversion_date := null;
138 P_conversion_type := null;
139 P_rate := null;
140 P_converted_amount:= P_amount;
141 RETURN;
142
143 END IF;
144
145 /* Added for Bug2419636 as sometimes the reurned amount from the GL_CURRENCY_API.convert_amount_sql call is actually
146 -1 or -2 and it is being treated as an error so the fix involves first we always pass a positive amount to the call
147 and later convert back the changed amount into its proper sign, this allows us to assume that -1 and -2 are always
148 errors and not other wise. */
149
150 IF P_amount < 0 THEN
151 V_factor := -1;
152 ELSE
153 V_factor := 1;
154 END IF;
155
156 IF ( P_conversion_type = 'User') THEN
157 IF( P_user_validate_flag = 'Y') THEN
158
159 V_allow_user_rate_type := is_user_rate_type_allowed (P_from_currency ,
160 P_to_currency ,
161 P_conversion_date) ;
162
163 IF ( V_allow_user_rate_type = 'Y') then
164 /* Bug fix for bug 2753298 Starts Here */
165 IF (P_Rate IS NULL) THEN
166 RAISE pa_multi_currency.no_rate ;
167 END IF;
168 /* Bug fix for bug 2753298 Ends Here Here */
169 P_converted_amount := PA_CURRENCY.round_trans_currency_amt
170 (P_amount * NVL(P_Rate,1),P_to_currency) ;
171 P_denominator := 1 ;
172 P_numerator := NVL(P_rate,1) ;
173 ELSE
174 X_status := 'PA_USR_RATE_NOT_ALLOWED';
175 RETURN ;
176 END IF;
177
178 ELSE P_converted_amount := PA_CURRENCY.round_trans_currency_amt
179 (P_amount * P_Rate, P_to_currency) ;
180 P_denominator := 1 ;
181 P_numerator := P_rate ;
182 END IF;
183
184 ELSE
185 V_amount := p_amount * v_factor; -- Make amount positive Bug 2419636
186 V_converted_amount := GL_CURRENCY_API.convert_amount_sql
187 ( P_from_currency ,
188 P_to_currency ,
189 P_conversion_date ,
190 P_conversion_type ,
191 V_amount ) ;
192 IF ( V_converted_amount = -1 ) THEN
193
194 /* Bug 6058074 code begins */
195
196 IF pa_multi_currency_txn.G_calling_module = 'WORKPLAN' then
197
198 V_converted_amount := GL_CURRENCY_API.convert_closest_amount_sql
199 ( x_from_currency => P_from_currency ,
200 x_to_currency => P_to_currency ,
201 x_conversion_date => P_conversion_date ,
202 x_conversion_type => P_conversion_type ,
203 x_user_rate => 1,
204 x_amount => V_amount ,
205 x_max_roll_days => -1 ) ;
206 l_call_closest_flag := 'T';
207 END IF;
208
209 /* Bug 6058074 code begins */
210 IF ( V_converted_amount = -1 ) THEN
211 RAISE pa_multi_currency.no_rate ;
212 END IF ;
213 ELSIF ( V_converted_amount = -2 ) THEN
214 RAISE pa_multi_currency.invalid_currency ;
215 END IF ;
216 -- P_converted_amount := V_converted_amount ;
217 P_converted_amount := V_converted_amount * v_factor ; -- Changing Converted Amount to Original Sign Bug 2419636
218
219 /* Bug 6058074 begin */
220 If l_call_closest_flag = 'T' then
221
222 V_numerator := GL_CURRENCY_API.get_closest_rate_numerator_sql( P_from_currency,
223 P_to_currency,
224 P_conversion_date,
225 P_conversion_type ,
226 -1);
227 /* Bug 6058074 end */
228
229 else
230 V_numerator := GL_CURRENCY_API.get_rate_numerator_sql( P_from_currency,
231 P_to_currency,
232 P_conversion_date,
233 P_conversion_type );
234 end if;
235
236 P_numerator := V_numerator ;
237
238 If l_call_closest_flag = 'T' then
239
240 /* Bug 6058074 begin */
241 V_denominator := GL_CURRENCY_API.get_closest_rate_denom_sql( P_from_currency,
242 P_to_currency,
243 P_conversion_date,
244 P_conversion_type,
245 -1 );
246 /* Bug 6058074 end */
247
248 else
249 V_denominator := GL_CURRENCY_API.get_rate_denominator_sql( P_from_currency,
250 P_to_currency,
251 P_conversion_date,
252 P_conversion_type );
253 end if;
254
255 P_denominator := V_denominator ;
256 -- Get conversion rate by using the x_numerator and x_denominator
257 IF (( P_numerator > 0 ) AND ( P_denominator > 0 )) THEN
258 P_rate := P_numerator / P_denominator;
259
260 ELSE
261 IF (( P_numerator = -2 ) OR (P_denominator = -2 )) THEN
262 raise pa_multi_currency.invalid_currency;
263
264 ELSE
265 raise pa_multi_currency.no_rate;
266 END IF;
267 END IF;
268
269
270
271 END IF ;
272
273 EXCEPTION
274 WHEN pa_multi_currency.no_rate THEN
275 IF (P_handle_exception_flag = 'Y') THEN
276 X_status := 'PA_NO_EXCH_RATE_EXISTS';
277 ELSE
278 RAISE;
279 END IF;
280 WHEN pa_multi_currency.invalid_currency THEN
281 IF (P_handle_exception_flag = 'Y') THEN
282 X_status := 'PA_CURR_NOT_VALID';
283 ELSE
284 RAISE;
285 END IF;
286 WHEN others THEN
287 RAISE;
288
289 END convert_amount;
290
291 ------------------------------------------------------------------------------
292 -- Function pa_multi_currency.convert_amount_sql.
293 -- Comments for the function are at the package specification level
294 ------------------------------------------------------------------------------
295 --
296 -- Function
297 -- convert_amount_sql
298 --
299 -- Purpose
300 -- Returns the amount converted from the from currency into the
301 -- functional currency of that set of books by calling convert_amount().
302 -- The amount returned is rounded to the precision and minimum account
303 -- unit of the to currency.
304 --
305 FUNCTION convert_amount_sql (
306 P_from_currency VARCHAR2,
307 P_to_currency VARCHAR2,
308 P_conversion_date DATE,
309 P_conversion_type VARCHAR2 ,
310 P_Rate NUMBER,
311 P_amount NUMBER ) RETURN NUMBER IS
312
313 v_converted_amount NUMBER;
314 v_conversion_date Date;
315 v_conversion_type Varchar2(30);
316 v_denominator NUMBER;
317 v_numerator NUMBER;
318 v_rate NUMBER;
319 v_status Varchar2(100);
320
321 BEGIN
322
323 v_conversion_date := P_conversion_date;
324 v_conversion_type := P_conversion_type;
325 v_rate := P_Rate;
326 convert_amount ( P_from_currency => P_from_currency,
327 P_to_currency => P_to_currency,
328 P_conversion_date => v_conversion_date,
329 P_conversion_type => v_conversion_type,
330 P_amount => P_amount,
331 P_user_validate_flag => 'N',
332 P_handle_exception_flag => 'N',
333 P_converted_amount => v_converted_amount,
334 P_denominator => v_denominator,
335 P_numerator => v_numerator,
336 P_rate => v_rate,
337 X_status => v_status);
338 return( v_converted_amount );
339
340 EXCEPTION
341
342 WHEN pa_multi_currency.NO_RATE THEN
343 v_converted_amount := -1;
344 return( v_converted_amount );
345
346 WHEN pa_multi_currency.INVALID_CURRENCY THEN
347 v_converted_amount := -2;
348 return( v_converted_amount );
349
350 END convert_amount_sql;
351
352
353 ------------------------------------------------------------------------------
354 -- Function pa_multi_currency.convert_closest_amount.
355 -- Comments for the function are at the package specification level
356 ------------------------------------------------------------------------------
357
358 PROCEDURE convert_closest_amount
359 ( P_from_currency IN VARCHAR2,
360 P_to_currency IN VARCHAR2,
361 P_conversion_date IN OUT NOCOPY DATE ,
362 P_conversion_type IN OUT NOCOPY VARCHAR2,
363 P_amount IN NUMBER,
364 P_user_validate_flag IN VARCHAR2 ,
365 P_handle_exception_flag IN VARCHAR2,
366 P_maxroll_days IN NUMBER ,
367 P_converted_amount IN OUT NOCOPY NUMBER,
368 P_denominator IN OUT NOCOPY NUMBER,
369 P_numerator IN OUT NOCOPY NUMBER,
370 P_rate IN OUT NOCOPY NUMBER,
371 X_status OUT NOCOPY VARCHAR2) IS
372
373 V_allow_user_rate_type VARCHAR2(1) ;
374 V_converted_amount NUMBER ;
375
376 BEGIN
377 pa_cc_utils.set_curr_function('convert_closest_amount');
378 IF P_DEBUG_MODE THEN
379 pa_cc_utils.log_message('convert_closest_amount: ' || 'Start ');
380 END IF;
381
382 X_status := null ;
383 P_conversion_date := NVL(P_conversion_date, sysdate);
384
385 IF (P_from_currency = P_to_currency) THEN
386 P_conversion_date := null;
387 P_conversion_type := null;
388 P_rate := null;
389 P_converted_amount:= P_amount;
390 pa_cc_utils.reset_curr_function ;
391 RETURN;
392 END IF;
393
394 IF ( P_conversion_type = 'User') THEN
395 IF( P_user_validate_flag = 'Y') THEN
396 IF P_DEBUG_MODE THEN
397 pa_cc_utils.log_message('convert_closest_amount: ' || 'Before calling is_user_rate_type_allowed');
398 END IF;
399 V_allow_user_rate_type := is_user_rate_type_allowed (P_from_currency ,
400 P_to_currency ,
401 P_conversion_date) ;
402
403
404 IF ( V_allow_user_rate_type = 'Y') then
405 P_converted_amount := PA_CURRENCY.round_trans_currency_amt
406 (P_amount * NVL(P_Rate,1),P_to_currency) ;
407 P_denominator := 1 ;
408 P_numerator := NVL(P_rate,1) ;
409 ELSE
410 X_status := 'PA_USR_RATE_NOT_ALLOWED';
411 pa_cc_utils.reset_curr_function ;
412 RETURN ;
413 END IF;
414
415 ELSE P_converted_amount := PA_CURRENCY.round_trans_currency_amt
416 (P_amount * P_Rate, P_to_currency) ;
417 P_denominator := 1 ;
418 P_numerator := P_rate ;
419 END IF;
420
421 ELSE
422 IF P_DEBUG_MODE THEN
423 pa_cc_utils.log_message('Before Calling GL_CURRENCY_API.convert_closest_amount');
424 END IF;
425 GL_CURRENCY_API.convert_closest_amount
426 ( P_from_currency ,
427 P_to_currency ,
428 P_conversion_date ,
429 P_conversion_type ,
430 P_rate ,
431 P_amount ,
432 P_maxroll_days ,
433 P_converted_amount ,
434 P_denominator ,
435 P_numerator ,
436 P_rate ) ;
437 IF P_DEBUG_MODE THEN
438 pa_cc_utils.log_message('After Calling GL_CURRENCY_API.convert_closest_amount');
439 END IF;
440 P_converted_amount := PA_CURRENCY.round_trans_currency_amt
441 ( P_converted_amount, P_to_currency);
442 END IF ;
443 IF P_DEBUG_MODE THEN
444 pa_cc_utils.log_message('convert_closest_amount: ' || 'End ');
445 END IF;
446 pa_cc_utils.reset_curr_function ;
447
448 EXCEPTION
449
450 WHEN gl_currency_api.no_rate THEN
451 IF (P_handle_exception_flag = 'Y') THEN
452 X_status := 'PA_NO_EXCH_RATE_EXISTS';
453 ELSE
454 IF P_DEBUG_MODE THEN
455 pa_cc_utils.log_message('convert_closest_amount: ' || pa_debug.G_err_stack);
456 pa_cc_utils.log_message('convert_closest_amount: ' || SQLERRM);
457 END IF;
458 RAISE;
459 END IF;
460 WHEN gl_currency_api.invalid_currency THEN
461 IF (P_handle_exception_flag = 'Y') THEN
462 X_status := 'PA_CURR_NOT_VALID';
463 ELSE
464 IF P_DEBUG_MODE THEN
465 pa_cc_utils.log_message('convert_closest_amount: ' || pa_debug.G_err_stack);
466 pa_cc_utils.log_message('convert_closest_amount: ' || SQLERRM);
467 END IF;
468 RAISE;
469 END IF;
470 WHEN others THEN
471 IF P_DEBUG_MODE THEN
472 pa_cc_utils.log_message('convert_closest_amount: ' || pa_debug.G_err_stack);
473 pa_cc_utils.log_message('convert_closest_amount: ' || SQLERRM);
474 END IF;
475 RAISE;
476
477 END convert_closest_amount;
478
479
480 ------------------------------------------------------------------------------
481 -- Procedure pa_multi_currency.format_amount.
482 -- Comments for the Procedure are at the package specification level
483 ------------------------------------------------------------------------------
484 PROCEDURE format_amount (P_currency IN VARCHAR2,
485 P_amount IN NUMBER,
486 P_field_length IN NUMBER,
487 P_formatted_amount OUT NOCOPY VARCHAR2 ) IS
488
489 l_format_mask VARCHAR2(1000) DEFAULT NULL;
490 l_curr_code VARCHAR2(15);
491 num_rows NUMBER ;
492
493 BEGIN
494
495 pa_cc_utils.set_curr_function('format_amount');
496 IF P_DEBUG_MODE THEN
497 pa_cc_utils.log_message('format_amount: ' || 'Start ');
498 END IF;
499
500 num_rows := FormatMaskTab.count ;
501 -- This gets the Number of Rows in the PL/SQL table.
502
503 FOR i in 1..num_rows LOOP
504 IF P_DEBUG_MODE THEN
505 pa_cc_utils.log_message('format_amount: ' || 'Start of Loop');
506 END IF;
507 IF ( P_currency IS NOT NULL
508 AND FormatMaskTab(i).currency_code = P_currency) THEN
509 IF P_DEBUG_MODE THEN
510 pa_cc_utils.log_message('format_amount: ' || 'Before retrieving from PLSQL Table');
511 END IF;
512
513 l_format_mask := FormatMaskTab(i).format_mask ;
514 IF P_DEBUG_MODE THEN
515 pa_cc_utils.log_message('format_amount: ' || 'Before exit after getting format mask');
516 END IF;
517
518 EXIT ;
519 END IF ;
520 IF P_DEBUG_MODE THEN
521 pa_cc_utils.log_message('format_amount: ' || 'End of Loop');
522 END IF;
523
524 END LOOP ;
525
526 -- We first check if the table has the currency code and we fetch the
527 -- corresponding format mask. This is done by looping thru the table
528 -- If the required currency code is not there in the table, we call the
529 -- FND API get_format_mask to get the format_mask. This format_mask and
530 -- corresponding currency code is then stored in the table.
531
532 IF ( l_format_mask is NULL
533 AND P_currency IS NOT NULL )THEN
534 IF P_DEBUG_MODE THEN
535 pa_cc_utils.log_message('format_amount: ' || 'Before calling FND_CURRENCY.get_format_mask');
536 END IF;
537
538 l_format_mask := FND_CURRENCY.get_format_mask (P_currency,
539 P_field_length ) ;
540 FormatMaskTab(num_rows + 1).currency_code := P_currency ;
541 FormatMaskTab(num_rows + 1).format_mask := l_format_mask ;
542 END IF;
543 P_formatted_amount := TO_CHAR(P_amount, l_format_mask) ;
544 IF P_DEBUG_MODE THEN
545 pa_cc_utils.log_message('format_amount: ' || 'End ');
546 END IF;
547 pa_cc_utils.reset_curr_function ;
548
549 -- This applies the format mask to the amount to get the formatted amount.
550 EXCEPTION
551 WHEN OTHERS THEN
552 IF P_DEBUG_MODE THEN
553 pa_cc_utils.log_message('format_amount: ' || pa_debug.G_err_stack);
554 pa_cc_utils.log_message('format_amount: ' || SQLERRM);
555 END IF;
556 RAISE ;
557 END format_amount ;
558
559 ------------------------------------------------------------------------------
560 -- Function pa_multi_currency.validate_rate_type.
561 -- Comments for the function are at the package specification level
562 ------------------------------------------------------------------------------
563 FUNCTION validate_rate_type ( P_rate_type VARCHAR2 )
564 RETURN varchar2 IS
565
566 CURSOR C1 IS
567 SELECT 'X'
568 FROM dual
569 WHERE EXISTS(
570 SELECT 'X'
571 FROM pa_conversion_types_v
572 WHERE conversion_type = P_rate_type) ;
573
574 l_Rate_type C1%ROWTYPE;
575
576 BEGIN
577 pa_cc_utils.set_curr_function('validate_rate_type');
578 IF P_DEBUG_MODE THEN
579 pa_cc_utils.log_message('validate_rate_type: ' || 'Start ');
580 END IF;
581
582 OPEN C1 ;
583 IF P_DEBUG_MODE THEN
584 pa_cc_utils.log_message('validate_rate_type: ' || 'After Open Cursor');
585 END IF;
586 FETCH C1 INTO l_Rate_type ;
587 IF P_DEBUG_MODE THEN
588 pa_cc_utils.log_message('validate_rate_type: ' || 'After fetch Cursor');
589 END IF;
590 IF C1%NOTFOUND THEN
591 CLOSE C1;
592 pa_cc_utils.reset_curr_function ;
593 RETURN 'N';
594 ELSE
595 CLOSE C1;
596 pa_cc_utils.reset_curr_function ;
597 RETURN 'Y';
598 END IF ;
599 IF P_DEBUG_MODE THEN
600 pa_cc_utils.log_message('validate_rate_type: ' || 'End ');
601 END IF;
602 pa_cc_utils.reset_curr_function ;
603
604 EXCEPTION
605 WHEN others THEN
606 IF P_DEBUG_MODE THEN
607 pa_cc_utils.log_message('validate_rate_type: ' || pa_debug.G_err_stack);
608 pa_cc_utils.log_message('validate_rate_type: ' || SQLERRM);
609 END IF;
610 RAISE ;
611 END validate_rate_type ;
612
613 ------------------------------------------------------------------------------
614 -- Function pa_multi_currency.validate_currency_code.
615 -- Comments for the function are at the package specification level
616 ------------------------------------------------------------------------------
617 FUNCTION validate_currency_code ( P_Currency_code VARCHAR2,
618 P_EI_date DATE )
619 RETURN varchar2 IS
620
621 --
622 -- Bug 4352158
623 -- Changed the following cursor to refer table FND_CURRENCIES
624 -- instead of fnd_currencies_vl.
625 --
626 CURSOR C1 IS
627 SELECT 'X'
628 FROM dual
629 WHERE EXISTS(
630 SELECT 'X'
631 FROM FND_CURRENCIES
632 WHERE currency_code = P_Currency_code
633 AND enabled_flag = 'Y'
634 AND P_EI_date
635 BETWEEN NVL(start_date_active, P_EI_date)
636 AND NVL(end_date_active , P_EI_date)) ;
637
638 l_currency_code C1%ROWTYPE;
639
640 BEGIN
641 pa_cc_utils.set_curr_function('validate_currency_code');
642 IF P_DEBUG_MODE THEN
643 pa_cc_utils.log_message('validate_currency_code: ' || 'Start ');
644 END IF;
645
646 If (G_PrevCurr = P_Currency_code and trunc(G_PrevEiDate) = trunc(P_EI_date)) Then
647
648 --Bug 2749049
649 pa_cc_utils.reset_curr_function ;
650 RETURN G_CurrValid;
651
652 Else
653
654 OPEN C1 ;
655 IF P_DEBUG_MODE THEN
656 pa_cc_utils.log_message('validate_currency_code: ' || 'After Open Cursor');
657 END IF;
658 FETCH C1 INTO l_currency_code ;
659 IF P_DEBUG_MODE THEN
660 pa_cc_utils.log_message('validate_currency_code: ' || 'After fetch Cursor');
661 END IF;
662 IF C1%NOTFOUND THEN
663 CLOSE C1;
664 IF P_DEBUG_MODE THEN
665 pa_cc_utils.log_message('validate_currency_code: ' || 'After close Cursor when currency is not valid');
666 END IF;
667 pa_cc_utils.reset_curr_function ;
668 G_CurrValid := 'N';
669 G_PrevCurr := P_Currency_code;
670 G_PrevEiDate := P_EI_date;
671 RETURN 'N';
672 ELSE
673 CLOSE C1;
674 IF P_DEBUG_MODE THEN
675 pa_cc_utils.log_message('validate_currency_code: ' || 'After close Cursor when currency is valid');
676 END IF;
677 pa_cc_utils.reset_curr_function ;
678 G_CurrValid := 'Y';
679 G_PrevCurr := P_Currency_code;
680 G_PrevEiDate := P_EI_date;
681 RETURN 'Y';
682 END IF ;
683
684 End If;
685
686 IF P_DEBUG_MODE THEN
687 pa_cc_utils.log_message('validate_currency_code: ' || 'End ');
688 END IF;
689 pa_cc_utils.reset_curr_function ;
690
691 EXCEPTION
692 WHEN others THEN
693 IF P_DEBUG_MODE THEN
694 pa_cc_utils.log_message('validate_currency_code: ' || pa_debug.G_err_stack);
695 pa_cc_utils.log_message('validate_currency_code: ' || SQLERRM);
696 END IF;
697 --Bug 2749049
698 pa_cc_utils.reset_curr_function ;
699 RAISE ;
700 END validate_currency_code ;
701
702
703 --PA-K Performance Improvement Changes
704 --Caching values.
705 FUNCTION get_conversion_type ( P_user_rate_type VARCHAR2 )
706 RETURN varchar2 IS
707
708 CURSOR C1 IS
709 SELECT conversion_type
710 FROM pa_conversion_types_v
711 WHERE user_conversion_type = P_user_rate_type;
712
713 l_Rate_type pa_conversion_types_v.conversion_type%TYPE;
714
715 BEGIN
716 pa_cc_utils.set_curr_function('get_conversion_type');
717 IF P_DEBUG_MODE THEN
718 pa_cc_utils.log_message('get_conversion_type: ' || 'Start ');
719 END IF;
720
721 If (G_PrevUserRateType = P_user_rate_type) Then
722
723 pa_cc_utils.reset_curr_function ; /* Added for Bug 3161853 */
724 RETURN G_PrevRateType;
725
726 Else
727
728 OPEN C1 ;
729 IF P_DEBUG_MODE THEN
730 pa_cc_utils.log_message('get_conversion_type: ' || 'After Opening Cursor');
731 END IF;
732 FETCH C1 INTO l_Rate_type ;
733 IF P_DEBUG_MODE THEN
734 pa_cc_utils.log_message('get_conversion_type: ' || 'After Fetching Cursor');
735 END IF;
736
737 G_PrevRateType := l_Rate_type;
738 G_PrevUserRateType := P_user_rate_type;
739
740 CLOSE C1;
741 IF P_DEBUG_MODE THEN
742 pa_cc_utils.log_message('get_conversion_type: ' || 'After closing Cursor');
743 END IF;
744 pa_cc_utils.reset_curr_function ;
745 RETURN l_rate_type;
746
747 End If;
748
749 IF P_DEBUG_MODE THEN
750 pa_cc_utils.log_message('get_conversion_type: ' || 'End ');
751 END IF;
752 pa_cc_utils.reset_curr_function ;
753
754 EXCEPTION
755 WHEN others THEN
756 IF P_DEBUG_MODE THEN
757 pa_cc_utils.log_message('get_conversion_type: ' || pa_debug.G_err_stack);
758 pa_cc_utils.log_message('get_conversion_type: ' || SQLERRM);
759 END IF;
760 pa_cc_utils.reset_curr_function ;
761 RETURN NULL;
762 END get_conversion_type ;
763
764
765 ------------------------------------------------------------------------------
766 -- procedure to initialize global variables.
767 ------------------------------------------------------------------------------
768 PROCEDURE init IS
769
770 BEGIN
771
772 pa_cc_utils.set_curr_function('Init');
773 pa_cc_utils.log_message('Start ');
774
775 G_accounting_currency_code := get_acct_currency_code ;
776
777 G_rate_date_code := check_rate_date_code ;
778
779 G_rate_type := get_rate_type ;
780 pa_cc_utils.log_message('End ');
781 pa_cc_utils.reset_curr_function ;
782
783 END init ;
784
785 ------------------------------------------------------------------------------
786 -- Function to get User_Conversion_Type value
787 ------------------------------------------------------------------------------
788 FUNCTION Get_User_Conversion_Type ( P_Conversion_Type VARCHAR2 )
789 RETURN VARCHAR2
790 IS
791
792 X_User_Conversion_Type VARCHAR2(200);
793
794 BEGIN
795
796 IF P_Conversion_Type IS NOT NULL
797 THEN
798 GL_DAILY_CONV_TYPES_PKG.select_columns(P_Conversion_Type, X_User_Conversion_Type);
799
800 RETURN X_User_Conversion_Type ;
801 ELSE
802 RETURN NULL;
803 END IF;
804
805 END Get_User_Conversion_Type ;
806
807 END pa_multi_currency ;