[Home] [Help]
PACKAGE BODY: APPS.OKL_FA_AMOUNTS_PVT
Source
1 package body okl_fa_amounts_pvt AS
2 /* $Header: OKLRAAMB.pls 120.2 2006/07/12 08:49:56 dpsingh noship $ */
3 --------------------------------------------------------------------------------
4 --start of comments
5 -- Description : This api takes the asset id and book type code as inputs and
6 -- returns the Oracle fixed asset amounts in contract currency
7 -- IN Parameters : p_asset_id - asset id
8 -- p_book_type_code - book_type code
9 -- OUT Parameters :
10 -- x_cost FA current cost
11 -- x_adj_cost FA adjusted cost
12 -- x_original_cost FA original cost
13 -- x_salvage_value FA salvage value
14 -- x_recoverable_cost FA recoverable cost
15 -- x_adj_recoverable_cost FA adjusted recoverable cost
16 --End of comments
17 --------------------------------------------------------------------------------
18 Procedure convert_fa_amounts
19 (p_api_version IN NUMBER,
20 p_init_msg_list IN VARCHAR2,
21 x_return_status OUT NOCOPY VARCHAR2,
22 x_msg_count OUT NOCOPY NUMBER,
23 x_msg_data OUT NOCOPY VARCHAR2,
24 p_asset_id IN NUMBER,
25 p_book_type_code IN VARCHAR2,
26 x_cost OUT NOCOPY NUMBER,
27 x_adj_cost OUT NOCOPY NUMBER,
28 x_original_cost OUT NOCOPY NUMBER,
29 x_salvage_value OUT NOCOPY NUMBER,
30 x_recoverable_cost OUT NOCOPY NUMBER,
31 x_adj_recoverable_cost OUT NOCOPY NUMBER) is
32
33 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
34 l_api_name CONSTANT varchar2(30) := 'CONVERT_FA_AMOUNTS';
35 l_api_version CONSTANT NUMBER := 1.0;
36
37
38 Cursor conv_params_csr(assetid NUMBER) is
39 Select khr.CURRENCY_CODE CONTRACT_CURRENCY_CODE,
40 khr.CURRENCY_CONVERSION_TYPE,
41 khr.CURRENCY_CONVERSION_RATE,
42 khr.CURRENCY_CONVERSION_DATE,
43 khr.AUTHORING_ORG_ID,
44 aopt.SET_OF_BOOKS_ID,
45 sob.CURRENCY_CODE FUNCTIONAL_CURRENCY_CODE
46 FROM GL_LEDGERS_PUBLIC_V sob,
47 OKL_SYS_ACCT_OPTS aopt,
48 OKL_K_HEADERS_FULL_V khr,
49 OKC_K_LINES_B cle,
50 OKC_LINE_STYLES_B lse,
51 OKC_K_ITEMS cim
52 WHERE sob.ledger_id = aopt.set_of_books_id
53 and aopt.org_id = khr.authoring_org_id
54 and khr.id = cle.dnz_chr_id
55 and cle.id = cim.cle_id
56 and cle.dnz_chr_id = cim.dnz_chr_id
57 and cle.lse_id = lse.id
58 and lse.lty_code = 'FIXED_ASSET'
59 and cim.object1_id1 = to_char(assetid)
60 and cim.object1_id2 = '#'
61 and cim.jtot_object1_code = 'OKX_ASSET';
62
63 l_conv_params_rec conv_params_csr%RowType;
64
65
66 Cursor fa_amounts_csr (assetid NUMBER,
67 bookcode VARCHAR2) is
68 Select cost,
69 adjusted_cost,
70 original_cost,
71 salvage_value,
72 recoverable_cost,
73 adjusted_recoverable_cost
74 from FA_BOOKS
75 where asset_id = assetid
76 and book_type_code = bookcode
77 and transaction_header_id_out is null
78 and date_ineffective is null;
79
80 l_fa_amounts_rec fa_amounts_csr%rowtype;
81
82 l_cost NUMBER;
83 l_adj_cost NUMBER;
84 l_original_cost NUMBER;
85 l_salvage_value NUMBER;
86 l_recoverable_cost NUMBER;
87 l_adj_recoverable_cost NUMBER;
88
89 l_inv_conv_rate NUMBER;
90 begin
91 x_return_status := OKL_API.G_RET_STS_SUCCESS;
92 -- Call start_activity to create savepoint, check compatibility
93 -- and initialize message list
94 x_return_status := OKL_API.START_ACTIVITY (
95 l_api_name
96 ,p_init_msg_list
97 ,'_PVT'
98 ,x_return_status);
99 -- Check if activity started successfully
100 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
101 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
102 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
103 RAISE OKL_API.G_EXCEPTION_ERROR;
104 END IF;
105
106 open conv_params_csr(p_asset_id);
107 Fetch conv_params_csr into l_conv_params_rec;
108 if conv_params_csr%notfound then
109 null;
110 --raise error currency parameters not found
111 else
112 open fa_amounts_csr(p_asset_id, p_book_type_code);
113 fetch fa_amounts_csr into l_fa_amounts_rec;
114 if fa_amounts_csr%notfound then
115 null;
116 --raise error fa data not found
117 elsif l_conv_params_rec.contract_currency_code = l_conv_params_rec.functional_currency_code then
118 l_cost := l_fa_amounts_rec.cost;
119 l_adj_cost := l_fa_amounts_rec.adjusted_cost;
120 l_original_cost := l_fa_amounts_rec.original_cost;
121 l_salvage_value := l_fa_amounts_rec.salvage_value;
122 l_recoverable_cost := l_fa_amounts_rec.recoverable_cost;
123 l_adj_recoverable_cost := l_fa_amounts_rec.adjusted_recoverable_cost;
124 elsif l_conv_params_rec.contract_currency_code <> l_conv_params_rec.functional_currency_code then
125 If upper(l_conv_params_rec.currency_conversion_type) <> 'USER' Then
126 If l_conv_params_rec.currency_conversion_type is null OR
127 --conv_params_csr.currency_conversion_rate is null OR
128 l_conv_params_rec.currency_conversion_date is null then
129 null;
130 --raise error : currency conversion parameters not available;
131 else
132 l_cost := GL_CURRENCY_API.convert_amount (
133 x_from_currency => l_conv_params_rec.functional_currency_code,
134 x_to_currency => l_conv_params_rec.CONTRACT_CURRENCY_CODE,
135 x_conversion_date => l_conv_params_rec.currency_conversion_date,
136 x_conversion_type => l_conv_params_rec.currency_conversion_type,
137 x_amount => l_fa_amounts_rec.cost);
138 l_adj_cost := GL_CURRENCY_API.convert_amount (
139 x_from_currency => l_conv_params_rec.functional_currency_code,
140 x_to_currency => l_conv_params_rec.CONTRACT_CURRENCY_CODE,
141 x_conversion_date => l_conv_params_rec.currency_conversion_date,
142 x_conversion_type => l_conv_params_rec.currency_conversion_type,
143 x_amount => l_fa_amounts_rec.adjusted_cost);
144 l_original_cost := GL_CURRENCY_API.convert_amount (
145 x_from_currency => l_conv_params_rec.functional_currency_code,
146 x_to_currency => l_conv_params_rec.CONTRACT_CURRENCY_CODE,
147 x_conversion_date => l_conv_params_rec.currency_conversion_date,
148 x_conversion_type => l_conv_params_rec.currency_conversion_type,
149 x_amount => l_fa_amounts_rec.original_cost);
150 l_salvage_value := GL_CURRENCY_API.convert_amount (
151 x_from_currency => l_conv_params_rec.functional_currency_code,
152 x_to_currency => l_conv_params_rec.CONTRACT_CURRENCY_CODE,
153 x_conversion_date => l_conv_params_rec.currency_conversion_date,
154 x_conversion_type => l_conv_params_rec.currency_conversion_type,
155 x_amount => l_fa_amounts_rec.salvage_value);
156 l_recoverable_cost := GL_CURRENCY_API.convert_amount (
157 x_from_currency => l_conv_params_rec.functional_currency_code,
158 x_to_currency => l_conv_params_rec.CONTRACT_CURRENCY_CODE,
159 x_conversion_date => l_conv_params_rec.currency_conversion_date,
160 x_conversion_type => l_conv_params_rec.currency_conversion_type,
161 x_amount => l_fa_amounts_rec.recoverable_cost);
162 l_adj_recoverable_cost := GL_CURRENCY_API.convert_amount (
163 x_from_currency => l_conv_params_rec.functional_currency_code,
164 x_to_currency => l_conv_params_rec.CONTRACT_CURRENCY_CODE,
165 x_conversion_date => l_conv_params_rec.currency_conversion_date,
166 x_conversion_type => l_conv_params_rec.currency_conversion_type,
167 x_amount => l_fa_amounts_rec.adjusted_recoverable_cost);
168 end if;
169 Elsif upper(l_conv_params_rec.currency_conversion_type) = 'USER' then
170 If l_conv_params_rec.currency_conversion_rate is null then
171 null;
172 --raise error : need a rate
173 Else
174 l_inv_conv_rate := (1/l_conv_params_rec.currency_conversion_rate);
175 l_cost := l_inv_conv_rate * l_fa_amounts_rec.cost;
176 l_adj_cost := l_inv_conv_rate * l_fa_amounts_rec.adjusted_cost;
177 l_original_cost := l_inv_conv_rate * l_fa_amounts_rec.original_cost;
178 l_salvage_value := l_inv_conv_rate * l_fa_amounts_rec.salvage_value;
179 l_recoverable_cost := l_inv_conv_rate * l_fa_amounts_rec.recoverable_cost;
180 l_adj_recoverable_cost := l_inv_conv_rate * l_fa_amounts_rec.adjusted_recoverable_cost;
181 End If;
182 End If;
183 end If;
184 close fa_amounts_csr;
185 end if;
186 close conv_params_csr;
187
188
189 l_cost := okl_accounting_util.CROSS_CURRENCY_ROUND_AMOUNT(l_cost, l_conv_params_rec.CONTRACT_CURRENCY_CODE);
190 l_adj_cost := okl_accounting_util.CROSS_CURRENCY_ROUND_AMOUNT(l_adj_cost, l_conv_params_rec.CONTRACT_CURRENCY_CODE);
191 l_original_cost := okl_accounting_util.CROSS_CURRENCY_ROUND_AMOUNT(l_original_cost, l_conv_params_rec.CONTRACT_CURRENCY_CODE);
192 l_salvage_value := okl_accounting_util.CROSS_CURRENCY_ROUND_AMOUNT(l_salvage_value, l_conv_params_rec.CONTRACT_CURRENCY_CODE);
193 l_recoverable_cost := okl_accounting_util.CROSS_CURRENCY_ROUND_AMOUNT(l_recoverable_cost, l_conv_params_rec.CONTRACT_CURRENCY_CODE);
194 l_adj_recoverable_cost := okl_accounting_util.CROSS_CURRENCY_ROUND_AMOUNT(l_adj_recoverable_cost, l_conv_params_rec.CONTRACT_CURRENCY_CODE);
195
196
197 x_cost := l_cost;
198 x_adj_cost := l_adj_cost;
199 x_original_cost := l_original_cost;
200 x_salvage_value := l_salvage_value;
201 x_recoverable_cost := l_recoverable_cost;
202 x_adj_recoverable_cost := l_adj_recoverable_cost;
203
204 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
205 EXCEPTION
206 WHEN OKL_API.G_EXCEPTION_ERROR THEN
207 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
208 l_api_name,
209 G_PKG_NAME,
210 'OKL_API.G_RET_STS_ERROR',
211 x_msg_count,
212 x_msg_data,
213 '_PVT');
214 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
215 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
216 l_api_name,
217 G_PKG_NAME,
218 'OKL_API.G_RET_STS_UNEXP_ERROR',
219 x_msg_count,
220 x_msg_data,
221 '_PVT');
222 WHEN OTHERS THEN
223 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
224 l_api_name,
225 G_PKG_NAME,
226 'OTHERS',
227 x_msg_count,
228 x_msg_data,
229 '_PVT');
230 end convert_fa_amounts;
231 --------------------------------------------------------------------------------
232 --start of comments
233 -- Description : This api takes the OKL finacial asset line id as input and
234 -- returns the Oracle fixed asset CORP Bok amounts in contract currency
235 -- IN Parameters : p_fin_asset_id - Financial asset line id. (OKL fin asset top
236 -- line id
237 -- OUT Parameters :
238 -- x_cost FA current cost
239 -- x_adj_cost FA adjusted cost
240 -- x_original_cost FA original cost
241 -- x_salvage_value FA salvage value
242 -- x_recoverable_cost FA recoverable cost
243 -- x_adj_recoverable_cost FA adjusted recoverable cost
244 --End of comments
245 --------------------------------------------------------------------------------
246 Procedure convert_fa_amounts
247 (p_api_version IN NUMBER,
248 p_init_msg_list IN VARCHAR2,
249 x_return_status OUT NOCOPY VARCHAR2,
250 x_msg_count OUT NOCOPY NUMBER,
251 x_msg_data OUT NOCOPY VARCHAR2,
252 p_fin_ast_id IN NUMBER,
253 x_cost OUT NOCOPY NUMBER,
254 x_adj_cost OUT NOCOPY NUMBER,
255 x_original_cost OUT NOCOPY NUMBER,
256 x_salvage_value OUT NOCOPY NUMBER,
257 x_recoverable_cost OUT NOCOPY NUMBER,
258 x_adj_recoverable_cost OUT NOCOPY NUMBER) is
259
260 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
261 l_api_name CONSTANT varchar2(30) := 'CONVERT_FA_AMOUNTS';
262 l_api_version CONSTANT NUMBER := 1.0;
263
264
265 CURSOR fixed_Ast_csr(finastid NUMBER) is
266 SELECT to_number(cim.object1_id1)
267 FROM okc_k_items cim,
268 fa_additions fa,
269 okc_k_lines_b cle
270 where fa.asset_id = to_number(cim.object1_id1)
271 and cim.object1_id2 = '#'
272 and cim.jtot_object1_code = 'OKX_ASSET'
273 and cim.cle_id = cle.id
274 and cim.dnz_chr_id = cle.dnz_chr_id
275 and cle.cle_id = finastid;
276
277 l_asset_id NUMBER;
278
279 CURSOR Corp_Book_csr (asstid NUMBER) is
280 SELECT fab.book_type_code
281 FROM FA_BOOKS FAB,
282 FA_BOOK_CONTROLS FBC
283 WHERE fab.book_type_code = fbc.book_type_code
284 AND fbc.book_class = 'CORPORATE'
285 AND fab.asset_id = asstid
286 AND fab.transaction_header_id_out is null
287 AND fab.date_ineffective is null;
288
289 l_book_type_code varchar2(15);
290
291 l_cost NUMBER;
292 l_adj_cost NUMBER;
293 l_original_cost NUMBER;
294 l_salvage_value NUMBER;
295 l_recoverable_cost NUMBER;
296 l_adj_recoverable_cost NUMBER;
297
298 Begin
299 x_return_status := OKL_API.G_RET_STS_SUCCESS;
300 -- Call start_activity to create savepoint, check compatibility
301 -- and initialize message list
302 x_return_status := OKL_API.START_ACTIVITY (
303 l_api_name
304 ,p_init_msg_list
305 ,'_PVT'
306 ,x_return_status);
307 -- Check if activity started successfully
308 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
309 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
310 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
311 RAISE OKL_API.G_EXCEPTION_ERROR;
312 END IF;
313
314 --get fixed asset
315 Open fixed_Ast_csr(p_fin_ast_id);
316 Fetch fixed_Ast_csr into l_asset_id;
317 If fixed_Ast_csr%NOTFOUND then
318 Null;
319 End If;
320 Close fixed_Ast_csr;
321
322 --get book_type_code
323 Open Corp_Book_csr(l_asset_id);
324 Fetch Corp_Book_csr into l_book_type_code;
325 If Corp_Book_csr%NOTFOUND then
326 Null;
327 End If;
328 Close Corp_Book_csr;
329
330 --dbms_output.put_line('calling api with '||to_char(l_asset_id)||' '||l_book_type_code);
331 okl_fa_amounts_pvt.convert_fa_amounts
332 (p_api_version => p_api_version,
333 p_init_msg_list => p_init_msg_list,
334 x_return_status => x_return_status,
335 x_msg_count => x_msg_count,
336 x_msg_data => x_msg_data,
337 p_asset_id => l_asset_id,
338 p_book_type_code => l_book_type_code,
339 x_cost => l_cost,
340 x_adj_cost => l_adj_cost,
341 x_original_cost => l_original_cost,
342 x_salvage_value => l_salvage_value,
343 x_recoverable_cost => l_recoverable_cost,
344 x_adj_recoverable_cost => l_adj_recoverable_cost);
345 -- Check if activity started successfully
346 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
347 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
348 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
349 RAISE OKL_API.G_EXCEPTION_ERROR;
350 END IF;
351
352 x_cost := l_cost;
353 x_adj_cost := l_adj_cost;
354 x_original_cost := l_original_cost;
355 x_salvage_value := l_salvage_value;
356 x_recoverable_cost := l_recoverable_cost;
357 x_adj_recoverable_cost := l_adj_recoverable_cost;
358
359 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
360 EXCEPTION
361 WHEN OKL_API.G_EXCEPTION_ERROR THEN
362 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
363 l_api_name,
364 G_PKG_NAME,
365 'OKL_API.G_RET_STS_ERROR',
366 x_msg_count,
367 x_msg_data,
368 '_PVT');
369 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
370 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
371 l_api_name,
372 G_PKG_NAME,
373 'OKL_API.G_RET_STS_UNEXP_ERROR',
374 x_msg_count,
375 x_msg_data,
376 '_PVT');
377 WHEN OTHERS THEN
378 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
379 l_api_name,
380 G_PKG_NAME,
381 'OTHERS',
382 x_msg_count,
383 x_msg_data,
384 '_PVT');
385
386 end convert_fa_amounts;
387 --------------------------------------------------------------------------------
388 --start of comments
389 -- Description : This api takes the OKL finacial asset line id, asset cost and salvage value in
390 -- contract currency as input and
391 -- returns cost and salvage value amounts in functional currency
392 -- IN Parameters : p_fin_asset_id - Financial asset line id. (OKL fin asset top
393 -- line id
394 -- p_k_cost - contract cost in contract currency
395 -- p_k_salvage_value - contract salvage value in contract currency
396 -- OUT Parameters :
397 -- x_fa_cost FA current cost in functional currency
398 -- x_fa_salvage_value FA salvage value in functional currency
399 --End of comments
400 --------------------------------------------------------------------------------
401 Procedure convert_okl_amounts
402 (p_api_version IN NUMBER,
403 p_init_msg_list IN VARCHAR2,
404 x_return_status OUT NOCOPY VARCHAR2,
405 x_msg_count OUT NOCOPY NUMBER,
406 x_msg_data OUT NOCOPY VARCHAR2,
407 p_fin_ast_id IN NUMBER,
408 p_okl_cost IN NUMBER,
409 p_okl_salvage_value IN NUMBER,
410 x_fa_cost OUT NOCOPY NUMBER,
411 x_fa_salvage_value OUT NOCOPY NUMBER) is
412
413 l_return_status VARCHAR2(1) default OKL_API.G_RET_STS_SUCCESS;
414 l_api_name CONSTANT varchar2(30) := 'CONVERT_OKL_AMOUNTS';
415 l_api_version CONSTANT NUMBER := 1.0;
416
417 Cursor conv_params_csr(finassetid NUMBER) is
418 Select khr.CURRENCY_CODE CONTRACT_CURRENCY_CODE,
419 khr.CURRENCY_CONVERSION_TYPE,
420 khr.CURRENCY_CONVERSION_RATE,
421 khr.CURRENCY_CONVERSION_DATE,
422 khr.AUTHORING_ORG_ID,
423 khr.DEAL_TYPE,
424 aopt.SET_OF_BOOKS_ID,
425 sob.CURRENCY_CODE FUNCTIONAL_CURRENCY_CODE
426 FROM GL_LEDGERS_PUBLIC_V sob,
427 OKL_SYS_ACCT_OPTS aopt,
428 OKL_K_HEADERS_FULL_V khr,
429 OKC_K_LINES_B cle,
430 OKC_LINE_STYLES_B lse
431 WHERE sob.ledger_id = aopt.set_of_books_id
432 and aopt.org_id = khr.authoring_org_id
433 and khr.id = cle.dnz_chr_id
434 and khr.id = cle.chr_id
435 and cle.lse_id = lse.id
436 and lse.lty_code = 'FREE_FORM1'
437 and cle.id = finassetid;
438
439 l_conv_params_rec conv_params_csr%ROWTYPE;
440
441 Cursor okl_amt_csr(finassetid NUMBER) is
442 Select kle.OEC,
443 kle.RESIDUAL_VALUE
444 from OKL_K_LINES KLE
445 where kle.id = finassetid;
446
447 l_oec OKL_K_LINES.OEC%TYPE;
448 l_residual_value OKL_K_LINES.RESIDUAL_VALUE%TYPE;
449
450 l_okl_cost NUMBER;
451 l_okl_salvage_value NUMBER;
452
453 l_fa_cost NUMBER;
454 l_fa_salvage_value NUMBER;
455 begin
456 x_return_status := OKL_API.G_RET_STS_SUCCESS;
457 -- Call start_activity to create savepoint, check compatibility
458 -- and initialize message list
459 x_return_status := OKL_API.START_ACTIVITY (
460 l_api_name
461 ,p_init_msg_list
462 ,'_PVT'
463 ,x_return_status);
464 -- Check if activity started successfully
465 IF (x_return_status = OKL_API.G_RET_STS_UNEXP_ERROR) THEN
466 RAISE OKL_API.G_EXCEPTION_UNEXPECTED_ERROR;
467 ELSIF (x_return_status = OKL_API.G_RET_STS_ERROR) THEN
468 RAISE OKL_API.G_EXCEPTION_ERROR;
469 END IF;
470
471 open conv_params_csr(p_fin_ast_id);
472 Fetch conv_params_csr into l_conv_params_rec;
473 if conv_params_csr%notfound then
474 null;
475 --raise error currency parameters not found
476 End if;
477 close conv_params_csr;
478
479 If (p_okl_cost is null) OR (p_okl_salvage_value is null) then
480 --get OEC from top line
481 Open okl_amt_csr(p_fin_ast_id);
482 fetch okl_amt_csr into l_oec, l_residual_value;
483 If okl_amt_csr%NOTFOUND then
484 null;
485 --error!!
486 End If;
487 Close okl_amt_csr;
488 End If;
489
490 If p_okl_cost is null then
491 l_okl_cost := l_oec;
492 else
493 l_okl_cost := p_okl_cost;
494 end if;
495
496 If l_conv_params_rec.deal_type = 'LEASEOP' then
497 If nvl(p_okl_salvage_value,0) = 0 Then
498 l_okl_salvage_value := l_residual_value;
499 Else
500 l_okl_salvage_value := nvl(p_okl_salvage_value,0);
501 End If;
502 Else
503 l_okl_salvage_value := nvl(p_okl_salvage_value,0);
504 End If;
505 --dbms_output.put_line('cost :' ||to_char(l_okl_cost));
506 --dbms_output.put_line('salvage value :' ||to_char(l_okl_salvage_value));
507 if l_conv_params_rec.contract_currency_code = l_conv_params_rec.functional_currency_code then
508 l_fa_cost := l_okl_cost;
509 l_fa_salvage_value := l_okl_salvage_value;
510 elsif l_conv_params_rec.contract_currency_code <> l_conv_params_rec.functional_currency_code then
511 If upper(l_conv_params_rec.currency_conversion_type) <> 'USER' Then
512 If l_conv_params_rec.currency_conversion_type is null OR
513 l_conv_params_rec.currency_conversion_date is null then
514 null;
515 --raise error : currency conversion parameters not available;
516 else
517 l_fa_cost := GL_CURRENCY_API.convert_amount (
518 x_from_currency => l_conv_params_rec.contract_currency_code,
519 x_to_currency => l_conv_params_rec.FUNCTIONAL_CURRENCY_CODE,
520 x_conversion_date => l_conv_params_rec.currency_conversion_date,
521 x_conversion_type => l_conv_params_rec.currency_conversion_type,
522 x_amount => l_okl_cost);
523 l_fa_salvage_value := GL_CURRENCY_API.convert_amount (
524 x_from_currency => l_conv_params_rec.contract_currency_code,
525 x_to_currency => l_conv_params_rec.FUNCTIONAL_CURRENCY_CODE,
526 x_conversion_date => l_conv_params_rec.currency_conversion_date,
527 x_conversion_type => l_conv_params_rec.currency_conversion_type,
528 x_amount => l_okl_salvage_value);
529 end if;
530 Elsif upper(l_conv_params_rec.currency_conversion_type) = 'USER' Then
531 If l_conv_params_rec.currency_conversion_rate is null then
532 null;
533 --raise error : need a rate
534 Else
535 l_fa_cost := l_conv_params_rec.currency_conversion_rate * l_okl_cost;
536 l_fa_salvage_value := l_conv_params_rec.currency_conversion_rate * l_okl_salvage_value;
537 End If;
538 End If;
539 End If;
540
541
542 l_fa_cost := okl_accounting_util.CROSS_CURRENCY_ROUND_AMOUNT(l_fa_cost,l_conv_params_rec.FUNCTIONAL_CURRENCY_CODE);
543 l_fa_salvage_value := okl_accounting_util.CROSS_CURRENCY_ROUND_AMOUNT(l_fa_salvage_value,l_conv_params_rec.FUNCTIONAL_CURRENCY_CODE);
544
545
546 x_fa_cost := l_fa_cost;
547 x_fa_salvage_value := l_fa_salvage_value;
548
549 OKL_API.END_ACTIVITY (x_msg_count,x_msg_data );
550 EXCEPTION
551 WHEN OKL_API.G_EXCEPTION_ERROR THEN
552 x_return_status := OKL_API.HANDLE_EXCEPTIONS(
553 l_api_name,
554 G_PKG_NAME,
555 'OKL_API.G_RET_STS_ERROR',
556 x_msg_count,
557 x_msg_data,
558 '_PVT');
559 WHEN OKL_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
560 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
561 l_api_name,
562 G_PKG_NAME,
563 'OKL_API.G_RET_STS_UNEXP_ERROR',
564 x_msg_count,
565 x_msg_data,
566 '_PVT');
567 WHEN OTHERS THEN
568 x_return_status :=OKL_API.HANDLE_EXCEPTIONS(
569 l_api_name,
570 G_PKG_NAME,
571 'OTHERS',
572 x_msg_count,
573 x_msg_data,
574 '_PVT');
575
576 end convert_okl_amounts;
577
578 end okl_fa_amounts_pvt;