[Home] [Help]
PACKAGE BODY: APPS.FA_INS_DETAIL_PKG
Source
1 PACKAGE BODY FA_INS_DETAIL_PKG as
2 /* $Header: FAXINDDB.pls 120.23.12020000.4 2013/02/06 11:20:57 saalampa ship $ */
3
4 --
5 -- FUNCTION faxindd
6 --
7
8 g_release number := fa_cache_pkg.fazarel_release;
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_bonus_deprn_adj_amount NUMBER DEFAULT NULL,
24 X_bonus_deprn_amount NUMBER DEFAULT NULL,
25 X_deprn_amount NUMBER DEFAULT NULL,
26 X_reval_amortization NUMBER DEFAULT NULL,
27 X_reval_deprn_expense NUMBER DEFAULT NULL,
28 X_impairment_amount NUMBER DEFAULT NULL,
29 X_ytd_impairment NUMBER DEFAULT NULL,
30 X_impairment_reserve NUMBER DEFAULT NULL,
31 X_capital_adjustment NUMBER DEFAULT NULL, --Bug 6666666
32 X_general_fund NUMBER DEFAULT NULL, --Bug 6666666
33 X_b_row BOOLEAN DEFAULT TRUE,
34 X_mrc_sob_type_code VARCHAR2,
35 X_set_of_books_id NUMBER
36 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type)
37
38 return BOOLEAN is
39
40 h_dpr_dtl fa_std_types.dpr_dtl_row_struct;
41 h_ytd NUMBER;
42 h_deprn_reserve NUMBER;
43
44 /* Bug 525654 Modification */
45 h_deprn_adjustment_amount NUMBER;
46 h_reval_reserve NUMBER;
47 h_ytd_reval_dep_exp NUMBER;
48 h_period_counter NUMBER;
49 h_cost NUMBER;
50
51 h_bonus_ytd NUMBER;
52 h_bonus_deprn_reserve NUMBER;
53
54 h_msg_name VARCHAR2(30) := NULL;
55
56 BEGIN
57
58 IF (X_init_message_flag = 'YES') THEN
59 FA_SRVR_MSG.INIT_SERVER_MESSAGE; /* init server msg stack */
60 fa_debug_pkg.initialize; /* init debug msg stack */
61 END IF;
62
63 IF (X_book_type_code IS NULL) OR (X_asset_id IS NULL) THEN
64 FA_SRVR_MSG.add_message(
65 CALLING_FN => 'FA_INS_DETAIL_PKG.faxindd',
66 NAME => 'FA_SHARED_ARGUMENTS', p_log_level_rec => p_log_level_rec);
67 return(FALSE);
68 END IF;
69
70 h_dpr_dtl.book := X_book_type_code;
71 h_dpr_dtl.asset_id := X_asset_id;
72
73
74 IF (X_cost IS NULL OR
75 X_deprn_reserve IS NULL OR
76 X_reval_reserve IS NULL OR
77 X_ytd IS NULL OR
78 X_ytd_reval_dep_exp IS NULL OR
79 X_period_counter IS NULL OR
80 X_bonus_ytd IS NULL OR
81 X_bonus_deprn_reserve IS NULL) THEN
82
83
84 if (X_mrc_sob_type_code = 'R') then
85
86 h_msg_name := 'FA_DD_DEP_SUM';
87
88 SELECT ytd_deprn, deprn_reserve,
89 reval_reserve, ytd_reval_deprn_expense,
90 bonus_ytd_deprn, bonus_deprn_reserve,
91 period_counter
92 INTO h_ytd,
93 h_deprn_reserve,
94 h_reval_reserve,
95 h_ytd_reval_dep_exp,
96 h_bonus_ytd,
97 h_bonus_deprn_reserve,
98 h_period_counter
99 FROM fa_mc_deprn_summary
100 WHERE book_type_code = X_book_type_code
101 AND asset_id = X_asset_id
102 AND deprn_source_code = 'BOOKS'
103 AND set_of_books_id = X_set_of_books_id;
104
105 h_msg_name := 'FA_DD_BOOKS';
106
107 SELECT decode(ad.asset_type,
108 'GROUP', 0,
109 bk.cost)
110 INTO h_cost
111 FROM FA_MC_BOOKS bk,
112 FA_ADDITIONS_B ad
113 WHERE ad.asset_id = X_asset_id
114 AND ad.asset_id = bk.asset_id
115 AND bk.book_type_code = X_book_type_code
116 and bk.transaction_header_id_out is null
117 AND set_of_books_id = X_set_of_books_id;
118
119 else
120
121 h_msg_name := 'FA_DD_DEP_SUM';
122
123 SELECT ytd_deprn, deprn_reserve,
124 reval_reserve, ytd_reval_deprn_expense,
125 bonus_ytd_deprn, bonus_deprn_reserve,
126 period_counter
127 INTO h_ytd,
128 h_deprn_reserve,
129 h_reval_reserve,
130 h_ytd_reval_dep_exp,
131 h_bonus_ytd,
132 h_bonus_deprn_reserve,
133 h_period_counter
134 FROM fa_deprn_summary
135 WHERE book_type_code = X_book_type_code
136 AND asset_id = X_asset_id
137 AND deprn_source_code = 'BOOKS';
138
139 h_msg_name := 'FA_DD_BOOKS';
140
141 SELECT decode(ad.asset_type,
142 'GROUP', 0,
143 bk.cost)
144 INTO h_cost
145 FROM FA_BOOKS bk,
146 FA_ADDITIONS_B ad
147 WHERE ad.asset_id = X_asset_id
148 AND ad.asset_id = bk.asset_id
149 AND bk.book_type_code = X_book_type_code
150 and bk.transaction_header_id_out is null;
151
152 end if; -- end sob_id
153
154 h_msg_name := NULL;
155 if (p_log_level_rec.statement_level) then
156 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','deprn_summary values:','', p_log_level_rec => p_log_level_rec);
157 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_deprn',h_ytd, p_log_level_rec => p_log_level_rec);
158 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','deprn_reserve',h_deprn_reserve, p_log_level_rec => p_log_level_rec);
159 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','reval_reserve',h_reval_reserve, p_log_level_rec => p_log_level_rec);
160 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_reval_deprn_expense',h_ytd_reval_dep_exp, p_log_level_rec => p_log_level_rec);
161 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','period_counter',h_period_counter, p_log_level_rec => p_log_level_rec);
162 end if;
163
164 END IF;
165
166
167 /* Bug 525654 Modification */
168
169 IF X_deprn_adjustment_amount IS NULL THEN
170
171 if (X_mrc_sob_type_code ='R') then
172
173 SELECT sum(nvl(deprn_adjustment_amount,0))
174 INTO h_deprn_adjustment_amount
175 FROM fa_mc_deprn_detail
176 WHERE book_type_code = X_book_type_code
177 AND asset_id = X_asset_id
178 AND deprn_source_code = 'B'
179 AND set_of_books_id = X_set_of_books_id;
180
181 else
182
183 SELECT sum(nvl(deprn_adjustment_amount,0))
184 INTO h_deprn_adjustment_amount
185 FROM fa_deprn_detail
186 WHERE book_type_code = X_book_type_code
187 AND asset_id = X_asset_id
188 AND deprn_source_code = 'B';
189
190 end if;
191 END IF;
192
193
194 IF (X_cost IS NOT NULL) THEN
195 h_dpr_dtl.cost := X_cost;
196 ELSE
197 h_dpr_dtl.cost := h_cost;
198 END IF;
199
200 IF (X_ytd IS NOT NULL) THEN
201 h_dpr_dtl.ytd := X_ytd;
202 ELSE
203 h_dpr_dtl.ytd := h_ytd;
204 END IF;
205
206 IF (X_deprn_reserve IS NOT NULL) THEN
207 h_dpr_dtl.deprn_reserve := X_deprn_reserve;
208 ELSE
209 h_dpr_dtl.deprn_reserve := h_deprn_reserve;
210 END IF;
211
212 /* Bug 525654 Modification */
213 IF (X_deprn_adjustment_amount IS NOT NULL) THEN
214 h_dpr_dtl.deprn_adjustment_amount := X_deprn_adjustment_amount;
215 ELSE
216 h_dpr_dtl.deprn_adjustment_amount := h_deprn_adjustment_amount;
217 END IF;
218
219
220
221 IF (X_reval_reserve IS NOT NULL) THEN
222 h_dpr_dtl.reval_reserve := X_reval_reserve;
223 h_dpr_dtl.reval_rsv_flag := TRUE;
224 ELSE
225 IF (h_reval_reserve IS NULL) THEN
226 h_dpr_dtl.reval_reserve := 0;
227 h_dpr_dtl.reval_rsv_flag := FALSE;
228 ELSE
229 h_dpr_dtl.reval_reserve := h_reval_reserve;
230 h_dpr_dtl.reval_rsv_flag := TRUE;
231 END IF;
232 END IF;
233
234 IF (X_ytd_reval_dep_exp IS NOT NULL) THEN
235 h_dpr_dtl.ytd_reval_dep_exp := X_ytd_reval_dep_exp;
236 h_dpr_dtl.ytd_reval_dep_exp_flag := TRUE;
237 ELSE
238 IF (h_ytd_reval_dep_exp IS NULL) THEN
239 h_dpr_dtl.ytd_reval_dep_exp := 0;
240 h_dpr_dtl.ytd_reval_dep_exp_flag := FALSE;
241 ELSE
242 h_dpr_dtl.ytd_reval_dep_exp := h_ytd_reval_dep_exp;
243 h_dpr_dtl.ytd_reval_dep_exp_flag := TRUE;
244 END IF;
245 END IF;
246 IF (X_bonus_ytd IS NOT NULL) THEN
247 h_dpr_dtl.bonus_ytd := X_bonus_ytd;
248 ELSE
249 h_dpr_dtl.bonus_ytd := h_bonus_ytd;
250 END IF;
251
252 IF (X_bonus_deprn_reserve IS NOT NULL) THEN
253 h_dpr_dtl.bonus_deprn_reserve := X_bonus_deprn_reserve;
254 ELSE
255 h_dpr_dtl.bonus_deprn_reserve := h_bonus_deprn_reserve;
256 END IF;
257
258 -- IAS36, add nvl below
259 h_dpr_dtl.period_counter := nvl(h_period_counter, X_period_counter);
260
261 -- IAS36
262 h_dpr_dtl.bonus_deprn_adj_amount := X_bonus_deprn_adj_amount;
263 h_dpr_dtl.bonus_deprn_amount := nvl(X_bonus_deprn_amount, 0);
264 h_dpr_dtl.impairment_amount := X_impairment_amount;
265 h_dpr_dtl.ytd_impairment := X_ytd_impairment;
266 h_dpr_dtl.impairment_reserve := X_impairment_reserve;
267 h_dpr_dtl.deprn_amount := nvl(X_deprn_amount, 0);
268 h_dpr_dtl.reval_amortization := nvl(X_reval_amortization, 0);
269 h_dpr_dtl.reval_deprn_expense := nvl(X_reval_deprn_expense, 0);
270
271 -- Bug 6666666
272 h_dpr_dtl.capital_adjustment := X_capital_adjustment;
273 h_dpr_dtl.general_fund := X_general_fund;
274
275 if (p_log_level_rec.statement_level) then
276 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','values before call to fadpdtl','', p_log_level_rec => p_log_level_rec);
277 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','cost',h_dpr_dtl.cost, p_log_level_rec => p_log_level_rec);
278 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_deprn',h_dpr_dtl.ytd, p_log_level_rec => p_log_level_rec);
279 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','deprn_reserve',h_dpr_dtl.deprn_reserve, p_log_level_rec => p_log_level_rec);
280 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','reval_reserve',h_dpr_dtl.reval_reserve, p_log_level_rec => p_log_level_rec);
281 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_reval_deprn_expense',h_dpr_dtl.ytd_reval_dep_exp, p_log_level_rec => p_log_level_rec);
282 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','period_counter',h_dpr_dtl.period_counter, p_log_level_rec => p_log_level_rec);
283 end if;
284
285 IF (NOT fadpdtl(X_dpr_dtl => h_dpr_dtl,
286 X_source_flag => X_b_row, -- TRUE, Modified for ias36
287 X_mrc_sob_type_code => X_mrc_sob_type_code,
288 X_set_of_books_id => X_set_of_books_id,
289 p_log_level_rec => p_log_level_rec)) THEN
290 FA_SRVR_MSG.add_message (
291 CALLING_FN => 'FA_INS_DETAIL_PKG.faxindd', p_log_level_rec => p_log_level_rec);
292 return(FALSE);
293 END IF;
294
295 return(TRUE);
296
297 EXCEPTION
298
299 WHEN NO_DATA_FOUND then
300 FA_SRVR_MSG.add_message(
301 CALLING_FN => 'FA_INS_DETAIL_PKG.faxindd',
302 NAME => h_msg_name, p_log_level_rec => p_log_level_rec);
303 return FALSE;
304
305 WHEN OTHERS THEN
306 FA_SRVR_MSG.ADD_SQL_ERROR(
307 CALLING_FN => 'FA_INS_DETAIL_PKG.faxindd', p_log_level_rec => p_log_level_rec);
308 return(FALSE);
309 END faxindd;
310
311
312 --
313 -- FUNCTION fadpdtl
314 --
315 FUNCTION fadpdtl(X_dpr_dtl FA_STD_TYPES.DPR_DTL_ROW_STRUCT,
316 X_source_flag BOOLEAN,
317 X_mrc_sob_type_code VARCHAR2,
318 X_set_of_books_id NUMBER,
319 p_log_level_rec IN FA_API_TYPES.log_level_rec_type)
320 return BOOLEAN IS
321
322 h_book_type_code VARCHAR2(30);
323 h_asset_id NUMBER;
324 h_period_counter NUMBER;
325 h_dist_book VARCHAR2(30);
326 h_source_code VARCHAR2(1);
327
328 h_dist_id NUMBER;
329 h_units_assigned NUMBER;
330 h_sysdate DATE;
331 h_rec_count NUMBER := 0;
332 h_dist_count NUMBER := 0;
333 h_total_units NUMBER := 0;
334 h_pc_counter NUMBER := 0;
335
336 h_sum_cost NUMBER := 0;
337 h_sum_ytd NUMBER := 0;
338 h_sum_deprn_reserve NUMBER := 0;
339
340 /* Bug 525654 Modification */
341
342 h_part_deprn_adjustment_amount NUMBER := 0;
343 h_sum_reval_reserve NUMBER := 0;
344 h_sum_ytd_reval_dep_exp NUMBER := 0;
345 h_sum_bonus_ytd NUMBER := 0;
346 h_sum_bonus_deprn_reserve NUMBER := 0;
347
348 h_part_cost NUMBER := 0;
349 h_part_ytd NUMBER := 0;
350 h_part_deprn_reserve NUMBER := 0;
351 h_part_reval_reserve NUMBER := 0;
352 h_part_ytd_reval_dep_exp NUMBER := 0;
353 h_part_bonus_ytd NUMBER := 0;
354 h_part_bonus_deprn_reserve NUMBER := 0;
355
356 -- IAS36
357 h_part_bonus_deprn_amount NUMBER := 0;
358 h_part_bonus_deprn_adj_amount NUMBER := 0;
359 h_part_impairment_amount NUMBER := 0;
360 h_part_ytd_impairment NUMBER := 0;
361 h_part_impairment_reserve NUMBER := 0;
362 h_part_deprn_amount NUMBER := 0;
363 h_part_reval_amortization NUMBER := 0;
364 h_part_reval_deprn_expense NUMBER := 0;
365 h_sum_bonus_amount NUMBER := 0;
366 h_sum_bonus_deprn_adj_amount NUMBER := 0;
367 h_sum_impairment_amount NUMBER := 0;
368 h_sum_ytd_impairment NUMBER := 0;
369 h_sum_impairment_reserve NUMBER := 0;
370 h_sum_deprn_amount NUMBER := 0;
371 h_sum_reval_amortization NUMBER := 0;
372 h_sum_reval_deprn_expense NUMBER := 0;
373
374 --Bug 6666666
375 h_part_capital_adjustment NUMBER := 0;
376 h_part_general_fund NUMBER := 0;
377 h_sum_capital_adjustment NUMBER := 0;
378 h_sum_general_fund NUMBER := 0;
379
380 --Added for 9128700
381 h_add_date DATE := NULL;
382
383 h_full_ytd NUMBER := 0; -- Bug 5984105
384
385 h_msg_name VARCHAR2(30) := NULL;
386 ERROR_FOUND EXCEPTION;
387
388 h_count NUMBER := 0; --Bug 9142501
389 h_cost_to_clear NUMBER := 0; --Bug 9142501
390
391 CURSOR C1_11 IS
392 SELECT distribution_id, units_assigned
393 FROM fa_distribution_history
394 WHERE book_type_code = h_dist_book AND
395 asset_id = h_asset_id AND
396 date_ineffective IS NULL
397 ORDER BY distribution_id;
398
399 --Changed for 9128700
400
401 CURSOR C1 IS
402 SELECT distribution_id, units_assigned
403 FROM fa_distribution_history
404 WHERE book_type_code = h_dist_book
405 AND asset_id = h_asset_id
406 AND h_add_date BETWEEN
407 date_effective AND NVL(date_ineffective,SYSDATE)
408 ORDER BY distribution_id;
409
410
411 -- Bug 5984105 Fetch transfered out current period distribuitons
412 /*Bug#8421266- Modified cursor to fetch all the distributions transferred out in current fiscal year */
413 CURSOR C2 IS
414 SELECT dh.distribution_id,
415 dh.units_assigned,
416 dp.period_counter
417 FROM fa_distribution_history dh, fa_deprn_periods dp, fa_transaction_headers th
418 WHERE dh.asset_id = X_dpr_dtl.asset_id
419 AND dh.book_type_code = fa_cache_pkg.fazcbc_record.distribution_source_book
420 AND dp.book_type_code = X_dpr_dtl.book
421 AND NVL(dh.date_ineffective, sysdate) >= dp.period_open_date
422 and dh.transaction_header_id_out IS not NULL
423 and th.book_type_code = dh.book_type_code
424 and th.asset_id = dh.asset_id
425 and th.date_Effective between dp.period_open_date and NVL(dp.period_close_date,sysdate)
426 and th.transaction_type_code in ('TRANSFER','UNIT ADJUSTMENT','RECLASS','REINSTATEMENT')
427 --Bug# 7291015 - Added Unit Adjustment,Bug# 6701439 - Added Reclass
428 /*Bug#7836587 - Added REINSTATEMENT */
429 and dh.transaction_header_id_out = th.transaction_header_id
430 and dp.fiscal_year =
431 (select fiscal_year
432 from fa_deprn_periods dp2
433 where dp2.period_close_date is NULL
434 and book_type_code = X_dpr_dtl.book)
435 ORDER BY dh.distribution_id;
436
437 CURSOR C_MC_COST_TO_CLEAR IS --Bug 9142501
438 SELECT NVL(SUM(DECODE(adj.debit_credit_flag,'DR', -1 * adj.adjustment_amount, adj.adjustment_amount)),0)
439 FROM FA_MC_ADJUSTMENTS adj,
440 FA_TRANSACTION_HEADERS th
441 WHERE adj.book_type_code(+) = h_book_type_code
442 AND adj.asset_id(+) = h_asset_id
443 AND adj.adjustment_type(+) = decode (th.transaction_type_code, 'CIP ADDITION', 'CIP COST', 'ADDITION', 'COST')
444 AND adj.distribution_id(+) = h_dist_id
445 AND th.book_type_code = h_book_type_code
446 AND th.asset_id = h_asset_id
447 AND th.transaction_type_code in ('CIP ADDITION','ADDITION')
448 AND th.transaction_header_id = adj.transaction_header_id(+)
449 GROUP BY adj.adjustment_amount,debit_credit_flag,th.transaction_header_id;
450
451 CURSOR C_COST_TO_CLEAR IS --Bug 9142501
452 SELECT NVL(SUM(DECODE(adj.debit_credit_flag,'DR', -1 * adj.adjustment_amount, adj.adjustment_amount)),0)
453 FROM FA_ADJUSTMENTS adj,
454 FA_TRANSACTION_HEADERS th
455 WHERE adj.book_type_code(+) = h_book_type_code
456 AND adj.asset_id(+) = h_asset_id
457 AND adj.adjustment_type(+) = decode (th.transaction_type_code, 'CIP ADDITION', 'CIP COST', 'ADDITION', 'COST')
458 AND adj.distribution_id(+) = h_dist_id
459 AND th.book_type_code = h_book_type_code
460 AND th.asset_id = h_asset_id
461 AND th.transaction_type_code in ('CIP ADDITION','ADDITION')
462 AND th.transaction_header_id = adj.transaction_header_id(+)
463 GROUP BY adj.adjustment_amount,debit_credit_flag,th.transaction_header_id;
464
465
466 BEGIN
467
468 -- need to insure this is only called from faxindd and no other location!!!!
469
470 h_book_type_code := X_dpr_dtl.book;
471 h_asset_id := X_dpr_dtl.asset_id;
472 h_period_counter := X_dpr_dtl.period_counter;
473
474 h_msg_name := 'FA_SHARED_DATA_ERR_BC';
475
476 -- bug# 2140468 - use cache
477 h_dist_book := fa_cache_pkg.fazcbc_record.distribution_source_book;
478
479 h_msg_name := 'FA_SHARED_DATA_ERR_DH';
480
481 /*Bug 9142501 - Start:In POA Cost adjustment should not reflect in B row of fa_deprn_detail.
482 ADDITION_COST_TO_CLEAR should contain old value only, which is addition time value. */
483 IF X_mrc_sob_type_code = 'R' THEN
484 SELECT COUNT(*)
485 INTO h_count
486 FROM FA_MC_DEPRN_DETAIL
487 WHERE book_type_code = h_book_type_code AND
488 asset_id = h_asset_id AND
489 period_counter = h_period_counter;
490 ELSE
491 SELECT COUNT(*)
492 INTO h_count
493 FROM FA_DEPRN_DETAIL
494 WHERE book_type_code = h_book_type_code AND
495 asset_id = h_asset_id AND
496 period_counter = h_period_counter;
497 END IF;
498 /*Bug 9142501 - End*/
499
500 if (G_release = 11 or X_source_flag = FALSE) then
501 SELECT nvl(SUM(dh.units_assigned),0), COUNT(*)
502 INTO h_total_units, h_dist_count
503 FROM fa_distribution_history dh
504 WHERE dh.book_type_code = h_dist_book AND
505 dh.asset_id = h_asset_id AND
506 dh.date_ineffective IS NULL;
507 else
508 -- Bug 8237945 ... Since this is called only in Period of Addition, and in
509 -- Period of addition we always have to take Distributions at the time of
510 -- additions into consideration . Commented dh.date_ineffective is null
511 -- condition
512 -- Bug 8281792 ... We need to pass h_dist_book for book_type_code, since we can
513 -- have a situation where we are using Tax Book and fa_distribution_history does
514 -- not contain units. Also rewritten the query using EXISTS cluase
515
516 --Modified for 9128700
517
518 BEGIN
519
520 SELECT MIN(date_effective)
521 INTO h_add_date
522 FROM fa_transaction_headers
523 WHERE book_type_code = h_book_type_code
524 AND asset_id = h_asset_id
525 AND transaction_type_code LIKE '%ADDITION%';
526
527 EXCEPTION
528 WHEN OTHERS THEN
529 if (p_log_level_rec.statement_level) then
530 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','Getting date added',SQLERRM, p_log_level_rec => p_log_level_rec);
531 end if;
532
533 RAISE ERROR_FOUND;
534 END;
535
536
537 SELECT nvl(SUM(dh.units_assigned),0), COUNT(*)
538 INTO h_total_units, h_dist_count
539 FROM fa_distribution_history dh
540 WHERE dh.book_type_code = h_dist_book
541 AND dh.asset_id = h_asset_id
542 AND h_add_date BETWEEN
543 date_effective AND NVL(date_ineffective,SYSDATE);
544
545 --End of modification for 9128700
546
547 end if;
548
549 IF (h_total_units = 0) THEN
550 FA_SRVR_MSG.add_message(
551 CALLING_FN => 'FA_INS_DETAIL_PKG.fadpdtl',
552 NAME => 'FA_SHARED_DATA_ERR_DH', p_log_level_rec => p_log_level_rec);
553 return (FALSE);
554 END IF;
555
556 h_msg_name := NULL;
557
558 if X_mrc_sob_type_code = 'R' then
559 DELETE FROM fa_mc_deprn_detail
560 WHERE book_type_code = h_book_type_code AND
561 asset_id = h_asset_id AND
562 period_counter = h_period_counter AND
563 set_of_books_id = X_set_of_books_id;
564 else
565 DELETE FROM fa_deprn_detail
566 WHERE book_type_code = h_book_type_code AND
567 asset_id = h_asset_id AND
568 period_counter = h_period_counter;
569 end if; -- end mrc
570
571
572 IF (SQL%NOTFOUND) THEN
573 null;
574 END IF;
575
576
577 IF (X_source_flag) THEN -- insert B row
578 h_source_code := 'B';
579 h_sysdate := sysdate;
580 ELSE
581 h_source_code := 'D'; -- insert D row
582 h_sysdate := sysdate;
583 END IF;
584
585 -- Bug 5984105 -- Start
586 -- Insert rows into fa_deprn_detail for the
587 -- transfered out distributions
588 h_full_ytd := X_dpr_dtl.ytd;
589
590 if (p_log_level_rec.statement_level) then
591 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','At Start Total Ytd',h_full_ytd, p_log_level_rec => p_log_level_rec);
592 end if;
593 if (X_source_flag = FALSE ) then
594 open c2;
595 loop
596 h_units_assigned := 0;
597 h_dist_id := 0;
598
599 FETCH C2 INTO h_dist_id,
600 h_units_assigned,
601 h_pc_counter;
602 EXIT WHEN C2%NOTFOUND;
603 BEGIN
604
605 /*Bug#8421266 - Modified query to fetch ytd_deprn of transferred out distribution.*/
606 if (X_mrc_sob_type_code = 'R') then
607 SELECT ytd_deprn
608 INTO h_part_ytd
609 FROM fa_mc_deprn_detail
610 WHERE book_type_code = h_book_type_code
611 and asset_id = h_asset_id
612 and distribution_id = h_dist_id
613 and period_counter = (select max(period_counter)
614 from fa_mc_deprn_detail fdd2
615 where fdd2.asset_id = h_asset_id
616 and fdd2.distribution_id = h_dist_id
617 and fdd2.set_of_books_id = X_set_of_books_id
618 and fdd2.book_type_code = h_book_type_code)
619 and set_of_books_id = X_set_of_books_id;
620 else
621 SELECT ytd_deprn
622 INTO h_part_ytd
623 FROM fa_deprn_detail
624 WHERE book_type_code = h_book_type_code
625 and asset_id = h_asset_id
626 and distribution_id = h_dist_id
627 and period_counter = (select max(period_counter)
628 from fa_deprn_detail fdd2
629 where fdd2.asset_id = h_asset_id
630 and fdd2.book_type_code = h_book_type_code
631 and fdd2.distribution_id = h_dist_id);
632 end if;
633 EXCEPTION
634 WHEN OTHERS THEN
635 h_part_ytd := 0;
636 END;
637
638 h_full_ytd := h_full_ytd - h_part_ytd;
639
640 if (p_log_level_rec.statement_level) then
641 fa_debug_pkg.add('FA_INS_DETAIL_PKG.fadpdtl','values after C2 fetch','', p_log_level_rec => p_log_level_rec);
642 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','dist_id',h_dist_id, p_log_level_rec => p_log_level_rec);
643 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','units_assigned',h_units_assigned, p_log_level_rec => p_log_level_rec);
644 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','h_part_ytd',h_part_ytd, p_log_level_rec => p_log_level_rec);
645 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','Total Ytd',h_full_ytd, p_log_level_rec => p_log_level_rec);
646 end if;
647
648 /*Bug#8421266 - Insert row in deprn table only when transferred out in current period.*/
649 if h_pc_counter = h_period_counter then
650 if (X_mrc_sob_type_code = 'R') then
651
652 INSERT INTO fa_mc_deprn_detail
653 (SET_OF_BOOKS_ID,
654 BOOK_TYPE_CODE,
655 ASSET_ID,
656 DISTRIBUTION_ID,
657 PERIOD_COUNTER,
658 DEPRN_RUN_DATE,
659 DEPRN_AMOUNT,
660 YTD_DEPRN,
661 ADDITION_COST_TO_CLEAR,
662 DEPRN_RESERVE,
663 /* Bug 525654 Modification */
664 DEPRN_ADJUSTMENT_AMOUNT,
665 REVAL_RESERVE,
666 YTD_REVAL_DEPRN_EXPENSE,
667 COST,
668 DEPRN_SOURCE_CODE,
669 BONUS_DEPRN_AMOUNT,
670 BONUS_YTD_DEPRN,
671 BONUS_DEPRN_RESERVE,
672 BONUS_DEPRN_ADJUSTMENT_AMOUNT,
673 IMPAIRMENT_AMOUNT,
674 YTD_IMPAIRMENT,
675 impairment_reserve,
676 REVAL_AMORTIZATION,
677 REVAL_DEPRN_EXPENSE)
678 VALUES (X_set_of_books_id,
679 h_book_type_code,
680 h_asset_id,
681 h_dist_id,
682 h_period_counter,
683 h_sysdate,
684 0,
685 h_part_ytd, ---ytd_deprn
686 0, ---cost_to_clear( doubt for POA)
687 0,
688 0,
689 0,
690 0,
691 0,
692 h_source_code,
693 0,
694 0,
695 0,
696 0,
697 0,
698 0,
699 0,
700 0,
701 0);
702
703 else
704 INSERT INTO fa_deprn_detail(
705 BOOK_TYPE_CODE,
706 ASSET_ID,
707 DISTRIBUTION_ID,
708 PERIOD_COUNTER,
709 DEPRN_RUN_DATE,
710 DEPRN_AMOUNT,
711 YTD_DEPRN,
712 ADDITION_COST_TO_CLEAR,
713 DEPRN_RESERVE,
714 /* Bug 525654 Modification */
715 DEPRN_ADJUSTMENT_AMOUNT,
716 REVAL_RESERVE,
717 YTD_REVAL_DEPRN_EXPENSE,
718 COST,
719 DEPRN_SOURCE_CODE,
720 BONUS_DEPRN_AMOUNT,
721 BONUS_YTD_DEPRN,
722 BONUS_DEPRN_RESERVE,
723 BONUS_DEPRN_ADJUSTMENT_AMOUNT,
724 IMPAIRMENT_AMOUNT,
725 YTD_IMPAIRMENT,
726 impairment_reserve,
727 REVAL_AMORTIZATION,
728 REVAL_DEPRN_EXPENSE)
729 VALUES (h_book_type_code,
730 h_asset_id,
731 h_dist_id,
732 h_period_counter,
733 h_sysdate,
734 0,
735 h_part_ytd, ---ytd_deprn
736 0, ---cost_to_clear( doubt for POA)
737 0,
738 0,
739 0,
740 0,
741 0,
742 h_source_code,
743 0,
744 0,
745 0,
746 0,
747 0,
748 0,
749 0,
750 0,
751 0);
752 end if;
753 end if;
754 end loop;
755 end if;
756
757 -- Bug 5984105 -- End
758
759 if (G_release = 11 OR X_source_flag = FALSE ) then /* Bug# 8731454 - Need to use C1_11 only for impairment */
760 OPEN C1_11;
761 else
762 OPEN C1;
763 end if;
764
765 LOOP
766 h_units_assigned := 0;
767 h_dist_id := 0;
768
769 if (G_release = 11 OR X_source_flag = FALSE ) then -- Bug# 8731454
770 FETCH C1_11 INTO h_dist_id, h_units_assigned;
771 EXIT WHEN C1_11%NOTFOUND;
772 else
773 FETCH C1 INTO h_dist_id, h_units_assigned;
774 EXIT WHEN C1%NOTFOUND;
775 end if;
776
777 if (p_log_level_rec.statement_level) then
778 fa_debug_pkg.add('FA_INS_DETAIL_PKG.fadpdtl','values after the fetch','', p_log_level_rec => p_log_level_rec);
779 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','dist_id',h_dist_id, p_log_level_rec => p_log_level_rec);
780 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','units_assigned',h_units_assigned, p_log_level_rec => p_log_level_rec);
781 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','total_units',h_total_units, p_log_level_rec => p_log_level_rec);
782 end if;
783
784 /*Bug 9142501 - Start:In POA Cost adjustment should not reflect in B row of fa_deprn_detail.
785 ADDITION_COST_TO_CLEAR should contain old value only, which is addition time value. */
786 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','Brahma2 before Loop','BRAHMA',p_log_level_rec => p_log_level_rec);
787 IF h_count > 0 THEN
788 IF X_mrc_sob_type_code = 'R' THEN
789 OPEN C_MC_COST_TO_CLEAR;
790 FETCH C_MC_COST_TO_CLEAR INTO h_cost_to_clear;
791 CLOSE C_MC_COST_TO_CLEAR;
792 ELSE
793 OPEN C_COST_TO_CLEAR;
794 FETCH C_COST_TO_CLEAR INTO h_cost_to_clear;
795 CLOSE C_COST_TO_CLEAR;
796 END IF;
797 END IF;
798 /*Bug 9142501 - End*/
799
800 h_rec_count := h_rec_count + 1;
801
802 h_part_cost := (X_dpr_dtl.cost * h_units_assigned) / h_total_units;
803
804 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_cost,
805 X_book => h_book_type_code,
806 X_set_of_books_id => X_set_of_books_id,
807 p_log_level_rec => p_log_level_rec)) THEN
808 raise ERROR_FOUND;
809 END IF;
810
811 h_part_ytd := (h_full_ytd * h_units_assigned) / h_total_units; -- Bug 5984105
812
813 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_ytd,
814 X_book => h_book_type_code,
815 X_set_of_books_id => X_set_of_books_id,
816 p_log_level_rec => p_log_level_rec)) THEN
817 raise ERROR_FOUND;
818 END IF;
819
820
821 /* Bug 525654 Modification */
822 h_part_deprn_adjustment_amount := ( X_dpr_dtl.deprn_adjustment_amount * h_units_assigned) / h_total_units;
823
824 h_part_deprn_reserve := (X_dpr_dtl.deprn_reserve * h_units_assigned) /
825 h_total_units;
826
827 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_deprn_reserve,
828 X_book => h_book_type_code,
829 X_set_of_books_id => X_set_of_books_id,
830 p_log_level_rec => p_log_level_rec)) THEN
831 raise ERROR_FOUND;
832 END IF;
833
834 IF (X_dpr_dtl.reval_rsv_flag) THEN
835 h_part_reval_reserve := (X_dpr_dtl.reval_reserve * h_units_assigned) /
836 h_total_units;
837
838 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_reval_reserve,
839 X_book => h_book_type_code,
840 X_set_of_books_id => X_set_of_books_id,
841 p_log_level_rec => p_log_level_rec)) THEN
842 raise ERROR_FOUND;
843 END IF;
844 ELSE
845 h_part_reval_reserve := NULL;
846 END IF;
847
848
849 IF (X_dpr_dtl.ytd_reval_dep_exp_flag) THEN
850 h_part_ytd_reval_dep_exp := (X_dpr_dtl.ytd_reval_dep_exp * h_units_assigned) /
851 h_total_units;
852
853 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_ytd_reval_dep_exp,
854 X_book => h_book_type_code,
855 X_set_of_books_id => X_set_of_books_id,
856 p_log_level_rec => p_log_level_rec)) THEN
857 raise ERROR_FOUND;
858 END IF;
859 ELSE
860 h_part_ytd_reval_dep_exp := NULL;
861 END IF;
862
863 h_part_bonus_ytd := (X_dpr_dtl.bonus_ytd * h_units_assigned) /
864 h_total_units;
865
866 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_bonus_ytd,
867 X_book => h_book_type_code,
868 X_set_of_books_id => X_set_of_books_id,
869 p_log_level_rec => p_log_level_rec)) THEN
870 raise ERROR_FOUND;
871 END IF;
872
873 h_part_bonus_deprn_reserve := (X_dpr_dtl.bonus_deprn_reserve * h_units_assigned) /
874 h_total_units;
875
876 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_bonus_deprn_reserve,
877 X_book => h_book_type_code,
878 X_set_of_books_id => X_set_of_books_id,
879 p_log_level_rec => p_log_level_rec)) THEN
880 raise ERROR_FOUND;
881 END IF;
882
883 -- IAS36
884 -- bonus, bonus adj, imp, ytd imp, and ltd imp
885 h_part_bonus_deprn_amount := (X_dpr_dtl.bonus_deprn_amount * h_units_assigned) /
886 h_total_units;
887
888 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_bonus_deprn_amount,
889 X_book => h_book_type_code,
890 X_set_of_books_id => X_set_of_books_id,
891 p_log_level_rec => p_log_level_rec)) THEN
892 raise ERROR_FOUND;
893 END IF;
894
895 h_part_bonus_deprn_adj_amount := (X_dpr_dtl.bonus_deprn_adj_amount * h_units_assigned) /
896 h_total_units;
897
898 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_bonus_deprn_adj_amount,
899 X_book => h_book_type_code,
900 X_set_of_books_id => X_set_of_books_id,
901 p_log_level_rec => p_log_level_rec)) THEN
902 raise ERROR_FOUND;
903 END IF;
904
905 h_part_impairment_amount := (X_dpr_dtl.impairment_amount * h_units_assigned) /
906 h_total_units;
907
908 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_impairment_amount,
909 X_book => h_book_type_code,
910 X_set_of_books_id => X_set_of_books_id,
911 p_log_level_rec => p_log_level_rec)) THEN
912 raise ERROR_FOUND;
913 END IF;
914
915 h_part_ytd_impairment := (X_dpr_dtl.ytd_impairment * h_units_assigned) /
916 h_total_units;
917
918 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_ytd_impairment,
919 X_book => h_book_type_code,
920 X_set_of_books_id => X_set_of_books_id,
921 p_log_level_rec => p_log_level_rec)) THEN
922 raise ERROR_FOUND;
923 END IF;
924
925 h_part_impairment_reserve := (X_dpr_dtl.impairment_reserve * h_units_assigned) /
926 h_total_units;
927
928 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_impairment_reserve,
929 X_book => h_book_type_code,
930 X_set_of_books_id => X_set_of_books_id,
931 p_log_level_rec => p_log_level_rec)) THEN
932 raise ERROR_FOUND;
933 END IF;
934
935 h_part_deprn_amount := (X_dpr_dtl.deprn_amount * h_units_assigned) /
936 h_total_units;
937
938 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_deprn_amount,
939 X_book => h_book_type_code,
940 X_set_of_books_id => X_set_of_books_id,
941 p_log_level_rec => p_log_level_rec)) THEN
942 raise ERROR_FOUND;
943 END IF;
944
945 h_part_reval_amortization := (X_dpr_dtl.reval_amortization * h_units_assigned) /
946 h_total_units;
947
948 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_reval_amortization,
949 X_book => h_book_type_code,
950 X_set_of_books_id => X_set_of_books_id,
951 p_log_level_rec => p_log_level_rec)) THEN
952 raise ERROR_FOUND;
953 END IF;
954
955 h_part_reval_deprn_expense := (X_dpr_dtl.reval_deprn_expense * h_units_assigned) /
956 h_total_units;
957
958 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_reval_deprn_expense,
959 X_book => h_book_type_code,
960 X_set_of_books_id => X_set_of_books_id,
961 p_log_level_rec => p_log_level_rec)) THEN
962 raise ERROR_FOUND;
963 END IF;
964
965 -- Bug 6666666
966
967 h_part_capital_adjustment := (X_dpr_dtl.capital_adjustment * h_units_assigned) /
968 h_total_units;
969
970 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_capital_adjustment,
971 X_book => h_book_type_code,
972 X_set_of_books_id => X_set_of_books_id,
973 p_log_level_rec => p_log_level_rec)) THEN
974 raise ERROR_FOUND;
975 END IF;
976
977 h_part_general_fund := (X_dpr_dtl.general_fund * h_units_assigned) /
978 h_total_units;
979
980 IF (NOT FA_UTILS_PKG.faxrnd(X_amount => h_part_general_fund,
981 X_book => h_book_type_code,
982 X_set_of_books_id => X_set_of_books_id,
983 p_log_level_rec => p_log_level_rec)) THEN
984 raise ERROR_FOUND;
985 END IF;
986
987 h_sum_cost := h_sum_cost + h_part_cost;
988 h_sum_ytd := h_sum_ytd + h_part_ytd;
989 h_sum_deprn_reserve := h_sum_deprn_reserve + h_part_deprn_reserve;
990 h_sum_bonus_ytd := h_sum_bonus_ytd + h_part_bonus_ytd;
991 h_sum_bonus_deprn_reserve := h_sum_bonus_deprn_reserve + h_part_bonus_deprn_reserve;
992 -- IAS36
993 h_sum_bonus_amount := h_sum_bonus_amount + h_part_bonus_deprn_amount;
994 h_sum_bonus_deprn_adj_amount := h_sum_bonus_deprn_adj_amount + h_part_bonus_deprn_adj_amount;
995 h_sum_impairment_amount := h_sum_impairment_amount + h_part_impairment_amount;
996 h_sum_ytd_impairment := h_sum_ytd_impairment + h_part_ytd_impairment;
997 h_sum_impairment_reserve := h_sum_impairment_reserve + h_part_impairment_reserve;
998 h_sum_deprn_amount := h_sum_deprn_amount + h_part_deprn_amount;
999 h_sum_reval_amortization := h_sum_reval_amortization + h_part_reval_amortization;
1000 h_sum_reval_deprn_expense := h_sum_reval_deprn_expense + h_part_reval_deprn_expense;
1001
1002 --Bug 6666666
1003 h_sum_capital_adjustment := h_sum_capital_adjustment + h_part_capital_adjustment;
1004 h_sum_general_fund := h_sum_general_fund + h_part_general_fund;
1005
1006 if (X_dpr_dtl.reval_rsv_flag) then
1007 h_sum_reval_reserve := h_sum_reval_reserve + h_part_reval_reserve;
1008 end if;
1009 if (X_dpr_dtl.ytd_reval_dep_exp_flag) then
1010 h_sum_ytd_reval_dep_exp := h_sum_ytd_reval_dep_exp +
1011 h_part_ytd_reval_dep_exp;
1012 end if;
1013
1014
1015 IF (h_rec_count = h_dist_count) THEN
1016 h_part_cost := h_part_cost + (X_dpr_dtl.cost - h_sum_cost);
1017 h_part_ytd := h_part_ytd + (h_full_ytd - h_sum_ytd); -- Bug 5984105
1018 h_part_deprn_reserve := h_part_deprn_reserve +
1019 (X_dpr_dtl.deprn_reserve - h_sum_deprn_reserve);
1020 h_part_bonus_ytd := h_part_bonus_ytd + (X_dpr_dtl.bonus_ytd - h_sum_bonus_ytd);
1021 h_part_bonus_deprn_reserve := h_part_bonus_deprn_reserve +
1022 (X_dpr_dtl.bonus_deprn_reserve - h_sum_bonus_deprn_reserve);
1023
1024 if (X_dpr_dtl.reval_rsv_flag) then
1025 h_part_reval_reserve := h_part_reval_reserve +
1026 (X_dpr_dtl.reval_reserve - h_sum_reval_reserve);
1027 end if;
1028 if (X_dpr_dtl.ytd_reval_dep_exp_flag) then
1029 h_part_ytd_reval_dep_exp := h_part_ytd_reval_dep_exp +
1030 (X_dpr_dtl.ytd_reval_dep_exp - h_sum_ytd_reval_dep_exp);
1031 end if;
1032
1033 -- IAS36
1034 h_part_bonus_deprn_amount := h_part_bonus_deprn_amount + (X_dpr_dtl.bonus_deprn_amount - h_sum_bonus_amount);
1035 h_part_bonus_deprn_adj_amount := h_part_bonus_deprn_adj_amount + (X_dpr_dtl.bonus_deprn_adj_amount -
1036 h_sum_bonus_deprn_adj_amount);
1037 h_part_impairment_amount := h_part_impairment_amount + (X_dpr_dtl.impairment_amount - h_sum_impairment_amount);
1038 h_part_ytd_impairment := h_part_ytd_impairment + (X_dpr_dtl.ytd_impairment - h_sum_ytd_impairment);
1039 h_part_impairment_reserve := h_part_impairment_reserve + (X_dpr_dtl.impairment_reserve - h_sum_impairment_reserve);
1040 h_part_deprn_amount := h_part_deprn_amount + (X_dpr_dtl.deprn_amount - h_sum_deprn_amount);
1041 h_part_reval_amortization := h_part_reval_amortization + (X_dpr_dtl.reval_amortization - h_sum_reval_amortization);
1042 h_part_reval_deprn_expense := h_part_reval_deprn_expense + (X_dpr_dtl.reval_deprn_expense - h_sum_reval_deprn_expense);
1043
1044 -- Bug 6666666
1045 h_part_capital_adjustment := h_part_capital_adjustment + (X_dpr_dtl.capital_adjustment - h_sum_capital_adjustment);
1046 h_part_general_fund := h_part_general_fund + (X_dpr_dtl.general_fund - h_sum_general_fund);
1047
1048 END IF;
1049
1050 if (p_log_level_rec.statement_level) then
1051 fa_debug_pkg.add('FA_INS_DETAIL_PKG.fadpdtl','values before the insert to deprn_detail','', p_log_level_rec => p_log_level_rec);
1052 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','book',h_book_type_code, p_log_level_rec => p_log_level_rec);
1053 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','asset_id',h_asset_id, p_log_level_rec => p_log_level_rec);
1054 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','dist_id',h_dist_id, p_log_level_rec => p_log_level_rec);
1055 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','source_code',h_source_code, p_log_level_rec => p_log_level_rec);
1056 fa_debug_pkg.add('FA_INS_DETAIL_PKG.fadpdtl','period_counter',h_period_counter, p_log_level_rec => p_log_level_rec);
1057 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_deprn',h_part_ytd, p_log_level_rec => p_log_level_rec);
1058 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','deprn_reserve',h_part_deprn_reserve, p_log_level_rec => p_log_level_rec);
1059 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','reval_reserve',h_part_reval_reserve, p_log_level_rec => p_log_level_rec);
1060 fa_debug_pkg.add('FA_INS_DETAIL_PKG.faxindd','ytd_reval_deprn_expense',h_part_ytd_reval_dep_exp, p_log_level_rec => p_log_level_rec);
1061 end if;
1062
1063 if (G_release = 11) then
1064 h_cost_to_clear := h_part_cost;
1065 end if;
1066
1067 if (X_mrc_sob_type_code = 'R') then
1068 INSERT INTO fa_mc_deprn_detail
1069 (SET_OF_BOOKS_ID,
1070 BOOK_TYPE_CODE,
1071 ASSET_ID,
1072 DISTRIBUTION_ID,
1073 PERIOD_COUNTER,
1074 DEPRN_RUN_DATE,
1075 DEPRN_AMOUNT,
1076 YTD_DEPRN,
1077 ADDITION_COST_TO_CLEAR,
1078 DEPRN_RESERVE,
1079 /* Bug 525654 Modification */
1080 DEPRN_ADJUSTMENT_AMOUNT,
1081 REVAL_RESERVE,
1082 YTD_REVAL_DEPRN_EXPENSE,
1083 COST,
1084 DEPRN_SOURCE_CODE,
1085 BONUS_DEPRN_AMOUNT,
1086 BONUS_YTD_DEPRN,
1087 BONUS_DEPRN_RESERVE,
1088 BONUS_DEPRN_ADJUSTMENT_AMOUNT,
1089 IMPAIRMENT_AMOUNT,
1090 YTD_IMPAIRMENT,
1091 impairment_reserve,
1092 REVAL_AMORTIZATION,
1093 REVAL_DEPRN_EXPENSE,
1094 CAPITAL_ADJUSTMENT,
1095 GENERAL_FUND)
1096 VALUES (X_set_of_books_id,
1097 h_book_type_code,
1098 h_asset_id,
1099 h_dist_id,
1100 h_period_counter,
1101 h_sysdate,
1102 h_part_deprn_amount,
1103 h_part_ytd,
1104 decode(h_source_code, 'B', decode(h_count,0,h_part_cost,h_cost_to_clear),0), --Bug 9142501
1105 h_part_deprn_reserve,
1106 /* Bug 525654 Modification */
1107 h_part_deprn_adjustment_amount,
1108 h_part_reval_reserve,
1109 h_part_ytd_reval_dep_exp,
1110 decode(h_source_code, 'D',h_part_cost,0),
1111 h_source_code,
1112 h_part_bonus_deprn_amount,
1113 h_part_bonus_ytd,
1114 h_part_bonus_deprn_reserve,
1115 h_part_bonus_deprn_adj_amount,
1116 h_part_impairment_amount,
1117 h_part_ytd_impairment,
1118 h_part_impairment_reserve,
1119 h_part_reval_amortization,
1120 h_part_reval_deprn_expense,
1121 h_part_capital_adjustment,
1122 h_part_general_fund);
1123
1124 else
1125
1126 INSERT INTO fa_deprn_detail(BOOK_TYPE_CODE,
1127 ASSET_ID,
1128 DISTRIBUTION_ID,
1129 PERIOD_COUNTER,
1130 DEPRN_RUN_DATE,
1131 DEPRN_AMOUNT,
1132 YTD_DEPRN,
1133 ADDITION_COST_TO_CLEAR,
1134 DEPRN_RESERVE,
1135 /* Bug 525654 Modification */
1136 DEPRN_ADJUSTMENT_AMOUNT,
1137 REVAL_RESERVE,
1138 YTD_REVAL_DEPRN_EXPENSE,
1139 COST,
1140 DEPRN_SOURCE_CODE,
1141 BONUS_DEPRN_AMOUNT,
1142 BONUS_YTD_DEPRN,
1143 BONUS_DEPRN_RESERVE,
1144 BONUS_DEPRN_ADJUSTMENT_AMOUNT,
1145 IMPAIRMENT_AMOUNT,
1146 YTD_IMPAIRMENT,
1147 impairment_reserve,
1148 REVAL_AMORTIZATION,
1149 REVAL_DEPRN_EXPENSE,
1150 CAPITAL_ADJUSTMENT,
1151 GENERAL_FUND)
1152 VALUES (h_book_type_code,
1153 h_asset_id,
1154 h_dist_id,
1155 h_period_counter,
1156 h_sysdate,
1157 h_part_deprn_amount,
1158 h_part_ytd,
1159 decode(h_source_code, 'B', decode(h_count,0,h_part_cost,h_cost_to_clear),0), --Bug 9142501
1160 h_part_deprn_reserve,
1161 /* Bug 525654 Modification */
1162 h_part_deprn_adjustment_amount,
1163 h_part_reval_reserve,
1164 h_part_ytd_reval_dep_exp,
1165 decode(h_source_code, 'D',h_part_cost,0),
1166 h_source_code,
1167 h_part_bonus_deprn_amount,
1168 h_part_bonus_ytd,
1169 h_part_bonus_deprn_reserve,
1170 h_part_bonus_deprn_adj_amount,
1171 h_part_impairment_amount,
1172 h_part_ytd_impairment,
1173 h_part_impairment_reserve,
1174 h_part_reval_amortization,
1175 h_part_reval_deprn_expense,
1176 h_part_capital_adjustment,
1177 h_part_general_fund);
1178
1179 end if; -- end mrc
1180
1181 END LOOP;
1182
1183 if (G_release = 11 OR X_source_flag = FALSE ) then -- Bug# 8731454
1184 CLOSE C1_11;
1185 else
1186 CLOSE C1;
1187 end if;
1188
1189 return (TRUE);
1190
1191 EXCEPTION
1192 WHEN NO_DATA_FOUND THEN
1193 FA_SRVR_MSG.add_message(
1194 CALLING_FN => 'FA_INS_DETAIL_PKG.fadpdtl',
1195 NAME => h_msg_name, p_log_level_rec => p_log_level_rec);
1196 return (FALSE);
1197
1198 WHEN ERROR_FOUND THEN
1199 FA_SRVR_MSG.add_message(
1200 CALLING_FN => 'FA_INS_DETAIL_PKG.fadpdtl', p_log_level_rec => p_log_level_rec);
1201
1202 if (G_release = 11 OR X_source_flag = FALSE) then -- Bug# 8731454
1203 close C1_11;
1204 else
1205 close C1;
1206 end if;
1207
1208 return (FALSE);
1209
1210 WHEN OTHERS THEN
1211 FA_SRVR_MSG.ADD_SQL_ERROR(
1212 CALLING_FN => 'FA_INS_DETAIL.fadpdtl', p_log_level_rec => p_log_level_rec);
1213
1214 if (G_release = 11 OR X_source_flag = FALSE) then -- Bug# 8731454
1215 close C1_11;
1216 else
1217 close C1;
1218 end if;
1219
1220 return(FALSE);
1221 END fadpdtl;
1222
1223 END FA_INS_DETAIL_PKG;