1 PACKAGE BODY POA_GA_UTIL_PKG as
2 /* $Header: poagautilb.pls 115.2 2004/01/24 00:00:08 mangupta noship $ */
3
4 FUNCTION is_enabled(p_po_header_id IN PO_HEADERS_ALL.po_header_id%TYPE,
5 p_org_id IN PO_HEADERS_ALL.org_id%TYPE)
6 RETURN VARCHAR2 IS
7
8 l_enabled_flag PO_GA_ORG_ASSIGNMENTS.enabled_flag%TYPE;
9
10 BEGIN
11
12 SELECT pgoa.enabled_flag
13 INTO l_enabled_flag
14 FROM po_ga_org_assignments pgoa
15 WHERE pgoa.po_header_id = p_po_header_id -- input global agreement id
16 AND pgoa.organization_id = p_org_id; -- input org id
17
18 return l_enabled_flag;
19
20 EXCEPTION
21
22 WHEN OTHERS THEN
23 return 'N';
24
25 END is_enabled;
26
27 FUNCTION is_global_agreement(p_po_header_id IN PO_HEADERS_ALL.po_header_id%TYPE)
28 RETURN VARCHAR2 IS
29
30 l_global_agreement_flag PO_HEADERS_ALL.global_agreement_flag%TYPE;
31
32 BEGIN
33
34 SELECT global_agreement_flag
35 INTO l_global_agreement_flag
36 FROM po_headers_all
37 WHERE po_header_id = p_po_header_id;
38
39 return nvl(l_global_agreement_flag, 'N');
40
41 EXCEPTION
42
43 WHEN OTHERS THEN
44 return 'N';
45
46 END is_global_agreement;
47
48 -- from currency code is the functional currency of the global agreement
49 -- to currency code is the functional currency of the standard PO
50 -- We convert from the functional currency of the GA to the DBI
51 -- primary global currency using DBI primary rate type and Std PO rate date
52 -- and then convert from DBI primary global currency to the functional
53 -- currency of the std PO using DBI primary rate type and Std PO rate date
54
55 FUNCTION get_ga_conversion_rate(p_from_currency_code IN VARCHAR2, p_to_currency_code IN VARCHAR2, p_rate_date IN DATE)
56
57 RETURN NUMBER IS
58
59 l_global_currency_code VARCHAR2(30);
60 l_global_rate_type VARCHAR2(15);
61 rate1 NUMBER;
62 rate2 NUMBER;
63
64 begin
65
66 -- convert GA functional currency to DBI global currency
67 rate1 := fii_currency.get_global_rate_primary(p_from_currency_code, p_rate_date);
68
69 if(rate1 is null or rate1 < 0) then return null; end if;
70
71 -- now convert DBI global currency to std PO functional currency
72 l_global_currency_code := bis_common_parameters.get_currency_code;
73 l_global_rate_type := bis_common_parameters.get_rate_type;
74
75 rate2 := fii_currency.get_rate(l_global_currency_code, p_to_currency_code, p_rate_date, l_global_rate_type);
76
77 if(rate2 is null or rate2 < 0) then return null; end if;
78
79 RETURN (rate1 * rate2);
80
81 EXCEPTION
82 WHEN OTHERS THEN
83 return null;
84
85 END get_ga_conversion_rate;
86
87 END POA_GA_UTIL_PKG;