[Home] [Help]
PACKAGE BODY: APPS.FA_IMPAIRMENT_POST_PVT
Source
1 PACKAGE BODY FA_IMPAIRMENT_POST_PVT AS
2 /* $Header: FAVIMPTB.pls 120.25.12020000.3 2013/03/29 11:34:22 saalampa ship $ */
3
4 g_print_debug boolean := fa_cache_pkg.fa_print_debug;
5 g_release number := fa_cache_pkg.fazarel_release;
6
7 --
8 -- Datatypes for pl/sql tables below
9 --
10 TYPE tab_rowid_type IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
11 TYPE tab_num15_type IS TABLE OF NUMBER(15) INDEX BY BINARY_INTEGER;
12 TYPE tab_num_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
13 TYPE tab_date_type IS TABLE OF DATE INDEX BY BINARY_INTEGER;
14 TYPE tab_char1_type IS TABLE OF VARCHAR2(15) INDEX BY BINARY_INTEGER;
15 TYPE tab_char3_type IS TABLE OF VARCHAR2(3) INDEX BY BINARY_INTEGER;
16 TYPE tab_char15_type IS TABLE OF VARCHAR2(15) INDEX BY BINARY_INTEGER;
17 TYPE tab_char30_type IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;
18
19 g_temp_number number;
20 g_temp_integer binary_integer;
21 g_temp_boolean boolean;
22 g_temp_varchar2 varchar2(100);
23
24
25 --*********************** Private functions ******************************--
26 FUNCTION call_deprn_basis(
27 p_asset_hdr_rec IN fa_api_types.asset_hdr_rec_type
28 , p_trans_rec IN fa_api_types.trans_rec_type
29 , p_period_rec IN fa_api_types.period_rec_type
30 , p_asset_type_rec IN fa_api_types.asset_type_rec_type
31 , p_asset_fin_rec IN fa_api_types.asset_fin_rec_type
32 , p_asset_deprn_rec IN fa_api_types.asset_deprn_rec_type
33 , p_asset_desc_rec IN fa_api_types.asset_desc_rec_type
34 , x_new_raf OUT NOCOPY NUMBER
35 , x_new_formula_factor OUT NOCOPY NUMBER
36 , x_new_adjusted_cost OUT NOCOPY NUMBER
37 , p_mrc_sob_type_code IN VARCHAR2
38 , p_calling_fn IN VARCHAR2
39 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) RETURN BOOLEAN;
40
41
42 FUNCTION create_cost_entries(
43 p_asset_hdr_rec IN fa_api_types.asset_hdr_rec_type
44 , p_trans_rec IN fa_api_types.trans_rec_type
45 , p_period_rec IN fa_api_types.period_rec_type
46 , p_asset_type_rec IN fa_api_types.asset_type_rec_type
47 , p_cost IN NUMBER
48 , p_current_units IN NUMBER
49 , p_mrc_sob_type_code IN VARCHAR2
50 , p_calling_fn IN VARCHAR2
51 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) RETURN BOOLEAN;
52
53
54 --*********************** Public functions ******************************--
55 FUNCTION process_post(
56 p_request_id IN NUMBER,
57 p_book_type_code IN VARCHAR2,
58 p_period_rec IN FA_API_TYPES.period_rec_type,
59 p_worker_id IN NUMBER,
60 p_mrc_sob_type_code IN VARCHAR2,
61 p_set_of_books_id IN NUMBER,
62 p_calling_fn IN VARCHAR2
63 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) RETURN BOOLEAN IS
64
65 l_calling_fn varchar2(60) := 'FA_IMPAIRMENT_POST_PVT.process_post';
66 l_mode varchar2(20) := 'RUNNING POST';
67
68 CURSOR c_get_itf is
69 select ITF.REQUEST_ID
70 , ITF.IMPAIRMENT_ID
71 , ITF.BOOK_TYPE_CODE
72 , ITF.ASSET_ID
73 , ITF.CASH_GENERATING_UNIT_ID
74 , ITF.NET_BOOK_VALUE
75 , ITF.NET_SELLING_PRICE
76 , ITF.VALUE_IN_USE
77 , ITF.IMPAIRMENT_AMOUNT
78 , ITF.YTD_IMPAIRMENT
79 , ITF.impairment_reserve
80 , ITF.GOODWILL_ASSET_FLAG
81 , NVL(ITF.DEPRN_RUN_DATE,sysdate) -- bug #6658765
82 , NVL(ITF.DEPRN_AMOUNT,0) -- bug #6658765
83 , NVL(ITF.YTD_DEPRN,0) -- bug #6658765
84 , NVL(ITF.DEPRN_RESERVE,0) -- bug #6658765
85 , ITF.ADJUSTED_COST
86 , ITF.BONUS_RATE
87 , ITF.LTD_PRODUCTION
88 , ITF.PERIOD_COUNTER
89 , ITF.PRODUCTION
90 , ITF.REVAL_AMORTIZATION
91 , ITF.REVAL_AMORTIZATION_BASIS
92 , ITF.REVAL_DEPRN_EXPENSE
93 , NVL(ITF.REVAL_RESERVE,0)
94 , ITF.YTD_PRODUCTION
95 , ITF.YTD_REVAL_DEPRN_EXPENSE
96 , ITF.PRIOR_FY_EXPENSE
97 , ITF.BONUS_DEPRN_AMOUNT
98 , ITF.BONUS_YTD_DEPRN
99 , ITF.BONUS_DEPRN_RESERVE
100 , ITF.PRIOR_FY_BONUS_EXPENSE
101 , ITF.DEPRN_OVERRIDE_FLAG
102 , ITF.SYSTEM_DEPRN_AMOUNT
103 , ITF.SYSTEM_BONUS_DEPRN_AMOUNT
104 , nvl(ITF.DEPRN_ADJUSTMENT_AMOUNT, 0)
105 , nvl(ITF.BONUS_DEPRN_ADJUSTMENT_AMOUNT, 0)
106 , ITF.COST
107 , ITF.CREATION_DATE
108 , ITF.CREATED_BY
109 , ITF.CURRENT_UNITS
110 , ITF.CATEGORY_ID
111 , ITF.IMPAIRMENT_DATE
112 , ITF.PERIOD_OF_ADDITION_FLAG
113 , nvl(ITF.REVAL_RESERVE_ADJ_AMOUNT, 0)
114 , ITF.RATE_ADJUSTMENT_FACTOR
115 , ITF.FORMULA_FACTOR
116 , ITF.EOFY_RESERVE
117 , ITF.CAPITAL_ADJUSTMENT -- Start of Bug 6666666
118 , ITF.GENERAL_FUND
119 , ITF.IMPAIR_CLASS
120 , ITF.IMPAIR_LOSS_ACCT
121 , ITF.SPLIT_IMPAIR_FLAG
122 , ITF.SPLIT1_IMPAIR_CLASS
123 , ITF.SPLIT1_LOSS_AMOUNT
124 , ITF.SPLIT1_REVAL_RESERVE
125 , ITF.SPLIT1_PERCENT
126 , ITF.SPLIT1_LOSS_ACCT
127 , ITF.SPLIT2_IMPAIR_CLASS
128 , ITF.SPLIT2_LOSS_AMOUNT
129 , ITF.SPLIT2_REVAL_RESERVE
130 , ITF.SPLIT2_PERCENT
131 , ITF.SPLIT2_LOSS_ACCT
132 , ITF.SPLIT3_IMPAIR_CLASS
133 , ITF.SPLIT3_LOSS_AMOUNT
134 , ITF.SPLIT3_REVAL_RESERVE
135 , ITF.SPLIT3_PERCENT
136 , ITF.SPLIT3_LOSS_ACCT -- End of Bug 6666666
137 , nvl(ITF.ALLOWED_DEPRN_LIMIT_AMOUNT,0)
138 , ITF.REVAL_LOSS_BALANCE
139 from FA_ITF_IMPAIRMENTS ITF
140 , FA_IMPAIRMENTS IMP
141 where ITF.WORKER_ID = p_worker_id
142 and ITF.BOOK_TYPE_CODE = p_book_type_code
143 and IMP.REQUEST_ID = p_request_id
144 and IMP.BOOK_TYPE_CODE = p_book_type_code
145 and IMP.IMPAIRMENT_ID = ITF.IMPAIRMENT_ID
146 and IMP.STATUS = l_mode
147 and (IMP.IMPAIRMENT_AMOUNT <> 0 AND IMP.NET_BOOK_VALUE <> 0) -- Bug# 7000391
148 -- and ITF.PERIOD_COUNTER = p_period_rec.period_counter
149 ;
150
151 CURSOR c_mc_get_itf is
152 select ITF.REQUEST_ID
153 , ITF.IMPAIRMENT_ID
154 , ITF.BOOK_TYPE_CODE
155 , ITF.ASSET_ID
156 , ITF.CASH_GENERATING_UNIT_ID
157 , ITF.NET_BOOK_VALUE
158 , ITF.NET_SELLING_PRICE
159 , ITF.VALUE_IN_USE
160 , ITF.IMPAIRMENT_AMOUNT
161 , ITF.YTD_IMPAIRMENT
162 , ITF.impairment_reserve
163 , ITF.GOODWILL_ASSET_FLAG
164 , NVL(ITF.DEPRN_RUN_DATE,sysdate) -- Bug #6658765
165 , NVL(ITF.DEPRN_AMOUNT,0) -- Bug #6658765
166 , NVL(ITF.YTD_DEPRN,0) -- Bug #6658765
167 , NVL(ITF.DEPRN_RESERVE,0) -- Bug #6658765
168 , ITF.ADJUSTED_COST
169 , ITF.BONUS_RATE
170 , ITF.LTD_PRODUCTION
171 , ITF.PERIOD_COUNTER
172 , ITF.PRODUCTION
173 , ITF.REVAL_AMORTIZATION
174 , ITF.REVAL_AMORTIZATION_BASIS
175 , ITF.REVAL_DEPRN_EXPENSE
176 , NVL(ITF.REVAL_RESERVE,0)
177 , ITF.YTD_PRODUCTION
178 , ITF.YTD_REVAL_DEPRN_EXPENSE
179 , ITF.PRIOR_FY_EXPENSE
180 , ITF.BONUS_DEPRN_AMOUNT
181 , ITF.BONUS_YTD_DEPRN
182 , ITF.BONUS_DEPRN_RESERVE
183 , ITF.PRIOR_FY_BONUS_EXPENSE
184 , ITF.DEPRN_OVERRIDE_FLAG
185 , ITF.SYSTEM_DEPRN_AMOUNT
186 , ITF.SYSTEM_BONUS_DEPRN_AMOUNT
187 , nvl(ITF.DEPRN_ADJUSTMENT_AMOUNT, 0)
188 , nvl(ITF.BONUS_DEPRN_ADJUSTMENT_AMOUNT, 0)
189 , ITF.COST
190 , ITF.CREATION_DATE
191 , ITF.CREATED_BY
192 , ITF.CURRENT_UNITS
193 , ITF.CATEGORY_ID
194 , ITF.IMPAIRMENT_DATE
195 , ITF.PERIOD_OF_ADDITION_FLAG
196 , nvl(ITF.REVAL_RESERVE_ADJ_AMOUNT, 0)
197 , ITF.RATE_ADJUSTMENT_FACTOR
198 , ITF.FORMULA_FACTOR
199 , ITF.EOFY_RESERVE
200 , ITF.CAPITAL_ADJUSTMENT -- Start of Bug 6666666
201 , ITF.GENERAL_FUND
202 , ITF.IMPAIR_CLASS
203 , ITF.IMPAIR_LOSS_ACCT
204 , ITF.SPLIT_IMPAIR_FLAG
205 , ITF.SPLIT1_IMPAIR_CLASS
206 , ITF.SPLIT1_LOSS_AMOUNT
207 , ITF.SPLIT1_REVAL_RESERVE
208 , ITF.SPLIT1_PERCENT
209 , ITF.SPLIT1_LOSS_ACCT
210 , ITF.SPLIT2_IMPAIR_CLASS
211 , ITF.SPLIT2_LOSS_AMOUNT
212 , ITF.SPLIT2_REVAL_RESERVE
213 , ITF.SPLIT2_PERCENT
214 , ITF.SPLIT2_LOSS_ACCT
215 , ITF.SPLIT3_IMPAIR_CLASS
216 , ITF.SPLIT3_LOSS_AMOUNT
217 , ITF.SPLIT3_REVAL_RESERVE
218 , ITF.SPLIT3_PERCENT
219 , ITF.SPLIT3_LOSS_ACCT -- End of Bug 6666666
220 , nvl(ITF.ALLOWED_DEPRN_LIMIT_AMOUNT,0)
221 , ITF.REVAL_LOSS_BALANCE
222 from FA_MC_ITF_IMPAIRMENTS ITF
223 , FA_MC_IMPAIRMENTS IMP
224 where ITF.WORKER_ID = p_worker_id
225 and ITF.BOOK_TYPE_CODE = p_book_type_code
226 and ITF.SET_OF_BOOKS_ID = p_set_of_books_id
227 and IMP.REQUEST_ID = p_request_id
228 and IMP.BOOK_TYPE_CODE = p_book_type_code
229 and IMP.IMPAIRMENT_ID = ITF.IMPAIRMENT_ID
230 and IMP.STATUS = l_mode
231 and IMP.SET_OF_BOOKS_ID = p_set_of_books_id
232 and (IMP.IMPAIRMENT_AMOUNT <> 0 AND IMP.NET_BOOK_VALUE <> 0) -- Bug# 7000391
233 -- and ITF.PERIOD_COUNTER = p_period_rec.period_counter
234 ;
235
236
237 l_asset_hdr_rec fa_api_types.asset_hdr_rec_type;
238
239 CURSOR c_get_dists IS
240 select th.transaction_header_id
241 , th.transaction_date_entered
242 , th.date_effective
243 , th.last_update_date
244 , th.last_updated_by
245 , th.transaction_subtype
246 , th.transaction_key
247 , th.amortization_start_date
248 , th.calling_interface
249 , decode(dt.transaction_header_id_out, null, null, dt.distribution_id)
250 , dt.code_combination_id
251 , dt.location_id
252 , dt.assigned_to
253 , dt.transaction_units
254 FROM fa_transaction_headers th
255 , fa_distribution_history dt
256 WHERE th.book_type_code = p_book_type_code
257 AND th.asset_id = l_asset_hdr_rec.asset_id
258 AND dt.asset_id = l_asset_hdr_rec.asset_id
259 AND dt.book_type_code = p_book_type_code
260 AND (dt.transaction_header_id_in = th.transaction_header_id or
261 dt.transaction_header_id_out = th.transaction_header_id)
262 AND th.transaction_type_code = 'TRANSFER'
263 AND th.transaction_date_entered <
264 p_period_rec.calendar_period_open_date
265 AND th.date_effective >= p_period_rec.period_open_date;
266
267 /* 12844989 - to set correct old_adj_cost of asset in extended deprn period.*/
268 CURSOR c_mc_get_old_adj_cost IS
269 select fb.ADJUSTED_COST
270 from fa_mc_books fb,fa_transaction_headers fth
271 where fb.asset_id = l_asset_hdr_rec.asset_id
272 and fb. book_type_code = l_asset_hdr_rec.book_type_code
273 and fb.transaction_header_id_in = fth.transaction_header_id
274 and fb.book_type_code = fth.book_type_code
275 and fb.asset_id = fth.asset_id
276 and fb.deprn_method_code = 'JP-STL-EXTND'
277 and nvl(fth.transaction_key,'XX') <> 'IM'
278 order by fth.transaction_header_id desc;
279
280 CURSOR c_get_old_adj_cost IS
281 select fb.ADJUSTED_COST
282 from fa_books fb,fa_transaction_headers fth
283 where fb.asset_id = l_asset_hdr_rec.asset_id
284 and fb. book_type_code = l_asset_hdr_rec.book_type_code
285 and fb.transaction_header_id_in = fth.transaction_header_id
286 and fb.book_type_code = fth.book_type_code
287 and fb.asset_id = fth.asset_id
288 and fb.deprn_method_code = 'JP-STL-EXTND'
289 and nvl(fth.transaction_key,'XX') <> 'IM'
290 order by fth.transaction_header_id desc;
291
292 t_request_id tab_num15_type;
293 t_impairment_id tab_num15_type;
294 t_book_type_code tab_char15_type;
295 t_asset_id tab_num15_type;
296 t_cash_generating_unit_id tab_num15_type;
297 t_net_book_value tab_num_type;
298 t_net_selling_price tab_num_type;
299 t_value_in_use tab_num_type;
300 t_impairment_amount tab_num_type;
301 t_ytd_impairment tab_num_type;
302 t_impairment_reserve tab_num_type;
303 t_goodwill_asset_flag tab_char1_type;
304 t_deprn_run_date tab_date_type;
305 t_deprn_amount tab_num_type;
306 t_ytd_deprn tab_num_type;
307 t_deprn_reserve tab_num_type;
308 t_adjusted_cost tab_num_type;
309 t_bonus_rate tab_num_type;
310 t_ltd_production tab_num_type;
311 t_period_counter tab_num15_type;
312 t_production tab_num_type;
313 t_reval_amortization tab_num_type;
314 t_reval_amortization_basis tab_num_type;
315 t_reval_deprn_expense tab_num_type;
316 t_reval_reserve tab_num_type;
317 t_ytd_production tab_num_type;
318 t_ytd_reval_deprn_expense tab_num_type;
319 t_prior_fy_expense tab_num_type;
320 t_bonus_deprn_amount tab_num_type;
321 t_bonus_ytd_deprn tab_num_type;
322 t_bonus_deprn_reserve tab_num_type;
323 t_prior_fy_bonus_expense tab_num_type;
324 t_deprn_override_flag tab_char1_type;
325 t_system_deprn_amount tab_num_type;
326 t_system_bonus_deprn_amount tab_num_type;
327 t_deprn_adjustment_amount tab_num_type;
328 t_bonus_deprn_adj_amount tab_num_type;
329 t_cost tab_num_type;
330 t_creation_date tab_date_type;
331 t_created_by tab_num15_type;
332 t_current_units tab_num_type;
333 t_category_id tab_num15_type;
334 t_impairment_date tab_date_type;
335 t_new_adj_cost tab_num_type;
336 t_period_of_addition_flag tab_char1_type;
337 t_reval_reserve_adj_amount tab_num_type;
338 t_capital_adjustment tab_num_type; -- Start of Bug 6666666
339 t_general_fund tab_num_type;
340 t_impair_class tab_char3_type;
341 t_impair_loss_acct tab_char30_type;
342 t_split_impair_flag tab_char1_type;
343 t_split1_impair_class tab_char3_type;
344 t_split1_loss_amount tab_num_type;
345 t_split1_reval_reserve tab_num_type;
346 t_split1_percent tab_num_type;
347 t_split1_loss_acct tab_char30_type;
348 t_split2_impair_class tab_char3_type;
349 t_split2_loss_amount tab_num_type;
350 t_split2_reval_reserve tab_num_type;
351 t_split2_percent tab_num_type;
352 t_split2_loss_acct tab_char30_type;
353 t_split3_impair_class tab_char3_type;
354 t_split3_loss_amount tab_num_type;
355 t_split3_reval_reserve tab_num_type;
356 t_split3_percent tab_num_type;
357 t_split3_loss_acct tab_char30_type; -- End of Bug 6666666
358 t_allowed_deprn_limit_amount tab_num_type;
359 t_reval_loss_balance tab_num_type;
360
361
362 t_thid FA_IMPAIRMENT_DELETE_PVT.tab_num15_type; /* 8394781 */
363 t_old_thid tab_num15_type;
364 t_new_raf tab_num_type;
365 t_new_formula_factor tab_num_type;
366 t_raf tab_num_type;
367 t_formula_factor tab_num_type;
368 t_eofy_reserve tab_num_type;
369
370 t_dist_thid tab_num15_type;
371 t_transaction_date_entered tab_date_type;
372 t_date_effective tab_date_type;
373 t_last_update_date tab_date_type;
374 t_last_updated_by tab_num15_type;
375 t_transaction_subtype tab_char15_type;
376 t_transaction_key tab_char3_type;
377 t_amortization_start_date tab_date_type;
378 t_calling_interface tab_char30_type;
379 t_dist_id tab_num15_type;
380 t_ccid tab_num15_type;
381 t_loc_id tab_num15_type;
382 t_assign_to tab_num15_type;
383 t_trx_units tab_num_type;
384
385 t_rate_in_use tab_num_type; --9781938 /*changed these variable to table type*/
386 t_nbv_at_switch tab_num_type; --9781938 /*changed these variable to table type*/
387
388 t_period_counter_fully_rsv tab_num_type; --9781938 /*changed these variable to table type*/
389 t_period_counter_life_complete tab_num_type; --9781938 /*changed these variable to table type*/
390 t_period_counter_fully_ext tab_num_type; --9786860
391 l_adj FA_ADJUST_TYPE_PKG.FA_ADJ_ROW_STRUCT;
392
393 l_trans_rec fa_api_types.trans_rec_type;
394 l_asset_type_rec fa_api_types.asset_type_rec_type;
395 l_asset_fin_rec fa_api_types.asset_fin_rec_type;
396 l_asset_deprn_rec fa_api_types.asset_deprn_rec_type;
397 l_asset_desc_rec fa_api_types.asset_desc_rec_type;
398 l_asset_cat_rec fa_api_types.asset_cat_rec_type;
399 l_asset_dist_tbl fa_api_types.asset_dist_tbl_type;
400
401 l_period_counter number(15); -- store period counter impaired
402
403 l_limit binary_integer := 200; -- limit constant for C1 cursor
404
405 --secondary changes
406 l_secondary_sob_id number;
407
408 pos_err exception;
409 x_return_status number := 0;
410
411
412 BEGIN
413
414 if (p_log_level_rec.statement_level) then
415 fa_debug_pkg.add(l_calling_fn,'Process Post', 'BEGIN', p_log_level_rec => p_log_level_rec);
416 fa_debug_pkg.add(l_calling_fn,'worker id', p_worker_id, p_log_level_rec => p_log_level_rec);
417 fa_debug_pkg.add(l_calling_fn,'book type code', p_book_type_code, p_log_level_rec => p_log_level_rec);
418 fa_debug_pkg.add(l_calling_fn,'period counter', p_period_rec.period_counter, p_log_level_rec => p_log_level_rec);
419 fa_debug_pkg.add(l_calling_fn,'request_id', p_request_id, p_log_level_rec => p_log_level_rec);
420 end if;
421
422 -- Initializing common variables
423 l_adj.book_type_code := p_book_type_code;
424 l_adj.period_counter_created := p_period_rec.period_counter;
425 l_adj.period_counter_adjusted := p_period_rec.period_counter;
426 l_adj.selection_mode := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
427 l_adj.selection_retid := 0;
428 l_adj.leveling_flag := TRUE;
429 l_adj.flush_adj_flag := TRUE; --FALSE;
430 l_adj.gen_ccid_flag := TRUE;
431 l_adj.track_member_flag := null;
432 l_adj.set_of_books_id := p_set_of_books_id; -- RER12 MRC changes
433 l_adj.mrc_sob_type_code := p_mrc_sob_type_code; --8666930
434 l_asset_hdr_rec.book_type_code := p_book_type_code;
435 l_asset_hdr_rec.set_of_books_id := p_set_of_books_id;
436
437 /*Bug#9182681 - to update request_id,for asset impairment report */
438 if (p_mrc_sob_type_code = 'R') then
439 UPDATE FA_MC_ITF_IMPAIRMENTS
440 set REQUEST_ID = p_request_id
441 WHERE WORKER_ID = p_worker_id
442 AND BOOK_TYPE_CODE = p_book_type_code
443 AND SET_OF_BOOKS_ID = p_set_of_books_id
444 AND IMPAIRMENT_ID in
445 (SELECT IMPAIRMENT_ID
446 FROM FA_MC_IMPAIRMENTS IMP
447 WHERE IMP.BOOK_TYPE_CODE = p_book_type_code
448 AND IMP.STATUS = l_mode
449 AND IMP.SET_OF_BOOKS_ID = p_set_of_books_id
450 AND (IMP.IMPAIRMENT_AMOUNT <> 0 AND IMP.NET_BOOK_VALUE <> 0));
451 else
452 UPDATE FA_ITF_IMPAIRMENTS
453 set REQUEST_ID = p_request_id
454 WHERE WORKER_ID = p_worker_id
455 AND BOOK_TYPE_CODE = p_book_type_code
456 AND IMPAIRMENT_ID in
457 (SELECT IMPAIRMENT_ID
458 FROM FA_IMPAIRMENTS IMP
459 WHERE IMP.BOOK_TYPE_CODE = p_book_type_code
460 AND IMP.STATUS = l_mode
461 AND (IMP.IMPAIRMENT_AMOUNT <> 0 AND IMP.NET_BOOK_VALUE <> 0));
462 end if;
463
464 if (p_mrc_sob_type_code = 'R') then
465 OPEN c_mc_get_itf;
466 else
467 OPEN c_get_itf;
468 end if;
469 --
470 -- Outer Loop
471 LOOP
472 if (p_log_level_rec.statement_level) then
473 fa_debug_pkg.add(l_calling_fn,'Inside of ', 'Outer Loop', p_log_level_rec => p_log_level_rec);
474 end if;
475
476 t_thid.delete;
477 t_old_thid.delete;
478
479 if (p_mrc_sob_type_code = 'R') then
480 FETCH c_mc_get_itf BULK COLLECT INTO t_request_id
481 , t_impairment_id
482 , t_book_type_code
483 , t_asset_id
484 , t_cash_generating_unit_id
485 , t_net_book_value
486 , t_net_selling_price
487 , t_value_in_use
488 , t_impairment_amount
489 , t_ytd_impairment
490 , t_impairment_reserve
491 , t_goodwill_asset_flag
492 , t_deprn_run_date
493 , t_deprn_amount
494 , t_ytd_deprn
495 , t_deprn_reserve
496 , t_adjusted_cost
497 , t_bonus_rate
498 , t_ltd_production
499 , t_period_counter
500 , t_production
501 , t_reval_amortization
502 , t_reval_amortization_basis
503 , t_reval_deprn_expense
504 , t_reval_reserve
505 , t_ytd_production
506 , t_ytd_reval_deprn_expense
507 , t_prior_fy_expense
508 , t_bonus_deprn_amount
509 , t_bonus_ytd_deprn
510 , t_bonus_deprn_reserve
511 , t_prior_fy_bonus_expense
512 , t_deprn_override_flag
513 , t_system_deprn_amount
514 , t_system_bonus_deprn_amount
515 , t_deprn_adjustment_amount
516 , t_bonus_deprn_adj_amount
517 , t_cost
518 , t_creation_date
519 , t_created_by
520 , t_current_units
521 , t_category_id
522 , t_impairment_date
523 , t_period_of_addition_flag
524 , t_reval_reserve_adj_amount
525 , t_raf
526 , t_formula_factor
527 , t_eofy_reserve
528 , t_capital_adjustment -- Start of Bug 6666666
529 , t_general_fund
530 , t_impair_class
531 , t_impair_loss_acct
532 , t_split_impair_flag
533 , t_split1_impair_class
534 , t_split1_loss_amount
535 , t_split1_reval_reserve
536 , t_split1_percent
537 , t_split1_loss_acct
538 , t_split2_impair_class
539 , t_split2_loss_amount
540 , t_split2_reval_reserve
541 , t_split2_percent
542 , t_split2_loss_acct
543 , t_split3_impair_class
544 , t_split3_loss_amount
545 , t_split3_reval_reserve
546 , t_split3_percent
547 , t_split3_loss_acct -- End of Bug 6666666
548 , t_allowed_deprn_limit_amount
549 , t_reval_loss_balance
550 LIMIT l_limit;
551
552
553 else
554 FETCH c_get_itf BULK COLLECT INTO t_request_id
555 , t_impairment_id
556 , t_book_type_code
557 , t_asset_id
558 , t_cash_generating_unit_id
559 , t_net_book_value
560 , t_net_selling_price
561 , t_value_in_use
562 , t_impairment_amount
563 , t_ytd_impairment
564 , t_impairment_reserve
565 , t_goodwill_asset_flag
566 , t_deprn_run_date
567 , t_deprn_amount
568 , t_ytd_deprn
569 , t_deprn_reserve
570 , t_adjusted_cost
571 , t_bonus_rate
572 , t_ltd_production
573 , t_period_counter
574 , t_production
575 , t_reval_amortization
576 , t_reval_amortization_basis
577 , t_reval_deprn_expense
578 , t_reval_reserve
579 , t_ytd_production
580 , t_ytd_reval_deprn_expense
581 , t_prior_fy_expense
582 , t_bonus_deprn_amount
583 , t_bonus_ytd_deprn
584 , t_bonus_deprn_reserve
585 , t_prior_fy_bonus_expense
586 , t_deprn_override_flag
587 , t_system_deprn_amount
588 , t_system_bonus_deprn_amount
589 , t_deprn_adjustment_amount
590 , t_bonus_deprn_adj_amount
591 , t_cost
592 , t_creation_date
593 , t_created_by
594 , t_current_units
595 , t_category_id
596 , t_impairment_date
597 , t_period_of_addition_flag
598 , t_reval_reserve_adj_amount
599 , t_raf
600 , t_formula_factor
601 , t_eofy_reserve
602 , t_capital_adjustment -- Start of Bug 6666666
603 , t_general_fund
604 , t_impair_class
605 , t_impair_loss_acct
606 , t_split_impair_flag
607 , t_split1_impair_class
608 , t_split1_loss_amount
609 , t_split1_reval_reserve
610 , t_split1_percent
611 , t_split1_loss_acct
612 , t_split2_impair_class
613 , t_split2_loss_amount
614 , t_split2_reval_reserve
615 , t_split2_percent
616 , t_split2_loss_acct
617 , t_split3_impair_class
618 , t_split3_loss_amount
619 , t_split3_reval_reserve
620 , t_split3_percent
621 , t_split3_loss_acct -- End of Bug 6666666
622 , t_allowed_deprn_limit_amount
623 , t_reval_loss_balance
624 LIMIT l_limit;
625
626 end if;
627
628 if (p_log_level_rec.statement_level) then
629 fa_debug_pkg.add(l_calling_fn,'t_request_id.count', t_request_id.count, p_log_level_rec => p_log_level_rec);
630
631 for i in 1..t_request_id.count loop
632 fa_debug_pkg.add(l_calling_fn,'t_impairment_id', t_impairment_id(i));
633 fa_debug_pkg.add(l_calling_fn,'t_asset_id', t_asset_id(i));
634 end loop;
635 end if;
636
637 if (t_request_id.count = 0) then
638 if (p_mrc_sob_type_code = 'R') then
639 CLOSE c_mc_get_itf;
640 else
641 CLOSE c_get_itf;
642 end if;
643 EXIT;
644 end if;
645
646 l_period_counter := t_period_counter(1);
647
648 fa_std_types.deprn_override_trigger_enabled := FALSE; --16275774 start
649
650 FORALL i in 1..t_request_id.count
651 UPDATE fa_deprn_override
652 SET status = 'POSTED'
653 WHERE asset_id = t_asset_id(i)
654 AND book_type_code = p_book_type_code
655 AND period_name = p_period_rec.period_name
656 AND t_deprn_override_flag(i) <> fa_std_types.FA_NO_OVERRIDE;
657
658 fa_std_types.deprn_override_trigger_enabled := TRUE; --16275774 end
659
660 -- Insert th
661 if (p_mrc_sob_type_code = 'R') then
662 -- select impairment thid of primary book
663 -- Following update is to get thid from primary book
664 if (p_log_level_rec.statement_level) then
665 fa_debug_pkg.add(l_calling_fn,'Getting Records from ', 'FA_TRANSACTION_HEADERS', p_log_level_rec => p_log_level_rec);
666 end if;
667
668 FORALL i in 1..t_request_id.count
669 UPDATE FA_TRANSACTION_HEADERS
670 SET ATTRIBUTE15 = ATTRIBUTE15
671 WHERE ASSET_ID = t_asset_id(i)
672 AND BOOK_TYPE_CODE = p_book_type_code
673 AND TRANSACTION_TYPE_CODE = decode(G_release,'11',decode(t_period_of_addition_flag(i), 'Y', 'ADDITION', 'ADJUSTMENT'),'ADJUSTMENT')
674 AND TRANSACTION_DATE_ENTERED = t_impairment_date(i)
675 AND TRANSACTION_SUBTYPE = 'AMORTIZED'
676 AND TRANSACTION_KEY = 'IM'
677 AND CALLING_INTERFACE = 'FAPIMP'
678 AND DATE_EFFECTIVE = t_creation_date(i)
679 RETURNING TRANSACTION_HEADER_ID BULK COLLECT INTO t_thid;
680 -- Secondary Changes
681 if G_release <> 11 and p_mrc_sob_type_code = 'R' then
682
683 l_secondary_sob_id := FA_XLA_EVENTS_PVT.get_secondary_sob_id(p_book_type_code);
684
685 if(l_secondary_sob_id > 0)then
686 if not FA_IMPAIRMENT_DELETE_PVT.process_impair_event(
687 p_book_type_code => p_book_type_code,
688 p_mrc_sob_type_code => p_mrc_sob_type_code,
689 p_set_of_books_id => l_secondary_sob_id,
690 p_calling_fn => l_calling_fn ,
691 p_thid => t_thid,
692 p_log_level_rec => p_log_level_rec ) then
693
694 raise pos_err;
695 end if;
696 end if;
697
698 end if;
699 else
700 if (p_log_level_rec.statement_level) then
701 fa_debug_pkg.add(l_calling_fn,'Insert into ', 'FA_TRANSACTION_HEADERS', p_log_level_rec => p_log_level_rec);
702 end if;
703
704 if G_release = 11 then
705 FORALL i in 1..t_request_id.count
706 UPDATE FA_TRANSACTION_HEADERS
707 SET TRANSACTION_TYPE_CODE = 'ADDITION/VOID'
708 WHERE t_period_of_addition_flag(i) = 'Y'
709 AND asset_id = t_asset_id(i)
710 AND book_type_code = p_book_type_code
711 AND transaction_type_code = 'ADDITION';
712 end if;
713
714 FORALL i in 1..t_request_id.count
715 INSERT INTO FA_TRANSACTION_HEADERS(
716 TRANSACTION_HEADER_ID
717 , BOOK_TYPE_CODE
718 , ASSET_ID
719 , TRANSACTION_TYPE_CODE
720 , TRANSACTION_DATE_ENTERED
721 , DATE_EFFECTIVE
722 , LAST_UPDATE_DATE
723 , LAST_UPDATED_BY
724 , TRANSACTION_SUBTYPE
725 , TRANSACTION_KEY
726 , AMORTIZATION_START_DATE
727 , CALLING_INTERFACE
728 , MASS_TRANSACTION_ID
729 ) VALUES (
730 FA_TRANSACTION_HEADERS_S.NEXTVAL
731 , p_book_type_code
732 , t_asset_id(i)
733 , decode(G_release,'11',decode(t_period_of_addition_flag(i), 'Y', 'ADDITION', 'ADJUSTMENT'),'ADJUSTMENT')
734 , t_impairment_date(i)
735 , t_creation_date(i)
736 , t_creation_date(i)
737 , t_created_by(i)
738 , 'AMORTIZED'
739 , 'IM'
740 , t_impairment_date(i)
741 , 'FAPIMP'
742 , t_impairment_id(i)
743 ) RETURNING transaction_header_id BULK COLLECT INTO t_thid;
744 end if;
745
746 /*8394781 - To create event */
747 if G_release <> 11 and p_mrc_sob_type_code = 'P' then
748 if not FA_IMPAIRMENT_DELETE_PVT.process_impair_event(
749 p_book_type_code => p_book_type_code,
750 p_mrc_sob_type_code => p_mrc_sob_type_code,
751 p_set_of_books_id => p_set_of_books_id,
752 p_calling_fn => l_calling_fn ,
753 p_thid => t_thid,
754 p_log_level_rec => p_log_level_rec ) then
755
756 raise pos_err;
757 end if;
758 end if;
759
760 FOR i in 1..t_request_id.count LOOP
761
762 l_asset_hdr_rec.asset_id := t_asset_id(i);
763 l_asset_hdr_rec.period_of_addition := t_period_of_addition_flag(i);
764
765 l_adj.asset_id := l_asset_hdr_rec.asset_id;
766 l_adj.transaction_header_id := t_thid(i);
767 l_adj.current_units := t_current_units(i);
768 l_adj.adjustment_amount := t_impairment_amount(i) + t_reval_reserve_adj_amount(i);
769 l_adj.last_update_date := t_creation_date(i);
770
771 -- Need to skip followings if this is backdated imp
772 if (p_period_rec.period_counter = l_period_counter) then
773
774 -- Populate fin rec
775 if not FA_UTIL_PVT.get_asset_fin_rec
776 (p_asset_hdr_rec => l_asset_hdr_rec,
777 px_asset_fin_rec => l_asset_fin_rec,
778 p_transaction_header_id => NULL,
779 p_mrc_sob_type_code => p_mrc_sob_type_code, p_log_level_rec => p_log_level_rec) then
780 raise pos_err;
781 end if;
782
783 if not FA_UTIL_PVT.get_asset_desc_rec(
784 p_asset_hdr_rec => l_asset_hdr_rec,
785 px_asset_desc_rec => l_asset_desc_rec, p_log_level_rec => p_log_level_rec) then
786 raise pos_err;
787 end if;
788
789
790 if (l_asset_fin_rec.adjustment_required_status = 'TFR') then
791 -- ************************************
792 -- Process Prior Period Transfer if any
793 -- ************************************
794 if (p_log_level_rec.statement_level) then
795 fa_debug_pkg.add(l_calling_fn,'Start processing ', 'Prior Period Transfer', p_log_level_rec => p_log_level_rec);
796 end if;
797
798 l_asset_cat_rec.category_id := t_category_id(i);
799
800 l_asset_dist_tbl.delete;
801
802 OPEN c_get_dists;
803 FETCH c_get_dists BULK COLLECT INTO t_dist_thid
804 , t_transaction_date_entered
805 , t_date_effective
806 , t_last_update_date
807 , t_last_updated_by
808 , t_transaction_subtype
809 , t_transaction_key
810 , t_amortization_start_date
811 , t_calling_interface
812 , t_dist_id
813 , t_ccid
814 , t_loc_id
815 , t_assign_to
816 , t_trx_units;
817 CLOSE c_get_dists;
818
819 for j in 1..t_dist_thid.count loop
820 l_asset_dist_tbl(j).distribution_id := t_dist_id(j);
821 l_asset_dist_tbl(j).transaction_units := t_trx_units(j);
822 l_asset_dist_tbl(j).assigned_to := t_assign_to(j);
823 l_asset_dist_tbl(j).expense_ccid := t_ccid(j);
824 l_asset_dist_tbl(j).location_ccid := t_loc_id(j);
825 end loop;
826
827 if (p_log_level_rec.statement_level) then
828 fa_debug_pkg.add(l_calling_fn,'l_asset_dist_tbl has been populated ', t_dist_thid.count, p_log_level_rec => p_log_level_rec);
829 end if;
830
831 if not FA_TRANSFER_PVT.fadppt
832 (p_trans_rec => l_trans_rec,
833 p_asset_hdr_rec => l_asset_hdr_rec,
834 p_asset_desc_rec => l_asset_desc_rec,
835 p_asset_cat_rec => l_asset_cat_rec,
836 p_asset_dist_tbl => l_asset_dist_tbl, p_log_level_rec => p_log_level_rec) then
837 raise pos_err;
838 end if;
839 end if;
840
841
842 l_trans_rec.transaction_header_id := t_thid(i);
843 l_trans_rec.transaction_date_entered := t_impairment_date(i);
844 l_trans_rec.amortization_start_date := l_trans_rec.transaction_date_entered;
845
846 l_trans_rec.transaction_type_code := 'ADJUSTMENT';
847 l_trans_rec.transaction_subtype := 'AMORTIZED';
848 l_trans_rec.transaction_key := 'IM';
849 l_trans_rec.who_info.last_update_date := t_creation_date(i);
850 l_trans_rec.who_info.last_updated_by := t_created_by(i);
851 l_trans_rec.who_info.created_by := t_created_by(i);
852 l_trans_rec.who_info.creation_date := t_creation_date(i);
853
854 -- popualte type rec
855 if not FA_UTIL_PVT.get_asset_type_rec
856 (p_asset_hdr_rec => l_asset_hdr_rec,
857 px_asset_type_rec => l_asset_type_rec,
858 p_date_effective => null, p_log_level_rec => p_log_level_rec) then
859 raise pos_err;
860 end if;
861
862 if not fa_cache_pkg.fazccb(p_book_type_code,
863 t_category_id(i),
864 p_log_level_rec) then
865 fa_srvr_msg.add_message(calling_fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
866 raise pos_err;
867 end if;
868
869 if (t_period_of_addition_flag(i) = 'Y') and G_release = 11 then
870 -- *****************************************
871 -- Process (Cip_)cost entries for addition
872 -- *****************************************
873 if (p_log_level_rec.statement_level) then
874 fa_debug_pkg.add(l_calling_fn,'Calling function ', 'create_cost_entries', p_log_level_rec => p_log_level_rec);
875 end if;
876
877 if not create_cost_entries(p_asset_hdr_rec => l_asset_hdr_rec
878 , p_trans_rec => l_trans_rec
879 , p_period_rec => p_period_rec
880 , p_asset_type_rec => l_asset_type_rec
881 , p_cost => t_cost(i)
882 , p_current_units => t_current_units(i)
883 , p_mrc_sob_type_code => p_mrc_sob_type_code
884 , p_calling_fn => l_calling_fn
885 , p_log_level_rec => p_log_level_rec
886 ) then
887 fa_srvr_msg.add_message(calling_fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
888 raise pos_err;
889 end if;
890
891
892 if (l_asset_fin_rec.adjustment_required_status = 'ADD') and
893 (t_deprn_adjustment_amount(i) <> 0) then
894 -- *****************************************
895 -- Process Prior Period Addition if any
896 -- *****************************************
897 /*Bug#7685879 - replaced t_impairment_amount with t_deprn_adjustment_amount */
898 l_adj.adjustment_amount := t_deprn_adjustment_amount(i);
899 l_adj.source_type_code := 'DEPRECIATION';
900 l_adj.adjustment_type := 'EXPENSE';
901 l_adj.account := fa_cache_pkg.fazccb_record.deprn_expense_acct;
902 l_adj.account_type := 'DEPRN_EXPENSE_ACCT';
903 l_adj.debit_credit_flag := 'DR';
904
905 if (p_log_level_rec.statement_level) then
906 fa_debug_pkg.add(l_calling_fn,'Calling faxinaj for ', 'ppa Catch-up Expense', p_log_level_rec => p_log_level_rec);
907 end if;
908
909 if not FA_INS_ADJUST_PKG.faxinaj (l_adj,
910 t_creation_date(i),
911 t_created_by(i),
912 -1,
913 p_log_level_rec) then
914 raise pos_err;
915 end if;
916
917 if (p_log_level_rec.statement_level) then
918 fa_debug_pkg.add(l_calling_fn,'Calling function ', 'Prior Period Addition', p_log_level_rec => p_log_level_rec);
919 end if;
920
921 end if;
922
923 end if;
924
925 l_asset_deprn_rec.set_of_books_id := l_asset_hdr_rec.set_of_books_id;
926 l_asset_deprn_rec.deprn_amount := t_deprn_amount(i);
927 l_asset_deprn_rec.ytd_deprn := t_ytd_deprn(i);
928 l_asset_deprn_rec.deprn_reserve := t_deprn_reserve(i);
929 l_asset_deprn_rec.prior_fy_expense := t_prior_fy_expense(i);
930 l_asset_deprn_rec.bonus_deprn_amount := t_bonus_deprn_amount(i);
931 l_asset_deprn_rec.bonus_ytd_deprn := t_bonus_ytd_deprn(i);
932 l_asset_deprn_rec.bonus_deprn_reserve := t_bonus_deprn_reserve(i);
933 l_asset_deprn_rec.prior_fy_bonus_expense := t_prior_fy_bonus_expense(i);
934 l_asset_deprn_rec.reval_amortization := t_reval_amortization(i);
935 l_asset_deprn_rec.reval_amortization_basis := t_reval_amortization_basis(i);
936 l_asset_deprn_rec.reval_deprn_expense := t_reval_deprn_expense(i);
937 l_asset_deprn_rec.reval_ytd_deprn := t_ytd_reval_deprn_expense(i);
938 l_asset_deprn_rec.reval_deprn_reserve := t_reval_reserve(i);
939 l_asset_deprn_rec.production := t_production(i);
940 l_asset_deprn_rec.ytd_production := t_ytd_production(i);
941 l_asset_deprn_rec.ltd_production := t_ltd_production(i);
942 l_asset_deprn_rec.impairment_amount := t_impairment_amount(i);
943 l_asset_deprn_rec.ytd_impairment := t_ytd_impairment(i);
944 l_asset_deprn_rec.impairment_reserve := t_impairment_reserve(i);
945
946
947 -- Calculate New deprn basis
948 if (p_log_level_rec.statement_level) then
949 fa_debug_pkg.add(l_calling_fn,'Calling function ', 'Deprn Basis', p_log_level_rec => p_log_level_rec);
950 end if;
951
952 if (p_log_level_rec.statement_level) then
953 fa_debug_pkg.add(l_calling_fn, 'Before Calling', 'fa_cache_pkg.fazccmt', p_log_level_rec => p_log_level_rec);
954 fa_debug_pkg.add(l_calling_fn, 'deprn_method_code', l_asset_fin_rec.deprn_method_code, p_log_level_rec => p_log_level_rec);
955 fa_debug_pkg.add(l_calling_fn, 'life_in_months', l_asset_fin_rec.life_in_months, p_log_level_rec => p_log_level_rec);
956 end if;
957
958 if (not fa_cache_pkg.fazccmt(l_asset_fin_rec.deprn_method_code,
959 l_asset_fin_rec.life_in_months, p_log_level_rec => p_log_level_rec)) then
960 if (p_log_level_rec.statement_level) then
961 fa_debug_pkg.add(l_calling_fn, 'Error calling', 'fa_cache_pkg.fazccmt', p_log_level_rec => p_log_level_rec);
962 end if;
963
964 raise pos_err;
965 end if;
966
967 if (p_log_level_rec.statement_level) then
968 fa_debug_pkg.add(l_calling_fn, 'rate_source_rule', fa_cache_pkg.fazccmt_record.rate_source_rule, p_log_level_rec => p_log_level_rec);
969 fa_debug_pkg.add(l_calling_fn, 'deprn_basis_rule', fa_cache_pkg.fazccmt_record.deprn_basis_rule, p_log_level_rec => p_log_level_rec);
970 fa_debug_pkg.add(l_calling_fn, 'use_rsv_after_imp_flag', fa_cache_pkg.fazcdrd_record.use_rsv_after_imp_flag, p_log_level_rec => p_log_level_rec);
971 end if;
972
973 if (fa_cache_pkg.fazccmt_record.rate_source_rule = fa_std_types.FAD_RSR_FLAT) and
974 (fa_cache_pkg.fazccmt_record.deprn_basis_rule = fa_std_types.FAD_DBR_COST) and
975 (nvl(fa_cache_pkg.fazcdrd_record.use_rsv_after_imp_flag, 'Y') = 'Y') and
976 NVL(fa_cache_pkg.fazccmt_record.JP_IMP_CALC_BASIS_FLAG, 'XX') <> 'YES' then
977 l_asset_deprn_rec.impairment_reserve := l_asset_deprn_rec.deprn_reserve +
978 l_asset_deprn_rec.impairment_reserve;
979 elsif (nvl(fa_cache_pkg.fazcdrd_record.use_rsv_after_imp_flag, 'N') = 'Y') and
980 (fa_cache_pkg.fazcdbr_record.rule_name = 'FLAT RATE EXTENSION') then
981 l_asset_fin_rec.eofy_reserve := l_asset_deprn_rec.deprn_reserve;
982 end if;
983
984 /*phase5 need to set transaction key = 'JI' for deprn methods using JP NBV based calculations for impairment*/
985 if (NVL(fa_cache_pkg.fazccmt_record.JP_IMP_CALC_BASIS_FLAG, 'NO') = 'YES') then
986 l_trans_rec.transaction_key := 'JI';
987 /*12844989 - to set correct old_adj_cost of asset in extended deprn period.*/
988 if l_asset_fin_rec.deprn_method_code = 'JP-STL-EXTND' then
989 if (p_mrc_sob_type_code = 'R') then
990 open c_mc_get_old_adj_cost;
991 else
992 open c_get_old_adj_cost;
993 end if;
994 fetch c_get_old_adj_cost into l_asset_fin_rec.adjusted_cost;
995 if (p_mrc_sob_type_code = 'R') then
996 close c_mc_get_old_adj_cost;
997 else
998 close c_get_old_adj_cost;
999 end if;
1000 end if;
1001 end if;
1002 if not call_deprn_basis(p_asset_hdr_rec => l_asset_hdr_rec
1003 , p_trans_rec => l_trans_rec
1004 , p_period_rec => p_period_rec
1005 , p_asset_type_rec => l_asset_type_rec
1006 , p_asset_fin_rec => l_asset_fin_rec
1007 , p_asset_deprn_rec => l_asset_deprn_rec
1008 , p_asset_desc_rec => l_asset_desc_rec
1009 , x_new_raf => t_new_raf(i)
1010 , x_new_formula_factor => t_new_formula_factor(i)
1011 , x_new_adjusted_cost => t_new_adj_cost(i)
1012 , p_mrc_sob_type_code => p_mrc_sob_type_code
1013 , p_calling_fn => l_calling_fn
1014 , p_log_level_rec => p_log_level_rec) then
1015 fa_srvr_msg.add_message(calling_fn => l_calling_fn, p_log_level_rec => p_log_level_rec);
1016 raise pos_err;
1017 end if;
1018 else
1019 t_new_adj_cost(i) := t_adjusted_cost(i);
1020 t_new_raf(i) := t_raf(i);
1021 t_new_formula_factor(i) := t_formula_factor(i);
1022 end if; -- (p_period_rec.period_counter = t_period_counter(i))
1023 /* Bug 9577878 need to set period counter fully reserved correctly*/
1024 if (NVL(fa_cache_pkg.fazccmt_record.EXCLUDE_SALVAGE_VALUE_FLAG, 'NO') = 'YES') then
1025 if ((t_new_adj_cost(i) + l_asset_fin_rec.salvage_value) <= t_allowed_deprn_limit_amount(i)) then
1026 t_period_counter_fully_rsv(i) := p_period_rec.period_counter;
1027 t_period_counter_life_complete(i) := p_period_rec.period_counter;
1028 else
1029 t_period_counter_fully_rsv(i) := null;
1030 t_period_counter_life_complete(i) := null;
1031 end if;
1032 else
1033 if (t_new_adj_cost(i) <= t_allowed_deprn_limit_amount(i)) then
1034 t_period_counter_fully_rsv(i) := p_period_rec.period_counter;
1035 t_period_counter_life_complete(i) := p_period_rec.period_counter;
1036 else
1037 t_period_counter_fully_rsv(i) := null;
1038 t_period_counter_life_complete(i) := null;
1039 end if;
1040 end if;
1041 t_period_counter_fully_ext(i) := null;
1042 /*Bug 9574021 need to keep original value of period counter fully reserve and period counter life complete for extended asset*/
1043 IF (l_asset_fin_rec.deprn_method_code = 'JP-STL-EXTND') then
1044 SELECT PERIOD_COUNTER_LIFE_COMPLETE,PERIOD_COUNTER_FULLY_RESERVED
1045 INTO t_period_counter_life_complete(i),t_period_counter_fully_rsv(i)
1046 FROM FA_BOOKS
1047 WHERE BOOK_TYPE_CODE = p_book_type_code
1048 AND ASSET_ID = l_asset_hdr_rec.asset_id
1049 AND TRANSACTION_HEADER_ID_OUT is NULL;
1050 /*BUG 9786860 */
1051 IF (t_new_adj_cost(i) <= 0) THEN
1052 t_period_counter_fully_ext(i) := p_period_rec.period_counter;
1053 END IF;
1054 if (p_log_level_rec.statement_level) then
1055 fa_debug_pkg.add(l_calling_fn,'INSIDE EXTENDED LOGIC FOR', ' PC FULLY RESRVE and LIFE COMPLETE and EXTENDED', p_log_level_rec => p_log_level_rec);
1056 fa_debug_pkg.add(l_calling_fn,'PERIOD_COUNTER_LIFE_COMPLETE', t_period_counter_life_complete(i), p_log_level_rec => p_log_level_rec);
1057 fa_debug_pkg.add(l_calling_fn,'PERIOD_COUNTER_FULLY_RESERVED', t_period_counter_fully_rsv(i), p_log_level_rec => p_log_level_rec);
1058 fa_debug_pkg.add(l_calling_fn,'PERIOD_COUNTER_FULLY_EXTENDED', t_period_counter_fully_ext(i), p_log_level_rec => p_log_level_rec);
1059 end if;
1060 END IF;
1061 /*Bug 9818289 Initialized below variables so that they have values in case of Non-Japanese methods*/
1062 t_rate_in_use(i) := null;
1063 t_nbv_at_switch(i) := null;
1064 /*Phase5 Calculations around switching and rate in use for assets using JP-250DB methods*/
1065 if (NVL(fa_cache_pkg.fazccmt_record.JP_IMP_CALC_BASIS_FLAG, 'NO') = 'YES') then
1066 t_rate_in_use(i) := l_asset_fin_rec.rate_in_use;
1067 t_nbv_at_switch(i) := l_asset_fin_rec.nbv_at_switch;
1068
1069 if ((fa_cache_pkg.fazcct_record.number_per_fiscal_year = p_period_rec.period_num) and
1070 (nvl(fa_cache_pkg.fazccmt_record.guarantee_rate_method_flag,'NO') = 'YES') and
1071 (l_asset_fin_rec.rate_in_use = fa_cache_pkg.fazcfor_record.original_rate ))then
1072
1073 if (((t_new_adj_cost(i) + l_asset_fin_rec.salvage_value) * fa_cache_pkg.fazcfor_record.original_rate) <= (t_cost(i) * fa_cache_pkg.fazcfor_record.guarantee_rate )) then
1074 t_rate_in_use(i) := fa_cache_pkg.fazcfor_record.revised_rate;
1075 t_nbv_at_switch(i) := t_new_adj_cost(i) + l_asset_fin_rec.salvage_value;
1076
1077 if (p_log_level_rec.statement_level) then
1078 fa_debug_pkg.add(l_calling_fn,'ASSET WILL SWITCH AFTER', 'CURRENT IMPAIRMENT', p_log_level_rec => p_log_level_rec);
1079 fa_debug_pkg.add(l_calling_fn,'t_rate_in_use(i)', t_rate_in_use(i), p_log_level_rec => p_log_level_rec);
1080 fa_debug_pkg.add(l_calling_fn,'t_nbv_at_switch(i)', t_nbv_at_switch(i), p_log_level_rec => p_log_level_rec);
1081 end if;
1082 else
1083 t_rate_in_use(i) := fa_cache_pkg.fazcfor_record.original_rate;
1084 t_nbv_at_switch(i) := NULL;
1085 end if;
1086 end if;
1087 if (p_log_level_rec.statement_level) then
1088 fa_debug_pkg.add(l_calling_fn,'INSIDE JAPAN LOGIC', 'NBV CALCULATIONS FOR NBV', p_log_level_rec => p_log_level_rec);
1089 fa_debug_pkg.add(l_calling_fn,'t_rate_in_use(i)', t_rate_in_use(i), p_log_level_rec => p_log_level_rec);
1090 fa_debug_pkg.add(l_calling_fn,'t_nbv_at_switch(i)', t_nbv_at_switch(i), p_log_level_rec => p_log_level_rec);
1091 end if;
1092 end if;
1093 -- Insert Adj
1094 if (p_log_level_rec.statement_level) then
1095 fa_debug_pkg.add(l_calling_fn,'Preparing variables for ', 'faxinaj', p_log_level_rec => p_log_level_rec);
1096 end if;
1097
1098 l_adj.source_type_code := 'ADJUSTMENT';
1099
1100 if (p_log_level_rec.statement_level) then
1101 fa_debug_pkg.add(l_calling_fn,'fa_cache_pkg.fazcbc_record.sorp_enabled_flag', fa_cache_pkg.fazcbc_record.sorp_enabled_flag, p_log_level_rec => p_log_level_rec);
1102 end if;
1103
1104 -- Bug 6666666 : Added for the SORP Compliance Project
1105 -- The following code snippet is used to create the impairment accounting
1106 -- entries. This functionality is documented in
1107 -- section 16.2 in the SORP Functional Design Document
1108 if fa_cache_pkg.fazcbc_record.sorp_enabled_flag = 'Y' then
1109
1110 if not FA_SORP_IMPAIRMENT_PVT.create_sorp_imp_acct (
1111 px_adj => l_adj
1112 , p_impairment_amount => t_impairment_amount(i)
1113 , p_reval_reserve_adj => t_reval_reserve_adj_amount(i)
1114 , p_impair_class => t_impair_class(i)
1115 , p_impair_loss_acct => t_impair_loss_acct(i)
1116 , p_split_impair_flag => t_split_impair_flag(i)
1117 , p_split1_impair_class => t_split1_impair_class(i)
1118 , p_split1_loss_amount => t_split1_loss_amount(i)
1119 , p_split1_reval_reserve => t_split1_reval_reserve(i)
1120 , p_split1_loss_acct => t_split1_loss_acct(i)
1121 , p_split2_impair_class => t_split2_impair_class(i)
1122 , p_split2_loss_amount => t_split2_loss_amount(i)
1123 , p_split2_reval_reserve => t_split2_reval_reserve(i)
1124 , p_split2_loss_acct => t_split2_loss_acct(i)
1125 , p_split3_impair_class => t_split3_impair_class(i)
1126 , p_split3_loss_amount => t_split3_loss_amount(i)
1127 , p_split3_reval_reserve => t_split3_reval_reserve(i)
1128 , p_split3_loss_acct => t_split3_loss_acct(i)
1129 , p_created_by => t_created_by(i)
1130 , p_creation_date => t_creation_date(i)
1131 , p_log_level_rec => p_log_level_rec
1132 ) then
1133 fa_debug_pkg.add(l_calling_fn,'Error creating SORP Impair
1134 entries', 'True', p_log_level_rec => p_log_level_rec);
1135 raise pos_err;
1136 end if;
1137
1138 if (p_log_level_rec.statement_level) then
1139 fa_debug_pkg.add(l_calling_fn,'Processing of create_sorp_imp_acct', 'successful', p_log_level_rec => p_log_level_rec);
1140 end if;
1141
1142 -- ******************************************************
1143 -- Need to create catchup entry for BD SORP IMP
1144 -- ******************************************************
1145 if (p_period_rec.period_counter > t_period_counter(i)) and
1146 (nvl(l_asset_fin_rec.adjustment_required_status, 'NONE') <> 'ADD') and
1147 (t_deprn_adjustment_amount(i) <> 0) and
1148 (G_release = 11 ) then
1149
1150 l_adj.adjustment_amount := t_deprn_adjustment_amount(i);
1151 l_adj.source_type_code := 'DEPRECIATION';
1152 l_adj.adjustment_type := 'EXPENSE';
1153 l_adj.account := fa_cache_pkg.fazccb_record.deprn_expense_acct;
1154 l_adj.account_type := 'DEPRN_EXPENSE_ACCT';
1155 l_adj.debit_credit_flag := 'DR';
1156
1157 if (p_log_level_rec.statement_level) then
1158 fa_debug_pkg.add(l_calling_fn,'Calling faxinaj for ', 'Catch-up Expense', p_log_level_rec => p_log_level_rec);
1159 end if;
1160
1161 if not FA_INS_ADJUST_PKG.faxinaj (l_adj,
1162 t_creation_date(i),
1163 t_created_by(i),
1164 -1,
1165 p_log_level_rec) then
1166 raise pos_err;
1167 end if;
1168 /*11803529 */
1169 -- Create neutralizing entry for adjustment catchup entry
1170 if not FA_SORP_UTIL_PVT.create_sorp_neutral_acct (
1171 t_deprn_adjustment_amount(i)
1172 , 'N'
1173 , l_adj
1174 , t_created_by(i)
1175 , t_creation_date(i)
1176 , p_log_level_rec
1177 ) then
1178 fa_debug_pkg.add(l_calling_fn,'Error at create_sorp_neutral_acct',
1179 'for Catch-up Expense', p_log_level_rec => p_log_level_rec);
1180 return false;
1181 end if;
1182
1183 end if; -- End p_period_rec.period_counter > t_period_counter(i)
1184
1185 else -- If SORP is not enabled then perform the regular accounting
1186
1187 --******************************************************
1188 -- Accumulated Impairment
1189 --******************************************************
1190 l_adj.adjustment_amount := t_impairment_amount(i) + t_reval_reserve_adj_amount(i); /*Bug# 8602103*/
1191 l_adj.adjustment_type := 'IMPAIR RESERVE';
1192 l_adj.account_type := 'IMPAIR_RESERVE_ACCT';
1193 l_adj.account := fa_cache_pkg.fazccb_record.impair_reserve_acct;
1194
1195 l_adj.debit_credit_flag := 'CR';
1196
1197 if (p_log_level_rec.statement_level) then
1198 fa_debug_pkg.add(l_calling_fn,'Calling faxinaj for ', 'Accumulated Impairments', p_log_level_rec => p_log_level_rec);
1199 end if;
1200
1201 if not FA_INS_ADJUST_PKG.faxinaj (l_adj,
1202 t_creation_date(i),
1203 t_created_by(i),
1204 -1,
1205 p_log_level_rec) then
1206 raise pos_err;
1207 end if;
1208
1209 --******************************************************
1210 -- Impairment Expense
1211 --******************************************************
1212 l_adj.adjustment_amount := t_impairment_amount(i);
1213 l_adj.adjustment_type := 'IMPAIR EXPENSE';
1214 l_adj.account_type := 'IMPAIR_EXPENSE_ACCT';
1215 l_adj.account := fa_cache_pkg.fazccb_record.impair_expense_acct;
1216 l_adj.debit_credit_flag := 'DR';
1217
1218 if (p_log_level_rec.statement_level) then
1219 fa_debug_pkg.add(l_calling_fn,'Calling faxinaj for ', 'Impairments Expense', p_log_level_rec => p_log_level_rec);
1220 end if;
1221
1222 if not FA_INS_ADJUST_PKG.faxinaj (l_adj,
1223 t_creation_date(i),
1224 t_created_by(i),
1225 -1,
1226 p_log_level_rec) then
1227 raise pos_err;
1228 end if;
1229
1230
1231 -- ******************************************************
1232 -- Need to create catchup entry for BD IMP
1233 -- ******************************************************
1234 if (p_period_rec.period_counter > t_period_counter(i)) and
1235 (nvl(l_asset_fin_rec.adjustment_required_status, 'NONE') <> 'ADD') and
1236 (t_deprn_adjustment_amount(i) <> 0) then
1237
1238 l_adj.adjustment_amount := t_deprn_adjustment_amount(i);
1239 l_adj.source_type_code := 'DEPRECIATION';
1240 l_adj.adjustment_type := 'EXPENSE';
1241 l_adj.account := fa_cache_pkg.fazccb_record.deprn_expense_acct;
1242 l_adj.account_type := 'DEPRN_EXPENSE_ACCT';
1243 l_adj.debit_credit_flag := 'DR';
1244
1245 if (p_log_level_rec.statement_level) then
1246 fa_debug_pkg.add(l_calling_fn,'Calling faxinaj for ', 'Catch-up Expense', p_log_level_rec => p_log_level_rec);
1247 end if;
1248
1249 if not FA_INS_ADJUST_PKG.faxinaj (l_adj,
1250 t_creation_date(i),
1251 t_created_by(i),
1252 -1,
1253 p_log_level_rec) then
1254 raise pos_err;
1255 end if;
1256
1257 end if;
1258
1259 if (t_reval_reserve_adj_amount(i) <> 0) then
1260 --******************************************************
1261 -- Revaluation Reserve
1262 --******************************************************
1263 --Bug7036770
1264 --made changes to the adjustment amount passed to get the
1265 --correct reval reserve after impairment.
1266
1267 l_adj.adjustment_amount := t_reval_reserve_adj_amount(i) - t_reval_reserve(i);
1268 l_adj.adjustment_type := 'REVAL RESERVE';
1269 l_adj.account_type := 'REVAL_RESERVE_ACCT';
1270 l_adj.account := fa_cache_pkg.fazccb_record.reval_reserve_acct;
1271 l_adj.debit_credit_flag := 'DR';
1272
1273 if (p_log_level_rec.statement_level) then
1274 fa_debug_pkg.add(l_calling_fn,'Calling faxinaj for ', 'Reval Reserve', p_log_level_rec => p_log_level_rec);
1275 end if;
1276
1277 if not FA_INS_ADJUST_PKG.faxinaj (l_adj,
1278 t_creation_date(i),
1279 t_created_by(i),
1280 -1,
1281 p_log_level_rec) then
1282 raise pos_err;
1283 end if;
1284 end if;
1285
1286 end if; -- End If SORP/Non SORP check
1287
1288 if (p_log_level_rec.statement_level) then
1289 fa_debug_pkg.add(l_calling_fn,'Finish calling', 'faxinaj', p_log_level_rec => p_log_level_rec);
1290 end if;
1291
1292 if (p_period_rec.period_counter = l_period_counter) then
1293
1294 if (p_log_level_rec.statement_level) then
1295 fa_debug_pkg.add(l_calling_fn,'Calling FAXINDD for ', 'FA_DEPRN_DETAIL', p_log_level_rec => p_log_level_rec);
1296 fa_debug_pkg.add(l_calling_fn,'p_period_rec.period_counter', p_period_rec.period_counter, p_log_level_rec => p_log_level_rec);
1297 fa_debug_pkg.add(l_calling_fn,'t_cost('||to_char(i)||')', t_cost(i));
1298 fa_debug_pkg.add(l_calling_fn,'t_deprn_reserve('||to_char(i)||')', t_deprn_reserve(i));
1299 fa_debug_pkg.add(l_calling_fn,'t_reval_reserve('||to_char(i)||')', t_reval_reserve(i));
1300 fa_debug_pkg.add(l_calling_fn,'t_ytd_deprn('||to_char(i)||')', t_ytd_deprn(i));
1301 fa_debug_pkg.add(l_calling_fn,'t_ytd_reval_deprn_expense('||to_char(i)||')', t_ytd_reval_deprn_expense(i));
1302 fa_debug_pkg.add(l_calling_fn,'t_new_adj_cost('||to_char(i)||')', t_new_adj_cost(i));
1303 fa_debug_pkg.add(l_calling_fn,'t_net_book_value'||to_char(i)||')',t_net_book_value(i));
1304 end if;
1305
1306 -- Insert DD
1307
1308
1309 -- Bug 6666666 : Added for the SORP Compliance Project
1310 -- If SORP is enabled the value of general fund and
1311 -- capital adjustment are set.
1312 if fa_cache_pkg.fazcbc_record.sorp_enabled_flag = 'Y' then
1313 if not FA_INS_DETAIL_PKG.FAXINDD
1314 (X_book_type_code => p_book_type_code,
1315 X_asset_id => t_asset_id(i),
1316 X_period_counter => p_period_rec.period_counter,
1317 X_cost => t_cost(i),
1318 X_deprn_reserve => nvl(t_deprn_reserve(i), 0),
1319 X_deprn_adjustment_amount => nvl(t_deprn_adjustment_amount(i), 0),
1320 X_reval_reserve => nvl(t_reval_reserve(i), 0),
1321 X_ytd => nvl(t_ytd_deprn(i), 0),
1322 X_ytd_reval_dep_exp => nvl(t_ytd_reval_deprn_expense(i), 0),
1323 X_bonus_ytd => nvl(t_bonus_ytd_deprn(i), 0),
1324 X_bonus_deprn_reserve => nvl(t_bonus_deprn_reserve(i), 0),
1325 X_init_message_flag => 'NO',
1326 X_bonus_deprn_adj_amount => t_bonus_deprn_adj_amount(i),
1327 X_bonus_deprn_amount => t_bonus_deprn_amount(i),
1328 X_deprn_amount => t_deprn_amount(i),
1329 X_reval_amortization => t_reval_amortization(i),
1330 X_reval_deprn_expense => t_reval_deprn_expense(i),
1331 X_impairment_amount => t_impairment_amount(i),
1332 X_ytd_impairment => t_ytd_impairment(i),
1333 X_impairment_reserve => t_impairment_reserve(i),
1334 X_capital_adjustment => t_capital_adjustment(i)
1335 - nvl(t_reval_amortization(i),0)
1336 + nvl(t_deprn_amount(i),0), --Bug 6666666
1337 X_general_fund => t_general_fund(i)
1338 + nvl(t_deprn_amount(i),0), --Bug 6666666
1339 X_b_row => FALSE,
1340 X_mrc_sob_type_code => p_mrc_sob_type_code,
1341 X_set_of_books_id => p_set_of_books_id,
1342 p_log_level_rec => p_log_level_rec
1343 ) then raise
1344 pos_err;
1345 end if;
1346 else -- If SORP is not enabled capital adjustment and general fund
1347 -- should be null
1348 if not FA_INS_DETAIL_PKG.FAXINDD
1349 (X_book_type_code => p_book_type_code,
1350 X_asset_id => t_asset_id(i),
1351 X_period_counter => p_period_rec.period_counter,
1352 X_cost => t_cost(i),
1353 X_deprn_reserve => nvl(t_deprn_reserve(i), 0),
1354 X_deprn_adjustment_amount => nvl(t_deprn_adjustment_amount(i), 0),
1355 X_reval_reserve => nvl(t_reval_reserve(i), 0),
1356 X_ytd => nvl(t_ytd_deprn(i), 0),
1357 X_ytd_reval_dep_exp => nvl(t_ytd_reval_deprn_expense(i), 0),
1358 X_bonus_ytd => nvl(t_bonus_ytd_deprn(i), 0),
1359 X_bonus_deprn_reserve => nvl(t_bonus_deprn_reserve(i), 0),
1360 X_init_message_flag => 'NO',
1361 X_bonus_deprn_adj_amount => t_bonus_deprn_adj_amount(i),
1362 X_bonus_deprn_amount => t_bonus_deprn_amount(i),
1363 X_deprn_amount => t_deprn_amount(i),
1364 X_reval_amortization => t_reval_amortization(i),
1365 X_reval_deprn_expense => t_reval_deprn_expense(i),
1366 X_impairment_amount => t_impairment_amount(i),
1367 X_ytd_impairment => t_ytd_impairment(i),
1368 X_impairment_reserve => t_impairment_reserve(i),
1369 X_capital_adjustment => NULL, --Bug 6666666
1370 X_general_fund => NULL, --Bug 6666666
1371 X_b_row => FALSE,
1372 X_mrc_sob_type_code => p_mrc_sob_type_code,
1373 X_set_of_books_id => p_set_of_books_id,
1374 p_log_level_rec => p_log_level_rec
1375 ) then raise
1376 pos_err;
1377 end if;
1378 end if;
1379
1380 end if; -- (p_period_rec.period_counter = t_period_counter(i))
1381
1382 END LOOP; -- i in 1..t_request_id.count
1383
1384 -- Insert DS only if this is cur per imp
1385 if (p_period_rec.period_counter = l_period_counter) then
1386
1387 if (p_mrc_sob_type_code = 'R') then
1388 if (p_log_level_rec.statement_level) then
1389 fa_debug_pkg.add(l_calling_fn,'Insert into ', 'FA_DEPRN_SUMMARY_MRC_V', p_log_level_rec => p_log_level_rec);
1390 end if;
1391
1392 -- Bug 6666666 : If SORP is enabled, insert values for capital adj
1393 -- and general fund
1394 if fa_cache_pkg.fazcbc_record.sorp_enabled_flag = 'Y' then
1395 FORALL i in 1..t_request_id.count
1396 INSERT INTO FA_MC_DEPRN_SUMMARY( SET_OF_BOOKS_ID
1397 , BOOK_TYPE_CODE
1398 , ASSET_ID
1399 , PERIOD_COUNTER
1400 , DEPRN_RUN_DATE
1401 , DEPRN_AMOUNT
1402 , YTD_DEPRN
1403 , DEPRN_RESERVE
1404 , DEPRN_SOURCE_CODE
1405 , ADJUSTED_COST
1406 , BONUS_RATE
1407 , REVAL_AMORTIZATION
1408 , REVAL_DEPRN_EXPENSE
1409 , REVAL_RESERVE
1410 , YTD_REVAL_DEPRN_EXPENSE
1411 , PRODUCTION
1412 , YTD_PRODUCTION
1413 , LTD_PRODUCTION
1414 , REVAL_AMORTIZATION_BASIS
1415 , PRIOR_FY_EXPENSE
1416 , BONUS_DEPRN_AMOUNT
1417 , BONUS_YTD_DEPRN
1418 , BONUS_DEPRN_RESERVE
1419 , BONUS_DEPRN_ADJUSTMENT_AMOUNT
1420 , PRIOR_FY_BONUS_EXPENSE
1421 , DEPRN_OVERRIDE_FLAG
1422 , SYSTEM_DEPRN_AMOUNT
1423 , SYSTEM_BONUS_DEPRN_AMOUNT
1424 , IMPAIRMENT_AMOUNT
1425 , YTD_IMPAIRMENT
1426 , IMPAIRMENT_RESERVE
1427 , CAPITAL_ADJUSTMENT -- Bug 6666666
1428 , GENERAL_FUND -- Bug 6666666
1429 , DEPRN_ADJUSTMENT_AMOUNT
1430 , REVAL_LOSS_BALANCE
1431 ) VALUES ( p_set_of_books_id
1432 , p_book_type_code -- BOOK_TYPE_CODE
1433 , t_asset_id(i) -- ASSET_ID
1434 , p_period_rec.period_counter -- PERIOD_COUNTER
1435 , t_creation_date(i) -- DEPRN_RUN_DATE
1436 , t_deprn_amount(i) -- DEPRN_AMOUNT
1437 , t_ytd_deprn(i) -- YTD_DEPRN
1438 , t_deprn_reserve(i) -- DEPRN_RESERVE
1439 , 'DEPRN' -- DEPRN_SOURCE_CODE
1440 , t_adjusted_cost(i) -- ADJUSTED_COST
1441 , t_bonus_rate(i) -- BONUS_RATE
1442 , t_reval_amortization(i) -- REVAL_AMORTIZATION
1443 , t_reval_deprn_expense(i) -- REVAL_DEPRN_EXPENSE
1444 , t_reval_reserve(i) -- REVAL_RESERVE
1445 , t_ytd_reval_deprn_expense(i) -- YTD_REVAL_DEPRN_EXPENSE
1446 , t_production(i) -- PRODUCTION
1447 , t_ytd_production(i) -- YTD_PRODUCTION
1448 , t_ltd_production(i) -- LTD_PRODUCTION
1449 , t_reval_amortization_basis(i) -- REVAL_AMORTIZATION_BASIS
1450 , t_prior_fy_expense(i) -- PRIOR_FY_EXPENSE
1451 , t_bonus_deprn_amount(i) -- BONUS_DEPRN_AMOUNT
1452 , t_bonus_ytd_deprn(i) -- BONUS_YTD_DEPRN
1453 , t_bonus_deprn_reserve(i) -- BONUS_DEPRN_RESERVE
1454 , t_bonus_deprn_adj_amount(i) -- BONUS_DEPRN_ADJUSTMENT_AMOUNT
1455 , t_prior_fy_bonus_expense(i) -- PRIOR_FY_BONUS_EXPENSE
1456 , t_deprn_override_flag(i) -- DEPRN_OVERRIDE_FLAG
1457 , t_system_deprn_amount(i) -- SYSTEM_DEPRN_AMOUNT
1458 , t_system_bonus_deprn_amount(i) -- SYSTEM_BONUS_DEPRN_AMOUNT
1459 , t_impairment_amount(i) -- IMPAIRMENT_AMOUNT
1460 , t_ytd_impairment(i) -- YTD_IMPAIRMENT
1461 , t_impairment_reserve(i) -- impairment_reserve
1462 , t_capital_adjustment(i)
1463 - nvl(t_reval_amortization(i),0)
1464 + nvl(t_deprn_amount(i),0) -- Capital Adjustment -- Bug 6666666
1465 , t_general_fund(i)
1466 + nvl(t_deprn_amount(i),0) -- General Fund -- Bug 6666666
1467 , t_deprn_adjustment_amount(i)
1468 , t_reval_loss_balance(i)
1469 );
1470 else -- If SORP is not enabled
1471 FORALL i in 1..t_request_id.count
1472 INSERT INTO FA_MC_DEPRN_SUMMARY( SET_OF_BOOKS_ID
1473 , BOOK_TYPE_CODE
1474 , ASSET_ID
1475 , PERIOD_COUNTER
1476 , DEPRN_RUN_DATE
1477 , DEPRN_AMOUNT
1478 , YTD_DEPRN
1479 , DEPRN_RESERVE
1480 , DEPRN_SOURCE_CODE
1481 , ADJUSTED_COST
1482 , BONUS_RATE
1483 , REVAL_AMORTIZATION
1484 , REVAL_DEPRN_EXPENSE
1485 , REVAL_RESERVE
1486 , YTD_REVAL_DEPRN_EXPENSE
1487 , PRODUCTION
1488 , YTD_PRODUCTION
1489 , LTD_PRODUCTION
1490 , REVAL_AMORTIZATION_BASIS
1491 , PRIOR_FY_EXPENSE
1492 , BONUS_DEPRN_AMOUNT
1493 , BONUS_YTD_DEPRN
1494 , BONUS_DEPRN_RESERVE
1495 , BONUS_DEPRN_ADJUSTMENT_AMOUNT
1496 , PRIOR_FY_BONUS_EXPENSE
1497 , DEPRN_OVERRIDE_FLAG
1498 , SYSTEM_DEPRN_AMOUNT
1499 , SYSTEM_BONUS_DEPRN_AMOUNT
1500 , IMPAIRMENT_AMOUNT
1501 , YTD_IMPAIRMENT
1502 , IMPAIRMENT_RESERVE
1503 , CAPITAL_ADJUSTMENT -- Bug 6666666
1504 , GENERAL_FUND -- Bug 6666666
1505 , DEPRN_ADJUSTMENT_AMOUNT
1506 , REVAL_LOSS_BALANCE
1507 ) VALUES ( p_set_of_books_id
1508 , p_book_type_code -- BOOK_TYPE_CODE
1509 , t_asset_id(i) -- ASSET_ID
1510 , p_period_rec.period_counter -- PERIOD_COUNTER
1511 , t_creation_date(i) -- DEPRN_RUN_DATE
1512 , t_deprn_amount(i) -- DEPRN_AMOUNT
1513 , t_ytd_deprn(i) -- YTD_DEPRN
1514 , t_deprn_reserve(i) -- DEPRN_RESERVE
1515 , 'DEPRN' -- DEPRN_SOURCE_CODE
1516 , t_adjusted_cost(i) -- ADJUSTED_COST
1517 , t_bonus_rate(i) -- BONUS_RATE
1518 , t_reval_amortization(i) -- REVAL_AMORTIZATION
1519 , t_reval_deprn_expense(i) -- REVAL_DEPRN_EXPENSE
1520 , t_reval_reserve(i) -- REVAL_RESERVE
1521 , t_ytd_reval_deprn_expense(i) -- YTD_REVAL_DEPRN_EXPENSE
1522 , t_production(i) -- PRODUCTION
1523 , t_ytd_production(i) -- YTD_PRODUCTION
1524 , t_ltd_production(i) -- LTD_PRODUCTION
1525 , t_reval_amortization_basis(i) -- REVAL_AMORTIZATION_BASIS
1526 , t_prior_fy_expense(i) -- PRIOR_FY_EXPENSE
1527 , t_bonus_deprn_amount(i) -- BONUS_DEPRN_AMOUNT
1528 , t_bonus_ytd_deprn(i) -- BONUS_YTD_DEPRN
1529 , t_bonus_deprn_reserve(i) -- BONUS_DEPRN_RESERVE
1530 , t_bonus_deprn_adj_amount(i) -- BONUS_DEPRN_ADJUSTMENT_AMOUNT
1531 , t_prior_fy_bonus_expense(i) -- PRIOR_FY_BONUS_EXPENSE
1532 , t_deprn_override_flag(i) -- DEPRN_OVERRIDE_FLAG
1533 , t_system_deprn_amount(i) -- SYSTEM_DEPRN_AMOUNT
1534 , t_system_bonus_deprn_amount(i) -- SYSTEM_BONUS_DEPRN_AMOUNT
1535 , t_impairment_amount(i) -- IMPAIRMENT_AMOUNT
1536 , t_ytd_impairment(i) -- YTD_IMPAIRMENT
1537 , t_impairment_reserve(i) -- impairment_reserve
1538 , NULL -- Capital Adjustment -- Bug 6666666
1539 , NULL -- General Fund -- Bug 6666666
1540 , t_deprn_adjustment_amount(i)
1541 , t_reval_loss_balance(i)
1542 );
1543 end if; -- End IF SORP is enabled
1544
1545
1546
1547 else
1548
1549 if (p_log_level_rec.statement_level) then
1550 fa_debug_pkg.add(l_calling_fn,'Insert into ', 'FA_DEPRN_SUMMARY', p_log_level_rec => p_log_level_rec);
1551 end if;
1552
1553 -- Bug 6666666 : If SORP is enabled, insert values for capital adj
1554 -- and general fund
1555 if fa_cache_pkg.fazcbc_record.sorp_enabled_flag = 'Y' then
1556 FORALL i in 1..t_request_id.count
1557 INSERT INTO FA_DEPRN_SUMMARY( BOOK_TYPE_CODE
1558 , ASSET_ID
1559 , PERIOD_COUNTER
1560 , DEPRN_RUN_DATE
1561 , DEPRN_AMOUNT
1562 , YTD_DEPRN
1563 , DEPRN_RESERVE
1564 , DEPRN_SOURCE_CODE
1565 , ADJUSTED_COST
1566 , BONUS_RATE
1567 , REVAL_AMORTIZATION
1568 , REVAL_DEPRN_EXPENSE
1569 , REVAL_RESERVE
1570 , YTD_REVAL_DEPRN_EXPENSE
1571 , PRODUCTION
1572 , YTD_PRODUCTION
1573 , LTD_PRODUCTION
1574 , REVAL_AMORTIZATION_BASIS
1575 , PRIOR_FY_EXPENSE
1576 , BONUS_DEPRN_AMOUNT
1577 , BONUS_YTD_DEPRN
1578 , BONUS_DEPRN_RESERVE
1579 , BONUS_DEPRN_ADJUSTMENT_AMOUNT
1580 , PRIOR_FY_BONUS_EXPENSE
1581 , DEPRN_OVERRIDE_FLAG
1582 , SYSTEM_DEPRN_AMOUNT
1583 , SYSTEM_BONUS_DEPRN_AMOUNT
1584 , IMPAIRMENT_AMOUNT
1585 , YTD_IMPAIRMENT
1586 , IMPAIRMENT_RESERVE
1587 , CAPITAL_ADJUSTMENT -- Bug 6666666
1588 , GENERAL_FUND -- Bug 6666666
1589 , DEPRN_ADJUSTMENT_AMOUNT
1590 , REVAL_LOSS_BALANCE
1591 ) VALUES ( p_book_type_code -- BOOK_TYPE_CODE
1592 , t_asset_id(i) -- ASSET_ID
1593 , p_period_rec.period_counter -- PERIOD_COUNTER
1594 , t_creation_date(i) -- DEPRN_RUN_DATE
1595 , t_deprn_amount(i) -- DEPRN_AMOUNT
1596 , t_ytd_deprn(i) -- YTD_DEPRN
1597 , t_deprn_reserve(i) -- DEPRN_RESERVE
1598 , 'DEPRN' -- DEPRN_SOURCE_CODE
1599 , t_adjusted_cost(i) -- ADJUSTED_COST
1600 , t_bonus_rate(i) -- BONUS_RATE
1601 , t_reval_amortization(i) -- REVAL_AMORTIZATION
1602 , t_reval_deprn_expense(i) -- REVAL_DEPRN_EXPENSE
1603 , t_reval_reserve(i) -- REVAL_RESERVE
1604 , t_ytd_reval_deprn_expense(i) -- YTD_REVAL_DEPRN_EXPENSE
1605 , t_production(i) -- PRODUCTION
1606 , t_ytd_production(i) -- YTD_PRODUCTION
1607 , t_ltd_production(i) -- LTD_PRODUCTION
1608 , t_reval_amortization_basis(i) -- REVAL_AMORTIZATION_BASIS
1609 , t_prior_fy_expense(i) -- PRIOR_FY_EXPENSE
1610 , t_bonus_deprn_amount(i) -- BONUS_DEPRN_AMOUNT
1611 , t_bonus_ytd_deprn(i) -- BONUS_YTD_DEPRN
1612 , t_bonus_deprn_reserve(i) -- BONUS_DEPRN_RESERVE
1613 , t_bonus_deprn_adj_amount(i) -- BONUS_DEPRN_ADJUSTMENT_AMOUNT
1614 , t_prior_fy_bonus_expense(i) -- PRIOR_FY_BONUS_EXPENSE
1615 , t_deprn_override_flag(i) -- DEPRN_OVERRIDE_FLAG
1616 , t_system_deprn_amount(i) -- SYSTEM_DEPRN_AMOUNT
1617 , t_system_bonus_deprn_amount(i) -- SYSTEM_BONUS_DEPRN_AMOUNT
1618 , t_impairment_amount(i) -- IMPAIRMENT_AMOUNT
1619 , t_ytd_impairment(i) -- YTD_IMPAIRMENT
1620 , t_impairment_reserve(i) -- impairment_reserve
1621 , t_capital_adjustment(i)
1622 - nvl(t_reval_amortization(i),0)
1623 + nvl(t_deprn_amount(i),0) -- Capital Adjustment -- Bug 6666666
1624 , t_general_fund(i)
1625 + nvl(t_deprn_amount(i),0) -- General Fund -- Bug 6666666
1626 , t_deprn_adjustment_amount(i)
1627 , t_reval_loss_balance(i)
1628 );
1629 else -- If SORP is not enabled
1630 FORALL i in 1..t_request_id.count
1631 INSERT INTO FA_DEPRN_SUMMARY( BOOK_TYPE_CODE
1632 , ASSET_ID
1633 , PERIOD_COUNTER
1634 , DEPRN_RUN_DATE
1635 , DEPRN_AMOUNT
1636 , YTD_DEPRN
1637 , DEPRN_RESERVE
1638 , DEPRN_SOURCE_CODE
1639 , ADJUSTED_COST
1640 , BONUS_RATE
1641 , REVAL_AMORTIZATION
1642 , REVAL_DEPRN_EXPENSE
1643 , REVAL_RESERVE
1644 , YTD_REVAL_DEPRN_EXPENSE
1645 , PRODUCTION
1646 , YTD_PRODUCTION
1647 , LTD_PRODUCTION
1648 , REVAL_AMORTIZATION_BASIS
1649 , PRIOR_FY_EXPENSE
1650 , BONUS_DEPRN_AMOUNT
1651 , BONUS_YTD_DEPRN
1652 , BONUS_DEPRN_RESERVE
1653 , BONUS_DEPRN_ADJUSTMENT_AMOUNT
1654 , PRIOR_FY_BONUS_EXPENSE
1655 , DEPRN_OVERRIDE_FLAG
1656 , SYSTEM_DEPRN_AMOUNT
1657 , SYSTEM_BONUS_DEPRN_AMOUNT
1658 , IMPAIRMENT_AMOUNT
1659 , YTD_IMPAIRMENT
1660 , IMPAIRMENT_RESERVE
1661 , CAPITAL_ADJUSTMENT -- Bug 6666666
1662 , GENERAL_FUND -- Bug 6666666
1663 , DEPRN_ADJUSTMENT_AMOUNT
1664 , REVAL_LOSS_BALANCE
1665 ) VALUES ( p_book_type_code -- BOOK_TYPE_CODE
1666 , t_asset_id(i) -- ASSET_ID
1667 , p_period_rec.period_counter -- PERIOD_COUNTER
1668 , t_creation_date(i) -- DEPRN_RUN_DATE
1669 , t_deprn_amount(i) -- DEPRN_AMOUNT
1670 , t_ytd_deprn(i) -- YTD_DEPRN
1671 , t_deprn_reserve(i) -- DEPRN_RESERVE
1672 , 'DEPRN' -- DEPRN_SOURCE_CODE
1673 , t_adjusted_cost(i) -- ADJUSTED_COST
1674 , t_bonus_rate(i) -- BONUS_RATE
1675 , t_reval_amortization(i) -- REVAL_AMORTIZATION
1676 , t_reval_deprn_expense(i) -- REVAL_DEPRN_EXPENSE
1677 , t_reval_reserve(i) -- REVAL_RESERVE
1678 , t_ytd_reval_deprn_expense(i) -- YTD_REVAL_DEPRN_EXPENSE
1679 , t_production(i) -- PRODUCTION
1680 , t_ytd_production(i) -- YTD_PRODUCTION
1681 , t_ltd_production(i) -- LTD_PRODUCTION
1682 , t_reval_amortization_basis(i) -- REVAL_AMORTIZATION_BASIS
1683 , t_prior_fy_expense(i) -- PRIOR_FY_EXPENSE
1684 , t_bonus_deprn_amount(i) -- BONUS_DEPRN_AMOUNT
1685 , t_bonus_ytd_deprn(i) -- BONUS_YTD_DEPRN
1686 , t_bonus_deprn_reserve(i) -- BONUS_DEPRN_RESERVE
1687 , t_bonus_deprn_adj_amount(i) -- BONUS_DEPRN_ADJUSTMENT_AMOUNT
1688 , t_prior_fy_bonus_expense(i) -- PRIOR_FY_BONUS_EXPENSE
1689 , t_deprn_override_flag(i) -- DEPRN_OVERRIDE_FLAG
1690 , t_system_deprn_amount(i) -- SYSTEM_DEPRN_AMOUNT
1691 , t_system_bonus_deprn_amount(i) -- SYSTEM_BONUS_DEPRN_AMOUNT
1692 , t_impairment_amount(i) -- IMPAIRMENT_AMOUNT
1693 , t_ytd_impairment(i) -- YTD_IMPAIRMENT
1694 , t_impairment_reserve(i) -- impairment_reserve
1695 , NULL -- Capital Adjustment -- Bug 6666666
1696 , NULL -- General Fund -- Bug 6666666
1697 , t_deprn_adjustment_amount(i)
1698 , t_reval_loss_balance(i)
1699 );
1700 end if; -- End If SORP is enabled
1701 end if;
1702
1703 end if; -- (p_period_rec.period_counter = t_period_counter(i))
1704
1705 -- Deactivate Books
1706 if (p_mrc_sob_type_code = 'R') then
1707 if (p_log_level_rec.statement_level) then
1708 fa_debug_pkg.add(l_calling_fn,'Deactivating ', 'FA_BOOKS_MRC_V', p_log_level_rec => p_log_level_rec);
1709 end if;
1710
1711 FORALL i in 1..t_request_id.count
1712 UPDATE FA_MC_BOOKS
1713 SET DATE_INEFFECTIVE = t_creation_date(i)
1714 , TRANSACTION_HEADER_ID_OUT = t_thid(i)
1715 WHERE ASSET_ID = t_asset_id(i)
1716 AND BOOK_TYPE_CODE = p_book_type_code
1717 AND TRANSACTION_HEADER_ID_OUT is null
1718 AND SET_OF_BOOKS_ID = p_set_of_books_id
1719 RETURNING transaction_header_id_in BULK COLLECT INTO t_old_thid;
1720
1721 else
1722 if (p_log_level_rec.statement_level) then
1723 fa_debug_pkg.add(l_calling_fn,'Deactivating ', 'FA_BOOKS', p_log_level_rec => p_log_level_rec);
1724 end if;
1725
1726 FORALL i in 1..t_request_id.count
1727 UPDATE FA_BOOKS
1728 SET DATE_INEFFECTIVE = t_creation_date(i)
1729 , TRANSACTION_HEADER_ID_OUT = t_thid(i)
1730 WHERE ASSET_ID = t_asset_id(i)
1731 AND BOOK_TYPE_CODE = p_book_type_code
1732 AND TRANSACTION_HEADER_ID_OUT is null
1733 RETURNING transaction_header_id_in BULK COLLECT INTO t_old_thid;
1734 end if;
1735 -- Insert books
1736
1737 if (p_mrc_sob_type_code = 'R') then
1738 if (p_log_level_rec.statement_level) then
1739 fa_debug_pkg.add(l_calling_fn,'Inserting record into ', 'FA_BOOKS_MRC_V', p_log_level_rec => p_log_level_rec);
1740 end if;
1741
1742 FORALL i in 1..t_request_id.count
1743 INSERT INTO FA_MC_BOOKS( SET_OF_BOOKS_ID
1744 , BOOK_TYPE_CODE
1745 , ASSET_ID
1746 , DATE_PLACED_IN_SERVICE
1747 , DATE_EFFECTIVE
1748 , DEPRN_START_DATE
1749 , DEPRN_METHOD_CODE
1750 , LIFE_IN_MONTHS
1751 , RATE_ADJUSTMENT_FACTOR
1752 , ADJUSTED_COST
1753 , COST
1754 , ORIGINAL_COST
1755 , SALVAGE_VALUE
1756 , PRORATE_CONVENTION_CODE
1757 , PRORATE_DATE
1758 , COST_CHANGE_FLAG
1759 , ADJUSTMENT_REQUIRED_STATUS
1760 , CAPITALIZE_FLAG
1761 , RETIREMENT_PENDING_FLAG
1762 , DEPRECIATE_FLAG
1763 , LAST_UPDATE_DATE
1764 , LAST_UPDATED_BY
1765 , TRANSACTION_HEADER_ID_IN
1766 , ITC_AMOUNT_ID
1767 , ITC_AMOUNT
1768 , RETIREMENT_ID
1769 , TAX_REQUEST_ID
1770 , ITC_BASIS
1771 , BASIC_RATE
1772 , ADJUSTED_RATE
1773 , BONUS_RULE
1774 , CEILING_NAME
1775 , RECOVERABLE_COST
1776 , ADJUSTED_CAPACITY
1777 , FULLY_RSVD_REVALS_COUNTER
1778 , IDLED_FLAG
1779 , PERIOD_COUNTER_CAPITALIZED
1780 , PERIOD_COUNTER_FULLY_RESERVED
1781 , PERIOD_COUNTER_FULLY_RETIRED
1782 , PRODUCTION_CAPACITY
1783 , REVAL_AMORTIZATION_BASIS
1784 , REVAL_CEILING
1785 , UNIT_OF_MEASURE
1786 , UNREVALUED_COST
1787 , ANNUAL_DEPRN_ROUNDING_FLAG
1788 , PERCENT_SALVAGE_VALUE
1789 , ALLOWED_DEPRN_LIMIT
1790 , ALLOWED_DEPRN_LIMIT_AMOUNT
1791 , PERIOD_COUNTER_LIFE_COMPLETE
1792 , ADJUSTED_RECOVERABLE_COST
1793 , ANNUAL_ROUNDING_FLAG
1794 , GLOBAL_ATTRIBUTE1
1795 , GLOBAL_ATTRIBUTE2
1796 , GLOBAL_ATTRIBUTE3
1797 , GLOBAL_ATTRIBUTE4
1798 , GLOBAL_ATTRIBUTE5
1799 , GLOBAL_ATTRIBUTE6
1800 , GLOBAL_ATTRIBUTE7
1801 , GLOBAL_ATTRIBUTE8
1802 , GLOBAL_ATTRIBUTE9
1803 , GLOBAL_ATTRIBUTE10
1804 , GLOBAL_ATTRIBUTE11
1805 , GLOBAL_ATTRIBUTE12
1806 , GLOBAL_ATTRIBUTE13
1807 , GLOBAL_ATTRIBUTE14
1808 , GLOBAL_ATTRIBUTE15
1809 , GLOBAL_ATTRIBUTE16
1810 , GLOBAL_ATTRIBUTE17
1811 , GLOBAL_ATTRIBUTE18
1812 , GLOBAL_ATTRIBUTE19
1813 , GLOBAL_ATTRIBUTE20
1814 , GLOBAL_ATTRIBUTE_CATEGORY
1815 , EOFY_ADJ_COST
1816 , EOFY_FORMULA_FACTOR
1817 , SHORT_FISCAL_YEAR_FLAG
1818 , CONVERSION_DATE
1819 , ORIGINAL_DEPRN_START_DATE
1820 , REMAINING_LIFE1
1821 , REMAINING_LIFE2
1822 , OLD_ADJUSTED_COST
1823 , FORMULA_FACTOR
1824 , GROUP_ASSET_ID
1825 , SALVAGE_TYPE
1826 , DEPRN_LIMIT_TYPE
1827 , REDUCTION_RATE
1828 , REDUCE_ADDITION_FLAG
1829 , REDUCE_ADJUSTMENT_FLAG
1830 , REDUCE_RETIREMENT_FLAG
1831 , RECOGNIZE_GAIN_LOSS
1832 , RECAPTURE_RESERVE_FLAG
1833 , LIMIT_PROCEEDS_FLAG
1834 , TERMINAL_GAIN_LOSS
1835 , TRACKING_METHOD
1836 , EXCLUDE_FULLY_RSV_FLAG
1837 , EXCESS_ALLOCATION_OPTION
1838 , DEPRECIATION_OPTION
1839 , MEMBER_ROLLUP_FLAG
1840 , ALLOCATE_TO_FULLY_RSV_FLAG
1841 , ALLOCATE_TO_FULLY_RET_FLAG
1842 , TERMINAL_GAIN_LOSS_AMOUNT
1843 , CIP_COST
1844 , YTD_PROCEEDS
1845 , LTD_PROCEEDS
1846 , LTD_COST_OF_REMOVAL
1847 , EOFY_RESERVE
1848 , PRIOR_EOFY_RESERVE
1849 , EOP_ADJ_COST
1850 , EOP_FORMULA_FACTOR
1851 , EXCLUDE_PROCEEDS_FROM_BASIS
1852 , RETIREMENT_DEPRN_OPTION
1853 , TERMINAL_GAIN_LOSS_FLAG
1854 , SUPER_GROUP_ID
1855 , OVER_DEPRECIATE_OPTION
1856 , DISABLED_FLAG
1857 , CASH_GENERATING_UNIT_ID
1858 ) SELECT SET_OF_BOOKS_ID
1859 , BOOK_TYPE_CODE
1860 , ASSET_ID
1861 , DATE_PLACED_IN_SERVICE
1862 , t_creation_date(i) -- DATE_EFFECTIVE
1863 , DEPRN_START_DATE
1864 , DEPRN_METHOD_CODE
1865 , LIFE_IN_MONTHS
1866 , t_new_raf(i) --RATE_ADJUSTMENT_FACTOR
1867 , t_new_adj_cost(i) -- ADJUSTED_COST
1868 , COST
1869 , ORIGINAL_COST
1870 , SALVAGE_VALUE
1871 , PRORATE_CONVENTION_CODE
1872 , PRORATE_DATE
1873 , COST_CHANGE_FLAG
1874 , ADJUSTMENT_REQUIRED_STATUS
1875 , CAPITALIZE_FLAG
1876 , RETIREMENT_PENDING_FLAG
1877 , DEPRECIATE_FLAG
1878 , t_creation_date(i) -- LAST_UPDATE_DATE
1879 , t_created_by(i) -- LAST_UPDATED_BY
1880 , t_thid(i) -- TRANSACTION_HEADER_ID_IN
1881 , ITC_AMOUNT_ID
1882 , ITC_AMOUNT
1883 , RETIREMENT_ID
1884 , TAX_REQUEST_ID
1885 , ITC_BASIS
1886 , BASIC_RATE
1887 , ADJUSTED_RATE
1888 , BONUS_RULE
1889 , CEILING_NAME
1890 , RECOVERABLE_COST
1891 , ADJUSTED_CAPACITY
1892 , FULLY_RSVD_REVALS_COUNTER
1893 , IDLED_FLAG
1894 , PERIOD_COUNTER_CAPITALIZED
1895 , t_period_counter_fully_rsv(i) -- phase5 decode(sign(t_new_adj_cost(i) - t_allowed_deprn_limit_amount(i)), 1, null, p_period_rec.period_counter) --PERIOD_COUNTER_FULLY_RESERVED
1896 , PERIOD_COUNTER_FULLY_RETIRED
1897 , PRODUCTION_CAPACITY
1898 , t_reval_reserve(i)
1899 , REVAL_CEILING
1900 , UNIT_OF_MEASURE
1901 , UNREVALUED_COST
1902 , 'ADJ'
1903 , PERCENT_SALVAGE_VALUE
1904 , ALLOWED_DEPRN_LIMIT
1905 , ALLOWED_DEPRN_LIMIT_AMOUNT
1906 , t_period_counter_life_complete(i) -- phase5 decode(sign(t_new_adj_cost(i) - t_allowed_deprn_limit_amount(i)), 1, null, p_period_rec.period_counter) --PERIOD_COUNTER_LIFE_COMPLETE
1907 , ADJUSTED_RECOVERABLE_COST
1908 , ANNUAL_ROUNDING_FLAG
1909 , GLOBAL_ATTRIBUTE1
1910 , GLOBAL_ATTRIBUTE2
1911 , GLOBAL_ATTRIBUTE3
1912 , GLOBAL_ATTRIBUTE4
1913 , GLOBAL_ATTRIBUTE5
1914 , GLOBAL_ATTRIBUTE6
1915 , GLOBAL_ATTRIBUTE7
1916 , GLOBAL_ATTRIBUTE8
1917 , GLOBAL_ATTRIBUTE9
1918 , GLOBAL_ATTRIBUTE10
1919 , GLOBAL_ATTRIBUTE11
1920 , GLOBAL_ATTRIBUTE12
1921 , GLOBAL_ATTRIBUTE13
1922 , GLOBAL_ATTRIBUTE14
1923 , GLOBAL_ATTRIBUTE15
1924 , GLOBAL_ATTRIBUTE16
1925 , GLOBAL_ATTRIBUTE17
1926 , GLOBAL_ATTRIBUTE18
1927 , GLOBAL_ATTRIBUTE19
1928 , GLOBAL_ATTRIBUTE20
1929 , GLOBAL_ATTRIBUTE_CATEGORY
1930 , EOFY_ADJ_COST
1931 , EOFY_FORMULA_FACTOR
1932 , SHORT_FISCAL_YEAR_FLAG
1933 , CONVERSION_DATE
1934 , ORIGINAL_DEPRN_START_DATE
1935 , REMAINING_LIFE1
1936 , REMAINING_LIFE2
1937 , OLD_ADJUSTED_COST
1938 , t_new_formula_factor(i) --FORMULA_FACTOR
1939 , GROUP_ASSET_ID
1940 , SALVAGE_TYPE
1941 , DEPRN_LIMIT_TYPE
1942 , REDUCTION_RATE
1943 , REDUCE_ADDITION_FLAG
1944 , REDUCE_ADJUSTMENT_FLAG
1945 , REDUCE_RETIREMENT_FLAG
1946 , RECOGNIZE_GAIN_LOSS
1947 , RECAPTURE_RESERVE_FLAG
1948 , LIMIT_PROCEEDS_FLAG
1949 , TERMINAL_GAIN_LOSS
1950 , TRACKING_METHOD
1951 , EXCLUDE_FULLY_RSV_FLAG
1952 , EXCESS_ALLOCATION_OPTION
1953 , DEPRECIATION_OPTION
1954 , MEMBER_ROLLUP_FLAG
1955 , ALLOCATE_TO_FULLY_RSV_FLAG
1956 , ALLOCATE_TO_FULLY_RET_FLAG
1957 , TERMINAL_GAIN_LOSS_AMOUNT
1958 , CIP_COST
1959 , YTD_PROCEEDS
1960 , LTD_PROCEEDS
1961 , LTD_COST_OF_REMOVAL
1962 , t_eofy_reserve(i) --EOFY_RESERVE
1963 , PRIOR_EOFY_RESERVE
1964 , EOP_ADJ_COST
1965 , EOP_FORMULA_FACTOR
1966 , EXCLUDE_PROCEEDS_FROM_BASIS
1967 , RETIREMENT_DEPRN_OPTION
1968 , TERMINAL_GAIN_LOSS_FLAG
1969 , SUPER_GROUP_ID
1970 , OVER_DEPRECIATE_OPTION
1971 , DISABLED_FLAG
1972 , CASH_GENERATING_UNIT_ID
1973 FROM FA_MC_BOOKS
1974 WHERE TRANSACTION_HEADER_ID_IN = t_old_thid(i)
1975 and SET_OF_BOOKS_ID = p_set_of_books_id ;
1976
1977 else
1978 if (p_log_level_rec.statement_level) then
1979 fa_debug_pkg.add(l_calling_fn,'Inserting record into ', 'FA_BOOKS', p_log_level_rec => p_log_level_rec);
1980 end if;
1981
1982 FORALL i in 1..t_request_id.count
1983 INSERT INTO FA_BOOKS( BOOK_TYPE_CODE
1984 , ASSET_ID
1985 , DATE_PLACED_IN_SERVICE
1986 , DATE_EFFECTIVE
1987 , DEPRN_START_DATE
1988 , DEPRN_METHOD_CODE
1989 , LIFE_IN_MONTHS
1990 , RATE_ADJUSTMENT_FACTOR
1991 , ADJUSTED_COST
1992 , COST
1993 , ORIGINAL_COST
1994 , SALVAGE_VALUE
1995 , PRORATE_CONVENTION_CODE
1996 , PRORATE_DATE
1997 , COST_CHANGE_FLAG
1998 , ADJUSTMENT_REQUIRED_STATUS
1999 , CAPITALIZE_FLAG
2000 , RETIREMENT_PENDING_FLAG
2001 , DEPRECIATE_FLAG
2002 , LAST_UPDATE_DATE
2003 , LAST_UPDATED_BY
2004 , TRANSACTION_HEADER_ID_IN
2005 , ITC_AMOUNT_ID
2006 , ITC_AMOUNT
2007 , RETIREMENT_ID
2008 , TAX_REQUEST_ID
2009 , ITC_BASIS
2010 , BASIC_RATE
2011 , ADJUSTED_RATE
2012 , BONUS_RULE
2013 , CEILING_NAME
2014 , RECOVERABLE_COST
2015 , ADJUSTED_CAPACITY
2016 , FULLY_RSVD_REVALS_COUNTER
2017 , IDLED_FLAG
2018 , PERIOD_COUNTER_CAPITALIZED
2019 , PERIOD_COUNTER_FULLY_RESERVED
2020 , PERIOD_COUNTER_FULLY_RETIRED
2021 , PRODUCTION_CAPACITY
2022 , REVAL_AMORTIZATION_BASIS
2023 , REVAL_CEILING
2024 , UNIT_OF_MEASURE
2025 , UNREVALUED_COST
2026 , ANNUAL_DEPRN_ROUNDING_FLAG
2027 , PERCENT_SALVAGE_VALUE
2028 , ALLOWED_DEPRN_LIMIT
2029 , ALLOWED_DEPRN_LIMIT_AMOUNT
2030 , PERIOD_COUNTER_LIFE_COMPLETE
2031 , ADJUSTED_RECOVERABLE_COST
2032 , ANNUAL_ROUNDING_FLAG
2033 , GLOBAL_ATTRIBUTE1
2034 , GLOBAL_ATTRIBUTE2
2035 , GLOBAL_ATTRIBUTE3
2036 , GLOBAL_ATTRIBUTE4
2037 , GLOBAL_ATTRIBUTE5
2038 , GLOBAL_ATTRIBUTE6
2039 , GLOBAL_ATTRIBUTE7
2040 , GLOBAL_ATTRIBUTE8
2041 , GLOBAL_ATTRIBUTE9
2042 , GLOBAL_ATTRIBUTE10
2043 , GLOBAL_ATTRIBUTE11
2044 , GLOBAL_ATTRIBUTE12
2045 , GLOBAL_ATTRIBUTE13
2046 , GLOBAL_ATTRIBUTE14
2047 , GLOBAL_ATTRIBUTE15
2048 , GLOBAL_ATTRIBUTE16
2049 , GLOBAL_ATTRIBUTE17
2050 , GLOBAL_ATTRIBUTE18
2051 , GLOBAL_ATTRIBUTE19
2052 , GLOBAL_ATTRIBUTE20
2053 , GLOBAL_ATTRIBUTE_CATEGORY
2054 , EOFY_ADJ_COST
2055 , EOFY_FORMULA_FACTOR
2056 , SHORT_FISCAL_YEAR_FLAG
2057 , CONVERSION_DATE
2058 , ORIGINAL_DEPRN_START_DATE
2059 , REMAINING_LIFE1
2060 , REMAINING_LIFE2
2061 , OLD_ADJUSTED_COST
2062 , FORMULA_FACTOR
2063 , GROUP_ASSET_ID
2064 , SALVAGE_TYPE
2065 , DEPRN_LIMIT_TYPE
2066 , REDUCTION_RATE
2067 , REDUCE_ADDITION_FLAG
2068 , REDUCE_ADJUSTMENT_FLAG
2069 , REDUCE_RETIREMENT_FLAG
2070 , RECOGNIZE_GAIN_LOSS
2071 , RECAPTURE_RESERVE_FLAG
2072 , LIMIT_PROCEEDS_FLAG
2073 , TERMINAL_GAIN_LOSS
2074 , TRACKING_METHOD
2075 , EXCLUDE_FULLY_RSV_FLAG
2076 , EXCESS_ALLOCATION_OPTION
2077 , DEPRECIATION_OPTION
2078 , MEMBER_ROLLUP_FLAG
2079 , ALLOCATE_TO_FULLY_RSV_FLAG
2080 , ALLOCATE_TO_FULLY_RET_FLAG
2081 , TERMINAL_GAIN_LOSS_AMOUNT
2082 , CIP_COST
2083 , YTD_PROCEEDS
2084 , LTD_PROCEEDS
2085 , LTD_COST_OF_REMOVAL
2086 , EOFY_RESERVE
2087 , PRIOR_EOFY_RESERVE
2088 , EOP_ADJ_COST
2089 , EOP_FORMULA_FACTOR
2090 , EXCLUDE_PROCEEDS_FROM_BASIS
2091 , RETIREMENT_DEPRN_OPTION
2092 , TERMINAL_GAIN_LOSS_FLAG
2093 , SUPER_GROUP_ID
2094 , OVER_DEPRECIATE_OPTION
2095 , DISABLED_FLAG
2096 , CASH_GENERATING_UNIT_ID
2097 , RATE_IN_USE
2098 , NBV_AT_SWITCH
2099 , PRIOR_ADJUSTED_RATE
2100 , PRIOR_BASIC_RATE
2101 , PRIOR_LIFE_IN_MONTHS
2102 , PRIOR_DEPRN_METHOD
2103 , PRIOR_DEPRN_LIMIT
2104 , PRIOR_DEPRN_LIMIT_AMOUNT
2105 , PRIOR_DEPRN_LIMIT_TYPE
2106 , EXTENDED_DEPRECIATION_PERIOD
2107 , EXTENDED_DEPRN_FLAG
2108 , PERIOD_COUNTER_FULLY_EXTENDED
2109 ) SELECT BOOK_TYPE_CODE
2110 , ASSET_ID
2111 , DATE_PLACED_IN_SERVICE
2112 , t_creation_date(i) -- DATE_EFFECTIVE
2113 , DEPRN_START_DATE
2114 , DEPRN_METHOD_CODE
2115 , LIFE_IN_MONTHS
2116 , t_new_raf(i) --RATE_ADJUSTMENT_FACTOR
2117 , t_new_adj_cost(i) -- ADJUSTED_COST
2118 , COST
2119 , ORIGINAL_COST
2120 , SALVAGE_VALUE
2121 , PRORATE_CONVENTION_CODE
2122 , PRORATE_DATE
2123 , COST_CHANGE_FLAG
2124 , ADJUSTMENT_REQUIRED_STATUS
2125 , CAPITALIZE_FLAG
2126 , RETIREMENT_PENDING_FLAG
2127 , DEPRECIATE_FLAG
2128 , t_creation_date(i) -- LAST_UPDATE_DATE
2129 , t_created_by(i) -- LAST_UPDATED_BY
2130 , t_thid(i) -- TRANSACTION_HEADER_ID_IN
2131 , ITC_AMOUNT_ID
2132 , ITC_AMOUNT
2133 , RETIREMENT_ID
2134 , TAX_REQUEST_ID
2135 , ITC_BASIS
2136 , BASIC_RATE
2137 , ADJUSTED_RATE
2138 , BONUS_RULE
2139 , CEILING_NAME
2140 , RECOVERABLE_COST
2141 , ADJUSTED_CAPACITY
2142 , FULLY_RSVD_REVALS_COUNTER
2143 , IDLED_FLAG
2144 , PERIOD_COUNTER_CAPITALIZED
2145 , t_period_counter_fully_rsv(i) -- phase5 decode(sign(t_new_adj_cost(i)-t_allowed_deprn_limit_amount(i)), 1, null, p_period_rec.period_counter) --PERIOD_COUNTER_FULLY_RESERVED
2146 , PERIOD_COUNTER_FULLY_RETIRED
2147 , PRODUCTION_CAPACITY
2148 , t_reval_reserve(i)
2149 , REVAL_CEILING
2150 , UNIT_OF_MEASURE
2151 , UNREVALUED_COST
2152 , 'ADJ'
2153 , PERCENT_SALVAGE_VALUE
2154 , ALLOWED_DEPRN_LIMIT
2155 , ALLOWED_DEPRN_LIMIT_AMOUNT
2156 , t_period_counter_life_complete(i) -- phase5 decode(sign(t_new_adj_cost(i) - t_allowed_deprn_limit_amount(i)), 1, null, p_period_rec.period_counter) --PERIOD_COUNTER_LIFE_COMPLETE
2157 , ADJUSTED_RECOVERABLE_COST
2158 , ANNUAL_ROUNDING_FLAG
2159 , GLOBAL_ATTRIBUTE1
2160 , GLOBAL_ATTRIBUTE2
2161 , GLOBAL_ATTRIBUTE3
2162 , GLOBAL_ATTRIBUTE4
2163 , GLOBAL_ATTRIBUTE5
2164 , GLOBAL_ATTRIBUTE6
2165 , GLOBAL_ATTRIBUTE7
2166 , GLOBAL_ATTRIBUTE8
2167 , GLOBAL_ATTRIBUTE9
2168 , GLOBAL_ATTRIBUTE10
2169 , GLOBAL_ATTRIBUTE11
2170 , GLOBAL_ATTRIBUTE12
2171 , GLOBAL_ATTRIBUTE13
2172 , GLOBAL_ATTRIBUTE14
2173 , GLOBAL_ATTRIBUTE15
2174 , GLOBAL_ATTRIBUTE16
2175 , GLOBAL_ATTRIBUTE17
2176 , GLOBAL_ATTRIBUTE18
2177 , GLOBAL_ATTRIBUTE19
2178 , GLOBAL_ATTRIBUTE20
2179 , GLOBAL_ATTRIBUTE_CATEGORY
2180 , EOFY_ADJ_COST
2181 , EOFY_FORMULA_FACTOR
2182 , SHORT_FISCAL_YEAR_FLAG
2183 , CONVERSION_DATE
2184 , ORIGINAL_DEPRN_START_DATE
2185 , REMAINING_LIFE1
2186 , REMAINING_LIFE2
2187 , OLD_ADJUSTED_COST
2188 , t_new_formula_factor(i) --FORMULA_FACTOR
2189 , GROUP_ASSET_ID
2190 , SALVAGE_TYPE
2191 , DEPRN_LIMIT_TYPE
2192 , REDUCTION_RATE
2193 , REDUCE_ADDITION_FLAG
2194 , REDUCE_ADJUSTMENT_FLAG
2195 , REDUCE_RETIREMENT_FLAG
2196 , RECOGNIZE_GAIN_LOSS
2197 , RECAPTURE_RESERVE_FLAG
2198 , LIMIT_PROCEEDS_FLAG
2199 , TERMINAL_GAIN_LOSS
2200 , TRACKING_METHOD
2201 , EXCLUDE_FULLY_RSV_FLAG
2202 , EXCESS_ALLOCATION_OPTION
2203 , DEPRECIATION_OPTION
2204 , MEMBER_ROLLUP_FLAG
2205 , ALLOCATE_TO_FULLY_RSV_FLAG
2206 , ALLOCATE_TO_FULLY_RET_FLAG
2207 , TERMINAL_GAIN_LOSS_AMOUNT
2208 , CIP_COST
2209 , YTD_PROCEEDS
2210 , LTD_PROCEEDS
2211 , LTD_COST_OF_REMOVAL
2212 , t_eofy_reserve(i) --EOFY_RESERVE
2213 , PRIOR_EOFY_RESERVE
2214 , EOP_ADJ_COST
2215 , EOP_FORMULA_FACTOR
2216 , EXCLUDE_PROCEEDS_FROM_BASIS
2217 , RETIREMENT_DEPRN_OPTION
2218 , TERMINAL_GAIN_LOSS_FLAG
2219 , SUPER_GROUP_ID
2220 , OVER_DEPRECIATE_OPTION
2221 , DISABLED_FLAG
2222 , CASH_GENERATING_UNIT_ID
2223 , t_rate_in_use(i)
2224 , t_nbv_at_switch(i) --phase5
2225 , PRIOR_ADJUSTED_RATE
2226 , PRIOR_BASIC_RATE
2227 , PRIOR_LIFE_IN_MONTHS
2228 , PRIOR_DEPRN_METHOD
2229 , PRIOR_DEPRN_LIMIT
2230 , PRIOR_DEPRN_LIMIT_AMOUNT
2231 , PRIOR_DEPRN_LIMIT_TYPE
2232 , EXTENDED_DEPRECIATION_PERIOD
2233 , EXTENDED_DEPRN_FLAG
2234 , t_period_counter_fully_ext(i) --bug 9786860
2235 FROM FA_BOOKS
2236 WHERE TRANSACTION_HEADER_ID_IN = t_old_thid(i);
2237 end if;
2238
2239 if (p_log_level_rec.statement_level) then
2240 fa_debug_pkg.add(l_calling_fn,'Reached Commit ', ' ', p_log_level_rec => p_log_level_rec);
2241 end if;
2242
2243 -- COMMIT;
2244
2245
2246 END LOOP; -- Outer Loop
2247
2248 --
2249 --
2250
2251 if (p_log_level_rec.statement_level) then
2252 fa_debug_pkg.add(l_calling_fn,'Process Posting', 'END', p_log_level_rec => p_log_level_rec);
2253 end if;
2254
2255 return true;
2256
2257 EXCEPTION
2258 WHEN pos_err THEN
2259
2260 if (p_log_level_rec.statement_level) then
2261 fa_debug_pkg.add(l_calling_fn,'EXCEPTION', 'pos_err', p_log_level_rec => p_log_level_rec);
2262 fa_debug_pkg.add(l_calling_fn,'sqlerrm', substrb(sqlerrm, 1, 200));
2263 end if;
2264
2265 return false;
2266
2267 WHEN OTHERS THEN
2268
2269 if (p_log_level_rec.statement_level) then
2270 fa_debug_pkg.add(l_calling_fn,'EXCEPTION', 'OTHERS', p_log_level_rec => p_log_level_rec);
2271 fa_debug_pkg.add(l_calling_fn,'sqlerrm', substrb(sqlerrm, 1, 200));
2272 end if;
2273
2274 return false;
2275
2276 END process_post;
2277
2278 FUNCTION call_deprn_basis(
2279 p_asset_hdr_rec IN fa_api_types.asset_hdr_rec_type
2280 , p_trans_rec IN fa_api_types.trans_rec_type
2281 , p_period_rec IN fa_api_types.period_rec_type
2282 , p_asset_type_rec IN fa_api_types.asset_type_rec_type
2283 , p_asset_fin_rec IN fa_api_types.asset_fin_rec_type
2284 , p_asset_deprn_rec IN fa_api_types.asset_deprn_rec_type
2285 , p_asset_desc_rec IN fa_api_types.asset_desc_rec_type
2286 , x_new_raf OUT NOCOPY NUMBER
2287 , x_new_formula_factor OUT NOCOPY NUMBER
2288 , x_new_adjusted_cost OUT NOCOPY NUMBER
2289 , p_mrc_sob_type_code IN VARCHAR2
2290 , p_calling_fn IN VARCHAR2
2291 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) RETURN BOOLEAN IS
2292
2293 l_calling_fn varchar2(60) := 'fa_process_impairment_pvt.call_deprn_basis';
2294
2295 CURSOR c_get_next_period is
2296 SELECT cp.start_date
2297 , cp.end_date
2298 , cp.period_name
2299 , cp.period_num
2300 , fy.fiscal_year
2301 , fy.start_date
2302 , fy.end_date
2303 FROM fa_calendar_periods cp,
2304 fa_deprn_periods dp,
2305 fa_fiscal_year fy
2306 WHERE dp.book_type_code = p_asset_hdr_rec.book_type_code
2307 AND dp.period_counter = p_period_rec.period_counter
2308 AND cp.calendar_type = fa_cache_pkg.fazcbc_record.deprn_calendar
2309 AND cp.start_date = dp.calendar_period_close_date + 1
2310 AND fy.fiscal_year_name = fa_cache_pkg.fazcbc_record.fiscal_year_name
2311 AND cp.start_date between fy.start_date and fy.end_date;
2312
2313
2314 l_asset_fin_rec_new fa_api_types.asset_fin_rec_type;
2315 l_period_rec fa_api_types.period_rec_type; -- This holds info about next period
2316
2317 --++++++++ variables for manual override ++++++++
2318 l_rate_source_rule VARCHAR2(25);
2319 l_deprn_basis_rule VARCHAR2(25);
2320
2321 --+++++++++++++++ For calling faxcde +++++++++++++++
2322 l_dpr_in FA_STD_TYPES.dpr_struct;
2323 l_dpr_out FA_STD_TYPES.dpr_out_struct;
2324 l_dpr_arr FA_STD_TYPES.dpr_arr_type;
2325 l_running_mode NUMBER;
2326
2327 l_deprn_reserve NUMBER;
2328 l_temp_integer BINARY_INTEGER;
2329 l_temp_number number;
2330
2331 l_eofy_rec_cost number;
2332 l_eofy_sal_val number;
2333 l_eop_rec_cost number;
2334 l_eop_sal_val number;
2335
2336 db_err exception;
2337
2338 BEGIN
2339
2340 if (p_log_level_rec.statement_level) then
2341 fa_debug_pkg.add(l_calling_fn, 'Begin', p_asset_hdr_rec.asset_id, p_log_level_rec => p_log_level_rec);
2342 end if;
2343
2344 l_period_rec.period_counter := p_period_rec.period_counter + 1;
2345
2346 OPEN c_get_next_period;
2347 FETCH c_get_next_period INTO l_period_rec.calendar_period_open_date
2348 , l_period_rec.calendar_period_close_date
2349 , l_period_rec.period_name
2350 , l_period_rec.period_num
2351 , l_period_rec.fiscal_year
2352 , l_period_rec.fy_start_date
2353 , l_period_rec.fy_end_date;
2354 CLOSE c_get_next_period;
2355
2356 l_period_rec.period_open_date := sysdate;
2357
2358 -- Setting 0s to avoid calling FA_CALC_DEPRN_BASIS1_PKG.GET_EOFY_EOP
2359 -- This should not be necessary for specific deprn basis rules which
2360 -- should be used only with some type of group assets
2361 l_eofy_rec_cost := 0;
2362 l_eofy_sal_val := 0;
2363 l_eop_rec_cost := 0;
2364 l_eop_sal_val := 0;
2365
2366 -- Populate fin rec
2367 l_asset_fin_rec_new := p_asset_fin_rec;
2368
2369 -- populate period rec for next period
2370
2371 if (not FA_CACHE_PKG.fazccmt
2372 (l_asset_fin_rec_new.deprn_method_code,
2373 l_asset_fin_rec_new.life_in_months, p_log_level_rec => p_log_level_rec)) then
2374 FA_SRVR_MSG.ADD_MESSAGE(CALLING_FN => 'FA_AMORT_PKG.faxraf', p_log_level_rec => p_log_level_rec);
2375 return FALSE;
2376 end if;
2377
2378 if (not fa_cache_pkg.fazccmt
2379 (l_asset_fin_rec_new.deprn_method_code,
2380 l_asset_fin_rec_new.life_in_months, p_log_level_rec => p_log_level_rec)) then
2381 FA_SRVR_MSG.ADD_MESSAGE(CALLING_FN => 'FA_AMORT_PKG.faxraf', p_log_level_rec => p_log_level_rec);
2382 return FALSE;
2383 end if;
2384
2385 -- Skipping call to faxcde because it is unnecessary for flat-cost with period end balance,
2386 -- use recoverable cost, period average, and beginning balance basis rules
2387 -- There are more cases which calling this function unnecessary but not include for this time.
2388 if (not(((fa_cache_pkg.fazccmt_record.rate_source_rule = fa_std_types.FAD_RSR_FLAT) and
2389 (fa_cache_pkg.fazccmt_record.deprn_basis_rule = fa_std_types.FAD_DBR_COST) and
2390 (fa_cache_pkg.fazcdbr_record.rule_name in ('PERIOD END BALANCE', 'PERIOD END AVERAGE',
2391 'USE RECOVERABLE COST', 'BEGINNING PERIOD')) or
2392 fa_cache_pkg.fazccmt_record.rate_source_rule = fa_std_types.FAD_RSR_PROD))) then
2393
2394 l_dpr_in.asset_num := p_asset_desc_rec.asset_number;
2395 l_dpr_in.calendar_type := fa_cache_pkg.fazcbc_record.deprn_calendar;
2396 l_dpr_in.book := p_asset_hdr_rec.book_type_code;
2397 l_dpr_in.asset_id := p_asset_hdr_rec.asset_id;
2398 l_dpr_in.adj_cost := l_asset_fin_rec_new.recoverable_cost;
2399 l_dpr_in.rec_cost := l_asset_fin_rec_new.recoverable_cost;
2400 l_dpr_in.reval_amo_basis := l_asset_fin_rec_new.reval_amortization_basis;
2401 l_dpr_in.deprn_rsv := 0;
2402 l_dpr_in.reval_rsv := p_asset_deprn_rec.reval_deprn_reserve;
2403 l_dpr_in.adj_rate := l_asset_fin_rec_new.adjusted_rate;
2404 l_dpr_in.rate_adj_factor := l_asset_fin_rec_new.rate_adjustment_factor;
2405 l_dpr_in.capacity := l_asset_fin_rec_new.production_capacity;
2406 l_dpr_in.adj_capacity := l_asset_fin_rec_new.adjusted_capacity;
2407 l_dpr_in.ltd_prod := 0;
2408
2409 l_dpr_in.ceil_name := l_asset_fin_rec_new.ceiling_name;
2410 l_dpr_in.bonus_rule := l_asset_fin_rec_new.bonus_rule;
2411 l_dpr_in.method_code := l_asset_fin_rec_new.deprn_method_code;
2412 l_dpr_in.jdate_in_service :=
2413 to_number(to_char(l_asset_fin_rec_new.date_placed_in_service, 'J'));
2414 l_dpr_in.prorate_jdate := to_number(to_char(l_asset_fin_rec_new.prorate_date, 'J'));
2415 l_dpr_in.deprn_start_jdate := to_number(to_char(l_asset_fin_rec_new.deprn_start_date, 'J'));
2416 l_dpr_in.jdate_retired := 0; -- don't know this is correct or not
2417 l_dpr_in.ret_prorate_jdate := 0; -- don't know this is correct or not
2418 l_dpr_in.life := l_asset_fin_rec_new.life_in_months;
2419
2420 l_dpr_in.rsv_known_flag := TRUE;
2421 l_dpr_in.salvage_value := l_asset_fin_rec_new.salvage_value;
2422 l_dpr_in.pc_life_end := l_asset_fin_rec_new.period_counter_life_complete;
2423 l_dpr_in.adj_rec_cost := l_asset_fin_rec_new.adjusted_recoverable_cost;
2424 l_dpr_in.prior_fy_exp := p_asset_deprn_rec.prior_fy_expense;
2425 l_dpr_in.deprn_rounding_flag := l_asset_fin_rec_new.annual_deprn_rounding_flag;
2426 l_dpr_in.deprn_override_flag := p_trans_rec.deprn_override_flag;
2427 l_dpr_in.used_by_adjustment := TRUE;
2428 l_dpr_in.ytd_deprn := p_asset_deprn_rec.ytd_deprn;
2429 l_dpr_in.short_fiscal_year_flag := l_asset_fin_rec_new.short_fiscal_year_flag;
2430 l_dpr_in.conversion_date := l_asset_fin_rec_new.conversion_date;
2431 l_dpr_in.prorate_date := l_asset_fin_rec_new.prorate_date;
2432 l_dpr_in.orig_deprn_start_date := l_asset_fin_rec_new.orig_deprn_start_date;
2433 l_dpr_in.old_adj_cost := l_asset_fin_rec_new.old_adjusted_cost;
2434 l_dpr_in.formula_factor := l_asset_fin_rec_new.formula_factor;
2435 l_dpr_in.bonus_deprn_exp := p_asset_deprn_rec.bonus_deprn_amount;
2436 l_dpr_in.bonus_ytd_deprn := p_asset_deprn_rec.bonus_ytd_deprn;
2437 l_dpr_in.bonus_deprn_rsv := p_asset_deprn_rec.bonus_deprn_reserve;
2438 l_dpr_in.prior_fy_bonus_exp := p_asset_deprn_rec.prior_fy_bonus_expense;
2439
2440 l_dpr_in.tracking_method := l_asset_fin_rec_new.tracking_method;
2441 l_dpr_in.allocate_to_fully_ret_flag := l_asset_fin_rec_new.allocate_to_fully_ret_flag;
2442 l_dpr_in.allocate_to_fully_rsv_flag := l_asset_fin_rec_new.allocate_to_fully_rsv_flag;
2443 l_dpr_in.excess_allocation_option := l_asset_fin_rec_new.excess_allocation_option;
2444 l_dpr_in.depreciation_option := l_asset_fin_rec_new.depreciation_option;
2445 l_dpr_in.member_rollup_flag := l_asset_fin_rec_new.member_rollup_flag;
2446 l_dpr_in.over_depreciate_option := l_asset_fin_rec_new.over_depreciate_option;
2447 l_dpr_in.mrc_sob_type_code := p_mrc_sob_type_code;
2448 l_dpr_in.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
2449
2450 --
2451 -- Not for what-if yet
2452 --
2453 l_running_mode := fa_std_types.FA_DPR_NORMAL;
2454
2455 if not fa_cache_pkg.fazcct(fa_cache_pkg.fazcbc_record.deprn_calendar, p_log_level_rec => p_log_level_rec) then
2456 if (p_log_level_rec.statement_level) then
2457 fa_debug_pkg.add(l_calling_fn, 'Error calling', 'fa_cache_pkg.fazcct', p_log_level_rec => p_log_level_rec);
2458 end if;
2459
2460 raise db_err;
2461 end if;
2462
2463 if not fa_cache_pkg.fazccp(fa_cache_pkg.fazcbc_record.prorate_calendar,
2464 fa_cache_pkg.fazcbc_record.fiscal_year_name,
2465 l_dpr_in.prorate_jdate,
2466 l_temp_number,
2467 l_dpr_in.y_begin,
2468 l_temp_integer, p_log_level_rec => p_log_level_rec) then
2469 if (p_log_level_rec.statement_level) then
2470 fa_debug_pkg.add(l_calling_fn, 'Error calling',
2471 'fa_cache_pkg.fazccp', p_log_level_rec => p_log_level_rec);
2472 fa_debug_pkg.add(l_calling_fn, 'fa_cache_pkg.fazcbc_record.prorate_calendar',
2473 fa_cache_pkg.fazcbc_record.prorate_calendar, p_log_level_rec => p_log_level_rec);
2474 fa_debug_pkg.add(l_calling_fn, 'fa_cache_pkg.fazcbc_record.fiscal_year_name',
2475 fa_cache_pkg.fazcbc_record.fiscal_year_name, p_log_level_rec => p_log_level_rec);
2476 end if;
2477
2478 raise db_err;
2479 end if;
2480
2481 l_dpr_in.p_cl_begin := 1;
2482
2483 if (p_log_level_rec.statement_level) then
2484 fa_debug_pkg.add(l_calling_fn, 'number_per_fiscal_year',
2485 fa_cache_pkg.fazcct_record.number_per_fiscal_year, p_log_level_rec => p_log_level_rec);
2486 fa_debug_pkg.add(l_calling_fn, 'l_period_rec.period_num', l_period_rec.period_num, p_log_level_rec => p_log_level_rec);
2487 end if;
2488
2489 if (l_period_rec.period_num = 1) then
2490 l_dpr_in.y_end := l_period_rec.fiscal_year - 1;
2491 l_dpr_in.p_cl_end := fa_cache_pkg.fazcct_record.number_per_fiscal_year;
2492 else
2493 l_dpr_in.y_end := l_period_rec.fiscal_year;
2494 l_dpr_in.p_cl_end := l_period_rec.period_num - 1;
2495 end if;
2496
2497 if (p_log_level_rec.statement_level) then
2498 fa_debug_pkg.add(l_calling_fn, 'l_dpr_in.p_cl_end', l_dpr_in.p_cl_end, p_log_level_rec => p_log_level_rec);
2499 end if;
2500
2501 l_dpr_in.rate_adj_factor := 1;
2502
2503 -- manual override
2504 if fa_cache_pkg.fa_deprn_override_enabled then
2505 if (not fa_cache_pkg.fazccmt(
2506 l_asset_fin_rec_new.deprn_method_code,
2507 l_asset_fin_rec_new.life_in_months, p_log_level_rec => p_log_level_rec)) then
2508 if (p_log_level_rec.statement_level) then
2509 fa_debug_pkg.add(l_calling_fn, 'Error calling',
2510 'fa_cache_pkg.fazccmt', p_log_level_rec => p_log_level_rec);
2511 end if;
2512
2513 raise db_err;
2514 end if;
2515
2516 l_rate_source_rule := fa_cache_pkg.fazccmt_record.rate_source_rule;
2517 l_deprn_basis_rule := fa_cache_pkg.fazccmt_record.deprn_basis_rule;
2518
2519 -- update override status only if satisfies condintion,
2520 -- otherwise do not update status when calculating RAF
2521 -- 1. formula; or
2522 -- 2. (calc or table) and cost
2523
2524 l_dpr_in.update_override_status :=
2525 ((l_rate_source_rule = fa_std_types.FAD_RSR_FORMULA)
2526 OR (((l_rate_source_rule = fa_std_types.FAD_RSR_CALC)
2527 OR (l_rate_source_rule = fa_std_types.FAD_RSR_TABLE))
2528 AND (l_deprn_basis_rule = fa_std_types.FAD_DBR_COST)));
2529 end if;
2530
2531 --+++++++ Call Depreciation engine for rate adjustment factor +++++++
2532 if not FA_CDE_PKG.faxcde(l_dpr_in,
2533 l_dpr_arr,
2534 l_dpr_out,
2535 l_running_mode, p_log_level_rec => p_log_level_rec) then
2536 if (p_log_level_rec.statement_level) then
2537 fa_debug_pkg.add(l_calling_fn, 'Error calling',
2538 'FA_CDE_PKG.faxcde', p_log_level_rec => p_log_level_rec);
2539 end if;
2540
2541 raise db_err;
2542 end if;
2543
2544 -- Bug 4129984.
2545
2546 if ((fa_cache_pkg.fazcbc_record.AMORTIZE_REVAL_RESERVE_FLAG='YES') and
2547 (l_asset_fin_rec_new.Reval_Amortization_Basis is not null) and
2548 (p_asset_type_rec.asset_type = 'CAPITALIZED') and
2549 (l_asset_fin_rec_new.group_asset_id is null)) then
2550
2551 l_asset_fin_rec_new.reval_amortization_basis := p_asset_deprn_rec.reval_deprn_reserve;
2552 end if;
2553
2554 else -- in the case of skipping faxcde call
2555 l_dpr_out.new_adj_cost := l_asset_fin_rec_new.recoverable_cost;
2556 l_dpr_out.new_deprn_rsv := p_asset_deprn_rec.deprn_reserve;
2557 l_dpr_out.new_bonus_deprn_rsv := p_asset_deprn_rec.bonus_deprn_reserve;
2558 end if;
2559
2560
2561
2562 -- code fix for bug no.3630495. added the following line to calculate the adjusted capacity
2563 if (nvl(l_asset_fin_rec_new.tracking_method, 'NO TRACK') = 'ALLOCATE') and -- ENERGY
2564 (fa_cache_pkg.fazcdrd_record.rule_name = 'ENERGY PERIOD END BALANCE') then -- ENERGY
2565 null;
2566 else
2567 l_asset_fin_rec_new.adjusted_capacity:=l_asset_fin_rec_new.production_capacity- nvl(l_dpr_out.new_ltd_prod, 0);
2568 end if;
2569
2570 if (p_asset_hdr_rec.period_of_addition = 'Y') and
2571 (p_asset_type_rec.asset_type = 'GROUP') then
2572 l_asset_fin_rec_new.eofy_reserve := nvl(l_asset_fin_rec_new.eofy_reserve,
2573 p_asset_deprn_rec.deprn_reserve -
2574 p_asset_deprn_rec.ytd_deprn);
2575 else
2576
2577 -- Fix for Bug#4541399: We have to activate this code
2578 -- only when l_asset_fin_rec_new.eofy_reserve is NULL
2579 if (l_asset_fin_rec_new.eofy_reserve is null) then
2580 l_asset_fin_rec_new.eofy_reserve := p_asset_deprn_rec.deprn_reserve -
2581 p_asset_deprn_rec.ytd_deprn;
2582 end if;
2583
2584 end if;
2585
2586 if (not FA_CALC_DEPRN_BASIS1_PKG.CALL_DEPRN_BASIS
2587 (p_event_type => 'AMORT_ADJ',
2588 p_asset_fin_rec_new => l_asset_fin_rec_new,
2589 p_asset_fin_rec_old => p_asset_fin_rec,
2590 p_asset_hdr_rec => p_asset_hdr_rec,
2591 p_asset_type_rec => p_asset_type_rec,
2592 p_asset_deprn_rec => p_asset_deprn_rec,
2593 p_trans_rec => p_trans_rec,
2594 p_trans_rec_adj => p_trans_rec,
2595 p_period_rec => l_period_rec,
2596 p_current_total_rsv => p_asset_deprn_rec.deprn_reserve,
2597 p_current_rsv => p_asset_deprn_rec.deprn_reserve -
2598 p_asset_deprn_rec.bonus_deprn_reserve,
2599 p_current_total_ytd => p_asset_deprn_rec.ytd_deprn,
2600 p_hyp_basis => l_dpr_out.new_adj_cost,
2601 p_hyp_total_rsv => l_dpr_out.new_deprn_rsv,
2602 p_hyp_rsv => l_dpr_out.new_deprn_rsv -
2603 l_dpr_out.new_bonus_deprn_rsv,
2604 p_eofy_recoverable_cost => l_eofy_rec_cost,
2605 p_eop_recoverable_cost => l_eop_rec_cost,
2606 p_eofy_salvage_value => l_eofy_sal_val,
2607 p_eop_salvage_value => l_eop_sal_val,
2608 p_mrc_sob_type_code => p_mrc_sob_type_code,
2609 p_used_by_adjustment => 'ADJUSTMENT',
2610 px_new_adjusted_cost => x_new_adjusted_cost,
2611 px_new_raf => x_new_raf,
2612 px_new_formula_factor => x_new_formula_factor, p_log_level_rec => p_log_level_rec)) then
2613 raise db_err;
2614 end if;
2615
2616 if (p_log_level_rec.statement_level) then
2617 fa_debug_pkg.add(l_calling_fn,'call_deprn_basis', 'END', p_log_level_rec => p_log_level_rec);
2618 end if;
2619
2620 return true;
2621
2622 EXCEPTION
2623 WHEN db_err THEN
2624
2625 if (p_log_level_rec.statement_level) then
2626 fa_debug_pkg.add(l_calling_fn,'EXCEPTION', 'pos_err', p_log_level_rec => p_log_level_rec);
2627 fa_debug_pkg.add(l_calling_fn,'sqlerrm', substrb(sqlerrm, 1, 200));
2628 end if;
2629
2630 return false;
2631
2632 WHEN OTHERS THEN
2633
2634 if (p_log_level_rec.statement_level) then
2635 fa_debug_pkg.add(l_calling_fn,'EXCEPTION', 'OTHERS', p_log_level_rec => p_log_level_rec);
2636 fa_debug_pkg.add(l_calling_fn,'sqlerrm', substrb(sqlerrm, 1, 200));
2637 end if;
2638
2639 return false;
2640 END call_deprn_basis;
2641
2642 FUNCTION create_cost_entries(
2643 p_asset_hdr_rec IN fa_api_types.asset_hdr_rec_type
2644 , p_trans_rec IN fa_api_types.trans_rec_type
2645 , p_period_rec IN fa_api_types.period_rec_type
2646 , p_asset_type_rec IN fa_api_types.asset_type_rec_type
2647 , p_cost IN NUMBER
2648 , p_current_units IN NUMBER
2649 , p_mrc_sob_type_code IN VARCHAR2
2650 , p_calling_fn IN VARCHAR2
2651 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type) RETURN BOOLEAN IS
2652
2653 l_calling_fn varchar2(60) := 'fa_impairment_post_pvt.create_cost_entries';
2654
2655 l_adj FA_ADJUST_TYPE_PKG.FA_ADJ_ROW_STRUCT;
2656
2657 cre_err exception;
2658 BEGIN
2659 if (p_log_level_rec.statement_level) then
2660 fa_debug_pkg.add(l_calling_fn,'Begin', p_asset_hdr_rec.asset_id, p_log_level_rec => p_log_level_rec);
2661 end if;
2662
2663 -- Initializing common variables
2664 l_adj.transaction_header_id := p_trans_rec.transaction_header_id;
2665 l_adj.asset_id := p_asset_hdr_rec.asset_id;
2666 l_adj.book_type_code := p_asset_hdr_rec.book_type_code;
2667 l_adj.period_counter_created := p_period_rec.period_counter;
2668 l_adj.period_counter_adjusted := p_period_rec.period_counter;
2669 l_adj.current_units := p_current_units;
2670 l_adj.selection_mode := FA_ADJUST_TYPE_PKG.FA_AJ_ACTIVE;
2671 l_adj.selection_retid := 0;
2672 l_adj.leveling_flag := TRUE;
2673 l_adj.flush_adj_flag := TRUE; --FALSE;
2674 l_adj.gen_ccid_flag := TRUE;
2675 l_adj.track_member_flag := null;
2676
2677 if p_asset_type_rec.asset_type = 'CIP' then
2678 l_adj.source_type_code := 'CIP ADDITION';
2679 l_adj.adjustment_type := 'CIP COST';
2680 l_adj.account_type := 'CIP_COST_ACCT';
2681 l_adj.account := fa_cache_pkg.fazccb_record.CIP_COST_ACCT;
2682 else
2683 l_adj.source_type_code := 'ADDITION';
2684 l_adj.adjustment_type := 'COST';
2685 l_adj.account_type := 'ASSET_COST_ACCT';
2686 l_adj.account := fa_cache_pkg.fazccb_record.ASSET_COST_ACCT;
2687 end if;
2688
2689 if p_cost > 0 then
2690 l_adj.debit_credit_flag := 'DR';
2691 l_adj.adjustment_amount := p_cost;
2692 else
2693 l_adj.debit_credit_flag := 'CR';
2694 l_adj.adjustment_amount := -p_cost;
2695 end if;
2696
2697 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
2698 l_adj.set_of_books_id := p_asset_hdr_rec.set_of_books_id;
2699
2700 if (p_log_level_rec.statement_level) then
2701 fa_debug_pkg.add(l_calling_fn,'calling faxinaj ', 'COST', p_log_level_rec => p_log_level_rec);
2702 end if;
2703
2704
2705 if not FA_INS_ADJUST_PKG.faxinaj
2706 (l_adj,
2707 p_trans_rec.who_info.last_update_date,
2708 p_trans_rec.who_info.last_updated_by,
2709 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
2710 raise cre_err;
2711 end if;
2712
2713 l_adj.adjustment_type := 'COST CLEARING';
2714
2715 if p_asset_type_rec.asset_type = 'CIP' then
2716 l_adj.account_type := 'CIP_CLEARING_ACCT';
2717 l_adj.account := fa_cache_pkg.fazccb_record.CIP_CLEARING_ACCT;
2718 else
2719 l_adj.account_type := 'ASSET_CLEARING_ACCT';
2720 l_adj.account := fa_cache_pkg.fazccb_record.ASSET_CLEARING_ACCT;
2721 end if;
2722
2723 if p_cost > 0 then
2724 l_adj.debit_credit_flag := 'CR';
2725 l_adj.adjustment_amount := p_cost;
2726 else
2727 l_adj.debit_credit_flag := 'DR';
2728 l_adj.adjustment_amount := -p_cost;
2729 end if;
2730
2731 l_adj.mrc_sob_type_code := p_mrc_sob_type_code;
2732
2733 if (p_log_level_rec.statement_level) then
2734 fa_debug_pkg.add(l_calling_fn,'calling faxinaj ', 'CLEARING', p_log_level_rec => p_log_level_rec);
2735 end if;
2736
2737 if not FA_INS_ADJUST_PKG.faxinaj
2738 (l_adj,
2739 p_trans_rec.who_info.last_update_date,
2740 p_trans_rec.who_info.last_updated_by,
2741 p_trans_rec.who_info.last_update_login, p_log_level_rec => p_log_level_rec) then
2742 raise cre_err;
2743 end if;
2744
2745
2746 if (p_log_level_rec.statement_level) then
2747 fa_debug_pkg.add(l_calling_fn,'End', p_asset_hdr_rec.asset_id, p_log_level_rec => p_log_level_rec);
2748 end if;
2749
2750 return true;
2751
2752 EXCEPTION
2753 WHEN cre_err THEN
2754
2755 if (p_log_level_rec.statement_level) then
2756 fa_debug_pkg.add(l_calling_fn,'EXCEPTION', 'cre_err', p_log_level_rec => p_log_level_rec);
2757 fa_debug_pkg.add(l_calling_fn,'sqlerrm', substrb(sqlerrm, 1, 200));
2758 end if;
2759
2760 return false;
2761
2762 WHEN OTHERS THEN
2763
2764 if (p_log_level_rec.statement_level) then
2765 fa_debug_pkg.add(l_calling_fn,'EXCEPTION', 'OTHERS', p_log_level_rec => p_log_level_rec);
2766 fa_debug_pkg.add(l_calling_fn,'sqlerrm', substrb(sqlerrm, 1, 200));
2767 end if;
2768
2769 return false;
2770
2771 END create_cost_entries;
2772
2773
2774 END FA_IMPAIRMENT_POST_PVT;