[Home] [Help]
PACKAGE BODY: APPS.FA_INS_DETAIL_PKG
Source
1 PACKAGE BODY FA_INS_DETAIL_PKG as
2 /* $Header: FAXINDDB.pls 120.7.12010000.4 2009/02/25 01:22:28 bmaddine ship $ */
3
4 --
5 -- FUNCTION faxindd
6 --
7
8 g_print_debug boolean := fa_cache_pkg.fa_print_debug;
9
10 FUNCTION faxindd (X_book_type_code VARCHAR2,
11 X_asset_id NUMBER,
12 X_period_counter NUMBER := NULL,
13 X_cost NUMBER := NULL,
14 X_deprn_reserve NUMBER := NULL,
15 /* Bug 525654 Modification */
16 X_deprn_adjustment_amount NUMBER := NULL,
17 X_reval_reserve NUMBER := NULL,
18 X_ytd NUMBER := NULL,
19 X_ytd_reval_dep_exp NUMBER := NULL,
20 X_bonus_ytd NUMBER := NULL,
21 X_bonus_deprn_reserve NUMBER := NULL,
22 X_init_message_flag VARCHAR2 DEFAULT 'NO',
23 X_mrc_sob_type_code VARCHAR2,
24 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
25
26 return BOOLEAN is
27
28 h_dpr_dtl fa_std_types.dpr_dtl_row_struct;
29 h_ytd NUMBER;
30 h_deprn_reserve NUMBER;
31
32 /* Bug 525654 Modification */
33 h_deprn_adjustment_amount NUMBER;
34 h_reval_reserve NUMBER;
35 h_ytd_reval_dep_exp NUMBER;
36 h_period_counter NUMBER;
37 h_cost NUMBER;
38
39 h_bonus_ytd NUMBER;
40 h_bonus_deprn_reserve NUMBER;
41
42 h_msg_name VARCHAR2(30) := NULL;
43
44 BEGIN
45
46 IF (X_init_message_flag = 'YES') THEN
47 FA_SRVR_MSG.INIT_SERVER_MESSAGE; /* init server msg stack */
48 fa_debug_pkg.initialize; /* init debug msg stack */
49 END IF;
50
51 IF (X_book_type_code IS NULL) OR (X_asset_id IS NULL) THEN
52 FA_SRVR_MSG.add_message(
53 CALLING_FN => 'FA_INS_DETAIL_PKG.faxindd',
54 NAME => 'FA_SHARED_ARGUMENTS'
55 ,p_log_level_rec => p_log_level_rec);
56 return(FALSE);
57 END IF;
58
59 h_dpr_dtl.book := X_book_type_code;
60 h_dpr_dtl.asset_id := X_asset_id;
61
62
63 IF (X_cost IS NULL OR
64 X_deprn_reserve IS NULL OR
65 X_reval_reserve IS NULL OR
66 X_ytd IS NULL OR
67 X_ytd_reval_dep_exp IS NULL OR
68 X_period_counter IS NULL OR
69 X_bonus_ytd IS NULL OR
70 X_bonus_deprn_reserve IS NULL) THEN
71
72
73 if (X_mrc_sob_type_code = 'R') then
74
75 h_msg_name := 'FA_DD_DEP_SUM';
76
77 SELECT ytd_deprn, deprn_reserve,
78 reval_reserve, ytd_reval_deprn_expense,
79 bonus_ytd_deprn, bonus_deprn_reserve,
80 period_counter
81 INTO h_ytd,
82 h_deprn_reserve,
83 h_reval_reserve,
84 h_ytd_reval_dep_exp,
85 h_bonus_ytd,
86 h_bonus_deprn_reserve,
87 h_period_counter
88 FROM fa_deprn_summary_mrc_v
89 WHERE book_type_code = X_book_type_code
90 AND asset_id = X_asset_id
91 AND deprn_source_code = 'BOOKS';
92
93 h_msg_name := 'FA_DD_BOOKS';
94
95 SELECT decode(ad.asset_type,
96 'GROUP', 0,
97 bk.cost)
98 INTO h_cost
99 FROM FA_BOOKS_MRC_V bk,
100 FA_ADDITIONS_B ad
101 WHERE ad.asset_id = X_asset_id
102 AND ad.asset_id = bk.asset_id
103 AND bk.book_type_code = X_book_type_code
104 and bk.transaction_header_id_out is null;
105
106 else
107
108 h_msg_name := 'FA_DD_DEP_SUM';
109
110 SELECT ytd_deprn, deprn_reserve,
111 reval_reserve, ytd_reval_deprn_expense,
112 bonus_ytd_deprn, bonus_deprn_reserve,
113 period_counter
114 INTO h_ytd,
115 h_deprn_reserve,
116 h_reval_reserve,
117 h_ytd_reval_dep_exp,
118 h_bonus_ytd,
119 h_bonus_deprn_reserve,
120 h_period_counter
121 FROM fa_deprn_summary
122 WHERE book_type_code = X_book_type_code
123 AND asset_id = X_asset_id
124 AND deprn_source_code = 'BOOKS';
125
126 h_msg_name := 'FA_DD_BOOKS';
127
128 SELECT decode(ad.asset_type,
129 'GROUP', 0,
130 bk.cost)
131 INTO h_cost
132 FROM FA_BOOKS bk,
133 FA_ADDITIONS_B ad
134 WHERE ad.asset_id = X_asset_id
135 AND ad.asset_id = bk.asset_id
136 AND bk.book_type_code = X_book_type_code
137 and bk.transaction_header_id_out is null;
138
139 end if; -- end sob_id
140
141 h_msg_name := NULL;
142 if (g_print_debug) then
143 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','deprn_summary values:',''
144 ,p_log_level_rec => p_log_level_rec);
145 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_deprn',h_ytd
146 ,p_log_level_rec => p_log_level_rec);
147 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','deprn_reserve',h_deprn_reserve
148 ,p_log_level_rec => p_log_level_rec);
149 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','reval_reserve',h_reval_reserve
150 ,p_log_level_rec => p_log_level_rec);
151 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_reval_deprn_expense',h_ytd_reval_dep_exp
152 ,p_log_level_rec => p_log_level_rec);
153 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','period_counter',h_period_counter
154 ,p_log_level_rec => p_log_level_rec);
155 end if;
156
157 END IF;
158
159
160 /* Bug 525654 Modification */
161
162 IF X_deprn_adjustment_amount IS NULL THEN
163
164 if (X_mrc_sob_type_code ='R') then
165
166 SELECT sum(nvl(deprn_adjustment_amount,0))
167 INTO h_deprn_adjustment_amount
168 FROM fa_deprn_detail_mrc_v
169 WHERE book_type_code = X_book_type_code
170 AND asset_id = X_asset_id
171 AND deprn_source_code = 'B';
172
173 else
174
175 SELECT sum(nvl(deprn_adjustment_amount,0))
176 INTO h_deprn_adjustment_amount
177 FROM fa_deprn_detail
178 WHERE book_type_code = X_book_type_code
179 AND asset_id = X_asset_id
180 AND deprn_source_code = 'B';
181
182 end if;
183 END IF;
184
185
186 IF (X_cost IS NOT NULL) THEN
187 h_dpr_dtl.cost := X_cost;
188 ELSE
189 h_dpr_dtl.cost := h_cost;
190 END IF;
191
192 IF (X_ytd IS NOT NULL) THEN
193 h_dpr_dtl.ytd := X_ytd;
194 ELSE
195 h_dpr_dtl.ytd := h_ytd;
196 END IF;
197
198 IF (X_deprn_reserve IS NOT NULL) THEN
199 h_dpr_dtl.deprn_reserve := X_deprn_reserve;
200 ELSE
201 h_dpr_dtl.deprn_reserve := h_deprn_reserve;
202 END IF;
203
204 /* Bug 525654 Modification */
205 IF (X_deprn_adjustment_amount IS NOT NULL) THEN
206 h_dpr_dtl.deprn_adjustment_amount := X_deprn_adjustment_amount;
207 ELSE
208 h_dpr_dtl.deprn_adjustment_amount := h_deprn_adjustment_amount;
209 END IF;
210
211
212
213 IF (X_reval_reserve IS NOT NULL) THEN
214 h_dpr_dtl.reval_reserve := X_reval_reserve;
215 h_dpr_dtl.reval_rsv_flag := TRUE;
216 ELSE
217 IF (h_reval_reserve IS NULL) THEN
218 h_dpr_dtl.reval_reserve := 0;
219 h_dpr_dtl.reval_rsv_flag := FALSE;
220 ELSE
221 h_dpr_dtl.reval_reserve := h_reval_reserve;
222 h_dpr_dtl.reval_rsv_flag := TRUE;
223 END IF;
224 END IF;
225
226 IF (X_ytd_reval_dep_exp IS NOT NULL) THEN
227 h_dpr_dtl.ytd_reval_dep_exp := X_ytd_reval_dep_exp;
228 h_dpr_dtl.ytd_reval_dep_exp_flag := TRUE;
229 ELSE
230 IF (h_ytd_reval_dep_exp IS NULL) THEN
231 h_dpr_dtl.ytd_reval_dep_exp := 0;
232 h_dpr_dtl.ytd_reval_dep_exp_flag := FALSE;
233 ELSE
234 h_dpr_dtl.ytd_reval_dep_exp := h_ytd_reval_dep_exp;
235 h_dpr_dtl.ytd_reval_dep_exp_flag := TRUE;
236 END IF;
237 END IF;
238 IF (X_bonus_ytd IS NOT NULL) THEN
239 h_dpr_dtl.bonus_ytd := X_bonus_ytd;
240 ELSE
241 h_dpr_dtl.bonus_ytd := h_bonus_ytd;
242 END IF;
243
244 IF (X_bonus_deprn_reserve IS NOT NULL) THEN
245 h_dpr_dtl.bonus_deprn_reserve := X_bonus_deprn_reserve;
246 ELSE
247 h_dpr_dtl.bonus_deprn_reserve := h_bonus_deprn_reserve;
248 END IF;
249
250 h_dpr_dtl.period_counter := h_period_counter;
251
252 if (g_print_debug) then
253 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','values before call to fadpdtl',''
254 ,p_log_level_rec => p_log_level_rec);
255 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','cost',h_dpr_dtl.cost
256 ,p_log_level_rec => p_log_level_rec);
257 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_deprn',h_dpr_dtl.ytd
258 ,p_log_level_rec => p_log_level_rec);
259 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','deprn_reserve',h_dpr_dtl.deprn_reserve
260 ,p_log_level_rec => p_log_level_rec);
261 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','reval_reserve',h_dpr_dtl.reval_reserve
262 ,p_log_level_rec => p_log_level_rec);
263 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_reval_deprn_expense',h_dpr_dtl.ytd_reval_dep_exp
264 ,p_log_level_rec => p_log_level_rec);
265 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','period_counter',h_dpr_dtl.period_counter
266 ,p_log_level_rec => p_log_level_rec);
267 end if;
268
269 IF (NOT fadpdtl(X_dpr_dtl => h_dpr_dtl,
270 X_source_flag => TRUE,
271 X_mrc_sob_type_code => X_mrc_sob_type_code
272 ,p_log_level_rec => p_log_level_rec)) THEN
273 FA_SRVR_MSG.add_message (
274 CALLING_FN => 'FA_INS_DETAIL_PKG.faxindd'
275 ,p_log_level_rec => p_log_level_rec);
276 return(FALSE);
277 END IF;
278
279 return(TRUE);
280
281 EXCEPTION
282
283 WHEN NO_DATA_FOUND then
284 FA_SRVR_MSG.add_message(
285 CALLING_FN => 'FA_INS_DETAIL_PKG.faxindd',
286 NAME => h_msg_name
287 ,p_log_level_rec => p_log_level_rec);
288 return FALSE;
289
290 WHEN OTHERS THEN
291 FA_SRVR_MSG.ADD_SQL_ERROR(
292 CALLING_FN => 'FA_INS_DETAIL_PKG.faxindd'
293 ,p_log_level_rec => p_log_level_rec);
294 return(FALSE);
295 END faxindd;
296
297
298 --
299 -- FUNCTION fadpdtl
300 --
301 FUNCTION fadpdtl(X_dpr_dtl FA_STD_TYPES.DPR_DTL_ROW_STRUCT,
302 X_source_flag BOOLEAN,
303 X_mrc_sob_type_code VARCHAR2,
304 p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null)
305 return BOOLEAN IS
306
307 h_book_type_code VARCHAR2(15);
308 h_asset_id NUMBER;
309 h_period_counter NUMBER;
310 h_dist_book VARCHAR2(15);
311 h_source_code VARCHAR2(1);
312
313 h_dist_id NUMBER;
314 h_units_assigned NUMBER;
315 h_sysdate DATE;
316 h_rec_count NUMBER := 0;
317 h_dist_count NUMBER := 0;
318 h_total_units NUMBER := 0;
319
320 h_sum_cost NUMBER := 0;
321 h_sum_ytd NUMBER := 0;
322 h_sum_deprn_reserve NUMBER := 0;
323
324 /* Bug 525654 Modification */
325
326 h_part_deprn_adjustment_amount NUMBER := 0;
327 h_sum_reval_reserve NUMBER := 0;
328 h_sum_ytd_reval_dep_exp NUMBER := 0;
329 h_sum_bonus_ytd NUMBER := 0;
330 h_sum_bonus_deprn_reserve NUMBER := 0;
331
332 h_part_cost NUMBER := 0;
333 h_part_ytd NUMBER := 0;
334 h_part_deprn_reserve NUMBER := 0;
335 h_part_reval_reserve NUMBER := 0;
336 h_part_ytd_reval_dep_exp NUMBER := 0;
337 h_part_bonus_ytd NUMBER := 0;
338 h_part_bonus_deprn_reserve NUMBER := 0;
339 h_msg_name VARCHAR2(30) := NULL;
340 ERROR_FOUND EXCEPTION;
341
342 CURSOR C1 IS
343 SELECT distribution_id, units_assigned
344 FROM fa_distribution_history
345 WHERE book_type_code = h_dist_book AND
346 asset_id = h_asset_id AND /* Bug 8237945 ... Since this is called only in Period of Addition,
347 and in Period of addition we always have to take
348 Distributions at the time of additions into consideration .*/
349 transaction_header_id_in = (SELECT TRANSACTION_HEADER_ID
350 FROM fa_transaction_headers
351 WHERE asset_id = h_asset_id
352 AND book_type_code = h_dist_book
353 AND transaction_type_code = 'TRANSFER IN')
354 -- date_ineffective IS NULL
355 ORDER BY distribution_id;
356
357 BEGIN
358
359 -- need to insure this is only called from faxindd and no other location!!!!
360
361 h_book_type_code := X_dpr_dtl.book;
362 h_asset_id := X_dpr_dtl.asset_id;
363 h_period_counter := X_dpr_dtl.period_counter;
364
365 h_msg_name := 'FA_SHARED_DATA_ERR_BC';
366
367 -- bug# 2140468 - use cache
368 h_dist_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
369
370 h_msg_name := 'FA_SHARED_DATA_ERR_DH';
371 /* Bug 8237945 ... Since this is called only in Period of Addition, and in Period of addition we always have to take Distributions at the time of additions into consideration . Commented dh.date_ineffective is null condition*/
372 /* Bug 8281792 ... We need to pass h_dist_book for book_type_code, since we can have a situation where we are using Tax Book and fa_distribution_history does not contain units. Also rewritten the query using EXISTS cluase*/
373 SELECT nvl(SUM(dh.units_assigned),0), COUNT(*)
374 INTO h_total_units, h_dist_count
375 FROM fa_distribution_history dh
376 WHERE dh.book_type_code = h_dist_book AND
377 dh.asset_id = h_asset_id AND
378 exists( SELECT 'X' FROM FA_TRANSACTION_HEADERS th
379 WHERE asset_id = h_asset_id and
380 book_type_code = h_dist_book and
381 dh.transaction_header_id_in = th.transaction_header_id and
382 th.transaction_type_code = 'TRANSFER IN');
383 -- dh.date_ineffective IS NULL;
384
385 IF (h_total_units = 0) THEN
386 FA_SRVR_MSG.add_message(
387 CALLING_FN => 'FA_INS_DETAIL_PKG.fadpdtl',
388 NAME => 'FA_SHARED_DATA_ERR_DH'
389 ,p_log_level_rec => p_log_level_rec);
390 return (FALSE);
391 END IF;
392
393 h_msg_name := NULL;
394
395 if X_mrc_sob_type_code = 'R' then
396 DELETE FROM fa_deprn_detail_mrc_v
397 WHERE book_type_code = h_book_type_code AND
398 asset_id = h_asset_id AND
399 period_counter = h_period_counter;
400 else
401 DELETE FROM fa_deprn_detail
402 WHERE book_type_code = h_book_type_code AND
403 asset_id = h_asset_id AND
404 period_counter = h_period_counter;
405 end if; -- end mrc
406
407
408 IF (SQL%NOTFOUND) THEN
409 null;
410 END IF;
411
412
413 IF (X_source_flag) THEN -- insert B row
414 h_source_code := 'B';
415
416 -- bug# 2180468 - for performance
417 -- select min(date_effective)
418 -- into h_sysdate
419 -- from fa_transaction_headers
420 -- where book_type_code = h_book_type_code and
421 -- asset_id = h_asset_id;
422
423 -- IF (SQL%NOTFOUND) THEN
424 h_sysdate := sysdate;
425 -- END IF;
426
427 ELSE
428 h_source_code := 'D'; -- insert D row
429 h_sysdate := sysdate;
430 END IF;
431
432 OPEN C1;
433
434 LOOP
435 h_units_assigned := 0;
436 h_dist_id := 0;
437
438 FETCH C1 INTO h_dist_id,
439 h_units_assigned;
440 EXIT WHEN C1%NOTFOUND;
441 if (g_print_debug) then
442 fa_debug_pkg.add('FA_INS_DETAIL_PKG.fadpdtl','values after the fetch',''
443 ,p_log_level_rec => p_log_level_rec);
444 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','dist_id',h_dist_id
445 ,p_log_level_rec => p_log_level_rec);
446 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','units_assigned',h_units_assigned
447 ,p_log_level_rec => p_log_level_rec);
448 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','total_units',h_total_units
449 ,p_log_level_rec => p_log_level_rec);
450 end if;
451
452 h_rec_count := h_rec_count + 1;
453
454 h_part_cost := (X_dpr_dtl.cost * h_units_assigned) / h_total_units;
455
456 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_cost,
457 X_book => h_dist_book
458 ,p_log_level_rec => p_log_level_rec)) THEN
459 raise ERROR_FOUND;
460 END IF;
461
462 h_part_ytd := (X_dpr_dtl.ytd * h_units_assigned) / h_total_units;
463
464 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_ytd,
465 X_book => h_dist_book
466 ,p_log_level_rec => p_log_level_rec)) THEN
467 raise ERROR_FOUND;
468 END IF;
469
470
471 /* Bug 525654 Modification */
472 h_part_deprn_adjustment_amount := ( X_dpr_dtl.deprn_adjustment_amount * h_units_assigned) / h_total_units;
473
474 h_part_deprn_reserve := (X_dpr_dtl.deprn_reserve * h_units_assigned) /
475 h_total_units;
476
477 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_deprn_reserve,
478 X_book => h_dist_book
479 ,p_log_level_rec => p_log_level_rec)) THEN
480 raise ERROR_FOUND;
481 END IF;
482
483 IF (X_dpr_dtl.reval_rsv_flag) THEN
484 h_part_reval_reserve := (X_dpr_dtl.reval_reserve * h_units_assigned) /
485 h_total_units;
486
487 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_reval_reserve,
488 X_book => h_dist_book
489 ,p_log_level_rec => p_log_level_rec)) THEN
490 raise ERROR_FOUND;
491 END IF;
492 ELSE
493 h_part_reval_reserve := NULL;
494 END IF;
495
496
497 IF (X_dpr_dtl.ytd_reval_dep_exp_flag) THEN
498 h_part_ytd_reval_dep_exp := (X_dpr_dtl.ytd_reval_dep_exp * h_units_assigned) /
499 h_total_units;
500
501 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_ytd_reval_dep_exp,
502 X_book => h_dist_book
503 ,p_log_level_rec => p_log_level_rec)) THEN
504 raise ERROR_FOUND;
505 END IF;
506 ELSE
507 h_part_ytd_reval_dep_exp := NULL;
508 END IF;
509
510 h_part_bonus_ytd := (X_dpr_dtl.bonus_ytd * h_units_assigned) /
511 h_total_units;
512
513 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_bonus_ytd,
514 X_book => h_dist_book
515 ,p_log_level_rec => p_log_level_rec)) THEN
516 raise ERROR_FOUND;
517 END IF;
518
519 h_part_bonus_deprn_reserve := (X_dpr_dtl.bonus_deprn_reserve * h_units_assigned) /
520 h_total_units;
521
522 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_bonus_deprn_reserve,
523 X_book => h_dist_book
524 ,p_log_level_rec => p_log_level_rec)) THEN
525 raise ERROR_FOUND;
526 END IF;
527
528 h_sum_cost := h_sum_cost + h_part_cost;
529 h_sum_ytd := h_sum_ytd + h_part_ytd;
530 h_sum_deprn_reserve := h_sum_deprn_reserve + h_part_deprn_reserve;
531 h_sum_bonus_ytd := h_sum_bonus_ytd + h_part_bonus_ytd;
532 h_sum_bonus_deprn_reserve := h_sum_bonus_deprn_reserve + h_part_bonus_deprn_reserve;
533
534 if (X_dpr_dtl.reval_rsv_flag) then
535 h_sum_reval_reserve := h_sum_reval_reserve + h_part_reval_reserve;
536 end if;
537 if (X_dpr_dtl.ytd_reval_dep_exp_flag) then
538 h_sum_ytd_reval_dep_exp := h_sum_ytd_reval_dep_exp +
539 h_part_ytd_reval_dep_exp;
540 end if;
541
542 IF (h_rec_count = h_dist_count) THEN
543 h_part_cost := h_part_cost + (X_dpr_dtl.cost - h_sum_cost);
544 h_part_ytd := h_part_ytd + (X_dpr_dtl.ytd - h_sum_ytd);
545 h_part_deprn_reserve := h_part_deprn_reserve +
546 (X_dpr_dtl.deprn_reserve - h_sum_deprn_reserve);
547 h_part_bonus_ytd := h_part_bonus_ytd + (X_dpr_dtl.bonus_ytd - h_sum_bonus_ytd);
548 h_part_bonus_deprn_reserve := h_part_bonus_deprn_reserve +
549 (X_dpr_dtl.bonus_deprn_reserve - h_sum_bonus_deprn_reserve);
550
551 if (X_dpr_dtl.reval_rsv_flag) then
552 h_part_reval_reserve := h_part_reval_reserve +
553 (X_dpr_dtl.reval_reserve - h_sum_reval_reserve);
554 end if;
555 if (X_dpr_dtl.ytd_reval_dep_exp_flag) then
556 h_part_ytd_reval_dep_exp := h_part_ytd_reval_dep_exp +
557 (X_dpr_dtl.ytd_reval_dep_exp - h_sum_ytd_reval_dep_exp);
558 end if;
559
560 END IF;
561
562 if (g_print_debug) then
563 fa_debug_pkg.add('FA_INS_DETAIL_PKG.fadpdtl','values before the insert to deprn_detail',''
564 ,p_log_level_rec => p_log_level_rec);
565 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','book',h_book_type_code
566 ,p_log_level_rec => p_log_level_rec);
567 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','asset_id',h_asset_id
568 ,p_log_level_rec => p_log_level_rec);
569 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','dist_id',h_dist_id
570 ,p_log_level_rec => p_log_level_rec);
571 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','source_code',h_source_code
572 ,p_log_level_rec => p_log_level_rec);
573 fa_debug_pkg.add('FA_INS_DETAIL_PKG.fadpdtl','period_counter',h_period_counter
574 ,p_log_level_rec => p_log_level_rec);
575 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_deprn',h_part_ytd
576 ,p_log_level_rec => p_log_level_rec);
577 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','deprn_reserve',h_part_deprn_reserve
578 ,p_log_level_rec => p_log_level_rec);
579 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','reval_reserve',h_part_reval_reserve
580 ,p_log_level_rec => p_log_level_rec);
581 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_reval_deprn_expense',h_part_ytd_reval_dep_exp
582 ,p_log_level_rec => p_log_level_rec);
583 end if;
584
585 if (X_mrc_sob_type_code = 'R') then
586 INSERT INTO fa_deprn_detail_mrc_v
587 (BOOK_TYPE_CODE,
588 ASSET_ID,
589 DISTRIBUTION_ID,
590 PERIOD_COUNTER,
591 DEPRN_RUN_DATE,
592 DEPRN_AMOUNT,
593 YTD_DEPRN,
594 ADDITION_COST_TO_CLEAR,
595 DEPRN_RESERVE,
596 /* Bug 525654 Modification */
597 DEPRN_ADJUSTMENT_AMOUNT,
598 REVAL_RESERVE,
599 YTD_REVAL_DEPRN_EXPENSE,
600 COST,
601 DEPRN_SOURCE_CODE,
602 BONUS_DEPRN_AMOUNT,
603 BONUS_YTD_DEPRN,
604 BONUS_DEPRN_RESERVE)
605 VALUES (h_book_type_code,
606 h_asset_id,
607 h_dist_id,
608 h_period_counter,
609 h_sysdate,
610 0,
611 h_part_ytd,
612 decode(h_source_code, 'B',h_part_cost,0),
613 h_part_deprn_reserve,
614 /* Bug 525654 Modification */
615 h_part_deprn_adjustment_amount,
616 h_part_reval_reserve,
617 h_part_ytd_reval_dep_exp,
618 decode(h_source_code, 'D',h_part_cost,0),
619 h_source_code,
620 0,
621 h_part_bonus_ytd,
622 h_part_bonus_deprn_reserve);
623
624 else
625
626 INSERT INTO fa_deprn_detail(BOOK_TYPE_CODE,
627 ASSET_ID,
628 DISTRIBUTION_ID,
629 PERIOD_COUNTER,
630 DEPRN_RUN_DATE,
631 DEPRN_AMOUNT,
632 YTD_DEPRN,
633 ADDITION_COST_TO_CLEAR,
634 DEPRN_RESERVE,
635 /* Bug 525654 Modification */
636 DEPRN_ADJUSTMENT_AMOUNT,
637 REVAL_RESERVE,
638 YTD_REVAL_DEPRN_EXPENSE,
639 COST,
640 DEPRN_SOURCE_CODE,
641 BONUS_DEPRN_AMOUNT,
642 BONUS_YTD_DEPRN,
643 BONUS_DEPRN_RESERVE)
644 VALUES (h_book_type_code,
645 h_asset_id,
646 h_dist_id,
647 h_period_counter,
648 h_sysdate,
649 0,
650 h_part_ytd,
651 decode(h_source_code, 'B',h_part_cost,0),
652 h_part_deprn_reserve,
653 /* Bug 525654 Modification */
654 h_part_deprn_adjustment_amount,
655 h_part_reval_reserve,
656 h_part_ytd_reval_dep_exp,
657 decode(h_source_code, 'D',h_part_cost,0),
658 h_source_code,
659 0,
660 h_part_bonus_ytd,
661 h_part_bonus_deprn_reserve);
662
663 end if; -- end mrc
664
665 END LOOP;
666
667 CLOSE C1;
668 return (TRUE);
669
670 EXCEPTION
671 WHEN NO_DATA_FOUND THEN
672 FA_SRVR_MSG.add_message(
673 CALLING_FN => 'FA_INS_DETAIL_PKG.fadpdtl',
674 NAME => h_msg_name
675 ,p_log_level_rec => p_log_level_rec);
676 return (FALSE);
677
678 WHEN ERROR_FOUND THEN
679 FA_SRVR_MSG.add_message(
680 CALLING_FN => 'FA_INS_DETAIL_PKG.fadpdtl'
681 ,p_log_level_rec => p_log_level_rec);
682 close C1;
683 return (FALSE);
684
685 WHEN OTHERS THEN
686 FA_SRVR_MSG.ADD_SQL_ERROR(
687 CALLING_FN => 'FA_INS_DETAIL.fadpdtl'
688 ,p_log_level_rec => p_log_level_rec);
689 close C1;
690 return(FALSE);
691 END fadpdtl;
692
693 END FA_INS_DETAIL_PKG;