DBA Data[Home] [Help]

PACKAGE BODY: APPS.GL_EURO_USER_RATE_API

Source


1 PACKAGE BODY gl_euro_user_rate_api AS
2 /* $Header: glusteub.pls 120.3 2005/05/05 01:44:44 kvora ship $ */
3 
4 
5   ---
6   --- PUBLIC FUNCTIONS
7   ---
8 
9   --
10   -- Function
11   --   allow_direct_entry
12   --
13   -- Purpose
14   -- 	Returns 'Y' if the customer is allowed to directly enter EMU -> OTHER
15   --                and OTHER -> EMU rates
16   --            'N' otherwise.
17   --
18   -- History
19   --   20-MAY-99  D J Ogg 	Created
20   --
21   -- Arguments
22   --   * None *
23   FUNCTION allow_direct_entry  RETURN VARCHAR2 IS
24   BEGIN
25     RETURN(nvl(fnd_profile.value('GL_ALLOW_USER_RATE_BETWEEN_EMU_AND_NONEMU'),
26            'Y'));
27   END allow_direct_entry;
28 
29   --
30   -- Procedure
31   --   is_cross_rate
32   --
33   -- Purpose
34   -- 	Returns 'Y' if the current conversion type is User AND
35   --                they are converting from EMU -> OTHER or OTHER -> EMU AND
36   --                they are not allowed to enter EMU -> OTHER and
37   --                OTHER -> EMU rates directly
38   --    Returns 'N' Otherwise
39   --
40   -- History
41   --   20-MAY-99  D J Ogg 	Created
42   --
43   -- Arguments
44   --   x_from_currency		From currency
45   --   x_to_currency 		To currency
46   --   x_conversion_date	Conversion date
47   --   x_conversion_type        Conversion Type
48   --
49   FUNCTION is_cross_rate(
50 		x_from_currency			VARCHAR2,
51 		x_to_currency			VARCHAR2,
52 		x_conversion_date		DATE,
53                 x_conversion_type               VARCHAR2 ) RETURN VARCHAR2 IS
54     x_relationship  VARCHAR2(50);
55     x_fixed_rate    BOOLEAN;
56   BEGIN
57     IF (gl_euro_user_rate_api.allow_direct_entry <> 'N') THEN
58       RETURN('N');
59     END IF;
60 
61     IF (x_conversion_type <> 'User') THEN
62       RETURN('N');
63     END IF;
64 
65     gl_currency_api.get_relation(
66       x_from_currency,
67       x_to_currency,
68       trunc(x_conversion_date),
69       x_fixed_rate,
70       x_relationship);
71 
72     IF (x_relationship IN ('EMU-OTHER', 'OTHER-EMU')) THEN
73       RETURN('Y');
74     ELSE
75       RETURN('N');
76     END IF;
77   EXCEPTION
78     WHEN gl_currency_api.INVALID_CURRENCY THEN
79       RAISE INVALID_CURRENCY;
80   END is_cross_rate;
81 
82 
83   --
84   -- Procedure
85   --   get_prompts_and_rate
86   --
87   -- Purpose
88   -- 	Returns the prompts to use for EURO -> OTHER (or OTHER -> EURO),
89   --    EURO -> EMU, and EMU -> OTHER (or OTHER -> EMU) and the
90   --    rate from EURO -> EMU
91   --
92   -- History
93   --   20-MAY-99  D J Ogg 	Created
94   --
95   -- Arguments
96   --   x_from_currency		From currency
97   --   x_to_currency 		To currency
98   --   x_conversion_date	Conversion date
99   --   x_euro_to_other_prompt   EURO -> OTHER prompt
100   --   x_euro_to_emu_prompt     EURO -> EMU prompt
101   --   x_emu_to_other_prompt    EMU -> OTHER prompt
102   --   x_euro_to_emu_rate       EURO -> EMU rate
103   --
104   PROCEDURE get_prompts_and_rate(
105 		x_from_currency			       VARCHAR2,
106 		x_to_currency			       VARCHAR2,
107 		x_conversion_date		       DATE,
108                 x_euro_to_other_prompt          IN OUT NOCOPY VARCHAR2,
109                 x_euro_to_emu_prompt            IN OUT NOCOPY VARCHAR2,
110                 x_emu_to_other_prompt           IN OUT NOCOPY VARCHAR2,
111                 x_euro_to_emu_rate              IN OUT NOCOPY NUMBER ) IS
112     x_relationship  VARCHAR2(50);
113     x_fixed_rate    BOOLEAN;
114     euro_code       VARCHAR2(15);
115   BEGIN
116     gl_currency_api.get_relation(
117       x_from_currency,
118       x_to_currency,
119       trunc(x_conversion_date),
120       x_fixed_rate,
121       x_relationship);
122 
123     euro_code := gl_currency_api.get_euro_code;
124 
125     IF (x_relationship = 'EMU-OTHER') THEN
126       fnd_message.set_name('SQLGL', 'GL_GLXFCMDR_CURRENCY');
127       fnd_message.set_token('CURRENCY1', euro_code);
128       fnd_message.set_token('CURRENCY2', x_to_currency);
129       x_euro_to_other_prompt := substrb(fnd_message.get, 1, 30);
130 
131       fnd_message.set_name('SQLGL', 'GL_GLXFCMDR_CURRENCY');
132       fnd_message.set_token('CURRENCY1', euro_code);
133       fnd_message.set_token('CURRENCY2', x_from_currency);
134       x_euro_to_emu_prompt := substrb(fnd_message.get, 1, 30);
135 
136       fnd_message.set_name('SQLGL', 'GL_GLXFCMDR_CURRENCY');
137       fnd_message.set_token('CURRENCY1', x_from_currency);
138       fnd_message.set_token('CURRENCY2', x_to_currency);
139       x_emu_to_other_prompt := substrb(fnd_message.get, 1, 30);
140 
141       x_euro_to_emu_rate := gl_currency_api.get_rate(
142                                euro_code,
143                                x_from_currency,
144                                trunc(x_conversion_date),
145                                NULL);
146 
147     ELSIF (x_relationship = 'OTHER-EMU') THEN
148       fnd_message.set_name('SQLGL', 'GL_GLXFCMDR_CURRENCY');
149       fnd_message.set_token('CURRENCY1', x_from_currency);
150       fnd_message.set_token('CURRENCY2', euro_code);
151       x_euro_to_other_prompt := substrb(fnd_message.get, 1, 30);
152 
153       fnd_message.set_name('SQLGL', 'GL_GLXFCMDR_CURRENCY');
154       fnd_message.set_token('CURRENCY1', euro_code);
155       fnd_message.set_token('CURRENCY2', x_to_currency);
156       x_euro_to_emu_prompt := substrb(fnd_message.get, 1, 30);
157 
158       fnd_message.set_name('SQLGL', 'GL_GLXFCMDR_CURRENCY');
159       fnd_message.set_token('CURRENCY1', x_from_currency);
160       fnd_message.set_token('CURRENCY2', x_to_currency);
161       x_emu_to_other_prompt := substrb(fnd_message.get, 1, 30);
162 
163       x_euro_to_emu_rate := gl_currency_api.get_rate(
164                                euro_code,
165                                x_to_currency,
166                                trunc(x_conversion_date),
167                                NULL);
168     ELSE
169       RAISE INVALID_RELATION;
170     END IF;
171   EXCEPTION
172     WHEN gl_currency_api.INVALID_CURRENCY THEN
173       RAISE INVALID_CURRENCY;
174   END get_prompts_and_rate;
175 
176   --
177   -- Procedure
178   --   get_cross_rate
179   --
180   -- Purpose
181   -- 	Given the EURO -> OTHER or OTHER -> EURO rate the user has entered
182   --    and the EURO -> EMU rate, returns the EMU -> OTHER or OTHER -> EMU
183   --    rate
184   --
185   -- History
186   --   20-MAY-99  D J Ogg 	Created
187   --
188   -- Arguments
189   --   x_from_currency		From currency
190   --   x_to_currency 		To currency
191   --   x_conversion_date        Conversion date
192   --   x_euro_to_other_rate     EURO -> OTHER or OTHER -> EURO rate
193   --   x_euro_to_emu_rate       EURO -> EMU rate
194   --
195   FUNCTION get_cross_rate(
196 		x_from_currency			VARCHAR2,
197 		x_to_currency			VARCHAR2,
198                 x_conversion_date               DATE,
199                 x_euro_to_other_rate            NUMBER,
200                 x_euro_to_emu_rate              NUMBER ) RETURN NUMBER IS
201     x_relationship  VARCHAR2(50);
202     x_fixed_rate    BOOLEAN;
203   BEGIN
204     gl_currency_api.get_relation(
205       x_from_currency,
206       x_to_currency,
207       trunc(x_conversion_date),
208       x_fixed_rate,
209       x_relationship);
210 
211     IF (x_relationship = 'EMU-OTHER') THEN
212       RETURN (x_euro_to_other_rate / x_euro_to_emu_rate);
213     ELSIF (x_relationship = 'OTHER-EMU') THEN
214       RETURN (x_euro_to_other_rate * x_euro_to_emu_rate);
215     ELSE
216       RAISE INVALID_RELATION;
217     END IF;
218   EXCEPTION
219     WHEN gl_currency_api.INVALID_CURRENCY THEN
220       RAISE INVALID_CURRENCY;
221   END get_cross_rate;
222 
223 END gl_euro_user_rate_api;
224