[Home] [Help]
PACKAGE BODY: APPS.FA_CIP_PUB
Source
1 PACKAGE BODY FA_CIP_PUB as
2 /* $Header: FAPCIPB.pls 120.18 2006/08/25 15:43:48 spooyath noship $ */
3
4 --*********************** Global constants ******************************--
5
6 G_PKG_NAME CONSTANT varchar2(30) := 'FA_CIP_PUB';
7 G_API_NAME CONSTANT varchar2(30) := 'Capitalization/Reverse API';
8 G_API_VERSION CONSTANT number := 1.0;
9
10 g_log_level_rec fa_api_types.log_level_rec_type;
11
12 --*********************** Private functions ******************************--
13
14
15 FUNCTION do_cap_rev
16 (p_api_version IN NUMBER,
17 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
18 p_commit IN VARCHAR2 := FND_API.G_FALSE,
19 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
20 p_calling_fn IN VARCHAR2,
21 x_return_status OUT NOCOPY VARCHAR2,
22 x_msg_count OUT NOCOPY NUMBER,
23 x_msg_data OUT NOCOPY VARCHAR2,
24
25 px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
26 px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
27 px_asset_fin_rec IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
28 p_cap_rev IN VARCHAR2,
29 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN;
30
31 -- private declaration for books (mrc) wrapper
32
33 FUNCTION do_all_books
34 (px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
35 px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
36 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
37 px_asset_type_rec IN OUT NOCOPY FA_API_TYPES.asset_type_rec_type,
38 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
39 px_asset_fin_rec IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
40 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN;
41
42 --*********************** Public procedures ******************************--
43
44 PROCEDURE do_capitalization
45 (p_api_version IN NUMBER,
46 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
47 p_commit IN VARCHAR2 := FND_API.G_FALSE,
48 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
49 p_calling_fn IN VARCHAR2,
50 x_return_status OUT NOCOPY VARCHAR2,
51 x_msg_count OUT NOCOPY NUMBER,
52 x_msg_data OUT NOCOPY VARCHAR2,
53
54 px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
55 px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
56 px_asset_fin_rec IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type) AS
57
58 l_cap_rev VARCHAR2(10) := 'CAPITALIZE';
59 l_calling_fn VARCHAR2(30) := 'fa_cip_pub.do_capitalization';
60 cap_err EXCEPTION;
61
62 BEGIN
63
64 if (not g_log_level_rec.initialized) then
65 if (NOT fa_util_pub.get_log_level_rec (
66 x_log_level_rec => g_log_level_rec
67 )) then
68 raise cap_err;
69 end if;
70 end if;
71
72 px_trans_rec.transaction_type_code := 'CAPITALIZE';
73
74 if not do_cap_rev (
75 p_api_version => p_api_version,
76 p_init_msg_list => p_init_msg_list,
77 p_commit => p_commit,
78 p_validation_level => p_validation_level,
79 p_calling_fn => p_calling_fn,
80 x_return_status => x_return_status,
81 x_msg_count => x_msg_count,
82 x_msg_data => x_msg_data,
83 px_trans_rec => px_trans_rec,
84 px_asset_hdr_rec => px_asset_hdr_rec,
85 px_asset_fin_rec => px_asset_fin_rec,
86 p_cap_rev => l_cap_rev,
87 p_log_level_rec => g_log_level_rec) then
88 raise cap_err;
89 end if;
90
91 -- commit if p_commit is TRUE.
92 if (fnd_api.to_boolean (p_commit)) then
93 COMMIT WORK;
94 end if;
95
96 x_return_status := FND_API.G_RET_STS_SUCCESS;
97
98 return;
99
100 EXCEPTION
101
102 WHEN CAP_ERR THEN
103
104 fa_srvr_msg.add_message(calling_fn => l_calling_fn
105 ,p_log_level_rec => g_log_level_rec);
106
107 -- do not retrieve / clear messaging when this is being called
108 -- from cip-in-taxapi allow calling program to dump them
109 -- if (nvl(p_calling_fn, 'N') <> 'fa_ciptax_api_pkg.cip_adj') then
110
111 -- Commented for bugfix 4672237
112 -- FA_DEBUG_PKG.dump_debug_messages(max_mesgs => 0);
113 FND_MSG_PUB.count_and_get (
114 p_count => x_msg_count,
115 p_data => x_msg_data
116 );
117 -- end if;
118
119 x_return_status := FND_API.G_RET_STS_ERROR;
120
121 return;
122
123 WHEN OTHERS THEN
124
125 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
126 ,p_log_level_rec => g_log_level_rec);
127
128 -- do not retrieve / clear messaging when this is being called
129 -- from cip-in-taxapi allow calling program to dump them
130 -- if (nvl(p_calling_fn, 'N') <> 'fa_ciptax_api_pkg.cip_adj') then
131 -- Commented for bugfix 4672237
132 -- FA_DEBUG_PKG.dump_debug_messages(max_mesgs => 0);
133 FND_MSG_PUB.count_and_get (
134 p_count => x_msg_count,
135 p_data => x_msg_data
136 );
137 -- end if;
138
139 x_return_status := FND_API.G_RET_STS_ERROR;
140
141 return;
142
143 END do_capitalization;
144
145 PROCEDURE do_reverse
146 (p_api_version IN NUMBER,
147 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
148 p_commit IN VARCHAR2 := FND_API.G_FALSE,
149 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
150 p_calling_fn IN VARCHAR2,
151 x_return_status OUT NOCOPY VARCHAR2,
152 x_msg_count OUT NOCOPY NUMBER,
153 x_msg_data OUT NOCOPY VARCHAR2,
154
155 px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
156 px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
157 px_asset_fin_rec IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type) AS
158
159 l_cap_rev VARCHAR2(10) := 'REVERSE';
160 l_calling_fn VARCHAR2(30) := 'fa_cip_pub.do_reverse';
161 rev_err EXCEPTION;
162
163 BEGIN
164
165 if (not g_log_level_rec.initialized) then
166 if (NOT fa_util_pub.get_log_level_rec (
167 x_log_level_rec => g_log_level_rec
168 )) then
169 raise rev_err;
170 end if;
171 end if;
172
173 px_trans_rec.transaction_type_code := 'REVERSE';
174
175 if not do_cap_rev (
176 p_api_version => p_api_version,
177 p_init_msg_list => p_init_msg_list,
178 p_commit => p_commit,
179 p_validation_level => p_validation_level,
180 p_calling_fn => p_calling_fn,
181 x_return_status => x_return_status,
182 x_msg_count => x_msg_count,
183 x_msg_data => x_msg_data,
184 px_trans_rec => px_trans_rec,
185 px_asset_hdr_rec => px_asset_hdr_rec,
186 px_asset_fin_rec => px_asset_fin_rec,
187 p_cap_rev => l_cap_rev,
188 p_log_level_rec => g_log_level_rec) then
189 raise rev_err;
190 end if;
191
192 -- commit if p_commit is TRUE.
193 if (fnd_api.to_boolean (p_commit)) then
194 COMMIT WORK;
195 end if;
196
197 x_return_status := FND_API.G_RET_STS_SUCCESS;
198
199 return;
200
201
202 EXCEPTION
203
204 WHEN REV_ERR THEN
205
206 fa_srvr_msg.add_message(calling_fn => l_calling_fn
207 ,p_log_level_rec => g_log_level_rec);
208
209 -- do not retrieve / clear messaging when this is being called
210 -- from cip-in-taxapi allow calling program to dump them
211 -- if (nvl(p_calling_fn, 'N') <> 'fa_ciptax_api_pkg.cip_adj') then
212
213 -- Commented for bugfix 4672237
214 -- FA_DEBUG_PKG.dump_debug_messages(max_mesgs => 0);
215 FND_MSG_PUB.count_and_get (
216 p_count => x_msg_count,
217 p_data => x_msg_data
218 );
219 -- end if;
220
221 x_return_status := FND_API.G_RET_STS_ERROR;
222
223 return;
224
225 WHEN OTHERS THEN
226
227 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
228 ,p_log_level_rec => g_log_level_rec);
229
230 -- do not retrieve / clear messaging when this is being called
231 -- from cip-in-taxapi allow calling program to dump them
232 -- if (nvl(p_calling_fn, 'X') <> 'fa_ciptax_api_pkg.cip_adj') then
233
234 -- Commented for bugfix 4672237
235 -- FA_DEBUG_PKG.dump_debug_messages(max_mesgs => 0);
236 FND_MSG_PUB.count_and_get (
237 p_count => x_msg_count,
238 p_data => x_msg_data
239 );
240 -- end if;
241
242 x_return_status := FND_API.G_RET_STS_ERROR;
243
244 return;
245
246 END do_reverse;
247
248 --*********************** Private procedures ******************************--
249
250 FUNCTION do_cap_rev
251 (p_api_version IN NUMBER,
252 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
253 p_commit IN VARCHAR2 := FND_API.G_FALSE,
254 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
255 p_calling_fn IN VARCHAR2,
256 x_return_status OUT NOCOPY VARCHAR2,
257 x_msg_count OUT NOCOPY NUMBER,
258 x_msg_data OUT NOCOPY VARCHAR2,
259
260 px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
261 px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
262 px_asset_fin_rec IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
263 p_cap_rev IN VARCHAR2,
264 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
265
266 l_reporting_flag VARCHAR2(1);
267 l_count NUMBER := 0;
268
269 l_asset_desc_rec FA_API_TYPES.asset_desc_rec_type;
270 l_asset_type_rec FA_API_TYPES.asset_type_rec_type;
271 l_asset_cat_rec FA_API_TYPES.asset_cat_rec_type;
272
273 -- Bug 5475276 Cursor to get the book_type_code
274 CURSOR c_corp_book( p_asset_id number ) IS
275 SELECT bc.book_type_code
276 FROM fa_books bks,
277 fa_book_controls bc
278 WHERE bks.book_type_code = bc.distribution_source_book
279 AND bks.book_type_code = bc.book_type_code
280 AND bks.asset_id = p_asset_id
281 AND bks.transaction_header_id_out is null;
282
283 -- used to store original sob info upon entry into api
284 l_orig_set_of_books_id NUMBER;
285 l_orig_currency_context VARCHAR2(64);
286
287 -- used for tax books when doing cip-in-tax or autocopy
288 l_trans_rec FA_API_TYPES.trans_rec_type;
289 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
290 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
291 l_tax_book_tbl FA_CACHE_PKG.fazctbk_tbl_type;
292 l_tax_index NUMBER; -- index for tax loop
293
294 l_calling_fn VARCHAR2(30) := 'fa_cip_pub.do_cap_rev';
295 cap_rev_err EXCEPTION;
296
297 --Added following variables for bugfix# 5155488
298 l_period_of_addition_flag varchar2(1);
299 l_dist_trans_rec FA_API_TYPES.trans_rec_type;
300 l_asset_hierarchy_rec FA_API_TYPES.asset_hierarchy_rec_type;
301 l_asset_deprn_rec FA_API_TYPES.asset_deprn_rec_type;
302 l_asset_dist_rec FA_API_TYPES.asset_dist_rec_type;
303 l_asset_dist_tbl FA_API_TYPES.asset_dist_tbl_type;
304 l_inv_tbl FA_API_TYPES.inv_tbl_type;
305 l_return_status VARCHAR2(1);
306 l_mesg_count number := 0;
307 l_mesg_len number;
308 l_mesg varchar2(4000);
309 l_corp_thid number;
310
311 BEGIN
312
313 SAVEPOINT do_cap_rev;
314
315 -- Initialize message list if p_init_msg_list is set to TRUE.
316 if (fnd_api.to_boolean(p_init_msg_list)) then
317 -- initialize error message stack.
318 fa_srvr_msg.init_server_message;
319
320 -- initialize debug message stack.
321 fa_debug_pkg.initialize;
322 end if;
323
324 -- Check version of the API
325 -- Standard call to check for API call compatibility.
326 if NOT fnd_api.compatible_api_call (
327 G_API_VERSION,
328 p_api_version,
329 G_API_NAME,
330 G_PKG_NAME) then
331 x_return_status := FND_API.G_RET_STS_ERROR;
332 raise cap_rev_err;
333 end if;
334
335 -- Bug 5475276 Get the book_type_code if it is not supplied.
336 if (px_asset_hdr_rec.book_type_code is null) then
337
338 open c_corp_book( px_asset_hdr_rec.asset_id );
339 fetch c_corp_book into px_asset_hdr_rec.book_type_code;
340 close c_corp_book;
341
342 if px_asset_hdr_rec.book_type_code is null then
343 fa_srvr_msg.add_message
344 (calling_fn => l_calling_fn,
345 name => 'FA_EXP_GET_ASSET_INFO'
346 ,p_log_level_rec => p_log_level_rec);
347 raise cap_rev_err;
348 end if;
349 end if;
350
351 -- call the cache for the primary transaction book
352 if NOT fa_cache_pkg.fazcbc(X_book => px_asset_hdr_rec.book_type_code
353 ,p_log_level_rec => p_log_level_rec) then
354 raise cap_rev_err;
355 end if;
356
357 -- commenting this out until after complete uptake of apis
358 -- (in this case from cap form and massadd) at which point
359 -- the interim fa_ciptax_api_pkg will be obsolete and this
360 -- package will and must only be called for corporate book
361 -- (the if condition for book class for the cip-tax loop
362 -- will also become obsolete)
363 --
364 -- if (fa_cache_pkg.fazcbc_record.book_class <> 'CORPORATE') then
365 -- fa_srvr_msg.add_message
366 -- (calling_fn => l_calling_fn,
367 -- name => '**FA_NO_DIR_CAP_TAX***');
368 -- raise cap_rev_err;
369 -- end if;
370
371 px_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
372
373 -- verify the asset exist in the book already
374 if not FA_ASSET_VAL_PVT.validate_asset_book
375 (p_transaction_type_code => 'CAPITALIZATION',
376 p_book_type_code => px_asset_hdr_rec.book_type_code,
377 p_asset_id => px_asset_hdr_rec.asset_id,
378 p_calling_fn => 'fa_adjustment_pub.do_adjustment'
379 ,p_log_level_rec => p_log_level_rec) then
380 raise cap_rev_err;
381 end if;
382
383 -- get the current info for the primary book
384
385 if (p_log_level_rec.statement_level) then
386 fa_debug_pkg.add(l_calling_fn,
387 'in main, sobid', px_asset_hdr_rec.set_of_books_id
388 ,p_log_level_rec => p_log_level_rec);
389 end if;
390
391 fnd_profile.get ('GL_SET_OF_BKS_ID',l_orig_set_of_books_id);
392 l_orig_currency_context := SUBSTRB(USERENV('CLIENT_INFO'),45,10);
393
394 fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
395 fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
396
397 -- Account for transaction submitted from a responsibility
398 -- that is not tied to a SOB_ID by getting the value from
399 -- the book struct
400
401 -- Get the book type code P,R or N
402 if not fa_cache_pkg.fazcsob
403 (X_set_of_books_id => px_asset_hdr_rec.set_of_books_id,
404 X_mrc_sob_type_code => l_reporting_flag
405 ,p_log_level_rec => p_log_level_rec) then
406 raise cap_rev_err;
407 end if;
408
409 -- Error out if the program is submitted from the Reporting Responsibility
410 -- No transaction permitted directly on reporting books.
411
412 IF l_reporting_flag = 'R' THEN
413 fa_srvr_msg.add_message
414 (calling_fn => l_calling_fn,
415 name => 'MRC_OSP_INVALID_BOOK_TYPE'
416 ,p_log_level_rec => p_log_level_rec);
417 raise cap_rev_err;
418 END IF;
419
420 -- end initial MRC validation
421
422
423 -- set trx type
424 if p_cap_rev = 'CAPITALIZE' then
425 px_trans_rec.transaction_type_code := 'ADDITION';
426
427 elsif p_cap_rev = 'REVERSE' then
428 px_trans_rec.transaction_type_code := 'CIP REVERSE';
429 else
430 fa_srvr_msg.add_message
431 (calling_fn => l_calling_fn,
432 name => '***INVALID_TRX_TYPE***'
433 ,p_log_level_rec => p_log_level_rec);
434 raise cap_rev_err;
435 end if;
436
437
438 -- load the needed structs
439 if not FA_UTIL_PVT.get_asset_desc_rec
440 (p_asset_hdr_rec => px_asset_hdr_rec,
441 px_asset_desc_rec => l_asset_desc_rec
442 ,p_log_level_rec => p_log_level_rec) then
443 raise cap_rev_err;
444 end if;
445
446 if not FA_UTIL_PVT.get_asset_cat_rec
447 (p_asset_hdr_rec => px_asset_hdr_rec,
448 px_asset_cat_rec => l_asset_cat_rec,
449 p_date_effective => null
450 ,p_log_level_rec => p_log_level_rec) then
451 raise cap_rev_err;
452 end if;
453
454 if not FA_UTIL_PVT.get_asset_type_rec
455 (p_asset_hdr_rec => px_asset_hdr_rec,
456 px_asset_type_rec => l_asset_type_rec,
457 p_date_effective => null
458 ,p_log_level_rec => p_log_level_rec) then
459 raise cap_rev_err;
460 end if;
461
462 -- remove after api update
463 -- verify the transaction / asset type combi is valid for corp books
464
465 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
466
467 if (((l_asset_type_rec.asset_type = 'CIP') and
468 (px_trans_rec.transaction_type_code = 'CIP REVERSE')) or
469 ((l_asset_type_rec.asset_type = 'CAPITALIZED') and
470 (px_trans_rec.transaction_type_code = 'ADDITION')) or
471 (l_asset_type_rec.asset_type = 'EXPENSED')) then
472
473 fa_srvr_msg.add_message
474 (calling_fn => l_calling_fn,
475 name => '***INVALID_COMBO***'
476 ,p_log_level_rec => p_log_level_rec);
477 raise cap_rev_err;
478
479 end if;
480
481 end if;
482
483 if not do_all_books
484 (px_trans_rec => px_trans_rec,
485 px_asset_hdr_rec => px_asset_hdr_rec ,
486 p_asset_desc_rec => l_asset_desc_rec ,
487 px_asset_type_rec => l_asset_type_rec,
488 p_asset_cat_rec => l_asset_cat_rec ,
489 px_asset_fin_rec => px_asset_fin_rec
490 ,p_log_level_rec => p_log_level_rec)then
491 raise cap_rev_err;
492 end if;
493
494 -- remove the if condition after api update as this will always be corp book
495 -- If book is a corporate book, process cip assets and autocopy
496
497 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
498
499 -- null out the deprn_adj table as we do not want to autocopy
500 -- any deprn info to tax books
501 -- still need to DO THIS!!!
502
503 l_trans_rec := px_trans_rec;
504 l_asset_hdr_rec := px_asset_hdr_rec;
505
506
507 -- ideally we may want to revisit this and get the CAP version
508 -- of the cache when in period of addition and changing to
509 -- capitalization, calling the additions api or for reversals
510 -- deleting the asset from tax books in period of addition
511 -- if allow cip assets is not enabled.
512
513 if not fa_cache_pkg.fazctbk
514 (x_corp_book => px_asset_hdr_rec.book_type_code,
515 x_asset_type => 'CIP',
516 x_tax_book_tbl => l_tax_book_tbl
517 ,p_log_level_rec => p_log_level_rec) then
518 raise cap_rev_err;
519 end if;
520
521 for l_tax_index in 1..l_tax_book_tbl.count loop
522
523 l_asset_fin_rec := null;
524
525 if (p_log_level_rec.statement_level) then
526 fa_debug_pkg.add(l_calling_fn,
527 'in do_cap_rev processing tax book', l_tax_book_tbl(l_tax_index),
528 p_log_level_rec => p_log_level_rec);
529 end if;
530
531 -- verify that the asset exists in the tax book
532 -- if not just bypass it without failing
533
534 if not (FA_ASSET_VAL_PVT.validate_asset_book
535 (p_transaction_type_code => 'CAPITALIZATION',
536 p_book_type_code => l_tax_book_tbl(l_tax_index),
537 p_asset_id => px_asset_hdr_rec.asset_id,
538 p_calling_fn => 'fa_adjustment_pub.do_adjustment')) then
539 --null;
540 -- bugfix# 5155488
541 if not (FA_ASSET_VAL_PVT.validate_period_of_addition
542 (p_asset_id => px_asset_hdr_rec.asset_id,
543 p_book => px_asset_hdr_rec.book_type_code,
544 px_period_of_addition => l_period_of_addition_flag)) then
545 raise cap_rev_err;
546 end if;
547
548 if(nvl(l_period_of_addition_flag,'N') = 'Y') then
549
550 select transaction_header_id
551 into l_corp_thid
552 from fa_transaction_headers
553 where asset_id=px_asset_hdr_rec.asset_id
554 and book_type_code=px_asset_hdr_rec.book_type_code
555 and transaction_type_code='CIP REVERSE';
556
557 l_asset_hdr_rec.asset_id := px_asset_hdr_rec.asset_id;
558 l_asset_hdr_rec.book_type_code := l_tax_book_tbl(l_tax_index);
559 l_trans_rec.source_transaction_header_id := l_corp_thid;
560 l_trans_rec.calling_interface := 'FAXASSET';
561 l_trans_rec.mass_reference_id := px_trans_rec.mass_reference_id;
562 l_trans_rec.transaction_header_id := null;
563
564 select cost,
565 date_placed_in_service,
566 group_asset_id,
567 salvage_type,
568 percent_salvage_value,
569 salvage_value
570 into l_asset_fin_rec.cost,
571 l_asset_fin_rec.date_placed_in_service,
572 l_asset_fin_rec.group_asset_id,
573 l_asset_fin_rec.salvage_type,
574 l_asset_fin_rec.percent_salvage_value,
575 l_asset_fin_rec.salvage_value
576 from fa_books
577 where asset_id = px_asset_hdr_rec.asset_id
578 and book_type_code = fa_cache_pkg.fazcbc_record.distribution_source_book
579 and transaction_header_id_in = l_corp_thid;
580
581 if (nvl(fa_cache_pkg.fazcbc_record.copy_group_assignment_flag, 'N') = 'N') then
582 l_asset_fin_rec.group_asset_id := null;
583 end if;
584
585 if (nvl(fa_cache_pkg.fazcbc_record.copy_salvage_value_flag, 'NO') = 'NO') then
586 l_asset_fin_rec.salvage_type := null;
587 l_asset_fin_rec.percent_salvage_value := null;
588 l_asset_fin_rec.salvage_value := null;
589 end if;
590
591 FA_ADDITION_PUB.do_addition
592 ( p_api_version => 1.0,
593 p_init_msg_list => FND_API.G_FALSE,
594 p_commit => FND_API.G_FALSE,
595 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
596 x_return_status => l_return_status,
597 x_msg_count => l_mesg_count,
598 x_msg_data => l_mesg,
599 p_calling_fn => null,
600 px_trans_rec => l_trans_rec,
601 px_dist_trans_rec => l_dist_trans_rec,
602 px_asset_hdr_rec => l_asset_hdr_rec,
603 px_asset_desc_rec => l_asset_desc_rec,
604 px_asset_type_rec => l_asset_type_rec,
605 px_asset_cat_rec => l_asset_cat_rec,
606 px_asset_hierarchy_rec => l_asset_hierarchy_rec,
607 px_asset_fin_rec => l_asset_fin_rec,
608 px_asset_deprn_rec => l_asset_deprn_rec,
609 px_asset_dist_tbl => l_asset_dist_tbl,
610 px_inv_tbl => l_inv_tbl
611 );
612
613 if (l_return_status <> FND_API.G_RET_STS_SUCCESS) then
614 raise cap_rev_err;
615 end if;
616
617 end if;
618 -- end bugfix# 5155488
619 else
620
621 -- cache the book information for the tax book
622 if (NOT fa_cache_pkg.fazcbc(X_book => l_tax_book_tbl(l_tax_index))) then
623 raise cap_rev_err;
624 end if;
625
626 -- NOTE!!!!
627 -- May need to set the transaction date, trx_type, subtype here as well
628 -- based on the open period and settings for each tax book in the loop
629
630 l_asset_hdr_rec.book_type_code := l_tax_book_tbl(l_tax_index);
631 l_asset_hdr_rec.set_of_books_id := fa_cache_pkg.fazcbc_record.set_of_books_id;
632
633 l_trans_rec.source_transaction_header_id := px_trans_rec.transaction_header_id;
634 l_trans_rec.mass_reference_id := px_trans_rec.mass_reference_id;
635 l_trans_rec.transaction_header_id := null;
636
637 -- BUG# 2623092
638 -- need to reset trx_type here in order to process tax book
639 -- in period of addition
640
641 if p_cap_rev = 'CAPITALIZE' then
642 l_trans_rec.transaction_type_code := 'ADDITION';
643 elsif p_cap_rev = 'REVERSE' then
644 l_trans_rec.transaction_type_code := 'CIP REVERSE';
645 end if;
646 l_asset_fin_rec.date_placed_in_service := px_asset_fin_rec.date_placed_in_service;
647
648 -- set the gl sob info for the primary tax book
649 fnd_profile.put('GL_SET_OF_BKS_ID', l_asset_hdr_rec.set_of_books_id);
650 fnd_client_info.set_currency_context (l_asset_hdr_rec.set_of_books_id);
651
652 if not do_all_books
653 (px_trans_rec => l_trans_rec, -- tax
654 px_asset_hdr_rec => l_asset_hdr_rec, -- tax
655 p_asset_desc_rec => l_asset_desc_rec,
656 px_asset_type_rec => l_asset_type_rec,
657 p_asset_cat_rec => l_asset_cat_rec,
658 px_asset_fin_rec => l_asset_fin_rec
659 ,p_log_level_rec => p_log_level_rec) then
660 raise cap_rev_err;
661 end if;
662
663 end if; -- exists in tax book
664
665 end loop; -- tax books
666
667 end if; -- corporate book
668
669 x_return_status := FND_API.G_RET_STS_SUCCESS;
670
671 return TRUE;
672
673 EXCEPTION
674
675 when cap_rev_err then
676 ROLLBACK TO do_cap_rev;
677
678 fnd_profile.put('GL_SET_OF_BKS_ID', l_orig_set_of_books_id);
679 fnd_client_info.set_currency_context (l_orig_currency_context);
680
681 fa_srvr_msg.add_message(calling_fn => l_calling_fn
682 ,p_log_level_rec => p_log_level_rec);
683
684 x_return_status := FND_API.G_RET_STS_ERROR;
685
686 return FALSE;
687
688 when others then
689 ROLLBACK TO do_cap_rev;
690
691 fnd_profile.put('GL_SET_OF_BKS_ID', l_orig_set_of_books_id);
692 fnd_client_info.set_currency_context (l_orig_currency_context);
693
694 fa_srvr_msg.add_sql_error(calling_fn => l_calling_fn
695 ,p_log_level_rec => p_log_level_rec);
696
697 x_return_status := FND_API.G_RET_STS_ERROR;
698
699 return FALSE;
700
701 END do_cap_rev;
702
703 -------------------------------------------------------------------------------
704
705 FUNCTION do_all_books
706 (px_trans_rec IN OUT NOCOPY FA_API_TYPES.trans_rec_type,
707 px_asset_hdr_rec IN OUT NOCOPY FA_API_TYPES.asset_hdr_rec_type,
708 p_asset_desc_rec IN FA_API_TYPES.asset_desc_rec_type,
709 px_asset_type_rec IN OUT NOCOPY FA_API_TYPES.asset_type_rec_type,
710 p_asset_cat_rec IN FA_API_TYPES.asset_cat_rec_type,
711 px_asset_fin_rec IN OUT NOCOPY FA_API_TYPES.asset_fin_rec_type,
712 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) RETURN BOOLEAN IS
713
714 -- used for calling private api for reporting books
715 l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
716 l_asset_fin_rec FA_API_TYPES.asset_fin_rec_type;
717 l_asset_fin_rec_old FA_API_TYPES.asset_fin_rec_type;
718
719 -- used for retrieving "new" structs from private api calls
720 l_reporting_flag varchar2(1);
721 l_period_rec FA_API_TYPES.period_rec_type;
722 l_sob_tbl FA_CACHE_PKG.fazcrsob_sob_tbl_type;
723
724 -- used for get_rate
725 l_exchange_date date;
726 l_rate number;
727 l_result_code varchar2(15);
728 l_exchange_rate number;
729 l_avg_rate number;
730
731 l_complete varchar2(1);
732 l_result_code1 varchar2(15);
733
734 l_transaction_date date;
735 l_date_placed_in_service date;
736
737 -- used for new group code
738 l_group_trans_rec fa_api_types.trans_rec_type;
739 l_group_asset_hdr_rec fa_api_types.asset_hdr_rec_type;
740 l_group_asset_desc_rec fa_api_types.asset_desc_rec_type;
741 l_group_asset_type_rec fa_api_types.asset_type_rec_type;
742 l_group_asset_cat_rec fa_api_types.asset_cat_rec_type;
743 l_group_asset_fin_rec_old fa_api_types.asset_fin_rec_type;
744 l_group_asset_fin_rec_adj fa_api_types.asset_fin_rec_type;
745 l_group_asset_fin_rec_new fa_api_types.asset_fin_rec_type;
746 l_group_asset_deprn_rec_old fa_api_types.asset_deprn_rec_type;
747 l_group_asset_deprn_rec_adj fa_api_types.asset_deprn_rec_type;
748 l_group_asset_deprn_rec_new fa_api_types.asset_deprn_rec_type;
749 l_inv_trans_rec fa_api_types.inv_trans_rec_type;
750 l_group_reclass_options_rec fa_api_types.group_reclass_options_rec_type;
751
752 l_calling_fn varchar2(30) := 'fa_cip_pub.do_all_books';
753 cap_rev_err EXCEPTION;
754
755 BEGIN
756
757 -- call the category cache used for faxinajc calls
758 if not fa_cache_pkg.fazccb
759 (X_book => px_asset_hdr_rec.book_type_code,
760 X_cat_id => p_asset_cat_rec.category_id
761 ,p_log_level_rec => p_log_level_rec) then
762 raise cap_rev_err;
763 end if;
764
765 -- call transaction approval
766 if not FA_TRX_APPROVAL_PKG.faxcat
767 (X_book => px_asset_hdr_rec.book_type_code,
768 X_asset_id => px_asset_hdr_rec.asset_id,
769 X_trx_type => px_trans_rec.transaction_type_code,
770 X_trx_date => px_trans_rec.transaction_date_entered,
771 X_init_message_flag => 'NO'
772 ,p_log_level_rec => p_log_level_rec) then
773 raise cap_rev_err;
774 end if;
775
776 -- load the period struct for current period info
777 if not FA_UTIL_PVT.get_period_rec
778 (p_book => px_asset_hdr_rec.book_type_code,
779 p_effective_date => NULL,
780 x_period_rec => l_period_rec
781 ,p_log_level_rec => p_log_level_rec) then
782 raise cap_rev_err;
783 end if;
784
785 -- check if this is the period of addition - use absolute mode for adjustments
786 if not FA_ASSET_VAL_PVT.validate_period_of_addition
787 (p_asset_id => px_asset_hdr_rec.asset_id,
788 p_book => px_asset_hdr_rec.book_type_code,
789 p_mode => 'ABSOLUTE',
790 px_period_of_addition => px_asset_hdr_rec.period_of_addition
791 ,p_log_level_rec => p_log_level_rec) then
792 raise cap_rev_err;
793 end if;
794
795 -- Bugfix #4904281
796 if(px_asset_fin_rec.date_placed_in_service is null) then
797 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
798 l_date_placed_in_service := greatest(l_period_rec.calendar_period_open_date,
799 least(sysdate,l_period_rec.calendar_period_close_date));
800
801 px_asset_fin_rec.date_placed_in_service :=
802 to_date(to_char(l_date_placed_in_service,'DD/MM/YYYY'),'DD/MM/YYYY');
803 end if;
804 end if;
805 -- End Bugfix
806 -- Default transaction_date_entered
807 if ((px_trans_rec.transaction_date_entered is null) and
808 (px_asset_fin_rec.date_placed_in_service is null)) then
809
810 if (fa_cache_pkg.fazcbc_record.book_class = 'CORPORATE') then
811 -- Default to last day of the period
812 l_transaction_date := greatest(l_period_rec.calendar_period_open_date,
813 least(sysdate,l_period_rec.calendar_period_close_date));
814 px_trans_rec.transaction_date_entered :=
815 to_date(to_char(l_transaction_date,'DD/MM/YYYY'),'DD/MM/YYYY');
816 end if;
817
818 elsif ((px_trans_rec.transaction_date_entered is null) and
819 (px_asset_fin_rec.date_placed_in_service is not null)) then
820 px_trans_rec.transaction_date_entered :=
821 px_asset_fin_rec.date_placed_in_service;
822 end if;
823
824
825 -- remove any time stamps from both dates:
826 px_trans_rec.transaction_date_entered :=
827 to_date(to_char(px_trans_rec.transaction_date_entered,'DD/MM/YYYY'),'DD/MM/YYYY');
828
829 px_asset_fin_rec.date_placed_in_service :=
830 to_date(to_char(px_asset_fin_rec.date_placed_in_service,'DD/MM/YYYY'),'DD/MM/YYYY');
831
832
833 -- defaulting within calc engine has been removed for group
834 -- explicitly overirde the related fields here
835 -- NOTE: not overiding salvage /limit info here
836 --
837 -- l_asset_fin_rec_old := NULL;
838
839
840 if not fa_cache_pkg.fazccbd (X_book => px_asset_hdr_rec.book_type_code,
841 X_cat_id => p_asset_cat_rec.category_id,
842 X_jdpis => to_number(to_char(px_asset_fin_rec.date_placed_in_service, 'J'))) then
843 raise cap_rev_err;
844 end if;
845
846 px_asset_fin_rec.deprn_method_code := fa_cache_pkg.fazccbd_record.deprn_method;
847 px_asset_fin_rec.life_in_months := fa_cache_pkg.fazccbd_record.life_in_months;
848 px_asset_fin_rec.basic_rate := fa_cache_pkg.fazccbd_record.basic_rate;
849 px_asset_fin_rec.adjusted_rate := fa_cache_pkg.fazccbd_record.adjusted_rate;
850 px_asset_fin_rec.prorate_convention_code := fa_cache_pkg.fazccbd_record.prorate_convention_code;
851 px_asset_fin_rec.depreciate_flag := fa_cache_pkg.fazccbd_record.depreciate_flag;
852 px_asset_fin_rec.bonus_rule := fa_cache_pkg.fazccbd_record.bonus_rule;
853 px_asset_fin_rec.ceiling_name := fa_cache_pkg.fazccbd_record.ceiling_name;
854 px_asset_fin_rec.production_capacity := fa_cache_pkg.fazccbd_record.production_capacity;
855 px_asset_fin_rec.unit_of_measure := fa_cache_pkg.fazccbd_record.unit_of_measure;
856
857 -- call the sob cache to get the table of sob_ids
858 if not FA_CACHE_PKG.fazcrsob
859 (x_book_type_code => px_asset_hdr_rec.book_type_code,
860 x_sob_tbl => l_sob_tbl
861 ,p_log_level_rec => p_log_level_rec) then
862 raise cap_rev_err;
863 end if;
864
865 -- set up the local asset_header and sob_id
866 l_asset_hdr_rec := px_asset_hdr_rec;
867
868
869 -- loop through each book starting with the primary and
870 -- call the private API for each
871
872 FOR l_sob_index in 0..l_sob_tbl.count LOOP
873
874 --clear out the fin rec
875 l_asset_fin_rec := NULL;
876 l_asset_fin_rec.date_placed_in_service := px_asset_fin_rec.date_placed_in_service;
877
878 -- BUG 4553782
879 l_asset_fin_rec.deprn_method_code := px_asset_fin_rec.deprn_method_code;
880 l_asset_fin_rec.life_in_months := px_asset_fin_rec.life_in_months;
881 l_asset_fin_rec.basic_rate := px_asset_fin_rec.basic_rate;
882 l_asset_fin_rec.adjusted_rate := px_asset_fin_rec.adjusted_rate;
883 l_asset_fin_rec.prorate_convention_code := px_asset_fin_rec.prorate_convention_code;
884 l_asset_fin_rec.depreciate_flag := px_asset_fin_rec.depreciate_flag;
885 l_asset_fin_rec.bonus_rule := px_asset_fin_rec.bonus_rule;
886 l_asset_fin_rec.ceiling_name := px_asset_fin_rec.ceiling_name;
887 l_asset_fin_rec.production_capacity := px_asset_fin_rec.production_capacity;
888 l_asset_fin_rec.unit_of_measure := px_asset_fin_rec.unit_of_measure;
889 -- END BUG
890
891 if (l_sob_index = 0) then
892 l_reporting_flag := 'P';
893 px_trans_rec.transaction_date_entered := px_asset_fin_rec.date_placed_in_service;
894 else
895 l_reporting_flag := 'R';
896 l_asset_hdr_rec.set_of_books_id := l_sob_tbl(l_sob_index);
897
898 -- set the sob_id and currency context
899 fnd_profile.put('GL_SET_OF_BKS_ID', l_sob_tbl(l_sob_index));
900 fnd_client_info.set_currency_context (to_char(l_sob_tbl(l_sob_index)));
901
902 end if;
903
904
905 -- call the cache to set the sob_id used for rounding and other lower
906 -- level code for each book.
907 if NOT fa_cache_pkg.fazcbcs(X_book => px_asset_hdr_rec.book_type_code
908 ,p_log_level_rec => p_log_level_rec) then
909 raise cap_rev_err;
910 end if;
911
912 -- load the old structs
913 if not FA_UTIL_PVT.get_asset_fin_rec
914 (p_asset_hdr_rec => px_asset_hdr_rec,
915 px_asset_fin_rec => l_asset_fin_rec_old,
916 p_transaction_header_id => NULL,
917 p_mrc_sob_type_code => l_reporting_flag
918 ,p_log_level_rec => p_log_level_rec) then
919 raise cap_rev_err;
920 end if;
921
922 --HH Validate disabled_flag
923 if not FA_ASSET_VAL_PVT.validate_disabled_flag
924 (p_group_asset_id => px_asset_hdr_rec.asset_id,
925 p_book_type_code => px_asset_hdr_rec.book_type_code,
926 p_old_flag => l_asset_fin_rec_old.disabled_flag,
927 p_new_flag => l_asset_fin_rec_old.disabled_flag
928 ,p_log_level_rec => p_log_level_rec) then
929 raise cap_rev_err;
930 end if; --End HH
931
932 -- main private api
933 if not fa_cip_pvt.do_cap_rev
934 (px_trans_rec => px_trans_rec,
935 p_asset_hdr_rec => px_asset_hdr_rec,
936 p_asset_desc_rec => p_asset_desc_rec,
937 p_asset_cat_rec => p_asset_cat_rec,
938 px_asset_type_rec => px_asset_type_rec,
939 p_asset_fin_rec_old => l_asset_fin_rec_old,
940 px_asset_fin_rec => l_asset_fin_rec,
941 p_period_rec => l_period_rec,
942 p_mrc_sob_type_code => l_reporting_flag
943 ,p_log_level_rec => p_log_level_rec) then
944 raise cap_rev_err;
945 end if;
946
947 if (l_sob_index <> 0) then
948
949 if px_asset_hdr_rec.period_of_addition = 'N' then
950 if (px_asset_fin_rec.cost <> 0) then
951 l_avg_rate := l_asset_fin_rec_old.cost /
952 px_asset_fin_rec.cost;
953 else
954 select br1.avg_exchange_rate
955 into l_avg_rate
956 from fa_mc_books_rates br1
957 where br1.asset_id = l_asset_hdr_rec.asset_id
958 and br1.book_type_code = l_asset_hdr_rec.book_type_code
959 and br1.set_of_books_id = l_asset_hdr_rec.set_of_books_id
960 and br1.transaction_header_id =
961 (select max(br2.transaction_header_id)
962 from fa_mc_books_rates br2
963 where br2.asset_id = l_asset_hdr_rec.asset_id
964 and br2.book_type_code = l_asset_hdr_rec.book_type_code
965 and br2.set_of_books_id = l_asset_hdr_rec.set_of_books_id);
966 end if;
967
968 l_exchange_rate := l_avg_rate;
969
970 -- insert the books_rates record
971
972 MC_FA_UTILITIES_PKG.insert_books_rates
973 (p_set_of_books_id => l_asset_hdr_rec.set_of_books_id,
974 p_asset_id => l_asset_hdr_rec.asset_id,
975 p_book_type_code => l_asset_hdr_rec.book_type_code,
976 p_transaction_header_id => px_trans_rec.transaction_header_id,
977 p_invoice_transaction_id => null,
978 p_exchange_date => px_trans_rec.transaction_date_entered, -- ??? dpis
979 p_cost => 0,
980 p_exchange_rate => l_exchange_rate,
981 p_avg_exchange_rate => l_avg_rate,
982 p_last_updated_by => px_trans_rec.who_info.last_updated_by,
983 p_last_update_date => px_trans_rec.who_info.last_update_date,
984 p_last_update_login => px_trans_rec.who_info.last_update_login,
985 p_complete => 'Y',
986 p_trigger => 'l_calling_fn',
987 p_currency_code => l_asset_hdr_rec.set_of_books_id
988 ,p_log_level_rec => p_log_level_rec);
989
990 end if; -- period of addition
991
992 end if; -- reporting book
993
994
995 -- GROUP API CALL
996 -- this will be called once passing both primary and reporting info
997 -- to adjust primary and reporting books for the group
998
999 if (l_asset_fin_rec_old.group_asset_id is not null) then
1000
1001 -- set up the group recs
1002 l_group_asset_hdr_rec := l_asset_hdr_rec;
1003 l_group_asset_hdr_rec.asset_id := l_asset_fin_rec_old.group_asset_id;
1004 l_group_trans_rec := px_trans_rec; -- will set the amort start date
1005
1006 if (l_reporting_flag <> 'R') then
1007
1008 if not FA_UTIL_PVT.get_asset_desc_rec
1009 (p_asset_hdr_rec => l_group_asset_hdr_rec,
1010 px_asset_desc_rec => l_group_asset_desc_rec
1011 ,p_log_level_rec => p_log_level_rec) then
1012 raise cap_rev_err;
1013 end if;
1014
1015 if not FA_UTIL_PVT.get_asset_cat_rec
1016 (p_asset_hdr_rec => l_group_asset_hdr_rec,
1017 px_asset_cat_rec => l_group_asset_cat_rec,
1018 p_date_effective => null
1019 ,p_log_level_rec => p_log_level_rec) then
1020 raise cap_rev_err;
1021 end if;
1022
1023 if not FA_UTIL_PVT.get_asset_type_rec
1024 (p_asset_hdr_rec => l_group_asset_hdr_rec,
1025 px_asset_type_rec => l_group_asset_type_rec,
1026 p_date_effective => null
1027 ,p_log_level_rec => p_log_level_rec) then
1028 raise cap_rev_err;
1029 end if;
1030
1031 if not FA_ASSET_VAL_PVT.validate_period_of_addition
1032 (p_asset_id => l_group_asset_hdr_rec.asset_id,
1033 p_book => l_group_asset_hdr_rec.book_type_code,
1034 p_mode => 'ABSOLUTE',
1035 px_period_of_addition => l_group_asset_hdr_rec.period_of_addition
1036 ,p_log_level_rec => p_log_level_rec) then
1037 raise cap_rev_err;
1038 end if;
1039
1040 l_group_trans_rec.transaction_type_code := 'GROUP ADJUSTMENT';
1041 l_group_trans_rec.member_transaction_header_id := px_trans_rec.transaction_header_id;
1042
1043 if (NOT fa_trx_approval_pkg.faxcat
1044 (X_book => l_group_asset_hdr_rec.book_type_code,
1045 X_asset_id => l_group_asset_hdr_rec.asset_id,
1046 X_trx_type => l_group_trans_rec.transaction_type_code,
1047 X_trx_date => l_group_trans_rec.transaction_date_entered,
1048 X_init_message_flag => 'NO'
1049 ,p_log_level_rec => p_log_level_rec)) then
1050 raise cap_rev_err;
1051 end if;
1052
1053 -- use dpis as amort start
1054 l_group_trans_rec.transaction_subtype := 'AMORTIZED';
1055 l_group_trans_rec.amortization_start_date := l_asset_fin_rec.date_placed_in_service;
1056
1057 select fa_transaction_headers_s.nextval
1058 into l_group_trans_rec.transaction_header_id
1059 from dual;
1060
1061 end if;
1062
1063 -- load the old structs
1064 if not FA_UTIL_PVT.get_asset_fin_rec
1065 (p_asset_hdr_rec => l_group_asset_hdr_rec,
1066 px_asset_fin_rec => l_group_asset_fin_rec_old,
1067 p_transaction_header_id => NULL,
1068 p_mrc_sob_type_code => l_reporting_flag
1069 ,p_log_level_rec => p_log_level_rec) then raise cap_rev_err;
1070 end if;
1071
1072 --HH Validate disabled_flag
1073 --No trx on a disabled group.
1074 if not FA_ASSET_VAL_PVT.validate_disabled_flag
1075 (p_group_asset_id => l_group_asset_hdr_rec.asset_id,
1076 p_book_type_code => l_group_asset_hdr_rec.book_type_code,
1077 p_old_flag => l_group_asset_fin_rec_old.disabled_flag,
1078 p_new_flag => l_group_asset_fin_rec_old.disabled_flag
1079 ,p_log_level_rec => p_log_level_rec) then
1080 raise cap_rev_err;
1081 end if; --End HH
1082
1083 if not FA_UTIL_PVT.get_asset_deprn_rec
1084 (p_asset_hdr_rec => l_group_asset_hdr_rec ,
1085 px_asset_deprn_rec => l_group_asset_deprn_rec_old,
1086 p_period_counter => NULL,
1087 p_mrc_sob_type_code => l_reporting_flag
1088 ,p_log_level_rec => p_log_level_rec) then raise cap_rev_err;
1089 end if;
1090
1091 -- need to account for portion of cip_cost that may already have been
1092 -- in group's basis:
1093
1094 if (px_asset_type_rec.asset_type = 'CAPITALIZED') then -- originally cip
1095 l_group_asset_fin_rec_adj.cip_cost := -l_asset_fin_rec_old.cip_cost;
1096 l_group_asset_fin_rec_adj.cost := l_asset_fin_rec_old.cip_cost;
1097 l_group_trans_rec.transaction_key := 'MC';
1098 l_group_asset_fin_rec_adj.salvage_value := nvl(l_asset_fin_rec_old.salvage_value,0);--bug# 4129999
1099 else
1100 l_group_asset_fin_rec_adj.cip_cost := l_asset_fin_rec_old.cip_cost;
1101 l_group_asset_fin_rec_adj.cost := -l_asset_fin_rec_old.cip_cost;
1102 l_group_trans_rec.transaction_key := 'MV';
1103 end if;
1104
1105 if not FA_ADJUSTMENT_PVT.do_adjustment
1106 (px_trans_rec => l_group_trans_rec,
1107 px_asset_hdr_rec => l_group_asset_hdr_rec,
1108 p_asset_desc_rec => l_group_asset_desc_rec,
1109 p_asset_type_rec => l_group_asset_type_rec,
1110 p_asset_cat_rec => l_group_asset_cat_rec,
1111 p_asset_fin_rec_old => l_group_asset_fin_rec_old,
1112 p_asset_fin_rec_adj => l_group_asset_fin_rec_adj,
1113 x_asset_fin_rec_new => l_group_asset_fin_rec_new,
1114 p_inv_trans_rec => l_inv_trans_rec,
1115 p_asset_deprn_rec_old => l_group_asset_deprn_rec_old,
1116 p_asset_deprn_rec_adj => l_group_asset_deprn_rec_adj,
1117 x_asset_deprn_rec_new => l_group_asset_deprn_rec_new,
1118 p_period_rec => l_period_rec,
1119 p_mrc_sob_type_code => l_reporting_flag,
1120 p_group_reclass_options_rec =>l_group_reclass_options_rec,
1121 p_calling_fn => 'fa_addition_pub.do_addition'
1122 ,p_log_level_rec => p_log_level_rec)then
1123 raise cap_rev_err;
1124 end if; -- do_adjustment
1125 end if; -- group asset id not null
1126
1127 end loop;
1128
1129 -- set the gl sob info back to the primary book so fazcbc cache is ok
1130 fnd_profile.put('GL_SET_OF_BKS_ID', px_asset_hdr_rec.set_of_books_id);
1131 fnd_client_info.set_currency_context (px_asset_hdr_rec.set_of_books_id);
1132
1133 return true;
1134
1135 EXCEPTION
1136
1137 WHEN CAP_REV_ERR THEN
1138 fa_srvr_msg.add_message(calling_fn => l_calling_fn
1139 ,p_log_level_rec => p_log_level_rec);
1140 return FALSE;
1141
1142 WHEN OTHERS THEN
1143 fa_srvr_msg.add_sql_error(CALLING_FN => l_calling_fn
1144 ,p_log_level_rec => p_log_level_rec);
1145 return FALSE;
1146
1147 END do_all_books;
1148
1149 -----------------------------------------------------------------------------
1150
1151 END FA_CIP_PUB;