4 --pragma RESTRICT_REFERENCES (pa_multi_currency,WNDS,WNPS);
1 PACKAGE pa_multi_currency AUTHID CURRENT_USER AS
2 --$Header: PAXTMCTS.pls 120.1 2005/08/11 10:56:38 eyefimov noship $
3
5
6 -- Package Global Variables.
7
8 G_accounting_currency_code VARCHAR2(15);
9 G_rate_date_code VARCHAR2(1);
10 G_rate_type VARCHAR2(30);
11 no_rate EXCEPTION ;
12 invalid_currency EXCEPTION ;
13 /*----------------------------------------------------------------------------*/
14 -- Start of Comments
15 -- API Name : check_rate_date_code
16 -- Type : Public
17 -- Pre-Reqs : None
18 -- Function :Returns the value of the default_rate_date_code from
19 -- PA_IMPLEMENTATIONS
20 -- Purity : WNDS, WNPS.
21 -- Parameters :
22 -- IN : None
23 -- RETURNS : VARCHAR2
24 -- End of Comments
25 /*---------------------------------------------------------------------------*/
26
27
28 FUNCTION check_rate_date_code
29 RETURN VARCHAR2;
30 --pragma RESTRICT_REFERENCES(check_rate_date_code,WNDS,WNPS);
31
32 /*----------------------------------------------------------------------------*/
33 -- Start of Comments
37 -- Function : Returns the value of default rate_type from the
34 -- API Name : get_acct_rate_type
35 -- Type : Public
36 -- Pre-Reqs : None
38 -- pa_implemantations table
39 -- Parameters :
40 -- IN : None
41 -- OUT : VARCHAR2
42 /*----------------------------------------------------------------------------*/
43 FUNCTION get_rate_type
44 RETURN varchar2;
45 --pragma RESTRICT_REFERENCES (get_rate_type,WNDS,WNPS);
46
47 /*----------------------------------------------------------------------------*/
48 -- Start of Comments
49 -- API Name : get_acct_currency_code
50 -- Type : Public
51 -- Pre-Reqs : None
52 -- Function : returns the Accounting Currency Code based on the set of
53 -- books id of the user's responsibility.
54 -- Parameters :
55 -- IN : None
56 -- OUT : VARCHAR2
57 /*----------------------------------------------------------------------------*/
58
59 FUNCTION get_acct_currency_code
60 RETURN VARCHAR2;
61 --pragma RESTRICT_REFERENCES(get_acct_currency_code,WNDS,WNPS);
62
63 /*----------------------------------------------------------------------------*/
64 -- Start of Comments
65 -- API Name : is_user_rate_type_allowed
66 -- Type : Public
67 -- Pre-Reqs : None
68 -- Function : Returns 'Y' if 'USER' rate type is allowed.
69 -- Returns 'N' otherwise.
70 -- Parameters :
71 -- IN Task_Id NUMBER
72 -- From Currency VARCHAR2,
73 -- To Currency VARCHAR2,
74 -- Conversion Date DATE DEFAULT SYSDATE
75 -- OUT VARCHAR2
76 /*----------------------------------------------------------------------------*/
77
78 FUNCTION is_user_rate_type_allowed (P_from_currency VARCHAR2,
79 P_to_currency VARCHAR2,
80 P_conversion_date DATE DEFAULT SYSDATE)
81 RETURN VARCHAR2 ;
82 --pragma RESTRICT_REFERENCES(is_user_rate_type_allowed,WNDS,WNPS );
83
84
85 /*----------------------------------------------------------------------------*/
86 -- Start of Comments
87 -- API Name : convert_amount
88 -- Type : Public
89 -- Pre-Reqs : None
90 -- Type : Procedure
91 -- Function : returns the converted amount based on the currency
92 -- attributes. also, returns the exchange rate as well
93 -- as error messages, if any.
94 -- Parameters :
95 -- IN
96 -- P_from_currency VARCHAR2,
97 -- P_to_currency VARCHAR2,
98 -- P_amount NUMBER
99 -- P_user_validate_flag VARCHAR2
100 -- P_handle_exception_flag VARCHAR2
101 -- IN/OUT
102
103 -- P_conversion_date DATE DEFAULT SYSDATE,
104 -- P_conversion_type VARCHAR2,
105 -- P_converted_amount NUMBER,
106 -- P_denominator NUMBER,
107 -- P_numerator NUMBER,
108 -- P_rate NUMBER,
109 -- X_status(OUT ONLY) VARCHAR2
110
111 /*----------------------------------------------------------------------------*/
112 PROCEDURE convert_amount (
113 P_from_currency IN VARCHAR2,
114 P_to_currency IN VARCHAR2,
115 P_conversion_date IN OUT NOCOPY DATE ,
116 P_conversion_type IN OUT NOCOPY VARCHAR2,
117 P_amount IN NUMBER,
118 P_user_validate_flag IN VARCHAR2,
119 P_handle_exception_flag IN VARCHAR2 DEFAULT 'Y',
120 P_converted_amount IN OUT NOCOPY NUMBER,
121 P_denominator IN OUT NOCOPY NUMBER,
122 P_numerator IN OUT NOCOPY NUMBER,
123 P_rate IN OUT NOCOPY NUMBER,
124 X_status OUT NOCOPY VARCHAR2) ;
125
126 --pragma RESTRICT_REFERENCES(convert_amount,WNDS,WNPS);
127 /*----------------------------------------------------------------------------*/
128 -- Start of Comments
129 -- API Name : convert_amount_sql
130 -- Type : Public
131 -- Pre-Reqs : None
132 -- Type : Function
133 -- Function : returns the converted amount based on the currency
134 -- attributes.
135 -- Parameters :
136 -- IN
137 -- P_from_currency VARCHAR2,
138 -- P_to_currency VARCHAR2,
139 -- P_conversion_date DATE,
140 -- P_conversion_type VARCHAR2,
141 -- P_Rate NUMBER,
142 -- P_amount NUMBER
143 /*----------------------------------------------------------------------------*/
144 FUNCTION convert_amount_sql (
145 P_from_currency VARCHAR2,
146 P_to_currency VARCHAR2,
147 P_conversion_date DATE,
148 P_conversion_type VARCHAR2 DEFAULT NULL,
149 P_Rate NUMBER,
150 P_amount NUMBER ) RETURN NUMBER;
151
152 --PRAGMA RESTRICT_REFERENCES(convert_amount_sql,WNDS,WNPS);
153
154 /*----------------------------------------------------------------------------*/
155 -- Start of Comments
156 -- API Name : convert_closest_amount
157 -- Type : Public
158 -- Pre-Reqs : None
159 -- Type : Procedure
163 -- Makes use of the maxroll_days to get the rate if not
160 -- Function : returns the converted amount based on the currency
161 -- attributes. also, returns the exchange rate as well
162 -- as error messages, if any.
164 -- found for the particular date.
165 -- Parameters :
166 -- IN
167 -- P_from_currency VARCHAR2,
168 -- P_to_currency VARCHAR2,
169 -- P_amount NUMBER
170 -- P_user_validate_flag VARCHAR2
171 -- P_handle_exception_flag VARCHAR2
172 -- P_maxroll_days NUMBER DEFAULT 0
173 -- IN/OUT
174
175 -- P_conversion_date DATE DEFAULT SYSDATE,
176 -- P_conversion_type VARCHAR2,
177 -- P_converted_amount NUMBER,
178 -- P_denominator NUMBER,
179 -- P_numerator NUMBER,
180 -- P_rate NUMBER,
181 -- X_status(OUT ONLY) VARCHAR2
182
183 PROCEDURE convert_closest_amount
184 ( P_from_currency IN VARCHAR2,
185 P_to_currency IN VARCHAR2,
186 P_conversion_date IN OUT NOCOPY DATE ,
187 P_conversion_type IN OUT NOCOPY VARCHAR2,
188 P_amount IN NUMBER,
189 P_user_validate_flag IN VARCHAR2,
190 P_handle_exception_flag IN VARCHAR2 DEFAULT 'Y',
191 P_maxroll_days IN NUMBER DEFAULT 0,
192 P_converted_amount IN OUT NOCOPY NUMBER,
193 P_denominator IN OUT NOCOPY NUMBER,
194 P_numerator IN OUT NOCOPY NUMBER,
195 P_rate IN OUT NOCOPY NUMBER,
196 X_status OUT NOCOPY VARCHAR2) ;
197
198
199 /*----------------------------------------------------------------------------*/
200 -- Start of Comments
201 -- API Name : format_amount
202 -- Type : Public
203 -- Pre-Reqs : None
204 -- Function : Returns the formatted amount based on the Currency Code
205 -- Parameters :
206 -- IN P_currency IN VARCHAR2
207 -- P_amount IN NUMBER
208 -- P_field_length IN NUMBER
209 -- P_formatted_amount MUST be a VARCHAR2 field and MUST be
210 -- atleast 10 characters longer than the field_length
211 -- OUT P_formatted_amount OUT VARCHAR2
212 /*----------------------------------------------------------------------------*/
213 PROCEDURE format_amount (P_currency IN VARCHAR2,
214 P_amount IN NUMBER,
215 P_field_length IN NUMBER,
216 P_formatted_amount OUT NOCOPY VARCHAR2 );
217
218 /*------------------------------------------------------------------------------
219 The following table is created to store The Currency Code and its associated
220 Format Mask so that the FND API need not be called repeatedly. The procedure
221 Format_amount first searches the table for the Currency Code and Format Mask
222 and the FND API is called only if it is not found in this table. The new
223 Currency and format msak is then stored in the table as well.
224 ------------------------------------------------------------------------------*/
225
226 TYPE curr_mask IS RECORD (
227 currency_code VARCHAR2(15),
228 format_mask VARCHAR2(2000));
229 TYPE format is TABLE of curr_mask
230 INDEX BY BINARY_INTEGER;
231 FormatMaskTab format;
232
233 /*----------------------------------------------------------------------------*/
234 -- Start of Comments
235 -- API Name : validate_rate_type
236 -- Type : Public
237 -- Pre-Reqs : None
238 -- Function : Returns 'Y' if valid rate type. returns 'N' otherwise
239 -- Parameters :
240 -- IN P_Rate_type IN VARCHAR2 Required
241 -- OUT VARCHAR2
242 /*----------------------------------------------------------------------------*/
243 FUNCTION validate_rate_type ( P_rate_type VARCHAR2 )
244 RETURN varchar2 ;
245
246 /*----------------------------------------------------------------------------*/
247 -- Start of Comments
248 -- API Name : validate_currency_code
249 -- Type : Public
250 -- Pre-Reqs : None
251 -- Function : Returns 'Y' if valid currency code. returns 'N' otherwise
252 -- Parameters :
253 -- IN P_currency_code IN VARCHAR2 Required
254 -- OUT VARCHAR2
255 /*----------------------------------------------------------------------------*/
256 FUNCTION validate_currency_code ( P_Currency_code VARCHAR2,
257 P_EI_date DATE )
258 RETURN varchar2 ;
259 /*----------------------------------------------------------------------------*/
260 -- Start of Comments
261 -- API Name : init
262 -- Type : Public
263 -- Function : Initializes the global variables by calling the
264 -- appropriate functions.
265 -- Pre-Reqs : None
266 -- Type : Procedure
267 /*----------------------------------------------------------------------------*/
268
269 PROCEDURE init ;
270
271 /*----------------------------------------------------------------------------*/
272 -- Start of Comments
273 -- API Name : get_conversion_type
274 -- Type : Public
275 -- Pre-Reqs : None
276 -- Function : Returns conversion rate type
277 -- Parameters :
278 -- IN P_User_Rate_type IN VARCHAR2 Required
279 -- OUT VARCHAR2
280 /*----------------------------------------------------------------------------*/
281 FUNCTION get_conversion_type ( P_user_rate_type VARCHAR2 )
282 RETURN varchar2 ;
283
284 --PA-K Performance Improvement Changes
285 G_PrevRateType pa_conversion_types_v.conversion_type%TYPE;
286 G_PrevUserRateType pa_conversion_types_v.user_conversion_type%TYPE;
287 G_CurrValid VARCHAR2(1);
288 G_PrevCurr fnd_currencies_vl.currency_code%TYPE;
289 G_PrevEiDate DATE;
290
291
292 ------------------------------------------------------------------------------
293 -- Function to get User_Conversion_Type value
294 ------------------------------------------------------------------------------
295 FUNCTION Get_User_Conversion_Type ( P_Conversion_Type VARCHAR2 )
296 RETURN VARCHAR2;
297
298 END pa_multi_currency;