DBA Data[Home] [Help]

PACKAGE BODY: APPS.OPI_DBI_CURRENCY_PKG

Source


1 PACKAGE BODY OPI_DBI_CURRENCY_PKG as
2 /* $Header: OPICURRB.pls 115.2 2003/01/10 00:07:47 csheu noship $ */
3 
4 g_global_currency_code	varchar2(3);
5 g_ou_is_cached		BOOLEAN := FALSE;
6 g_w_is_cached		BOOLEAN := FALSE;
7 
8 g_rate_date DATE := to_date('01/01/0039', 'DD/MM/YYYY');
9 g_currency_rate  NUMBER;
10 g_rate_type  VARCHAR2(150) := '**YYYYYYY';
11 g_currency_code VARCHAR2(150) := '**YYYYYYY';
12 g_rate  NUMBER := -99999;
13 
14 g_operating_unit varchar2(10);
15 g_functional_currency_code varchar2(3);
16 g_common_functional_currency varchar2(3);
17 g_sec_profile_id varchar2(10);
18 
19 -- -------------------------------
20 -- get_global_currency
21 -- -------------------------------
22 FUNCTION get_global_currency RETURN VARCHAR2 IS
23 
24 BEGIN
25 
26  return bis_common_parameters.get_currency_code;
27 
28 END get_global_currency;
29 
30 -- -------
31 -- get_ou
32 -- -------
33 
34 FUNCTION get_ou(p_selected_org IN varchar2) RETURN NUMBER IS
35 
36 l_ou	NUMBER;
37 
38 BEGIN
39 
40     select DECODE(FPG.MULTI_ORG_FLAG, 'Y', TO_NUMBER(HOI2.ORG_INFORMATION3),
41      TO_NUMBER(NULL))
42     into l_ou
43     from HR_ORGANIZATION_INFORMATION HOI2,
44 	FND_PRODUCT_GROUPS FPG
45     where (HOI2.ORG_INFORMATION_CONTEXT || '') ='Accounting Information'
46     and organization_id = p_selected_org;
47 
48     return l_ou;
49 
50   EXCEPTION
51     when others then
52 	return (-1);
53 
54 END get_ou;
55 
56 -- ---------------------
57 -- get_display_currency
58 -- ----------------------
59 
60 FUNCTION get_display_currency( p_currency_code	IN varchar2,
61 			       p_selected_org  	IN varchar2,
62                                p_org_type	IN varchar2) return varchar2
63  IS
64 
65  l_f_currency_code	varchar2(15) := null;
66  l_return_value		varchar2(1)  := '0';
67  l_ou			number;
68  l_failure		exception;
69 
70 
71  BEGIN
72 
73     -- selected currency is the same as the global currency
74 
75    if(upper(p_org_type) = 'O') THEN -- for operating unit page parameter
76 
77     IF NOT g_ou_is_cached THEN
78         g_global_currency_code := bis_common_parameters.get_currency_code;
79         g_ou_is_cached := TRUE;
80 
81         IF (g_global_currency_code is null) THEN
82           RAISE l_failure;
83         END IF;
84 
85     end IF;
86 
87     if(p_currency_code = 'FII_GLOBAL1') then
88      	return '1';
89 
90     else -- Currency is not the global currency
91 
92      if(p_selected_org <> 'ALL') then
93 	select currency_code
94 	  into l_f_currency_code
95 	from financials_system_params_all fsp,
96 	     gl_sets_of_books gsob
97 	where fsp.org_id = p_selected_org
98 	  and fsp.set_of_books_id = gsob.set_of_books_id;
99 
100      	if(p_currency_code = l_f_currency_code) then
101 		if(l_f_currency_code = g_global_currency_code) then return '0';
102 		else return '1';
103 		end if;
104         else
105             return '0';
106         end if;
107 
108      else -- if org ='ALL' returns '0' for non-global currency
109       return '0';
110      end if;
111     end if;
112 
113   elsif (upper(p_org_type) = 'W') THEN   -- for inventory org page parameter
114 
115     IF NOT g_w_is_cached then
116         g_global_currency_code := bis_common_parameters.get_currency_code;
117         g_w_is_cached := TRUE;
118 
119         IF (g_global_currency_code is null) THEN
120           RAISE l_failure;
121         END IF;
122     END IF;
123 
124     if(p_currency_code = 'FII_GLOBAL1') then
125 	  return '1';
126 
127     else  -- Currency is not the global currency
128 
129      if(p_selected_org <> 'ALL') then
130 
131         l_ou := get_ou(p_selected_org);
132 
133 	IF(l_ou = -1) THEN
134 	  RAISE l_failure;
135 	END IF;
136 
137 	select currency_code
138 	  into l_f_currency_code
139 	from financials_system_params_all fsp,
140 	     gl_sets_of_books gsob
141 	where fsp.org_id = l_ou
142 	  and fsp.set_of_books_id = gsob.set_of_books_id;
143 
144        	if(p_currency_code = l_f_currency_code) then
145 		if(l_f_currency_code = g_global_currency_code) then return '0';
146 		else return '1';
147 		end if;
148        	else
149 	  return '0';
150        	end if;
151 
152      else -- p_selected_org = 'ALL' and functional currency
153 	  return '0';
154 
155      end if; -- end if p_selected_org<>'ALL'
156     end if;  -- end if p_currency_code = 'FII_GLOBAL1'
157 
158   end if;
159 
160   EXCEPTION
161     when l_failure then
162 	return '0';
163 
164     when others then
165 	return '0';
166 
167 
168   END get_display_currency;
169 
170 
171 END OPI_DBI_CURRENCY_PKG;